repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
charlie5/cBound
Ada
1,869
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_minmax_parameteriv_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 Interfaces.Integer_32; pad2 : aliased swig.int8_t_Array (0 .. 11); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_minmax_parameteriv_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_minmax_parameteriv_reply_t.Item, Element_Array => xcb.xcb_glx_get_minmax_parameteriv_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_minmax_parameteriv_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_minmax_parameteriv_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_minmax_parameteriv_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_minmax_parameteriv_reply_t;
AaronC98/PlaneSystem
Ada
3,800
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2017, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ -- This package is based on Tree_Reader from the XMLada package. It is used -- to create a DOM object using the SAX parser. with DOM.Core; with Sax.Readers; private with Sax.Attributes; private with Unicode.CES; private package SOAP.Message.Reader is use DOM.Core; type Tree_Reader is new Sax.Readers.Reader with private; -- Tree_Reader create a DOM tree using the SAX parser function Get_Tree (Read : Tree_Reader) return DOM.Core.Document; private type Tree_Reader is new Sax.Readers.Reader with record Tree : DOM.Core.Document; Current_Node : Node; Internal_Encoding : Unicode.CES.Encoding_Scheme; end record; overriding procedure Start_Document (Handler : in out Tree_Reader); overriding procedure Start_Element (Handler : in out Tree_Reader; Namespace_URI : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := ""; Atts : Sax.Attributes.Attributes'Class); overriding procedure End_Element (Handler : in out Tree_Reader; Namespace_URI : Unicode.CES.Byte_Sequence := ""; Local_Name : Unicode.CES.Byte_Sequence := ""; Qname : Unicode.CES.Byte_Sequence := ""); overriding procedure Characters (Handler : in out Tree_Reader; Ch : Unicode.CES.Byte_Sequence); overriding procedure Ignorable_Whitespace (Handler : in out Tree_Reader; Ch : Unicode.CES.Byte_Sequence); end SOAP.Message.Reader;
zyron92/banana_tree_generator
Ada
976
adb
with Parseur_Temp,Svg_Helpers,Ada.Text_IO, Ada.Integer_Text_IO; use Parseur_Temp,Svg_Helpers,Ada.Text_IO, Ada.Integer_Text_IO; procedure Test_Svg is Fichier : File_Type; P1: Coord_Point := (X=>-2.5, Y=>-4.33012701892219); P2: Coord_Point := (X=>-0.492608180923429, Y=>-6.55956149535438); begin Create(Fichier,Out_File,"test_svg_OK.svg"); Header(14.5190978224269,14.5190978224269,Fichier); Translation_Image(6.43444280220142,7.92820323027551,Fichier); Appliquer_Couleur_Epaisseur(True,0,0,0,"0.1",Fichier); Tracer_Ligne_Droite(P1,P2,Fichier); Fin_Couleur_Translation(Fichier); Appliquer_Couleur_Epaisseur(False,255,0,0,"0.1",Fichier); Tracer_Courbe(-1.49630409046171,-5.44484425713829,-1.41780015609729,-3.94689995500642,-1.66723373785405,-5.12039269405429,-1.1296818135361,-3.72002205430849, Fichier); Fin_Couleur_Translation(Fichier); Fin_Couleur_Translation(Fichier); Footer(Fichier); Close (Fichier); end Test_Svg;
PThierry/ewok-kernel
Ada
4,408
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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. -- -- #if CONFIG_KERNEL_DOMAIN with ewok.tasks; #end if; package body ewok.perm with spark_mode => on is function dmashm_is_granted (from : in t_real_task_id; to : in t_real_task_id) return boolean is begin return ewok.perm_auto.com_dmashm_perm (from, to); end dmashm_is_granted; function ipc_is_granted (from : in t_real_task_id; to : in t_real_task_id) return boolean is begin return ewok.perm_auto.com_ipc_perm (from, to); end ipc_is_granted; #if CONFIG_KERNEL_DOMAIN function is_same_domain (from : in t_real_task_id; to : in t_real_task_id) return boolean with spark_mode => off -- implies tasks.get_domain() to be SPARK compatible is begin return ewok.tasks.get_domain (from) = ewok.tasks.get_domain (to); end is_same_domain; #end if; function ressource_is_granted (perm_name : in t_perm_name; task_id : in applications.t_real_task_id) return boolean is begin -- is there some assertion checking that some ressources tuples are -- forbidden case perm_name is when PERM_RES_DEV_DMA => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_DMA = 1; when PERM_RES_DEV_CRYPTO_USR => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 1 or ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_CRYPTO_CFG => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 2 or ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_CRYPTO_FULL => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_CRYPTO = 3; when PERM_RES_DEV_BUSES => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_BUS = 1; when PERM_RES_DEV_EXTI => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_EXTI = 1; when PERM_RES_DEV_TIM => return ewok.perm_auto.ressource_perm_register_tab(task_id).DEV_TIM = 1; when PERM_RES_TIM_GETMILLI => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 0; when PERM_RES_TIM_GETMICRO => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 1; when PERM_RES_TIM_GETCYCLE => return ewok.perm_auto.ressource_perm_register_tab(task_id).TIM_TIME > 2; when PERM_RES_TSK_FISR => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FISR = 1; when PERM_RES_TSK_FIPC => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_FIPC = 1; when PERM_RES_TSK_RESET => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_RESET = 1; when PERM_RES_TSK_UPGRADE => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_UPGRADE = 1; when PERM_RES_TSK_RNG => return ewok.perm_auto.ressource_perm_register_tab(task_id).TSK_RNG = 1; when PERM_RES_MEM_DYNAMIC_MAP => return ewok.perm_auto.ressource_perm_register_tab(task_id).MEM_DYNAMIC_MAP = 1; end case; end ressource_is_granted; end ewok.perm;
ytomino/gnat4drake
Ada
282
ads
pragma License (Unrestricted); with System; package GNAT.Traceback is pragma Preelaborate; type Tracebacks_Array is array (Positive range <>) of System.Address; procedure Call_Chain ( Traceback : out Tracebacks_Array; Len : out Natural); end GNAT.Traceback;
tum-ei-rcs/StratoX
Ada
539
adb
with Units; use Units; package body Units.Navigation with SPARK_Mode is function foo return Heading_Type is result : Angle_Type; -- SPARK GPL 2016: everything okay. -- SPARK Pro 18.0w: error with DEGREE 360; remove "constant" and it works A : Angle_Type := DEGREE_360; begin return Heading_Type( result ); end foo; function bar return Length_Type is EPS : constant := 1.0E-12; pragma Assert (EPS > Float'Small); begin return 0.0*Meter; end bar; end Units.Navigation;
sungyeon/drake
Ada
24,491
adb
with Ada.Calendar.Naked; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Form_Parameters; with System.Storage_Elements; package body Ada.Directories is use type System.Native_Directories.File_Kind; use type System.Native_Directories.Searching.Handle_Type; use type System.Storage_Elements.Storage_Offset; subtype Directory_Entry_Information_Type is System.Native_Directories.Directory_Entry_Information_Type; procedure Free is new Unchecked_Deallocation (String, String_Access); function Pack_For_Copy_File (Form : String) return Boolean; function Pack_For_Copy_File (Form : String) return Boolean is Keyword_First : Positive; Keyword_Last : Natural; Item_First : Positive; Item_Last : Natural; Last : Natural; Overwrite : Boolean := True; -- default begin Last := Form'First - 1; while Last < Form'Last loop System.Form_Parameters.Get ( Form (Last + 1 .. Form'Last), Keyword_First, Keyword_Last, Item_First, Item_Last, Last); declare Keyword : String renames Form (Keyword_First .. Keyword_Last); Item : String renames Form (Item_First .. Item_Last); begin if Keyword = "overwrite" then if Item'Length > 0 and then Item (Item'First) = 'f' then Overwrite := False; -- false elsif Item'Length > 0 and then Item (Item'First) = 't' then Overwrite := True; -- true end if; elsif Keyword = "mode" then -- compatibility with GNAT runtime if Item'Length > 0 and then Item (Item'First) = 'c' then Overwrite := False; -- copy elsif Item'Length > 0 and then Item (Item'First) = 'o' then Overwrite := True; -- overwrite end if; end if; end; end loop; return Overwrite; end Pack_For_Copy_File; procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type); procedure Finalize (Object : in out Non_Controlled_Directory_Entry_Type) is begin if Object.Status = Detached then Free (Object.Path); System.Native_Directories.Searching.Free (Object.Directory_Entry); end if; end Finalize; procedure Assign ( Target : out Non_Controlled_Directory_Entry_Type; Source : Non_Controlled_Directory_Entry_Type); procedure Assign ( Target : out Non_Controlled_Directory_Entry_Type; Source : Non_Controlled_Directory_Entry_Type) is begin Target.Additional.Filled := False; Target.Status := Detached; Target.Path := new String'(Source.Path.all); Target.Directory_Entry := System.Native_Directories.Searching.New_Directory_Entry ( Source.Directory_Entry); end Assign; procedure End_Search ( Search : aliased in out Non_Controlled_Search_Type; Raise_On_Error : Boolean); procedure End_Search ( Search : aliased in out Non_Controlled_Search_Type; Raise_On_Error : Boolean) is begin Free (Search.Path); System.Native_Directories.Searching.End_Search ( Search.Search, Raise_On_Error => Raise_On_Error); end End_Search; procedure Get_Next_Entry ( Search : aliased in out Non_Controlled_Search_Type; Directory_Entry : in out Non_Controlled_Directory_Entry_Type); procedure Get_Next_Entry ( Search : aliased in out Non_Controlled_Search_Type; Directory_Entry : in out Non_Controlled_Directory_Entry_Type) is Has_Next : Boolean; begin System.Native_Directories.Searching.Get_Next_Entry ( Search.Search, Directory_Entry.Directory_Entry, Has_Next); if Has_Next then Directory_Entry.Additional.Filled := False; else Directory_Entry.Status := Empty; end if; end Get_Next_Entry; function Current (Object : Directory_Iterator) return Cursor; function Current (Object : Directory_Iterator) return Cursor is Listing : constant not null Directory_Listing_Access := Object.Listing; begin if not Is_Assigned ( Controlled_Searches.Next_Directory_Entry (Listing.Search).all) then -- call End_Search at this time, for propagating the exceptions. declare NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Listing.Search).all; begin End_Search (NC_Search, Raise_On_Error => True); end; return 0; -- No_Element else return Cursor (Listing.Count); end if; end Current; -- directory and file operations procedure Create_Directory ( New_Directory : String; Form : String) is pragma Unreferenced (Form); begin System.Native_Directories.Create_Directory (New_Directory); end Create_Directory; procedure Create_Directory ( New_Directory : String) is begin System.Native_Directories.Create_Directory (New_Directory); end Create_Directory; procedure Create_Path ( New_Directory : String; Form : String) is pragma Unreferenced (Form); begin Create_Path (New_Directory); end Create_Path; procedure Create_Path ( New_Directory : String) is I : Positive := New_Directory'Last + 1; begin while I > New_Directory'First loop declare P : Positive := I - 1; begin Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter ( New_Directory, Last => P); exit when Exists (New_Directory (New_Directory'First .. P)); declare S_First : Positive; S_Last : Natural; begin Hierarchical_File_Names.Simple_Name ( New_Directory (New_Directory'First .. P), First => S_First, Last => S_Last); I := S_First; end; end; end loop; while I <= New_Directory'Last loop declare R_First : Positive; R_Last : Natural; begin Hierarchical_File_Names.Relative_Name ( New_Directory (I .. New_Directory'Last), First => R_First, Last => R_Last); declare P : Natural := R_First - 1; begin Hierarchical_File_Names.Exclude_Trailing_Path_Delimiter ( New_Directory, Last => P); Create_Directory (New_Directory (New_Directory'First .. P)); end; I := R_First; end; end loop; end Create_Path; procedure Delete_Tree (Directory : String) is Search : aliased Search_Type; begin Start_Search (Search, Directory, "*", (others => True)); while More_Entries (Search) loop declare Directory_Entry : Directory_Entry_Type renames Look_Next_Entry (Search).Element.all; Name : constant String := Full_Name (Directory_Entry); begin case Kind (Directory_Entry) is when Ordinary_File | Special_File => Delete_File (Name); when Directories.Directory => Delete_Tree (Name); -- recursive end case; end; Skip_Next_Entry (Search); end loop; End_Search (Search); Delete_Directory (Directory); end Delete_Tree; procedure Copy_File ( Source_Name : String; Target_Name : String; Form : String) is begin System.Native_Directories.Copy_File ( Source_Name, Target_Name, Overwrite => Pack_For_Copy_File (Form)); end Copy_File; function Compose ( Containing_Directory : String := ""; Name : String; Extension : String := ""; Path_Delimiter : Hierarchical_File_Names.Path_Delimiter_Type := Hierarchical_File_Names.Default_Path_Delimiter) return String is pragma Check (Pre, Check => Containing_Directory'Length = 0 or else Hierarchical_File_Names.Is_Simple_Name (Name) or else raise Name_Error); -- RM A.16(82/3) begin return Hierarchical_File_Names.Compose ( Containing_Directory, Name, Extension, Path_Delimiter => Path_Delimiter); end Compose; -- file and directory queries function Kind (Name : String) return File_Kind is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); return File_Kind'Enum_Val ( System.Native_Directories.File_Kind'Enum_Rep ( System.Native_Directories.Kind (Information))); end Kind; function Size (Name : String) return File_Size is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); if System.Native_Directories.Kind (Information) /= System.Native_Directories.Ordinary_File then raise Constraint_Error; -- implementation-defined else return System.Native_Directories.Size (Information); end if; end Size; function Modification_Time (Name : String) return Calendar.Time is Information : aliased Directory_Entry_Information_Type; begin System.Native_Directories.Get_Information (Name, Information); return Calendar.Naked.To_Time ( System.Native_Directories.Modification_Time (Information)); end Modification_Time; procedure Set_Modification_Time (Name : String; Time : Calendar.Time) is begin System.Native_Directories.Set_Modification_Time ( Name, Calendar.Naked.To_Native_Time (Time)); end Set_Modification_Time; -- directory searching function Is_Assigned (Directory_Entry : Directory_Entry_Type) return Boolean is NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return NC_Directory_Entry.Status /= Empty; end Is_Assigned; package body Controlled_Entries is function Reference (Object : Directories.Directory_Entry_Type) return not null access Non_Controlled_Directory_Entry_Type is begin return Directory_Entry_Type (Object).Data'Unrestricted_Access; end Reference; overriding procedure Finalize (Object : in out Directory_Entry_Type) is begin Finalize (Object.Data); end Finalize; end Controlled_Entries; function Is_Open (Search : Search_Type) return Boolean is NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; begin return NC_Search.Search.Handle /= System.Native_Directories.Searching.Null_Handle; end Is_Open; procedure Start_Search ( Search : in out Search_Type; Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) is pragma Check (Pre, Check => not Is_Open (Search) or else raise Status_Error); function Cast is new Unchecked_Conversion ( Filter_Type, System.Native_Directories.Searching.Filter_Type); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; Has_Next : Boolean; begin NC_Search.Path := new String'(Full_Name (Directory)); declare NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; begin System.Native_Directories.Searching.Start_Search ( NC_Search.Search, Directory, Pattern, Cast (Filter), NC_Next_Directory_Entry.Directory_Entry, Has_Next); if Has_Next then NC_Next_Directory_Entry.Path := NC_Search.Path; NC_Next_Directory_Entry.Additional.Filled := False; NC_Next_Directory_Entry.Status := Attached; else NC_Next_Directory_Entry.Status := Empty; end if; end; end Start_Search; function Start_Search ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) return Search_Type is begin return Result : Search_Type do Start_Search (Result, Directory, Pattern, Filter); end return; end Start_Search; procedure End_Search (Search : in out Search_Type) is pragma Check (Pre, Is_Open (Search) or else raise Status_Error); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; begin End_Search (NC_Search, Raise_On_Error => True); end End_Search; function More_Entries ( Search : Search_Type) return Boolean is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); begin return Is_Assigned ( Controlled_Searches.Next_Directory_Entry (Search).all); end More_Entries; procedure Get_Next_Entry ( Search : in out Search_Type; Directory_Entry : out Directory_Entry_Type) is pragma Unmodified (Directory_Entry); -- modified via Reference pragma Check (Pre, Check => More_Entries (Search) -- checking the predicate or else raise Use_Error); -- RM A.16(110/3) NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin Finalize (NC_Directory_Entry); -- copy to the detached entry Assign (Target => NC_Directory_Entry, Source => NC_Next_Directory_Entry); -- search next Get_Next_Entry (NC_Search, NC_Next_Directory_Entry); end Get_Next_Entry; function Get_Next_Entry ( Search : aliased in out Search_Type) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do Get_Next_Entry (Search, Result); end return; end Get_Next_Entry; function Look_Next_Entry ( Search : aliased Search_Type) return Constant_Reference_Type is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); begin return (Element => Controlled_Searches.Next_Directory_Entry (Search)); end Look_Next_Entry; procedure Skip_Next_Entry ( Search : in out Search_Type) is pragma Check (Dynamic_Predicate, Check => Is_Open (Search) or else raise Status_Error); NC_Search : Non_Controlled_Search_Type renames Controlled_Searches.Reference (Search).all; NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Controlled_Searches.Next_Directory_Entry (Search).all).all; begin Get_Next_Entry (NC_Search, NC_Next_Directory_Entry); end Skip_Next_Entry; procedure Search ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True); Process : not null access procedure ( Directory_Entry : Directory_Entry_Type)) is Search : aliased Search_Type; begin Start_Search (Search, Directory, Pattern, Filter); while More_Entries (Search) loop Process (Look_Next_Entry (Search).Element.all); Skip_Next_Entry (Search); end loop; End_Search (Search); end Search; package body Controlled_Searches is function Reference (Object : Directories.Search_Type) return not null access Non_Controlled_Search_Type is begin return Search_Type (Object).Data'Unrestricted_Access; end Reference; function Next_Directory_Entry (Object : Directories.Search_Type) return not null access Directory_Entry_Type is begin return Search_Type (Object).Next_Directory_Entry'Unrestricted_Access; end Next_Directory_Entry; overriding procedure Finalize (Search : in out Search_Type) is begin if Search.Data.Search.Handle /= System.Native_Directories.Searching.Null_Handle then End_Search (Search.Data, Raise_On_Error => False); end if; end Finalize; end Controlled_Searches; -- directory iteration function Is_Open (Listing : Directory_Listing) return Boolean is begin return Is_Open (Listing.Search); end Is_Open; function Entries ( Directory : String; Pattern : String := "*"; Filter : Filter_Type := (others => True)) return Directory_Listing is begin return Result : Directory_Listing do Result.Count := 1; Start_Search (Result.Search, Directory, Pattern, Filter); end return; end Entries; function Has_Entry (Position : Cursor) return Boolean is begin return Position > 0; end Has_Entry; function Iterate ( Listing : Directory_Listing'Class) return Directory_Iterators.Forward_Iterator'Class is pragma Check (Dynamic_Predicate, Check => Is_Open (Directory_Listing (Listing)) or else raise Status_Error); begin return Directory_Iterator'(Listing => Listing'Unrestricted_Access); end Iterate; function Current_Entry ( Entries : Directory_Listing'Class; Position : Cursor) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do pragma Unmodified (Result); -- modified via Reference declare Source_Reference : constant Constant_Reference_Type := Constant_Reference (Directory_Listing (Entries), Position); -- checking the predicate and Position in Constant_Reference NC_Next_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference ( Source_Reference.Element.all) .all; NC_Result : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Result).all; begin Assign (Target => NC_Result, Source => NC_Next_Directory_Entry); end; end return; end Current_Entry; function Constant_Reference ( Container : aliased Directory_Listing; Position : Cursor) return Constant_Reference_Type is pragma Check (Dynamic_Predicate, Check => Is_Open (Container) or else raise Status_Error); pragma Check (Pre, Check => Integer (Position) = Container.Count or else raise Status_Error); begin return Look_Next_Entry (Container.Search); end Constant_Reference; overriding function First (Object : Directory_Iterator) return Cursor is pragma Check (Pre, Object.Listing.Count = 1 or else raise Status_Error); begin return Current (Object); end First; overriding function Next (Object : Directory_Iterator; Position : Cursor) return Cursor is pragma Check (Pre, Check => Integer (Position) = Object.Listing.Count or else raise Status_Error); Listing : constant not null Directory_Listing_Access := Object.Listing; begin -- increment Listing.Count := Listing.Count + 1; -- search next Skip_Next_Entry (Listing.Search); return Current (Object); end Next; -- operations on directory entries procedure Get_Entry ( Name : String; Directory_Entry : out Directory_Entry_Type) is pragma Unmodified (Directory_Entry); -- modified via Reference NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; Directory_First : Positive; Directory_Last : Natural; Simple_Name_First : Positive; Simple_Name_Last : Natural; begin -- decompose the name Hierarchical_File_Names.Containing_Directory (Name, First => Directory_First, Last => Directory_Last); Hierarchical_File_Names.Simple_Name (Name, First => Simple_Name_First, Last => Simple_Name_Last); -- make a detached entry Finalize (NC_Directory_Entry); NC_Directory_Entry.Path := new String'(Full_Name (Name (Directory_First .. Directory_Last))); NC_Directory_Entry.Directory_Entry := null; NC_Directory_Entry.Additional.Filled := False; NC_Directory_Entry.Status := Detached; System.Native_Directories.Searching.Get_Entry ( NC_Directory_Entry.Path.all, Name (Simple_Name_First .. Simple_Name_Last), NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional); end Get_Entry; function Get_Entry ( Name : String) return Directory_Entry_Type is begin return Result : Directory_Entry_Type do Get_Entry (Name, Result); end return; end Get_Entry; function Simple_Name ( Directory_Entry : Directory_Entry_Type) return String is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return System.Native_Directories.Searching.Simple_Name ( NC_Directory_Entry.Directory_Entry); end Simple_Name; function Full_Name ( Directory_Entry : Directory_Entry_Type) return String is Name : constant String := Simple_Name (Directory_Entry); -- checking the predicate NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return Hierarchical_File_Names.Compose ( NC_Directory_Entry.Path.all, Name); end Full_Name; function Kind ( Directory_Entry : Directory_Entry_Type) return File_Kind is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return File_Kind'Enum_Val ( System.Native_Directories.File_Kind'Enum_Rep ( System.Native_Directories.Searching.Kind ( NC_Directory_Entry.Directory_Entry))); end Kind; function Size ( Directory_Entry : Directory_Entry_Type) return File_Size is begin if Kind (Directory_Entry) /= Ordinary_File then -- checking the predicate raise Constraint_Error; -- implementation-defined else declare NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return System.Native_Directories.Searching.Size ( NC_Directory_Entry.Path.all, NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional); end; end if; end Size; function Modification_Time ( Directory_Entry : Directory_Entry_Type) return Calendar.Time is pragma Check (Dynamic_Predicate, Check => Is_Assigned (Directory_Entry) or else raise Status_Error); NC_Directory_Entry : Non_Controlled_Directory_Entry_Type renames Controlled_Entries.Reference (Directory_Entry).all; begin return Calendar.Naked.To_Time ( System.Native_Directories.Searching.Modification_Time ( NC_Directory_Entry.Path.all, NC_Directory_Entry.Directory_Entry, NC_Directory_Entry.Additional)); end Modification_Time; end Ada.Directories;
AdaCore/gpr
Ada
20
ads
package O is end O;
reznikmm/matreshka
Ada
105
ads
-- Ada implementation of 9P - Plan 9 Remote Resource Protocol package Styx is pragma Pure; end Styx;
io7m/coreland-plexlog-ada
Ada
57
ads
package Plexlog is pragma Pure (Plexlog); end Plexlog;
AaronC98/PlaneSystem
Ada
5,356
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2004-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ with GNAT.MD5; with AWS.Communication.Client; with AWS.Digest; with AWS.Messages; with AWS.Server.Hotplug; with AWS.URL; package body AWS.Client.Hotplug is -------------- -- Register -- -------------- function Register (Name : String; Password : String; Server : String; Regexp : String; URL : String) return Response.Data is use type Messages.Status_Code; Srv : AWS.URL.Object; Response : AWS.Response.Data; Digest : AWS.Digest.Digest_String; begin Srv := AWS.URL.Parse (Server); -- Ask the server for a Nonce string Response := Communication.Client.Send_Message (AWS.URL.Host (Srv), AWS.URL.Port (Srv), AWS.Server.Hotplug.Request_Nonce_Message, Communication.Parameters (Name)); if AWS.Response.Status_Code (Response) /= Messages.S200 then return Response; end if; -- Send registration with a digest encoded using the server Nonce declare Nonce : constant String := AWS.Response.Message_Body (Response); begin Digest := AWS.Digest.Create (Name, "hotplug", GNAT.MD5.Digest (Name & ":aws:" & Password), Nonce, "hotplug", Regexp); return AWS.Communication.Client.Send_Message (AWS.URL.Host (Srv), AWS.URL.Port (Srv), AWS.Server.Hotplug.Register_Message, Communication.Parameters (Name, Digest, Regexp, URL)); end; exception when AWS.URL.URL_Error => return AWS.Response.Acknowledge (Messages.S400, "Server URL error"); end Register; ---------------- -- Unregister -- ---------------- function Unregister (Name : String; Password : String; Server : String; Regexp : String) return Response.Data is use type Messages.Status_Code; Srv : AWS.URL.Object; Response : AWS.Response.Data; Digest : AWS.Digest.Digest_String; begin Srv := AWS.URL.Parse (Server); -- Ask the server for a Nonce string Response := AWS.Communication.Client.Send_Message (AWS.URL.Host (Srv), AWS.URL.Port (Srv), AWS.Server.Hotplug.Request_Nonce_Message, Communication.Parameters (Name)); if AWS.Response.Status_Code (Response) /= Messages.S200 then return Response; end if; -- Send unregister message with a digest encoded using the server Nonce declare Nonce : constant String := AWS.Response.Message_Body (Response); begin Digest := AWS.Digest.Create (Name, "hotplug", GNAT.MD5.Digest (Name & ":aws:" & Password), Nonce, "hotplug", Regexp); return AWS.Communication.Client.Send_Message (AWS.URL.Host (Srv), AWS.URL.Port (Srv), AWS.Server.Hotplug.Unregister_Message, Communication.Parameters (Name, Digest, Regexp)); end; exception when AWS.URL.URL_Error => return AWS.Response.Acknowledge (Messages.S400, "Server URL error"); end Unregister; end AWS.Client.Hotplug;
gonma95/RealTimeSystem_CarDistrations
Ada
8,923
adb
-- Gonzalo Martin Rodriguez -- Ivan Fernandez Samaniego with Kernel.Serial_Output; use Kernel.Serial_Output; with Ada.Real_Time; use Ada.Real_Time; with ada.strings.unbounded; use ada.strings.unbounded; with ada.strings.unbounded.text_io; use ada.strings.unbounded.text_io; with System; use System; with Tools; use Tools; with devices; use devices; package body Driver is task body Distance is Current_D: Distance_Samples_Type := 0; Current_V: Speed_Samples_Type := 0; Recommended_Distance: float; Siguiente_Instante: Time; begin Siguiente_Instante := Big_Bang + Milliseconds(300); loop Starting_Notice ("Distance"); Measures.Write_Distance; Measures.Write_Speed; Measures.Read_Distance (Current_D); Measures.Read_Speed (Current_V); Recommended_Distance := float ((Current_V/10)**2); if (float(Current_D) < float(Recommended_Distance)/float(3000)) then Symptoms.Write_Peligro_Colision (True); Symptoms.Write_Distancia_Insegura (False); Symptoms.Write_Distancia_Imprudente (False); elsif (float(Current_D) < float(Recommended_Distance)/float(2000)) then Symptoms.Write_Distancia_Imprudente (True); Symptoms.Write_Distancia_Insegura (False); Symptoms.Write_Peligro_Colision (False); elsif (float(Current_D) < Recommended_Distance)then Symptoms.Write_Distancia_Insegura (True); Symptoms.Write_Distancia_Imprudente (False); Symptoms.Write_Peligro_Colision (False); else Symptoms.Write_Distancia_Insegura (False); Symptoms.Write_Distancia_Imprudente (False); Symptoms.Write_Peligro_Colision (False); end if; Finishing_Notice ("Distance"); delay until Siguiente_Instante; Siguiente_Instante := Siguiente_Instante + Milliseconds(300); end loop; end Distance; task body Steering is Previous_S : Steering_Samples_Type; Current_S : Steering_Samples_Type := 0; Speed: Speed_Samples_Type := 0; Siguiente_Instante: Time; begin Siguiente_Instante := Big_Bang + Milliseconds(350); loop Starting_Notice ("Steering"); Previous_S := Current_S; Symptoms.Write_Steering; Measures.Write_Speed; Symptoms.Read_Steering (Current_S); Measures.Read_Speed (Speed); if Previous_S - Current_S > abs(20) and Speed > 40 then Symptoms.Write_Steering_Symptom (True); else Symptoms.Write_Steering_Symptom (False); end if; Finishing_Notice ("Steering"); delay until Siguiente_Instante; Siguiente_Instante := Siguiente_Instante + Milliseconds(350); end loop; end Steering; task body Head is Previous_H: HeadPosition_Samples_Type := (+2,-2); Current_H: HeadPosition_Samples_Type := (+2, -2); Current_S: Steering_Samples_Type; Siguiente_Instante: Time; begin Siguiente_Instante := Big_Bang + Milliseconds(400); loop Starting_Notice ("Head"); Previous_H := Current_H; Symptoms.Write_HeadPosition; Symptoms.Write_Steering; Symptoms.Read_HeadPosition (Current_H); Symptoms.Read_Steering (Current_S); if (((abs Previous_H(x) > 30) and (abs Current_H(x) > 30)) or ((Previous_H(y) > 30) and (Current_H(y) > 30) and (Current_S < 30)) or ((Previous_H(y) < 30) and (Current_H(y) < 30) and (Current_S > 30))) then Symptoms.Write_Head_Symptom (True); else Symptoms.Write_Head_Symptom (False); end if; Finishing_Notice ("Head"); delay until Siguiente_Instante; Siguiente_Instante := Siguiente_Instante + Milliseconds(400); end loop; end Head; protected body Symptoms is procedure Write_Head_Symptom (Value: in Boolean) is begin Head_Symptom := Value; Execution_Time(Milliseconds(2)); end Write_Head_Symptom; procedure Read_Head_Symptom (Value: out Boolean) is begin Value := Head_Symptom; Execution_Time(Milliseconds(2)); end Read_Head_Symptom; procedure Write_Distancia_Insegura (Value: in Boolean) is begin Distancia_Insegura := Value; Execution_Time(Milliseconds(3)); end Write_Distancia_Insegura; procedure Read_Distancia_Insegura (Value: out Boolean) is begin Value := Distancia_Insegura; Execution_Time(Milliseconds(3)); end Read_Distancia_Insegura; procedure Write_Distancia_Imprudente (Value: in Boolean) is begin Distancia_Imprudente := Value; Execution_Time(Milliseconds(4)); end Write_Distancia_Imprudente; procedure Read_Distancia_Imprudente (Value: out Boolean) is begin Value := Distancia_Imprudente; Execution_Time(Milliseconds(4)); end Read_Distancia_Imprudente; procedure Write_Peligro_Colision (Value: in Boolean) is begin Peligro_Colision := Value; Execution_Time(Milliseconds(5)); end Write_Peligro_Colision; procedure Read_Peligro_Colision (Value: out Boolean) is begin Value := Peligro_Colision; Execution_Time(Milliseconds(5)); end Read_Peligro_Colision; procedure Write_Steering_Symptom (Value: in Boolean) is begin Steering_Symptom := Value; Execution_Time(Milliseconds(6)); end Write_Steering_Symptom; procedure Read_Steering_Symptom (Value: out Boolean) is begin Value := Steering_Symptom; Execution_Time(Milliseconds(6)); end Read_Steering_Symptom; procedure Write_HeadPosition is begin Reading_HeadPosition(HeadPosition); Execution_Time(Milliseconds(7)); end Write_HeadPosition; procedure Read_HeadPosition (Value: out HeadPosition_Samples_Type) is begin Value := HeadPosition; Execution_Time(Milliseconds(7)); end Read_HeadPosition; procedure Write_Steering is begin Reading_Steering (Steering); Execution_Time(Milliseconds(8)); end Write_Steering; procedure Read_Steering (Value: out Steering_Samples_Type) is begin Value := Steering; Execution_Time(Milliseconds(8)); end Read_Steering; procedure Display_Symptom (Symptom: in Unbounded_String) is begin Current_Time (Big_Bang); Put ("............# "); Put ("Symptom: "); Put (Symptom); Execution_Time(Milliseconds(2)); end Display_Symptom; procedure Show_Symptoms is begin if Head_Symptom then Display_Symptom (To_Unbounded_String("CABEZA INCLINADA")); end if; if Steering_Symptom then Display_Symptom (To_Unbounded_String("VOLANTAZO")); end if; if Distancia_Insegura then Display_Symptom (To_Unbounded_String("DISTANCIA INSEGURA")); end if; if Distancia_Imprudente then Display_Symptom (To_Unbounded_String("DISTANCIA IMPRUDENTE")); end if; if Peligro_Colision then Display_Symptom (To_Unbounded_String("PELIGRO COLISION")); end if; Execution_Time(Milliseconds(6)); end Show_Symptoms; end Symptoms; protected body Measures is procedure Read_Distance (Value: out Distance_Samples_Type) is begin Value := Distance; Execution_Time(Milliseconds(2)); end Read_Distance; procedure Write_Distance is begin Reading_Distance(Distance); Execution_Time(Milliseconds(3)); end Write_Distance; procedure Show_Distance is begin Display_Distance(Distance); Execution_Time(Milliseconds(4)); end Show_Distance; procedure Read_Speed (Value: out Speed_Samples_Type) is begin Value := Speed; Execution_Time(Milliseconds(5)); end Read_Speed; procedure Write_Speed is begin Reading_Speed(Speed); Execution_Time(Milliseconds(6)); end Write_Speed; procedure Show_Speed is begin Display_Speed(Speed); Execution_Time(Milliseconds(7)); end Show_Speed; end Measures; begin null; end Driver;
AdaCore/gpr
Ada
3,423
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception -- with Ada.Strings.Maps.Constants; package body GPR2.Unit is ------------ -- As_Ref -- ------------ function As_Ref (Element : Source_Reference.Identifier.Set.Object) return Dependencies_Ref.Ref is Result : Dependencies_Ref.Ref; begin Result.Set (Element); return Result; end As_Ref; ----------------------- -- Set_Separate_From -- ----------------------- procedure Set_Separate_From (Self : in out Object; Name : Name_Type) is begin Self.Sep_From := +String (Name); Self.Kind := S_Separate; end Set_Separate_From; ------------------ -- Update_Index -- ------------------ procedure Update_Index (Self : in out Object; Index : Unit_Index) is begin Self.Index := Index; end Update_Index; ----------------- -- Update_Kind -- ----------------- procedure Update_Kind (Self : in out Object; Kind : Library_Unit_Type) is begin Self.Kind := Kind; end Update_Kind; ------------------------ -- Update_Name_Casing -- ------------------------ procedure Update_Name (Self : in out Object; Name : Name_Type) is begin Self.Name := +String (Name); end Update_Name; --------------------- -- Valid_Unit_Name -- --------------------- function Valid_Unit_Name (Unit_Name : Name_Type; On_Error : access procedure (Message : String) := null) return Boolean is use Ada.Strings.Maps; function Not_Valid return String is ("unit '" & String (Unit_Name) & "' not valid, "); procedure Error (Message : String); ----------- -- Error -- ----------- procedure Error (Message : String) is begin if On_Error /= null then On_Error (Message); end if; end Error; begin -- Must start with a letter if not Is_In (Unit_Name (Unit_Name'First), Constants.Letter_Set or To_Set ("_")) then Error (Not_Valid & "should start with a letter or an underscore"); return False; end if; -- Cannot have dots and underscores one after another and should -- contain only alphanumeric characters. for K in Unit_Name'First + 1 .. Unit_Name'Last loop declare Two_Chars : constant Name_Type := Unit_Name (K - 1 .. K); begin if Two_Chars = "_." then Error (Not_Valid & "cannot contain dot after underscore"); return False; elsif Two_Chars = "__" then Error (Not_Valid & "two consecutive underscores not permitted"); return False; elsif Two_Chars = "._" then Error (Not_Valid & "cannot contain underscore after dot"); return False; elsif Two_Chars = ".." then Error (Not_Valid & "two consecutive dots not permitted"); return False; elsif not Characters.Handling.Is_Alphanumeric (Unit_Name (K)) and then Unit_Name (K) not in '.' | '_' then Error (Not_Valid & "should have only alpha numeric characters"); return False; end if; end; end loop; return True; end Valid_Unit_Name; end GPR2.Unit;
reznikmm/matreshka
Ada
3,411
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package ODF.DOM.Attributes.Office is end ODF.DOM.Attributes.Office;
jscparker/math_packages
Ada
1,484
ads
-- package Quadrature -- -- The equation is dY/dt = F (t). -- The solution is just the area under the curve - quadrature. -- F(t) is input as a generic formal function called Integrand. -- -- If you want (d/dt)**N Y = F(t), then N is written as -- -- N = Order_of_Equation -- -- Then the integrated Y(0) is solution of (d/dt)**N Y = F(t), -- Then the integrated Y(1) is solution of (d/dt)**N-1 Y = F(t), -- and so on. generic type Real is digits <>; with function Integrand (X : Real) return Real is <>; package Quadrature is Order_of_Equation : constant Positive := 1; type Dyn_Index is range 0 .. Order_of_Equation-1; type Dynamical_Variable is array(Dyn_Index) of Real; DynZero : constant Dynamical_Variable := (others => (+0.0)); function F (Time : Real; Y : Dynamical_Variable) return Dynamical_Variable; -- Defines the equation to be integrated, -- dY/dt = F (t, Y). Even if the equation is t or Y -- independent, it must be entered in this form. function "*" (Left : Real; Right : Dynamical_Variable) return Dynamical_Variable; function "+" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable; function "-" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable; function Norm (Y : Dynamical_Variable) return Real; pragma Inline (F, "*", "+", "-", Norm); end Quadrature;
zhmu/ananas
Ada
70,431
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . S U P E R B O U N D E D -- -- -- -- B o d y -- -- -- -- Copyright (C) 2003-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. -- -- -- ------------------------------------------------------------------------------ -- Ghost code, loop invariants and assertions in this unit are meant for -- analysis only, not for run-time checking, as it would be too costly -- otherwise. This is enforced by setting the assertion policy to Ignore. pragma Assertion_Policy (Ghost => Ignore, Loop_Invariant => Ignore, Assert => Ignore); with Ada.Strings.Maps; use Ada.Strings.Maps; package body Ada.Strings.Superbounded with SPARK_Mode is ------------ -- Concat -- ------------ function Concat (Left : Super_String; Right : Super_String) return Super_String is begin return Result : Super_String (Left.Max_Length) do declare Llen : constant Natural := Left.Current_Length; Rlen : constant Natural := Right.Current_Length; Nlen : constant Natural := Llen + Rlen; begin if Nlen > Left.Max_Length then raise Ada.Strings.Length_Error; end if; Result.Data (1 .. Llen) := Left.Data (1 .. Llen); if Rlen > 0 then Result.Data (Llen + 1 .. Nlen) := Right.Data (1 .. Rlen); end if; Result.Current_Length := Nlen; end; end return; end Concat; function Concat (Left : Super_String; Right : String) return Super_String is begin return Result : Super_String (Left.Max_Length) do declare Llen : constant Natural := Left.Current_Length; Nlen : constant Natural := Llen + Right'Length; begin if Nlen > Left.Max_Length then raise Ada.Strings.Length_Error; end if; Result.Data (1 .. Llen) := Left.Data (1 .. Llen); if Right'Length > 0 then Result.Data (Llen + 1 .. Nlen) := Super_String_Data (Right); end if; Result.Current_Length := Nlen; end; end return; end Concat; function Concat (Left : String; Right : Super_String) return Super_String is begin return Result : Super_String (Right.Max_Length) do declare Llen : constant Natural := Left'Length; Rlen : constant Natural := Right.Current_Length; Nlen : constant Natural := Llen + Rlen; begin if Nlen > Right.Max_Length then raise Ada.Strings.Length_Error; end if; Result.Data (1 .. Llen) := Super_String_Data (Left); if Rlen > 0 then Result.Data (Llen + 1 .. Nlen) := Right.Data (1 .. Rlen); end if; Result.Current_Length := Nlen; end; end return; end Concat; function Concat (Left : Super_String; Right : Character) return Super_String is begin return Result : Super_String (Left.Max_Length) do declare Llen : constant Natural := Left.Current_Length; begin if Llen = Left.Max_Length then raise Ada.Strings.Length_Error; end if; Result.Data (1 .. Llen) := Left.Data (1 .. Llen); Result.Data (Llen + 1) := Right; Result.Current_Length := Llen + 1; end; end return; end Concat; function Concat (Left : Character; Right : Super_String) return Super_String is begin return Result : Super_String (Right.Max_Length) do declare Rlen : constant Natural := Right.Current_Length; begin if Rlen = Right.Max_Length then raise Ada.Strings.Length_Error; end if; Result.Data (1) := Left; Result.Data (2 .. Rlen + 1) := Right.Data (1 .. Rlen); Result.Current_Length := Rlen + 1; end; end return; end Concat; ----------- -- Equal -- ----------- function "=" (Left : Super_String; Right : Super_String) return Boolean is begin return Super_To_String (Left) = Super_To_String (Right); end "="; function Equal (Left : Super_String; Right : String) return Boolean is begin return Super_To_String (Left) = Right; end Equal; function Equal (Left : String; Right : Super_String) return Boolean is begin return Left = Super_To_String (Right); end Equal; ------------- -- Greater -- ------------- function Greater (Left : Super_String; Right : Super_String) return Boolean is begin return Super_To_String (Left) > Super_To_String (Right); end Greater; function Greater (Left : Super_String; Right : String) return Boolean is begin return Super_To_String (Left) > Right; end Greater; function Greater (Left : String; Right : Super_String) return Boolean is begin return Left > Super_To_String (Right); end Greater; ---------------------- -- Greater_Or_Equal -- ---------------------- function Greater_Or_Equal (Left : Super_String; Right : Super_String) return Boolean is begin return Super_To_String (Left) >= Super_To_String (Right); end Greater_Or_Equal; function Greater_Or_Equal (Left : Super_String; Right : String) return Boolean is begin return Super_To_String (Left) >= Right; end Greater_Or_Equal; function Greater_Or_Equal (Left : String; Right : Super_String) return Boolean is begin return Left >= Super_To_String (Right); end Greater_Or_Equal; ---------- -- Less -- ---------- function Less (Left : Super_String; Right : Super_String) return Boolean is begin return Super_To_String (Left) < Super_To_String (Right); end Less; function Less (Left : Super_String; Right : String) return Boolean is begin return Super_To_String (Left) < Right; end Less; function Less (Left : String; Right : Super_String) return Boolean is begin return Left < Super_To_String (Right); end Less; ------------------- -- Less_Or_Equal -- ------------------- function Less_Or_Equal (Left : Super_String; Right : Super_String) return Boolean is begin return Super_To_String (Left) <= Super_To_String (Right); end Less_Or_Equal; function Less_Or_Equal (Left : Super_String; Right : String) return Boolean is begin return Super_To_String (Left) <= Right; end Less_Or_Equal; function Less_Or_Equal (Left : String; Right : Super_String) return Boolean is begin return Left <= Super_To_String (Right); end Less_Or_Equal; ---------------------- -- Set_Super_String -- ---------------------- procedure Set_Super_String (Target : out Super_String; Source : String; Drop : Truncation := Error) is Slen : constant Natural := Source'Length; Max_Length : constant Positive := Target.Max_Length; begin if Slen <= Max_Length then Target.Data (1 .. Slen) := Super_String_Data (Source); Target.Current_Length := Slen; else case Drop is when Strings.Right => Target.Data (1 .. Max_Length) := Super_String_Data (Source (Source'First .. Source'First - 1 + Max_Length)); Target.Current_Length := Max_Length; when Strings.Left => Target.Data (1 .. Max_Length) := Super_String_Data (Source (Source'Last - (Max_Length - 1) .. Source'Last)); Target.Current_Length := Max_Length; when Strings.Error => raise Ada.Strings.Length_Error; end case; end if; end Set_Super_String; ------------------ -- Super_Append -- ------------------ -- Case of Super_String and Super_String function Super_Append (Left : Super_String; Right : Super_String; Drop : Truncation := Error) return Super_String is Max_Length : constant Positive := Left.Max_Length; Result : Super_String (Max_Length); Llen : constant Natural := Left.Current_Length; Rlen : constant Natural := Right.Current_Length; begin if Llen <= Max_Length - Rlen then Result.Data (1 .. Llen) := Left.Data (1 .. Llen); if Rlen > 0 then Result.Data (Llen + 1 .. Llen + Rlen) := Right.Data (1 .. Rlen); end if; Result.Current_Length := Llen + Rlen; else case Drop is when Strings.Right => if Llen >= Max_Length then -- only case is Llen = Max_Length Result.Data := Left.Data; else Result.Data (1 .. Llen) := Left.Data (1 .. Llen); Result.Data (Llen + 1 .. Max_Length) := Right.Data (1 .. Max_Length - Llen); end if; when Strings.Left => if Rlen >= Max_Length then -- only case is Rlen = Max_Length Result.Data := Right.Data; else Result.Data (1 .. Max_Length - Rlen) := Left.Data (Llen - (Max_Length - Rlen - 1) .. Llen); Result.Data (Max_Length - Rlen + 1 .. Max_Length) := Right.Data (1 .. Rlen); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Append; procedure Super_Append (Source : in out Super_String; New_Item : Super_String; Drop : Truncation := Error) is Max_Length : constant Positive := Source.Max_Length; Llen : constant Natural := Source.Current_Length; Rlen : constant Natural := New_Item.Current_Length; begin if Llen <= Max_Length - Rlen then if Rlen > 0 then Source.Data (Llen + 1 .. Llen + Rlen) := New_Item.Data (1 .. Rlen); Source.Current_Length := Llen + Rlen; end if; else case Drop is when Strings.Right => if Llen < Max_Length then Source.Data (Llen + 1 .. Max_Length) := New_Item.Data (1 .. Max_Length - Llen); end if; when Strings.Left => if Rlen >= Max_Length then -- only case is Rlen = Max_Length Source.Data := New_Item.Data; else Source.Data (1 .. Max_Length - Rlen) := Source.Data (Llen - (Max_Length - Rlen - 1) .. Llen); Source.Data (Max_Length - Rlen + 1 .. Max_Length) := New_Item.Data (1 .. Rlen); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Source.Current_Length := Max_Length; end if; end Super_Append; -- Case of Super_String and String function Super_Append (Left : Super_String; Right : String; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Left.Max_Length; Result : Super_String (Max_Length); Llen : constant Natural := Left.Current_Length; Rlen : constant Natural := Right'Length; begin if Llen <= Max_Length - Rlen then Result.Data (1 .. Llen) := Left.Data (1 .. Llen); if Rlen > 0 then Result.Data (Llen + 1 .. Llen + Rlen) := Super_String_Data (Right); end if; Result.Current_Length := Llen + Rlen; else case Drop is when Strings.Right => if Llen >= Max_Length then -- only case is Llen = Max_Length Result.Data := Left.Data; else Result.Data (1 .. Llen) := Left.Data (1 .. Llen); Result.Data (Llen + 1 .. Max_Length) := Super_String_Data (Right (Right'First .. Right'First - 1 - Llen + Max_Length)); end if; when Strings.Left => if Rlen >= Max_Length then Result.Data (1 .. Max_Length) := Super_String_Data (Right (Right'Last - (Max_Length - 1) .. Right'Last)); else Result.Data (1 .. Max_Length - Rlen) := Left.Data (Llen - (Max_Length - Rlen - 1) .. Llen); Result.Data (Max_Length - Rlen + 1 .. Max_Length) := Super_String_Data (Right); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Append; procedure Super_Append (Source : in out Super_String; New_Item : String; Drop : Truncation := Error) is Max_Length : constant Positive := Source.Max_Length; Llen : constant Natural := Source.Current_Length; Rlen : constant Natural := New_Item'Length; begin if Llen <= Max_Length - Rlen then if Rlen > 0 then Source.Data (Llen + 1 .. Llen + Rlen) := Super_String_Data (New_Item); Source.Current_Length := Llen + Rlen; end if; else case Drop is when Strings.Right => if Llen < Max_Length then Source.Data (Llen + 1 .. Max_Length) := Super_String_Data (New_Item (New_Item'First .. New_Item'First - 1 - Llen + Max_Length)); end if; when Strings.Left => if Rlen >= Max_Length then Source.Data (1 .. Max_Length) := Super_String_Data (New_Item (New_Item'Last - (Max_Length - 1) .. New_Item'Last)); else Source.Data (1 .. Max_Length - Rlen) := Source.Data (Llen - (Max_Length - Rlen - 1) .. Llen); Source.Data (Max_Length - Rlen + 1 .. Max_Length) := Super_String_Data (New_Item); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Source.Current_Length := Max_Length; end if; end Super_Append; -- Case of String and Super_String function Super_Append (Left : String; Right : Super_String; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Right.Max_Length; Result : Super_String (Max_Length); Llen : constant Natural := Left'Length; Rlen : constant Natural := Right.Current_Length; begin if Llen <= Max_Length - Rlen then Result.Data (1 .. Llen) := Super_String_Data (Left); if Rlen > 0 then Result.Data (Llen + 1 .. Llen + Rlen) := Right.Data (1 .. Rlen); end if; Result.Current_Length := Llen + Rlen; else case Drop is when Strings.Right => if Llen >= Max_Length then Result.Data (1 .. Max_Length) := Super_String_Data (Left (Left'First .. Left'First + (Max_Length - 1))); else Result.Data (1 .. Llen) := Super_String_Data (Left); Result.Data (Llen + 1 .. Max_Length) := Right.Data (1 .. Max_Length - Llen); end if; when Strings.Left => if Rlen >= Max_Length then Result.Data (1 .. Max_Length) := Right.Data (Rlen - (Max_Length - 1) .. Rlen); else Result.Data (1 .. Max_Length - Rlen) := Super_String_Data (Left (Left'Last - (Max_Length - Rlen - 1) .. Left'Last)); Result.Data (Max_Length - Rlen + 1 .. Max_Length) := Right.Data (1 .. Rlen); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Append; -- Case of Super_String and Character function Super_Append (Left : Super_String; Right : Character; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Left.Max_Length; Result : Super_String (Max_Length); Llen : constant Natural := Left.Current_Length; begin if Llen < Max_Length then Result.Data (1 .. Llen) := Left.Data (1 .. Llen); Result.Data (Llen + 1) := Right; Result.Current_Length := Llen + 1; return Result; else case Drop is when Strings.Right => return Left; when Strings.Left => Result.Data (1 .. Max_Length - 1) := Left.Data (2 .. Max_Length); Result.Data (Max_Length) := Right; Result.Current_Length := Max_Length; return Result; when Strings.Error => raise Ada.Strings.Length_Error; end case; end if; end Super_Append; procedure Super_Append (Source : in out Super_String; New_Item : Character; Drop : Truncation := Error) is Max_Length : constant Positive := Source.Max_Length; Llen : constant Natural := Source.Current_Length; begin if Llen < Max_Length then Source.Data (Llen + 1) := New_Item; Source.Current_Length := Llen + 1; else case Drop is when Strings.Right => null; when Strings.Left => Source.Data (1 .. Max_Length - 1) := Source.Data (2 .. Max_Length); Source.Data (Max_Length) := New_Item; when Strings.Error => raise Ada.Strings.Length_Error; end case; end if; end Super_Append; -- Case of Character and Super_String function Super_Append (Left : Character; Right : Super_String; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Right.Max_Length; Result : Super_String (Max_Length); Rlen : constant Natural := Right.Current_Length; begin if Rlen < Max_Length then Result.Data (1) := Left; Result.Data (2 .. Rlen + 1) := Right.Data (1 .. Rlen); Result.Current_Length := Rlen + 1; return Result; else case Drop is when Strings.Right => Result.Data (1) := Left; Result.Data (2 .. Max_Length) := Right.Data (1 .. Max_Length - 1); Result.Current_Length := Max_Length; return Result; when Strings.Left => return Right; when Strings.Error => raise Ada.Strings.Length_Error; end case; end if; end Super_Append; ----------------- -- Super_Count -- ----------------- function Super_Count (Source : Super_String; Pattern : String; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is begin return Search.Count (Super_To_String (Source), Pattern, Mapping); end Super_Count; function Super_Count (Source : Super_String; Pattern : String; Mapping : Maps.Character_Mapping_Function) return Natural is begin return Search.Count (Super_To_String (Source), Pattern, Mapping); end Super_Count; function Super_Count (Source : Super_String; Set : Maps.Character_Set) return Natural is begin return Search.Count (Super_To_String (Source), Set); end Super_Count; ------------------ -- Super_Delete -- ------------------ function Super_Delete (Source : Super_String; From : Positive; Through : Natural) return Super_String is Result : Super_String (Source.Max_Length); Slen : constant Natural := Source.Current_Length; Num_Delete : constant Integer := Through - From + 1; begin if Num_Delete <= 0 then return Source; elsif From - 1 > Slen then raise Ada.Strings.Index_Error; elsif Through >= Slen then Result.Data (1 .. From - 1) := Source.Data (1 .. From - 1); Result.Current_Length := From - 1; return Result; else Result.Data (1 .. From - 1) := Source.Data (1 .. From - 1); Result.Data (From .. Slen - Num_Delete) := Source.Data (Through + 1 .. Slen); Result.Current_Length := Slen - Num_Delete; return Result; end if; end Super_Delete; procedure Super_Delete (Source : in out Super_String; From : Positive; Through : Natural) is Slen : constant Natural := Source.Current_Length; Num_Delete : constant Integer := Through - From + 1; begin if Num_Delete <= 0 then return; elsif From - 1 > Slen then raise Ada.Strings.Index_Error; elsif Through >= Slen then Source.Current_Length := From - 1; else Source.Current_Length := Slen - Num_Delete; Source.Data (From .. Source.Current_Length) := Source.Data (Through + 1 .. Slen); end if; end Super_Delete; ---------------------- -- Super_Find_Token -- ---------------------- procedure Super_Find_Token (Source : Super_String; Set : Maps.Character_Set; From : Positive; Test : Strings.Membership; First : out Positive; Last : out Natural) is begin Search.Find_Token (Super_To_String (Source), Set, From, Test, First, Last); end Super_Find_Token; procedure Super_Find_Token (Source : Super_String; Set : Maps.Character_Set; Test : Strings.Membership; First : out Positive; Last : out Natural) is begin Search.Find_Token (Super_To_String (Source), Set, Test, First, Last); end Super_Find_Token; ---------------- -- Super_Head -- ---------------- function Super_Head (Source : Super_String; Count : Natural; Pad : Character := Space; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Source.Max_Length; Result : Super_String (Max_Length); Slen : constant Natural := Source.Current_Length; Npad : constant Integer := Count - Slen; begin if Npad <= 0 then Result.Data (1 .. Count) := Source.Data (1 .. Count); Result.Current_Length := Count; elsif Count <= Max_Length then Result.Data (1 .. Slen) := Source.Data (1 .. Slen); Result.Data (Slen + 1 .. Count) := [others => Pad]; Result.Current_Length := Count; else case Drop is when Strings.Right => Result.Data (1 .. Slen) := Source.Data (1 .. Slen); if Slen < Max_Length then Result.Data (Slen + 1 .. Max_Length) := [others => Pad]; end if; when Strings.Left => if Npad >= Max_Length then Result.Data := [others => Pad]; else Result.Data (1 .. Max_Length - Npad) := Source.Data (Count - Max_Length + 1 .. Slen); Result.Data (Max_Length - Npad + 1 .. Max_Length) := [others => Pad]; end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Head; procedure Super_Head (Source : in out Super_String; Count : Natural; Pad : Character := Space; Drop : Truncation := Error) is Max_Length : constant Positive := Source.Max_Length; Slen : constant Natural := Source.Current_Length; Npad : constant Integer := Count - Slen; Temp : Super_String_Data (1 .. Max_Length); begin if Npad <= 0 then Source.Current_Length := Count; elsif Count <= Max_Length then Source.Data (Slen + 1 .. Count) := [others => Pad]; Source.Current_Length := Count; else case Drop is when Strings.Right => if Slen < Max_Length then Source.Data (Slen + 1 .. Max_Length) := [others => Pad]; end if; when Strings.Left => if Npad > Max_Length then Source.Data := [others => Pad]; else Temp := Source.Data; Source.Data (1 .. Max_Length - Npad) := Temp (Count - Max_Length + 1 .. Slen); Source.Data (Max_Length - Npad + 1 .. Max_Length) := [others => Pad]; end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Source.Current_Length := Max_Length; end if; end Super_Head; ----------------- -- Super_Index -- ----------------- function Super_Index (Source : Super_String; Pattern : String; Going : Strings.Direction := Strings.Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is begin return Search.Index (Super_To_String (Source), Pattern, Going, Mapping); end Super_Index; function Super_Index (Source : Super_String; Pattern : String; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural is begin return Search.Index (Super_To_String (Source), Pattern, Going, Mapping); end Super_Index; function Super_Index (Source : Super_String; Set : Maps.Character_Set; Test : Strings.Membership := Strings.Inside; Going : Strings.Direction := Strings.Forward) return Natural is begin return Search.Index (Super_To_String (Source), Set, Test, Going); end Super_Index; function Super_Index (Source : Super_String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural is begin return Search.Index (Super_To_String (Source), Pattern, From, Going, Mapping); end Super_Index; function Super_Index (Source : Super_String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural is begin return Search.Index (Super_To_String (Source), Pattern, From, Going, Mapping); end Super_Index; function Super_Index (Source : Super_String; Set : Maps.Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural is begin return Result : Natural do Result := Search.Index (Super_To_String (Source), Set, From, Test, Going); pragma Assert (if (for all J in 1 .. Super_Length (Source) => (if J = From or else (J > From) = (Going = Forward) then (Test = Inside) /= Maps.Is_In (Source.Data (J), Set))) then Result = 0); end return; end Super_Index; --------------------------- -- Super_Index_Non_Blank -- --------------------------- function Super_Index_Non_Blank (Source : Super_String; Going : Strings.Direction := Strings.Forward) return Natural is begin return Search.Index_Non_Blank (Super_To_String (Source), Going); end Super_Index_Non_Blank; function Super_Index_Non_Blank (Source : Super_String; From : Positive; Going : Direction := Forward) return Natural is begin return Search.Index_Non_Blank (Super_To_String (Source), From, Going); end Super_Index_Non_Blank; ------------------ -- Super_Insert -- ------------------ function Super_Insert (Source : Super_String; Before : Positive; New_Item : String; Drop : Strings.Truncation := Strings.Error) return Super_String with SPARK_Mode => Off is Max_Length : constant Positive := Source.Max_Length; Result : Super_String (Max_Length); Slen : constant Natural := Source.Current_Length; Nlen : constant Natural := New_Item'Length; Blen : constant Natural := Before - 1; Alen : constant Integer := Slen - Blen; Droplen : constant Integer := Slen - Max_Length + Nlen; -- Blen, Alen are the lengths of the before and after pieces of the -- source string. The number of dropped characters is Natural'Max (0, -- Droplen). begin if Alen < 0 then raise Ada.Strings.Index_Error; elsif Droplen <= 0 then Result.Data (1 .. Blen) := Source.Data (1 .. Blen); Result.Data (Before .. Before - 1 + Nlen) := Super_String_Data (New_Item); if Before <= Slen then Result.Data (Before + Nlen .. Slen + Nlen) := Source.Data (Before .. Slen); end if; Result.Current_Length := Slen + Nlen; else case Drop is when Strings.Right => Result.Data (1 .. Blen) := Source.Data (1 .. Blen); if Droplen >= Alen then Result.Data (Before .. Max_Length) := Super_String_Data (New_Item (New_Item'First .. New_Item'First - Before + Max_Length)); pragma Assert (String (Result.Data (Before .. Max_Length)) = New_Item (New_Item'First .. New_Item'First - Before + Max_Length)); else Result.Data (Before .. Before - 1 + Nlen) := Super_String_Data (New_Item); Result.Data (Before + Nlen .. Max_Length) := Source.Data (Before .. Slen - Droplen); end if; when Strings.Left => if Alen > 0 then Result.Data (Max_Length - (Alen - 1) .. Max_Length) := Source.Data (Before .. Slen); end if; if Droplen > Blen then if Alen < Max_Length then Result.Data (1 .. Max_Length - Alen) := Super_String_Data (New_Item (New_Item'Last - (Max_Length - Alen) + 1 .. New_Item'Last)); end if; else Result.Data (Blen - Droplen + 1 .. Max_Length - Alen) := Super_String_Data (New_Item); Result.Data (1 .. Blen - Droplen) := Source.Data (Droplen + 1 .. Blen); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Insert; procedure Super_Insert (Source : in out Super_String; Before : Positive; New_Item : String; Drop : Strings.Truncation := Strings.Error) is begin -- We do a double copy here because this is one of the situations -- in which we move data to the right, and at least at the moment, -- GNAT is not handling such cases correctly ??? Source := Super_Insert (Source, Before, New_Item, Drop); end Super_Insert; --------------------- -- Super_Overwrite -- --------------------- function Super_Overwrite (Source : Super_String; Position : Positive; New_Item : String; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Source.Max_Length; Result : Super_String (Max_Length); Slen : constant Natural := Source.Current_Length; Droplen : Natural; begin if Position - 1 > Slen then raise Ada.Strings.Index_Error; elsif New_Item'Length = 0 then return Source; elsif Position - 1 <= Slen - New_Item'Length then Result.Data (1 .. Slen) := Source.Data (1 .. Slen); Result.Data (Position .. Position - 1 + New_Item'Length) := Super_String_Data (New_Item); Result.Current_Length := Source.Current_Length; return Result; elsif Position - 1 <= Max_Length - New_Item'Length then Result.Data (1 .. Position - 1) := Source.Data (1 .. Position - 1); Result.Data (Position .. Position - 1 + New_Item'Length) := Super_String_Data (New_Item); Result.Current_Length := Position - 1 + New_Item'Length; return Result; else Droplen := Position - 1 - Max_Length + New_Item'Length; case Drop is when Strings.Right => Result.Data (1 .. Position - 1) := Source.Data (1 .. Position - 1); Result.Data (Position .. Max_Length) := Super_String_Data (New_Item (New_Item'First .. New_Item'Last - Droplen)); when Strings.Left => if New_Item'Length >= Max_Length then Result.Data (1 .. Max_Length) := Super_String_Data (New_Item (New_Item'Last - Max_Length + 1 .. New_Item'Last)); else Result.Data (1 .. Max_Length - New_Item'Length) := Source.Data (Droplen + 1 .. Position - 1); Result.Data (Max_Length - New_Item'Length + 1 .. Max_Length) := Super_String_Data (New_Item); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; return Result; end if; end Super_Overwrite; procedure Super_Overwrite (Source : in out Super_String; Position : Positive; New_Item : String; Drop : Strings.Truncation := Strings.Error) with SPARK_Mode => Off is Max_Length : constant Positive := Source.Max_Length; Slen : constant Natural := Source.Current_Length; Droplen : Natural; begin if Position - 1 > Slen then raise Ada.Strings.Index_Error; elsif Position - 1 <= Slen - New_Item'Length then Source.Data (Position .. Position - 1 + New_Item'Length) := Super_String_Data (New_Item); elsif Position - 1 <= Max_Length - New_Item'Length then Source.Data (Position .. Position - 1 + New_Item'Length) := Super_String_Data (New_Item); Source.Current_Length := Position - 1 + New_Item'Length; else Droplen := Position - 1 - Max_Length + New_Item'Length; case Drop is when Strings.Right => Source.Data (Position .. Max_Length) := Super_String_Data (New_Item (New_Item'First .. New_Item'Last - Droplen)); when Strings.Left => if New_Item'Length > Max_Length then Source.Data (1 .. Max_Length) := Super_String_Data (New_Item (New_Item'Last - Max_Length + 1 .. New_Item'Last)); else Source.Data (1 .. Max_Length - New_Item'Length) := Source.Data (Droplen + 1 .. Position - 1); Source.Data (Max_Length - New_Item'Length + 1 .. Max_Length) := Super_String_Data (New_Item); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Source.Current_Length := Max_Length; end if; end Super_Overwrite; --------------------------- -- Super_Replace_Element -- --------------------------- procedure Super_Replace_Element (Source : in out Super_String; Index : Positive; By : Character) is begin if Index <= Source.Current_Length then Source.Data (Index) := By; else raise Ada.Strings.Index_Error; end if; end Super_Replace_Element; ------------------------- -- Super_Replace_Slice -- ------------------------- function Super_Replace_Slice (Source : Super_String; Low : Positive; High : Natural; By : String; Drop : Strings.Truncation := Strings.Error) return Super_String with SPARK_Mode => Off is Max_Length : constant Positive := Source.Max_Length; Slen : constant Natural := Source.Current_Length; begin if Low - 1 > Slen then raise Strings.Index_Error; elsif High < Low then return Super_Insert (Source, Low, By, Drop); else declare Blen : constant Natural := Low - 1; Alen : constant Natural := Natural'Max (0, Slen - High); Droplen : constant Integer := Blen + Alen - Max_Length + By'Length; Result : Super_String (Max_Length); -- Blen and Alen are the lengths of the pieces of the original -- string that end up in the result string before and after the -- replaced slice. The number of dropped characters is Natural'Max -- (0, Droplen). begin if Droplen <= 0 then Result.Data (1 .. Blen) := Source.Data (1 .. Blen); Result.Data (Low .. Blen + By'Length) := Super_String_Data (By); if Alen > 0 then Result.Data (Low + By'Length .. Blen + By'Length + Alen) := Source.Data (High + 1 .. Slen); end if; Result.Current_Length := Blen + By'Length + Alen; else case Drop is when Strings.Right => Result.Data (1 .. Blen) := Source.Data (1 .. Blen); if Droplen >= Alen then Result.Data (Low .. Max_Length) := Super_String_Data (By (By'First .. By'First - Low + Max_Length)); else Result.Data (Low .. Low - 1 + By'Length) := Super_String_Data (By); Result.Data (Low + By'Length .. Max_Length) := Source.Data (High + 1 .. Slen - Droplen); end if; when Strings.Left => if Alen > 0 then Result.Data (Max_Length - (Alen - 1) .. Max_Length) := Source.Data (High + 1 .. Slen); end if; if Droplen >= Blen then Result.Data (1 .. Max_Length - Alen) := Super_String_Data (By (By'Last - (Max_Length - Alen) + 1 .. By'Last)); else Result.Data (Blen - Droplen + 1 .. Max_Length - Alen) := Super_String_Data (By); Result.Data (1 .. Blen - Droplen) := Source.Data (Droplen + 1 .. Blen); end if; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end; end if; end Super_Replace_Slice; procedure Super_Replace_Slice (Source : in out Super_String; Low : Positive; High : Natural; By : String; Drop : Strings.Truncation := Strings.Error) is begin -- We do a double copy here because this is one of the situations -- in which we move data to the right, and at least at the moment, -- GNAT is not handling such cases correctly ??? Source := Super_Replace_Slice (Source, Low, High, By, Drop); end Super_Replace_Slice; --------------------- -- Super_Replicate -- --------------------- function Super_Replicate (Count : Natural; Item : Character; Drop : Truncation := Error; Max_Length : Positive) return Super_String is Result : Super_String (Max_Length); begin if Count <= Max_Length then Result.Data (1 .. Count) := [others => Item]; Result.Current_Length := Count; elsif Drop = Strings.Error then raise Ada.Strings.Length_Error; else Result.Data (1 .. Max_Length) := [others => Item]; Result.Current_Length := Max_Length; end if; return Result; end Super_Replicate; function Super_Replicate (Count : Natural; Item : String; Drop : Truncation := Error; Max_Length : Positive) return Super_String is Result : Super_String (Max_Length); Indx : Natural; Ilen : constant Natural := Item'Length; -- Parts of the proof involving manipulations with the modulo operator -- are complicated for the prover and can't be done automatically in -- the global subprogram. That's why we isolate them in these two ghost -- lemmas. procedure Lemma_Mod (K : Natural; Q : Natural) with Ghost, Pre => Ilen /= 0 and then Q mod Ilen = 0 and then K - Q in 0 .. Ilen - 1, Post => K mod Ilen = K - Q; -- Lemma_Mod is applied to an index considered in Lemma_Split to prove -- that it has the right value modulo Item'Length. procedure Lemma_Mod_Zero (X : Natural) with Ghost, Pre => Ilen /= 0 and then X mod Ilen = 0 and then X <= Natural'Last - Ilen, Post => (X + Ilen) mod Ilen = 0; -- Lemma_Mod_Zero is applied to prove that the length of the range -- of indexes considered in the loop, when dropping on the Left, is -- a multiple of Item'Length. procedure Lemma_Split (Going : Direction) with Ghost, Pre => Ilen /= 0 and then Indx in 0 .. Max_Length - Ilen and then (if Going = Forward then Indx mod Ilen = 0 else (Max_Length - Indx - Ilen) mod Ilen = 0) and then Result.Data (Indx + 1 .. Indx + Ilen)'Initialized and then String (Result.Data (Indx + 1 .. Indx + Ilen)) = Item, Post => (if Going = Forward then (for all J in Indx + 1 .. Indx + Ilen => Result.Data (J) = Item (Item'First + (J - 1) mod Ilen)) else (for all J in Indx + 1 .. Indx + Ilen => Result.Data (J) = Item (Item'Last - (Max_Length - J) mod Ilen))); -- Lemma_Split is used after Result.Data (Indx + 1 .. Indx + Ilen) is -- updated to Item and concludes that the characters match for each -- index when taken modulo Item'Length, as the considered slice starts -- at index 1 (or ends at index Max_Length, if Going = Backward) modulo -- Item'Length. --------------- -- Lemma_Mod -- --------------- procedure Lemma_Mod (K : Natural; Q : Natural) is null; -------------------- -- Lemma_Mod_Zero -- -------------------- procedure Lemma_Mod_Zero (X : Natural) is null; ----------------- -- Lemma_Split -- ----------------- procedure Lemma_Split (Going : Direction) is begin if Going = Forward then for K in Indx + 1 .. Indx + Ilen loop Lemma_Mod (K - 1, Indx); pragma Loop_Invariant (for all J in Indx + 1 .. K => Result.Data (J) = Item (Item'First + (J - 1) mod Ilen)); end loop; else for K in Indx + 1 .. Indx + Ilen loop Lemma_Mod (Max_Length - K, Max_Length - Indx - Ilen); pragma Loop_Invariant (for all J in Indx + 1 .. K => Result.Data (J) = Item (Item'Last - (Max_Length - J) mod Ilen)); end loop; end if; end Lemma_Split; begin if Count = 0 or else Ilen <= Max_Length / Count then if Count * Ilen > 0 then Indx := 0; for J in 1 .. Count loop Result.Data (Indx + 1 .. Indx + Ilen) := Super_String_Data (Item); pragma Assert (for all K in 1 .. Ilen => Result.Data (Indx + K) = Item (Item'First - 1 + K)); pragma Assert (String (Result.Data (Indx + 1 .. Indx + Ilen)) = Item); Lemma_Split (Forward); Indx := Indx + Ilen; pragma Loop_Invariant (Indx = J * Ilen); pragma Loop_Invariant (Result.Data (1 .. Indx)'Initialized); pragma Loop_Invariant (for all K in 1 .. Indx => Result.Data (K) = Item (Item'First + (K - 1) mod Ilen)); end loop; end if; Result.Current_Length := Count * Ilen; else case Drop is when Strings.Right => Indx := 0; while Indx < Max_Length - Ilen loop Result.Data (Indx + 1 .. Indx + Ilen) := Super_String_Data (Item); pragma Assert (for all K in 1 .. Ilen => Result.Data (Indx + K) = Item (Item'First - 1 + K)); pragma Assert (String (Result.Data (Indx + 1 .. Indx + Ilen)) = Item); Lemma_Split (Forward); Indx := Indx + Ilen; pragma Loop_Invariant (Indx mod Ilen = 0); pragma Loop_Invariant (Indx in 0 .. Max_Length - 1); pragma Loop_Invariant (Result.Data (1 .. Indx)'Initialized); pragma Loop_Invariant (for all K in 1 .. Indx => Result.Data (K) = Item (Item'First + (K - 1) mod Ilen)); end loop; Result.Data (Indx + 1 .. Max_Length) := Super_String_Data (Item (Item'First .. Item'First + (Max_Length - Indx - 1))); pragma Assert (for all J in Indx + 1 .. Max_Length => Result.Data (J) = Item (Item'First - 1 - Indx + J)); for J in Indx + 1 .. Max_Length loop Lemma_Mod (J - 1, Indx); pragma Loop_Invariant (for all K in 1 .. J => Result.Data (K) = Item (Item'First + (K - 1) mod Ilen)); end loop; when Strings.Left => Indx := Max_Length; while Indx > Ilen loop Indx := Indx - Ilen; Result.Data (Indx + 1 .. Indx + Ilen) := Super_String_Data (Item); pragma Assert (for all K in 1 .. Ilen => Result.Data (Indx + K) = Item (Item'First - 1 + K)); pragma Assert (String (Result.Data (Indx + 1 .. Indx + Ilen)) = Item); Lemma_Split (Backward); Lemma_Mod_Zero (Max_Length - Indx - Ilen); pragma Loop_Invariant ((Max_Length - Indx) mod Ilen = 0); pragma Loop_Invariant (Indx in 1 .. Max_Length); pragma Loop_Invariant (Result.Data (Indx + 1 .. Max_Length)'Initialized); pragma Loop_Invariant (for all K in Indx + 1 .. Max_Length => Result.Data (K) = Item (Item'Last - (Max_Length - K) mod Ilen)); end loop; Result.Data (1 .. Indx) := Super_String_Data (Item (Item'Last - Indx + 1 .. Item'Last)); pragma Assert (for all J in 1 .. Indx => Result.Data (J) = Item (Item'Last - Indx + J)); for J in reverse 1 .. Indx loop Lemma_Mod (Max_Length - J, Max_Length - Indx); pragma Loop_Invariant (for all K in J .. Max_Length => Result.Data (K) = Item (Item'Last - (Max_Length - K) mod Ilen)); end loop; when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Replicate; function Super_Replicate (Count : Natural; Item : Super_String; Drop : Strings.Truncation := Strings.Error) return Super_String is begin return Super_Replicate (Count, Super_To_String (Item), Drop, Item.Max_Length); end Super_Replicate; ----------------- -- Super_Slice -- ----------------- function Super_Slice (Source : Super_String; Low : Positive; High : Natural) return Super_String is begin return Result : Super_String (Source.Max_Length) do if Low - 1 > Source.Current_Length or else High > Source.Current_Length then raise Index_Error; end if; if High >= Low then Result.Data (1 .. High - Low + 1) := Source.Data (Low .. High); Result.Current_Length := High - Low + 1; end if; end return; end Super_Slice; procedure Super_Slice (Source : Super_String; Target : out Super_String; Low : Positive; High : Natural) is begin if Low - 1 > Source.Current_Length or else High > Source.Current_Length then raise Index_Error; end if; if High >= Low then Target.Data (1 .. High - Low + 1) := Source.Data (Low .. High); Target.Current_Length := High - Low + 1; else Target.Current_Length := 0; end if; end Super_Slice; ---------------- -- Super_Tail -- ---------------- function Super_Tail (Source : Super_String; Count : Natural; Pad : Character := Space; Drop : Strings.Truncation := Strings.Error) return Super_String is Max_Length : constant Positive := Source.Max_Length; Result : Super_String (Max_Length); Slen : constant Natural := Source.Current_Length; Npad : constant Integer := Count - Slen; begin if Npad <= 0 then if Count > 0 then Result.Data (1 .. Count) := Source.Data (Slen - (Count - 1) .. Slen); Result.Current_Length := Count; end if; elsif Count <= Max_Length then Result.Data (1 .. Npad) := [others => Pad]; if Slen > 0 then Result.Data (Npad + 1 .. Count) := Source.Data (1 .. Slen); end if; Result.Current_Length := Count; else case Drop is when Strings.Right => if Npad >= Max_Length then Result.Data := [others => Pad]; else Result.Data (1 .. Npad) := [others => Pad]; Result.Data (Npad + 1 .. Max_Length) := Source.Data (1 .. Max_Length - Npad); end if; when Strings.Left => Result.Data (1 .. Max_Length - Slen) := [others => Pad]; Result.Data (Max_Length - Slen + 1 .. Max_Length) := Source.Data (1 .. Slen); when Strings.Error => raise Ada.Strings.Length_Error; end case; Result.Current_Length := Max_Length; end if; return Result; end Super_Tail; procedure Super_Tail (Source : in out Super_String; Count : Natural; Pad : Character := Space; Drop : Truncation := Error) is Max_Length : constant Positive := Source.Max_Length; Slen : constant Natural := Source.Current_Length; Npad : constant Integer := Count - Slen; Temp : constant Super_String_Data (1 .. Max_Length) := Source.Data; begin if Npad <= 0 then Source.Current_Length := Count; if Count > 0 then Source.Data (1 .. Count) := Temp (Slen - (Count - 1) .. Slen); end if; elsif Count <= Max_Length then Source.Data (1 .. Npad) := [others => Pad]; if Slen > 0 then Source.Data (Npad + 1 .. Count) := Temp (1 .. Slen); end if; Source.Current_Length := Count; else case Drop is when Strings.Right => if Npad >= Max_Length then Source.Data := [others => Pad]; else Source.Data (1 .. Npad) := [others => Pad]; Source.Data (Npad + 1 .. Max_Length) := Temp (1 .. Max_Length - Npad); end if; when Strings.Left => Source.Data (1 .. Max_Length - Slen) := [others => Pad]; Source.Data (Max_Length - Slen + 1 .. Max_Length) := Temp (1 .. Slen); when Strings.Error => raise Ada.Strings.Length_Error; end case; Source.Current_Length := Max_Length; end if; end Super_Tail; --------------------- -- Super_Translate -- --------------------- function Super_Translate (Source : Super_String; Mapping : Maps.Character_Mapping) return Super_String is Result : Super_String (Source.Max_Length); begin for J in 1 .. Source.Current_Length loop Result.Data (J) := Value (Mapping, Source.Data (J)); pragma Loop_Invariant (Result.Data (1 .. J)'Initialized); pragma Loop_Invariant (for all K in 1 .. J => Result.Data (K) = Value (Mapping, Source.Data (K))); end loop; Result.Current_Length := Source.Current_Length; return Result; end Super_Translate; procedure Super_Translate (Source : in out Super_String; Mapping : Maps.Character_Mapping) is begin for J in 1 .. Source.Current_Length loop Source.Data (J) := Value (Mapping, Source.Data (J)); pragma Loop_Invariant (for all K in 1 .. J => Source.Data (K) = Value (Mapping, Source'Loop_Entry.Data (K))); end loop; end Super_Translate; function Super_Translate (Source : Super_String; Mapping : Maps.Character_Mapping_Function) return Super_String is Result : Super_String (Source.Max_Length); begin for J in 1 .. Source.Current_Length loop Result.Data (J) := Mapping.all (Source.Data (J)); pragma Loop_Invariant (Result.Data (1 .. J)'Initialized); pragma Loop_Invariant (for all K in 1 .. J => Result.Data (K) = Mapping (Source.Data (K))); end loop; Result.Current_Length := Source.Current_Length; return Result; end Super_Translate; procedure Super_Translate (Source : in out Super_String; Mapping : Maps.Character_Mapping_Function) is begin for J in 1 .. Source.Current_Length loop Source.Data (J) := Mapping.all (Source.Data (J)); pragma Loop_Invariant (for all K in 1 .. J => Source.Data (K) = Mapping (Source'Loop_Entry.Data (K))); end loop; end Super_Translate; ---------------- -- Super_Trim -- ---------------- function Super_Trim (Source : Super_String; Side : Trim_End) return Super_String is Result : Super_String (Source.Max_Length); Last : constant Natural := Source.Current_Length; begin case Side is when Strings.Left => declare Low : constant Natural := Super_Index_Non_Blank (Source, Forward); begin -- All blanks case if Low = 0 then return Result; end if; Result.Data (1 .. Last - Low + 1) := Source.Data (Low .. Last); Result.Current_Length := Last - Low + 1; end; when Strings.Right => declare High : constant Natural := Super_Index_Non_Blank (Source, Backward); begin -- All blanks case if High = 0 then return Result; end if; Result.Data (1 .. High) := Source.Data (1 .. High); Result.Current_Length := High; end; when Strings.Both => declare Low : constant Natural := Super_Index_Non_Blank (Source, Forward); begin -- All blanks case if Low = 0 then return Result; end if; declare High : constant Natural := Super_Index_Non_Blank (Source, Backward); begin Result.Data (1 .. High - Low + 1) := Source.Data (Low .. High); Result.Current_Length := High - Low + 1; end; end; end case; return Result; end Super_Trim; procedure Super_Trim (Source : in out Super_String; Side : Trim_End) is Last : constant Natural := Source.Current_Length; begin case Side is when Strings.Left => declare Low : constant Natural := Super_Index_Non_Blank (Source, Forward); begin -- All blanks case if Low = 0 then Source.Current_Length := 0; else Source.Data (1 .. Last - Low + 1) := Source.Data (Low .. Last); Source.Current_Length := Last - Low + 1; end if; end; when Strings.Right => declare High : constant Natural := Super_Index_Non_Blank (Source, Backward); begin Source.Current_Length := High; end; when Strings.Both => declare Low : constant Natural := Super_Index_Non_Blank (Source, Forward); begin -- All blanks case if Low = 0 then Source.Current_Length := 0; else declare High : constant Natural := Super_Index_Non_Blank (Source, Backward); begin Source.Data (1 .. High - Low + 1) := Source.Data (Low .. High); Source.Current_Length := High - Low + 1; end; end if; end; end case; end Super_Trim; function Super_Trim (Source : Super_String; Left : Maps.Character_Set; Right : Maps.Character_Set) return Super_String is Result : Super_String (Source.Max_Length); Low : Natural; High : Natural; begin Low := Super_Index (Source, Left, Outside, Forward); -- Case where source comprises only characters in Left if Low = 0 then return Result; end if; High := Super_Index (Source, Right, Outside, Backward); -- Case where source comprises only characters in Right if High = 0 then return Result; end if; if High >= Low then Result.Data (1 .. High - Low + 1) := Source.Data (Low .. High); Result.Current_Length := High - Low + 1; end if; return Result; end Super_Trim; procedure Super_Trim (Source : in out Super_String; Left : Maps.Character_Set; Right : Maps.Character_Set) is Last : constant Natural := Source.Current_Length; Temp : Super_String_Data (1 .. Last); Low : Natural; High : Natural; begin Temp := Source.Data (1 .. Last); Low := Super_Index (Source, Left, Outside, Forward); -- Case where source comprises only characters in Left if Low = 0 then Source.Current_Length := 0; else High := Super_Index (Source, Right, Outside, Backward); -- Case where source comprises only characters in Right if High = 0 then Source.Current_Length := 0; elsif Low = 1 then Source.Current_Length := High; elsif High < Low then Source.Current_Length := 0; else Source.Data (1 .. High - Low + 1) := Temp (Low .. High); Source.Current_Length := High - Low + 1; end if; end if; end Super_Trim; ----------- -- Times -- ----------- function Times (Left : Natural; Right : Character; Max_Length : Positive) return Super_String is Result : Super_String (Max_Length); begin if Left > Max_Length then raise Ada.Strings.Length_Error; else for J in 1 .. Left loop Result.Data (J) := Right; pragma Loop_Invariant (Result.Data (1 .. J)'Initialized); pragma Loop_Invariant (for all K in 1 .. J => Result.Data (K) = Right); end loop; Result.Current_Length := Left; end if; return Result; end Times; function Times (Left : Natural; Right : String; Max_Length : Positive) return Super_String is Result : Super_String (Max_Length); Pos : Natural := 0; Rlen : constant Natural := Right'Length; Nlen : constant Natural := Left * Rlen; -- Parts of the proof involving manipulations with the modulo operator -- are complicated for the prover and can't be done automatically in -- the global subprogram. That's why we isolate them in these two ghost -- lemmas. procedure Lemma_Mod (K : Integer) with Ghost, Pre => Rlen /= 0 and then Pos mod Rlen = 0 and then Pos in 0 .. Max_Length - Rlen and then K in Pos .. Pos + Rlen - 1, Post => K mod Rlen = K - Pos; -- Lemma_Mod is applied to an index considered in Lemma_Split to prove -- that it has the right value modulo Right'Length. procedure Lemma_Split with Ghost, Pre => Rlen /= 0 and then Pos mod Rlen = 0 and then Pos in 0 .. Max_Length - Rlen and then Result.Data (1 .. Pos + Rlen)'Initialized and then String (Result.Data (Pos + 1 .. Pos + Rlen)) = Right, Post => (for all K in Pos + 1 .. Pos + Rlen => Result.Data (K) = Right (Right'First + (K - 1) mod Rlen)); -- Lemma_Split is used after Result.Data (Pos + 1 .. Pos + Rlen) is -- updated to Right and concludes that the characters match for each -- index when taken modulo Right'Length, as the considered slice starts -- at index 1 modulo Right'Length. --------------- -- Lemma_Mod -- --------------- procedure Lemma_Mod (K : Integer) is null; ----------------- -- Lemma_Split -- ----------------- procedure Lemma_Split is begin for K in Pos + 1 .. Pos + Rlen loop Lemma_Mod (K - 1); pragma Loop_Invariant (for all J in Pos + 1 .. K => Result.Data (J) = Right (Right'First + (J - 1) mod Rlen)); end loop; end Lemma_Split; begin if Nlen > Max_Length then raise Ada.Strings.Length_Error; else if Nlen > 0 then for J in 1 .. Left loop Result.Data (Pos + 1 .. Pos + Rlen) := Super_String_Data (Right); pragma Assert (for all K in 1 .. Rlen => Result.Data (Pos + K) = Right (Right'First - 1 + K)); pragma Assert (String (Result.Data (Pos + 1 .. Pos + Rlen)) = Right); Lemma_Split; Pos := Pos + Rlen; pragma Loop_Invariant (Pos = J * Rlen); pragma Loop_Invariant (Result.Data (1 .. Pos)'Initialized); pragma Loop_Invariant (for all K in 1 .. Pos => Result.Data (K) = Right (Right'First + (K - 1) mod Rlen)); end loop; end if; Result.Current_Length := Nlen; end if; return Result; end Times; function Times (Left : Natural; Right : Super_String) return Super_String is Result : Super_String (Right.Max_Length); Pos : Natural := 0; Rlen : constant Natural := Right.Current_Length; Nlen : constant Natural := Left * Rlen; begin if Nlen > Right.Max_Length then raise Ada.Strings.Length_Error; else if Nlen > 0 then for J in 1 .. Left loop Result.Data (Pos + 1 .. Pos + Rlen) := Right.Data (1 .. Rlen); Pos := Pos + Rlen; pragma Loop_Invariant (Pos = J * Rlen); pragma Loop_Invariant (Result.Data (1 .. Pos)'Initialized); pragma Loop_Invariant (for all K in 1 .. Pos => Result.Data (K) = Right.Data (1 + (K - 1) mod Rlen)); end loop; end if; Result.Current_Length := Nlen; end if; return Result; end Times; --------------------- -- To_Super_String -- --------------------- function To_Super_String (Source : String; Max_Length : Positive; Drop : Truncation := Error) return Super_String is Result : Super_String (Max_Length); Slen : constant Natural := Source'Length; begin if Slen <= Max_Length then Result.Data (1 .. Slen) := Super_String_Data (Source); Result.Current_Length := Slen; else case Drop is when Strings.Right => Result.Data (1 .. Max_Length) := Super_String_Data (Source (Source'First .. Source'First - 1 + Max_Length)); Result.Current_Length := Max_Length; when Strings.Left => Result.Data (1 .. Max_Length) := Super_String_Data (Source (Source'Last - (Max_Length - 1) .. Source'Last)); Result.Current_Length := Max_Length; when Strings.Error => raise Ada.Strings.Length_Error; end case; end if; return Result; end To_Super_String; end Ada.Strings.Superbounded;
BrickBot/Bound-T-H8-300
Ada
5,974
ads
-- Flow.Show (decl) -- -- Textual output of flow-graphs and related data structures. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.8 $ -- $Date: 2015/10/24 19:36:49 $ -- -- $Log: flow-show.ads,v $ -- Revision 1.8 2015/10/24 19:36:49 niklas -- Moved to free licence. -- -- Revision 1.7 2008-01-31 21:57:45 niklas -- BT-CH-0108: Fixes to BT-CH-0098. -- -- Revision 1.6 2007/12/22 15:23:47 niklas -- BT-CH-0101: Option "-trace graph". -- -- Revision 1.5 2006/05/29 11:22:34 niklas -- BT-CH-0023. -- -- Revision 1.4 2006/04/27 08:36:29 niklas -- Added function Locus (Step_Tag_T). -- -- Revision 1.3 2005/04/18 09:30:46 niklas -- Added Report_Unresolved_Flow. -- -- Revision 1.2 2004/04/26 18:27:58 niklas -- First Tidorum version. -- Include Symbol Table parameter in Show_Steps and Show_Nodes. -- Show also Dynamics of Step. -- Catch exceptions in Show_Steps and Show_Nodes. -- -- Revision 1.1 2001/03/21 20:31:24 holsti -- First version. -- with Output; with Symbols; package Flow.Show is function Statements ( Step : Step_T; Source : Symbols.Symbol_Table_T) return Output.Statement_Range_T; -- -- The statement range corresponding to the prime address of -- the given step. function All_Statements ( Step : Step_T; Source : Symbols.Symbol_Table_T) return Output.Statement_Range_T; -- -- The statement range corresponding to all instruction addresses -- involved with the given step. function Statements ( Steps : Step_List_T; Source : Symbols.Symbol_Table_T) return Output.Statement_Range_T; -- -- The statement range corresponding to the prime addresses of -- the given steps. function Locus ( Graph : Graph_T; Source : Symbols.Symbol_Table_T) return Output.Locus_T; -- -- Identifies the location of the instructions covered by -- the flow-graph, in the program under analysis. -- The "statements" part of the result is defined, and -- perhaps also the source-file. -- The symbol-table is needed to map code addresses to -- source locations. function Locus ( Tag : Step_Tag_T; Source : Symbols.Symbol_Table_T) return Output.Locus_T; -- -- Location of the step-tag in the target program. -- The "statements" part of the result is defined, and -- perhaps also the source-file. function Locus ( Step : Step_T; Source : Symbols.Symbol_Table_T) return Output.Locus_T; -- -- Location of the step in the target program. -- The "statements" part of the result is defined, and -- perhaps also the source-file. function Locus ( Node : Node_T; Source : Symbols.Symbol_Table_T) return Output.Locus_T; -- -- Location of the node in the target program. -- The "statements" part of the result is defined, and -- perhaps also the source-file. function Locus ( Edge : Boundable_Edge_T'Class; Source : Symbols.Symbol_Table_T) return Output.Locus_T; -- -- Location of the Edge (actuall the source step) in the -- target program. -- The "statements" part of the result is defined, and -- perhaps also the source-file. procedure Show_Steps ( Graph : in Graph_T; Source : in Symbols.Symbol_Table_T); -- -- Displays the individual steps and step-edges. -- Results on standard output. procedure Show_Nodes ( Graph : in Graph_T; Source : in Symbols.Symbol_Table_T); -- -- Displays the basic-block nodes and the related edges. -- Results on standard output. procedure Trace_Graph ( Graph : in Graph_T; Source : in Symbols.Symbol_Table_T); -- -- Emits the steps and edges in the Graph as Trace lines, in a -- form that allows sorting and comparing by address while -- omitting the step and edge indices (which are more or less -- randomly assigned). procedure Report_Unresolved_Flow ( Graph : in Graph_T; Source : in Symbols.Symbol_Table_T); -- -- Reports the state of the remaining dynamic edges. -- An Unresolved edge is reported as an Error. -- A Stable or Growing edge is reported as a Note. end Flow.Show;
AaronC98/PlaneSystem
Ada
4,737
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; package AWS.Parameters.Set is pragma Obsolescent ("Use same operations from package AWS.Parameters"); procedure Add (Parameter_List : in out List; Name, Value : String; Decode : Boolean := True) with Post => Count (Parameter_List) = Count (Parameter_List'Old) + 1 or else Count (Parameter_List, Name) = Count (Parameter_List'Old, Name) + 1; -- Add a new Key/Value pair into the parameter set. -- If Decode is true, decodes Name and Value. This is used when handling -- multipart/form-data for example. -- A new value is always added, so if there is already a parameter with -- that name, Get will still return the old value. procedure Add (Parameter_List : in out List; Parameters : String) renames Parameters.Add; -- Set parameters for the current request. The Parameters string has the -- form "name1=value1&name2=value2...". The paramaters are added to the -- list. The parameters can start with a '?' (standard Web character -- separator) which is just ignored. procedure Add (Parameter_List : in out List; Parameters : in out AWS.Resources.Streams.Memory.Stream_Type'Class) renames Parameters.Add; -- Same as above, but use different parameters source. Used to reduce -- stack usage on big POST requests. This is the routine used by AWS for -- parsing the POST parameters. This routine also control the maximum -- number of parameter parsed as set by the corresponding configuration -- option. procedure Update (Parameter_List : in out List; Name, Value : String; Decode : Boolean := True); -- Same as Add, but replace an existing parameter if there is one procedure Case_Sensitive (Parameter_List : in out List; Mode : Boolean) renames Parameters.Case_Sensitive; -- If Mode is True it will use all parameters with case sensitivity procedure Reset (Parameter_List : in out List) renames Parameters.Reset; -- Removes all object from the Set. Set will be reinitialized and will be -- ready for new use. Too_Long_Parameter : exception renames Parameters.Too_Long_Parameter; -- Raised if the Add routine detects a too long parameter line when reading -- parameters from Memory_Stream. Too_Many_Parameters : exception renames Parameters.Too_Many_Parameters; -- Raised when the maximum number of parameters has been reached end AWS.Parameters.Set;
reznikmm/matreshka
Ada
3,663
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Language_Asian is type ODF_Style_Language_Asian is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Language_Asian is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Language_Asian;
reznikmm/matreshka
Ada
3,597
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.Elements.Generic_Hash; function AMF.UML.Packages.Hash is new AMF.Elements.Generic_Hash (UML_Package, UML_Package_Access);
reznikmm/matreshka
Ada
6,940
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_Draw.Floating_Frame_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Floating_Frame_Element_Node is begin return Self : Draw_Floating_Frame_Element_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Draw_Floating_Frame_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_Draw_Floating_Frame (ODF.DOM.Draw_Floating_Frame_Elements.ODF_Draw_Floating_Frame_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 Draw_Floating_Frame_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Floating_Frame_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Draw_Floating_Frame_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_Draw_Floating_Frame (ODF.DOM.Draw_Floating_Frame_Elements.ODF_Draw_Floating_Frame_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 Draw_Floating_Frame_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_Draw_Floating_Frame (Visitor, ODF.DOM.Draw_Floating_Frame_Elements.ODF_Draw_Floating_Frame_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.Draw_URI, Matreshka.ODF_String_Constants.Floating_Frame_Element, Draw_Floating_Frame_Element_Node'Tag); end Matreshka.ODF_Draw.Floating_Frame_Elements;
zhmu/ananas
Ada
3,208
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . W I D _ L L I -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Width attribute for signed integers larger than Integer -- Preconditions in this unit are meant for analysis only, not for run-time -- checking, so that the expected exceptions are raised. This is enforced by -- setting the corresponding assertion policy to Ignore. Postconditions and -- contract cases should not be executed at runtime as well, in order not to -- slow down the execution of these functions. pragma Assertion_Policy (Pre => Ignore, Post => Ignore, Contract_Cases => Ignore, Ghost => Ignore); with System.Width_I; package System.Wid_LLI with SPARK_Mode is function Width_Long_Long_Integer is new Width_I (Long_Long_Integer); pragma Pure_Function (Width_Long_Long_Integer); end System.Wid_LLI;
Gabriel-Degret/adalib
Ada
6,061
ads
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Iterator_Interfaces; generic type Key_Type is private; type Element_Type is private; with function Hash (Key : Key_Type) return Hash_Type; with function Equivalent_Keys (Left, Right : Key_Type) return Boolean; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Bounded_Hashed_Maps is pragma Preelaborate(Bounded_Hashed_Maps); pragma Remote_Types(Bounded_Hashed_Maps); type Map (Capacity : Count_Type; Modulus : Hash_Type) is tagged private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; pragma Preelaborable_Initialization(Map); type Cursor is private; pragma Preelaborable_Initialization(Cursor); Empty_Map : constant Map; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package Map_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); function "=" (Left, Right : Map) return Boolean; function Capacity (Container : Map) return Count_Type; procedure Reserve_Capacity (Container : in out Map; Capacity : in Count_Type); function Default_Modulus (Capacity : Count_Type) return Hash_Type; function Length (Container : Map) return Count_Type; function Is_Empty (Container : Map) return Boolean; procedure Clear (Container : in out Map); function Key (Position : Cursor) return Key_Type; function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Map; Position : in Cursor; New_Item : in Element_Type); procedure Query_Element (Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in Element_Type)); procedure Update_Element (Container : in out Map; Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in out Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased in Map; Position : in Cursor) return Constant_Reference_Type; function Reference (Container : aliased in out Map; Position : in Cursor) return Reference_Type; function Constant_Reference (Container : aliased in Map; Key : in Key_Type) return Constant_Reference_Type; function Reference (Container : aliased in out Map; Key : in Key_Type) return Reference_Type; procedure Assign (Target : in out Map; Source : in Map); function Copy (Source : Map; Capacity : Count_Type := 0; Modulus : Hash_Type := 0) return Map; procedure Move (Target : in out Map; Source : in out Map); procedure Insert (Container : in out Map; Key : in Key_Type; New_Item : in Element_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert (Container : in out Map; Key : in Key_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert (Container : in out Map; Key : in Key_Type; New_Item : in Element_Type); procedure Include (Container : in out Map; Key : in Key_Type; New_Item : in Element_Type); procedure Replace (Container : in out Map; Key : in Key_Type; New_Item : in Element_Type); procedure Exclude (Container : in out Map; Key : in Key_Type); procedure Delete (Container : in out Map; Key : in Key_Type); procedure Delete (Container : in out Map; Position : in out Cursor); function First (Container : Map) return Cursor; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Find (Container : Map; Key : Key_Type) return Cursor; function Element (Container : Map; Key : Key_Type) return Element_Type; function Contains (Container : Map; Key : Key_Type) return Boolean; function Equivalent_Keys (Left, Right : Cursor) return Boolean; function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean; function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean; procedure Iterate (Container : in Map; Process : not null access procedure (Position : in Cursor)); function Iterate (Container : in Map) return Map_Iterator_Interfaces.Forward_Iterator'Class; private -- not specified by the language end Ada.Containers.Bounded_Hashed_Maps;
Statkus/json-ada
Ada
660
ads
-- 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. package JSON is pragma Pure; end JSON;
reznikmm/matreshka
Ada
3,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.Attributes; package ODF.DOM.Table_Date_Start_Attributes is pragma Preelaborate; type ODF_Table_Date_Start_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Date_Start_Attribute_Access is access all ODF_Table_Date_Start_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Date_Start_Attributes;
reznikmm/matreshka
Ada
3,978
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Interfaces; package Matreshka.SIMD.Intel.CPUID is pragma Preelaborate; function Highest_CPUID (Extended : Boolean := False) return Interfaces.Unsigned_32; -- Returns highest value of supported 'cpuid' instruction. function Has_AVX return Boolean; -- Returns True when the processor supports the AVX instruction extensions. function Has_POPCNT return Boolean; -- Returns True when the processor supports the POPCNT instruction. function Has_SSE2 return Boolean; -- Returns True when the processor supports the Streaming SIMD Extensions 2 -- Instructions. end Matreshka.SIMD.Intel.CPUID;
jquorning/iNow
Ada
1,686
adb
pragma License (Restricted); -- -- Copyright (C) 2020 Jesper Quorning All Rights Reserved. -- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Directories; with Ada.Text_IO; with Setup; with SQL_Database; package body Files is --------------------------------------------------------------------------- -- Iterate througt Directory adding valid databases to Collection -- procedure Append_Collections (Collection : in out Collection_List; Directory : in String) is use Ada.Directories; DB_Only : constant String := "*." & Setup.Database_Extension; Filter : constant Filter_Type := (Ordinary_File => True, others => False); DB_Search : Search_Type; File_Entry : Directory_Entry_Type; begin if not Exists (Directory) then return; end if; Start_Search (DB_Search, Directory => Directory, Pattern => DB_Only, Filter => Filter); while More_Entries (DB_Search) loop Get_Next_Entry (DB_Search, File_Entry); if SQL_Database.Is_Valid (Full_Name (File_Entry)) then Collection.Append (To_Unbounded_String (Full_Name (File_Entry))); Ada.Text_IO.Put_Line ("Adding => " & Full_Name (File_Entry)); end if; end loop; End_Search (DB_Search); end Append_Collections; end Files;
caqg/linux-home
Ada
37,849
adb
-- Abstract : -- -- see spec. -- -- Copyright (C) 2017 - 2020 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. pragma License (GPL); with Ada.Strings.Fixed; with Ada.Strings.Unbounded; with Ada.Text_IO; with Ada_Process_Actions; -- token_enum_id package body Wisi.Ada is use WisiToken; ---------- -- body local subprograms function Indent_Record (Data : in out Parse_Data_Type; Anchor_Token : in Augmented_Token; Record_Token : in Augmented_Token; Indenting_Token : in Augmented_Token; Indenting_Comment : in Boolean; Offset : in Integer) return Wisi.Delta_Type is use Ada_Process_Actions; begin if Anchor_Token.Byte_Region = Null_Buffer_Region or Record_Token.Byte_Region = Null_Buffer_Region or Indenting_Token.Byte_Region = Null_Buffer_Region then return Null_Delta; end if; if not Indenting_Comment and Indenting_Token.ID = +RECORD_ID then -- Indenting 'record' return Indent_Anchored_2 (Data, Anchor_Token.Line, Record_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type, Accumulate => True); elsif Indenting_Comment and Indenting_Token.ID = +WITH_ID then -- comment before 'record'. test/ada_mode-nominal-child.ads Child_Type_1 return Indent_Anchored_2 (Data, Anchor_Token.Line, Indenting_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type, Accumulate => True); elsif Indenting_Comment and Indenting_Token.ID = +IS_ID then -- comment after 'is' if Record_Token.ID = +RECORD_ID then -- before 'record'. test/ada_mode-nominal.ads Record_Type_1 return Indent_Anchored_2 (Data, Anchor_Token.Line, Indenting_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type, Accumulate => True); else -- not before 'record'. test/ada_mode-nominal-child.ads Child_Type_1 return (Simple, (Int, Offset)); end if; else -- Indenting other comment, component or 'end' -- -- Ensure 'record' line is anchored. if not (Data.Indents (Record_Token.Line).Label = Anchored or Data.Indents (Record_Token.Line).Label = Anchor_Anchored) then if Anchor_Token.Line /= Record_Token.Line then -- We don't pass Indenting_Comment here, because 'record' is code. Indent_Token_1 (Data, Record_Token, Indent_Anchored_2 (Data, Anchor_Token.Line, Record_Token.Last_Line (Indenting_Comment => False), Ada_Indent_Record_Rel_Type, Accumulate => True), Indenting_Comment => False); end if; end if; return Indent_Anchored_2 (Data, Anchor_Line => Anchor_Token.Line, Last_Line => Indenting_Token.Last_Line (Indenting_Comment), Offset => Current_Indent_Offset (Data, Anchor_Token, Offset => (if Anchor_Token.Line = Record_Token.Line then Offset else Offset + Ada_Indent_Record_Rel_Type)), Accumulate => True); end if; end Indent_Record; ---------- -- Refactor body subprograms function Find_ID_At (Tree : in WisiToken.Syntax_Trees.Tree; Terminals : in Augmented_Token_Arrays.Vector; ID : in Token_ID; Edit_Begin : in WisiToken.Buffer_Pos) return WisiToken.Syntax_Trees.Node_Index is use WisiToken.Syntax_Trees; function Match (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean is begin return Tree.ID (Node) = ID and then Terminals (Tree.Min_Terminal_Index (Node)).Byte_Region.First = Edit_Begin; end Match; begin return Tree.Find_Descendant (Tree.Root, Predicate => Match'Access); end Find_ID_At; procedure Unrecognized (Expecting : in String; Found : in WisiToken.Syntax_Trees.Valid_Node_Index; Edit_Begin : in WisiToken.Buffer_Pos) with No_Return is begin raise SAL.Parameter_Error with "unrecognized subprogram call at byte_pos" & Edit_Begin'Image & "; expecting " & Expecting & " found node" & Found'Image; end Unrecognized; procedure Method_Object_To_Object_Method (Tree : in WisiToken.Syntax_Trees.Tree; Data : in out Parse_Data_Type; Edit_Begin : in WisiToken.Buffer_Pos) is -- Data.Tree contains one statement or declaration; Edit_Begin is at -- start of a subprogram call. Convert the subprogram call from -- Prefix.Method (Object, ...) to Object.Method (...). use Ada_Process_Actions; use Standard.Ada.Strings.Unbounded; use Standard.Ada.Text_IO; use WisiToken.Syntax_Trees; Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin); Edit_End : WisiToken.Buffer_Pos; Method : Valid_Node_Index; Temp : Node_Index; Association_List : Node_Index; Object : Valid_Node_Index; Result : Unbounded_String; begin if Call = Invalid_Node_Index then -- Most likely the edit point is wrong. raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image; elsif not (Tree.RHS_Index (Call) in 1 | 3) then raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image & " (found node" & Call'Image & ")"; end if; if WisiToken.Trace_Action > Detail then Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'"); end if; if Tree.RHS_Index (Call) = 3 then -- Code looks like: Length (Container)'Old. We only want to edit -- 'Length (Container)', keeping the trailing 'Old. Call := Tree.Child (Tree.Child (Call, 1), 1); end if; Association_List := Tree.Child (Tree.Child (Call, 2), 2); Edit_End := Tree.Byte_Region (Call).Last; Method := Tree.Child (Tree.Child (Call, 1), 1); loop case To_Token_Enum (Tree.ID (Method)) is when selected_component_ID | attribute_reference_ID => Method := Tree.Child (Method, 3); when qualified_expression_ID => Method := Tree.Child (Method, 3); -- aggregate if Tree.ID (Tree.Child (Method, 2)) = +association_list_ID then Method := Tree.Child (Method, 2); if Tree.RHS_Index (Method) = 1 then Temp := Tree.Find_Descendant (Tree.Child (Method, 1), +expression_ID); if Temp = Invalid_Node_Index then Unrecognized ("expression", Tree.Child (Method, 1), Edit_Begin); else Method := Temp; exit; end if; else Unrecognized ("association", Method, Edit_Begin); end if; else Unrecognized ("association_list", Method, Edit_Begin); end if; when IDENTIFIER_ID | STRING_LITERAL_ID => exit; when others => Unrecognized ("supported token", Method, Edit_Begin); end case; end loop; Temp := Tree.Find_Descendant (Association_List, +expression_ID); if Temp = Invalid_Node_Index then Unrecognized ("expression", Association_List, Edit_Begin); else Object := Temp; end if; -- Build remaining arg list in Result. loop if Tree.RHS_Index (Association_List) = 0 then Result := Get_Text (Data, Tree, Tree.Child (Association_List, 3)) & (if Length (Result) = 0 then "" else ", ") & Result; Association_List := Tree.Child (Association_List, 1); else -- The remaining element in Association_List is the first one, which is Object. if Length (Result) > 0 then Result := " (" & Result & ")"; end if; exit; end if; end loop; Result := (Get_Text (Data, Tree, Object) & "." & Get_Text (Data, Tree, Method)) & Result; Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ & Elisp_Escape_Quotes (To_String (Result)) & """]"); end Method_Object_To_Object_Method; procedure Object_Method_To_Method_Object (Tree : in WisiToken.Syntax_Trees.Tree; Data : in out Parse_Data_Type; Edit_Begin : in WisiToken.Buffer_Pos) is -- Data.Tree contains one statement or declaration; Edit_Begin is at -- start of a subprogram call. Convert the subprogram call from -- Object.Method (...) to Method (Object, ...). use Ada_Process_Actions; use Standard.Ada.Strings.Unbounded; use Standard.Ada.Text_IO; use WisiToken.Syntax_Trees; Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin); Edit_End : WisiToken.Buffer_Pos; Object_Method : Valid_Node_Index; Method : Unbounded_String; Object : Unbounded_String; Result : Unbounded_String; begin if Call = Invalid_Node_Index then -- Most likely the edit point is wrong. raise SAL.Parameter_Error with "no 'name' at byte_pos" & Edit_Begin'Image; elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image & " (found node" & Call'Image & ")"; end if; if WisiToken.Trace_Action > Detail then Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'"); end if; if Tree.RHS_Index (Call) = 3 then -- Code looks like: Container.Length'Old. We only want to edit -- 'Container.Length', keeping the trailing 'Old. Call := Tree.Child (Tree.Child (Call, 1), 1); end if; Edit_End := Tree.Byte_Region (Call).Last; Object_Method := Tree.Child (Call, 1); loop case To_Token_Enum (Tree.ID (Object_Method)) is when name_ID => Object_Method := Tree.Child (Object_Method, 1); when selected_component_ID => Object := +Get_Text (Data, Tree, Tree.Child (Object_Method, 1)); Method := +Get_Text (Data, Tree, Tree.Child (Object_Method, 3)); exit; when others => Unrecognized ("supported token", Object_Method, Edit_Begin); end case; end loop; Result := Method & " (" & Object; if Tree.RHS_Index (Call) = 1 then Result := Result & ", " & Get_Text (Data, Tree, Tree.Child (Tree.Child (Call, 2), 2)); end if; Result := Result & ")"; Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ & Elisp_Escape_Quotes (To_String (Result)) & """]"); end Object_Method_To_Method_Object; procedure Element_Object_To_Object_Index (Tree : in WisiToken.Syntax_Trees.Tree; Data : in out Parse_Data_Type; Edit_Begin : in WisiToken.Buffer_Pos) is -- Data.Tree contains one statement or declaration; Edit_Begin is at -- start of a subprogram call. Convert the subprogram call from -- Prefix.Element (Object, Index) to Object (Index). use Ada_Process_Actions; use Standard.Ada.Text_IO; use WisiToken.Syntax_Trees; Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin); Edit_End : WisiToken.Buffer_Pos; Temp : Node_Index; Association_List : Node_Index; Object : Valid_Node_Index; Index : Valid_Node_Index; begin if Call = Invalid_Node_Index then -- Most likely the edit point is wrong. raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image; elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image & " (found node" & Call'Image & ")"; end if; if WisiToken.Trace_Action > Detail then Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'"); end if; if Tree.RHS_Index (Call) = 2 then -- Code looks like: Element (Container, I).Op. We only want to edit -- the subprogram call, keeping the trailing .Op. Call := Tree.Child (Tree.Child (Call, 1), 1); elsif Tree.RHS_Index (Call) = 3 then -- Code looks like: Element (Container, I)'Old. We only want to edit -- the subprogram call, keeping the trailing 'Old. Call := Tree.Child (Tree.Child (Call, 1), 1); end if; Association_List := Tree.Child (Tree.Child (Call, 2), 2); Edit_End := Tree.Byte_Region (Call).Last; if Tree.RHS_Index (Association_List) /= 0 then Unrecognized ("two args", Association_List, Edit_Begin); end if; Temp := Tree.Find_Descendant (Association_List, +expression_ID); if Temp = Invalid_Node_Index then Unrecognized ("expression", Association_List, Edit_Begin); else Object := Temp; end if; Temp := Tree.Find_Descendant (Tree.Child (Association_List, 3), +expression_ID); if Temp = Invalid_Node_Index then Unrecognized ("expression", Association_List, Edit_Begin); else Index := Temp; end if; Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ & Elisp_Escape_Quotes (Get_Text (Data, Tree, Object) & " (" & Get_Text (Data, Tree, Index) & ")") & """]"); end Element_Object_To_Object_Index; procedure Object_Index_To_Element_Object (Tree : in WisiToken.Syntax_Trees.Tree; Data : in out Parse_Data_Type; Edit_Begin : in WisiToken.Buffer_Pos) is -- Data.Tree contains one statement or declaration; Edit_Begin is at -- start of a subprogram call. Convert the subprogram call from -- Object (Index) to Element (Object, Index). use Ada_Process_Actions; use Standard.Ada.Text_IO; use WisiToken.Syntax_Trees; Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin); Edit_End : WisiToken.Buffer_Pos; Temp : Node_Index; Association_List : Node_Index; Object : Valid_Node_Index; Index : Valid_Node_Index; begin if Call = Invalid_Node_Index then -- Most likely the edit point is wrong. raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image; elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image & " (found node" & Call'Image & ")"; end if; if WisiToken.Trace_Action > Detail then Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'"); end if; if Tree.RHS_Index (Call) = 2 then -- Code looks like: Object (I).Component. We only want to edit -- the subprogram call, keeping the trailing .Component. Call := Tree.Child (Tree.Child (Call, 1), 1); elsif Tree.RHS_Index (Call) = 3 then -- Code looks like: Container (I)'Old. We only want to edit -- the subprogram call, keeping the trailing 'Old. Call := Tree.Child (Tree.Child (Call, 1), 1); end if; Object := Tree.Child (Tree.Child (Call, 1), 1); Association_List := Tree.Child (Tree.Child (Call, 2), 2); Edit_End := Tree.Byte_Region (Call).Last; if Tree.RHS_Index (Association_List) /= 1 then Unrecognized ("one args", Association_List, Edit_Begin); end if; Temp := Tree.Find_Descendant (Tree.Child (Association_List, 1), +expression_ID); if Temp = Invalid_Node_Index then Unrecognized ("expression", Association_List, Edit_Begin); else Index := Temp; end if; Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ & Elisp_Escape_Quotes ("Element (" & Get_Text (Data, Tree, Object) & ", " & Get_Text (Data, Tree, Index) & ")") & """]"); end Object_Index_To_Element_Object; procedure Format_Parameter_List (Tree : in WisiToken.Syntax_Trees.Tree; Data : in out Parse_Data_Type; Edit_Begin : in WisiToken.Buffer_Pos) is separate; -- Data.Tree contains a subprogram declaration or body; Edit_Begin is -- at the start of a parameter list. Format the parameter list. -- -- Handle virtual tokens as much as possible; at least closing paren. ---------- -- Public subprograms, declaration order overriding procedure Initialize (Data : in out Parse_Data_Type; Lexer : in WisiToken.Lexer.Handle; Descriptor : access constant WisiToken.Descriptor; Base_Terminals : in WisiToken.Base_Token_Array_Access; Post_Parse_Action : in Post_Parse_Action_Type; Begin_Line : in WisiToken.Line_Number_Type; End_Line : in WisiToken.Line_Number_Type; Begin_Indent : in Integer; Params : in String) is use Standard.Ada.Strings.Fixed; use all type Ada_Process_Actions.Token_Enum_ID; First : Integer := Params'First; Last : Integer := Index (Params, " "); begin Wisi.Initialize (Wisi.Parse_Data_Type (Data), Lexer, Descriptor, Base_Terminals, Post_Parse_Action, Begin_Line, End_Line, Begin_Indent, ""); Data.First_Comment_ID := +COMMENT_ID; Data.Last_Comment_ID := WisiToken.Invalid_Token_ID; Data.Left_Paren_ID := +LEFT_PAREN_ID; Data.Right_Paren_ID := +RIGHT_PAREN_ID; Data.Embedded_Quote_Escape_Doubled := True; if Params /= "" then Ada_Indent := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Broken := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := First + 1; Ada_Indent_Comment_Col_0 := Params (First) = '1'; First := Last + 1; Last := First + 1; Ada_Indent_Comment_GNAT := Params (First) = '1'; First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Label := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Record_Rel_Type := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Renames := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Return := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_Use := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_When := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := Index (Params, " ", First); Ada_Indent_With := Integer'Value (Params (First .. Last - 1)); First := Last + 1; Last := First + 1; Ada_Indent_Hanging_Rel_Exp := Params (First) = '1'; First := Last + 1; Last := First + 1; End_Names_Optional := Params (First) = '1'; end if; Data.Indent_Comment_Col_0 := Ada_Indent_Comment_Col_0; end Initialize; overriding procedure Refactor (Data : in out Parse_Data_Type; Tree : in WisiToken.Syntax_Trees.Tree; Action : in Positive; Edit_Begin : in WisiToken.Buffer_Pos) is -- Must match "ada-refactor-*" in ada-wisi.el Method_Object_To_Object_Method : constant Positive := 1; Object_Method_To_Method_Object : constant Positive := 2; Element_Object_To_Object_Index : constant Positive := 3; Object_Index_To_Element_Object : constant Positive := 4; Format_Parameter_List : constant Positive := 5; begin if WisiToken.Trace_Action > Detail then Tree.Print_Tree (Data.Descriptor.all); end if; case Action is when Method_Object_To_Object_Method => Wisi.Ada.Method_Object_To_Object_Method (Tree, Data, Edit_Begin); when Object_Method_To_Method_Object => Wisi.Ada.Object_Method_To_Method_Object (Tree, Data, Edit_Begin); when Element_Object_To_Object_Index => Wisi.Ada.Element_Object_To_Object_Index (Tree, Data, Edit_Begin); when Object_Index_To_Element_Object => Wisi.Ada.Object_Index_To_Element_Object (Tree, Data, Edit_Begin); when Format_Parameter_List => Wisi.Ada.Format_Parameter_List (Tree, Data, Edit_Begin); when others => Standard.Ada.Text_IO.Put_Line ("(error ""unrecognized refactor action " & Action'Image & """)"); end case; end Refactor; overriding function Indent_Hanging_1 (Data : in out Parse_Data_Type; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Delta_1 : in Simple_Indent_Param; Delta_2 : in Simple_Indent_Param; Option : in Boolean; Accumulate : in Boolean) return Delta_Type is use all type Syntax_Trees.Node_Index; Indenting_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting); function Result (Delta_1 : in Simple_Indent_Param; Delta_2 : in Simple_Delta_Type) return Delta_Type is begin return (Hanging, Hanging_First_Line => Indenting_Token.Line, Hanging_Paren_State => Indenting_Token.Paren_State, Hanging_Delta_1 => Indent_Compute_Delta (Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta, Hanging_Delta_2 => Delta_2, Hanging_Accumulate => Accumulate); end Result; function Result (Delta_1 : in Simple_Delta_Type) return Delta_Type is begin return (Hanging, Hanging_First_Line => Indenting_Token.Line, Hanging_Paren_State => Indenting_Token.Paren_State, Hanging_Delta_1 => Delta_1, Hanging_Delta_2 => Delta_1, Hanging_Accumulate => Accumulate); end Result; function Comment_Result (D : in Simple_Indent_Param) return Delta_Type is begin return Indent_Compute_Delta (Data, Tree, Tokens, (Simple, D), Tree_Indenting, Indenting_Comment => False); end Comment_Result; use Ada_Process_Actions; begin if Tree.ID (Tree.Parent (Tree_Indenting)) = +association_opt_ID and then Syntax_Trees.Invalid_Node_Index /= Tree.Find_Ancestor (Tree_Indenting, +aspect_specification_opt_ID) then -- In aspect_specification_opt -- See ada.wy association_opt for test cases if not Indenting_Comment then return Result (Delta_1, Indent_Anchored_2 (Data, Indenting_Token.Line, Indenting_Token.Last_Indent_Line, Current_Indent_Offset (Data, Indenting_Token, 0), Accumulate => False).Simple_Delta); else -- Test case in test/aspects.ads return Result (Indent_Compute_Delta (Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta); end if; elsif Ada_Indent_Hanging_Rel_Exp then declare New_Delta_2 : constant Simple_Delta_Type := Indent_Anchored_2 (Data, Indenting_Token.Line, Indenting_Token.Last_Indent_Line, Current_Indent_Offset (Data, Indenting_Token, Ada_Indent_Broken), Accumulate => False).Simple_Delta; begin if not Option or Indenting_Token.Line = Indenting_Token.First_Indent_Line then return Result (Delta_1, New_Delta_2); else return Result (New_Delta_2); end if; end; elsif Indenting_Comment then -- Use delta for last line of Indenting_Token. -- Test cases in test/ada_mode-parens.adb Hello declare First_Terminal : Augmented_Token renames Data.Terminals (Indenting_Token.First_Terminals_Index); begin if Option then -- Test cases with "Item => ..." if First_Terminal.First then if Indenting_Token.First_Indent_Line = Indenting_Token.Last_Indent_Line then return Comment_Result (Delta_1); else return Comment_Result (Delta_2); end if; else if Indenting_Token.First_Indent_Line = Invalid_Line_Number then return Comment_Result ((Int, 0)); else return Comment_Result (Delta_1); end if; end if; else if First_Terminal.First then if Indenting_Token.First_Indent_Line = Indenting_Token.Last_Indent_Line then return Comment_Result (Delta_1); else return Comment_Result (Delta_2); end if; else if Indenting_Token.First_Indent_Line = Invalid_Line_Number then -- Comment is after first line in token return Comment_Result (Delta_1); else return Comment_Result (Delta_2); end if; end if; end if; end; elsif not Option or Indenting_Token.Line = Indenting_Token.First_Indent_Line then return Result (Delta_1, Indent_Compute_Delta (Data, Tree, Tokens, (Simple, Delta_2), Tree_Indenting, Indenting_Comment).Simple_Delta); else return Result (Indent_Compute_Delta (Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta); end if; end Indent_Hanging_1; function Ada_Indent_Aggregate (Data : in out Wisi.Parse_Data_Type'Class; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type is pragma Unreferenced (Data); pragma Unreferenced (Indenting_Comment); pragma Unreferenced (Args); pragma Unreferenced (Tokens); use all type Syntax_Trees.Node_Index; use Ada_Process_Actions; -- In our grammar, 'aggregate' can be an Ada aggregate, or a -- parenthesized expression. -- -- We always want an 'aggregate' to be indented by ada-indent-broken. -- However, in some places in the grammar, 'aggregate' is indented by -- ada-indent. The following checks for those places, and returns a -- correction value. The aggregate may be nested inside a conidtional -- expression, so we search for 'name' as well; see -- test/ada_mode-conditional_expressions-more_1.adb. Expression : constant Syntax_Trees.Node_Index := Tree.Find_Ancestor (Tree_Indenting, (+expression_opt_ID, +name_ID)); begin if Expression = Syntax_Trees.Invalid_Node_Index or else Tree.Parent (Expression) = Syntax_Trees.Invalid_Node_Index then return Null_Delta; elsif Tree.ID (Tree.Parent (Expression)) in +if_expression_ID | +elsif_expression_item_ID | +case_expression_alternative_ID then -- The controlling boolean expression in 'if_expression' and -- 'elsif_expression_item' cannot be an aggregate in legal Ada -- syntax. return (Simple, (Int, Ada_Indent_Broken - Ada_Indent)); else return Null_Delta; end if; end Ada_Indent_Aggregate; function Ada_Indent_Renames_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Indent_Arg_Arrays.Vector) return Wisi.Delta_Type is Subp_Tok : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1))))); Renames_Tok : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting); Paren_I : Base_Token_Index; begin if Subp_Tok.Char_Region = Null_Buffer_Region then -- built from entirely virtual tokens return Null_Delta; end if; Paren_I := Data.Find (Data.Left_Paren_ID, Subp_Tok); if Paren_I /= Augmented_Token_Arrays.No_Index then -- paren is present declare Paren_Tok : Augmented_Token renames Data.Terminals (Paren_I); begin if Ada_Indent_Renames > 0 then return Indent_Anchored_2 (Data, Anchor_Line => Subp_Tok.Line, Last_Line => Renames_Tok.Last_Line (Indenting_Comment), Offset => Ada_Indent_Renames, Accumulate => True); else return Indent_Anchored_2 (Data, Anchor_Line => Paren_Tok.Line, Last_Line => Renames_Tok.Last_Line (Indenting_Comment), Offset => Current_Indent_Offset (Data, Paren_Tok, abs Ada_Indent_Renames), Accumulate => True); end if; end; else return Indent_Anchored_2 (Data, Anchor_Line => Subp_Tok.Line, Last_Line => Renames_Tok.Last_Line (Indenting_Comment), Offset => Ada_Indent_Broken, Accumulate => True); end if; end Ada_Indent_Renames_0; function Ada_Indent_Return_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type is use all type Ada_Process_Actions.Token_Enum_ID; -- Tokens (Args (1)) = 'formal_part' -- Indenting = 'result_profile' -- Args (2) = delta (= 0!) -- -- We are indenting 'result_profile' in -- 'parameter_and_result_profile'. The indent depends on whether the -- 'formal_part' is present, and the location of 'FUNCTION'. Parameter_And_Result_Profile : constant Syntax_Trees.Valid_Node_Index := Tree.Parent (Tree_Indenting); Indenting : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting); begin if Indenting.Line = Indenting.First_Indent_Line then if Ada_Indent_Return <= 0 then declare Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1))))); begin return Indent_Anchored_2 (Data, Anchor_Line => Anchor_Token.Line, Last_Line => Indenting.Last_Line (Indenting_Comment), Offset => Current_Indent_Offset (Data, Anchor_Token, Args (2) + abs Ada_Indent_Return), Accumulate => True); end; else declare Function_N : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Sibling (Parameter_And_Result_Profile, +FUNCTION_ID); Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Function_N); begin return Indent_Anchored_2 (Data, Anchor_Line => Anchor_Token.Line, Last_Line => Indenting.Last_Line (Indenting_Comment), Offset => Current_Indent_Offset (Data, Anchor_Token, Args (2) + abs Ada_Indent_Return), Accumulate => True); end; end if; else return Null_Delta; end if; end Ada_Indent_Return_0; function Ada_Indent_Record_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type is begin return Indent_Record (Parse_Data_Type (Data), Anchor_Token => Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1))))), Record_Token => Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (2))))), Offset => Args (3), Indenting_Token => Get_Aug_Token (Data, Tree, Tree_Indenting), Indenting_Comment => Indenting_Comment); end Ada_Indent_Record_0; function Ada_Indent_Record_1 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in Syntax_Trees.Tree; Tokens : in Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type is -- We are indenting a token in record_definition or -- record_representation_clause, or a comment before 'record'. -- -- If record_definition, args (1) is the token ID of the anchor (= -- TYPE); it appears as a direct child in an ancestor -- full_type_declaration. -- -- If record_representation_clause, args (1) is FOR, child of -- record_representation_clause. use all type WisiToken.Syntax_Trees.Node_Label; use Ada_Process_Actions; Anchor : constant Token_ID := Token_ID (Integer'(Args (1))); Declaration : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Ancestor (Tree_Indenting, (if To_Token_Enum (Anchor) = TYPE_ID then +full_type_declaration_ID else +record_representation_clause_ID)); Tree_Anchor : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Child (Declaration, Anchor); begin if Tree.Label (Tree_Anchor) /= WisiToken.Syntax_Trees.Shared_Terminal then -- Anchor is virtual; Indent_Record would return Null_Delta return Null_Delta; end if; declare Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Anchor); -- Args (2) is the index of RECORD (or a nonterminal possibly -- starting with RECORD) in Tokens Record_Token_Tree_Index : constant Syntax_Trees.Node_Index := Tokens (Positive_Index_Type (Integer'(Args (2)))); Record_Token : constant Aug_Token_Ref := (case Tree.Label (Record_Token_Tree_Index) is when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Get_Aug_Token (Data, Tree, Record_Token_Tree_Index), when Nonterm => To_Aug_Token_Ref (Data.Terminals (Tree.Min_Terminal_Index (Record_Token_Tree_Index)))); Indenting_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting); begin -- Args (3) is the offset return Indent_Record (Parse_Data_Type (Data), Anchor_Token, Record_Token, Indenting_Token, Indenting_Comment, Args (3)); end; end Ada_Indent_Record_1; end Wisi.Ada;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
8,692
ads
-- This spec has been automatically generated from STM32F072x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.Flash is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ACR_LATENCY_Field is STM32_SVD.UInt3; subtype ACR_PRFTBE_Field is STM32_SVD.Bit; subtype ACR_PRFTBS_Field is STM32_SVD.Bit; -- Flash access control register type ACR_Register is record -- LATENCY LATENCY : ACR_LATENCY_Field := 16#0#; -- unspecified Reserved_3_3 : STM32_SVD.Bit := 16#0#; -- PRFTBE PRFTBE : ACR_PRFTBE_Field := 16#1#; -- Read-only. PRFTBS PRFTBS : ACR_PRFTBS_Field := 16#1#; -- unspecified Reserved_6_31 : STM32_SVD.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACR_Register use record LATENCY at 0 range 0 .. 2; Reserved_3_3 at 0 range 3 .. 3; PRFTBE at 0 range 4 .. 4; PRFTBS at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; subtype SR_BSY_Field is STM32_SVD.Bit; subtype SR_PGERR_Field is STM32_SVD.Bit; subtype SR_WRPRT_Field is STM32_SVD.Bit; subtype SR_EOP_Field is STM32_SVD.Bit; -- Flash status register type SR_Register is record -- Read-only. Busy BSY : SR_BSY_Field := 16#0#; -- unspecified Reserved_1_1 : STM32_SVD.Bit := 16#0#; -- Programming error PGERR : SR_PGERR_Field := 16#0#; -- unspecified Reserved_3_3 : STM32_SVD.Bit := 16#0#; -- Write protection error WRPRT : SR_WRPRT_Field := 16#0#; -- End of operation EOP : SR_EOP_Field := 16#0#; -- unspecified Reserved_6_31 : STM32_SVD.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record BSY at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; PGERR at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; WRPRT at 0 range 4 .. 4; EOP at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; subtype CR_PG_Field is STM32_SVD.Bit; subtype CR_PER_Field is STM32_SVD.Bit; subtype CR_MER_Field is STM32_SVD.Bit; subtype CR_OPTPG_Field is STM32_SVD.Bit; subtype CR_OPTER_Field is STM32_SVD.Bit; subtype CR_STRT_Field is STM32_SVD.Bit; subtype CR_LOCK_Field is STM32_SVD.Bit; subtype CR_OPTWRE_Field is STM32_SVD.Bit; subtype CR_ERRIE_Field is STM32_SVD.Bit; subtype CR_EOPIE_Field is STM32_SVD.Bit; subtype CR_FORCE_OPTLOAD_Field is STM32_SVD.Bit; -- Flash control register type CR_Register is record -- Programming PG : CR_PG_Field := 16#0#; -- Page erase PER : CR_PER_Field := 16#0#; -- Mass erase MER : CR_MER_Field := 16#0#; -- unspecified Reserved_3_3 : STM32_SVD.Bit := 16#0#; -- Option byte programming OPTPG : CR_OPTPG_Field := 16#0#; -- Option byte erase OPTER : CR_OPTER_Field := 16#0#; -- Start STRT : CR_STRT_Field := 16#0#; -- Lock LOCK : CR_LOCK_Field := 16#1#; -- unspecified Reserved_8_8 : STM32_SVD.Bit := 16#0#; -- Option bytes write enable OPTWRE : CR_OPTWRE_Field := 16#0#; -- Error interrupt enable ERRIE : CR_ERRIE_Field := 16#0#; -- unspecified Reserved_11_11 : STM32_SVD.Bit := 16#0#; -- End of operation interrupt enable EOPIE : CR_EOPIE_Field := 16#0#; -- Force option byte loading FORCE_OPTLOAD : CR_FORCE_OPTLOAD_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record PG at 0 range 0 .. 0; PER at 0 range 1 .. 1; MER at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; OPTPG at 0 range 4 .. 4; OPTER at 0 range 5 .. 5; STRT at 0 range 6 .. 6; LOCK at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; OPTWRE at 0 range 9 .. 9; ERRIE at 0 range 10 .. 10; Reserved_11_11 at 0 range 11 .. 11; EOPIE at 0 range 12 .. 12; FORCE_OPTLOAD at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype OBR_OPTERR_Field is STM32_SVD.Bit; subtype OBR_LEVEL1_PROT_Field is STM32_SVD.Bit; subtype OBR_LEVEL2_PROT_Field is STM32_SVD.Bit; subtype OBR_WDG_SW_Field is STM32_SVD.Bit; subtype OBR_nRST_STOP_Field is STM32_SVD.Bit; subtype OBR_nRST_STDBY_Field is STM32_SVD.Bit; subtype OBR_BOOT1_Field is STM32_SVD.Bit; subtype OBR_VDDA_MONITOR_Field is STM32_SVD.Bit; -- OBR_Data array element subtype OBR_Data_Element is STM32_SVD.Byte; -- OBR_Data array type OBR_Data_Field_Array is array (0 .. 1) of OBR_Data_Element with Component_Size => 8, Size => 16; -- Type definition for OBR_Data type OBR_Data_Field (As_Array : Boolean := False) is record case As_Array is when False => -- Data as a value Val : STM32_SVD.UInt16; when True => -- Data as an array Arr : OBR_Data_Field_Array; end case; end record with Unchecked_Union, Size => 16; for OBR_Data_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- Option byte register type OBR_Register is record -- Read-only. Option byte error OPTERR : OBR_OPTERR_Field; -- Read-only. Level 1 protection status LEVEL1_PROT : OBR_LEVEL1_PROT_Field; -- Read-only. Level 2 protection status LEVEL2_PROT : OBR_LEVEL2_PROT_Field; -- unspecified Reserved_3_7 : STM32_SVD.UInt5; -- Read-only. WDG_SW WDG_SW : OBR_WDG_SW_Field; -- Read-only. nRST_STOP nRST_STOP : OBR_nRST_STOP_Field; -- Read-only. nRST_STDBY nRST_STDBY : OBR_nRST_STDBY_Field; -- unspecified Reserved_11_11 : STM32_SVD.Bit; -- Read-only. BOOT1 BOOT1 : OBR_BOOT1_Field; -- Read-only. VDDA_MONITOR VDDA_MONITOR : OBR_VDDA_MONITOR_Field; -- unspecified Reserved_14_15 : STM32_SVD.UInt2; -- Read-only. Data0 Data : OBR_Data_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OBR_Register use record OPTERR at 0 range 0 .. 0; LEVEL1_PROT at 0 range 1 .. 1; LEVEL2_PROT at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; WDG_SW at 0 range 8 .. 8; nRST_STOP at 0 range 9 .. 9; nRST_STDBY at 0 range 10 .. 10; Reserved_11_11 at 0 range 11 .. 11; BOOT1 at 0 range 12 .. 12; VDDA_MONITOR at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; Data at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Flash type Flash_Peripheral is record -- Flash access control register ACR : aliased ACR_Register; -- Flash key register KEYR : aliased STM32_SVD.UInt32; -- Flash option key register OPTKEYR : aliased STM32_SVD.UInt32; -- Flash status register SR : aliased SR_Register; -- Flash control register CR : aliased CR_Register; -- Flash address register AR : aliased STM32_SVD.UInt32; -- Option byte register OBR : aliased OBR_Register; -- Write protection register WRPR : aliased STM32_SVD.UInt32; end record with Volatile; for Flash_Peripheral use record ACR at 16#0# range 0 .. 31; KEYR at 16#4# range 0 .. 31; OPTKEYR at 16#8# range 0 .. 31; SR at 16#C# range 0 .. 31; CR at 16#10# range 0 .. 31; AR at 16#14# range 0 .. 31; OBR at 16#1C# range 0 .. 31; WRPR at 16#20# range 0 .. 31; end record; -- Flash Flash_Periph : aliased Flash_Peripheral with Import, Address => System'To_Address (16#40022000#); end STM32_SVD.Flash;
reznikmm/matreshka
Ada
6,412
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, 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.CMOF.Classes; with AMF.CMOF.Properties; limited with AMF.Extents; with League.Holders; package AMF.Elements is pragma Preelaborate; type Abstract_Element is limited interface; type Element_Access is access all Abstract_Element'Class; ---------------------- -- MOF Operations -- ---------------------- not overriding function Get_Meta_Class (Self : not null access constant Abstract_Element) return AMF.CMOF.Classes.CMOF_Class_Access is abstract; -- Returns the Class that describes this element. not overriding function Container (Self : not null access constant Abstract_Element) return AMF.Elements.Element_Access is abstract; -- Returns the parent container of this element if any. Return null if -- there is no containing element. not overriding function Get (Self : not null access constant Abstract_Element; Property : not null AMF.CMOF.Properties.CMOF_Property_Access) return League.Holders.Holder is abstract; -- Gets the value of the given property. If the Property has multiplicity -- upper bound of 1, get() returns the value of the Property. If Property -- has multiplicity upper bound >1, get() returns a ReflectiveCollection -- containing the values of the Property. If there are no values, the -- ReflectiveCollection returned is empty. -- -- Exception: throws IllegalArgumentException if Property is not a member -- of the Class from class(). not overriding procedure Set (Self : not null access Abstract_Element; Property : not null AMF.CMOF.Properties.CMOF_Property_Access; Value : League.Holders.Holder) is abstract; -- If the Property has multiplicity upper bound = 1, set() atomically -- updates the value of the Property to the object parameter. If Property -- has multiplicity upper bound >1, the Object must be a kind of -- ReflectiveCollection. The behavior is identical to the following -- operations performed atomically: -- -- ReflectiveSequence list = element.get(property); -- list.clear(); -- list.addAll((ReflectiveCollection) object); -- -- There is no return value. Exception: throws IllegalArgumentException if -- Property is not a member of the Class from getMetaClass(). -- -- Exception: throws ClassCastException if the Property’s type -- isInstance(element) returns false and Property has multi-plicity upper -- bound = 1. -- -- Exception: throws ClassCastException if Element is not a -- ReflectiveCollection and Property has multiplicity upper bound > 1. -- -- Exception: throws IllegalArgumentException if element is null, Property -- is of type Class, and the multiplicity upper bound > 1. ---------------------- -- AMF Extensions -- ---------------------- not overriding function Extent (Self : not null access constant Abstract_Element) return AMF.Extents.Extent_Access is abstract; -- Returns extents which contains element. end AMF.Elements;
charlie5/cBound
Ada
1,461
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_fixed_iterator_t is -- Item -- type Item is record data : access xcb.xcb_render_fixed_t; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_fixed_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_fixed_iterator_t.Item, Element_Array => xcb.xcb_render_fixed_iterator_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_render_fixed_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_fixed_iterator_t.Pointer, Element_Array => xcb.xcb_render_fixed_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_fixed_iterator_t;
AdaCore/Ada_Drivers_Library
Ada
2,693
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This version is for use with the ravenscar-sfp runtime. with System; package Last_Chance_Handler is procedure Last_Chance_Handler (Msg : System.Address; Line : Integer); pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler"); pragma No_Return (Last_Chance_Handler); end Last_Chance_Handler;
onox/orka
Ada
1,412
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 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 Orka.Loggers.Formatting; with Orka.OS; package body Orka.Loggers.Terminal is protected body Logger_Object is procedure Log (From : String; Level : Severity; Message : String) is use all type Orka.OS.File_Kind; begin if Level <= Min_Level then Orka.OS.Put_Line (Formatting.Format_Message (From, Level, Message, Colorize => True), (if Level = Error then Standard_Error else Standard_Output)); end if; end Log; end Logger_Object; function Create_Logger (Level : Severity := Debug) return Logger_Ptr is begin return new Logger_Object (Min_Level => Level); end Create_Logger; end Orka.Loggers.Terminal;
damaki/SPARKNaCl
Ada
2,525
adb
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Core; use SPARKNaCl.Core; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Secretbox; use SPARKNaCl.Secretbox; with SPARKNaCl.Stream; with Ada.Text_IO; use Ada.Text_IO; procedure Secretbox is Firstkey : constant Core.Salsa20_Key := Construct ((16#1b#, 16#27#, 16#55#, 16#64#, 16#73#, 16#e9#, 16#85#, 16#d4#, 16#62#, 16#cd#, 16#51#, 16#19#, 16#7a#, 16#9a#, 16#46#, 16#c7#, 16#60#, 16#09#, 16#54#, 16#9e#, 16#ac#, 16#64#, 16#74#, 16#f2#, 16#06#, 16#c4#, 16#ee#, 16#08#, 16#44#, 16#f6#, 16#83#, 16#89#)); Nonce : constant Stream.HSalsa20_Nonce := (16#69#, 16#69#, 16#6e#, 16#e9#, 16#55#, 16#b6#, 16#2b#, 16#73#, 16#cd#, 16#62#, 16#bd#, 16#a8#, 16#75#, 16#fc#, 16#73#, 16#d6#, 16#82#, 16#19#, 16#e0#, 16#03#, 16#6b#, 16#7a#, 16#0b#, 16#37#); M : constant Byte_Seq (0 .. 162) := (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16#be#, 16#07#, 16#5f#, 16#c5#, 16#3c#, 16#81#, 16#f2#, 16#d5#, 16#cf#, 16#14#, 16#13#, 16#16#, 16#eb#, 16#eb#, 16#0c#, 16#7b#, 16#52#, 16#28#, 16#c5#, 16#2a#, 16#4c#, 16#62#, 16#cb#, 16#d4#, 16#4b#, 16#66#, 16#84#, 16#9b#, 16#64#, 16#24#, 16#4f#, 16#fc#, 16#e5#, 16#ec#, 16#ba#, 16#af#, 16#33#, 16#bd#, 16#75#, 16#1a#, 16#1a#, 16#c7#, 16#28#, 16#d4#, 16#5e#, 16#6c#, 16#61#, 16#29#, 16#6c#, 16#dc#, 16#3c#, 16#01#, 16#23#, 16#35#, 16#61#, 16#f4#, 16#1d#, 16#b6#, 16#6c#, 16#ce#, 16#31#, 16#4a#, 16#db#, 16#31#, 16#0e#, 16#3b#, 16#e8#, 16#25#, 16#0c#, 16#46#, 16#f0#, 16#6d#, 16#ce#, 16#ea#, 16#3a#, 16#7f#, 16#a1#, 16#34#, 16#80#, 16#57#, 16#e2#, 16#f6#, 16#55#, 16#6a#, 16#d6#, 16#b1#, 16#31#, 16#8a#, 16#02#, 16#4a#, 16#83#, 16#8f#, 16#21#, 16#af#, 16#1f#, 16#de#, 16#04#, 16#89#, 16#77#, 16#eb#, 16#48#, 16#f5#, 16#9f#, 16#fd#, 16#49#, 16#24#, 16#ca#, 16#1c#, 16#60#, 16#90#, 16#2e#, 16#52#, 16#f0#, 16#a0#, 16#89#, 16#bc#, 16#76#, 16#89#, 16#70#, 16#40#, 16#e0#, 16#82#, 16#f9#, 16#37#, 16#76#, 16#38#, 16#48#, 16#64#, 16#5e#, 16#07#, 16#05#); C : Byte_Seq (0 .. 162); S : Boolean; begin Create (C, S, M, Nonce, Firstkey); Put_Line ("Status is " & Img (S)); DH ("C is", C); end Secretbox;
zhmu/ananas
Ada
463
ads
package Discr37 is subtype Index is Integer range 0 .. 100; type Root; type Frame_Ptr is access all Root'Class; type Arr is array (Index range <>) of Frame_Ptr; type Root (Level : Index) is tagged record S : Arr (0 .. Level); end record; type Derived (Level : Index) is new Root (Level) with null record; type Child is new Derived (0) with record F : Arr (0 .. 100); end record; procedure Proc (A : access Child); end Discr37;
reznikmm/matreshka
Ada
3,717
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 League.Holders.Generic_Enumerations; package AMF.CMOF.Holders.Parameter_Direction_Kinds is new League.Holders.Generic_Enumerations (AMF.CMOF.CMOF_Parameter_Direction_Kind); pragma Preelaborate (AMF.CMOF.Holders.Parameter_Direction_Kinds);
AdaCore/libadalang
Ada
256
ads
package Pkg is type T is abstract tagged private; --% node.p_get_primitives() procedure Foo (X : T) is abstract; private type T is abstract tagged null record; --% node.p_get_primitives() function Priv (X : T) return Integer; end Pkg;
flyx/FreeTypeAda
Ada
2,625
ads
-- part of FreeTypeAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with Interfaces.C.Strings; with FT.Faces; with FT.Errors; private package FT.API is pragma Preelaborate; type Bool is new Boolean; function FT_Reference_Library (Ptr : Library_Ptr) return Errors.Error_Code; pragma Import (C, FT_Reference_Library, "FT_Reference_Library"); function FT_Done_Library (Library : Library_Ptr) return Errors.Error_Code; pragma Import (C, FT_Done_Library, "FT_Done_Library"); function FT_Get_Kerning (aFace : Face_Ptr; Left_Glyph : UInt; Right_Glyph : UInt; Kern_Mode : UInt; aKerning : access Vector) return Errors.Error_Code; pragma Import (C, FT_Get_Kerning, "FT_Get_Kerning"); function FT_Init_FreeType (aLibrary : access FT.Library_Ptr) return Errors.Error_Code; pragma Import (C, FT_Init_FreeType, "FT_Init_FreeType"); function FT_Get_Char_Index (Face : Face_Ptr; Char_Code : ULong) return Faces.Char_Index_Type; pragma Import (C, FT_Get_Char_Index, "FT_Get_Char_Index"); function FT_Load_Glyph (Face : Face_Ptr; Glyph_Index : Faces.Char_Index_Type; Flags : Faces.Load_Flag) return Errors.Error_Code; pragma Import (C, FT_Load_Glyph, "FT_Load_Glyph"); function FT_Load_Char (aFace : Face_Ptr; Char_Code : ULong; Load_Flags : Faces.Load_Flag) return Errors.Error_Code; pragma Import (C, FT_Load_Char, "FT_Load_Char"); function FT_New_Face (Library : Library_Ptr; File_Path_Name : Interfaces.C.Strings.chars_ptr; Face_Index : Faces.Face_Index_Type; aFace : access Face_Ptr) return Errors.Error_Code; pragma Import (C, FT_New_Face, "FT_New_Face"); function FT_Reference_Face (Face : Face_Ptr) return Errors.Error_Code; pragma Import (C, FT_Reference_Face, "FT_Reference_Face"); function FT_Done_Face (aFace : Face_Ptr) return Errors.Error_Code; pragma Import (C, FT_Done_Face, "FT_Done_Face"); function FT_Set_Pixel_Sizes (aFace : Face_Ptr; Pixel_Width : UInt; Pixel_Height : UInt) return Errors.Error_Code; pragma Import (C, FT_Set_Pixel_Sizes, "FT_Set_Pixel_Sizes"); private for Bool use (False => 0, True => 1); for Bool'Size use Interfaces.C.unsigned_char'Size; end FT.API;
zhmu/ananas
Ada
60
adb
procedure Raise_CE is begin raise Constraint_Error; end;
sungyeon/drake
Ada
577
ads
pragma License (Unrestricted); -- implementation unit specialized for Linux package System.Native_IO.Names is pragma Preelaborate; procedure Open_Ordinary ( Method : Open_Method; Handle : aliased out Handle_Type; Mode : File_Mode; Name : String; Out_Name : aliased out Name_Pointer; -- null Form : Packed_Form); procedure Get_Full_Name ( Handle : Handle_Type; Has_Full_Name : in out Boolean; Name : in out Name_Pointer; Is_Standard : Boolean; Raise_On_Error : Boolean); end System.Native_IO.Names;
MinimSecure/unum-sdk
Ada
1,738
adb
-- Copyright 2011-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 Task_Switch is ------------------- -- Declaractions -- ------------------- task type Callee is entry Finito; end Callee; type Callee_Ptr is access Callee; task type Caller is end Caller; type Caller_Ptr is access Caller; procedure Break_Me; My_Caller : Caller_Ptr; My_Callee : Callee_Ptr; ------------ -- Bodies -- ------------ task body Callee is begin -- Just wait until we are told to terminate this task. -- This is just to maintain this task alive. accept Finito do null; end Finito; end Callee; task body Caller is begin Break_Me; My_Callee.Finito; end Caller; procedure Break_Me is begin null; end Break_Me; begin -- Make sure to create the Callee task first... And then give it -- enough time to complete its activation phase before we start -- the Caller task. My_Callee := new Callee; delay 0.1; My_Caller := new Caller; end Task_Switch;
reznikmm/matreshka
Ada
3,993
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.Draw_Extrusion_Attributes; package Matreshka.ODF_Draw.Extrusion_Attributes is type Draw_Extrusion_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Extrusion_Attributes.ODF_Draw_Extrusion_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Extrusion_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Extrusion_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Extrusion_Attributes;
stcarrez/ada-mail
Ada
2,978
ads
----------------------------------------------------------------------- -- mail-parsers -- Parse mail content -- Copyright (C) 2020 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.Strings.Unbounded; with Util.Streams; private with Util.Streams.Buffered; package Mail.Parsers is type Processor is limited interface; procedure New_Mail (Handler : in out Processor) is abstract; procedure Read_Header (Handler : in out Processor; Name : in String; Content : in String) is abstract; procedure Read_Body (Handler : in out Processor; Line : in String) is abstract; type Parser_Type is tagged limited private; procedure Parse (Parser : in out Parser_Type; Stream : in Util.Streams.Input_Stream_Access; Process : access Processor'Class); private MAX_LENGTH : constant := 998 + 2; type Parser_State is (IN_START, IN_FROM, IN_HEADER, IN_BODY, IN_BODY_QUOTED_PRINTABLE, IN_BODY_PART); type Parser_Type is tagged limited record Has_Pending : Boolean := False; Is_Eof : Boolean := False; Pending : Character; Reader : Util.Streams.Buffered.Input_Buffer_Stream; Line : String (1 .. MAX_LENGTH); Length : Natural := 0; State : Parser_State := IN_START; Content_Type : Ada.Strings.Unbounded.Unbounded_String; Content_Encoding : Ada.Strings.Unbounded.Unbounded_String; Boundary : Ada.Strings.Unbounded.Unbounded_String; end record; procedure Read_Line (Parser : in out Parser_Type); procedure Parse_From (Parser : in out Parser_Type); procedure Parse_Header (Parser : in out Parser_Type; Process : access Processor'Class); procedure Parse_Body (Parser : in out Parser_Type; Process : access Processor'Class); procedure Parse_Body_Part (Parser : in out Parser_Type; Process : access Processor'Class); procedure Set_State (Parser : in out Parser_Type; State : in Parser_State); function Get_Boundary (Parser : in Parser_Type) return String; end Mail.Parsers;
tum-ei-rcs/StratoX
Ada
29,521
ads
-- This spec has been automatically generated from STM32F427x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with System; with HAL; package STM32_SVD.RTC is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- TR_Register -- ----------------- subtype TR_SU_Field is HAL.UInt4; subtype TR_ST_Field is HAL.UInt3; subtype TR_MNU_Field is HAL.UInt4; subtype TR_MNT_Field is HAL.UInt3; subtype TR_HU_Field is HAL.UInt4; subtype TR_HT_Field is HAL.UInt2; -- time register type TR_Register is record -- Second units in BCD format SU : TR_SU_Field := 16#0#; -- Second tens in BCD format ST : TR_ST_Field := 16#0#; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Minute units in BCD format MNU : TR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : TR_MNT_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Hour units in BCD format HU : TR_HU_Field := 16#0#; -- Hour tens in BCD format HT : TR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; ----------------- -- DR_Register -- ----------------- subtype DR_DU_Field is HAL.UInt4; subtype DR_DT_Field is HAL.UInt2; subtype DR_MU_Field is HAL.UInt4; subtype DR_WDU_Field is HAL.UInt3; subtype DR_YU_Field is HAL.UInt4; subtype DR_YT_Field is HAL.UInt4; -- date register type DR_Register is record -- Date units in BCD format DU : DR_DU_Field := 16#1#; -- Date tens in BCD format DT : DR_DT_Field := 16#0#; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- Month units in BCD format MU : DR_MU_Field := 16#1#; -- Month tens in BCD format MT : Boolean := False; -- Week day units WDU : DR_WDU_Field := 16#1#; -- Year units in BCD format YU : DR_YU_Field := 16#0#; -- Year tens in BCD format YT : DR_YT_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; YU at 0 range 16 .. 19; YT at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ----------------- -- CR_Register -- ----------------- subtype CR_WCKSEL_Field is HAL.UInt3; subtype CR_OSEL_Field is HAL.UInt2; -- control register type CR_Register is record -- Wakeup clock selection WCKSEL : CR_WCKSEL_Field := 16#0#; -- Time-stamp event active edge TSEDGE : Boolean := False; -- Reference clock detection enable (50 or 60 Hz) REFCKON : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- Hour format FMT : Boolean := False; -- Coarse digital calibration enable DCE : Boolean := False; -- Alarm A enable ALRAE : Boolean := False; -- Alarm B enable ALRBE : Boolean := False; -- Wakeup timer enable WUTE : Boolean := False; -- Time stamp enable TSE : Boolean := False; -- Alarm A interrupt enable ALRAIE : Boolean := False; -- Alarm B interrupt enable ALRBIE : Boolean := False; -- Wakeup timer interrupt enable WUTIE : Boolean := False; -- Time-stamp interrupt enable TSIE : Boolean := False; -- Add 1 hour (summer time change) ADD1H : Boolean := False; -- Subtract 1 hour (winter time change) SUB1H : Boolean := False; -- Backup BKP : Boolean := False; -- unspecified Reserved_19_19 : HAL.Bit := 16#0#; -- Output polarity POL : Boolean := False; -- Output selection OSEL : CR_OSEL_Field := 16#0#; -- Calibration output enable COE : Boolean := False; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record WCKSEL at 0 range 0 .. 2; TSEDGE at 0 range 3 .. 3; REFCKON at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; FMT at 0 range 6 .. 6; DCE at 0 range 7 .. 7; ALRAE at 0 range 8 .. 8; ALRBE at 0 range 9 .. 9; WUTE at 0 range 10 .. 10; TSE at 0 range 11 .. 11; ALRAIE at 0 range 12 .. 12; ALRBIE at 0 range 13 .. 13; WUTIE at 0 range 14 .. 14; TSIE at 0 range 15 .. 15; ADD1H at 0 range 16 .. 16; SUB1H at 0 range 17 .. 17; BKP at 0 range 18 .. 18; Reserved_19_19 at 0 range 19 .. 19; POL at 0 range 20 .. 20; OSEL at 0 range 21 .. 22; COE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------ -- ISR_Register -- ------------------ -- initialization and status register type ISR_Register is record -- Read-only. Alarm A write flag ALRAWF : Boolean := True; -- Read-only. Alarm B write flag ALRBWF : Boolean := True; -- Read-only. Wakeup timer write flag WUTWF : Boolean := True; -- Shift operation pending SHPF : Boolean := False; -- Read-only. Initialization status flag INITS : Boolean := False; -- Registers synchronization flag RSF : Boolean := False; -- Read-only. Initialization flag INITF : Boolean := False; -- Initialization mode INIT : Boolean := False; -- Alarm A flag ALRAF : Boolean := False; -- Alarm B flag ALRBF : Boolean := False; -- Wakeup timer flag WUTF : Boolean := False; -- Time-stamp flag TSF : Boolean := False; -- Time-stamp overflow flag TSOVF : Boolean := False; -- Tamper detection flag TAMP1F : Boolean := False; -- TAMPER2 detection flag TAMP2F : Boolean := False; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Read-only. Recalibration pending Flag RECALPF : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record ALRAWF at 0 range 0 .. 0; ALRBWF at 0 range 1 .. 1; WUTWF at 0 range 2 .. 2; SHPF at 0 range 3 .. 3; INITS at 0 range 4 .. 4; RSF at 0 range 5 .. 5; INITF at 0 range 6 .. 6; INIT at 0 range 7 .. 7; ALRAF at 0 range 8 .. 8; ALRBF at 0 range 9 .. 9; WUTF at 0 range 10 .. 10; TSF at 0 range 11 .. 11; TSOVF at 0 range 12 .. 12; TAMP1F at 0 range 13 .. 13; TAMP2F at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; RECALPF at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; ------------------- -- PRER_Register -- ------------------- subtype PRER_PREDIV_S_Field is HAL.UInt15; subtype PRER_PREDIV_A_Field is HAL.UInt7; -- prescaler register type PRER_Register is record -- Synchronous prescaler factor PREDIV_S : PRER_PREDIV_S_Field := 16#FF#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Asynchronous prescaler factor PREDIV_A : PRER_PREDIV_A_Field := 16#7F#; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRER_Register use record PREDIV_S at 0 range 0 .. 14; Reserved_15_15 at 0 range 15 .. 15; PREDIV_A at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; ------------------- -- WUTR_Register -- ------------------- subtype WUTR_WUT_Field is HAL.Short; -- wakeup timer register type WUTR_Register is record -- Wakeup auto-reload value bits WUT : WUTR_WUT_Field := 16#FFFF#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WUTR_Register use record WUT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; --------------------- -- CALIBR_Register -- --------------------- subtype CALIBR_DC_Field is HAL.UInt5; -- calibration register type CALIBR_Register is record -- Digital calibration DC : CALIBR_DC_Field := 16#0#; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Digital calibration sign DCS : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CALIBR_Register use record DC at 0 range 0 .. 4; Reserved_5_6 at 0 range 5 .. 6; DCS at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; --------------------- -- ALRMAR_Register -- --------------------- subtype ALRMAR_SU_Field is HAL.UInt4; subtype ALRMAR_ST_Field is HAL.UInt3; subtype ALRMAR_MNU_Field is HAL.UInt4; subtype ALRMAR_MNT_Field is HAL.UInt3; subtype ALRMAR_HU_Field is HAL.UInt4; subtype ALRMAR_HT_Field is HAL.UInt2; subtype ALRMAR_DU_Field is HAL.UInt4; subtype ALRMAR_DT_Field is HAL.UInt2; -- alarm A register type ALRMAR_Register is record -- Second units in BCD format SU : ALRMAR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMAR_ST_Field := 16#0#; -- Alarm A seconds mask MSK1 : Boolean := False; -- Minute units in BCD format MNU : ALRMAR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMAR_MNT_Field := 16#0#; -- Alarm A minutes mask MSK2 : Boolean := False; -- Hour units in BCD format HU : ALRMAR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMAR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- Alarm A hours mask MSK3 : Boolean := False; -- Date units or day in BCD format DU : ALRMAR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMAR_DT_Field := 16#0#; -- Week day selection WDSEL : Boolean := False; -- Alarm A date mask MSK4 : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMAR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; --------------------- -- ALRMBR_Register -- --------------------- subtype ALRMBR_SU_Field is HAL.UInt4; subtype ALRMBR_ST_Field is HAL.UInt3; subtype ALRMBR_MNU_Field is HAL.UInt4; subtype ALRMBR_MNT_Field is HAL.UInt3; subtype ALRMBR_HU_Field is HAL.UInt4; subtype ALRMBR_HT_Field is HAL.UInt2; subtype ALRMBR_DU_Field is HAL.UInt4; subtype ALRMBR_DT_Field is HAL.UInt2; -- alarm B register type ALRMBR_Register is record -- Second units in BCD format SU : ALRMBR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMBR_ST_Field := 16#0#; -- Alarm B seconds mask MSK1 : Boolean := False; -- Minute units in BCD format MNU : ALRMBR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMBR_MNT_Field := 16#0#; -- Alarm B minutes mask MSK2 : Boolean := False; -- Hour units in BCD format HU : ALRMBR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMBR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- Alarm B hours mask MSK3 : Boolean := False; -- Date units or day in BCD format DU : ALRMBR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMBR_DT_Field := 16#0#; -- Week day selection WDSEL : Boolean := False; -- Alarm B date mask MSK4 : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; ------------------ -- WPR_Register -- ------------------ subtype WPR_KEY_Field is HAL.Byte; -- write protection register type WPR_Register is record -- Write-only. Write protection key KEY : WPR_KEY_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WPR_Register use record KEY at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ------------------ -- SSR_Register -- ------------------ subtype SSR_SS_Field is HAL.Short; -- sub second register type SSR_Register is record -- Read-only. Sub second value SS : SSR_SS_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; --------------------- -- SHIFTR_Register -- --------------------- subtype SHIFTR_SUBFS_Field is HAL.UInt15; -- shift control register type SHIFTR_Register is record -- Write-only. Subtract a fraction of a second SUBFS : SHIFTR_SUBFS_Field := 16#0#; -- unspecified Reserved_15_30 : HAL.Short := 16#0#; -- Write-only. Add one second ADD1S : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SHIFTR_Register use record SUBFS at 0 range 0 .. 14; Reserved_15_30 at 0 range 15 .. 30; ADD1S at 0 range 31 .. 31; end record; ------------------- -- TSTR_Register -- ------------------- -- time stamp time register type TSTR_Register is record -- Read-only. Tamper 1 detection enable TAMP1E : Boolean; -- Read-only. Active level for tamper 1 TAMP1TRG : Boolean; -- Read-only. Tamper interrupt enable TAMPIE : Boolean; -- unspecified Reserved_3_15 : HAL.UInt13; -- Read-only. TAMPER1 mapping TAMP1INSEL : Boolean; -- Read-only. TIMESTAMP mapping TSINSEL : Boolean; -- Read-only. AFO_ALARM output type ALARMOUTTYPE : Boolean; -- unspecified Reserved_19_31 : HAL.UInt13; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSTR_Register use record TAMP1E at 0 range 0 .. 0; TAMP1TRG at 0 range 1 .. 1; TAMPIE at 0 range 2 .. 2; Reserved_3_15 at 0 range 3 .. 15; TAMP1INSEL at 0 range 16 .. 16; TSINSEL at 0 range 17 .. 17; ALARMOUTTYPE at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ------------------- -- TSDR_Register -- ------------------- subtype TSDR_DU_Field is HAL.UInt4; subtype TSDR_DT_Field is HAL.UInt2; subtype TSDR_MU_Field is HAL.UInt4; subtype TSDR_WDU_Field is HAL.UInt3; -- time stamp date register type TSDR_Register is record -- Read-only. Date units in BCD format DU : TSDR_DU_Field; -- Read-only. Date tens in BCD format DT : TSDR_DT_Field; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. Month units in BCD format MU : TSDR_MU_Field; -- Read-only. Month tens in BCD format MT : Boolean; -- Read-only. Week day units WDU : TSDR_WDU_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSDR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -------------------- -- TSSSR_Register -- -------------------- subtype TSSSR_SS_Field is HAL.Short; -- timestamp sub second register type TSSSR_Register is record -- Read-only. Sub second value SS : TSSSR_SS_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSSSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ------------------- -- CALR_Register -- ------------------- subtype CALR_CALM_Field is HAL.UInt9; --------------- -- CALR.CALW -- --------------- -- CALR_CALW array type CALR_CALW_Field_Array is array (8 .. 9) of Boolean with Component_Size => 1, Size => 2; -- Type definition for CALR_CALW type CALR_CALW_Field (As_Array : Boolean := False) is record case As_Array is when False => -- CALW as a value Val : HAL.UInt2; when True => -- CALW as an array Arr : CALR_CALW_Field_Array; end case; end record with Unchecked_Union, Size => 2; for CALR_CALW_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- calibration register type CALR_Register is record -- Calibration minus CALM : CALR_CALM_Field := 16#0#; -- unspecified Reserved_9_12 : HAL.UInt4 := 16#0#; -- Use a 16-second calibration cycle period CALW : CALR_CALW_Field := (As_Array => False, Val => 16#0#); -- Increase frequency of RTC by 488.5 ppm CALP : Boolean := False; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CALR_Register use record CALM at 0 range 0 .. 8; Reserved_9_12 at 0 range 9 .. 12; CALW at 0 range 13 .. 14; CALP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -------------------- -- TAFCR_Register -- -------------------- subtype TAFCR_TAMPFREQ_Field is HAL.UInt3; subtype TAFCR_TAMPFLT_Field is HAL.UInt2; subtype TAFCR_TAMPPRCH_Field is HAL.UInt2; -- tamper and alternate function configuration register type TAFCR_Register is record -- Tamper 1 detection enable TAMP1E : Boolean := False; -- Active level for tamper 1 TAMP1TRG : Boolean := False; -- Tamper interrupt enable TAMPIE : Boolean := False; -- Tamper 2 detection enable TAMP2E : Boolean := False; -- Active level for tamper 2 TAMP2TRG : Boolean := False; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Activate timestamp on tamper detection event TAMPTS : Boolean := False; -- Tamper sampling frequency TAMPFREQ : TAFCR_TAMPFREQ_Field := 16#0#; -- Tamper filter count TAMPFLT : TAFCR_TAMPFLT_Field := 16#0#; -- Tamper precharge duration TAMPPRCH : TAFCR_TAMPPRCH_Field := 16#0#; -- TAMPER pull-up disable TAMPPUDIS : Boolean := False; -- TAMPER1 mapping TAMP1INSEL : Boolean := False; -- TIMESTAMP mapping TSINSEL : Boolean := False; -- AFO_ALARM output type ALARMOUTTYPE : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TAFCR_Register use record TAMP1E at 0 range 0 .. 0; TAMP1TRG at 0 range 1 .. 1; TAMPIE at 0 range 2 .. 2; TAMP2E at 0 range 3 .. 3; TAMP2TRG at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; TAMPTS at 0 range 7 .. 7; TAMPFREQ at 0 range 8 .. 10; TAMPFLT at 0 range 11 .. 12; TAMPPRCH at 0 range 13 .. 14; TAMPPUDIS at 0 range 15 .. 15; TAMP1INSEL at 0 range 16 .. 16; TSINSEL at 0 range 17 .. 17; ALARMOUTTYPE at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ----------------------- -- ALRMASSR_Register -- ----------------------- subtype ALRMASSR_SS_Field is HAL.UInt15; subtype ALRMASSR_MASKSS_Field is HAL.UInt4; -- alarm A sub second register type ALRMASSR_Register is record -- Sub seconds value SS : ALRMASSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : HAL.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMASSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMASSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------------- -- ALRMBSSR_Register -- ----------------------- subtype ALRMBSSR_SS_Field is HAL.UInt15; subtype ALRMBSSR_MASKSS_Field is HAL.UInt4; -- alarm B sub second register type ALRMBSSR_Register is record -- Sub seconds value SS : ALRMBSSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : HAL.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMBSSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBSSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Real-time clock type RTC_Peripheral is record -- time register TR : TR_Register; -- date register DR : DR_Register; -- control register CR : CR_Register; -- initialization and status register ISR : ISR_Register; -- prescaler register PRER : PRER_Register; -- wakeup timer register WUTR : WUTR_Register; -- calibration register CALIBR : CALIBR_Register; -- alarm A register ALRMAR : ALRMAR_Register; -- alarm B register ALRMBR : ALRMBR_Register; -- write protection register WPR : WPR_Register; -- sub second register SSR : SSR_Register; -- shift control register SHIFTR : SHIFTR_Register; -- time stamp time register TSTR : TSTR_Register; -- time stamp date register TSDR : TSDR_Register; -- timestamp sub second register TSSSR : TSSSR_Register; -- calibration register CALR : CALR_Register; -- tamper and alternate function configuration register TAFCR : TAFCR_Register; -- alarm A sub second register ALRMASSR : ALRMASSR_Register; -- alarm B sub second register ALRMBSSR : ALRMBSSR_Register; -- backup register BKP0R : HAL.Word; -- backup register BKP1R : HAL.Word; -- backup register BKP2R : HAL.Word; -- backup register BKP3R : HAL.Word; -- backup register BKP4R : HAL.Word; -- backup register BKP5R : HAL.Word; -- backup register BKP6R : HAL.Word; -- backup register BKP7R : HAL.Word; -- backup register BKP8R : HAL.Word; -- backup register BKP9R : HAL.Word; -- backup register BKP10R : HAL.Word; -- backup register BKP11R : HAL.Word; -- backup register BKP12R : HAL.Word; -- backup register BKP13R : HAL.Word; -- backup register BKP14R : HAL.Word; -- backup register BKP15R : HAL.Word; -- backup register BKP16R : HAL.Word; -- backup register BKP17R : HAL.Word; -- backup register BKP18R : HAL.Word; -- backup register BKP19R : HAL.Word; end record with Volatile; for RTC_Peripheral use record TR at 0 range 0 .. 31; DR at 4 range 0 .. 31; CR at 8 range 0 .. 31; ISR at 12 range 0 .. 31; PRER at 16 range 0 .. 31; WUTR at 20 range 0 .. 31; CALIBR at 24 range 0 .. 31; ALRMAR at 28 range 0 .. 31; ALRMBR at 32 range 0 .. 31; WPR at 36 range 0 .. 31; SSR at 40 range 0 .. 31; SHIFTR at 44 range 0 .. 31; TSTR at 48 range 0 .. 31; TSDR at 52 range 0 .. 31; TSSSR at 56 range 0 .. 31; CALR at 60 range 0 .. 31; TAFCR at 64 range 0 .. 31; ALRMASSR at 68 range 0 .. 31; ALRMBSSR at 72 range 0 .. 31; BKP0R at 80 range 0 .. 31; BKP1R at 84 range 0 .. 31; BKP2R at 88 range 0 .. 31; BKP3R at 92 range 0 .. 31; BKP4R at 96 range 0 .. 31; BKP5R at 100 range 0 .. 31; BKP6R at 104 range 0 .. 31; BKP7R at 108 range 0 .. 31; BKP8R at 112 range 0 .. 31; BKP9R at 116 range 0 .. 31; BKP10R at 120 range 0 .. 31; BKP11R at 124 range 0 .. 31; BKP12R at 128 range 0 .. 31; BKP13R at 132 range 0 .. 31; BKP14R at 136 range 0 .. 31; BKP15R at 140 range 0 .. 31; BKP16R at 144 range 0 .. 31; BKP17R at 148 range 0 .. 31; BKP18R at 152 range 0 .. 31; BKP19R at 156 range 0 .. 31; end record; -- Real-time clock RTC_Periph : aliased RTC_Peripheral with Import, Address => RTC_Base; end STM32_SVD.RTC;
kraileth/ravenadm
Ada
21,261
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with File_Operations; with PortScan.Log; with Parameters; with Unix; with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Text_IO; package body PortScan.Packager is package FOP renames File_Operations; package LOG renames PortScan.Log; package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package TIO renames Ada.Text_IO; package PM renames Parameters; -------------------------------------------------------------------------------------------- -- exec_phase_package -------------------------------------------------------------------------------------------- function exec_phase_package (specification : PSP.Portspecs; log_handle : in out TIO.File_Type; log_name : String; phase_name : String; seq_id : port_id; port_prefix : String; rootdir : String) return Boolean is procedure metadata (position : subpackage_crate.Cursor); procedure package_it (position : subpackage_crate.Cursor); namebase : constant String := HT.USS (all_ports (seq_id).port_namebase); conbase : constant String := "/construction/" & namebase; spkgdir : constant String := rootdir & "/construction/metadata/"; wrkdir : constant String := rootdir & conbase; chspkgdir : constant String := "/construction/metadata/"; newpkgdir : constant String := "/construction/new_packages"; stagedir : constant String := conbase & "/stage"; display : constant String := "/+DISPLAY"; pkgvers : constant String := HT.USS (all_ports (seq_id).pkgversion); usrgrp_pkg : constant String := specification.get_field_value (PSP.sp_ug_pkg); ug_install : constant String := wrkdir & "/users-groups-install.sh"; ug_desinst : constant String := wrkdir & "/users-groups-deinstall.sh"; still_good : Boolean := True; procedure metadata (position : subpackage_crate.Cursor) is type three is range 1 .. 3; function convert_prepost (prepost : three) return String; function convert_stage (stage : three) return String; subpackage : constant String := HT.USS (subpackage_crate.Element (position).subpackage); message_file : constant String := wrkdir & "/.PKG_DISPLAY." & subpackage; descript_file : constant String := wrkdir & "/.PKG_DESC." & subpackage; scr_preinst : constant String := spkgdir & subpackage & "/pkg-pre-install"; scr_pstdeinst : constant String := spkgdir & subpackage & "/pkg-post-deinstall"; descript : String := "/+DESC"; manifest : String := "/+MANIFEST"; function convert_prepost (prepost : three) return String is begin case prepost is when 1 => return "pre-"; when 2 => return ""; when 3 => return "post-"; end case; end convert_prepost; function convert_stage (stage : three) return String is begin case stage is when 1 => return "install"; when 2 => return "upgrade"; when 3 => return "deinstall"; end case; end convert_stage; begin DIR.Create_Path (spkgdir & subpackage); if DIR.Exists (message_file) then DIR.Copy_File (Source_Name => message_file, Target_Name => spkgdir & subpackage & display); end if; if DIR.Exists (descript_file) then DIR.Copy_File (Source_Name => descript_file, Target_Name => spkgdir & subpackage & descript); end if; for action in three'Range loop for psp in three'Range loop declare script_file : String := wrkdir & "/pkg-" & convert_prepost (psp) & convert_stage (action) & "." & subpackage; pkg_script : String := spkgdir & subpackage & "/pkg-" & convert_prepost (psp) & convert_stage (action); begin if DIR.Exists (script_file) then DIR.Copy_File (Source_Name => script_file, Target_Name => pkg_script); end if; end; end loop; end loop; if subpackage = usrgrp_pkg then if DIR.Exists (ug_install) then FOP.concatenate_file (basefile => scr_preinst, another_file => ug_install); end if; if DIR.Exists (ug_desinst) then FOP.concatenate_file (basefile => scr_pstdeinst, another_file => ug_desinst); end if; end if; write_package_manifest (spec => specification, port_prefix => port_prefix, subpackage => subpackage, seq_id => seq_id, pkgversion => pkgvers, filename => spkgdir & subpackage & manifest); end metadata; procedure package_it (position : subpackage_crate.Cursor) is subpackage : constant String := HT.USS (subpackage_crate.Element (position).subpackage); package_list : constant String := conbase & "/.manifest." & subpackage & ".mktmp"; FORCE_POST_PATTERNS : constant String := "rmdir mkfontscale mkfontdir fc-cache " & "fonts.dir fonts.scale gtk-update-icon-cache gio-querymodules gtk-query-immodules " & "load-octave-pkg ocamlfind update-desktop-database update-mime-database " & "gdk-pixbuf-query-loaders catalog.ports glib-compile-schemas ccache-update-links"; MORE_ENV : constant String := " RAVENSW_DBDIR=/var/db/pkg8" & " PLIST_KEYWORDS_DIR=/xports/Mk/Keywords "; PKG_CREATE : constant String := "/usr/bin/ravensw create"; PKG_CREATE_ARGS : constant String := " --root-dir " & stagedir & " --metadata " & chspkgdir & subpackage & " --plist " & package_list & " --out-dir " & newpkgdir & " --verbose "; namebase : constant String := specification.get_namebase; pkgname : String := namebase & "-" & subpackage & "-" & HT.USS (all_ports (seq_id).port_variant) & "-" & pkgvers; package_cmd : constant String := PM.chroot_cmd & rootdir & " /usr/bin/env FORCE_POST=" & LAT.Quotation & FORCE_POST_PATTERNS & LAT.Quotation & MORE_ENV & PKG_CREATE & PKG_CREATE_ARGS & pkgname; move_cmd : constant String := PM.chroot_cmd & rootdir & " /bin/mv " & newpkgdir & "/" & pkgname & arc_ext & " /packages/All/"; link_cmd : constant String := PM.chroot_cmd & rootdir & " /bin/ln -sf /packages/All/" & pkgname & arc_ext & " /packages/Latest/" & pkgname & arc_ext; begin if still_good then if DIR.Exists (spkgdir & subpackage & display) then dump_pkg_message_to_log (display_file => spkgdir & subpackage & display, log_handle => log_handle); end if; if not DIR.Exists (rootdir & package_list) then still_good := False; TIO.Put_Line (log_handle, "=> The package list " & package_list & " for the " & subpackage & " subpackage does not exist."); end if; TIO.Put_Line (log_handle, "===> Building " & pkgname & " subpackage"); TIO.Close (log_handle); still_good := execute_command (package_cmd, log_name); if still_good then still_good := execute_command (move_cmd, log_name); end if; if still_good and then namebase = "pkg" then still_good := execute_command (link_cmd, log_name); end if; TIO.Open (File => log_handle, Mode => TIO.Append_File, Name => log_name); end if; end package_it; begin LOG.log_phase_begin (log_handle, phase_name); all_ports (seq_id).subpackages.Iterate (metadata'Access); check_deprecation (specification, log_handle); if not create_package_directory_if_necessary (log_handle) or else not create_latest_package_directory_too (log_handle) then return False; end if; DIR.Create_Directory (rootdir & newpkgdir); all_ports (seq_id).subpackages.Iterate (package_it'Access); LOG.log_phase_end (log_handle); return still_good; exception when others => return False; end exec_phase_package; -------------------------------------------------------------------------------------------- -- create_package_directory_if_necessary -------------------------------------------------------------------------------------------- function create_package_directory_if_necessary (log_handle : TIO.File_Type) return Boolean is packagedir : String := HT.USS (PM.configuration.dir_repository); begin if DIR.Exists (packagedir) then return True; end if; DIR.Create_Directory (packagedir); return True; exception when others => TIO.Put_Line (log_handle, "=> Can't create directory " & packagedir); return False; end create_package_directory_if_necessary; -------------------------------------------------------------------------------------------- -- create_package_directory_if_necessary -------------------------------------------------------------------------------------------- function create_latest_package_directory_too (log_handle : TIO.File_Type) return Boolean is packagedir : String := HT.USS (PM.configuration.dir_packages) & "/Latest"; begin if DIR.Exists (packagedir) then return True; end if; DIR.Create_Directory (packagedir); return True; exception when others => TIO.Put_Line (log_handle, "=> Can't create directory " & packagedir); return False; end create_latest_package_directory_too; -------------------------------------------------------------------------------------------- -- dump_pkg_message_to_log -------------------------------------------------------------------------------------------- procedure dump_pkg_message_to_log (display_file : String; log_handle : TIO.File_Type) is File_Size : Natural := Natural (DIR.Size (display_file)); begin if File_Size = 0 then DIR.Delete_File (display_file); else declare contents : String := FOP.get_file_contents (display_file); begin TIO.Put_Line (log_handle, contents); end; end if; end dump_pkg_message_to_log; -------------------------------------------------------------------------------------------- -- check_deprecation -------------------------------------------------------------------------------------------- procedure check_deprecation (spec : PSP.Portspecs; log_handle : TIO.File_Type) is deprecated : String := spec.get_field_value (PSP.sp_deprecated); expire_date : String := spec.get_field_value (PSP.sp_expiration); begin if deprecated /= "" then TIO.Put_Line (log_handle, "===> NOTICE:" & LAT.LF & LAT.LF & "This port is deprecated; you may wish to consider avoiding its packages." & LAT.LF & LAT.LF & deprecated & LAT.Full_Stop & LAT.LF & "It is scheduled to be removed on or after " & expire_date & LAT.LF ); end if; end check_deprecation; -------------------------------------------------------------------------------------------- -- quote -------------------------------------------------------------------------------------------- function quote (thetext : String) return String is begin return LAT.Quotation & thetext & LAT.Quotation; end quote; -------------------------------------------------------------------------------------------- -- write_package_manifest -------------------------------------------------------------------------------------------- procedure write_package_manifest (spec : PSP.Portspecs; port_prefix : String; subpackage : String; seq_id : port_id; pkgversion : String; filename : String) is procedure single_if_defined (name, value, not_value : String); procedure array_if_defined (name, value : String); function short_desc return String; file_handle : TIO.File_Type; variant : String := HT.USS (all_ports (seq_id).port_variant); procedure single_if_defined (name, value, not_value : String) is begin if value /= "" and then value /= not_value then TIO.Put_Line (file_handle, name & ": " & quote (value)); end if; end single_if_defined; procedure array_if_defined (name, value : String) is -- No identified need for quoting begin if value /= "" then TIO.Put_Line (file_handle, name & ": [ " & value & " ]"); end if; end array_if_defined; function short_desc return String is begin if spec.get_subpackage_length (variant) = 1 then return spec.get_tagline (variant); else return spec.get_tagline (variant) & " (" & subpackage & ")"; end if; end short_desc; name : String := quote (spec.get_namebase & "-" & subpackage & "-" & variant); origin : String := quote (spec.get_namebase & ":" & variant); begin TIO.Create (File => file_handle, Mode => TIO.Out_File, Name => filename); TIO.Put_Line (file_handle, LAT.Left_Curly_Bracket & LAT.LF & "name: " & name & LAT.LF & "version: " & quote (pkgversion) & LAT.LF & "origin: " & origin & LAT.LF & "comment: <<EOD" & LAT.LF & short_desc & LAT.LF & "EOD" & LAT.LF & "maintainer: " & quote (spec.get_field_value (PSP.sp_contacts)) & LAT.LF & "prefix: " & quote (port_prefix) & LAT.LF & "categories: [ " & spec.get_field_value (PSP.sp_keywords) & " ]" & LAT.LF & "licenselogic: " & quote (spec.get_license_scheme) ); -- We prefer "none" to "WWW : UNKNOWN" in the package manifest single_if_defined ("www", spec.get_field_value (PSP.sp_homepage), ""); array_if_defined ("licenses", spec.get_field_value (PSP.sp_licenses)); array_if_defined ("users", spec.get_field_value (PSP.sp_users)); array_if_defined ("groups", spec.get_field_value (PSP.sp_groups)); TIO.Put_Line (file_handle, "deps: {"); write_down_run_dependencies (file_handle, seq_id, subpackage); TIO.Put_Line (file_handle, "}"); TIO.Put_Line (file_handle, "options: {" & spec.get_options_list (variant) & " }"); write_package_annotations (spec, file_handle); -- Closing Curly Brace for manifest TIO.Put_Line (file_handle, "}"); TIO.Close (file_handle); exception when others => if TIO.Is_Open (file_handle) then TIO.Close (file_handle); end if; end write_package_manifest; -------------------------------------------------------------------------------------------- -- write_complete_metapackage_deps -------------------------------------------------------------------------------------------- procedure write_complete_metapackage_deps (spec : PSP.Portspecs; file_handle : TIO.File_Type; variant : String; pkgversion : String) is namebase : constant String := spec.get_namebase; num_subpackages : constant Natural := spec.get_subpackage_length (variant); begin for spkg in 1 .. num_subpackages loop declare subpackage : constant String := spec.get_subpackage_item (variant, spkg); begin if subpackage /= spkg_complete then TIO.Put_Line (file_handle, " " & quote (namebase & LAT.Hyphen & subpackage & LAT.Hyphen & variant) & " : {"); TIO.Put_Line (file_handle, " version : " & quote (pkgversion) & "," & LAT.LF & " origin : " & quote (namebase & LAT.Colon & variant) & LAT.LF & " },"); end if; end; end loop; end write_complete_metapackage_deps; -------------------------------------------------------------------------------------------- -- write_down_run_dependencies -------------------------------------------------------------------------------------------- procedure write_down_run_dependencies (file_handle : TIO.File_Type; seq_id : port_id; subpackage : String) is procedure scan (position : subpackage_crate.Cursor); procedure write_pkg_dep (pkgname, pkgversion, portkey : String); procedure assemble_origins (dep_position : spkg_id_crate.Cursor); found_subpackage : Boolean := False; procedure write_pkg_dep (pkgname, pkgversion, portkey : String) is begin TIO.Put_Line (file_handle, " " & quote (pkgname) & " : {"); TIO.Put_Line (file_handle, " version : " & quote (pkgversion) & "," & LAT.LF & " origin : " & quote (portkey) & LAT.LF & " },"); end write_pkg_dep; procedure assemble_origins (dep_position : spkg_id_crate.Cursor) is sprec : subpackage_identifier renames spkg_id_crate.Element (dep_position); namebase : String := HT.USS (all_ports (sprec.port).port_namebase); variant : String := HT.USS (all_ports (sprec.port).port_variant); portkey : String := namebase & LAT.Colon & variant; pkgversion : String := HT.USS (all_ports (sprec.port).pkgversion); pkgname : String := namebase & LAT.Hyphen & HT.USS (sprec.subpackage) & LAT.Hyphen & variant; begin write_pkg_dep (pkgname, pkgversion, portkey); end assemble_origins; procedure scan (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); begin if not found_subpackage then if HT.equivalent (rec.subpackage, subpackage) then found_subpackage := True; rec.spkg_run_deps.Iterate (assemble_origins'Access); end if; end if; end scan; begin all_ports (seq_id).subpackages.Iterate (scan'Access); end write_down_run_dependencies; -------------------------------------------------------------------------------------------- -- write_package_annotations -------------------------------------------------------------------------------------------- procedure write_package_annotations (spec : PSP.Portspecs; file_handle : TIO.File_Type) is num_notes : constant Natural := spec.get_list_length (PSP.sp_notes); begin if num_notes = 0 then return; end if; TIO.Put_Line (file_handle, "annotations: {"); for note in 1 .. num_notes loop declare nvpair : String := spec.get_list_item (PSP.sp_notes, note); key : String := HT.part_1 (nvpair, "="); value : String := HT.part_2 (nvpair, "="); begin TIO.Put_Line (file_handle, key & ": <<EOD" & LAT.LF & value & LAT.LF & "EOD"); end; end loop; TIO.Put_Line (file_handle, "}"); end write_package_annotations; -------------------------------------------------------------------------------------------- -- execute_command -------------------------------------------------------------------------------------------- function execute_command (command : String; name_of_log : String) return Boolean is use type Unix.process_exit; pid : Unix.pid_t; status : Unix.process_exit; hangmonitor : constant Boolean := True; truecommand : constant String := ravenexec & " " & name_of_log & " " & command; begin pid := Unix.launch_process (truecommand); if Unix.fork_failed (pid) then return False; end if; loop delay 0.25; status := Unix.process_status (pid); if status = Unix.exited_normally then return True; end if; if status = Unix.exited_with_error then return False; end if; end loop; end execute_command; end PortScan.Packager;
JeremyGrosser/clock3
Ada
826
ads
with HAL.I2C; use HAL.I2C; with HAL; use HAL; package HT16K33 is type Device (Port : not null Any_I2C_Port; Address : I2C_Address) is tagged limited record -- byte 0 is the address command Buffer : UInt8_Array (0 .. 16) := (0 => 0, others => 16#FF#); end record; subtype Brightness_Level is UInt8 range 0 .. 15; subtype Output_Index is Natural range 0 .. 127; procedure Initialize (This : in out Device); procedure Set_Brightness (This : in out Device; Level : Brightness_Level); procedure Set (This : in out Device; Num : Output_Index); procedure Clear (This : in out Device; Num : Output_Index); procedure Clear_All (This : in out Device); procedure Update (This : in out Device); end HT16K33;
persan/protobuf-ada
Ada
57
ads
package Protobuf_Unittest is end Protobuf_Unittest;
reznikmm/matreshka
Ada
3,693
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010, 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 Matreshka.StAX.Notation_Declarations is pragma Preelaborate; type StAX_Notation_Declaration is tagged private; type StAX_Notation_Declarations is tagged private; private type StAX_Notation_Declaration is tagged null record; type StAX_Notation_Declarations is tagged null record; end Matreshka.StAX.Notation_Declarations;
tum-ei-rcs/StratoX
Ada
588
ads
-- @summary this package serves as config lookup in HIL. -- actually this should not be here. Rather, HIL should -- offer an API for that. package HIL.Config is -- PX4IO PX4IO_BAUD_RATE_HZ : constant := 1_500_000; -- UBLOX Baudrate: Default: 9_600, PX4-FMU configured: 38_400 UBLOX_BAUD_RATE_HZ : constant := 38_400; type Buzzer_Out_T is (BUZZER_USE_PORT, BUZZER_USE_AUX5); BUZZER_PORT : constant Buzzer_Out_T := BUZZER_USE_AUX5; -- Pixlite: BUZZER_USE_AUX5. Pixhawk: BUZZER_USE_PORT -- MPU6000 MPU6000_SAMPLE_RATE_HZ : constant := 100; end HIL.Config;
msrLi/portingSources
Ada
833
adb
-- Copyright 2011-2014 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/>. package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
AdaCore/libadalang
Ada
157
adb
package body Foo is package body Nested is procedure Bar is begin Put_Line ("Hello, world!"); end Bar; end Nested; end Foo;
io7m/coreland-lua-ada
Ada
608
adb
with Lua; with Lua.Check_Raise; procedure Lua_Check_Exception is State : Lua.State_t; Caught : Boolean := False; use type Lua.State_t; use type Lua.Number_t; begin State := Lua.Open; if State = Lua.State_Error then raise Program_Error; end if; Lua.At_Panic (State => State, Panic_Function => Lua.Check_Raise.Check_Raise'Access); begin Lua.Push_Number (State, -1.0); Lua.Call (State, 1, 1); exception when Lua.Check_Raise.Check_Raise_Error => Caught := True; end; if not Caught then raise Program_Error; end if; end Lua_Check_Exception;
damaki/libkeccak
Ada
13,479
adb
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Text_IO; with Ada.Unchecked_Deallocation; with Interfaces; use Interfaces; with GNAT.Regpat; package body Test_Vectors is use type GNAT.Regpat.Match_Location; function Create_List (Value : in Value_Choice) return Value_Choice_Lists.List; ---------------- -- Initialize -- ---------------- overriding procedure Initialize (Object : in out Value_Choice) is begin case Object.VType is when String_Type => Object.Str := Null_Unbounded_String; when Integer_Type => Object.Int := 0; when Hex_Array_Type => Object.Hex := null; end case; end Initialize; ------------ -- Adjust -- ------------ overriding procedure Adjust (Object : in out Value_Choice) is begin if Object.VType = Hex_Array_Type and then Object.Hex /= null then Object.Hex := new Keccak.Types.Byte_Array'(Object.Hex.all); end if; end Adjust; -------------- -- Finalize -- -------------- overriding procedure Finalize (Object : in out Value_Choice) is procedure Free is new Ada.Unchecked_Deallocation (Keccak.Types.Byte_Array, Byte_Array_Access); begin if Object.VType = Hex_Array_Type and then Object.Hex /= null then Free (Object.Hex); end if; end Finalize; ------------------------------ -- Hex_String_To_Byte_Array -- ------------------------------ function Hex_String_To_Byte_Array (Str : in String) return Byte_Array_Access is function Char_To_Byte (C : in Character) return Keccak.Types.Byte; function Char_To_Byte (C : in Character) return Keccak.Types.Byte is Byte : Keccak.Types.Byte; begin if C >= '0' and C <= '9' then Byte := Keccak.Types.Byte (Character'Pos (C) - Character'Pos ('0')); elsif C >= 'a' and C <= 'f' then Byte := Keccak.Types.Byte (16#A# + (Character'Pos (C) - Character'Pos ('a'))); elsif C >= 'A' and C <= 'F' then Byte := Keccak.Types.Byte (16#A# + (Character'Pos (C) - Character'Pos ('A'))); else raise Constraint_Error; end if; return Byte; end Char_To_Byte; Byte_Array : Byte_Array_Access; I : Natural := 0; begin if (Str'Length mod 2 /= 0) then raise Constraint_Error; end if; Byte_Array := new Keccak.Types.Byte_Array (0 .. Str'Length / 2 - 1); while I < Str'Length loop Byte_Array.all (I / 2) := Shift_Left (Char_To_Byte (Str (Str'First + I)), 4) or Char_To_Byte (Str (Str'First + I + 1)); I := I + 2; end loop; return Byte_Array; end Hex_String_To_Byte_Array; -------------------------- -- String_To_Byte_Array -- -------------------------- function String_To_Byte_Array (Str : in String) return Byte_Array_Access is Byte_Array : Byte_Array_Access; begin Byte_Array := new Keccak.Types.Byte_Array (1 .. Str'Length); for I in Natural range 0 .. Str'Length - 1 loop Byte_Array (Byte_Array'First + I) := Keccak.Types.Byte (Character'Pos (Str (Str'First + I))); end loop; return Byte_Array; end String_To_Byte_Array; -------------------------- -- Byte_Array_To_String -- -------------------------- function Byte_Array_To_String (Data : in Keccak.Types.Byte_Array) return String is Hex_Characters : constant array (Keccak.Types.Byte range 0 .. 15) of Character := ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); Str : String (1 .. Data'Length * 2); I : Natural := 0; begin while I < Data'Length loop Str (I * 2 + 1) := Hex_Characters (Shift_Right (Data (Data'First + I), 4)); Str (I * 2 + 2) := Hex_Characters (Data (Data'First + I) mod 16); I := I + 1; end loop; return Str; end Byte_Array_To_String; ----------------- -- Create_List -- ----------------- function Create_List (Value : in Value_Choice) return Value_Choice_Lists.List is begin return L : Value_Choice_Lists.List do L := Value_Choice_Lists.Empty_List; L.Append (Value); end return; end Create_List; ---------- -- Load -- ---------- Pair_Regex : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile ("^(\w+)\s*=\s*""?([^""]*)""?$"); Empty_Line_Regex : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile ("^\s*$"); procedure Load (File_Name : in String; Schema : in Schema_Maps.Map; Vectors_List : out Lists.List) is File : Ada.Text_IO.File_Type; Test_Vector : Test_Vector_Maps.Map := Test_Vector_Maps.Empty_Map; begin Vectors_List := Lists.Empty_List; Ada.Text_IO.Open (File => File, Mode => Ada.Text_IO.In_File, Name => File_Name); while not Ada.Text_IO.End_Of_File (File) loop declare -- Read a line and trim whitespace. Line : constant String := Trim (Source => Ada.Text_IO.Get_Line (File), Left => To_Set (" " & CR), Right => To_Set (" " & CR)); begin Parse_Line (Test_Vector, Vectors_List, Schema, Line); end; end loop; Ada.Text_IO.Close (File); Append_Test_Vector (Test_Vector, Vectors_List, Schema); end Load; ---------------- -- Parse_Line -- ---------------- procedure Parse_Line (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map; Line : in String) is Pair_Match : GNAT.Regpat.Match_Array (0 .. 2) := (others => GNAT.Regpat.No_Match); Empty_Line_Match : GNAT.Regpat.Match_Array (0 .. 0) := (others => GNAT.Regpat.No_Match); Key_First : Natural; Key_Last : Natural; Key : Unbounded_String; Value_First : Natural; Value_Last : Natural; Value : Unbounded_String; begin GNAT.Regpat.Match (Pair_Regex, Line, Pair_Match); GNAT.Regpat.Match (Empty_Line_Regex, Line, Empty_Line_Match); if Empty_Line_Match (0) /= GNAT.Regpat.No_Match then -- Found an empty line. This signals the end of the current test vector entry. Append_Test_Vector (Test_Vector, Vectors_List, Schema); Test_Vector_Maps.Clear (Test_Vector); elsif Pair_Match (0) /= GNAT.Regpat.No_Match then Key_First := Pair_Match (1).First; Key_Last := Pair_Match (1).Last; Key := To_Unbounded_String (Line (Key_First .. Key_Last)); if Pair_Match (2) = GNAT.Regpat.No_Match then Value_First := Line'First; Value_Last := Line'First - 1; else Value_First := Pair_Match (2).First; Value_Last := Pair_Match (2).Last; end if; Value := To_Unbounded_String (Line (Value_First .. Value_Last)); Add_Test_Vector_Key_Value_Pair (Test_Vector, Vectors_List, Schema, Key, Value); end if; end Parse_Line; ------------------------------------ -- Add_Test_Vector_Key_Value_Pair -- ------------------------------------ procedure Add_Test_Vector_Key_Value_Pair (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map; Key : in Unbounded_String; Value : in Unbounded_String) is procedure Update_List (Key : in Unbounded_String; List : in out Value_Choice_Lists.List); procedure Update_List (Key : in Unbounded_String; List : in out Value_Choice_Lists.List) is begin case Schema.Element (Key).VType is when String_Type => List.Append (Value_Choice'(Controlled with VType => String_Type, Str => Value)); when Integer_Type => List.Append (Value_Choice'(Controlled with VType => Integer_Type, Int => Integer'Value (To_String (Value)))); when Hex_Array_Type => List.Append (Value_Choice'(Controlled with VType => Hex_Array_Type, Hex => Hex_String_To_Byte_Array (To_String (Value)))); end case; end Update_List; begin if Schema.Contains (Key) then -- Some test vector files do not have blank lines separating -- each test vector, so if we find a key that we have already -- put into the current test vector then we have found the -- start of the next test vector. if Test_Vector.Contains (Key) and not Schema.Element (Key).Is_List then Append_Test_Vector (Test_Vector, Vectors_List, Schema); end if; if Test_Vector.Contains (Key) then Test_Vector.Update_Element (Position => Test_Vector.Find (Key), Process => Update_List'Access); else case Schema.Element (Key).VType is when String_Type => Test_Vector.Insert (Key => Key, New_Item => Create_List (Value_Choice'(Controlled with VType => String_Type, Str => Value))); when Integer_Type => Test_Vector.Insert (Key => Key, New_Item => Create_List (Value_Choice'(Controlled with VType => Integer_Type, Int => Integer'Value (To_String (Value))))); when Hex_Array_Type => Test_Vector.Insert (Key => Key, New_Item => Create_List (Value_Choice'(Controlled with VType => Hex_Array_Type, Hex => Hex_String_To_Byte_Array (To_String (Value))))); end case; end if; else raise Schema_Error with "Unknown key"; end if; end Add_Test_Vector_Key_Value_Pair; ------------------------ -- Append_Test_Vector -- ------------------------ procedure Append_Test_Vector (Test_Vector : in out Test_Vector_Maps.Map; Vectors_List : in out Lists.List; Schema : in Schema_Maps.Map) is begin if not Test_Vector_Maps.Is_Empty (Test_Vector) then -- Check if there are any missing required schema values for C in Schema.Iterate loop if Schema_Maps.Element (C).Required and not Test_Vector.Contains (Schema_Maps.Key (C)) then raise Schema_Error with "Missing required key"; end if; end loop; Lists.Append (Vectors_List, Test_Vector); end if; end Append_Test_Vector; end Test_Vectors;
lkppo/sdlada
Ada
4,700
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Video.Palettes -- -- Palettes, colours and various conversions. -------------------------------------------------------------------------------------------------------------------- with Ada.Iterator_Interfaces; with Interfaces.C.Pointers; package SDL.Video.Palettes is pragma Preelaborate; package C renames Interfaces.C; type Colour_Component is range 0 .. 255 with Size => 8, Convention => C; type Colour is record Red : Colour_Component := Colour_Component'First; Green : Colour_Component := Colour_Component'First; Blue : Colour_Component := Colour_Component'First; Alpha : Colour_Component := Colour_Component'First; end record with Convention => C_Pass_by_Copy, Size => Colour_Component'Size * 4; Null_Colour : constant Colour := (others => <>); type RGB_Colour is record Red : Colour_Component := Colour_Component'First; Green : Colour_Component := Colour_Component'First; Blue : Colour_Component := Colour_Component'First; end record with Convention => C_Pass_by_Copy, Size => Colour_Component'Size * 4; Null_RGB_Colour : constant RGB_Colour := (others => <>); -- Cursor type for our iterator. type Cursor is private; No_Element : constant Cursor; function Element (Position : in Cursor) return Colour; function Has_Element (Position : in Cursor) return Boolean with Inline; -- Create the iterator interface package. package Palette_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); type Palette is tagged limited private with Default_Iterator => Iterate, Iterator_Element => Colour, Constant_Indexing => Constant_Reference; type Palette_Access is access Palette; function Constant_Reference (Container : aliased Palette; Position : Cursor) return Colour; function Iterate (Container : Palette) return Palette_Iterator_Interfaces.Forward_Iterator'Class; function Create (Total_Colours : in Positive) return Palette; procedure Free (Container : in out Palette); Empty_Palette : constant Palette; private type Colour_Array is array (C.size_t range <>) of aliased Colour with Convention => C; package Colour_Array_Pointer is new Interfaces.C.Pointers (Index => C.size_t, Element => Colour, Element_Array => Colour_Array, Default_Terminator => (others => Colour_Component'First)); type Internal_Palette is record Total : C.int; Colours : Colour_Array_Pointer.Pointer; Version : Interfaces.Unsigned_32; Ref_Count : C.int; end record with Convention => C; type Internal_Palette_Access is access Internal_Palette with Convention => C; type Palette is tagged limited record Data : Internal_Palette_Access; end record; type Palette_Constant_Access is access constant Palette; type Cursor is record Container : Palette_Constant_Access; Index : Natural; Current : Colour_Array_Pointer.Pointer; end record; No_Element : constant Cursor := Cursor'(Container => null, Index => Natural'First, Current => null); Empty_Palette : constant Palette := Palette'(Data => null); end SDL.Video.Palettes;
AdaCore/libadalang
Ada
107
ads
package Foo is type T is (A, B, C); subtype ST is T range B .. C; --% node.p_get_type() end Foo;
stcarrez/ada-servlet
Ada
9,042
adb
----------------------------------------------------------------------- -- servlet-cookies-tests - Unit tests for Cookies -- Copyright (C) 2011 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.Test_Caller; with Util.Log.Loggers; with Util.Measures; with Ada.Strings.Fixed; with Ada.Unchecked_Deallocation; package body Servlet.Cookies.Tests is use Ada.Strings.Fixed; use Util.Tests; use Util.Log; -- The logger Log : constant Loggers.Logger := Loggers.Create ("Servlet.Cookies.Tests"); procedure Free is new Ada.Unchecked_Deallocation (Cookie_Array, Cookie_Array_Access); package Caller is new Util.Test_Caller (Test, "Cookies"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Servlet.Cookies.Create_Cookie", Test_Create_Cookie'Access); Caller.Add_Test (Suite, "Test Servlet.Cookies.To_Http_Header", Test_To_Http_Header'Access); Caller.Add_Test (Suite, "Test Servlet.Cookies.Get_Cookies", Test_Parse_Http_Header'Access); end Add_Tests; -- ------------------------------ -- Test creation of cookie -- ------------------------------ procedure Test_Create_Cookie (T : in out Test) is C : constant Cookie := Create ("cookie", "value"); begin T.Assert_Equals ("cookie", Get_Name (C), "Invalid name"); T.Assert_Equals ("value", Get_Value (C), "Invalid value"); T.Assert (not Is_Secure (C), "Invalid is_secure"); end Test_Create_Cookie; -- ------------------------------ -- Test conversion of cookie for HTTP header -- ------------------------------ procedure Test_To_Http_Header (T : in out Test) is procedure Test_Cookie (C : in Cookie) is S : constant String := To_Http_Header (C); begin Log.Info ("Cookie {0}: {1}", Get_Name (C), S); T.Assert (S'Length > 0, "Invalid cookie length for: " & S); T.Assert (Index (S, "=") > 0, "Invalid cookie format; " & S); end Test_Cookie; procedure Test_Cookie (Name : in String; Value : in String) is C : Cookie := Create (Name, Value); begin Test_Cookie (C); for I in 1 .. 24 loop Set_Max_Age (C, I * 3600 + I); Test_Cookie (C); end loop; Set_Secure (C, True); Test_Cookie (C); Set_Http_Only (C, True); Test_Cookie (C); Set_Domain (C, "world.com"); Test_Cookie (C); Set_Path (C, "/some-path"); Test_Cookie (C); end Test_Cookie; begin Test_Cookie ("a", "b"); Test_Cookie ("session_id", "79e2317bcabe731e2f681f5725bbc621-&v=1"); Test_Cookie ("p_41_zy", ""); Test_Cookie ("p_34", """quoted\t"""); Test_Cookie ("d", "s"); declare C : Cookie := Create ("cookie-name", "79e2317bcabe731e2f681f5725bbc621"); Start : Util.Measures.Stamp; begin Set_Path (C, "/home"); Set_Domain (C, ".mydomain.example.com"); Set_Max_Age (C, 1000); Set_Http_Only (C, True); Set_Secure (C, True); Set_Comment (C, "some comment"); for I in 1 .. 1000 loop declare S : constant String := To_Http_Header (C); begin if S'Length < 10 then T.Assert (S'Length > 10, "Invalid cookie generation"); end if; end; end loop; Util.Measures.Report (S => Start, Title => "Generation of 1000 cookies"); end; end Test_To_Http_Header; -- ------------------------------ -- Test parsing of client cookie to build a list of Cookie objects -- ------------------------------ procedure Test_Parse_Http_Header (T : in out Test) is -- ------------------------------ -- Parse the header and check for the expected cookie count and verify -- the value of a specific cookie -- ------------------------------ procedure Test_Parse (Header : in String; Count : in Natural; Name : in String; Value : in String) is Start : Util.Measures.Stamp; C : Cookie_Array_Access := Get_Cookies (Header); Found : Boolean := False; begin Util.Measures.Report (S => Start, Title => "Parsing of cookie " & Name); T.Assert (C /= null, "Null value returned by Get_Cookies"); Assert_Equals (T, Count, C'Length, "Invalid count in result array"); for I in C'Range loop Log.Debug ("Cookie: {0}={1}", Get_Name (C (I)), Get_Value (C (I))); if Name = Get_Name (C (I)) then Assert_Equals (T, Value, Get_Value (C (I)), "Invalid cookie: " & Name); Found := True; end if; end loop; T.Assert (Found, "Cookie " & Name & " not found"); Free (C); end Test_Parse; begin Test_Parse ("A=B", 1, "A", "B"); Test_Parse ("A=B=", 1, "A", "B="); Test_Parse ("CONTEXTE=mar=101&nab=84fbbe2a81887732fe9c635d9ac319b5" & "&pfl=afide0&typsrv=we&sc=1&soumar=1011&srcurlconfigchapeau" & "=sous_ouv_formulaire_chapeau_dei_config&nag=550&reg=14505; " & "xtvrn=$354249$354336$; CEPORM=321169600.8782.0000; SES=auth=0&" & "cartridge_url=&return_url=; CEPORC=344500416.8782.0000", 5, "SES", "auth=0&cartridge_url=&return_url="); Test_Parse ("s_nr=1298652863627; s_sq=%5B%5BB%5D%5D; s_cc=true; oraclelicense=" & "accept-dbindex-cookie; gpv_p24=no%20value; gpw_e24=no%20value", 6, "gpw_e24", "no%20value"); -- Parse a set of cookies from microsoft.com Test_Parse ("WT_FPC=id=00.06.036.020-2037773472.29989343:lv=1300442685103:ss=1300442685103; " & "MC1=GUID=9d86c397c1a5ea4cab48d9fe19b76b4e&HASH=97c3&LV=20092&V=3; " & "A=I&I=AxUFAAAAAABwBwAALSllub5HorZBtWWX8ZeXcQ!!&CS=114[3B002j2p[0302g3V309; " & "WT_NVR_RU=0=technet|msdn:1=:2=; mcI=Fri, 31 Dec 2010 10:44:31 GMT; " & "omniID=beb780dd_ab6d_4802_9f37_e33dde280adb; CodeSnippetContainerLang=" & "Visual Basic; MSID=Microsoft.CreationDate=11/09/2010 10:08:25&Microsoft." & "LastVisitDate=03/01/2011 17:08:34&Microsoft.VisitStartDate=03/01/2011 " & "17:08:34&Microsoft.CookieId=882efa27-ee6c-40c5-96ba-2297f985d9e3&Microsoft" & ".TokenId=0c0a5e07-37a6-4ca3-afc0-0edf3de329f6&Microsoft.NumberOfVisits=" & "60&Microsoft.IdentityToken=RojEm8r/0KbCYeKasdfwekl3FtctotD5ocj7WVR72795" & "dBj23rXVz5/xeldkkKHr/NtXFN3xAvczHlHQHKw14/9f/VAraQFIzEYpypGE24z1AuPCzVwU" & "l4HZPnOFH+IA0u2oarcR1n3IMC4Gk8D1UOPBwGlYMB2Xl2W+Up8kJikc4qUxmFG+X5SRrZ3m7" & "LntAv92B4v7c9FPewcQHDSAJAmTOuy7+sl6zEwW2fGWjqGe3G7bh+qqUWPs4LrvSyyi7T3UCW" & "anSWn6jqJInP/MSeAxAvjbTrBwlJlE3AoUfXUJgL81boPYsIXZ30lPpqjMkyc0Jd70dffNNTo5" & "qwkvfFhyOvnfYoQ7dZ0REw+TRA01xHyyUSPINOVgM5Vcu4SdvcUoIlMR3Y097nK+lvx8SqV4UU" & "+QENW1wbBDa7/u6AQqUuk0616tWrBQMR9pYKwYsORUqLkQY5URzhVVA7Py28dLX002Nehqjbh68" & "4xQv/gQYbPZMZUq/wgmPsqA5mJU/lki6A0S/H/ULGbrJE0PBQr8T+Hd+Op4HxEHvjvkTs=&Micr" & "osoft.MicrosoftId=0004-1282-6244-7365; msresearch=%7B%22version%22%3A%224.6" & "%22%2C%22state%22%3A%7B%22name%22%3A%22IDLE%22%2C%22url%22%3Aundefined%2C%2" & "2timestamp%22%3A1296211850175%7D%2C%22lastinvited%22%3A1296211850175%2C%22u" & "serid%22%3A%2212962118501758905232121057759%22%2C%22vendorid%22%3A1%2C%22su" & "rveys%22%3A%5Bundefined%5D%7D; s_sq=%5B%5BB%5D%5D; s_cc=true; " & "GsfxStatsLog=true; GsfxSessionCookie=231210164895294015; ADS=SN=175A21EF;" & ".ASPXANONYMOUS=HJbsF8QczAEkAAAAMGU4YjY4YTctNDJhNy00NmQ3LWJmOWEtNjVjMzFmODY" & "1ZTA5dhasChFIbRm1YpxPXPteSbwdTE01", 15, "s_sq", "%5B%5BB%5D%5D"); end Test_Parse_Http_Header; end Servlet.Cookies.Tests;
zhmu/ananas
Ada
405
adb
-- { dg-do compile } -- { dg-options "-gnatws -O2 -fdump-tree-optimized" } with System; use System; with System.CRTL; use System.CRTL; function Opt60 (Size : size_t) return System.Address is Result : System.Address; begin Result := malloc (Size); if Result = System.Null_Address then raise Program_Error; end if; return Result; end; -- { dg-final { scan-tree-dump "== 0B" "optimized" } }
stcarrez/ada-awa
Ada
27,848
adb
----------------------------------------------------------------------- -- awa-tags-components -- Tags component -- Copyright (C) 2013, 2014, 2015, 2018, 2019, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Exceptions; with Ada.Unchecked_Deallocation; with Util.Strings; with Util.Log.Loggers; with ASF.Utils; with ASF.Converters; with ASF.Views.Nodes; with ASF.Components; with ASF.Components.Utils; with ASF.Components.Base; with ASF.Requests; with ASF.Events.Faces.Actions; with ASF.Applications.Main; with AWA.Tags.Beans; package body AWA.Tags.Components is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Tags.Components"); READONLY_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; function Create_Tag return ASF.Components.Base.UIComponent_Access; function Create_Cloud return ASF.Components.Base.UIComponent_Access; procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info; Item2 : in out AWA.Tags.Models.Tag_Info); procedure Dispatch (List : in out Tag_Info_Array); -- ------------------------------ -- Create an Tag_UIInput component -- ------------------------------ function Create_Tag return ASF.Components.Base.UIComponent_Access is begin return new Tag_UIInput; end Create_Tag; -- ------------------------------ -- Create an Tag_UICloud component -- ------------------------------ function Create_Cloud return ASF.Components.Base.UIComponent_Access is begin return new Tag_UICloud; end Create_Cloud; URI : aliased constant String := "http://code.google.com/p/ada-awa/jsf"; TAG_LIST_TAG : aliased constant String := "tagList"; TAG_CLOUD_TAG : aliased constant String := "tagCloud"; AWA_Bindings : aliased constant ASF.Factory.Binding_Array := (1 => (Name => TAG_CLOUD_TAG'Access, Component => Create_Cloud'Access, Tag => ASF.Views.Nodes.Create_Component_Node'Access), 2 => (Name => TAG_LIST_TAG'Access, Component => Create_Tag'Access, Tag => ASF.Views.Nodes.Create_Component_Node'Access) ); AWA_Factory : aliased constant ASF.Factory.Factory_Bindings := (URI => URI'Access, Bindings => AWA_Bindings'Access); -- ------------------------------ -- Get the Tags component factory. -- ------------------------------ function Definition return ASF.Factory.Factory_Bindings_Access is begin return AWA_Factory'Access; end Definition; -- ------------------------------ -- Returns True if the tag component must be rendered as readonly. -- ------------------------------ function Is_Readonly (UI : in Tag_UIInput; Context : in ASF.Contexts.Faces.Faces_Context'Class) return Boolean is pragma Unreferenced (Context); use type ASF.Components.Html.Forms.UIForm_Access; begin return UI.Get_Form = null; end Is_Readonly; -- ------------------------------ -- Render the javascript to enable the tag edition. -- ------------------------------ procedure Render_Script (UI : in Tag_UIInput; Id : in String; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Auto_Complete : constant String := UI.Get_Attribute ("autoCompleteUrl", Context); Allow_Edit : constant Boolean := UI.Get_Attribute ("allowEdit", Context); begin Writer.Queue_Script ("$('#"); Writer.Queue_Script (Id); Writer.Queue_Script (" input').tagedit({"); Writer.Queue_Script ("allowEdit: "); if Allow_Edit then Writer.Queue_Script ("true"); else Writer.Queue_Script ("false"); end if; if Auto_Complete'Length > 0 then Writer.Queue_Script (", autocompleteURL: '"); Writer.Queue_Script (Auto_Complete); Writer.Queue_Script ("'"); end if; Writer.Queue_Script ("});"); end Render_Script; -- ------------------------------ -- Get the tag after convertion with the optional converter. -- ------------------------------ function Get_Tag (UI : in Tag_UIInput; Tag : in Util.Beans.Objects.Object; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is begin if not Util.Beans.Objects.Is_Null (Tag) then declare Convert : constant access ASF.Converters.Converter'Class := Tag_UIInput'Class (UI).Get_Converter; begin if Convert /= null then return Convert.To_String (Value => Tag, Component => UI, Context => Context); else return Util.Beans.Objects.To_String (Value => Tag); end if; end; else return ""; end if; end Get_Tag; -- ------------------------------ -- Render the tag as a readonly item. -- ------------------------------ procedure Render_Readonly_Tag (UI : in Tag_UIInput; Tag : in Util.Beans.Objects.Object; Class : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Value : constant String := UI.Get_Tag (Tag, Context); begin Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Class) then Writer.Write_Attribute ("class", Class); end if; Writer.Start_Element ("span"); Writer.Write_Text (Value); Writer.End_Element ("span"); Writer.End_Element ("li"); end Render_Readonly_Tag; -- ------------------------------ -- Render the tag as a link. -- ------------------------------ procedure Render_Link_Tag (UI : in Tag_UIInput; Name : in String; Tag : in Util.Beans.Objects.Object; Link : in EL.Expressions.Expression; Class : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Value : constant String := UI.Get_Tag (Tag, Context); begin Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (Value)); Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Class) then Writer.Write_Attribute ("class", Class); end if; Writer.Start_Element ("a"); Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all)); Writer.Write_Text (Value); Writer.End_Element ("a"); Writer.End_Element ("li"); end Render_Link_Tag; -- ------------------------------ -- Render the tag for an input form. -- ------------------------------ procedure Render_Form_Tag (UI : in Tag_UIInput; Id : in String; Tag : in Util.Beans.Objects.Object; Writer : in Response_Writer_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin Writer.Start_Element ("input"); Writer.Write_Attribute (Name => "type", Value => "text"); Writer.Write_Attribute (Name => "name", Value => Id); if not Util.Beans.Objects.Is_Null (Tag) then declare Convert : constant access ASF.Converters.Converter'Class := Tag_UIInput'Class (UI).Get_Converter; begin if Convert /= null then Writer.Write_Attribute (Name => "value", Value => Convert.To_String (Value => Tag, Component => UI, Context => Context)); else Writer.Write_Attribute (Name => "value", Value => Tag); end if; end; end if; Writer.End_Element ("input"); end Render_Form_Tag; -- ------------------------------ -- Render the list of tags as readonly list. If a <tt>tagLink</tt> attribute is defined, -- a link is rendered for each tag. Otherwise, each tag is rendered as a <tt>span</tt>. -- ------------------------------ procedure Render_Readonly (UI : in Tag_UIInput; List : in Util.Beans.Basic.List_Bean_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Class : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass"); Count : constant Natural := List.Get_Count; Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink"); begin if Count > 0 then Writer.Start_Element ("ul"); UI.Render_Attributes (Context, Writer); if Link /= null then declare Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink"); Name : constant String := UI.Get_Attribute (Name => "var", Context => Context, Default => "tag"); begin for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Link_Tag (Name => Name, Tag => List.Get_Row, Link => Link, Class => Class, Writer => Writer, Context => Context); end loop; end; else for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Readonly_Tag (Tag => List.Get_Row, Class => Class, Writer => Writer, Context => Context); end loop; end if; Writer.End_Element ("ul"); end if; end Render_Readonly; -- ------------------------------ -- Render the list of tags for a form. -- ------------------------------ procedure Render_Form (UI : in Tag_UIInput; List : in Util.Beans.Basic.List_Bean_Access; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id); Count : constant Natural := List.Get_Count; Writer : constant Response_Writer_Access := Context.Get_Response_Writer; begin Writer.Start_Element ("div"); UI.Render_Attributes (Context, Writer); if Count > 0 then for I in 1 .. Count loop List.Set_Row_Index (I); Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[" & Util.Strings.Image (I) & "]", List.Get_Row, Writer, Context); end loop; else Writer.Write_Attribute ("id", Id); end if; Tag_UIInput'Class (UI).Render_Form_Tag (Id & "[]", Util.Beans.Objects.Null_Object, Writer, Context); Writer.End_Element ("div"); Tag_UIInput'Class (UI).Render_Script (Id, Writer, Context); end Render_Form; -- ------------------------------ -- Render the input component. Starts the DL/DD list and write the input -- component with the possible associated error message. -- ------------------------------ overriding procedure Encode_Begin (UI : in Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); Readonly : constant Boolean := UI.Is_Readonly (Context); List : Util.Beans.Basic.List_Bean_Access; begin if Bean = null then if not Readonly then ASF.Components.Base.Log_Error (UI, "There is no tagList bean value"); end if; return; elsif not (Bean.all in Util.Beans.Basic.List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "There bean value is not a List_Bean"); return; end if; List := Util.Beans.Basic.List_Bean'Class (Bean.all)'Unchecked_Access; if Readonly then UI.Render_Readonly (List, Context); else UI.Render_Form (List, Context); end if; end; end Encode_Begin; -- ------------------------------ -- Render the end of the input component. Closes the DL/DD list. -- ------------------------------ overriding procedure Encode_End (UI : in Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin null; end Encode_End; -- ------------------------------ -- Get the action method expression to invoke if the command is pressed. -- ------------------------------ function Get_Action_Expression (UI : in Tag_UIInput; Context : in ASF.Contexts.Faces.Faces_Context'Class) return EL.Expressions.Method_Expression is pragma Unreferenced (Context); begin return UI.Get_Method_Expression (Name => ASF.Components.ACTION_NAME); end Get_Action_Expression; -- ------------------------------ -- Decode any new state of the specified component from the request contained -- in the specified context and store that state on the component. -- -- During decoding, events may be enqueued for later processing -- (by event listeners that have registered an interest), by calling -- the <b>Queue_Event</b> on the associated component. -- ------------------------------ overriding procedure Process_Decodes (UI : in out Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Req : constant ASF.Requests.Request_Access := Context.Get_Request; Id : constant String := Ada.Strings.Unbounded.To_String (UI.Get_Client_Id); procedure Process_Parameter (Name, Value : in String); procedure Process_Parameter (Name, Value : in String) is begin if Name'Length <= Id'Length or else Name (Name'Last) /= ']' then return; end if; if Name (Name'First .. Name'First + Id'Length - 1) /= Id then return; end if; if Name (Name'First + Id'Length) /= '[' then return; end if; if Name (Name'Last - 1) = 'd' then UI.Deleted.Append (Value); elsif Name (Name'Last - 1) = 'a' or else Name (Name'Last - 1) = '[' then UI.Added.Append (Value); end if; end Process_Parameter; Val : constant String := Context.Get_Parameter (Id); begin Req.Iterate_Parameters (Process_Parameter'Access); UI.Is_Valid := True; if not UI.Added.Is_Empty or else not UI.Deleted.Is_Empty then ASF.Events.Faces.Actions.Post_Event (UI => UI, Method => UI.Get_Action_Expression (Context)); end if; exception when E : others => UI.Is_Valid := False; Log.Info (ASF.Components.Utils.Get_Line_Info (UI) & ": Exception raised when converting value {0} for component {1}: {2}", Val, Id, Ada.Exceptions.Exception_Name (E)); end; end Process_Decodes; -- ------------------------------ -- Perform the component tree processing required by the <b>Update Model Values</b> -- phase of the request processing lifecycle for all facets of this component, -- all children of this component, and this component itself, as follows. -- <ul> -- <li>If this component <b>rendered</b> property is false, skip further processing. -- <li>Call the <b>Process_Updates/b> of all facets and children. -- <ul> -- ------------------------------ overriding procedure Process_Updates (UI : in out Tag_UIInput; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is begin if UI.Is_Valid and then not UI.Is_Rendered (Context) then return; end if; declare use AWA.Tags.Beans; Value : constant Util.Beans.Objects.Object := Tag_UIInput'Class (UI).Get_Value; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); List : access Tag_List_Bean'Class; begin if Bean = null then ASF.Components.Base.Log_Error (UI, "There is no tagList bean value"); return; elsif not (Bean.all in Tag_List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "There is not taglist bean"); return; end if; List := Tag_List_Bean'Class (Bean.all)'Access; List.Set_Added (UI.Added); List.Set_Deleted (UI.Deleted); end; end Process_Updates; -- ------------------------------ -- Broadcast the event to the event listeners installed on this component. -- Listeners are called in the order in which they were added. -- ------------------------------ overriding procedure Broadcast (UI : in out Tag_UIInput; Event : not null access ASF.Events.Faces.Faces_Event'Class; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is pragma Unreferenced (UI); use ASF.Events.Faces.Actions; App : constant access ASF.Applications.Main.Application'Class := Context.Get_Application; Disp : constant Action_Listener_Access := App.Get_Action_Listener; begin if Disp /= null and then Event.all in Action_Event'Class then Disp.Process_Action (Event => Action_Event (Event.all), Context => Context); end if; end Broadcast; -- ------------------------------ -- Render the list of tags. If the <tt>tagLink</tt> attribute is defined, a link -- is rendered for each tag. -- ------------------------------ procedure Render_Cloud (UI : in Tag_UICloud; List : in Tag_Info_Array; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Link : constant access ASF.Views.Nodes.Tag_Attribute := UI.Get_Attribute ("tagLink"); Style : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "tagClass"); Font_Size : constant Boolean := True; begin Writer.Start_Element ("ul"); UI.Render_Attributes (Context, Writer); if Link /= null then declare Link : constant EL.Expressions.Expression := UI.Get_Expression ("tagLink"); Name : constant String := UI.Get_Attribute ("var", Context, ""); begin for I in List'Range loop Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Style) then Writer.Write_Attribute ("class", Style); end if; Writer.Start_Element ("a"); Context.Set_Attribute (Name, Util.Beans.Objects.To_Object (List (I).Tag)); Writer.Write_Attribute ("href", Link.Get_Value (Context.Get_ELContext.all)); if Font_Size then Writer.Write_Attribute ("style", "font-size:" & Util.Strings.Image (List (I).Count / 100) & "." & Util.Strings.Image (List (I).Count mod 100) & "px;"); else Writer.Write_Attribute ("class", "tag" & Util.Strings.Image (List (I).Count / 100)); end if; Writer.Write_Text (List (I).Tag); Writer.End_Element ("a"); Writer.End_Element ("li"); end loop; end; else for I in List'Range loop Writer.Start_Element ("li"); if not Util.Beans.Objects.Is_Null (Style) then Writer.Write_Attribute ("class", Style); end if; Writer.Write_Text (List (I).Tag); Writer.End_Element ("li"); end loop; end if; Writer.End_Element ("ul"); end Render_Cloud; -- ------------------------------ -- Compute the weight for each tag in the list according to the <tt>minWeight</tt> and -- <tt>maxWeight</tt> attributes. The computed weight is an integer multiplied by 100 -- and will range from 100x<i>minWeight</i> and 100x<i>maxWeight</i>. -- ------------------------------ procedure Compute_Cloud_Weight (UI : in Tag_UICloud; List : in out Tag_Info_Array; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is Min : constant Integer := UI.Get_Attribute ("minWeight", Context, 0); Max : constant Integer := UI.Get_Attribute ("maxWeight", Context, 100) - Min; Min_Count : constant Natural := List (List'Last).Count; Max_Count : Natural := List (List'First).Count; begin if Max_Count = Min_Count then Max_Count := Min_Count + 1; end if; for I in List'Range loop if List (I).Count = Min_Count then List (I).Count := 100 * Min; else List (I).Count := (100 * Max * (List (I).Count - Min_Count)) / (Max_Count - Min_Count) + 100 * Min; end if; end loop; end Compute_Cloud_Weight; procedure Swap (Item1 : in out AWA.Tags.Models.Tag_Info; Item2 : in out AWA.Tags.Models.Tag_Info) is Tmp : constant AWA.Tags.Models.Tag_Info := Item2; begin Item2 := Item1; Item1 := Tmp; end Swap; -- ------------------------------ -- A basic algorithm to dispatch the tags in the list. -- The original list is sorted on the tag count (due to the Tag_Ordered_Sets). -- We try to dispatch the first tags somewhere in the first or second halves of the list. -- ------------------------------ procedure Dispatch (List : in out Tag_Info_Array) is Middle : constant Natural := List'First + List'Length / 2; Quarter : Natural := List'Length / 4; Target : Natural := Middle; Pos : Natural := 0; begin while Target <= List'Last and then List'First + Pos < Middle and then Quarter /= 0 loop Swap (List (List'First + Pos), List (Target)); Pos := Pos + 1; if Target <= Middle then Target := List'Last - Quarter; else Target := List'First + Quarter; Quarter := Quarter / 2; end if; end loop; end Dispatch; -- ------------------------------ -- Render the tag cloud component. -- ------------------------------ overriding procedure Encode_Children (UI : in Tag_UICloud; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is procedure Free is new Ada.Unchecked_Deallocation (Object => Tag_Info_Array, Name => Tag_Info_Array_Access); Table : Tag_Info_Array_Access := null; begin if not UI.Is_Rendered (Context) then return; end if; declare use type Util.Beans.Basic.List_Bean_Access; Max : constant Integer := UI.Get_Attribute ("rows", Context, 1000); Layout : constant String := UI.Get_Attribute ("layout", Context); Bean : constant Util.Beans.Basic.List_Bean_Access := ASF.Components.Utils.Get_List_Bean (UI, "value", Context); Count : Natural; Tags : AWA.Tags.Beans.Tag_Ordered_Sets.Set; List : AWA.Tags.Beans.Tag_Info_List_Bean_Access; begin -- Check that we have a List_Bean but do not complain if we have a null value. if Bean = null or else Max <= 0 then return; end if; if not (Bean.all in AWA.Tags.Beans.Tag_Info_List_Bean'Class) then ASF.Components.Base.Log_Error (UI, "Invalid tag list bean: it does not " & "implement 'Tag_Info_List_Bean' interface"); return; end if; List := AWA.Tags.Beans.Tag_Info_List_Bean'Class (Bean.all)'Unchecked_Access; Count := List.Get_Count; if Count = 0 then return; end if; -- Pass 1: Collect the tags and keep the most used. for I in 1 .. Count loop Tags.Insert (List.List.Element (I)); if Integer (Tags.Length) > Max then Tags.Delete_Last; end if; end loop; Count := Natural (Tags.Length); Table := new Tag_Info_Array (1 .. Count); for I in 1 .. Count loop Table (I) := Tags.First_Element; Tags.Delete_First; end loop; -- Pass 2: Assign weight to each tag. UI.Compute_Cloud_Weight (Table.all, Context); -- Pass 3: Dispatch the tags using some layout algorithm. if Layout = "dispatch" then Dispatch (Table.all); end if; -- Pass 4: Render each tag. UI.Render_Cloud (Table.all, Context); Free (Table); exception when others => Free (Table); raise; end; end Encode_Children; begin ASF.Utils.Set_Text_Attributes (READONLY_ATTRIBUTE_NAMES); end AWA.Tags.Components;
tum-ei-rcs/StratoX
Ada
4,011
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S E C O N D A R Y _ S T A C K -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2014, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Version for use in HI-E mode with System.Storage_Elements; package System.Secondary_Stack with SPARK_Mode => On is package SSE renames System.Storage_Elements; Default_Secondary_Stack_Size : constant := 10 * 1024; -- Default size of a secondary stack procedure SS_Init (Stk : System.Address; Size : Natural := Default_Secondary_Stack_Size); -- Initialize the secondary stack with a main stack of the given Size. -- -- Stk is an IN parameter that is already pointing to a memory area of -- size Size and aligned to Standard'Maximum_Alignment. -- -- The secondary stack is fixed, and any attempt to allocate more than the -- initial size will result in a Storage_Error being raised. procedure SS_Allocate (Address : out System.Address; Storage_Size : SSE.Storage_Count); -- Allocate enough space for a 'Storage_Size' bytes object with Maximum -- alignment. The address of the allocated space is returned in 'Address' type Mark_Id is private; -- Type used to mark the stack function SS_Mark return Mark_Id; -- Return the Mark corresponding to the current state of the stack procedure SS_Release (M : Mark_Id); -- Restore the state of the stack corresponding to the mark M. If an -- additional chunk have been allocated, it will never be freed during a private pragma SPARK_Mode (Off); SS_Pool : Integer; -- Unused entity that is just present to ease the sharing of the pool -- mechanism for specific allocation/deallocation in the compiler type Mark_Id is new SSE.Integer_Address; end System.Secondary_Stack;
charlie5/lace
Ada
6,744
adb
with gel.Window.sdl, gel.Applet.gui_world, gel.Forge, gel.Sprite, gel.hinge_Joint, physics.Model, openGL.Model.box.colored, openGL.Palette, float_math.Algebra.linear.d3, ada.Text_IO, ada.Exceptions; pragma unreferenced (gel.Window.sdl); procedure launch_hinged_Box -- -- Shows variously hinged boxes. -- is package Math renames float_Math; use openGL, openGL.Model.box, opengl.Palette, ada.Text_IO; the_Applet : constant gel.Applet.gui_World.view := gel.Forge.new_gui_Applet ("hinged Box", 1536, 864); X : float_math.Real := 0.0; begin the_Applet.gui_Camera.Site_is ([0.0, 4.0, 30.0]); -- Position the camera. the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboard. the_Applet.Renderer.Background_is (Blue); -- Add sprites and joints. -- declare use float_Math; box_Size : constant gel.Math.Vector_3 := [1.0, 1.0, 1.0]; -- Box -- the_box_Model : constant openGL.Model.box.colored.view := openGL.Model.box.colored.new_Box (Size => box_Size, Faces => [Front => (colors => [others => (Red, Opaque)]), Rear => (colors => [others => (Blue, Opaque)]), Upper => (colors => [others => (Violet, Opaque)]), Lower => (colors => [others => (Yellow, Opaque)]), Left => (colors => [others => (Cyan, Opaque)]), Right => (colors => [others => (Magenta, Opaque)])]); the_static_box_physics_Model : constant physics.Model.view := physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube, half_Extents => box_Size)); the_dynamic_box_physics_Model : constant physics.Model.view := physics.Model.forge.new_physics_Model (shape_Info => (Kind => physics.Model.cube, half_Extents => box_Size / 2.0), Mass => 1.0); the_Box_1 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.static.1", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_static_box_physics_Model, owns_Graphics => False, owns_Physics => True); the_Box_2 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.2", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_dynamic_box_physics_Model, owns_Graphics => False, owns_Physics => False); the_Box_3 : constant gel.Sprite.view := gel.Sprite.forge.new_Sprite ("demo.Box.dynamic.3", the_Applet.gui_World.all'Access, math.Origin_3d, the_box_Model.all'Access, the_dynamic_box_physics_Model, owns_Graphics => True, owns_Physics => True); the_Joint_1 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item; the_Joint_2 : constant gel.hinge_Joint.view := new gel.hinge_Joint.item; begin the_Applet.gui_World.Gravity_is ([0.0, -10.0, 0.0]); the_Applet.gui_World.add (the_Box_1); the_Applet.gui_World.add (the_Box_2); the_Applet.gui_World.add (the_Box_3); the_Box_1.Site_is ([ 0.0, 0.0, 0.0]); the_Box_2.Site_is ([ -1.0, 2.0, 0.0]); the_Box_3.Site_is ([ 10.0, 10.0, 0.0]); -- the_Box_3.Site_is (( 10.0, 10.0, 0.0)); declare use math.Algebra.linear.d3; Frame_1 : constant math.Matrix_4x4 := math.Identity_4x4; Frame_2 : math.Matrix_4x4 := math.Identity_4x4; Frame_3 : math.Matrix_4x4 := math.Identity_4x4; y_Rot : math.Matrix_3x3 := y_Rotation_from (to_Radians (180.0)); begin set_Translation (Frame_2, [2.0, 2.0, 0.0]); set_Translation (Frame_3, [8.0, 8.0, 0.0]); -- set_Translation (Frame_3, (8.0, 8.0, 0.0)); -- set_Translation (Frame_B, y_Rot * math.Vector_3'( -2.0, 0.0, 0.0)); -- -- set_Rotation (Frame_A, x_Rotation_from (to_Radians (0.0))); -- set_Rotation (Frame_B, y_Rot); the_Joint_1.define (the_Applet.gui_World.Space, the_Box_3, Frame_3); the_Joint_2.define (the_Applet.gui_World.Space, the_Box_1, the_Box_2, Frame_1, Frame_2, low_Limit => to_Radians (-360.0), high_Limit => to_Radians ( 360.0), collide_Conected => False); -- TODO: -- the_Joint_2.define (the_Applet.gui_World.Space, -- the_Box_1, the_Box_2, -- pivot_Axis => (0.0, 0.0, 0.0)); -- the_Joint.low_Bound_is (Pitch, 0.0); -- the_Joint.low_Bound_is (Yaw, 0.0); -- the_Joint.low_Bound_is (Roll, 0.0); -- -- the_Joint.high_Bound_is (Pitch, 0.0); -- the_Joint.high_Bound_is (Yaw, 0.0); -- the_Joint.high_Bound_is (Roll, 0.0); end; the_Applet.gui_World.add (the_Joint_1.all'Access); -- Add joint to the world. the_Applet.gui_World.add (the_Joint_2.all'Access); -- Add joint to the world. end; while the_Applet.is_open loop the_Applet.freshen; -- Handle any new events and update the screen. end loop; the_Applet.destroy; exception when E : others => new_Line; put_Line ("Unhandled exception in main thread !"); put_Line (ada.Exceptions.exception_Information (E)); new_Line; end launch_hinged_Box;
reznikmm/matreshka
Ada
20,114
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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.OCL_Attributes; with AMF.OCL.Ocl_Expressions; with AMF.OCL.Variables.Collections; 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.String_Expressions; with AMF.UML.Types; with AMF.Visitors.OCL_Iterators; with AMF.Visitors.OCL_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.OCL_Iterate_Exps is ---------------- -- Get_Result -- ---------------- overriding function Get_Result (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.OCL.Variables.OCL_Variable_Access is begin return AMF.OCL.Variables.OCL_Variable_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Result (Self.Element))); end Get_Result; ---------------- -- Set_Result -- ---------------- overriding procedure Set_Result (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.OCL.Variables.OCL_Variable_Access) is begin raise Program_Error; -- AMF.Internals.Tables.OCL_Attributes.Internal_Set_Result -- (Self.Id, -- AMF.Internals.Helpers.To_Element -- (AMF.Elements.Element_Access (To))); end Set_Result; -------------- -- Get_Body -- -------------- overriding function Get_Body (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is begin return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Body (Self.Element))); end Get_Body; -------------- -- Set_Body -- -------------- overriding procedure Set_Body (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Body (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Body; ------------------ -- Get_Iterator -- ------------------ overriding function Get_Iterator (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.OCL.Variables.Collections.Ordered_Set_Of_OCL_Variable is begin return AMF.OCL.Variables.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Iterator (Self.Element))); end Get_Iterator; ---------------- -- Get_Source -- ---------------- overriding function Get_Source (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is begin return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Source (Self.Element))); end Get_Source; ---------------- -- Set_Source -- ---------------- overriding procedure Set_Source (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Source (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Source; -------------- -- Get_Type -- -------------- overriding function Get_Type (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Types.UML_Type_Access is begin return AMF.UML.Types.UML_Type_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Type (Self.Element))); end Get_Type; -------------- -- Set_Type -- -------------- overriding procedure Set_Type (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.UML.Types.UML_Type_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Type (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Type; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Name; -------------- -- Set_Name -- -------------- overriding procedure Set_Name (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.Optional_String) is begin if To.Is_Empty then AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, null); else AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, League.Strings.Internals.Internal (To.Value)); end if; end Set_Name; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; -------------------- -- Get_Visibility -- -------------------- overriding function Get_Visibility (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Optional_UML_Visibility_Kind is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility (Self.Element); end Get_Visibility; -------------------- -- Set_Visibility -- -------------------- overriding procedure Set_Visibility (Self : not null access OCL_Iterate_Exp_Proxy; To : AMF.UML.Optional_UML_Visibility_Kind) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility (Self.Element, To); end Set_Visibility; ----------------------- -- Get_Owned_Comment -- ----------------------- overriding function Get_Owned_Comment (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Comments.Collections.Set_Of_UML_Comment is begin return AMF.UML.Comments.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment (Self.Element))); end Get_Owned_Comment; ----------------------- -- Get_Owned_Element -- ----------------------- overriding function Get_Owned_Element (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element (Self.Element))); end Get_Owned_Element; --------------- -- Get_Owner -- --------------- overriding function Get_Owner (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Elements.UML_Element_Access is begin return AMF.UML.Elements.UML_Element_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner (Self.Element))); end Get_Owner; -------------------- -- All_Namespaces -- -------------------- overriding function All_Namespaces (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.All_Namespaces"; return All_Namespaces (Self); end All_Namespaces; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant OCL_Iterate_Exp_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.Namespace"; return Namespace (Self); end Namespace; -------------------- -- Qualified_Name -- -------------------- overriding function Qualified_Name (Self : not null access constant OCL_Iterate_Exp_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.Qualified_Name"; return Qualified_Name (Self); end Qualified_Name; --------------- -- Separator -- --------------- overriding function Separator (Self : not null access constant OCL_Iterate_Exp_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Separator unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.Separator"; return Separator (Self); end Separator; ------------------------ -- All_Owned_Elements -- ------------------------ overriding function All_Owned_Elements (Self : not null access constant OCL_Iterate_Exp_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.All_Owned_Elements"; return All_Owned_Elements (Self); end All_Owned_Elements; ------------------- -- Must_Be_Owned -- ------------------- overriding function Must_Be_Owned (Self : not null access constant OCL_Iterate_Exp_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Iterate_Exp_Proxy.Must_Be_Owned"; return Must_Be_Owned (Self); end Must_Be_Owned; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant OCL_Iterate_Exp_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Enter_Iterate_Exp (AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant OCL_Iterate_Exp_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Leave_Iterate_Exp (AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant OCL_Iterate_Exp_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.OCL_Iterators.OCL_Iterator'Class then AMF.Visitors.OCL_Iterators.OCL_Iterator'Class (Iterator).Visit_Iterate_Exp (Visitor, AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.OCL_Iterate_Exps;
1Crazymoney/LearnAda
Ada
421
adb
with Ada.Text_IO, Reversal, Cserel; use Ada.Text_IO; procedure Reversalas is type Tomb is array (Character range <>) of Float; procedure Csere is new Cserel(Float); procedure Revelsald is new Reversal(Float,Character,Tomb,Csere); T: Tomb := (3.0,6.2,1.7,5.2,3.9); begin Revelsald(T); for I in T'Range loop Put_Line( Float'Image( T(I) ) ); end loop; end Reversalas;
reznikmm/matreshka
Ada
4,957
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$ ------------------------------------------------------------------------------ -- User_Identifier is private type, thus Holders.Generic_Integers can't be -- instantiated with this type. This package provides equivalent -- implementation. ------------------------------------------------------------------------------ with League.Holders; private with League.Holders.Generic_Integers; package AWFC.Accounts.Users.User_Identifier_Holders is Value_Tag : constant League.Holders.Tag; function Element (Self : League.Holders.Holder) return AWFC.Accounts.Users.User_Identifier; -- Returns internal value. procedure Replace_Element (Self : in out League.Holders.Holder; To : AWFC.Accounts.Users.User_Identifier); -- Set value. Tag of the value must be set before this call. function To_Holder (Item : AWFC.Accounts.Users.User_Identifier) return League.Holders.Holder; -- Creates new Value from specified value. private package User_Identifier_Holders is new League.Holders.Generic_Integers (AWFC.Accounts.Users.User_Identifier); Value_Tag : constant League.Holders.Tag := User_Identifier_Holders.Value_Tag; function Element (Self : League.Holders.Holder) return AWFC.Accounts.Users.User_Identifier renames User_Identifier_Holders.Element; procedure Replace_Element (Self : in out League.Holders.Holder; To : AWFC.Accounts.Users.User_Identifier) renames User_Identifier_Holders.Replace_Element; function To_Holder (Item : AWFC.Accounts.Users.User_Identifier) return League.Holders.Holder renames User_Identifier_Holders.To_Holder; end AWFC.Accounts.Users.User_Identifier_Holders;
stcarrez/helios
Ada
3,929
adb
----------------------------------------------------------------------- -- helios-main -- Helios agent main procedure -- Copyright (C) 2017, 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.Text_IO; with Ada.Command_Line; with GNAT.Command_Line; with Util.Log.Loggers; with Util.Properties; with Util.Commands; with Util.Http.Clients.Curl; with Helios.Commands; procedure Helios.Main is use GNAT.Command_Line; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Helios.Main"); Log_Config : Util.Properties.Manager; Debug : Boolean := False; Verbose : Boolean := False; First : Natural := 0; All_Args : Util.Commands.Default_Argument_List (0); Ctx : Helios.Commands.Context_Type; begin Log_Config.Set ("log4j.rootCategory", "DEBUG,console"); Log_Config.Set ("log4j.appender.console", "Console"); Log_Config.Set ("log4j.appender.console.level", "ERROR"); Log_Config.Set ("log4j.appender.console.layout", "level-message"); Log_Config.Set ("log4j.appender.stdout", "Console"); Log_Config.Set ("log4j.appender.stdout.level", "INFO"); Log_Config.Set ("log4j.appender.stdout.layout", "message"); Log_Config.Set ("log4j.logger.Util", "FATAL"); Log_Config.Set ("log4j.logger.Util.Events", "ERROR"); Log_Config.Set ("log4j.logger.Helios", "ERROR"); Util.Log.Loggers.Initialize (Log_Config); Helios.Commands.Initialize; Util.Http.Clients.Curl.Register; Initialize_Option_Scan (Stop_At_First_Non_Switch => True, Section_Delimiters => "targs"); -- Parse the command line loop case Getopt ("* v d c:") is when ASCII.NUL => exit; when 'c' => Helios.Commands.Set_Configuration (Ctx, Parameter); First := First + 1; when 'd' => Debug := True; when 'v' => Verbose := True; when '*' => exit; when others => null; end case; First := First + 1; end loop; if Verbose or Debug then Log_Config.Set ("log4j.appender.console.level", "INFO"); Log_Config.Set ("log4j.logger.Util", "WARN"); Log_Config.Set ("log4j.logger.Helios", "DEBUG"); Log_Config.Set ("log4j.logger.Swagger", "DEBUG"); end if; if Debug then Log_Config.Set ("log4j.appender.console.level", "DEBUG"); end if; Util.Log.Loggers.Initialize (Log_Config); if First >= Ada.Command_Line.Argument_Count then Ada.Text_IO.Put_Line ("Missing command name to execute."); Helios.Commands.Usage (All_Args); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); return; end if; declare Cmd_Name : constant String := Full_Switch; Args : Util.Commands.Default_Argument_List (First + 1); begin Helios.Commands.Execute (Cmd_Name, Args, Ctx); end; exception when Helios.Commands.Error => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when Util.Commands.Not_Found => Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); when E : others => Log.Error ("Some internal error occurred", E); Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure); end Helios.Main;
reznikmm/matreshka
Ada
3,398
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package XSD_To_Ada is pragma Pure; end XSD_To_Ada;
io7m/coreland-cgbc-doc
Ada
158
ads
with CGBC.Bounded_Generic_Strings; package CGBC.Bounded_Strings is new Bounded_Generic_Strings (Character_Type => Character, String_Type => String);
MinimSecure/unum-sdk
Ada
1,387
adb
-- Copyright 2015-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 New_Integer is new Integer; type Integer_Access is access Integer; function F (I : Integer; A : Integer_Access) return Boolean is begin return True; end F; function F (I : New_Integer; A : Integer_Access) return Boolean is begin return False; end F; procedure P (I : Integer; A : Integer_Access) is begin null; end P; procedure P (I : New_Integer; A : Integer_Access) is begin null; end P; B1 : constant Boolean := F (Integer'(1), null); -- BREAK B2 : constant Boolean := F (New_Integer'(2), null); begin P (Integer'(3), null); P (New_Integer'(4), null); end Foo;
reznikmm/matreshka
Ada
3,704
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_Formula_Attributes is pragma Preelaborate; type ODF_Table_Formula_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Formula_Attribute_Access is access all ODF_Table_Formula_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Formula_Attributes;
reznikmm/matreshka
Ada
5,135
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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.Schema.Namespace_Items; package Matreshka.XML_Schema.AST.Namespaces is pragma Preelaborate; type Namespace_Node is new Abstract_Node and XML.Schema.Namespace_Items.XS_Namespace_Item with record Schema_Namespace : League.Strings.Universal_String; Owning_Model : Matreshka.XML_Schema.AST.Model_Access; end record; overriding procedure Enter_Node (Self : not null access Namespace_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Node (Self : not null access Namespace_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Node (Self : not null access Namespace_Node; Iterator : in out Matreshka.XML_Schema.Visitors.Abstract_Iterator'Class; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. overriding function Get_Schema_Namespace (Self : not null access Namespace_Node) return League.Strings.Universal_String; package Constructors is function Create (Owning_Model : not null Matreshka.XML_Schema.AST.Model_Access; Schema_Namespace : League.Strings.Universal_String) return not null Matreshka.XML_Schema.AST.Namespace_Access; end Constructors; end Matreshka.XML_Schema.AST.Namespaces;
reznikmm/matreshka
Ada
3,861
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.OCL.Ocl_Expressions; package AMF.OCL.Unspecified_Value_Exps is pragma Preelaborate; type OCL_Unspecified_Value_Exp is limited interface and AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression; type OCL_Unspecified_Value_Exp_Access is access all OCL_Unspecified_Value_Exp'Class; for OCL_Unspecified_Value_Exp_Access'Storage_Size use 0; end AMF.OCL.Unspecified_Value_Exps;
stcarrez/swagger-ada
Ada
2,216
ads
----------------------------------------------------------------------- -- openapi-server-applications -- REST application -- Copyright (C) 2017, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Properties; private with Security.OAuth.Servers; private with Servlet.Core.Rest; private with Servlet.Core.Files; private with Servlet.Security.OAuth; private with Servlet.Security.Filters.OAuth; private with Security.OAuth.File_Registry; package OpenAPI.Servers.Applications is type Application_Type is limited new OpenAPI.Servers.Application_Type with private; -- Configures the REST application so that it is ready to handler REST -- operations as well as give access to the OpenAPI UI that describes them. not overriding procedure Configure (App : in out Application_Type; Config : in Util.Properties.Manager'Class); private type Application_Type is limited new OpenAPI.Servers.Application_Type with record Api : aliased Servlet.Core.Rest.Rest_Servlet; OAuth : aliased Servlet.Security.OAuth.Token_Servlet; Filter : aliased Servlet.Security.Filters.OAuth.Auth_Filter; Files : aliased Servlet.Core.Files.File_Servlet; Ui_Files : aliased Servlet.Core.Files.File_Servlet; Auth : aliased Security.OAuth.Servers.Auth_Manager; Apps : aliased Security.OAuth.File_Registry.File_Application_Manager; Realm : aliased Security.OAuth.File_Registry.File_Realm_Manager; end record; end OpenAPI.Servers.Applications;
tum-ei-rcs/StratoX
Ada
981
ads
with Units; with Logger; package config.software is CSV_SEP : Character := ';'; DEBUG_MODE_IS_ACTIVE : constant Boolean := True; MAIN_TICK_RATE_MS : constant := 20; -- Tickrate in Milliseconds TEST_MODE_ACTIVE : constant Boolean := False; -- Mission CFG_ASCEND_TIMEOUT : constant Units.Time_Type := 1800.0 * Second; -- after this much time since mission start we unhitch. -- Droptest: 600, Strato: 1800 CFG_DESCEND_TIMEOUT : constant Units.Time_Type := 1800.0 * Second; -- after this much time since unhitch we assume landed -- Droptest: 360, Strato: 1800. Blockwalk: 360 POSITION_LEAST_ACCURACY : constant Units.Length_Type := 20.0 * Meter; -- the worst accepted GPS position accuracy for mission start CFG_LOGGER_LEVEL_UART : constant Logger.Log_Level := Logger.DEBUG; CFG_LOGGER_CALL_SKIP: constant := 10; -- prescaler...only every nth message is printed end Config.Software;
reznikmm/matreshka
Ada
4,035
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.Table_Refresh_Delay_Attributes; package Matreshka.ODF_Table.Refresh_Delay_Attributes is type Table_Refresh_Delay_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Refresh_Delay_Attributes.ODF_Table_Refresh_Delay_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Refresh_Delay_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Refresh_Delay_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Refresh_Delay_Attributes;
AdaCore/libadalang
Ada
142
adb
procedure Test (A : Foo; B : Bar) is C : Integer; begin for El : Foo_Elem of A loop B.RealBar (El); end loop; end Test;
tum-ei-rcs/StratoX
Ada
6,869
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . E X N _ L L F -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2015, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Note: the reason for treating exponents in the range 0 .. 4 specially is -- to ensure identical results to the static inline expansion in the case of -- a compile time known exponent in this range. The use of Float'Machine and -- Long_Float'Machine is to avoid unwanted extra precision in the results. package body System.Exn_LLF is function Exp (Left : Long_Long_Float; Right : Integer) return Long_Long_Float; -- Common routine used if Right not in 0 .. 4 --------------- -- Exn_Float -- --------------- function Exn_Float (Left : Float; Right : Integer) return Float is Temp : Float; begin case Right is when 0 => return 1.0; when 1 => return Left; when 2 => return Float'Machine (Left * Left); when 3 => return Float'Machine (Left * Left * Left); when 4 => Temp := Float'Machine (Left * Left); return Float'Machine (Temp * Temp); when others => return Float'Machine (Float (Exp (Long_Long_Float (Left), Right))); end case; end Exn_Float; -------------------- -- Exn_Long_Float -- -------------------- function Exn_Long_Float (Left : Long_Float; Right : Integer) return Long_Float is Temp : Long_Float; begin case Right is when 0 => return 1.0; when 1 => return Left; when 2 => return Long_Float'Machine (Left * Left); when 3 => return Long_Float'Machine (Left * Left * Left); when 4 => Temp := Long_Float'Machine (Left * Left); return Long_Float'Machine (Temp * Temp); when others => return Long_Float'Machine (Long_Float (Exp (Long_Long_Float (Left), Right))); end case; end Exn_Long_Float; ------------------------- -- Exn_Long_Long_Float -- ------------------------- function Exn_Long_Long_Float (Left : Long_Long_Float; Right : Integer) return Long_Long_Float is Temp : Long_Long_Float; begin case Right is when 0 => return 1.0; when 1 => return Left; when 2 => return Left * Left; when 3 => return Left * Left * Left; when 4 => Temp := Left * Left; return Temp * Temp; when others => return Exp (Left, Right); end case; end Exn_Long_Long_Float; --------- -- Exp -- --------- function Exp (Left : Long_Long_Float; Right : Integer) return Long_Long_Float is Result : Long_Long_Float := 1.0; Factor : Long_Long_Float := Left; Exp : Integer := Right; begin -- We use the standard logarithmic approach, Exp gets shifted right -- testing successive low order bits and Factor is the value of the -- base raised to the next power of 2. If the low order bit or Exp is -- set, multiply the result by this factor. For negative exponents, -- invert result upon return. if Exp >= 0 then loop if Exp rem 2 /= 0 then Result := Result * Factor; end if; Exp := Exp / 2; exit when Exp = 0; Factor := Factor * Factor; end loop; return Result; -- Here we have a negative exponent, and we compute the result as: -- 1.0 / (Left ** (-Right)) -- Note that the case of Left being zero is not special, it will -- simply result in a division by zero at the end, yielding a -- correctly signed infinity, or possibly generating an overflow. -- Note on overflow: The coding of this routine assumes that the -- target generates infinities with standard IEEE semantics. If this -- is not the case, then the code below may raise Constraint_Error. -- This follows the implementation permission given in RM 4.5.6(12). else begin loop if Exp rem 2 /= 0 then Result := Result * Factor; end if; Exp := Exp / 2; exit when Exp = 0; Factor := Factor * Factor; end loop; return 1.0 / Result; end; end if; end Exp; end System.Exn_LLF;
optikos/oasis
Ada
716
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Compilation_Units; with Program.Visibility; private procedure Program.Resolve_Standard (Unit : not null Program.Compilation_Units.Compilation_Unit_Access; Env : aliased in out Program.Visibility.Context); -- Resolve names in predefined Standard package. -- This is simplified version of resolver that creates and polulates -- name table for Standard package. It uses some implementation defined -- tricks, because Standard package can't be expressed in Ada. pragma Preelaborate (Program.Resolve_Standard);
AdaCore/gpr
Ada
81,348
ads
-- -- Copyright (C) 2019-2023, AdaCore -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with Ada.Containers; private with Ada.Containers.Vectors; private with Ada.Finalization; with Ada.Strings.Unbounded; with GNATCOLL.Refcount; with Gpr_Parser_Support.File_Readers; use Gpr_Parser_Support.File_Readers; with Gpr_Parser_Support.Lexical_Envs; use Gpr_Parser_Support.Lexical_Envs; with Gpr_Parser_Support.Symbols; use Gpr_Parser_Support.Symbols; with Gpr_Parser_Support.Token_Data_Handlers; use Gpr_Parser_Support.Token_Data_Handlers; with Gpr_Parser.Common; use Gpr_Parser.Common; private with Gpr_Parser.Implementation; private with Gpr_Parser.Debug; -- This package provides types and primitives to analyze source files as -- analysis units. -- -- This is the entry point to parse and process a unit: -- -- * First create an analysis context with -- :ada:ref:`Gpr_Parser.Analysis.Create_Context`. -- -- * Then get analysis units out of it using the ``Get_From_*`` functions. The -- most used of them is :ada:ref:`Gpr_Parser.Analysis.Get_From_File`, -- which allows you to get an analysis unit out of a file path. -- -- .. code-block:: ada -- -- with Libadalang.Analysis; -- -- procedure Main is -- package Lib renames Gpr_Parser.Analysis; -- -- Context : constant Lib.Analysis_Context := Lib.Create_Context; -- Unit : constant Lib.Analysis_Unit := -- Context.Get_From_File ("/path/to/source/file"); -- begin -- Unit.Print; -- end Main; package Gpr_Parser.Analysis is use Support.Diagnostics, Support.Slocs, Support.Text; type Analysis_Context is tagged private; -- This type represents a context for all source analysis. This is the -- first type you need to create to use Gpr_Parser. It will contain the -- results of all analysis, and is the main holder for all the data. -- -- You can create several analysis contexts if you need to, which enables -- you, for example to: -- -- * analyze several different projects at the same time; -- -- * analyze different parts of the same projects in parallel. -- -- In the current design, contexts always keep all of their analysis units -- allocated. If you need to get this memory released, the only option at -- your disposal is to destroy your analysis context instance. type Analysis_Unit is new Gpr_Parser_Support.Text.Text_Buffer_Ifc with private; -- This type represents the analysis of a single file. -- -- This type has strong-reference semantics and is ref-counted. -- Furthermore, a reference to a unit contains an implicit reference to the -- context that owns it. This means that keeping a reference to a unit will -- keep the context and all the unit it contains allocated. No_Analysis_Context : constant Analysis_Context; -- Special value to mean the absence of analysis context No_Analysis_Unit : constant Analysis_Unit; -- Special value to mean the absence of analysis unit. No analysis units -- can be passed this value. --------------- -- AST nodes -- --------------- type Gpr_Node is tagged private; -- Data type for all nodes. Nodes are assembled to make up a tree. See -- the node primitives below to inspect such trees. -- -- Unlike for contexts and units, this type has weak-reference -- semantics: keeping a reference to a node has no effect on the -- decision to keep the unit that it owns allocated. This means that -- once all references to the context and units related to a node are -- dropped, the context and its units are deallocated and the node -- becomes a stale reference: most operations on it will raise a -- ``Stale_Reference_Error``. -- -- Note that since reparsing an analysis unit deallocates all the nodes -- it contains, this operation makes all reference to these nodes stale -- as well. -- function Equals (L, R : Gpr_Node) return Boolean; -- Comparison function, meant to compare two nodes. -- -- .. note: For complex reasons, we cannot expose this function as the -- ``"="`` operator. This is the function you need to use as the -- equality function for containers instantiations. type All_Qualifier is new Gpr_Node with private ; type All_Qualifier_Absent is new All_Qualifier with private ; type All_Qualifier_Present is new All_Qualifier with private ; type Attribute_Decl is new Gpr_Node with private ; type Attribute_Reference is new Gpr_Node with private ; type Base_List is new Gpr_Node with private ; type Builtin_Function_Call is new Gpr_Node with private ; type Case_Construction is new Gpr_Node with private ; type Case_Item is new Gpr_Node with private ; type Case_Item_List is new Base_List with private with Iterable => (First => Case_Item_List_First, Next => Case_Item_List_Next, Has_Element => Case_Item_List_Has_Element, Element => Case_Item_List_Element) ; -- List of CaseItem. type Gpr_Node_List is new Base_List with private with Iterable => (First => Gpr_Node_List_First, Next => Gpr_Node_List_Next, Has_Element => Gpr_Node_List_Has_Element, Element => Gpr_Node_List_Element) ; -- List of GprNode. -- -- This list node can contain one of the following nodes: -- :ada:ref:`Attribute_Decl`, :ada:ref:`Builtin_Function_Call`, -- :ada:ref:`Case_Construction`, :ada:ref:`Empty_Decl`, -- :ada:ref:`Others_Designator`, :ada:ref:`Package_Decl`, -- :ada:ref:`String_Literal_At`, :ada:ref:`String_Literal`, -- :ada:ref:`Terms`, :ada:ref:`Typed_String_Decl`, -- :ada:ref:`Variable_Decl`, :ada:ref:`Variable_Reference` type Choices is new Gpr_Node_List with private ; -- This list node can contain one of the following nodes: -- :ada:ref:`Others_Designator`, :ada:ref:`String_Literal` type Compilation_Unit is new Gpr_Node with private ; type Empty_Decl is new Gpr_Node with private ; type Expr is new Gpr_Node with private ; type Single_Tok_Node is new Expr with private ; type Identifier is new Single_Tok_Node with private ; type Identifier_List is new Base_List with private with Iterable => (First => Identifier_List_First, Next => Identifier_List_Next, Has_Element => Identifier_List_Has_Element, Element => Identifier_List_Element) ; -- List of Identifier. type Limited_Node is new Gpr_Node with private ; type Limited_Absent is new Limited_Node with private ; type Limited_Present is new Limited_Node with private ; type Num_Literal is new Single_Tok_Node with private ; type Others_Designator is new Gpr_Node with private ; type Package_Decl is new Gpr_Node with private ; type Package_Extension is new Gpr_Node with private ; type Package_Renaming is new Gpr_Node with private ; type Package_Spec is new Gpr_Node with private ; type Prefix is new Expr with private ; type Project is new Gpr_Node with private ; type Project_Declaration is new Gpr_Node with private ; type Project_Extension is new Gpr_Node with private ; type Project_Qualifier is new Gpr_Node with private ; type Project_Qualifier_Abstract is new Project_Qualifier with private ; type Project_Qualifier_Aggregate is new Project_Qualifier with private ; type Project_Qualifier_Aggregate_Library is new Project_Qualifier with private ; type Project_Qualifier_Configuration is new Project_Qualifier with private ; type Project_Qualifier_Library is new Project_Qualifier with private ; type Project_Qualifier_Standard is new Project_Qualifier with private ; type String_Literal is new Single_Tok_Node with private ; type String_Literal_At is new Gpr_Node with private ; type String_Literal_List is new Base_List with private with Iterable => (First => String_Literal_List_First, Next => String_Literal_List_Next, Has_Element => String_Literal_List_Has_Element, Element => String_Literal_List_Element) ; -- List of StringLiteral. type Term_List is new Gpr_Node_List with private ; -- This list node can contain one of the following nodes: -- :ada:ref:`Builtin_Function_Call`, :ada:ref:`String_Literal_At`, -- :ada:ref:`Terms`, :ada:ref:`Variable_Reference` type Term_List_List is new Base_List with private with Iterable => (First => Term_List_List_First, Next => Term_List_List_Next, Has_Element => Term_List_List_Has_Element, Element => Term_List_List_Element) ; -- List of TermList. type Terms is new Gpr_Node with private ; type Type_Reference is new Gpr_Node with private ; type Typed_String_Decl is new Gpr_Node with private ; type Variable_Decl is new Gpr_Node with private ; type Variable_Reference is new Gpr_Node with private ; type With_Decl is new Gpr_Node with private ; type With_Decl_List is new Base_List with private with Iterable => (First => With_Decl_List_First, Next => With_Decl_List_Next, Has_Element => With_Decl_List_Has_Element, Element => With_Decl_List_Element) ; -- List of WithDecl. No_Gpr_Node : constant Gpr_Node; -- Special value to represent the absence of a node. Note that every -- node type derived from the root type has a similar ``No_Node`` -- constant. No_All_Qualifier : constant All_Qualifier; --% no-document: True No_All_Qualifier_Absent : constant All_Qualifier_Absent; --% no-document: True No_All_Qualifier_Present : constant All_Qualifier_Present; --% no-document: True No_Attribute_Decl : constant Attribute_Decl; --% no-document: True No_Attribute_Reference : constant Attribute_Reference; --% no-document: True No_Base_List : constant Base_List; --% no-document: True No_Builtin_Function_Call : constant Builtin_Function_Call; --% no-document: True No_Case_Construction : constant Case_Construction; --% no-document: True No_Case_Item : constant Case_Item; --% no-document: True No_Case_Item_List : constant Case_Item_List; --% no-document: True No_Gpr_Node_List : constant Gpr_Node_List; --% no-document: True No_Choices : constant Choices; --% no-document: True No_Compilation_Unit : constant Compilation_Unit; --% no-document: True No_Empty_Decl : constant Empty_Decl; --% no-document: True No_Expr : constant Expr; --% no-document: True No_Single_Tok_Node : constant Single_Tok_Node; --% no-document: True No_Identifier : constant Identifier; --% no-document: True No_Identifier_List : constant Identifier_List; --% no-document: True No_Limited_Node : constant Limited_Node; --% no-document: True No_Limited_Absent : constant Limited_Absent; --% no-document: True No_Limited_Present : constant Limited_Present; --% no-document: True No_Num_Literal : constant Num_Literal; --% no-document: True No_Others_Designator : constant Others_Designator; --% no-document: True No_Package_Decl : constant Package_Decl; --% no-document: True No_Package_Extension : constant Package_Extension; --% no-document: True No_Package_Renaming : constant Package_Renaming; --% no-document: True No_Package_Spec : constant Package_Spec; --% no-document: True No_Prefix : constant Prefix; --% no-document: True No_Project : constant Project; --% no-document: True No_Project_Declaration : constant Project_Declaration; --% no-document: True No_Project_Extension : constant Project_Extension; --% no-document: True No_Project_Qualifier : constant Project_Qualifier; --% no-document: True No_Project_Qualifier_Abstract : constant Project_Qualifier_Abstract; --% no-document: True No_Project_Qualifier_Aggregate : constant Project_Qualifier_Aggregate; --% no-document: True No_Project_Qualifier_Aggregate_Library : constant Project_Qualifier_Aggregate_Library; --% no-document: True No_Project_Qualifier_Configuration : constant Project_Qualifier_Configuration; --% no-document: True No_Project_Qualifier_Library : constant Project_Qualifier_Library; --% no-document: True No_Project_Qualifier_Standard : constant Project_Qualifier_Standard; --% no-document: True No_String_Literal : constant String_Literal; --% no-document: True No_String_Literal_At : constant String_Literal_At; --% no-document: True No_String_Literal_List : constant String_Literal_List; --% no-document: True No_Term_List : constant Term_List; --% no-document: True No_Term_List_List : constant Term_List_List; --% no-document: True No_Terms : constant Terms; --% no-document: True No_Type_Reference : constant Type_Reference; --% no-document: True No_Typed_String_Decl : constant Typed_String_Decl; --% no-document: True No_Variable_Decl : constant Variable_Decl; --% no-document: True No_Variable_Reference : constant Variable_Reference; --% no-document: True No_With_Decl : constant With_Decl; --% no-document: True No_With_Decl_List : constant With_Decl_List; --% no-document: True function Is_Null (Node : Gpr_Node'Class) return Boolean; -- Return whether this node is a null node reference. function Is_Token_Node (Node : Gpr_Node'Class) return Boolean; -- Return whether this node is a node that contains only a single token. function Is_Synthetic (Node : Gpr_Node'Class) return Boolean; -- Return whether this node is synthetic. function "=" (L, R : Gpr_Node'Class) return Boolean; -- Return whether ``L`` and ``R`` designate the same node function Image (Node : Gpr_Node'Class) return String; -- Return a short string describing ``Node``, or None" if ``Node.Is_Null`` -- is true. ------------------- -- Event handler -- ------------------- type Event_Handler_Interface is interface; -- Interface to handle events sent by the analysis context. procedure Unit_Requested_Callback (Self : in out Event_Handler_Interface; Context : Analysis_Context'Class; Name : Text_Type; From : Analysis_Unit'Class; Found : Boolean; Is_Not_Found_Error : Boolean) is null; -- Callback that will be called when a unit is requested from the context -- ``Context``. -- -- ``Name`` is the name of the requested unit. -- -- ``From`` is the unit from which the unit was requested. -- -- ``Found`` indicates whether the requested unit was found or not. -- -- ``Is_Not_Found_Error`` indicates whether the fact that the unit was not -- found is an error or not. -- -- .. warning:: The interface of this callback is probably subject to -- change, so should be treated as experimental. procedure Unit_Parsed_Callback (Self : in out Event_Handler_Interface; Context : Analysis_Context'Class; Unit : Analysis_Unit'Class; Reparsed : Boolean) is null; -- Callback that will be called when any unit is parsed from the context -- ``Context``. -- -- ``Unit`` is the resulting unit. -- -- ``Reparsed`` indicates whether the unit was reparsed, or whether it was -- the first parse. procedure Release (Self : in out Event_Handler_Interface) is abstract; -- Actions to perform when releasing resources associated to Self procedure Do_Release (Self : in out Event_Handler_Interface'Class); -- Helper for the instantiation below package Event_Handler_References is new GNATCOLL.Refcount.Shared_Pointers (Event_Handler_Interface'Class, Do_Release); subtype Event_Handler_Reference is Event_Handler_References.Ref; No_Event_Handler_Ref : Event_Handler_Reference renames Event_Handler_References.Null_Ref; function Create_Event_Handler_Reference (Handler : Event_Handler_Interface'Class) return Event_Handler_Reference; -- Simple wrapper around the GNATCOLL.Refcount API to create event handler -- references. -------------------- -- Unit providers -- -------------------- type Unit_Provider_Interface is interface; -- Interface to fetch analysis units from a name and a unit kind. -- -- The unit provider mechanism provides an abstraction which assumes that -- to any couple (unit name, unit kind) we can associate at most one source -- file. This means that several couples can be associated to the same -- source file, but on the other hand, only one one source file can be -- associated to a couple. -- -- This is used to make the semantic analysis able to switch from one -- analysis units to another. -- -- See the documentation of each unit provider for the exact semantics of -- the unit name/kind information. function Get_Unit_Filename (Provider : Unit_Provider_Interface; Name : Text_Type; Kind : Analysis_Unit_Kind) return String is abstract; -- Return the filename corresponding to the given unit name/unit kind. -- Raise a ``Property_Error`` if the given unit name is not valid. procedure Get_Unit_Location (Provider : Unit_Provider_Interface; Name : Text_Type; Kind : Analysis_Unit_Kind; Filename : in out Ada.Strings.Unbounded.Unbounded_String; PLE_Root_Index : in out Natural) is null; -- Like ``Get_Unit_Filename``, but return both the source file that -- ``Name``/``Kind`` designate (in ``Filename``) and the index of the PLE -- root inside that unit (in ``PLE_Root_Index``). If ``PLE_Root_Index`` is -- left to 0 upon return, discard the result and switch to the PLE root -- unaware ``Get_Unit_Filename`` function. function Get_Unit (Provider : Unit_Provider_Interface; Context : Analysis_Context'Class; Name : Text_Type; Kind : Analysis_Unit_Kind; Charset : String := ""; Reparse : Boolean := False) return Analysis_Unit'Class is abstract; -- Fetch and return the analysis unit referenced by the given unit name. -- Raise a ``Property_Error`` if the given unit name is not valid. procedure Get_Unit_And_PLE_Root (Provider : Unit_Provider_Interface; Context : Analysis_Context'Class; Name : Text_Type; Kind : Analysis_Unit_Kind; Charset : String := ""; Reparse : Boolean := False; Unit : in out Analysis_Unit'Class; PLE_Root_Index : in out Natural) is null; -- Like ``Get_Unit``, but return both the analysis unit that -- ``Name``/``Kind`` designate (in ``Unit``) and the index of the PLE root -- inside that unit (in ``PLE_Root_Index``). If ``PLE_Root_Index`` is left -- to 0 upon return, discard the result and switch to the PLE root unaware -- ``Get_Unit`` function. procedure Release (Provider : in out Unit_Provider_Interface) is abstract; -- Actions to perform when releasing resources associated to Provider procedure Do_Release (Provider : in out Unit_Provider_Interface'Class); -- Helper for the instantiation below package Unit_Provider_References is new GNATCOLL.Refcount.Shared_Pointers (Unit_Provider_Interface'Class, Do_Release); subtype Unit_Provider_Reference is Unit_Provider_References.Ref; No_Unit_Provider_Reference : Unit_Provider_Reference renames Unit_Provider_References.Null_Ref; function Create_Unit_Provider_Reference (Provider : Unit_Provider_Interface'Class) return Unit_Provider_Reference; -- Simple wrapper around the GNATCOLL.Refcount API to create unit provider -- references. --------------------------------- -- Analysis context primitives -- --------------------------------- function Create_Context (Charset : String := Default_Charset; File_Reader : File_Reader_Reference := No_File_Reader_Reference; Unit_Provider : Unit_Provider_Reference := No_Unit_Provider_Reference; Event_Handler : Event_Handler_Reference := No_Event_Handler_Ref; With_Trivia : Boolean := True; Tab_Stop : Positive := 8) return Analysis_Context; -- Create a new analysis context. -- -- ``Charset`` will be used as a default charset to decode input sources in -- analysis units. Please see ``GNATCOLL.Iconv`` for several supported -- charsets. Be careful: passing an unsupported charset is not guaranteed -- to raise an error here. If no charset is provided, ``"iso-8859-1"`` is -- the default. -- -- .. TODO: Passing an unsupported charset here is not guaranteed to raise -- an error right here, but this would be really helpful for users. -- -- When ``With_Trivia`` is true, the parsed analysis units will contain -- trivias. -- -- If provided, ``File_Reader`` will be used to fetch the contents of -- source files instead of the default, which is to just read it from the -- filesystem and decode it using the regular charset rules. Note that if -- provided, all parsing APIs that provide a buffer are forbidden, and any -- use of the rewriting API with the returned context is rejected. -- -- If provided, ``Unit_Provider`` will be used to query the file name that -- corresponds to a unit reference during semantic analysis. If it is -- ``null``, the default one is used instead. -- -- If provided, ``Event_Handler`` will be notified when various events -- happen. -- -- ``Tab_Stop`` is a positive number to describe the effect of tabulation -- characters on the column number in source files. --% belongs-to: Analysis_Context function Has_Unit (Context : Analysis_Context'Class; Unit_Filename : String) return Boolean; -- Return whether ``Context`` contains a unit correponding to -- ``Unit_Filename``. function Get_From_File (Context : Analysis_Context'Class; Filename : String; Charset : String := ""; Reparse : Boolean := False; Rule : Grammar_Rule := Default_Grammar_Rule) return Analysis_Unit; -- Create a new analysis unit for ``Filename`` or return the existing one -- if any. If ``Reparse`` is true and the analysis unit already exists, -- reparse it from ``Filename``. -- -- ``Rule`` controls which grammar rule is used to parse the unit. -- -- Use ``Charset`` in order to decode the source. If ``Charset`` is empty -- then use the context's default charset. -- -- If any failure occurs, such as file opening, decoding, lexing or parsing -- failure, return an analysis unit anyway: errors are described as -- diagnostics of the returned analysis unit. -- -- It is invalid to pass ``True`` to ``Reparse`` if a rewriting context is -- active. function Get_From_Buffer (Context : Analysis_Context'Class; Filename : String; Charset : String := ""; Buffer : String; Rule : Grammar_Rule := Default_Grammar_Rule) return Analysis_Unit; -- Create a new analysis unit for ``Filename`` or return the existing one -- if any. Whether the analysis unit already exists or not, (re)parse it -- from the source code in ``Buffer``. -- -- ``Rule`` controls which grammar rule is used to parse the unit. -- -- Use ``Charset`` in order to decode the source. If ``Charset`` is empty -- then use the context's default charset. -- -- If any failure occurs, such as file opening, decoding, lexing or parsing -- failure, return an analysis unit anyway: errors are described as -- diagnostics of the returned analysis unit. -- -- Calling this is invalid if a rewriting context is active. function Get_From_Buffer (Context : Analysis_Context'Class; Filename : String; Charset : String := ""; Buffer : Ada.Strings.Unbounded.Unbounded_String; Rule : Grammar_Rule := Default_Grammar_Rule) return Analysis_Unit; -- Likewise, but working on an unbounded string function Get_With_Error (Context : Analysis_Context'Class; Filename : String; Error : Text_Type; Charset : String := ""; Rule : Grammar_Rule := Default_Grammar_Rule) return Analysis_Unit; -- If a Unit for ``Filename`` already exists, return it unchanged. -- Otherwise, create an empty analysis unit for ``Filename`` with a -- diagnostic that contains the ``Error`` message. function Unit_Provider (Context : Analysis_Context'Class) return Unit_Provider_Reference; -- Return the unit provider for ``Context`` -- --% belongs-to: Analysis_Context function Hash (Context : Analysis_Context) return Ada.Containers.Hash_Type; -- Return a hash for this context, to be used in hash tables. function Has_With_Trivia (Context : Analysis_Context'Class) return Boolean; -- Return whether ``Context`` keeps trivia when parsing units procedure Discard_Errors_In_Populate_Lexical_Env (Context : Analysis_Context'Class; Discard : Boolean); -- Debug helper. Set whether ``Property_Error`` exceptions raised in -- ``Populate_Lexical_Env`` should be discarded. They are by default. procedure Set_Logic_Resolution_Timeout (Context : Analysis_Context'Class; Timeout : Natural); -- If ``Timeout`` is greater than zero, set a timeout for the resolution of -- logic equations. The unit is the number of steps in ANY/ALL relations. -- If ``Timeout`` is zero, disable the timeout. By default, the timeout is -- ``100 000`` steps. procedure Set_Lookup_Cache_Mode (Mode : Lookup_Cache_Kind); -- Set the lexical environments lookup cache mode according to ``Mode``. -- Note: Mainly meant for debugging the default mode. function Has_Rewriting_Handle (Context : Analysis_Context'Class) return Boolean; -- Return whether ``Context`` has a rewriting handler (see -- ``Gpr_Parser.Rewriting``), i.e. whether it is in the process of -- rewriting. If true, this means that the set of currently loaded analysis -- units is frozen until the rewriting process is done. function Get_Symbol_Table (Context : Analysis_Context'Class) return Symbol_Table; -- Return the symbol table attached to this context. Useful for users -- needing their own symbolization and wanting to share it with their -- language frontend. -- -- WARNING: EXPERIMENTAL & UNSAFE - The Symbol_Table exposes an unsafe API, -- that might be subject to some changes, use with caution. ------------------------------ -- Analysis unit primitives -- ------------------------------ function Context (Unit : Analysis_Unit'Class) return Analysis_Context; -- Return the context that owns this unit. function Hash (Unit : Analysis_Unit) return Ada.Containers.Hash_Type; -- Return a hash for this unit, to be used in hash tables. procedure Reparse (Unit : Analysis_Unit'Class; Charset : String := ""); -- Reparse an analysis unit from the associated file. -- -- Use ``Charset`` in order to decode the source. If ``Charset`` is empty -- then use the context's default charset. -- -- If any failure occurs, such as decoding, lexing or parsing failure, -- diagnostic are emitted to explain what happened. procedure Reparse (Unit : Analysis_Unit'Class; Charset : String := ""; Buffer : String); -- Reparse an analysis unit from a buffer. -- -- Use ``Charset`` in order to decode the source. If ``Charset`` is empty -- then use the context's default charset. -- -- If any failure occurs, such as decoding, lexing or parsing failure, -- diagnostic are emitted to explain what happened. procedure Populate_Lexical_Env (Unit : Analysis_Unit'Class ); -- Create lexical environments for this analysis unit, according to the -- specifications given in the language spec. -- -- If not done before, it will be automatically called during semantic -- analysis. Calling it before enables one to control where the latency -- occurs. -- -- Depending on whether errors are discarded (see -- ``Discard_Errors_In_Populate_Lexical_Env``), raise a ``Property_Error`` -- on failure. function Get_Filename (Unit : Analysis_Unit'Class) return String; -- Return the filename this unit is associated to. function Get_Charset (Unit : Analysis_Unit'Class) return String; -- Return the charset that was used to parse Unit function Has_Diagnostics (Unit : Analysis_Unit'Class) return Boolean; -- Return whether this unit has associated diagnostics. function Diagnostics (Unit : Analysis_Unit'Class) return Diagnostics_Array; -- Return an array that contains the diagnostics associated to this unit. function Format_GNU_Diagnostic (Unit : Analysis_Unit'Class; D : Diagnostic) return String; -- Format a diagnostic in a GNU fashion. See -- <https://www.gnu.org/prep/standards/html_node/Errors.html>. pragma Warnings (Off, "defined after private extension"); function Root (Unit : Analysis_Unit'Class) return Gpr_Node; -- Return the root node for this unit, or ``null`` if there is none. pragma Warnings (On, "defined after private extension"); function First_Token (Unit : Analysis_Unit'Class) return Token_Reference; -- Return a reference to the first token scanned in this unit. function Last_Token (Unit : Analysis_Unit'Class) return Token_Reference; -- Return a reference to the last token scanned in this unit. function Token_Count (Unit : Analysis_Unit'Class) return Natural; -- Return the number of tokens in this unit. function Trivia_Count (Unit : Analysis_Unit'Class) return Natural; -- Return the number of trivias in this unit. This is 0 for units that were -- parsed with trivia analysis disabled. function Unit (Token : Token_Reference) return Analysis_Unit; -- Return the analysis unit that owns ``Token`` function Text (Unit : Analysis_Unit'Class) return Text_Type; -- Return the source buffer associated to this unit. function Lookup_Token (Unit : Analysis_Unit'Class; Sloc : Source_Location) return Token_Reference; -- Look for a token in this unit that contains the given source location. -- If this falls before the first token, return the first token. If this -- falls between two tokens, return the token that appears before. If this -- falls after the last token, return the last token. If there is no token -- in this unit, return no token. procedure Dump_Lexical_Env (Unit : Analysis_Unit'Class); -- Debug helper: output the lexical envs for the given analysis unit. procedure Trigger_Envs_Debug (Is_Active : Boolean); -- Debug helper: activate debug traces for lexical envs lookups procedure Print (Unit : Analysis_Unit'Class; Show_Slocs : Boolean := True); -- Debug helper: output the AST and eventual diagnostic for this unit on -- standard output. -- -- If Show_Slocs, include AST nodes' source locations in the output. procedure PP_Trivia (Unit : Analysis_Unit'Class); -- Debug helper: output a minimal AST with mixed trivias overriding function Get_Line (Unit : Analysis_Unit; Line_Number : Positive) return Text_Type; -- Return the line of text at line number ``Line_Number`` type Child_Record (Kind : Child_Or_Trivia := Child) is record case Kind is when Child => Node : Gpr_Node; when Trivia => Trivia : Token_Reference; end case; end record; -- Variant that holds either an AST node or a token type Children_Array is private with Iterable => (First => First, Next => Next, Has_Element => Has_Element, Element => Element, Last => Last, Previous => Previous); -- This iterable type holds an array of ``Child`` or ``Trivia`` nodes function First (Self : Children_Array) return Natural; -- Return the first child or trivia cursor corresponding to the children -- array. Helper for the ``Iterable`` aspect. function Last (Self : Children_Array) return Natural; -- Return the last child or trivia cursor corresponding to the children -- array. Helper for the ``Iterable`` aspect. function Next (Self : Children_Array; Pos : Natural) return Natural; -- Return the child or trivia cursor that follows ``Self`` in the children -- array. Helper for the ``Iterable`` aspect. function Previous (Self : Children_Array; Pos : Natural) return Natural; -- Return the child or trivia cursor that follows ``Self`` in the children -- array. Helper for the ``Iterable`` aspect. function Has_Element (Self : Children_Array; Pos : Natural) return Boolean; -- Return if ``Pos`` is in ``Self``'s iteration range. Helper for the -- ``Iterable`` aspect. function Element (Self : Children_Array; Pos : Natural) return Child_Record; -- Return the child of trivia node at position ``Pos`` in ``Self``. Helper -- for the ``Iterable`` aspect. function Children_And_Trivia (Node : Gpr_Node'Class) return Children_Array; -- Return the children of this node interleaved with Trivia token nodes, so -- that: -- -- - Every trivia contained between ``Node.Start_Token`` and -- ``Node.End_Token - 1`` will be part of the returned array. -- -- - Nodes and trivias will be lexically ordered. --------------------- -- Composite types -- --------------------- type Gpr_Node_Array is array (Positive range <>) of Gpr_Node; -------------------- -- Token Iterator -- -------------------- type Token_Iterator is private with Iterable => (First => First_Token, Next => Next_Token, Has_Element => Has_Element, Element => Element); -- Allow iteration on a range of tokens corresponding to a node function First_Token (Self : Token_Iterator) return Token_Reference; -- Return the first token corresponding to the node function Next_Token (Self : Token_Iterator; Tok : Token_Reference) return Token_Reference; -- Return the token that follows Tok in the token stream function Has_Element (Self : Token_Iterator; Tok : Token_Reference) return Boolean; -- Return if Tok is in Self's iteration range function Element (Self : Token_Iterator; Tok : Token_Reference) return Token_Reference; -- Identity function: helper for the Iterable aspect ------------------------- -- AST Node primitives -- ------------------------- function Kind (Node : Gpr_Node'Class) return Gpr_Node_Kind_Type; function Kind_Name (Node : Gpr_Node'Class) return String; -- Return the concrete kind for Node pragma Warnings (Off, "defined after private extension"); function Parent (Node : Gpr_Node'Class) return Gpr_Node; -- Return the syntactic parent for this node. Return null for the root -- node. --% belongs-to: Gpr_Node function Parents (Node : Gpr_Node'Class; With_Self : Boolean := True) return Gpr_Node_Array; -- Return an array that contains the lexical parents, this node included -- iff ``with_self`` is True. Nearer parents are first in the list. --% belongs-to: Gpr_Node function Children (Node : Gpr_Node'Class) return Gpr_Node_Array; -- Return an array that contains the direct lexical children. -- -- .. warning:: This constructs a whole array every-time you call it, and -- as such is less efficient than calling the ``Child`` built-in. --% belongs-to: Gpr_Node function Token_Start (Node : Gpr_Node'Class) return Token_Reference; -- Return the first token used to parse this node. --% belongs-to: Gpr_Node function Token_End (Node : Gpr_Node'Class) return Token_Reference; -- Return the last token used to parse this node. --% belongs-to: Gpr_Node function Child_Index (Node : Gpr_Node'Class) return Integer; -- Return the 0-based index for Node in its parent's children. --% belongs-to: Gpr_Node function Previous_Sibling (Node : Gpr_Node'Class) return Gpr_Node; -- Return the node's previous sibling, or null if there is no such sibling. --% belongs-to: Gpr_Node function Next_Sibling (Node : Gpr_Node'Class) return Gpr_Node; -- Return the node's next sibling, or null if there is no such sibling. --% belongs-to: Gpr_Node function Unit (Node : Gpr_Node'Class) return Analysis_Unit; -- Return the analysis unit owning this node. --% belongs-to: Gpr_Node function Is_Ghost (Node : Gpr_Node'Class) return Boolean; -- Return whether the node is a ghost. -- -- Unlike regular nodes, ghost nodes cover no token in the input source: -- they are logically located instead between two tokens. Both the -- ``token_start`` and the ``token_end`` of all ghost nodes is the token -- right after this logical position. --% belongs-to: Gpr_Node function Full_Sloc_Image (Node : Gpr_Node'Class) return Text_Type; -- Return a string containing the filename + the sloc in GNU conformant -- format. Useful to create diagnostics from a node. --% belongs-to: Gpr_Node function P_As_Bool (Node : All_Qualifier'Class) return Boolean; -- Return whether this is an instance of AllQualifierPresent --% belongs-to: All_Qualifier function F_Attr_Name (Node : Attribute_Decl'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Attribute_Decl function F_Attr_Index (Node : Attribute_Decl'Class) return Gpr_Node; -- This field can contain one of the following nodes: -- :ada:ref:`Others_Designator`, :ada:ref:`String_Literal_At` --% belongs-to: Attribute_Decl function F_Expr (Node : Attribute_Decl'Class) return Term_List; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Builtin_Function_Call`, :ada:ref:`String_Literal_At`, -- :ada:ref:`Terms`, :ada:ref:`Variable_Reference` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Attribute_Decl function F_Attribute_Name (Node : Attribute_Reference'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Attribute_Reference function F_Attribute_Index (Node : Attribute_Reference'Class) return Gpr_Node; -- This field can contain one of the following nodes: -- :ada:ref:`Others_Designator`, :ada:ref:`String_Literal` --% belongs-to: Attribute_Reference function F_Function_Name (Node : Builtin_Function_Call'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Builtin_Function_Call function F_Parameters (Node : Builtin_Function_Call'Class) return Terms; -- When there are no parsing errors, this field is never null. --% belongs-to: Builtin_Function_Call function F_Var_Ref (Node : Case_Construction'Class) return Variable_Reference; -- When there are no parsing errors, this field is never null. --% belongs-to: Case_Construction function F_Items (Node : Case_Construction'Class) return Case_Item_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Case_Construction function F_Choice (Node : Case_Item'Class) return Choices; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Others_Designator`, :ada:ref:`String_Literal` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Case_Item function F_Decls (Node : Case_Item'Class) return Gpr_Node_List; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Attribute_Decl`, :ada:ref:`Case_Construction`, -- :ada:ref:`Empty_Decl`, :ada:ref:`Variable_Decl` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Case_Item function List_Child (Node : Case_Item_List'Class; Index : Positive) return Case_Item; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has -- no such child. function Case_Item_List_First (Node : Case_Item_List) return Positive; -- Implementation detail for the Iterable aspect function Case_Item_List_Next (Node : Case_Item_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function Case_Item_List_Has_Element (Node : Case_Item_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function Case_Item_List_Element (Node : Case_Item_List; Cursor : Positive) return Case_Item'Class; -- Implementation detail for the Iterable aspect function Gpr_Node_List_First (Node : Gpr_Node_List) return Positive; -- Implementation detail for the Iterable aspect function Gpr_Node_List_Next (Node : Gpr_Node_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function Gpr_Node_List_Has_Element (Node : Gpr_Node_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function Gpr_Node_List_Element (Node : Gpr_Node_List; Cursor : Positive) return Gpr_Node'Class; -- Implementation detail for the Iterable aspect function F_Project (Node : Compilation_Unit'Class) return Project; -- When there are no parsing errors, this field is never null. --% belongs-to: Compilation_Unit function List_Child (Node : Identifier_List'Class; Index : Positive) return Identifier; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has -- no such child. function Identifier_List_First (Node : Identifier_List) return Positive; -- Implementation detail for the Iterable aspect function Identifier_List_Next (Node : Identifier_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function Identifier_List_Has_Element (Node : Identifier_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function Identifier_List_Element (Node : Identifier_List; Cursor : Positive) return Identifier'Class; -- Implementation detail for the Iterable aspect function P_As_Bool (Node : Limited_Node'Class) return Boolean; -- Return whether this is an instance of LimitedPresent --% belongs-to: Limited_Node function F_Pkg_Name (Node : Package_Decl'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Decl function F_Pkg_Spec (Node : Package_Decl'Class) return Gpr_Node; -- This field can contain one of the following nodes: -- :ada:ref:`Package_Renaming`, :ada:ref:`Package_Spec` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Decl function F_Extended_Name (Node : Package_Extension'Class) return Identifier_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Extension function F_Renamed_Name (Node : Package_Renaming'Class) return Identifier_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Renaming function F_Extension (Node : Package_Spec'Class) return Package_Extension; --% belongs-to: Package_Spec function F_Decls (Node : Package_Spec'Class) return Gpr_Node_List; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Attribute_Decl`, :ada:ref:`Case_Construction`, -- :ada:ref:`Empty_Decl`, :ada:ref:`Variable_Decl` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Spec function F_End_Name (Node : Package_Spec'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Package_Spec function F_Prefix (Node : Prefix'Class) return Expr; -- This field can contain one of the following nodes: -- :ada:ref:`Identifier`, :ada:ref:`Prefix` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Prefix function F_Suffix (Node : Prefix'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Prefix function F_Context_Clauses (Node : Project'Class) return With_Decl_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Project function F_Project_Decl (Node : Project'Class) return Project_Declaration; -- When there are no parsing errors, this field is never null. --% belongs-to: Project function F_Qualifier (Node : Project_Declaration'Class) return Project_Qualifier; --% belongs-to: Project_Declaration function F_Qualifier (Node : Project_Declaration'Class) return Gpr_Project_Qualifier; --% belongs-to: Project_Declaration function F_Project_Name (Node : Project_Declaration'Class) return Expr; -- This field can contain one of the following nodes: -- :ada:ref:`Identifier`, :ada:ref:`Prefix` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Project_Declaration function F_Extension (Node : Project_Declaration'Class) return Project_Extension; --% belongs-to: Project_Declaration function F_Decls (Node : Project_Declaration'Class) return Gpr_Node_List; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Attribute_Decl`, :ada:ref:`Case_Construction`, -- :ada:ref:`Empty_Decl`, :ada:ref:`Package_Decl`, -- :ada:ref:`Typed_String_Decl`, :ada:ref:`Variable_Decl` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Project_Declaration function F_End_Name (Node : Project_Declaration'Class) return Expr; -- This field can contain one of the following nodes: -- :ada:ref:`Identifier`, :ada:ref:`Prefix` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Project_Declaration function F_Is_All (Node : Project_Extension'Class) return All_Qualifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Project_Extension function F_Is_All (Node : Project_Extension'Class) return Boolean; --% belongs-to: Project_Extension function F_Path_Name (Node : Project_Extension'Class) return String_Literal; -- When there are no parsing errors, this field is never null. --% belongs-to: Project_Extension function F_Str_Lit (Node : String_Literal_At'Class) return String_Literal; -- When there are no parsing errors, this field is never null. --% belongs-to: String_Literal_At function F_At_Lit (Node : String_Literal_At'Class) return Num_Literal; --% belongs-to: String_Literal_At function List_Child (Node : String_Literal_List'Class; Index : Positive) return String_Literal; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has -- no such child. function String_Literal_List_First (Node : String_Literal_List) return Positive; -- Implementation detail for the Iterable aspect function String_Literal_List_Next (Node : String_Literal_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function String_Literal_List_Has_Element (Node : String_Literal_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function String_Literal_List_Element (Node : String_Literal_List; Cursor : Positive) return String_Literal'Class; -- Implementation detail for the Iterable aspect function List_Child (Node : Term_List_List'Class; Index : Positive) return Term_List; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has -- no such child. function Term_List_List_First (Node : Term_List_List) return Positive; -- Implementation detail for the Iterable aspect function Term_List_List_Next (Node : Term_List_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function Term_List_List_Has_Element (Node : Term_List_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function Term_List_List_Element (Node : Term_List_List; Cursor : Positive) return Term_List'Class; -- Implementation detail for the Iterable aspect function F_Terms (Node : Terms'Class) return Term_List_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Terms function F_Var_Type_Name (Node : Type_Reference'Class) return Identifier_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Type_Reference function F_Type_Id (Node : Typed_String_Decl'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Typed_String_Decl function F_String_Literals (Node : Typed_String_Decl'Class) return String_Literal_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Typed_String_Decl function F_Var_Name (Node : Variable_Decl'Class) return Identifier; -- When there are no parsing errors, this field is never null. --% belongs-to: Variable_Decl function F_Var_Type (Node : Variable_Decl'Class) return Type_Reference; --% belongs-to: Variable_Decl function F_Expr (Node : Variable_Decl'Class) return Term_List; -- This field contains a list that itself contains one of the following -- nodes: :ada:ref:`Builtin_Function_Call`, :ada:ref:`String_Literal_At`, -- :ada:ref:`Terms`, :ada:ref:`Variable_Reference` -- -- When there are no parsing errors, this field is never null. --% belongs-to: Variable_Decl function F_Variable_Name (Node : Variable_Reference'Class) return Identifier_List; -- When there are no parsing errors, this field is never null. --% belongs-to: Variable_Reference function F_Attribute_Ref (Node : Variable_Reference'Class) return Attribute_Reference; --% belongs-to: Variable_Reference function F_Is_Limited (Node : With_Decl'Class) return Limited_Node; -- When there are no parsing errors, this field is never null. --% belongs-to: With_Decl function F_Is_Limited (Node : With_Decl'Class) return Boolean; --% belongs-to: With_Decl function F_Path_Names (Node : With_Decl'Class) return String_Literal_List; -- When there are no parsing errors, this field is never null. --% belongs-to: With_Decl function List_Child (Node : With_Decl_List'Class; Index : Positive) return With_Decl; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has -- no such child. function With_Decl_List_First (Node : With_Decl_List) return Positive; -- Implementation detail for the Iterable aspect function With_Decl_List_Next (Node : With_Decl_List; Cursor : Positive) return Positive; -- Implementation detail for the Iterable aspect function With_Decl_List_Has_Element (Node : With_Decl_List; Cursor : Positive) return Boolean; -- Implementation detail for the Iterable aspect function With_Decl_List_Element (Node : With_Decl_List; Cursor : Positive) return With_Decl'Class; -- Implementation detail for the Iterable aspect pragma Warnings (On, "defined after private extension"); ------------------------------- -- Tree traversal operations -- ------------------------------- function Children_Count (Node : Gpr_Node'Class) return Natural; -- Return the number of children ``Node`` has function First_Child_Index (Node : Gpr_Node'Class) return Natural; -- Return the index of the first child ``Node`` has function Last_Child_Index (Node : Gpr_Node'Class) return Natural; -- Return the index of the last child ``Node`` has, or 0 if there is no -- child. pragma Warnings (Off, "defined after private extension"); procedure Get_Child (Node : Gpr_Node'Class; Index : Positive; Index_In_Bounds : out Boolean; Result : out Gpr_Node); -- Return the ``Index``'th child of node, storing it into ``Result``. -- -- Child indexing is 1-based. Store in ``Index_In_Bounds`` whether ``Node`` -- had such a child: if not (i.e. ``Index`` is out-of-bounds), set -- ``Result`` to a null node. function Child (Node : Gpr_Node'Class; Index : Positive) return Gpr_Node; -- Return the ``Index``'th child of ``Node``, or null if ``Node`` has no -- such child. function First_Child (Node : Gpr_Node'Class) return Gpr_Node; -- Return the first child ``Node`` has, or ``No_Gpr_Node`` -- if there is none. function Last_Child (Node : Gpr_Node'Class) return Gpr_Node; -- Return the last child ``Node`` has, or ``No_Gpr_Node`` if -- there is none. pragma Warnings (On, "defined after private extension"); function Traverse (Node : Gpr_Node'Class; Visit : access function (Node : Gpr_Node'Class) return Visit_Status) return Visit_Status; -- Call ``Visit`` on ``Node`` and all its children, transitively. Calls -- happen in prefix order (i.e. top-down and left first). The traversal is -- controlled as follows by the result returned by Visit: -- -- ``Into`` -- The traversal continues normally with the syntactic children of the -- node just processed. -- -- ``Over`` -- The children of the node just processed are skipped and excluded from -- the traversal, but otherwise processing continues elsewhere in the -- tree. -- -- ``Stop`` -- The entire traversal is immediately abandoned, and the original call -- to ``Traverse`` returns ``Stop``. procedure Traverse (Node : Gpr_Node'Class; Visit : access function (Node : Gpr_Node'Class) return Visit_Status); -- This is the same as ``Traverse`` function except that no result is -- returned i.e. the ``Traverse`` function is called and the result is -- simply discarded. ---------------------------------------- -- Source location-related operations -- ---------------------------------------- function Sloc_Range (Node : Gpr_Node'Class) return Source_Location_Range; -- Return the source location range corresponding to the set of tokens from -- which Node was parsed. function Compare (Node : Gpr_Node'Class; Sloc : Source_Location) return Relative_Position; -- Compare Sloc to the sloc range of Node pragma Warnings (Off, "defined after private extension"); function Lookup (Node : Gpr_Node'Class; Sloc : Source_Location) return Gpr_Node; -- Look for the bottom-most AST node whose sloc range contains Sloc. Return -- it, or null if no such node was found. pragma Warnings (On, "defined after private extension"); ----------------------- -- Lexical utilities -- ----------------------- function Text (Node : Gpr_Node'Class) return Text_Type; -- Return the source buffer slice corresponding to the text that spans -- between the first and the last tokens of this node. -- -- Note that this returns the empty string for synthetic nodes. function Token_Range (Node : Gpr_Node'Class) return Token_Iterator; -- Return an iterator on the range of tokens encompassed by Node ------------------- -- Debug helpers -- ------------------- procedure Print (Node : Gpr_Node'Class; Show_Slocs : Boolean := True; Line_Prefix : String := ""); -- Debug helper: print to standard output Node and all its children. -- -- If Show_Slocs, include AST nodes' source locations in the output. -- -- Line_Prefix is prepended to each output line. procedure PP_Trivia (Node : Gpr_Node'Class; Line_Prefix : String := ""); -- Debug helper: print to standard output Node and all its children along -- with the trivia associated to them. Line_Prefix is prepended to each -- output line. procedure Assign_Names_To_Logic_Vars (Node : Gpr_Node'Class); -- Debug helper: Assign names to every logical variable in the root node, -- so that we can trace logical variables. -- The following As_* functions convert references to nodes from one type -- to another (Gpr_Node can refer to any node type). They -- raise a Constraint_Error if the conversion is invalid. pragma Warnings (Off, "defined after private extension"); function As_Gpr_Node (Node : Gpr_Node'Class) return Gpr_Node; --% no-document: True function As_All_Qualifier (Node : Gpr_Node'Class) return All_Qualifier; --% no-document: True function As_All_Qualifier_Absent (Node : Gpr_Node'Class) return All_Qualifier_Absent; --% no-document: True function As_All_Qualifier_Present (Node : Gpr_Node'Class) return All_Qualifier_Present; --% no-document: True function As_Attribute_Decl (Node : Gpr_Node'Class) return Attribute_Decl; --% no-document: True function As_Attribute_Reference (Node : Gpr_Node'Class) return Attribute_Reference; --% no-document: True function As_Base_List (Node : Gpr_Node'Class) return Base_List; --% no-document: True function As_Builtin_Function_Call (Node : Gpr_Node'Class) return Builtin_Function_Call; --% no-document: True function As_Case_Construction (Node : Gpr_Node'Class) return Case_Construction; --% no-document: True function As_Case_Item (Node : Gpr_Node'Class) return Case_Item; --% no-document: True function As_Case_Item_List (Node : Gpr_Node'Class) return Case_Item_List; --% no-document: True function As_Gpr_Node_List (Node : Gpr_Node'Class) return Gpr_Node_List; --% no-document: True function As_Choices (Node : Gpr_Node'Class) return Choices; --% no-document: True function As_Compilation_Unit (Node : Gpr_Node'Class) return Compilation_Unit; --% no-document: True function As_Empty_Decl (Node : Gpr_Node'Class) return Empty_Decl; --% no-document: True function As_Expr (Node : Gpr_Node'Class) return Expr; --% no-document: True function As_Single_Tok_Node (Node : Gpr_Node'Class) return Single_Tok_Node; --% no-document: True function As_Identifier (Node : Gpr_Node'Class) return Identifier; --% no-document: True function As_Identifier_List (Node : Gpr_Node'Class) return Identifier_List; --% no-document: True function As_Limited_Node (Node : Gpr_Node'Class) return Limited_Node; --% no-document: True function As_Limited_Absent (Node : Gpr_Node'Class) return Limited_Absent; --% no-document: True function As_Limited_Present (Node : Gpr_Node'Class) return Limited_Present; --% no-document: True function As_Num_Literal (Node : Gpr_Node'Class) return Num_Literal; --% no-document: True function As_Others_Designator (Node : Gpr_Node'Class) return Others_Designator; --% no-document: True function As_Package_Decl (Node : Gpr_Node'Class) return Package_Decl; --% no-document: True function As_Package_Extension (Node : Gpr_Node'Class) return Package_Extension; --% no-document: True function As_Package_Renaming (Node : Gpr_Node'Class) return Package_Renaming; --% no-document: True function As_Package_Spec (Node : Gpr_Node'Class) return Package_Spec; --% no-document: True function As_Prefix (Node : Gpr_Node'Class) return Prefix; --% no-document: True function As_Project (Node : Gpr_Node'Class) return Project; --% no-document: True function As_Project_Declaration (Node : Gpr_Node'Class) return Project_Declaration; --% no-document: True function As_Project_Extension (Node : Gpr_Node'Class) return Project_Extension; --% no-document: True function As_Project_Qualifier (Node : Gpr_Node'Class) return Project_Qualifier; --% no-document: True function As_Project_Qualifier_Abstract (Node : Gpr_Node'Class) return Project_Qualifier_Abstract; --% no-document: True function As_Project_Qualifier_Aggregate (Node : Gpr_Node'Class) return Project_Qualifier_Aggregate; --% no-document: True function As_Project_Qualifier_Aggregate_Library (Node : Gpr_Node'Class) return Project_Qualifier_Aggregate_Library; --% no-document: True function As_Project_Qualifier_Configuration (Node : Gpr_Node'Class) return Project_Qualifier_Configuration; --% no-document: True function As_Project_Qualifier_Library (Node : Gpr_Node'Class) return Project_Qualifier_Library; --% no-document: True function As_Project_Qualifier_Standard (Node : Gpr_Node'Class) return Project_Qualifier_Standard; --% no-document: True function As_String_Literal (Node : Gpr_Node'Class) return String_Literal; --% no-document: True function As_String_Literal_At (Node : Gpr_Node'Class) return String_Literal_At; --% no-document: True function As_String_Literal_List (Node : Gpr_Node'Class) return String_Literal_List; --% no-document: True function As_Term_List (Node : Gpr_Node'Class) return Term_List; --% no-document: True function As_Term_List_List (Node : Gpr_Node'Class) return Term_List_List; --% no-document: True function As_Terms (Node : Gpr_Node'Class) return Terms; --% no-document: True function As_Type_Reference (Node : Gpr_Node'Class) return Type_Reference; --% no-document: True function As_Typed_String_Decl (Node : Gpr_Node'Class) return Typed_String_Decl; --% no-document: True function As_Variable_Decl (Node : Gpr_Node'Class) return Variable_Decl; --% no-document: True function As_Variable_Reference (Node : Gpr_Node'Class) return Variable_Reference; --% no-document: True function As_With_Decl (Node : Gpr_Node'Class) return With_Decl; --% no-document: True function As_With_Decl_List (Node : Gpr_Node'Class) return With_Decl_List; --% no-document: True function Hash (Node : Gpr_Node) return Ada.Containers.Hash_Type; -- Generic hash function, to be used for nodes as keys in hash tables pragma Warnings (On, "defined after private extension"); private type Internal_Context_Access is access all Implementation.Analysis_Context_Type; type Internal_Unit_Access is access all Implementation.Analysis_Unit_Type; type Analysis_Context is new Ada.Finalization.Controlled with record Internal : Internal_Context_Access; end record; overriding procedure Initialize (Context : in out Analysis_Context); overriding procedure Adjust (Context : in out Analysis_Context); overriding procedure Finalize (Context : in out Analysis_Context); type Analysis_Unit is new Gpr_Parser_Support.Text.Text_Buffer_Ifc with record Internal : Internal_Unit_Access; Context : Analysis_Context; -- Keep a reference to the owning context so that the context lives as -- long as there is at least one reference to one of its units. end record; No_Analysis_Context : constant Analysis_Context := (Ada.Finalization.Controlled with Internal => null); No_Analysis_Unit : constant Analysis_Unit := (Internal => null, Context => (Ada.Finalization.Controlled with Internal => null)); -------------------------- -- AST nodes (internal) -- -------------------------- type Gpr_Node is tagged record Internal : Implementation.AST_Envs.Entity; Safety_Net : Implementation.Node_Safety_Net; end record; No_Gpr_Node : constant Gpr_Node := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type All_Qualifier is new Gpr_Node with null record; No_All_Qualifier : constant All_Qualifier := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type All_Qualifier_Absent is new All_Qualifier with null record; No_All_Qualifier_Absent : constant All_Qualifier_Absent := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type All_Qualifier_Present is new All_Qualifier with null record; No_All_Qualifier_Present : constant All_Qualifier_Present := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Attribute_Decl is new Gpr_Node with null record; No_Attribute_Decl : constant Attribute_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Attribute_Reference is new Gpr_Node with null record; No_Attribute_Reference : constant Attribute_Reference := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Base_List is new Gpr_Node with null record; No_Base_List : constant Base_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Builtin_Function_Call is new Gpr_Node with null record; No_Builtin_Function_Call : constant Builtin_Function_Call := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Case_Construction is new Gpr_Node with null record; No_Case_Construction : constant Case_Construction := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Case_Item is new Gpr_Node with null record; No_Case_Item : constant Case_Item := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Case_Item_List is new Base_List with null record; No_Case_Item_List : constant Case_Item_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Gpr_Node_List is new Base_List with null record; No_Gpr_Node_List : constant Gpr_Node_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Choices is new Gpr_Node_List with null record; No_Choices : constant Choices := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Compilation_Unit is new Gpr_Node with null record; No_Compilation_Unit : constant Compilation_Unit := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Empty_Decl is new Gpr_Node with null record; No_Empty_Decl : constant Empty_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Expr is new Gpr_Node with null record; No_Expr : constant Expr := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Single_Tok_Node is new Expr with null record; No_Single_Tok_Node : constant Single_Tok_Node := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Identifier is new Single_Tok_Node with null record; No_Identifier : constant Identifier := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Identifier_List is new Base_List with null record; No_Identifier_List : constant Identifier_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Limited_Node is new Gpr_Node with null record; No_Limited_Node : constant Limited_Node := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Limited_Absent is new Limited_Node with null record; No_Limited_Absent : constant Limited_Absent := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Limited_Present is new Limited_Node with null record; No_Limited_Present : constant Limited_Present := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Num_Literal is new Single_Tok_Node with null record; No_Num_Literal : constant Num_Literal := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Others_Designator is new Gpr_Node with null record; No_Others_Designator : constant Others_Designator := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Package_Decl is new Gpr_Node with null record; No_Package_Decl : constant Package_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Package_Extension is new Gpr_Node with null record; No_Package_Extension : constant Package_Extension := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Package_Renaming is new Gpr_Node with null record; No_Package_Renaming : constant Package_Renaming := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Package_Spec is new Gpr_Node with null record; No_Package_Spec : constant Package_Spec := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Prefix is new Expr with null record; No_Prefix : constant Prefix := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project is new Gpr_Node with null record; No_Project : constant Project := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Declaration is new Gpr_Node with null record; No_Project_Declaration : constant Project_Declaration := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Extension is new Gpr_Node with null record; No_Project_Extension : constant Project_Extension := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier is new Gpr_Node with null record; No_Project_Qualifier : constant Project_Qualifier := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Abstract is new Project_Qualifier with null record; No_Project_Qualifier_Abstract : constant Project_Qualifier_Abstract := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Aggregate is new Project_Qualifier with null record; No_Project_Qualifier_Aggregate : constant Project_Qualifier_Aggregate := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Aggregate_Library is new Project_Qualifier with null record; No_Project_Qualifier_Aggregate_Library : constant Project_Qualifier_Aggregate_Library := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Configuration is new Project_Qualifier with null record; No_Project_Qualifier_Configuration : constant Project_Qualifier_Configuration := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Library is new Project_Qualifier with null record; No_Project_Qualifier_Library : constant Project_Qualifier_Library := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Project_Qualifier_Standard is new Project_Qualifier with null record; No_Project_Qualifier_Standard : constant Project_Qualifier_Standard := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type String_Literal is new Single_Tok_Node with null record; No_String_Literal : constant String_Literal := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type String_Literal_At is new Gpr_Node with null record; No_String_Literal_At : constant String_Literal_At := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type String_Literal_List is new Base_List with null record; No_String_Literal_List : constant String_Literal_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Term_List is new Gpr_Node_List with null record; No_Term_List : constant Term_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Term_List_List is new Base_List with null record; No_Term_List_List : constant Term_List_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Terms is new Gpr_Node with null record; No_Terms : constant Terms := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Type_Reference is new Gpr_Node with null record; No_Type_Reference : constant Type_Reference := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Typed_String_Decl is new Gpr_Node with null record; No_Typed_String_Decl : constant Typed_String_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Variable_Decl is new Gpr_Node with null record; No_Variable_Decl : constant Variable_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type Variable_Reference is new Gpr_Node with null record; No_Variable_Reference : constant Variable_Reference := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type With_Decl is new Gpr_Node with null record; No_With_Decl : constant With_Decl := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); type With_Decl_List is new Base_List with null record; No_With_Decl_List : constant With_Decl_List := (Internal => Implementation.No_Entity, Safety_Net => Implementation.No_Node_Safety_Net); package Child_Record_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Child_Record); type Children_Array is record Children : Child_Record_Vectors.Vector; end record; procedure Check_Safety_Net (Self : Gpr_Node'Class); -- Check that Self's node and rebindings are still valid, raising a -- Stale_Reference_Error if one is not. -------------------------------- -- Token Iterator (internals) -- -------------------------------- type Token_Iterator is record Node : Gpr_Node; Last : Token_Index; end record; --------------------------------- -- Composite types (internals) -- --------------------------------- -- The dummy references to these packages forces them to be included in -- statically linked builds (thanks to the binder). This benefits the GDB -- helpers at no cost. Version : String renames Gpr_Parser.Version; procedure RN (Node : Gpr_Parser.Implementation.Bare_Gpr_Node) renames Gpr_Parser.Debug.PN; end Gpr_Parser.Analysis;
jwarwick/aoc_2020
Ada
1,185
adb
with AUnit.Assertions; use AUnit.Assertions; package body Day.Test is procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); g : constant Grid_Set.Set := load_file("test1.txt"); cycles : constant Natural := 6; t1 : constant Natural := active_count(g, cycles); begin Assert(t1 = 112, "Wrong number, expected 112, got" & Natural'IMAGE(t1)); end Test_Part1; procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); g : constant Grid_Set.Set := load_file("test1.txt"); cycles : constant Natural := 6; t2 : constant Natural := active_count_4d(g, cycles); begin Assert(t2 = 848, "Wrong number, expected 848, got" & Natural'IMAGE(t2)); end Test_Part2; function Name (T : Test) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Test Day package"); end Name; procedure Register_Tests (T : in out Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Part1'Access, "Test Part 1"); Register_Routine (T, Test_Part2'Access, "Test Part 2"); end Register_Tests; end Day.Test;
reznikmm/matreshka
Ada
3,961
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.Form_Order_Attributes; package Matreshka.ODF_Form.Order_Attributes is type Form_Order_Attribute_Node is new Matreshka.ODF_Form.Abstract_Form_Attribute_Node and ODF.DOM.Form_Order_Attributes.ODF_Form_Order_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Order_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Form_Order_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Form.Order_Attributes;
zhmu/ananas
Ada
3,227
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 9 1 -- -- -- -- 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 = 91 package System.Pack_91 is pragma Preelaborate; Bits : constant := 91; type Bits_91 is mod 2 ** Bits; for Bits_91'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_91 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_91 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_91 (Arr : System.Address; N : Natural; E : Bits_91; 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_91;
reznikmm/matreshka
Ada
5,196
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.Unmarshall_Actions.Collections is pragma Preelaborate; package UML_Unmarshall_Action_Collections is new AMF.Generic_Collections (UML_Unmarshall_Action, UML_Unmarshall_Action_Access); type Set_Of_UML_Unmarshall_Action is new UML_Unmarshall_Action_Collections.Set with null record; Empty_Set_Of_UML_Unmarshall_Action : constant Set_Of_UML_Unmarshall_Action; type Ordered_Set_Of_UML_Unmarshall_Action is new UML_Unmarshall_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Unmarshall_Action : constant Ordered_Set_Of_UML_Unmarshall_Action; type Bag_Of_UML_Unmarshall_Action is new UML_Unmarshall_Action_Collections.Bag with null record; Empty_Bag_Of_UML_Unmarshall_Action : constant Bag_Of_UML_Unmarshall_Action; type Sequence_Of_UML_Unmarshall_Action is new UML_Unmarshall_Action_Collections.Sequence with null record; Empty_Sequence_Of_UML_Unmarshall_Action : constant Sequence_Of_UML_Unmarshall_Action; private Empty_Set_Of_UML_Unmarshall_Action : constant Set_Of_UML_Unmarshall_Action := (UML_Unmarshall_Action_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Unmarshall_Action : constant Ordered_Set_Of_UML_Unmarshall_Action := (UML_Unmarshall_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Unmarshall_Action : constant Bag_Of_UML_Unmarshall_Action := (UML_Unmarshall_Action_Collections.Bag with null record); Empty_Sequence_Of_UML_Unmarshall_Action : constant Sequence_Of_UML_Unmarshall_Action := (UML_Unmarshall_Action_Collections.Sequence with null record); end AMF.UML.Unmarshall_Actions.Collections;
zhmu/ananas
Ada
145
ads
package Loop_Invariant1 is type Arr is array (Natural range <>) of Integer; procedure Proc (A : Arr; N : Integer); end Loop_Invariant1;
sungyeon/drake
Ada
5,231
adb
with Ada.Exception_Identification.From_Here; with System.Zero_Terminated_Strings; with C.errno; with C.fcntl; with C.stdio; -- rename(2) with C.sys.mman; with C.unistd; package body System.Native_Directories.Copying is use Ada.Exception_Identification.From_Here; use type Ada.Exception_Identification.Exception_Id; use type C.signed_int; use type C.unsigned_short; -- mode_t in FreeBSD use type C.unsigned_int; -- open flag, and mode_t in Linux use type C.signed_long; -- 64bit ssize_t use type C.size_t; -- implementation procedure Copy_File ( Source_Name : String; Target_Name : String; Overwrite : Boolean := True) is Exception_Id : Ada.Exception_Identification.Exception_Id := Ada.Exception_Identification.Null_Id; C_Source_Name : C.char_array ( 0 .. Source_Name'Length * Zero_Terminated_Strings.Expanding); Source : C.signed_int; C_Target_Name : C.char_array ( 0 .. Target_Name'Length * Zero_Terminated_Strings.Expanding); Target : C.signed_int; Flag : C.unsigned_int; Data : aliased C.sys.stat.struct_stat; Map : C.void_ptr; Written : C.sys.types.ssize_t; begin Zero_Terminated_Strings.To_C (Source_Name, C_Source_Name (0)'Access); Zero_Terminated_Strings.To_C (Target_Name, C_Target_Name (0)'Access); Source := C.fcntl.open (C_Source_Name (0)'Access, C.fcntl.O_RDONLY); if Source < 0 then Exception_Id := Named_IO_Exception_Id (C.errno.errno); else if C.sys.stat.fstat (Source, Data'Access) < 0 then Exception_Id := IO_Exception_Id (C.errno.errno); else Map := C.sys.mman.mmap ( C.void_ptr (Null_Address), C.size_t (Data.st_size), C.sys.mman.PROT_READ, C.sys.mman.MAP_FILE + C.sys.mman.MAP_SHARED, Source, 0); if Address (Map) = Address (C.sys.mman.MAP_FAILED) then Exception_Id := Use_Error'Identity; else Flag := C.fcntl.O_WRONLY or C.fcntl.O_CREAT or C.fcntl.O_EXLOCK; if not Overwrite then Flag := Flag or C.fcntl.O_EXCL; end if; Target := C.fcntl.open ( C_Target_Name (0)'Access, C.signed_int (Flag), Data.st_mode); if Target < 0 then Exception_Id := Named_IO_Exception_Id (C.errno.errno); else Written := C.unistd.write ( Target, C.void_const_ptr (Map), C.size_t (Data.st_size)); if Written < C.sys.types.ssize_t (Data.st_size) then Exception_Id := Device_Error'Identity; end if; -- close target if C.unistd.close (Target) < 0 and then Exception_Id = Ada.Exception_Identification.Null_Id then Exception_Id := IO_Exception_Id (C.errno.errno); end if; end if; -- munmap if C.sys.mman.munmap (Map, C.size_t (Data.st_size)) < 0 and then Exception_Id = Ada.Exception_Identification.Null_Id then Exception_Id := Use_Error'Identity; end if; end if; end if; -- close source if C.unistd.close (Source) < 0 and then Exception_Id = Ada.Exception_Identification.Null_Id then Exception_Id := IO_Exception_Id (C.errno.errno); end if; end if; -- raising if Exception_Id /= Ada.Exception_Identification.Null_Id then Raise_Exception (Exception_Id); end if; end Copy_File; procedure Replace_File ( Source_Name : String; Target_Name : String) is C_Source_Name : C.char_array ( 0 .. Source_Name'Length * Zero_Terminated_Strings.Expanding); C_Target_Name : C.char_array ( 0 .. Target_Name'Length * Zero_Terminated_Strings.Expanding); Target_Info : aliased C.sys.stat.struct_stat; Error : Boolean; begin Zero_Terminated_Strings.To_C (Source_Name, C_Source_Name (0)'Access); Zero_Terminated_Strings.To_C (Target_Name, C_Target_Name (0)'Access); -- if the target is already existing, -- copy attributes from the target to the source. Error := False; if C.sys.stat.lstat ( C_Target_Name (0)'Access, Target_Info'Access) = 0 then Error := C.sys.stat.lchmod ( C_Source_Name (0)'Access, Target_Info.st_mode and C.sys.stat.ALLPERMS) < 0; end if; if not Error then -- overwrite the target with the source. Error := C.stdio.rename ( C_Source_Name (0)'Access, C_Target_Name (0)'Access) < 0; end if; if Error then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; end Replace_File; end System.Native_Directories.Copying;
reznikmm/matreshka
Ada
4,739
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.Text_Object_Index_Elements; package Matreshka.ODF_Text.Object_Index_Elements is type Text_Object_Index_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Object_Index_Elements.ODF_Text_Object_Index with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Object_Index_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Object_Index_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Object_Index_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 Text_Object_Index_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 Text_Object_Index_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_Text.Object_Index_Elements;
faelys/natools
Ada
1,079
adb
with Interfaces; use Interfaces; package body Natools.S_Expressions.Printers.Pretty.Config.Newline_Cmd is P : constant array (0 .. 2) of Natural := (2, 3, 7); T1 : constant array (0 .. 2) of Unsigned_8 := (11, 29, 8); T2 : constant array (0 .. 2) of Unsigned_8 := (43, 5, 24); G : constant array (0 .. 48) of Unsigned_8 := (0, 6, 0, 6, 0, 23, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, 0, 4, 14, 1, 0, 0, 15, 15, 12, 0, 9, 5, 14, 0, 21, 7, 0, 0, 0, 3, 0, 0, 1, 12, 0, 0, 16, 0, 2, 0, 19, 1, 12); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 49; F2 := (F2 + Natural (T2 (K)) * J) mod 49; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 24; end Hash; end Natools.S_Expressions.Printers.Pretty.Config.Newline_Cmd;
jrcarter/Gnoga_File_Selection
Ada
8,848
adb
with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Directories; with Gnoga.Gui.Base; with Gnoga.Gui.Modal_Dialog; with Gnoga.Gui.Element.Common; with Gnoga.Gui.Element.Form; with Gnoga.Gui.View; package body Gnoga_File_Selection is function Select_File (Window : in out Gnoga.Gui.Window.Window_Type'Class; Initial_Directory : in String := ".") return Result_Info is Directory_Tag : constant String := " (directory)"; package Name_Lists is new Ada.Containers.Indefinite_Ordered_Sets (Element_Type => String); use Ada.Strings.Unbounded; protected Control is entry Wait_Until_Changed; procedure Signal_Changed; private -- Control Changed : Boolean := False; end Control; procedure Up_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class); -- Change current directory to parent of current directory procedure File_Selected (Object : in out Gnoga.Gui.Base.Base_Type'Class); -- User clicked on a file in the file list procedure Cancel_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class); -- User clicked on Cancel; return nothing picked procedure OK_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class); -- User clicked on OK; return selected or entered file name procedure Fill_List (Directory : in String; List : in out Gnoga.Gui.Element.Form.Selection_Type); -- Clears List, then adds the files in Directory to it, directories first, in alphabetical order Result_Ready : Boolean := False with Atomic; Result : Result_Info; Current_Dir : Unbounded_String := To_Unbounded_String (Ada.Directories.Full_Name (Initial_Directory) ); File_List : Gnoga.Gui.Element.Form.Selection_Type; File_Input : Gnoga.Gui.Element.Form.Text_Type; protected body Control is entry Wait_Until_Changed when Changed is -- Empty begin -- Wait_Until_Changed Changed := False; end Wait_Until_Changed; procedure Signal_Changed is -- Empty begin -- Signal_Changed Changed := True; end Signal_Changed; end Control; procedure Up_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty begin -- Up_Clicked Current_Dir := To_Unbounded_String (Ada.Directories.Containing_Directory (To_String (Current_Dir) ) ); Control.Signal_Changed; exception -- Up_Clicked when Ada.Directories.Use_Error => Gnoga.Log (Message => "Up_Clicked: Use_Error for " & To_String (Current_Dir) ); when others => Gnoga.Log (Message => "Up_Clicked: other exception"); end Up_Clicked; procedure File_Selected (Object : in out Gnoga.Gui.Base.Base_Type'Class) is Index : constant Natural := File_List.Selected_Index; begin -- File_Selected if Index = 0 then return; end if; Get_Name : declare Name : constant String := File_List.Value (Index); begin -- Get_Name if Name'Length <= Directory_Tag'Length or else Name (Name'Last - Directory_Tag'Length + 1 .. Name'Last) /= Directory_Tag then -- Normal file File_Input.Value (Value => Name); else -- Directory Current_Dir := To_Unbounded_String (Ada.Directories.Compose (To_String (Current_Dir), Name (Name'First .. Name'Last - Directory_Tag'Length) ) ); File_Input.Value (Value => ""); Control.Signal_Changed; end if; end Get_Name; end File_Selected; procedure Cancel_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty begin -- Cancel_Clicked Result_Ready := True; Control.Signal_Changed; end Cancel_Clicked; procedure OK_Clicked (Object : in out Gnoga.Gui.Base.Base_Type'Class) is Name : constant String := File_Input.Value; begin -- OK_Clicked if Name /= "" then Result := (Picked => True, Value => To_Unbounded_String (Ada.Directories.Compose (To_String (Current_Dir), Name) ) ); Result_Ready := True; Control.Signal_Changed; end if; -- else ignore end OK_Clicked; procedure Fill_List (Directory : in String; List : in out Gnoga.Gui.Element.Form.Selection_Type) is procedure Clear (List : in out Gnoga.Gui.Element.Form.Selection_Type); -- Removes all options from List procedure Add_Dir (Position : in Name_Lists.Cursor); -- Adds the Name at Position to List with Directory_Tag added to the end procedure Add_File (Position : in Name_Lists.Cursor); -- Adds the name at Position to List procedure Clear (List : in out Gnoga.Gui.Element.Form.Selection_Type) is -- Empty begin -- Clear All_Options : for I in reverse 1 .. List.Length loop List.Remove_Option (Index => I); end loop All_Options; end Clear; procedure Add_Dir (Position : in Name_Lists.Cursor) is Name : constant String := Name_Lists.Element (Position) & Directory_Tag; begin -- Add_Dir List.Add_Option (Value => Name, Text => Name); end Add_Dir; procedure Add_File (Position : in Name_Lists.Cursor) is Name : constant String := Name_Lists.Element (Position); begin -- Add_File List.Add_Option (Value => Name, Text => Name); end Add_File; Search_Info : Ada.Directories.Search_Type; File_Info : Ada.Directories.Directory_Entry_Type; Dir_List : Name_Lists.Set; File_List : Name_Lists.Set; begin -- Fill_List Clear (List => List); Ada.Directories.Start_Search (Search => Search_Info, Directory => Directory, Pattern => "*", Filter => (Ada.Directories.Special_File => False, others => True) ); All_Entries : loop exit All_Entries when not Ada.Directories.More_Entries (Search_Info); Ada.Directories.Get_Next_Entry (Search => Search_Info, Directory_Entry => File_Info); case Ada.Directories.Kind (File_Info) is when Ada.Directories.Directory => Get_Name : declare Name : constant String := Ada.Directories.Simple_Name (File_Info); begin -- Get_Name if Name /= "." and Name /= ".." then Dir_List.Insert (New_Item => Name); end if; end Get_Name; when Ada.Directories.Ordinary_File => File_List.Insert (New_Item => Ada.Directories.Simple_Name (File_Info) ); when Ada.Directories.Special_File => null; end case; end loop All_Entries; Dir_List.Iterate (Process => Add_Dir'Access); File_List.Iterate (Process => Add_File'Access); end Fill_List; Dialog : Gnoga.Gui.Modal_Dialog.Dialog_Type; View : Gnoga.Gui.View.View_Type; Form : Gnoga.Gui.Element.Form.Form_Type; Dir_Line : Gnoga.Gui.Element.Form.Text_Type; Up : Gnoga.Gui.Element.Common.Button_Type; Cancel : Gnoga.Gui.Element.Common.Button_Type; OK : Gnoga.Gui.Element.Common.Button_Type; begin -- Select_File Dialog.Create (Parent => Window); Dialog.Create_Main_View (View => View); Form.Create (Parent => View); Dir_Line.Create (Form => Form, Size => 100); Dir_Line.Read_Only; Up.Create (Parent => Form, Content => "Up"); Up.On_Click_Handler (Handler => Up_Clicked'Unrestricted_Access); Form.New_Line; File_List.Create (Form => Form, Visible_Lines => 20); File_List.On_Click_Handler (Handler => File_Selected'Unrestricted_Access); Form.New_Line; File_Input.Create (Form => Form, Size => 50); Cancel.Create (Parent => Form, Content => "Cancel"); Cancel.On_Click_Handler (Handler => Cancel_Clicked'Unrestricted_Access); OK.Create (Parent => Form, Content => "OK"); OK.On_Click_Handler (Handler => OK_Clicked'Unrestricted_Access); Dialog.Show; All_Dirs : loop Dir_Line.Value (Value => To_String (Current_Dir) ); File_Input.Value (Value => ""); Fill_List (Directory => To_String (Current_Dir), List => File_List); Control.Wait_Until_Changed; if Result_Ready then Dialog.Remove; return Result; end if; end loop All_Dirs; end Select_File; end Gnoga_File_Selection;
reznikmm/matreshka
Ada
3,689
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.Style_Region_Right_Elements is pragma Preelaborate; type ODF_Style_Region_Right is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Style_Region_Right_Access is access all ODF_Style_Region_Right'Class with Storage_Size => 0; end ODF.DOM.Style_Region_Right_Elements;
charlie5/cBound
Ada
1,437
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_visual_configs_cookie_t is -- Item -- type Item is record sequence : aliased Interfaces.C.unsigned; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_visual_configs_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_visual_configs_cookie_t.Item, Element_Array => xcb.xcb_glx_get_visual_configs_cookie_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_visual_configs_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_visual_configs_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_visual_configs_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_visual_configs_cookie_t;
sungyeon/drake
Ada
26
adb
../../generic/a-nusfge.adb
reznikmm/matreshka
Ada
3,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Fo_Country_Attributes is pragma Preelaborate; type ODF_Fo_Country_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Fo_Country_Attribute_Access is access all ODF_Fo_Country_Attribute'Class with Storage_Size => 0; end ODF.DOM.Fo_Country_Attributes;
reznikmm/matreshka
Ada
3,643
ads
------------------------------------------------------------------------------ -- -- -- 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$ ------------------------------------------------------------------------------ pragma Ada_2012; private package XML.SAX.Simple_Readers.Parser is procedure YYParse (Self : in out Simple_Reader); -- Parse XML document. procedure Initialize (State : in out Parser_State_Information); -- Initialize parser's state before first use. end XML.SAX.Simple_Readers.Parser;
reznikmm/matreshka
Ada
3,729
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.Dr3d_Ambient_Color_Attributes is pragma Preelaborate; type ODF_Dr3d_Ambient_Color_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Dr3d_Ambient_Color_Attribute_Access is access all ODF_Dr3d_Ambient_Color_Attribute'Class with Storage_Size => 0; end ODF.DOM.Dr3d_Ambient_Color_Attributes;
AdaCore/libadalang
Ada
512
adb
procedure Test is package Pouet is type Foo is tagged; procedure Do_Stuff (X : Foo) is null; type Foo is tagged null record; end Pouet; package Bidule is type Foo is new Pouet.Foo with null record; procedure Bar; end Bidule; package body Bidule is procedure Bar is X : Foo; begin Do_Stuff (X); pragma Test_Statement; end Lol; end Bidule; X : Pouet.Foo; begin X.Do_Stuff; pragma Test_Statement; end Test;
davidkristola/vole
Ada
1,180
ads
with kv.avm.Actor_References; with kv.avm.Control; package kv.avm.Services is -- Machines have a collection of services that will send messages -- to their destination when the time is right. The messages are -- service dependent, as is the timing. -- -- Since services may monitor asynchronous events, they may involve -- different threads of execution. This must be managed in their -- Execute method which is called from the Machine's thread. If -- a message is to be sent, it must be sent from this call tree. type Service_Interface is interface; type Service_Access is access Service_Interface'CLASS; procedure Set_Destination (Self : in out Service_Interface; Destination : in kv.avm.Actor_References.Actor_Reference_Type) is abstract; procedure Set_Machine (Self : in out Service_Interface; Machine : in kv.avm.Control.Control_Access) is abstract; procedure Execute (Self : in out Service_Interface) is abstract; function Get_Destination(Self : Service_Interface) return kv.avm.Actor_References.Actor_Reference_Type is abstract; procedure Foo; end kv.avm.Services;
charlie5/lace
Ada
25,171
adb
with bullet_c.Binding, bullet_physics.Object, c_math_c.Vector_3, c_math_c.Matrix_4x4, c_math_c.Conversion, Swig, interfaces.C, ada.unchecked_Conversion, ada.unchecked_Deallocation, ada.Text_IO; package body bullet_Physics.Joint is use c_math_c.Conversion, bullet_c.Binding, Interfaces, ada.Text_IO; type Any_limited_view is access all lace.Any.limited_item'Class; function to_Any_view is new ada.unchecked_Conversion (Swig.void_ptr, Any_limited_view); function to_Object_view is new ada.unchecked_Conversion (swig.void_ptr, physics.Object.view); pragma Unreferenced (to_Object_view); -------------- -- Joint.item -- overriding function reaction_Force (Self : in Item) return Vector_3 is begin raise Error with "TODO"; return math.Origin_3D; end reaction_Force; overriding function reaction_Torque (Self : in Item) return Real is begin raise Error with "TODO"; return 0.0; end reaction_Torque; overriding procedure user_Data_is (Self : in out Item; Now : access lace.Any.limited_item'Class) is begin Self.user_Data := Now; end user_Data_is; overriding function user_Data (Self : in Item) return access lace.Any.limited_item'Class is begin return Self.user_Data; end user_Data; -------- -- DoF6 -- function new_Dof6_Joint (Object_A, Object_B : in physics.Object.view; Frame_A, Frame_B : in Matrix_4x4) return physics.Joint.DoF6.view is Self : constant DoF6_view := new DoF6; c_Object_A : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_A).C; c_Object_B : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_B).C; c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A; c_Frame_B : aliased c_math_c.Matrix_4x4.item := +Frame_B; begin Self.C := b3d_new_DoF6_Joint (c_Object_A, c_Object_B, c_Frame_A'unchecked_Access, c_Frame_B'unchecked_Access); return Self; end new_Dof6_Joint; overriding procedure destruct (Self : in out DoF6) is begin raise Error with "TODO"; end destruct; overriding function Object_A (Self : in DoF6) return physics.Object.view is c_Object_A : constant bullet_c.Pointers.Object_pointer := b3d_Joint_Object_A (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_A))); end Object_A; overriding function Object_B (Self : in DoF6) return physics.Object.view is c_Object_B : constant bullet_c.Pointers.Object_pointer := b3d_Joint_Object_B (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_B))); end Object_B; overriding function Frame_A (Self : in DoF6) return Matrix_4x4 is begin return +b3d_Joint_Frame_A (Self.C); end Frame_A; overriding function Frame_B (Self : in DoF6) return Matrix_4x4 is begin return +b3d_Joint_Frame_B (Self.C); end Frame_B; overriding procedure Frame_A_is (Self : in out DoF6; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_A_is (Self.C, c_Now'unchecked_Access); end Frame_A_is; overriding procedure Frame_B_is (Self : in out DoF6; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_B_is (Self.C, c_Now'unchecked_Access); end Frame_B_is; overriding function is_Limited (Self : in DoF6; DoF : in Degree_of_freedom) return Boolean is use type Swig.bool; begin return b3d_Joint_is_Limited (Self.C, Degree_of_freedom'Pos (DoF)) /= 0; end is_Limited; overriding procedure Velocity_is (Self : in out DoF6; Now : in Real; DoF : in Degree_of_freedom) is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; b3d_Joint_Velocity_is (Self.C, C.int (DoF), c_math_c.Real (Now)); end Velocity_is; overriding function Extent (Self : in DoF6; DoF : Degree_of_freedom) return Real is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; return Real (b3d_Joint_Extent (Self.C, C.int (DoF))); end Extent; overriding procedure desired_Extent_is (Self : in out DoF6; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end desired_Extent_is; overriding function lower_Limit (Self : in DoF6; DoF : in Degree_of_freedom) return Real is begin return Real (b3d_Joint_6DoF_lower_Limit (Self.C, C.int (DoF))); end lower_Limit; overriding function upper_Limit (Self : in DoF6; DoF : in Degree_of_freedom) return Real is begin return Real (b3d_Joint_6DoF_upper_Limit (Self.C, C.int (DoF))); end upper_Limit; overriding procedure lower_Limit_is (Self : in out DoF6; Now : in Real; DoF : in Degree_of_freedom) is begin b3d_Joint_6DoF_lower_Limit_is (Self.C, C.int (DoF), c_math_c.Real (Now)); end lower_Limit_is; overriding procedure upper_Limit_is (Self : in out DoF6; Now : in Real; DoF : in Degree_of_freedom) is begin b3d_Joint_6DoF_upper_Limit_is (Self.C, C.int (DoF), c_math_c.Real (Now)); end upper_Limit_is; -------- -- Ball -- function new_Ball_Joint (Object_A, Object_B : in physics.Object.view; Pivot_in_A, Pivot_in_B : in Vector_3) return physics.Joint.ball.view is Self : constant Ball_view := new Ball; c_Object_A : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_A).C; c_Object_B : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_B).C; c_Pivot_in_A : aliased c_math_c.Vector_3.item := +Pivot_in_A; c_Pivot_in_B : aliased c_math_c.Vector_3.item := +Pivot_in_B; begin Self.C := b3d_new_ball_Joint (c_Object_A, c_Object_B, c_Pivot_in_A'unchecked_Access, c_Pivot_in_B'unchecked_Access); return Self; end new_Ball_Joint; overriding procedure destruct (Self : in out Ball) is begin raise Error with "TODO"; end destruct; overriding function Object_A (Self : in Ball) return physics.Object.view is c_Object_A : constant bullet_c.Pointers.Object_Pointer := b3d_Joint_Object_A (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_A))); end Object_A; overriding function Object_B (Self : in Ball) return physics.Object.view is c_Object_B : constant bullet_c.Pointers.Object_Pointer := b3d_Joint_Object_B (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_B))); end Object_B; overriding function Frame_A (Self : in Ball) return Matrix_4x4 is begin return +b3d_Joint_Frame_A (Self.C); end Frame_A; overriding function Frame_B (Self : in Ball) return Matrix_4x4 is begin return +b3d_Joint_Frame_B (Self.C); end Frame_B; overriding procedure Frame_A_is (Self : in out Ball; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_A_is (Self.C, c_Now'unchecked_Access); end Frame_A_is; overriding procedure Frame_B_is (Self : in out Ball; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_B_is (Self.C, c_Now'unchecked_Access); end Frame_B_is; overriding function is_Limited (Self : in Ball; DoF : in Degree_of_freedom) return Boolean is use type Swig.bool; begin return b3d_Joint_is_Limited (Self.C, Degree_of_freedom'Pos (DoF)) /= 0; end is_Limited; overriding procedure Velocity_is (Self : in out Ball; Now : in Real; DoF : in Degree_of_freedom) is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; b3d_Joint_Velocity_is (Self.C, C.int (Now), c_math_c.Real (DoF)); end Velocity_is; overriding function Extent (Self : in Ball; DoF : in Degree_of_freedom) return Real is begin if DoF < 4 then raise Program_Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; return Real (b3d_Joint_Extent (Self.C, C.int (DoF))); end Extent; overriding procedure desired_Extent_is (Self : in out Ball; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end desired_Extent_is; overriding function lower_Limit (Self : in Ball; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end lower_Limit; overriding function upper_Limit (Self : in Ball; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end upper_Limit; overriding procedure lower_Limit_is (Self : in out Ball; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end lower_Limit_is; overriding procedure upper_Limit_is (Self : in out Ball; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end upper_Limit_is; ---------- -- Slider -- function new_Slider_Joint (Object_A, Object_B : in physics.Object.view; Frame_A, Frame_B : in Matrix_4x4) return physics.Joint.slider.view is Self : constant Slider_view := new Slider; c_Object_A : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_A).C; c_Object_B : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_B).C; c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A; c_Frame_B : aliased c_math_c.Matrix_4x4.item := +Frame_B; begin Self.C := b3d_new_slider_Joint (c_Object_A, c_Object_B, c_Frame_A'Unchecked_Access, c_Frame_B'Unchecked_Access); return Self; end new_Slider_Joint; overriding procedure destruct (Self : in out Slider) is begin raise Error with "TODO"; end destruct; overriding function Object_A (Self : in Slider) return physics.Object.view is c_Object_A : constant bullet_c.Pointers.Object_Pointer := b3d_Joint_Object_A (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_A))); end Object_A; overriding function Object_B (Self : in Slider) return physics.Object.view is c_Object_B : constant bullet_c.Pointers.Object_Pointer := b3d_Joint_Object_B (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_B))); end Object_B; overriding function Frame_A (Self : in Slider) return Matrix_4x4 is begin return +b3d_Joint_Frame_A (Self.C); end Frame_A; overriding function Frame_B (Self : in Slider) return Matrix_4x4 is begin return +b3d_Joint_Frame_B (Self.C); end Frame_B; overriding procedure Frame_A_is (Self : in out Slider; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_A_is (Self.C, c_Now'unchecked_Access); end Frame_A_is; overriding procedure Frame_B_is (Self : in out Slider; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_B_is (Self.C, c_Now'unchecked_Access); end Frame_B_is; overriding function is_Limited (Self : in Slider; DoF : in Degree_of_freedom) return Boolean is use type Swig.bool; begin return b3d_Joint_is_Limited (Self.C, Degree_of_freedom'Pos (DoF)) /= 0; end is_Limited; overriding procedure Velocity_is (Self : in out Slider; Now : in Real; DoF : in Degree_of_freedom) is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; b3d_Joint_Velocity_is (Self.C, C.int (Now), c_math_c.Real (DoF)); end Velocity_is; overriding function Extent (Self : in Slider; DoF : Degree_of_freedom) return Real is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; return Real (b3d_Joint_Extent (Self.C, C.int (DoF))); end Extent; overriding procedure desired_Extent_is (Self : in out Slider; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end desired_Extent_is; overriding function lower_Limit (Self : in Slider; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end lower_Limit; overriding function upper_Limit (Self : in Slider; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end upper_Limit; overriding procedure lower_Limit_is (Self : in out Slider; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end lower_Limit_is; overriding procedure upper_Limit_is (Self : in out Slider; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end upper_Limit_is; -------------- -- cone_Twist -- function new_cone_Twist_Joint (Object_A, Object_B : in physics.Object.view; Frame_A, Frame_B : in Matrix_4x4) return physics.Joint.cone_twist.view is Self : constant cone_Twist_view := new cone_Twist; c_Object_A : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_A).C; c_Object_B : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_B).C; c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A; c_Frame_B : aliased c_math_c.Matrix_4x4.item := +Frame_B; begin Self.C := b3d_new_DoF6_Joint (c_Object_A, c_Object_B, c_Frame_A'unchecked_Access, c_Frame_B'unchecked_Access); return Self; end new_cone_Twist_Joint; overriding procedure destruct (Self : in out cone_Twist) is begin raise Error with "TODO"; end destruct; overriding function Object_A (Self : in cone_Twist) return physics.Object.view is c_Object_A : constant bullet_c.Pointers.Object_pointer := b3d_Joint_Object_A (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_A))); end Object_A; overriding function Object_B (Self : in cone_Twist) return physics.Object.view is c_Object_B : constant bullet_c.Pointers.Object_pointer := b3d_Joint_Object_B (Self.C); begin return physics.Object.view (to_Any_view (b3d_Object_user_Data (c_Object_B))); end Object_B; overriding function Frame_A (Self : in cone_Twist) return Matrix_4x4 is begin return +b3d_Joint_Frame_A (Self.C); end Frame_A; overriding function Frame_B (Self : in cone_Twist) return Matrix_4x4 is begin return +b3d_Joint_Frame_B (Self.C); end Frame_B; overriding procedure Frame_A_is (Self : in out cone_Twist; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_A_is (Self.C, c_Now'unchecked_Access); end Frame_A_is; overriding procedure Frame_B_is (Self : in out cone_Twist; Now : in Matrix_4x4) is c_Now : aliased c_math_c.Matrix_4x4.item := +Now; begin b3d_Joint_Frame_B_is (Self.C, c_Now'unchecked_Access); end Frame_B_is; overriding function is_Limited (Self : in cone_Twist; DoF : Degree_of_freedom) return Boolean is use type Swig.bool; begin return b3d_Joint_is_Limited (Self.C, Degree_of_freedom'Pos (DoF)) /= 0; end is_Limited; overriding procedure Velocity_is (Self : in out cone_Twist; Now : in Real; DoF : in Degree_of_freedom) is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; b3d_Joint_Velocity_is (Self.C, C.int (Now), c_math_c.Real (DoF)); end Velocity_is; overriding function Extent (Self : in cone_Twist; DoF : Degree_of_freedom) return Real is begin if DoF < 4 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; return Real (b3d_Joint_Extent (Self.C, C.int (DoF))); end Extent; overriding procedure desired_Extent_is (Self : in out cone_Twist; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end desired_Extent_is; overriding function lower_Limit (Self : in cone_Twist; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end lower_Limit; overriding function upper_Limit (Self : in cone_Twist; DoF : in Degree_of_freedom) return Real is begin raise Error with "TODO"; return 0.0; end upper_Limit; overriding procedure lower_Limit_is (Self : in out cone_Twist; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end lower_Limit_is; overriding procedure upper_Limit_is (Self : in out cone_Twist; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end upper_Limit_is; --------- -- Hinge -- function new_hinge_Joint (Object_A : in physics.Object.view; Frame_A : in Matrix_4x4) return physics.Joint.hinge.view is use type bullet_physics.Object.view; Self : constant Hinge_view := new Hinge; c_Object_A : constant bullet_C.Pointers.Object_Pointer := bullet_physics.Object.view (Object_A).C; c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A; begin Self.C := b3d_new_space_hinge_Joint (c_Object_A, c_Frame_A'unchecked_Access); return Self; end new_hinge_Joint; overriding procedure destruct (Self : in out Hinge) is pragma unreferenced (Self); begin put_Line ("bullet_physics-joint.adb => raise Program_Error with ""TBD"";"); raise Error with "TODO"; end destruct; function new_hinge_Joint (Object_A, Object_B : in physics.Object.view; Frame_A, Frame_B : in Matrix_4x4) return physics.Joint.hinge.view is use type bullet_physics.Object.view; Self : constant Hinge_view := new Hinge; c_Object_A : bullet_C.Pointers.Object_Pointer; c_Object_B : bullet_C.Pointers.Object_Pointer; c_Frame_A : aliased c_math_c.Matrix_4x4.item := +Frame_A; c_Frame_B : aliased c_math_c.Matrix_4x4.item := +Frame_B; begin if bullet_physics.Object.view (Object_A) /= null then c_Object_A := bullet_physics.Object.view (Object_A).C; end if; if bullet_physics.Object.view (Object_B) /= null then c_Object_B := bullet_physics.Object.view (Object_B).C; end if; Self.C := b3d_new_hinge_Joint (c_Object_A, c_Object_B, c_Frame_A'unchecked_Access, c_Frame_B'unchecked_Access); return Self; end new_hinge_Joint; overriding procedure Limits_are (Self : in out Hinge; Low, High : in Real; Softness : in Real := 0.9; biasFactor : in Real := 0.3; relaxationFactor : in Real := 1.0) is begin b3d_Joint_hinge_Limits_are (Self.C, c_Math_c.Real (Low), c_Math_c.Real (High), c_Math_c.Real (Softness), c_Math_c.Real (biasFactor), c_Math_c.Real (relaxationFactor)); end Limits_are; overriding function lower_Limit (Self : in Hinge) return Real is begin raise Error with "TODO"; return 0.0; end lower_Limit; overriding function upper_Limit (Self : in Hinge) return Real is begin raise Error with "TODO"; return 0.0; end upper_Limit; overriding function Angle (Self : in Hinge) return Real is begin raise Error with "TODO"; return 0.0; end Angle; overriding function Object_A (Self : in Hinge) return physics.Object.view is begin raise Error with "TODO"; return null; end Object_A; overriding function Object_B (Self : in Hinge) return physics.Object.view is begin raise Error with "TODO"; return null; end Object_B; overriding function Frame_A (Self : in Hinge) return Matrix_4x4 is c_Frame : aliased c_math_c.Matrix_4x4.item; begin raise Error with "TODO"; return +c_Frame; end Frame_A; overriding function Frame_B (Self : in Hinge) return Matrix_4x4 is c_Frame : aliased c_math_c.Matrix_4x4.item; begin raise Error with "TODO"; return +c_Frame; end Frame_B; overriding procedure Frame_A_is (Self : in out Hinge; Now : in Matrix_4x4) is c_Frame : aliased constant c_math_c.Matrix_4x4.item := +Now; pragma Unreferenced (c_Frame); begin raise Error with "TODO"; end Frame_A_is; overriding procedure Frame_B_is (Self : in out Hinge; Now : in Matrix_4x4) is c_Frame : aliased constant c_math_c.Matrix_4x4.item := +Now; pragma Unreferenced (c_Frame); begin raise Error with "TODO"; end Frame_B_is; overriding function is_Limited (Self : in Hinge; DoF : Degree_of_freedom) return Boolean is pragma unreferenced (Self); begin return DoF = 1; end is_Limited; overriding procedure Velocity_is (Self : in out Hinge; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; if DoF /= 1 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; end Velocity_is; overriding function Extent (Self : in Hinge; DoF : Degree_of_freedom) return Real is begin raise Error with "TODO"; if DoF /= 1 then raise Error with "Illegal degree of freedom:" & DoF'Image & "."; end if; return 0.0; end Extent; overriding procedure desired_Extent_is (Self : in out Hinge; Now : in Real; DoF : in Degree_of_freedom) is begin raise Error with "TODO"; end desired_Extent_is; -------- --- Free -- procedure free (the_Joint : in out physics.Joint.view) is procedure deallocate is new ada.unchecked_Deallocation (physics.Joint.item'Class, physics.Joint.view); begin deallocate (the_Joint); end free; end bullet_Physics.Joint;
riccardo-bernardini/eugen
Ada
702
adb
pragma Ada_2012; package body Line_Arrays.Classified is -------------- -- Classify -- -------------- function Classify (Classifier : Classifier_Type; Lines : Line_Array) return Classified_Line_Vectors.Vector is Result : Classified_Line_Vectors.Vector; begin Result.Clear; for Line of Lines loop declare C_Line : constant Classified_Line := Classify (Classifier, Line); begin if not Is_To_Be_Ignored (C_Line) then Result.Append (C_Line); end if; end; end loop; return Result; end Classify; end Line_Arrays.Classified;
reznikmm/matreshka
Ada
4,317
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Elements.Internals; package body ODF.DOM.Elements.Text.Outline_Level_Style.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Elements.Text.Outline_Level_Style.Text_Outline_Level_Style_Access) return ODF.DOM.Elements.Text.Outline_Level_Style.ODF_Text_Outline_Level_Style is begin return (XML.DOM.Elements.Internals.Create (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Elements.Text.Outline_Level_Style.Text_Outline_Level_Style_Access) return ODF.DOM.Elements.Text.Outline_Level_Style.ODF_Text_Outline_Level_Style is begin return (XML.DOM.Elements.Internals.Wrap (Matreshka.DOM_Nodes.Element_Access (Node)) with null record); end Wrap; end ODF.DOM.Elements.Text.Outline_Level_Style.Internals;
reznikmm/matreshka
Ada
8,394
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- 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 Matreshka.Internals.Strings.Configuration; with Matreshka.Internals.Unicode.Characters.Latin; with Matreshka.Internals.Utf16; package body Matreshka.Internals.Text_Codecs.ISO88595 is use Matreshka.Internals.Strings.Configuration; use Matreshka.Internals.Unicode.Characters.Latin; use type Matreshka.Internals.Unicode.Code_Unit_32; use type Matreshka.Internals.Utf16.Utf16_String_Index; ------------------- -- Decode_Append -- ------------------- overriding procedure Decode_Append (Self : in out ISO88595_Decoder; Data : Ada.Streams.Stream_Element_Array; String : in out Matreshka.Internals.Strings.Shared_String_Access) is begin Matreshka.Internals.Strings.Mutate (String, String.Unused + Data'Length); for J in Data'Range loop case Data (J) is when 16#00# .. 16#A0# | 16#AD# => -- Directly mapped. Self.Unchecked_Append (Self, String, Matreshka.Internals.Unicode.Code_Point (Data (J))); when 16#F0# => -- NUMERO SIGN Self.Unchecked_Append (Self, String, 16#2116#); when 16#FD# => -- SECTION SIGN Self.Unchecked_Append (Self, String, 16#A7#); when 16#A1# .. 16#AC# | 16#AE# .. 16#EF# | 16#F1# .. 16#FC# | 16#FE# .. 16#FF# => -- Computed. Self.Unchecked_Append (Self, String, Matreshka.Internals.Unicode.Code_Point (Data (J)) - 16#A0# + 16#0400#); end case; end loop; String_Handler.Fill_Null_Terminator (String); end Decode_Append; ------------- -- Decoder -- ------------- function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class is begin case Mode is when Raw => return ISO88595_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_Raw'Access); when XML_1_0 => return ISO88595_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_XML10'Access); when XML_1_1 => return ISO88595_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_XML11'Access); end case; end Decoder; ------------ -- Encode -- ------------ overriding procedure Encode (Self : in out ISO88595_Encoder; String : not null Matreshka.Internals.Strings.Shared_String_Access; Buffer : out MISEV.Shared_Stream_Element_Vector_Access) is pragma Unreferenced (Self); use Matreshka.Internals.Stream_Element_Vectors; use Ada.Streams; Code : Matreshka.Internals.Unicode.Code_Point; Position : Matreshka.Internals.Utf16.Utf16_String_Index := 0; Element : Ada.Streams.Stream_Element; begin if String.Unused = 0 then Buffer := Empty_Shared_Stream_Element_Vector'Access; else Buffer := Allocate (Ada.Streams.Stream_Element_Offset (String.Unused)); while Position < String.Unused loop Matreshka.Internals.Utf16.Unchecked_Next (String.Value, Position, Code); if Code in 16#0000# .. 16#00A0# then -- Direct mapping. Element := Stream_Element (Code); elsif Code = 16#00A7# then Element := 16#FD#; -- SECTION SIGN elsif Code = 16#00AD# then Element := 16#AD#; -- SOFT HYPHEN elsif Code = 16#2116# then Element := 16#F0#; -- NUMERO SIGN elsif Code in 16#0401# .. 16#40C# or Code in 16#040E# .. 16#044F# or Code in 16#0451# .. 16#045C# or Code in 16#045E# .. 16#045F# then -- Computable mapping. Element := Stream_Element (Code - 16#0400#) + 16#A0#; else Element := Question_Mark; end if; Buffer.Value (Buffer.Length) := Element; Buffer.Length := Buffer.Length + 1; end loop; end if; end Encode; ------------- -- Encoder -- ------------- function Encoder return Abstract_Encoder'Class is begin return ISO88595_Encoder'(null record); end Encoder; -------------- -- Is_Error -- -------------- overriding function Is_Error (Self : ISO88595_Decoder) return Boolean is pragma Unreferenced (Self); begin return False; end Is_Error; ------------------- -- Is_Mailformed -- ------------------- overriding function Is_Mailformed (Self : ISO88595_Decoder) return Boolean is pragma Unreferenced (Self); begin return False; end Is_Mailformed; end Matreshka.Internals.Text_Codecs.ISO88595;
persan/A-gst
Ada
300
ads
with AUnit.Test_Cases; package GStreamer.Rtsp.transport.Tests is use AUnit; type Test_Case is new AUnit.Test_Cases.Test_Case with null record; function Name (Test : Test_Case) return Message_String; procedure Register_Tests (Test : in out Test_Case); end GStreamer.Rtsp.transport.Tests;
reznikmm/matreshka
Ada
4,785
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Table_Change_Deletion_Elements; package Matreshka.ODF_Table.Change_Deletion_Elements is type Table_Change_Deletion_Element_Node is new Matreshka.ODF_Table.Abstract_Table_Element_Node and ODF.DOM.Table_Change_Deletion_Elements.ODF_Table_Change_Deletion with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Change_Deletion_Element_Node; overriding function Get_Local_Name (Self : not null access constant Table_Change_Deletion_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Table_Change_Deletion_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Table_Change_Deletion_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Table_Change_Deletion_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Table.Change_Deletion_Elements;