repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
zhmu/ananas
Ada
6,627
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . I N T E R R U P T S . N A M E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1991-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a HP-UX version of this package -- The following signals are reserved by the run time: -- SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGTRAP, SIGTERM, SIGABRT, SIGINT, -- SIGALRM, SIGSTOP, SIGKILL -- The pragma Unreserve_All_Interrupts affects the following signal(s): -- SIGINT: made available for Ada handler -- This target-dependent package spec contains names of interrupts -- supported by the local system. with System.OS_Interface; package Ada.Interrupts.Names is -- All identifiers in this unit are implementation defined pragma Implementation_Defined; -- Beware that the mapping of names to signals may be many-to-one. There -- may be aliases. Also, for all signal names that are not supported on -- the current system the value of the corresponding constant will be zero. SIGHUP : constant Interrupt_ID := System.OS_Interface.SIGHUP; -- hangup SIGINT : constant Interrupt_ID := System.OS_Interface.SIGINT; -- interrupt (rubout) SIGQUIT : constant Interrupt_ID := System.OS_Interface.SIGQUIT; -- quit (ASCD FS) SIGILL : constant Interrupt_ID := System.OS_Interface.SIGILL; -- illegal instruction (not reset) SIGTRAP : constant Interrupt_ID := System.OS_Interface.SIGTRAP; -- trace trap (not reset) SIGIOT : constant Interrupt_ID := System.OS_Interface.SIGIOT; -- IOT instruction SIGABRT : constant Interrupt_ID := -- used by abort, System.OS_Interface.SIGABRT; -- replace SIGIOT in the future SIGEMT : constant Interrupt_ID := System.OS_Interface.SIGEMT; -- EMT instruction SIGFPE : constant Interrupt_ID := System.OS_Interface.SIGFPE; -- floating point exception SIGKILL : constant Interrupt_ID := System.OS_Interface.SIGKILL; -- kill (cannot be caught or ignored) SIGBUS : constant Interrupt_ID := System.OS_Interface.SIGBUS; -- bus error SIGSEGV : constant Interrupt_ID := System.OS_Interface.SIGSEGV; -- segmentation violation SIGSYS : constant Interrupt_ID := System.OS_Interface.SIGSYS; -- bad argument to system call SIGPIPE : constant Interrupt_ID := -- write on a pipe with System.OS_Interface.SIGPIPE; -- no one to read it SIGALRM : constant Interrupt_ID := System.OS_Interface.SIGALRM; -- alarm clock SIGTERM : constant Interrupt_ID := System.OS_Interface.SIGTERM; -- software termination signal from kill SIGUSR1 : constant Interrupt_ID := System.OS_Interface.SIGUSR1; -- user defined signal 1 SIGUSR2 : constant Interrupt_ID := System.OS_Interface.SIGUSR2; -- user defined signal 2 SIGCLD : constant Interrupt_ID := System.OS_Interface.SIGCLD; -- child status change SIGCHLD : constant Interrupt_ID := System.OS_Interface.SIGCHLD; -- 4.3BSD's/POSIX name for SIGCLD SIGWINCH : constant Interrupt_ID := System.OS_Interface.SIGWINCH; -- window size change SIGURG : constant Interrupt_ID := System.OS_Interface.SIGURG; -- urgent condition on IO channel SIGPOLL : constant Interrupt_ID := System.OS_Interface.SIGPOLL; -- pollable event occurred SIGIO : constant Interrupt_ID := -- input/output possible, System.OS_Interface.SIGIO; -- SIGPOLL alias SIGSTOP : constant Interrupt_ID := System.OS_Interface.SIGSTOP; -- stop (cannot be caught or ignored) SIGTSTP : constant Interrupt_ID := System.OS_Interface.SIGTSTP; -- user stop requested from tty SIGCONT : constant Interrupt_ID := System.OS_Interface.SIGCONT; -- stopped process has been continued SIGTTIN : constant Interrupt_ID := System.OS_Interface.SIGTTIN; -- background tty read attempted SIGTTOU : constant Interrupt_ID := System.OS_Interface.SIGTTOU; -- background tty write attempted SIGVTALRM : constant Interrupt_ID := System.OS_Interface.SIGVTALRM; -- virtual timer expired SIGPROF : constant Interrupt_ID := System.OS_Interface.SIGPROF; -- profiling timer expired SIGPWR : constant Interrupt_ID := System.OS_Interface.SIGPWR; -- power-fail restart end Ada.Interrupts.Names;
persan/gprTools
Ada
400
ads
with Gprslaves.DB; with GNAT.Spitbol.Table_VString; with AWS.Status; with AWS.Response; package GPR_Tools.Gprslaves.Nameserver.Server is procedure Register (Server : DB.Info_Struct); function Find (Keys : GNAT.Spitbol.Table_VString.Table) return DB.Host_Info_Vectors.Vector; function Request (Request : AWS.Status.Data) return AWS.Response.Data; end GPR_Tools.Gprslaves.Nameserver.Server;
pdaxrom/Kino2
Ada
3,818
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Form_Demo.Handler -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control -- $Revision: 1.8 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Forms; use Terminal_Interface.Curses.Forms; generic with function My_Driver (Frm : Form; K : Key_Code; Pan : Panel) return Boolean; package Sample.Form_Demo.Handler is procedure Drive_Me (F : in Form; Lin : in Line_Position; Col : in Column_Position; Title : in String := ""); -- Position the menu at the given point and drive it. procedure Drive_Me (F : in Form; Title : in String := ""); -- Center menu and drive it. end Sample.Form_Demo.Handler;
1Crazymoney/LearnAda
Ada
1,922
adb
with Ada.Text_IO, Ada.Calendar, Ada.Numerics.Discrete_Random; use Ada.Text_IO; procedure Utkereszt is type lampaszinek is (piros, pirossarga, zold, sarga); protected jelzolampa is procedure valt; function szin return lampaszinek; private aktszin : lampaszinek := piros; end jelzolampa; protected body jelzolampa is procedure valt is begin -- valt if aktszin = sarga then aktszin := piros; else aktszin := lampaszinek'Succ(aktszin); end if; Put_Line("Lampa szine: " & lampaszinek'Image(aktszin)); end valt; function szin return lampaszinek is begin -- szin return aktszin; end szin; end jelzolampa; task utemezo; task body utemezo is begin for i in 1 .. 3 loop jelzolampa.valt; delay 3.0; jelzolampa.valt; delay 0.5; jelzolampa.valt; delay 2.0; jelzolampa.valt; delay 1.0; end loop; end utemezo; type String_Access is access String; type Duration_Access is access Duration; task type Auto( rendszam: String_Access; menetidoalampaig: Duration_Access ); type Auto_Access is access Auto; task body Auto is Atment : Boolean := false; begin Put_Line(rendszam.all & "elindult"); delay(menetidoalampaig.all); Put_Line(rendszam.all & "odaert a lampahoz"); while not Atment loop select jelzolampa.athalad; Atment := true; or delay 0.2; Put_Line(rendszam.all & "varakozik a lampanal"); end select; end loop; end Auto; autok : array(1 .. 3) of Auto_Access; begin -- Utkereszt autok(1) := new Auto(new String("AAA-111"), new Duration'(1.5)); autok(2) := new Auto(new String("BBB-111"), new Duration'(3.3)); autok(3) := new Auto(new String("CCC-111"), new Duration'(7.5)); end Utkereszt;
charlie5/aIDE
Ada
51
ads
procedure AdaM.Assist.Query.find_Entities.Driver;
stcarrez/ada-servlet
Ada
3,877
adb
----------------------------------------------------------------------- -- servlet-server -- Servlet Server for AWS -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2019, 2020, 2021, 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 AWS.Config.Set; with AWS.Status; with AWS.Response; with Servlet.Requests.Web; with Servlet.Responses.Web; with Util.Http.Clients.AWS; with Util.Log.Loggers; package body Servlet.Server.Web is use Util.Log; use Ada.Strings.Unbounded; Log : constant Loggers.Logger := Loggers.Create ("Servlet.Server.Web"); -- The logger function Server_Callback (Request : in AWS.Status.Data) return AWS.Response.Data; Server : AWS_Container_Access; overriding procedure Initialize (Instance : in out AWS_Container) is begin Instance.Conf := AWS.Config.Get_Current; AWS.Config.Set.Reuse_Address (O => Instance.Conf, Value => True); AWS.Config.Set.Upload_Directory (Instance.Conf, "upload"); Server := Instance'Unchecked_Access; end Initialize; ---------------------- -- Start the applications that have been registered. ---------------------- overriding procedure Start (Server : in out AWS_Container) is begin Log.Info ("Starting server..."); Container (Server).Start; AWS.Server.Start (Web_Server => Server.WS, Config => Server.Conf, Callback => Servlet.Server.Web.Server_Callback'Access); end Start; ---------------------- -- Configure the AWS server. ---------------------- procedure Configure (Server : in out AWS_Container; Process : not null access procedure (Config : in out AWS.Config.Object)) is begin Process (Server.Conf); end Configure; ---------------------- -- Configure the server before starting it. ---------------------- overriding procedure Configure (Server : in out AWS_Container; Config : in Configuration) is begin AWS.Config.Set.Server_Port (Server.Conf, Config.Listening_Port); AWS.Config.Set.Send_Buffer_Size (Server.Conf, Config.Buffer_Size); AWS.Config.Set.Max_Connection (Server.Conf, Config.Max_Connection); AWS.Config.Set.Reuse_Address (Server.Conf, Config.Reuse_Address); AWS.Config.Set.Accept_Queue_Size (Server.Conf, Config.Accept_Queue_Size); AWS.Config.Set.TCP_No_Delay (Server.Conf, Config.TCP_No_Delay); AWS.Config.Set.Upload_Size_Limit (Server.Conf, Config.Upload_Size_Limit); AWS.Config.Set.Upload_Directory (Server.Conf, To_String (Config.Upload_Directory)); AWS.Config.Set.Input_Line_Size_Limit (Config.Input_Line_Size_Limit); end Configure; ---------------------- -- Main server callback ---------------------- function Server_Callback (Request : in AWS.Status.Data) return AWS.Response.Data is Req : Servlet.Requests.Web.Request; Resp : Servlet.Responses.Web.Response; begin Req.Set_Request (Request'Unrestricted_Access); Server.Service (Req, Resp); Resp.Build; return Resp.Get_Data; end Server_Callback; begin Util.Http.Clients.AWS.Register; end Servlet.Server.Web;
zhmu/ananas
Ada
116,740
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . C O M M A N D _ L I N E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Deallocation; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.OS_Lib; use GNAT.OS_Lib; package body GNAT.Command_Line is -- General note: this entire body could use much more commenting. There -- are large sections of uncommented code throughout, and many formal -- parameters of local subprograms are not documented at all ??? package CL renames Ada.Command_Line; type Switch_Parameter_Type is (Parameter_None, Parameter_With_Optional_Space, -- ':' in getopt Parameter_With_Space_Or_Equal, -- '=' in getopt Parameter_No_Space, -- '!' in getopt Parameter_Optional); -- '?' in getopt procedure Set_Parameter (Variable : out Parameter_Type; Arg_Num : Positive; First : Positive; Last : Natural; Extra : Character := ASCII.NUL); pragma Inline (Set_Parameter); -- Set the parameter that will be returned by Parameter below -- -- Extra is a character that needs to be added when reporting Full_Switch. -- (it will in general be the switch character, for instance '-'). -- Otherwise, Full_Switch will report 'f' instead of '-f'. In particular, -- it needs to be set when reporting an invalid switch or handling '*'. -- -- Parameters need to be defined ??? function Goto_Next_Argument_In_Section (Parser : Opt_Parser) return Boolean; -- Go to the next argument on the command line. If we are at the end of -- the current section, we want to make sure there is no other identical -- section on the command line (there might be multiple instances of -- -largs). Returns True iff there is another argument. function Get_File_Names_Case_Sensitive return Integer; pragma Import (C, Get_File_Names_Case_Sensitive, "__gnat_get_file_names_case_sensitive"); File_Names_Case_Sensitive : constant Boolean := Get_File_Names_Case_Sensitive /= 0; procedure Canonical_Case_File_Name (S : in out String); -- Given a file name, converts it to canonical case form. For systems where -- file names are case sensitive, this procedure has no effect. If file -- names are not case sensitive (i.e. for example if you have the file -- "xyz.adb", you can refer to it as XYZ.adb or XyZ.AdB), then this call -- converts the given string to canonical all lower case form, so that two -- file names compare equal if they refer to the same file. procedure Internal_Initialize_Option_Scan (Parser : Opt_Parser; Switch_Char : Character; Stop_At_First_Non_Switch : Boolean; Section_Delimiters : String); -- Initialize Parser, which must have been allocated already function Argument (Parser : Opt_Parser; Index : Integer) return String; -- Return the index-th command line argument procedure Find_Longest_Matching_Switch (Switches : String; Arg : String; Index_In_Switches : out Integer; Switch_Length : out Integer; Param : out Switch_Parameter_Type); -- Return the Longest switch from Switches that at least partially matches -- Arg. Index_In_Switches is set to 0 if none matches. What are other -- parameters??? in particular Param is not always set??? procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Argument_List, Argument_List_Access); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Command_Line_Configuration_Record, Command_Line_Configuration); procedure Remove (Line : in out Argument_List_Access; Index : Integer); -- Remove a specific element from Line procedure Add (Line : in out Argument_List_Access; Str : String_Access; Before : Boolean := False); -- Add a new element to Line. If Before is True, the item is inserted at -- the beginning, else it is appended. procedure Add (Config : in out Command_Line_Configuration; Switch : Switch_Definition); procedure Add (Def : in out Alias_Definitions_List; Alias : Alias_Definition); -- Add a new element to Def procedure Initialize_Switch_Def (Def : out Switch_Definition; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG"); -- Initialize [Def] with the contents of the other parameters. -- This also checks consistency of the switch parameters, and will raise -- Invalid_Switch if they do not match. procedure Decompose_Switch (Switch : String; Parameter_Type : out Switch_Parameter_Type; Switch_Last : out Integer); -- Given a switch definition ("name:" for instance), extracts the type of -- parameter that is expected, and the name of the switch function Can_Have_Parameter (S : String) return Boolean; -- True if S can have a parameter function Require_Parameter (S : String) return Boolean; -- True if S requires a parameter function Actual_Switch (S : String) return String; -- Remove any possible trailing '!', ':', '?' and '=' generic with procedure Callback (Simple_Switch : String; Separator : String; Parameter : String; Index : Integer); -- Index in Config.Switches, or -1 procedure For_Each_Simple_Switch (Config : Command_Line_Configuration; Section : String; Switch : String; Parameter : String := ""; Unalias : Boolean := True); -- Breaks Switch into as simple switches as possible (expanding aliases and -- ungrouping common prefixes when possible), and call Callback for each of -- these. procedure Sort_Sections (Line : not null GNAT.OS_Lib.Argument_List_Access; Sections : GNAT.OS_Lib.Argument_List_Access; Params : GNAT.OS_Lib.Argument_List_Access); -- Reorder the command line switches so that the switches belonging to a -- section are grouped together. procedure Group_Switches (Cmd : Command_Line; Result : Argument_List_Access; Sections : Argument_List_Access; Params : Argument_List_Access); -- Group switches with common prefixes whenever possible. Once they have -- been grouped, we also check items for possible aliasing. procedure Alias_Switches (Cmd : Command_Line; Result : Argument_List_Access; Params : Argument_List_Access); -- When possible, replace one or more switches by an alias, i.e. a shorter -- version. function Looking_At (Type_Str : String; Index : Natural; Substring : String) return Boolean; -- Return True if the characters starting at Index in Type_Str are -- equivalent to Substring. generic with function Callback (S : String; Index : Integer) return Boolean; procedure Foreach_Switch (Config : Command_Line_Configuration; Section : String); -- Iterate over all switches defined in Config, for a specific section. -- Index is set to the index in Config.Switches. Stop iterating when -- Callback returns False. -------------- -- Argument -- -------------- function Argument (Parser : Opt_Parser; Index : Integer) return String is begin if Parser.Arguments /= null then return Parser.Arguments (Index + Parser.Arguments'First - 1).all; else return CL.Argument (Index); end if; end Argument; ------------------------------ -- Canonical_Case_File_Name -- ------------------------------ procedure Canonical_Case_File_Name (S : in out String) is begin if not File_Names_Case_Sensitive then for J in S'Range loop if S (J) in 'A' .. 'Z' then S (J) := Character'Val (Character'Pos (S (J)) + (Character'Pos ('a') - Character'Pos ('A'))); end if; end loop; end if; end Canonical_Case_File_Name; --------------- -- Expansion -- --------------- function Expansion (Iterator : Expansion_Iterator) return String is type Pointer is access all Expansion_Iterator; It : constant Pointer := Iterator'Unrestricted_Access; S : String (1 .. 1024); Last : Natural; Current : Depth := It.Current_Depth; NL : Positive; begin -- It is assumed that a directory is opened at the current level. -- Otherwise GNAT.Directory_Operations.Directory_Error will be raised -- at the first call to Read. loop Read (It.Levels (Current).Dir, S, Last); -- If we have exhausted the directory, close it and go back one level if Last = 0 then Close (It.Levels (Current).Dir); -- If we are at level 1, we are finished; return an empty string if Current = 1 then return String'(1 .. 0 => ' '); -- Otherwise continue with the directory at the previous level else Current := Current - 1; It.Current_Depth := Current; end if; -- If this is a directory, that is neither "." or "..", attempt to -- go to the next level. elsif Is_Directory (It.Dir_Name (1 .. It.Levels (Current).Name_Last) & S (1 .. Last)) and then S (1 .. Last) /= "." and then S (1 .. Last) /= ".." then -- We can go to the next level only if we have not reached the -- maximum depth, if Current < It.Maximum_Depth then NL := It.Levels (Current).Name_Last; -- And if relative path of this new directory is not too long if NL + Last + 1 < Max_Path_Length then Current := Current + 1; It.Current_Depth := Current; It.Dir_Name (NL + 1 .. NL + Last) := S (1 .. Last); NL := NL + Last + 1; It.Dir_Name (NL) := Directory_Separator; It.Levels (Current).Name_Last := NL; Canonical_Case_File_Name (It.Dir_Name (1 .. NL)); -- Open the new directory, and read from it GNAT.Directory_Operations.Open (It.Levels (Current).Dir, It.Dir_Name (1 .. NL)); end if; end if; end if; -- Check the relative path against the pattern -- Note that we try to match also against directory names, since -- clients of this function may expect to retrieve directories. declare Name : String := It.Dir_Name (It.Start .. It.Levels (Current).Name_Last) & S (1 .. Last); begin Canonical_Case_File_Name (Name); -- If it matches return the relative path if GNAT.Regexp.Match (Name, Iterator.Regexp) then return Name; end if; end; end loop; end Expansion; --------------------- -- Current_Section -- --------------------- function Current_Section (Parser : Opt_Parser := Command_Line_Parser) return String is begin if Parser.Current_Section = 1 then return ""; end if; for Index in reverse 1 .. Integer'Min (Parser.Current_Argument - 1, Parser.Section'Last) loop if Parser.Section (Index) = 0 then return Argument (Parser, Index); end if; end loop; return ""; end Current_Section; ----------------- -- Full_Switch -- ----------------- function Full_Switch (Parser : Opt_Parser := Command_Line_Parser) return String is begin if Parser.The_Switch.Extra = ASCII.NUL then return Argument (Parser, Parser.The_Switch.Arg_Num) (Parser.The_Switch.First .. Parser.The_Switch.Last); else return Parser.The_Switch.Extra & Argument (Parser, Parser.The_Switch.Arg_Num) (Parser.The_Switch.First .. Parser.The_Switch.Last); end if; end Full_Switch; ------------------ -- Get_Argument -- ------------------ function Get_Argument (Do_Expansion : Boolean := False; Parser : Opt_Parser := Command_Line_Parser) return String is End_Of_Args : Boolean; begin return Get_Argument (Do_Expansion, Parser, End_Of_Args); end Get_Argument; ------------------ -- Get_Argument -- ------------------ function Get_Argument (Do_Expansion : Boolean := False; Parser : Opt_Parser := Command_Line_Parser; End_Of_Arguments : out Boolean) return String is begin End_Of_Arguments := False; if Parser.In_Expansion then declare S : constant String := Expansion (Parser.Expansion_It); begin if S'Length /= 0 then return S; else Parser.In_Expansion := False; end if; end; end if; if Parser.Current_Argument > Parser.Arg_Count then -- If this is the first time this function is called if Parser.Current_Index = 1 then Parser.Current_Argument := 1; while Parser.Current_Argument <= Parser.Arg_Count and then Parser.Section (Parser.Current_Argument) /= Parser.Current_Section loop Parser.Current_Argument := Parser.Current_Argument + 1; end loop; else End_Of_Arguments := True; return String'(1 .. 0 => ' '); end if; elsif Parser.Section (Parser.Current_Argument) = 0 then while Parser.Current_Argument <= Parser.Arg_Count and then Parser.Section (Parser.Current_Argument) /= Parser.Current_Section loop Parser.Current_Argument := Parser.Current_Argument + 1; end loop; end if; Parser.Current_Index := Integer'Last; while Parser.Current_Argument <= Parser.Arg_Count and then Parser.Is_Switch (Parser.Current_Argument) loop Parser.Current_Argument := Parser.Current_Argument + 1; end loop; if Parser.Current_Argument > Parser.Arg_Count then End_Of_Arguments := True; return String'(1 .. 0 => ' '); elsif Parser.Section (Parser.Current_Argument) = 0 then return Get_Argument (Do_Expansion, Parser, End_Of_Arguments); end if; Parser.Current_Argument := Parser.Current_Argument + 1; -- Could it be a file name with wildcards to expand? if Do_Expansion then declare Arg : constant String := Argument (Parser, Parser.Current_Argument - 1); begin for Index in Arg'Range loop if Arg (Index) in '*' | '?' | '[' then Parser.In_Expansion := True; Start_Expansion (Parser.Expansion_It, Arg); return Get_Argument (Do_Expansion, Parser, End_Of_Arguments); end if; end loop; end; end if; return Argument (Parser, Parser.Current_Argument - 1); end Get_Argument; ---------------------- -- Decompose_Switch -- ---------------------- procedure Decompose_Switch (Switch : String; Parameter_Type : out Switch_Parameter_Type; Switch_Last : out Integer) is begin if Switch = "" then Parameter_Type := Parameter_None; Switch_Last := Switch'Last; return; end if; case Switch (Switch'Last) is when ':' => Parameter_Type := Parameter_With_Optional_Space; Switch_Last := Switch'Last - 1; when '=' => Parameter_Type := Parameter_With_Space_Or_Equal; Switch_Last := Switch'Last - 1; when '!' => Parameter_Type := Parameter_No_Space; Switch_Last := Switch'Last - 1; when '?' => Parameter_Type := Parameter_Optional; Switch_Last := Switch'Last - 1; when others => Parameter_Type := Parameter_None; Switch_Last := Switch'Last; end case; end Decompose_Switch; ---------------------------------- -- Find_Longest_Matching_Switch -- ---------------------------------- procedure Find_Longest_Matching_Switch (Switches : String; Arg : String; Index_In_Switches : out Integer; Switch_Length : out Integer; Param : out Switch_Parameter_Type) is Index : Natural; Length : Natural := 1; Last : Natural; P : Switch_Parameter_Type; begin Param := Parameter_None; Index_In_Switches := 0; Switch_Length := 0; -- Remove all leading spaces first to make sure that Index points -- at the start of the first switch. Index := Switches'First; while Index <= Switches'Last and then Switches (Index) = ' ' loop Index := Index + 1; end loop; while Index <= Switches'Last loop -- Search the length of the parameter at this position in Switches Length := Index; while Length <= Switches'Last and then Switches (Length) /= ' ' loop Length := Length + 1; end loop; -- Length now marks the separator after the current switch. Last will -- mark the last character of the name of the switch. if Length = Index + 1 then P := Parameter_None; Last := Index; else Decompose_Switch (Switches (Index .. Length - 1), P, Last); end if; -- If it is the one we searched, it may be a candidate if Arg'First + Last - Index <= Arg'Last and then Switches (Index .. Last) = Arg (Arg'First .. Arg'First + Last - Index) and then Last - Index + 1 > Switch_Length and then (P /= Parameter_With_Space_Or_Equal or else Arg'Last = Arg'First + Last - Index or else Arg (Arg'First + Last - Index + 1) = '=') then Param := P; Index_In_Switches := Index; Switch_Length := Last - Index + 1; end if; -- Look for the next switch in Switches while Index <= Switches'Last and then Switches (Index) /= ' ' loop Index := Index + 1; end loop; Index := Index + 1; end loop; end Find_Longest_Matching_Switch; ------------ -- Getopt -- ------------ function Getopt (Switches : String; Concatenate : Boolean := True; Parser : Opt_Parser := Command_Line_Parser) return Character is Dummy : Boolean; begin <<Restart>> -- If we have finished parsing the current command line item (there -- might be multiple switches in a single item), then go to the next -- element. if Parser.Current_Argument > Parser.Arg_Count or else (Parser.Current_Index > Argument (Parser, Parser.Current_Argument)'Last and then not Goto_Next_Argument_In_Section (Parser)) then return ASCII.NUL; end if; -- By default, the switch will not have a parameter Parser.The_Parameter := (Integer'Last, Integer'Last, Integer'Last - 1, ASCII.NUL); Parser.The_Separator := ASCII.NUL; declare Arg : constant String := Argument (Parser, Parser.Current_Argument); Index_Switches : Natural := 0; Max_Length : Natural := 0; End_Index : Natural; Param : Switch_Parameter_Type; begin -- If we are on a new item, test if this might be a switch if Parser.Current_Index = Arg'First then if Arg = "" or else Arg (Arg'First) /= Parser.Switch_Character then -- If it isn't a switch, return it immediately. We also know it -- isn't the parameter to a previous switch, since that has -- already been handled. if Switches (Switches'First) = '*' then Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Arg'First, Last => Arg'Last); Parser.Is_Switch (Parser.Current_Argument) := True; Dummy := Goto_Next_Argument_In_Section (Parser); return '*'; end if; if Parser.Stop_At_First then Parser.Current_Argument := Positive'Last; return ASCII.NUL; elsif not Goto_Next_Argument_In_Section (Parser) then return ASCII.NUL; else -- Recurse to get the next switch on the command line goto Restart; end if; end if; -- We are on the first character of a new command line argument, -- which starts with Switch_Character. Further analysis is needed. Parser.Current_Index := Parser.Current_Index + 1; Parser.Is_Switch (Parser.Current_Argument) := True; end if; Find_Longest_Matching_Switch (Switches => Switches, Arg => Arg (Parser.Current_Index .. Arg'Last), Index_In_Switches => Index_Switches, Switch_Length => Max_Length, Param => Param); -- If switch is not accepted, it is either invalid or is returned -- in the context of '*'. if Index_Switches = 0 then -- Find the current switch that we did not recognize. This is in -- fact difficult because Getopt does not know explicitly about -- short and long switches. Ideally, we would want the following -- behavior: -- * for short switches, with Concatenate: -- if -a is not recognized, and the command line has -daf -- we should report the invalid switch as "-a". -- * for short switches, wihtout Concatenate: -- we should report the invalid switch as "-daf". -- * for long switches: -- if the commadn line is "--long" we should report --long -- as unrecongized. -- Unfortunately, the fact that long switches start with a -- duplicate switch character is just a convention (so we could -- have a long switch "-long" for instance). We'll still rely on -- this convention here to try and get as helpful an error message -- as possible. -- Long switch case (starting with double switch character) if Arg (Arg'First + 1) = Parser.Switch_Character then End_Index := Arg'Last; -- Short switch case else End_Index := (if Concatenate then Parser.Current_Index else Arg'Last); end if; if Switches /= "" and then Switches (Switches'First) = '*' then -- Always prepend the switch character, so that users know -- that this comes from a switch on the command line. This -- is especially important when Concatenate is False, since -- otherwise the current argument first character is lost. if Parser.Section (Parser.Current_Argument) = 0 then -- A section transition should not be returned to the user Dummy := Goto_Next_Argument_In_Section (Parser); goto Restart; else Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, Last => Arg'Last, Extra => Parser.Switch_Character); Parser.Is_Switch (Parser.Current_Argument) := True; Dummy := Goto_Next_Argument_In_Section (Parser); return '*'; end if; end if; if Parser.Current_Index = Arg'First then Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, Last => End_Index); else Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, Last => End_Index, Extra => Parser.Switch_Character); end if; Parser.Current_Index := End_Index + 1; raise Invalid_Switch with "Unrecognized option '" & Full_Switch (Parser) & '''; end if; End_Index := Parser.Current_Index + Max_Length - 1; Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, Last => End_Index); case Param is when Parameter_With_Optional_Space => if End_Index < Arg'Last then Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => End_Index + 1, Last => Arg'Last); Dummy := Goto_Next_Argument_In_Section (Parser); elsif Parser.Current_Argument < Parser.Arg_Count and then Parser.Section (Parser.Current_Argument + 1) /= 0 then Parser.Current_Argument := Parser.Current_Argument + 1; Parser.The_Separator := ' '; Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => Argument (Parser, Parser.Current_Argument)'First, Last => Argument (Parser, Parser.Current_Argument)'Last); Parser.Is_Switch (Parser.Current_Argument) := True; Dummy := Goto_Next_Argument_In_Section (Parser); else Parser.Current_Index := End_Index + 1; raise Invalid_Parameter; end if; when Parameter_With_Space_Or_Equal => -- If the switch is of the form <switch>=xxx if End_Index < Arg'Last then if Arg (End_Index + 1) = '=' and then End_Index + 1 < Arg'Last then Parser.The_Separator := '='; Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => End_Index + 2, Last => Arg'Last); Dummy := Goto_Next_Argument_In_Section (Parser); else Parser.Current_Index := End_Index + 1; raise Invalid_Parameter; end if; -- Case of switch of the form <switch> xxx elsif Parser.Current_Argument < Parser.Arg_Count and then Parser.Section (Parser.Current_Argument + 1) /= 0 then Parser.Current_Argument := Parser.Current_Argument + 1; Parser.The_Separator := ' '; Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => Argument (Parser, Parser.Current_Argument)'First, Last => Argument (Parser, Parser.Current_Argument)'Last); Parser.Is_Switch (Parser.Current_Argument) := True; Dummy := Goto_Next_Argument_In_Section (Parser); else Parser.Current_Index := End_Index + 1; raise Invalid_Parameter; end if; when Parameter_No_Space => if End_Index < Arg'Last then Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => End_Index + 1, Last => Arg'Last); Dummy := Goto_Next_Argument_In_Section (Parser); else Parser.Current_Index := End_Index + 1; raise Invalid_Parameter; end if; when Parameter_Optional => if End_Index < Arg'Last then Set_Parameter (Parser.The_Parameter, Arg_Num => Parser.Current_Argument, First => End_Index + 1, Last => Arg'Last); end if; Dummy := Goto_Next_Argument_In_Section (Parser); when Parameter_None => if Concatenate or else End_Index = Arg'Last then Parser.Current_Index := End_Index + 1; else -- If Concatenate is False and the full argument is not -- recognized as a switch, this is an invalid switch. if Switches (Switches'First) = '*' then Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Arg'First, Last => Arg'Last); Parser.Is_Switch (Parser.Current_Argument) := True; Dummy := Goto_Next_Argument_In_Section (Parser); return '*'; end if; Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, Last => Arg'Last, Extra => Parser.Switch_Character); Parser.Current_Index := Arg'Last + 1; raise Invalid_Switch with "Unrecognized option '" & Full_Switch (Parser) & '''; end if; end case; return Switches (Index_Switches); end; end Getopt; ----------------------------------- -- Goto_Next_Argument_In_Section -- ----------------------------------- function Goto_Next_Argument_In_Section (Parser : Opt_Parser) return Boolean is begin Parser.Current_Argument := Parser.Current_Argument + 1; if Parser.Current_Argument > Parser.Arg_Count or else Parser.Section (Parser.Current_Argument) = 0 then loop Parser.Current_Argument := Parser.Current_Argument + 1; if Parser.Current_Argument > Parser.Arg_Count then Parser.Current_Index := 1; return False; end if; exit when Parser.Section (Parser.Current_Argument) = Parser.Current_Section; end loop; end if; Parser.Current_Index := Argument (Parser, Parser.Current_Argument)'First; return True; end Goto_Next_Argument_In_Section; ------------------ -- Goto_Section -- ------------------ procedure Goto_Section (Name : String := ""; Parser : Opt_Parser := Command_Line_Parser) is Index : Integer; begin Parser.In_Expansion := False; if Name = "" then Parser.Current_Argument := 1; Parser.Current_Index := 1; Parser.Current_Section := 1; return; end if; Index := 1; while Index <= Parser.Arg_Count loop if Parser.Section (Index) = 0 and then Argument (Parser, Index) = Parser.Switch_Character & Name then Parser.Current_Argument := Index + 1; Parser.Current_Index := 1; if Parser.Current_Argument <= Parser.Arg_Count then Parser.Current_Section := Parser.Section (Parser.Current_Argument); end if; -- Exit from loop if we have the start of another section if Index = Parser.Section'Last or else Parser.Section (Index + 1) /= 0 then return; end if; end if; Index := Index + 1; end loop; Parser.Current_Argument := Positive'Last; Parser.Current_Index := 2; -- so that Get_Argument returns nothing end Goto_Section; ---------------------------- -- Initialize_Option_Scan -- ---------------------------- procedure Initialize_Option_Scan (Switch_Char : Character := '-'; Stop_At_First_Non_Switch : Boolean := False; Section_Delimiters : String := "") is begin Internal_Initialize_Option_Scan (Parser => Command_Line_Parser, Switch_Char => Switch_Char, Stop_At_First_Non_Switch => Stop_At_First_Non_Switch, Section_Delimiters => Section_Delimiters); end Initialize_Option_Scan; ---------------------------- -- Initialize_Option_Scan -- ---------------------------- procedure Initialize_Option_Scan (Parser : out Opt_Parser; Command_Line : GNAT.OS_Lib.Argument_List_Access; Switch_Char : Character := '-'; Stop_At_First_Non_Switch : Boolean := False; Section_Delimiters : String := "") is begin Free (Parser); if Command_Line = null then Parser := new Opt_Parser_Data (CL.Argument_Count); Internal_Initialize_Option_Scan (Parser => Parser, Switch_Char => Switch_Char, Stop_At_First_Non_Switch => Stop_At_First_Non_Switch, Section_Delimiters => Section_Delimiters); else Parser := new Opt_Parser_Data (Command_Line'Length); Parser.Arguments := Command_Line; Internal_Initialize_Option_Scan (Parser => Parser, Switch_Char => Switch_Char, Stop_At_First_Non_Switch => Stop_At_First_Non_Switch, Section_Delimiters => Section_Delimiters); end if; end Initialize_Option_Scan; ------------------------------------- -- Internal_Initialize_Option_Scan -- ------------------------------------- procedure Internal_Initialize_Option_Scan (Parser : Opt_Parser; Switch_Char : Character; Stop_At_First_Non_Switch : Boolean; Section_Delimiters : String) is Section_Num : Section_Number; Section_Index : Integer; Last : Integer; Delimiter_Found : Boolean; Discard : Boolean; pragma Warnings (Off, Discard); begin Parser.Current_Argument := 0; Parser.Current_Index := 0; Parser.In_Expansion := False; Parser.Switch_Character := Switch_Char; Parser.Stop_At_First := Stop_At_First_Non_Switch; Parser.Section := [others => 1]; -- If we are using sections, we have to preprocess the command line to -- delimit them. A section can be repeated, so we just give each item -- on the command line a section number Section_Num := 1; Section_Index := Section_Delimiters'First; while Section_Index <= Section_Delimiters'Last loop Last := Section_Index; while Last <= Section_Delimiters'Last and then Section_Delimiters (Last) /= ' ' loop Last := Last + 1; end loop; Delimiter_Found := False; Section_Num := Section_Num + 1; for Index in 1 .. Parser.Arg_Count loop pragma Assert (Argument (Parser, Index)'First = 1); if Argument (Parser, Index) /= "" and then Argument (Parser, Index)(1) = Parser.Switch_Character and then Argument (Parser, Index) = Parser.Switch_Character & Section_Delimiters (Section_Index .. Last - 1) then Parser.Section (Index) := 0; Delimiter_Found := True; elsif Parser.Section (Index) = 0 then -- A previous section delimiter Delimiter_Found := False; elsif Delimiter_Found then Parser.Section (Index) := Section_Num; end if; end loop; Section_Index := Last + 1; while Section_Index <= Section_Delimiters'Last and then Section_Delimiters (Section_Index) = ' ' loop Section_Index := Section_Index + 1; end loop; end loop; Discard := Goto_Next_Argument_In_Section (Parser); end Internal_Initialize_Option_Scan; --------------- -- Parameter -- --------------- function Parameter (Parser : Opt_Parser := Command_Line_Parser) return String is begin if Parser.The_Parameter.First > Parser.The_Parameter.Last then return String'(1 .. 0 => ' '); else return Argument (Parser, Parser.The_Parameter.Arg_Num) (Parser.The_Parameter.First .. Parser.The_Parameter.Last); end if; end Parameter; --------------- -- Separator -- --------------- function Separator (Parser : Opt_Parser := Command_Line_Parser) return Character is begin return Parser.The_Separator; end Separator; ------------------- -- Set_Parameter -- ------------------- procedure Set_Parameter (Variable : out Parameter_Type; Arg_Num : Positive; First : Positive; Last : Natural; Extra : Character := ASCII.NUL) is begin Variable.Arg_Num := Arg_Num; Variable.First := First; Variable.Last := Last; Variable.Extra := Extra; end Set_Parameter; --------------------- -- Start_Expansion -- --------------------- procedure Start_Expansion (Iterator : out Expansion_Iterator; Pattern : String; Directory : String := ""; Basic_Regexp : Boolean := True) is Directory_Separator : Character; pragma Import (C, Directory_Separator, "__gnat_dir_separator"); First : Positive := Pattern'First; Pat : String := Pattern; begin Canonical_Case_File_Name (Pat); Iterator.Current_Depth := 1; -- If Directory is unspecified, use the current directory ("./" or ".\") if Directory = "" then Iterator.Dir_Name (1 .. 2) := "." & Directory_Separator; Iterator.Start := 3; else Iterator.Dir_Name (1 .. Directory'Length) := Directory; Iterator.Start := Directory'Length + 1; Canonical_Case_File_Name (Iterator.Dir_Name (1 .. Directory'Length)); -- Make sure that the last character is a directory separator if Directory (Directory'Last) /= Directory_Separator then Iterator.Dir_Name (Iterator.Start) := Directory_Separator; Iterator.Start := Iterator.Start + 1; end if; end if; Iterator.Levels (1).Name_Last := Iterator.Start - 1; -- Open the initial Directory, at depth 1 GNAT.Directory_Operations.Open (Iterator.Levels (1).Dir, Iterator.Dir_Name (1 .. Iterator.Start - 1)); -- If in the current directory and the pattern starts with "./" or ".\", -- drop the "./" or ".\" from the pattern. if Directory = "" and then Pat'Length > 2 and then Pat (Pat'First) = '.' and then Pat (Pat'First + 1) = Directory_Separator then First := Pat'First + 2; end if; Iterator.Regexp := GNAT.Regexp.Compile (Pat (First .. Pat'Last), Basic_Regexp, True); Iterator.Maximum_Depth := 1; -- Maximum_Depth is equal to 1 plus the number of directory separators -- in the pattern. for Index in First .. Pat'Last loop if Pat (Index) = Directory_Separator then Iterator.Maximum_Depth := Iterator.Maximum_Depth + 1; exit when Iterator.Maximum_Depth = Max_Depth; end if; end loop; end Start_Expansion; ---------- -- Free -- ---------- procedure Free (Parser : in out Opt_Parser) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Opt_Parser_Data, Opt_Parser); begin if Parser /= null and then Parser /= Command_Line_Parser then Free (Parser.Arguments); Unchecked_Free (Parser); end if; end Free; ------------------ -- Define_Alias -- ------------------ procedure Define_Alias (Config : in out Command_Line_Configuration; Switch : String; Expanded : String; Section : String := "") is Def : Alias_Definition; begin if Config = null then Config := new Command_Line_Configuration_Record; end if; Def.Alias := new String'(Switch); Def.Expansion := new String'(Expanded); Def.Section := new String'(Section); Add (Config.Aliases, Def); end Define_Alias; ------------------- -- Define_Prefix -- ------------------- procedure Define_Prefix (Config : in out Command_Line_Configuration; Prefix : String) is begin if Config = null then Config := new Command_Line_Configuration_Record; end if; Add (Config.Prefixes, new String'(Prefix)); end Define_Prefix; --------- -- Add -- --------- procedure Add (Config : in out Command_Line_Configuration; Switch : Switch_Definition) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Switch_Definitions, Switch_Definitions_List); Tmp : Switch_Definitions_List; begin if Config = null then Config := new Command_Line_Configuration_Record; end if; Tmp := Config.Switches; if Tmp = null then Config.Switches := new Switch_Definitions (1 .. 1); else Config.Switches := new Switch_Definitions (1 .. Tmp'Length + 1); Config.Switches (1 .. Tmp'Length) := Tmp.all; Unchecked_Free (Tmp); end if; if Switch.Switch /= null and then Switch.Switch.all = "*" then Config.Star_Switch := True; end if; Config.Switches (Config.Switches'Last) := Switch; end Add; --------- -- Add -- --------- procedure Add (Def : in out Alias_Definitions_List; Alias : Alias_Definition) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Alias_Definitions, Alias_Definitions_List); Tmp : Alias_Definitions_List := Def; begin if Tmp = null then Def := new Alias_Definitions (1 .. 1); else Def := new Alias_Definitions (1 .. Tmp'Length + 1); Def (1 .. Tmp'Length) := Tmp.all; Unchecked_Free (Tmp); end if; Def (Def'Last) := Alias; end Add; --------------------------- -- Initialize_Switch_Def -- --------------------------- procedure Initialize_Switch_Def (Def : out Switch_Definition; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG") is P1, P2 : Switch_Parameter_Type := Parameter_None; Last1, Last2 : Integer; begin if Switch /= "" then Def.Switch := new String'(Switch); Decompose_Switch (Switch, P1, Last1); end if; if Long_Switch /= "" then Def.Long_Switch := new String'(Long_Switch); Decompose_Switch (Long_Switch, P2, Last2); end if; if Switch /= "" and then Long_Switch /= "" then if (P1 = Parameter_None and then P2 /= P1) or else (P2 = Parameter_None and then P1 /= P2) or else (P1 = Parameter_Optional and then P2 /= P1) or else (P2 = Parameter_Optional and then P2 /= P1) then raise Invalid_Switch with "Inconsistent parameter types for " & Switch & " and " & Long_Switch; end if; end if; if Section /= "" then Def.Section := new String'(Section); end if; if Argument /= "ARG" then Def.Argument := new String'(Argument); end if; if Help /= "" then Def.Help := new String'(Help); end if; end Initialize_Switch_Def; ------------------- -- Define_Switch -- ------------------- procedure Define_Switch (Config : in out Command_Line_Configuration; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG") is Def : Switch_Definition; begin if Switch /= "" or else Long_Switch /= "" then Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section, Argument); Add (Config, Def); end if; end Define_Switch; ------------------- -- Define_Switch -- ------------------- procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access Boolean; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Value : Boolean := True) is Def : Switch_Definition (Switch_Boolean); begin if Switch /= "" or else Long_Switch /= "" then Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section); Def.Boolean_Output := Output.all'Unchecked_Access; Def.Boolean_Value := Value; Add (Config, Def); end if; end Define_Switch; ------------------- -- Define_Switch -- ------------------- procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access Integer; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Initial : Integer := 0; Default : Integer := 1; Argument : String := "ARG") is Def : Switch_Definition (Switch_Integer); begin if Switch /= "" or else Long_Switch /= "" then Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section, Argument); Def.Integer_Output := Output.all'Unchecked_Access; Def.Integer_Default := Default; Def.Integer_Initial := Initial; Add (Config, Def); end if; end Define_Switch; ------------------- -- Define_Switch -- ------------------- procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access GNAT.Strings.String_Access; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG") is Def : Switch_Definition (Switch_String); begin if Switch /= "" or else Long_Switch /= "" then Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section, Argument); Def.String_Output := Output.all'Unchecked_Access; Add (Config, Def); end if; end Define_Switch; ------------------- -- Define_Switch -- ------------------- procedure Define_Switch (Config : in out Command_Line_Configuration; Callback : not null Value_Callback; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG") is Def : Switch_Definition (Switch_Callback); begin if Switch /= "" or else Long_Switch /= "" then Initialize_Switch_Def (Def, Switch, Long_Switch, Help, Section, Argument); Def.Callback := Callback; Add (Config, Def); end if; end Define_Switch; -------------------- -- Define_Section -- -------------------- procedure Define_Section (Config : in out Command_Line_Configuration; Section : String) is begin if Config = null then Config := new Command_Line_Configuration_Record; end if; Add (Config.Sections, new String'(Section)); end Define_Section; -------------------- -- Foreach_Switch -- -------------------- procedure Foreach_Switch (Config : Command_Line_Configuration; Section : String) is begin if Config /= null and then Config.Switches /= null then for J in Config.Switches'Range loop if (Section = "" and then Config.Switches (J).Section = null) or else (Config.Switches (J).Section /= null and then Config.Switches (J).Section.all = Section) then exit when Config.Switches (J).Switch /= null and then not Callback (Config.Switches (J).Switch.all, J); exit when Config.Switches (J).Long_Switch /= null and then not Callback (Config.Switches (J).Long_Switch.all, J); end if; end loop; end if; end Foreach_Switch; ------------------ -- Get_Switches -- ------------------ function Get_Switches (Config : Command_Line_Configuration; Switch_Char : Character := '-'; Section : String := "") return String is Ret : Ada.Strings.Unbounded.Unbounded_String; use Ada.Strings.Unbounded; function Add_Switch (S : String; Index : Integer) return Boolean; -- Add a switch to Ret ---------------- -- Add_Switch -- ---------------- function Add_Switch (S : String; Index : Integer) return Boolean is pragma Unreferenced (Index); begin if S = "*" then Ret := "*" & Ret; -- Always first elsif S (S'First) = Switch_Char then Append (Ret, " " & S (S'First + 1 .. S'Last)); else Append (Ret, " " & S); end if; return True; end Add_Switch; Tmp : Boolean; pragma Unreferenced (Tmp); procedure Foreach is new Foreach_Switch (Add_Switch); -- Start of processing for Get_Switches begin if Config = null then return ""; end if; Foreach (Config, Section => Section); -- Add relevant aliases if Config.Aliases /= null then for A in Config.Aliases'Range loop if Config.Aliases (A).Section.all = Section then Tmp := Add_Switch (Config.Aliases (A).Alias.all, -1); end if; end loop; end if; return To_String (Ret); end Get_Switches; ------------------------ -- Section_Delimiters -- ------------------------ function Section_Delimiters (Config : Command_Line_Configuration) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; begin if Config /= null and then Config.Sections /= null then for S in Config.Sections'Range loop Append (Result, " " & Config.Sections (S).all); end loop; end if; return To_String (Result); end Section_Delimiters; ----------------------- -- Set_Configuration -- ----------------------- procedure Set_Configuration (Cmd : in out Command_Line; Config : Command_Line_Configuration) is begin Cmd.Config := Config; end Set_Configuration; ----------------------- -- Get_Configuration -- ----------------------- function Get_Configuration (Cmd : Command_Line) return Command_Line_Configuration is begin return Cmd.Config; end Get_Configuration; ---------------------- -- Set_Command_Line -- ---------------------- procedure Set_Command_Line (Cmd : in out Command_Line; Switches : String; Getopt_Description : String := ""; Switch_Char : Character := '-') is Tmp : Argument_List_Access; Parser : Opt_Parser; S : Character; Section : String_Access := null; function Real_Full_Switch (S : Character; Parser : Opt_Parser) return String; -- Ensure that the returned switch value contains the Switch_Char prefix -- if needed. ---------------------- -- Real_Full_Switch -- ---------------------- function Real_Full_Switch (S : Character; Parser : Opt_Parser) return String is begin if S = '*' then return Full_Switch (Parser); else return Switch_Char & Full_Switch (Parser); end if; end Real_Full_Switch; -- Start of processing for Set_Command_Line begin Free (Cmd.Expanded); Free (Cmd.Params); if Switches /= "" then Tmp := Argument_String_To_List (Switches); Initialize_Option_Scan (Parser, Tmp, Switch_Char); loop begin if Cmd.Config /= null then -- Do not use Getopt_Description in this case. Otherwise, -- if we have defined a prefix -gnaty, and two switches -- -gnatya and -gnatyL!, we would have a different behavior -- depending on the order of switches: -- -gnatyL1a => -gnatyL with argument "1a" -- -gnatyaL1 => -gnatya and -gnatyL with argument "1" -- This is because the call to Getopt below knows nothing -- about prefixes, and in the first case finds a valid -- switch with arguments, so returns it without analyzing -- the argument. In the second case, the switch matches "*", -- and is then decomposed below. -- Note: When a Command_Line object is associated with a -- Command_Line_Config (which is mostly the case for tools -- that let users choose the command line before spawning -- other tools, for instance IDEs), the configuration of -- the switches must be taken from the Command_Line_Config. S := Getopt (Switches => "* " & Get_Switches (Cmd.Config), Concatenate => False, Parser => Parser); else S := Getopt (Switches => "* " & Getopt_Description, Concatenate => False, Parser => Parser); end if; exit when S = ASCII.NUL; declare Sw : constant String := Real_Full_Switch (S, Parser); Is_Section : Boolean := False; begin if Cmd.Config /= null and then Cmd.Config.Sections /= null then Section_Search : for S in Cmd.Config.Sections'Range loop if Sw = Cmd.Config.Sections (S).all then Section := Cmd.Config.Sections (S); Is_Section := True; exit Section_Search; end if; end loop Section_Search; end if; if not Is_Section then if Section = null then Add_Switch (Cmd, Sw, Parameter (Parser)); else Add_Switch (Cmd, Sw, Parameter (Parser), Section => Section.all); end if; end if; end; exception when Invalid_Parameter => -- Add it with no parameter, if that's the way the user -- wants it. -- Specify the separator in all cases, as the switch might -- need to be unaliased, and the alias might contain -- switches with parameters. if Section = null then Add_Switch (Cmd, Switch_Char & Full_Switch (Parser)); else Add_Switch (Cmd, Switch_Char & Full_Switch (Parser), Section => Section.all); end if; end; end loop; Free (Parser); end if; end Set_Command_Line; ---------------- -- Looking_At -- ---------------- function Looking_At (Type_Str : String; Index : Natural; Substring : String) return Boolean is begin return Index + Substring'Length - 1 <= Type_Str'Last and then Type_Str (Index .. Index + Substring'Length - 1) = Substring; end Looking_At; ------------------------ -- Can_Have_Parameter -- ------------------------ function Can_Have_Parameter (S : String) return Boolean is begin if S'Length <= 1 then return False; end if; case S (S'Last) is when '!' | ':' | '?' | '=' => return True; when others => return False; end case; end Can_Have_Parameter; ----------------------- -- Require_Parameter -- ----------------------- function Require_Parameter (S : String) return Boolean is begin if S'Length <= 1 then return False; end if; case S (S'Last) is when '!' | ':' | '=' => return True; when others => return False; end case; end Require_Parameter; ------------------- -- Actual_Switch -- ------------------- function Actual_Switch (S : String) return String is begin if S'Length <= 1 then return S; end if; case S (S'Last) is when '!' | ':' | '?' | '=' => return S (S'First .. S'Last - 1); when others => return S; end case; end Actual_Switch; ---------------------------- -- For_Each_Simple_Switch -- ---------------------------- procedure For_Each_Simple_Switch (Config : Command_Line_Configuration; Section : String; Switch : String; Parameter : String := ""; Unalias : Boolean := True) is function Group_Analysis (Prefix : String; Group : String) return Boolean; -- Perform the analysis of a group of switches Found_In_Config : Boolean := False; function Is_In_Config (Config_Switch : String; Index : Integer) return Boolean; -- If Switch is the same as Config_Switch, run the callback and sets -- Found_In_Config to True. function Starts_With (Config_Switch : String; Index : Integer) return Boolean; -- if Switch starts with Config_Switch, sets Found_In_Config to True. -- The return value is for the Foreach_Switch iterator. -------------------- -- Group_Analysis -- -------------------- function Group_Analysis (Prefix : String; Group : String) return Boolean is Idx : Natural; Found : Boolean; function Analyze_Simple_Switch (Switch : String; Index : Integer) return Boolean; -- "Switches" is one of the switch definitions passed to the -- configuration, not one of the switches found on the command line. --------------------------- -- Analyze_Simple_Switch -- --------------------------- function Analyze_Simple_Switch (Switch : String; Index : Integer) return Boolean is pragma Unreferenced (Index); Full : constant String := Prefix & Group (Idx .. Group'Last); Sw : constant String := Actual_Switch (Switch); -- Switches definition minus argument definition Last : Natural; Param : Natural; begin -- Verify that sw starts with Prefix if Looking_At (Sw, Sw'First, Prefix) -- Verify that the group starts with sw and then Looking_At (Full, Full'First, Sw) then Last := Idx + Sw'Length - Prefix'Length - 1; Param := Last + 1; if Can_Have_Parameter (Switch) then -- Include potential parameter to the recursive call. Only -- numbers are allowed. while Last < Group'Last and then Group (Last + 1) in '0' .. '9' loop Last := Last + 1; end loop; end if; if not Require_Parameter (Switch) or else Last >= Param then if Idx = Group'First and then Last = Group'Last and then Last < Param then -- The group only concerns a single switch. Do not -- perform recursive call. -- Note that we still perform a recursive call if -- a parameter is detected in the switch, as this -- is a way to correctly identify such a parameter -- in aliases. return False; end if; Found := True; -- Recursive call, using the detected parameter if any if Last >= Param then For_Each_Simple_Switch (Config, Section, Prefix & Group (Idx .. Param - 1), Group (Param .. Last)); else For_Each_Simple_Switch (Config, Section, Prefix & Group (Idx .. Last), ""); end if; Idx := Last + 1; return False; end if; end if; return True; end Analyze_Simple_Switch; procedure Foreach is new Foreach_Switch (Analyze_Simple_Switch); -- Start of processing for Group_Analysis begin Idx := Group'First; while Idx <= Group'Last loop Found := False; Foreach (Config, Section); if not Found then For_Each_Simple_Switch (Config, Section, Prefix & Group (Idx), ""); Idx := Idx + 1; end if; end loop; return True; end Group_Analysis; ------------------ -- Is_In_Config -- ------------------ function Is_In_Config (Config_Switch : String; Index : Integer) return Boolean is Last : Natural; P : Switch_Parameter_Type; begin Decompose_Switch (Config_Switch, P, Last); if Config_Switch (Config_Switch'First .. Last) = Switch then case P is when Parameter_None => if Parameter = "" then Callback (Switch, "", "", Index => Index); Found_In_Config := True; return False; end if; when Parameter_With_Optional_Space => Callback (Switch, " ", Parameter, Index => Index); Found_In_Config := True; return False; when Parameter_With_Space_Or_Equal => Callback (Switch, "=", Parameter, Index => Index); Found_In_Config := True; return False; when Parameter_No_Space | Parameter_Optional => Callback (Switch, "", Parameter, Index); Found_In_Config := True; return False; end case; end if; return True; end Is_In_Config; ----------------- -- Starts_With -- ----------------- function Starts_With (Config_Switch : String; Index : Integer) return Boolean is Last : Natural; Param : Natural; P : Switch_Parameter_Type; begin -- This function is called when we believe the parameter was -- specified as part of the switch, instead of separately. Thus we -- look in the config to find all possible switches. Decompose_Switch (Config_Switch, P, Last); if Looking_At (Switch, Switch'First, Config_Switch (Config_Switch'First .. Last)) then -- Set first char of Param, and last char of Switch Param := Switch'First + Last; Last := Switch'First + Last - Config_Switch'First; case P is -- None is already handled in Is_In_Config when Parameter_None => null; when Parameter_With_Space_Or_Equal => if Param <= Switch'Last and then (Switch (Param) = ' ' or else Switch (Param) = '=') then Callback (Switch (Switch'First .. Last), "=", Switch (Param + 1 .. Switch'Last), Index); Found_In_Config := True; return False; end if; when Parameter_With_Optional_Space => if Param <= Switch'Last and then Switch (Param) = ' ' then Param := Param + 1; end if; Callback (Switch (Switch'First .. Last), " ", Switch (Param .. Switch'Last), Index); Found_In_Config := True; return False; when Parameter_No_Space | Parameter_Optional => Callback (Switch (Switch'First .. Last), "", Switch (Param .. Switch'Last), Index); Found_In_Config := True; return False; end case; end if; return True; end Starts_With; procedure Foreach_In_Config is new Foreach_Switch (Is_In_Config); procedure Foreach_Starts_With is new Foreach_Switch (Starts_With); -- Start of processing for For_Each_Simple_Switch begin -- First determine if the switch corresponds to one belonging to the -- configuration. If so, run callback and exit. -- ??? Is this necessary. On simple tests, we seem to have the same -- results with or without this call. Foreach_In_Config (Config, Section); if Found_In_Config then return; end if; -- If adding a switch that can in fact be expanded through aliases, -- add separately each of its expansions. -- This takes care of expansions like "-T" -> "-gnatwrs", where the -- alias and its expansion do not have the same prefix. Given the order -- in which we do things here, the expansion of the alias will itself -- be checked for a common prefix and split into simple switches. if Unalias and then Config /= null and then Config.Aliases /= null then for A in Config.Aliases'Range loop if Config.Aliases (A).Section.all = Section and then Config.Aliases (A).Alias.all = Switch and then Parameter = "" then For_Each_Simple_Switch (Config, Section, Config.Aliases (A).Expansion.all, ""); return; end if; end loop; end if; -- If adding a switch grouping several switches, add each of the simple -- switches instead. if Config /= null and then Config.Prefixes /= null then for P in Config.Prefixes'Range loop if Switch'Length > Config.Prefixes (P)'Length + 1 and then Looking_At (Switch, Switch'First, Config.Prefixes (P).all) then -- Alias expansion will be done recursively if Config.Switches = null then for S in Switch'First + Config.Prefixes (P)'Length .. Switch'Last loop For_Each_Simple_Switch (Config, Section, Config.Prefixes (P).all & Switch (S), ""); end loop; return; elsif Group_Analysis (Config.Prefixes (P).all, Switch (Switch'First + Config.Prefixes (P)'Length .. Switch'Last)) then -- Recursive calls already done on each switch of the group: -- Return without executing Callback. return; end if; end if; end loop; end if; -- Test if added switch is a known switch with parameter attached -- instead of being specified separately if Parameter = "" and then Config /= null and then Config.Switches /= null then Found_In_Config := False; Foreach_Starts_With (Config, Section); if Found_In_Config then return; end if; end if; -- The switch is invalid in the config, but we still want to report it. -- The config could, for instance, include "*" to specify it accepts -- all switches. Callback (Switch, " ", Parameter, Index => -1); end For_Each_Simple_Switch; ---------------- -- Add_Switch -- ---------------- procedure Add_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String := ""; Separator : Character := ASCII.NUL; Section : String := ""; Add_Before : Boolean := False) is Success : Boolean; begin Add_Switch (Cmd, Switch, Parameter, Separator, Section, Add_Before, Success); end Add_Switch; ---------------- -- Add_Switch -- ---------------- procedure Add_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String := ""; Separator : Character := ASCII.NUL; Section : String := ""; Add_Before : Boolean := False; Success : out Boolean) is procedure Add_Simple_Switch (Simple : String; Sepa : String; Param : String; Index : Integer); -- Add a new switch that has had all its aliases expanded, and switches -- ungrouped. We know there are no more aliases in Switches. ----------------------- -- Add_Simple_Switch -- ----------------------- procedure Add_Simple_Switch (Simple : String; Sepa : String; Param : String; Index : Integer) is Sep : Character; begin if Index = -1 and then Cmd.Config /= null and then not Cmd.Config.Star_Switch then raise Invalid_Switch with "Invalid switch " & Simple; end if; if Separator /= ASCII.NUL then Sep := Separator; elsif Sepa = "" then Sep := ASCII.NUL; else Sep := Sepa (Sepa'First); end if; if Cmd.Expanded = null then Cmd.Expanded := new Argument_List'(1 .. 1 => new String'(Simple)); if Param /= "" then Cmd.Params := new Argument_List'(1 .. 1 => new String'(Sep & Param)); else Cmd.Params := new Argument_List'(1 .. 1 => null); end if; if Section = "" then Cmd.Sections := new Argument_List'(1 .. 1 => null); else Cmd.Sections := new Argument_List'(1 .. 1 => new String'(Section)); end if; else -- Do we already have this switch? for C in Cmd.Expanded'Range loop if Cmd.Expanded (C).all = Simple and then ((Cmd.Params (C) = null and then Param = "") or else (Cmd.Params (C) /= null and then Cmd.Params (C).all = Sep & Param)) and then ((Cmd.Sections (C) = null and then Section = "") or else (Cmd.Sections (C) /= null and then Cmd.Sections (C).all = Section)) then return; end if; end loop; -- Inserting at least one switch Success := True; Add (Cmd.Expanded, new String'(Simple), Add_Before); if Param /= "" then Add (Cmd.Params, new String'(Sep & Param), Add_Before); else Add (Cmd.Params, null, Add_Before); end if; if Section = "" then Add (Cmd.Sections, null, Add_Before); else Add (Cmd.Sections, new String'(Section), Add_Before); end if; end if; end Add_Simple_Switch; procedure Add_Simple_Switches is new For_Each_Simple_Switch (Add_Simple_Switch); -- Local Variables Section_Valid : Boolean := False; -- Start of processing for Add_Switch begin if Section /= "" and then Cmd.Config /= null then for S in Cmd.Config.Sections'Range loop if Section = Cmd.Config.Sections (S).all then Section_Valid := True; exit; end if; end loop; if not Section_Valid then raise Invalid_Section; end if; end if; Success := False; Add_Simple_Switches (Cmd.Config, Section, Switch, Parameter); Free (Cmd.Coalesce); end Add_Switch; ------------ -- Remove -- ------------ procedure Remove (Line : in out Argument_List_Access; Index : Integer) is Tmp : Argument_List_Access := Line; begin Line := new Argument_List (Tmp'First .. Tmp'Last - 1); if Index /= Tmp'First then Line (Tmp'First .. Index - 1) := Tmp (Tmp'First .. Index - 1); end if; Free (Tmp (Index)); if Index /= Tmp'Last then Line (Index .. Tmp'Last - 1) := Tmp (Index + 1 .. Tmp'Last); end if; Unchecked_Free (Tmp); end Remove; --------- -- Add -- --------- procedure Add (Line : in out Argument_List_Access; Str : String_Access; Before : Boolean := False) is Tmp : Argument_List_Access := Line; begin if Tmp /= null then Line := new Argument_List (Tmp'First .. Tmp'Last + 1); if Before then Line (Tmp'First) := Str; Line (Tmp'First + 1 .. Tmp'Last + 1) := Tmp.all; else Line (Tmp'Range) := Tmp.all; Line (Tmp'Last + 1) := Str; end if; Unchecked_Free (Tmp); else Line := new Argument_List'(1 .. 1 => Str); end if; end Add; ------------------- -- Remove_Switch -- ------------------- procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Remove_All : Boolean := False; Has_Parameter : Boolean := False; Section : String := "") is Success : Boolean; begin Remove_Switch (Cmd, Switch, Remove_All, Has_Parameter, Section, Success); end Remove_Switch; ------------------- -- Remove_Switch -- ------------------- procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Remove_All : Boolean := False; Has_Parameter : Boolean := False; Section : String := ""; Success : out Boolean) is procedure Remove_Simple_Switch (Simple, Separator, Param : String; Index : Integer); -- Removes a simple switch, with no aliasing or grouping -------------------------- -- Remove_Simple_Switch -- -------------------------- procedure Remove_Simple_Switch (Simple, Separator, Param : String; Index : Integer) is C : Integer; pragma Unreferenced (Param, Separator, Index); begin if Cmd.Expanded /= null then C := Cmd.Expanded'First; while C <= Cmd.Expanded'Last loop if Cmd.Expanded (C).all = Simple and then (Remove_All or else (Cmd.Sections (C) = null and then Section = "") or else (Cmd.Sections (C) /= null and then Section = Cmd.Sections (C).all)) and then (not Has_Parameter or else Cmd.Params (C) /= null) then Remove (Cmd.Expanded, C); Remove (Cmd.Params, C); Remove (Cmd.Sections, C); Success := True; if not Remove_All then return; end if; else C := C + 1; end if; end loop; end if; end Remove_Simple_Switch; procedure Remove_Simple_Switches is new For_Each_Simple_Switch (Remove_Simple_Switch); -- Start of processing for Remove_Switch begin Success := False; Remove_Simple_Switches (Cmd.Config, Section, Switch, "", Unalias => not Has_Parameter); Free (Cmd.Coalesce); end Remove_Switch; ------------------- -- Remove_Switch -- ------------------- procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String; Section : String := "") is procedure Remove_Simple_Switch (Simple, Separator, Param : String; Index : Integer); -- Removes a simple switch, with no aliasing or grouping -------------------------- -- Remove_Simple_Switch -- -------------------------- procedure Remove_Simple_Switch (Simple, Separator, Param : String; Index : Integer) is pragma Unreferenced (Separator, Index); C : Integer; begin if Cmd.Expanded /= null then C := Cmd.Expanded'First; while C <= Cmd.Expanded'Last loop if Cmd.Expanded (C).all = Simple and then ((Cmd.Sections (C) = null and then Section = "") or else (Cmd.Sections (C) /= null and then Section = Cmd.Sections (C).all)) and then ((Cmd.Params (C) = null and then Param = "") or else (Cmd.Params (C) /= null -- Ignore the separator stored in Parameter and then Cmd.Params (C) (Cmd.Params (C)'First + 1 .. Cmd.Params (C)'Last) = Param)) then Remove (Cmd.Expanded, C); Remove (Cmd.Params, C); Remove (Cmd.Sections, C); -- The switch is necessarily unique by construction of -- Add_Switch. return; else C := C + 1; end if; end loop; end if; end Remove_Simple_Switch; procedure Remove_Simple_Switches is new For_Each_Simple_Switch (Remove_Simple_Switch); -- Start of processing for Remove_Switch begin Remove_Simple_Switches (Cmd.Config, Section, Switch, Parameter); Free (Cmd.Coalesce); end Remove_Switch; -------------------- -- Group_Switches -- -------------------- procedure Group_Switches (Cmd : Command_Line; Result : Argument_List_Access; Sections : Argument_List_Access; Params : Argument_List_Access) is function Compatible_Parameter (Param : String_Access) return Boolean; -- True when the parameter can be part of a group -------------------------- -- Compatible_Parameter -- -------------------------- function Compatible_Parameter (Param : String_Access) return Boolean is begin -- No parameter OK if Param = null then return True; -- We need parameters without separators elsif Param (Param'First) /= ASCII.NUL then return False; -- Parameters must be all digits else for J in Param'First + 1 .. Param'Last loop if Param (J) not in '0' .. '9' then return False; end if; end loop; return True; end if; end Compatible_Parameter; -- Local declarations Group : Ada.Strings.Unbounded.Unbounded_String; First : Natural; use type Ada.Strings.Unbounded.Unbounded_String; -- Start of processing for Group_Switches begin if Cmd.Config = null or else Cmd.Config.Prefixes = null then return; end if; for P in Cmd.Config.Prefixes'Range loop Group := Ada.Strings.Unbounded.Null_Unbounded_String; First := 0; for C in Result'Range loop if Result (C) /= null and then Compatible_Parameter (Params (C)) and then Looking_At (Result (C).all, Result (C)'First, Cmd.Config.Prefixes (P).all) then -- If we are still in the same section, group the switches if First = 0 or else (Sections (C) = null and then Sections (First) = null) or else (Sections (C) /= null and then Sections (First) /= null and then Sections (C).all = Sections (First).all) then Group := Group & Result (C) (Result (C)'First + Cmd.Config.Prefixes (P)'Length .. Result (C)'Last); if Params (C) /= null then Group := Group & Params (C) (Params (C)'First + 1 .. Params (C)'Last); Free (Params (C)); end if; if First = 0 then First := C; end if; Free (Result (C)); -- We changed section: we put the grouped switches to the first -- place, on continue with the new section. else Result (First) := new String' (Cmd.Config.Prefixes (P).all & Ada.Strings.Unbounded.To_String (Group)); Group := Ada.Strings.Unbounded.To_Unbounded_String (Result (C) (Result (C)'First + Cmd.Config.Prefixes (P)'Length .. Result (C)'Last)); First := C; end if; end if; end loop; if First > 0 then Result (First) := new String' (Cmd.Config.Prefixes (P).all & Ada.Strings.Unbounded.To_String (Group)); end if; end loop; end Group_Switches; -------------------- -- Alias_Switches -- -------------------- procedure Alias_Switches (Cmd : Command_Line; Result : Argument_List_Access; Params : Argument_List_Access) is Found : Boolean; First : Natural; procedure Check_Cb (Switch, Separator, Param : String; Index : Integer); -- Checks whether the command line contains [Switch]. Sets the global -- variable [Found] appropriately. This is called for each simple switch -- that make up an alias, to know whether the alias should be applied. procedure Remove_Cb (Switch, Separator, Param : String; Index : Integer); -- Remove the simple switch [Switch] from the command line, since it is -- part of a simpler alias -------------- -- Check_Cb -- -------------- procedure Check_Cb (Switch, Separator, Param : String; Index : Integer) is pragma Unreferenced (Separator, Index); begin if Found then for E in Result'Range loop if Result (E) /= null and then (Params (E) = null or else Params (E) (Params (E)'First + 1 .. Params (E)'Last) = Param) and then Result (E).all = Switch then return; end if; end loop; Found := False; end if; end Check_Cb; --------------- -- Remove_Cb -- --------------- procedure Remove_Cb (Switch, Separator, Param : String; Index : Integer) is pragma Unreferenced (Separator, Index); begin for E in Result'Range loop if Result (E) /= null and then (Params (E) = null or else Params (E) (Params (E)'First + 1 .. Params (E)'Last) = Param) and then Result (E).all = Switch then if First > E then First := E; end if; Free (Result (E)); Free (Params (E)); return; end if; end loop; end Remove_Cb; procedure Check_All is new For_Each_Simple_Switch (Check_Cb); procedure Remove_All is new For_Each_Simple_Switch (Remove_Cb); -- Start of processing for Alias_Switches begin if Cmd.Config = null or else Cmd.Config.Aliases = null then return; end if; for A in Cmd.Config.Aliases'Range loop -- Compute the various simple switches that make up the alias. We -- split the expansion into as many simple switches as possible, and -- then check whether the expanded command line has all of them. Found := True; Check_All (Cmd.Config, Switch => Cmd.Config.Aliases (A).Expansion.all, Section => Cmd.Config.Aliases (A).Section.all); if Found then First := Integer'Last; Remove_All (Cmd.Config, Switch => Cmd.Config.Aliases (A).Expansion.all, Section => Cmd.Config.Aliases (A).Section.all); Result (First) := new String'(Cmd.Config.Aliases (A).Alias.all); end if; end loop; end Alias_Switches; ------------------- -- Sort_Sections -- ------------------- procedure Sort_Sections (Line : not null GNAT.OS_Lib.Argument_List_Access; Sections : GNAT.OS_Lib.Argument_List_Access; Params : GNAT.OS_Lib.Argument_List_Access) is Sections_List : Argument_List_Access := new Argument_List'(1 .. 1 => null); Found : Boolean; Old_Line : constant Argument_List := Line.all; Old_Sections : constant Argument_List := Sections.all; Old_Params : constant Argument_List := Params.all; Index : Natural; begin -- First construct a list of all sections for E in Line'Range loop if Sections (E) /= null then Found := False; for S in Sections_List'Range loop if (Sections_List (S) = null and then Sections (E) = null) or else (Sections_List (S) /= null and then Sections (E) /= null and then Sections_List (S).all = Sections (E).all) then Found := True; exit; end if; end loop; if not Found then Add (Sections_List, Sections (E)); end if; end if; end loop; Index := Line'First; for S in Sections_List'Range loop for E in Old_Line'Range loop if (Sections_List (S) = null and then Old_Sections (E) = null) or else (Sections_List (S) /= null and then Old_Sections (E) /= null and then Sections_List (S).all = Old_Sections (E).all) then Line (Index) := Old_Line (E); Sections (Index) := Old_Sections (E); Params (Index) := Old_Params (E); Index := Index + 1; end if; end loop; end loop; Unchecked_Free (Sections_List); end Sort_Sections; ----------- -- Start -- ----------- procedure Start (Cmd : in out Command_Line; Iter : in out Command_Line_Iterator; Expanded : Boolean := False) is begin if Cmd.Expanded = null then Iter.List := null; return; end if; -- Reorder the expanded line so that sections are grouped Sort_Sections (Cmd.Expanded, Cmd.Sections, Cmd.Params); -- Coalesce the switches as much as possible if not Expanded and then Cmd.Coalesce = null then Cmd.Coalesce := new Argument_List (Cmd.Expanded'Range); for E in Cmd.Expanded'Range loop Cmd.Coalesce (E) := new String'(Cmd.Expanded (E).all); end loop; Free (Cmd.Coalesce_Sections); Cmd.Coalesce_Sections := new Argument_List (Cmd.Sections'Range); for E in Cmd.Sections'Range loop Cmd.Coalesce_Sections (E) := (if Cmd.Sections (E) = null then null else new String'(Cmd.Sections (E).all)); end loop; Free (Cmd.Coalesce_Params); Cmd.Coalesce_Params := new Argument_List (Cmd.Params'Range); for E in Cmd.Params'Range loop Cmd.Coalesce_Params (E) := (if Cmd.Params (E) = null then null else new String'(Cmd.Params (E).all)); end loop; -- Not a clone, since we will not modify the parameters anyway Alias_Switches (Cmd, Cmd.Coalesce, Cmd.Coalesce_Params); Group_Switches (Cmd, Cmd.Coalesce, Cmd.Coalesce_Sections, Cmd.Coalesce_Params); end if; if Expanded then Iter.List := Cmd.Expanded; Iter.Params := Cmd.Params; Iter.Sections := Cmd.Sections; else Iter.List := Cmd.Coalesce; Iter.Params := Cmd.Coalesce_Params; Iter.Sections := Cmd.Coalesce_Sections; end if; if Iter.List = null then Iter.Current := Integer'Last; else Iter.Current := Iter.List'First - 1; Next (Iter); end if; end Start; -------------------- -- Current_Switch -- -------------------- function Current_Switch (Iter : Command_Line_Iterator) return String is begin return Iter.List (Iter.Current).all; end Current_Switch; -------------------- -- Is_New_Section -- -------------------- function Is_New_Section (Iter : Command_Line_Iterator) return Boolean is Section : constant String := Current_Section (Iter); begin if Iter.Sections = null then return False; elsif Iter.Current = Iter.Sections'First or else Iter.Sections (Iter.Current - 1) = null then return Section /= ""; else return Section /= Iter.Sections (Iter.Current - 1).all; end if; end Is_New_Section; --------------------- -- Current_Section -- --------------------- function Current_Section (Iter : Command_Line_Iterator) return String is begin if Iter.Sections = null or else Iter.Current > Iter.Sections'Last or else Iter.Sections (Iter.Current) = null then return ""; end if; return Iter.Sections (Iter.Current).all; end Current_Section; ----------------------- -- Current_Separator -- ----------------------- function Current_Separator (Iter : Command_Line_Iterator) return String is begin if Iter.Params = null or else Iter.Current > Iter.Params'Last or else Iter.Params (Iter.Current) = null then return ""; else declare Sep : constant Character := Iter.Params (Iter.Current) (Iter.Params (Iter.Current)'First); begin if Sep = ASCII.NUL then return ""; else return "" & Sep; end if; end; end if; end Current_Separator; ----------------------- -- Current_Parameter -- ----------------------- function Current_Parameter (Iter : Command_Line_Iterator) return String is begin if Iter.Params = null or else Iter.Current > Iter.Params'Last or else Iter.Params (Iter.Current) = null then return ""; else -- Return result, skipping separator declare P : constant String := Iter.Params (Iter.Current).all; begin return P (P'First + 1 .. P'Last); end; end if; end Current_Parameter; -------------- -- Has_More -- -------------- function Has_More (Iter : Command_Line_Iterator) return Boolean is begin return Iter.List /= null and then Iter.Current <= Iter.List'Last; end Has_More; ---------- -- Next -- ---------- procedure Next (Iter : in out Command_Line_Iterator) is begin Iter.Current := Iter.Current + 1; while Iter.Current <= Iter.List'Last and then Iter.List (Iter.Current) = null loop Iter.Current := Iter.Current + 1; end loop; end Next; ---------- -- Free -- ---------- procedure Free (Config : in out Command_Line_Configuration) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Switch_Definitions, Switch_Definitions_List); procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Alias_Definitions, Alias_Definitions_List); begin if Config /= null then Free (Config.Prefixes); Free (Config.Sections); Free (Config.Usage); Free (Config.Help); Free (Config.Help_Msg); if Config.Aliases /= null then for A in Config.Aliases'Range loop Free (Config.Aliases (A).Alias); Free (Config.Aliases (A).Expansion); Free (Config.Aliases (A).Section); end loop; Unchecked_Free (Config.Aliases); end if; if Config.Switches /= null then for S in Config.Switches'Range loop Free (Config.Switches (S).Switch); Free (Config.Switches (S).Long_Switch); Free (Config.Switches (S).Help); Free (Config.Switches (S).Section); Free (Config.Switches (S).Argument); end loop; Unchecked_Free (Config.Switches); end if; Unchecked_Free (Config); end if; end Free; ---------- -- Free -- ---------- procedure Free (Cmd : in out Command_Line) is begin Free (Cmd.Expanded); Free (Cmd.Coalesce); Free (Cmd.Coalesce_Sections); Free (Cmd.Coalesce_Params); Free (Cmd.Params); Free (Cmd.Sections); end Free; --------------- -- Set_Usage -- --------------- procedure Set_Usage (Config : in out Command_Line_Configuration; Usage : String := "[switches] [arguments]"; Help : String := ""; Help_Msg : String := "") is begin if Config = null then Config := new Command_Line_Configuration_Record; end if; Free (Config.Usage); Free (Config.Help); Free (Config.Help_Msg); Config.Usage := new String'(Usage); Config.Help := new String'(Help); Config.Help_Msg := new String'(Help_Msg); end Set_Usage; ------------------ -- Display_Help -- ------------------ procedure Display_Help (Config : Command_Line_Configuration) is function Switch_Name (Def : Switch_Definition; Section : String) return String; -- Return the "-short, --long=ARG" string for Def. -- Returns "" if the switch is not in the section. function Param_Name (P : Switch_Parameter_Type; Name : String := "ARG") return String; -- Return the display for a switch parameter procedure Display_Section_Help (Section : String); -- Display the help for a specific section ("" is the default section) -------------------------- -- Display_Section_Help -- -------------------------- procedure Display_Section_Help (Section : String) is Max_Len : Natural := 0; begin -- ??? Special display for "*" New_Line; if Section /= "" then Put_Line ("Switches after " & Section); end if; -- Compute size of the switches column for S in Config.Switches'Range loop Max_Len := Natural'Max (Max_Len, Switch_Name (Config.Switches (S), Section)'Length); end loop; if Config.Aliases /= null then for A in Config.Aliases'Range loop if Config.Aliases (A).Section.all = Section then Max_Len := Natural'Max (Max_Len, Config.Aliases (A).Alias'Length); end if; end loop; end if; -- Display the switches for S in Config.Switches'Range loop declare N : constant String := Switch_Name (Config.Switches (S), Section); begin if N /= "" then Put (" "); Put (N); Put ([1 .. Max_Len - N'Length + 1 => ' ']); if Config.Switches (S).Help /= null then Put (Config.Switches (S).Help.all); end if; New_Line; end if; end; end loop; -- Display the aliases if Config.Aliases /= null then for A in Config.Aliases'Range loop if Config.Aliases (A).Section.all = Section then Put (" "); Put (Config.Aliases (A).Alias.all); Put ([1 .. Max_Len - Config.Aliases (A).Alias'Length + 1 => ' ']); Put ("Equivalent to " & Config.Aliases (A).Expansion.all); New_Line; end if; end loop; end if; end Display_Section_Help; ---------------- -- Param_Name -- ---------------- function Param_Name (P : Switch_Parameter_Type; Name : String := "ARG") return String is begin case P is when Parameter_None => return ""; when Parameter_With_Optional_Space => return " " & To_Upper (Name); when Parameter_With_Space_Or_Equal => return "=" & To_Upper (Name); when Parameter_No_Space => return To_Upper (Name); when Parameter_Optional => return '[' & To_Upper (Name) & ']'; end case; end Param_Name; ----------------- -- Switch_Name -- ----------------- function Switch_Name (Def : Switch_Definition; Section : String) return String is use Ada.Strings.Unbounded; Result : Unbounded_String; P1, P2 : Switch_Parameter_Type; Last1, Last2 : Integer := 0; begin if (Section = "" and then Def.Section = null) or else (Def.Section /= null and then Def.Section.all = Section) then if Def.Switch /= null and then Def.Switch.all = "*" then return "[any switch]"; end if; if Def.Switch /= null then Decompose_Switch (Def.Switch.all, P1, Last1); Append (Result, Def.Switch (Def.Switch'First .. Last1)); if Def.Long_Switch /= null then Decompose_Switch (Def.Long_Switch.all, P2, Last2); Append (Result, ", " & Def.Long_Switch (Def.Long_Switch'First .. Last2)); if Def.Argument = null then Append (Result, Param_Name (P2, "ARG")); else Append (Result, Param_Name (P2, Def.Argument.all)); end if; else if Def.Argument = null then Append (Result, Param_Name (P1, "ARG")); else Append (Result, Param_Name (P1, Def.Argument.all)); end if; end if; -- Def.Switch is null (Long_Switch must be non-null) else Decompose_Switch (Def.Long_Switch.all, P2, Last2); Append (Result, Def.Long_Switch (Def.Long_Switch'First .. Last2)); if Def.Argument = null then Append (Result, Param_Name (P2, "ARG")); else Append (Result, Param_Name (P2, Def.Argument.all)); end if; end if; end if; return To_String (Result); end Switch_Name; -- Start of processing for Display_Help begin if Config = null then return; end if; if Config.Help /= null and then Config.Help.all /= "" then Put_Line (Config.Help.all); end if; if Config.Usage /= null then Put_Line ("Usage: " & Base_Name (Ada.Command_Line.Command_Name) & " " & Config.Usage.all); else Put_Line ("Usage: " & Base_Name (Ada.Command_Line.Command_Name) & " [switches] [arguments]"); end if; if Config.Help_Msg /= null and then Config.Help_Msg.all /= "" then Put_Line (Config.Help_Msg.all); else Display_Section_Help (""); if Config.Sections /= null and then Config.Switches /= null then for S in Config.Sections'Range loop Display_Section_Help (Config.Sections (S).all); end loop; end if; end if; end Display_Help; ------------ -- Getopt -- ------------ procedure Getopt (Config : Command_Line_Configuration; Callback : Switch_Handler := null; Parser : Opt_Parser := Command_Line_Parser; Concatenate : Boolean := True; Quiet : Boolean := False) is Local_Config : Command_Line_Configuration := Config; Getopt_Switches : String_Access; C : Character := ASCII.NUL; Empty_Name : aliased constant String := ""; Current_Section : Integer := -1; Section_Name : not null access constant String := Empty_Name'Access; procedure Simple_Callback (Simple_Switch : String; Separator : String; Parameter : String; Index : Integer); -- Needs comments ??? procedure Do_Callback (Switch, Parameter : String; Index : Integer); ----------------- -- Do_Callback -- ----------------- procedure Do_Callback (Switch, Parameter : String; Index : Integer) is begin -- Do automatic handling when possible if Index /= -1 then case Local_Config.Switches (Index).Typ is when Switch_Untyped => null; -- no automatic handling when Switch_Boolean => Local_Config.Switches (Index).Boolean_Output.all := Local_Config.Switches (Index).Boolean_Value; return; when Switch_Integer => begin if Parameter = "" then Local_Config.Switches (Index).Integer_Output.all := Local_Config.Switches (Index).Integer_Default; else Local_Config.Switches (Index).Integer_Output.all := Integer'Value (Parameter); end if; exception when Constraint_Error => raise Invalid_Parameter with "Expected integer parameter for '" & Switch & "'"; end; return; when Switch_String => Free (Local_Config.Switches (Index).String_Output.all); Local_Config.Switches (Index).String_Output.all := new String'(Parameter); return; when Switch_Callback => Local_Config.Switches (Index).Callback (Switch, Parameter); return; end case; end if; -- Otherwise calls the user callback if one was defined if Callback /= null then Callback (Switch => Switch, Parameter => Parameter, Section => Section_Name.all); end if; end Do_Callback; procedure For_Each_Simple is new For_Each_Simple_Switch (Simple_Callback); --------------------- -- Simple_Callback -- --------------------- procedure Simple_Callback (Simple_Switch : String; Separator : String; Parameter : String; Index : Integer) is pragma Unreferenced (Separator); begin Do_Callback (Switch => Simple_Switch, Parameter => Parameter, Index => Index); end Simple_Callback; -- Start of processing for Getopt begin -- We work with a local copy of Config, because Config can be null, for -- example if Define_Switch was never called. We could modify Config -- itself, but then we would have to make it into an 'in out' parameter, -- which would be incompatible. if Local_Config = null then Local_Config := new Command_Line_Configuration_Record; end if; if Local_Config.Switches = null then Local_Config.Switches := new Switch_Definitions (1 .. 0); end if; -- Initialize sections if Local_Config.Sections = null then Local_Config.Sections := new Argument_List'(1 .. 0 => null); end if; Internal_Initialize_Option_Scan (Parser => Parser, Switch_Char => Parser.Switch_Character, Stop_At_First_Non_Switch => Parser.Stop_At_First, Section_Delimiters => Section_Delimiters (Local_Config)); Getopt_Switches := new String' (Get_Switches (Local_Config, Parser.Switch_Character, Section_Name.all) & " h -help"); -- Initialize output values for automatically handled switches for S in Local_Config.Switches'Range loop case Local_Config.Switches (S).Typ is when Switch_Untyped | Switch_Callback => null; -- Nothing to do when Switch_Boolean => Local_Config.Switches (S).Boolean_Output.all := not Local_Config.Switches (S).Boolean_Value; when Switch_Integer => Local_Config.Switches (S).Integer_Output.all := Local_Config.Switches (S).Integer_Initial; when Switch_String => if Local_Config.Switches (S).String_Output.all = null then Local_Config.Switches (S).String_Output.all := new String'(""); end if; end case; end loop; -- For all sections, and all switches within those sections loop C := Getopt (Switches => Getopt_Switches.all, Concatenate => Concatenate, Parser => Parser); if C = '*' then -- Full_Switch already includes the leading '-' Do_Callback (Switch => Full_Switch (Parser), Parameter => Parameter (Parser), Index => -1); elsif C /= ASCII.NUL then if Full_Switch (Parser) = "h" or else Full_Switch (Parser) = "-help" then Display_Help (Local_Config); raise Exit_From_Command_Line; end if; -- Do switch expansion if needed For_Each_Simple (Local_Config, Section => Section_Name.all, Switch => Parser.Switch_Character & Full_Switch (Parser), Parameter => Parameter (Parser)); else if Current_Section = -1 then Current_Section := Local_Config.Sections'First; else Current_Section := Current_Section + 1; end if; exit when Current_Section > Local_Config.Sections'Last; Section_Name := Local_Config.Sections (Current_Section); Goto_Section (Section_Name.all, Parser); Free (Getopt_Switches); Getopt_Switches := new String' (Get_Switches (Local_Config, Parser.Switch_Character, Section_Name.all)); end if; end loop; Free (Getopt_Switches); exception when Invalid_Switch => Free (Getopt_Switches); -- Message inspired by "ls" on Unix if not Quiet then Put_Line (Standard_Error, Base_Name (Ada.Command_Line.Command_Name) & ": unrecognized option '" & Full_Switch (Parser) & "'"); Try_Help; end if; raise; when others => Free (Getopt_Switches); raise; end Getopt; ----------- -- Build -- ----------- procedure Build (Line : in out Command_Line; Args : out GNAT.OS_Lib.Argument_List_Access; Expanded : Boolean := False; Switch_Char : Character := '-') is Iter : Command_Line_Iterator; Count : Natural := 0; begin Start (Line, Iter, Expanded => Expanded); while Has_More (Iter) loop if Is_New_Section (Iter) then Count := Count + 1; end if; Count := Count + 1; Next (Iter); end loop; Args := new Argument_List (1 .. Count); Count := Args'First; Start (Line, Iter, Expanded => Expanded); while Has_More (Iter) loop if Is_New_Section (Iter) then Args (Count) := new String'(Switch_Char & Current_Section (Iter)); Count := Count + 1; end if; Args (Count) := new String'(Current_Switch (Iter) & Current_Separator (Iter) & Current_Parameter (Iter)); Count := Count + 1; Next (Iter); end loop; end Build; -------------- -- Try_Help -- -------------- -- Note: Any change to the message displayed should also be done in -- gnatbind.adb that does not use this interface. procedure Try_Help is begin Put_Line (Standard_Error, "try """ & Base_Name (Ada.Command_Line.Command_Name, Suffix => ".exe") & " --help"" for more information."); end Try_Help; end GNAT.Command_Line;
smola/language-dataset
Ada
15,237
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- Copyright (C) 2016-2019, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with Interfaces; use Interfaces; with Interfaces.ARM_V7AR; use Interfaces.ARM_V7AR; with System; use System; package body Board_Init is -- MPU table constants pragma Warnings (Off, "*is not referenced"); Size_32B : constant Unsigned_32 := 2#00100_0#; -- 0x04 << 1 Size_64B : constant Unsigned_32 := 2#00101_0#; -- 0x05 << 1 Size_126B : constant Unsigned_32 := 2#00110_0#; -- 0x06 << 1 Size_256B : constant Unsigned_32 := 2#00111_0#; -- 0x07 << 1 Size_512B : constant Unsigned_32 := 2#01000_0#; -- 0x08 << 1 Size_1kB : constant Unsigned_32 := 2#01001_0#; -- 0x09 << 1 Size_2kB : constant Unsigned_32 := 2#01010_0#; -- 0x0A << 1 Size_4kB : constant Unsigned_32 := 2#01011_0#; -- 0x0B << 1 Size_8kB : constant Unsigned_32 := 2#01100_0#; -- 0x0C << 1 Size_16kB : constant Unsigned_32 := 2#01101_0#; -- 0x0D << 1 Size_32kB : constant Unsigned_32 := 2#01110_0#; -- 0x0E << 1 Size_64kB : constant Unsigned_32 := 2#01111_0#; -- 0x0F << 1 Size_128kB : constant Unsigned_32 := 2#10000_0#; -- 0x10 << 1 Size_256kB : constant Unsigned_32 := 2#10001_0#; -- 0x11 << 1 Size_512kB : constant Unsigned_32 := 2#10010_0#; -- 0x12 << 1 Size_1MB : constant Unsigned_32 := 2#10011_0#; -- 0x13 << 1 Size_2MB : constant Unsigned_32 := 2#10100_0#; -- 0x14 << 1 Size_4MB : constant Unsigned_32 := 2#10101_0#; -- 0x15 << 1 Size_8MB : constant Unsigned_32 := 2#10110_0#; -- 0x16 << 1 Size_16MB : constant Unsigned_32 := 2#10111_0#; -- 0x17 << 1 Size_32MB : constant Unsigned_32 := 2#11000_0#; -- 0x18 << 1 Size_64MB : constant Unsigned_32 := 2#11001_0#; -- 0x19 << 1 Size_128MB : constant Unsigned_32 := 2#11010_0#; -- 0x1A << 1 Size_256MB : constant Unsigned_32 := 2#11011_0#; -- 0x1B << 1 Size_512MB : constant Unsigned_32 := 2#11100_0#; -- 0x1C << 1 Size_1GB : constant Unsigned_32 := 2#11101_0#; -- 0x1D << 1 Size_2GB : constant Unsigned_32 := 2#11110_0#; -- 0x1E << 1 Size_4GB : constant Unsigned_32 := 2#11111_0#; -- 0x1F << 1 XN : constant Unsigned_32 := 16#1000#; AP_NA_NA : constant Unsigned_32 := 16#000#; AP_RW_NA : constant Unsigned_32 := 16#100#; AP_RW_RO : constant Unsigned_32 := 16#200#; AP_RW_RW : constant Unsigned_32 := 16#300#; AP_RO_NA : constant Unsigned_32 := 16#500#; AP_RO_RO : constant Unsigned_32 := 16#600#; STRONGLY_ORDERED : constant Unsigned_32 := 16#00#; -- TEX: 0, C: 0, B: 0 SHAREABLE_DEVICE : constant Unsigned_32 := 16#01#; -- TEX: 0, C: 0, B: 1 WT_NO_WA : constant Unsigned_32 := 16#02#; -- TEX: 0, C: 1, B: 0 WB_NO_WA : constant Unsigned_32 := 16#03#; -- TEX: 0, C: 1, B: 1 NO_CACHE : constant Unsigned_32 := 16#08#; -- TEX: 1, C: 0, B: 0 WB_WA : constant Unsigned_32 := 16#0B#; -- TEX: 1, C: 1, B: 1 NON_SHAREABLE : constant Unsigned_32 := 16#10#; -- TEX: 2, C: 0, B: 0 SHARED : constant Unsigned_32 := 16#04#; pragma Warnings (On, "*is not referenced"); procedure System_Init; pragma Import (C, System_Init, "__gnat_system_init"); -- Initializes clocks and peripherals. This part is MCU specific. -- Code generated using HalCoGen.get procedure Enable_Event_Bus_Export; -- Allows the CPU to signal any single-bit or double-bit errors -- detected by its ECC logic for accesses to program flash or data -- RAM procedure Enable_ECC; -- Enables Checksum Checks on RAM and FLASH. procedure Setup_MPU; -- Setup the Memory Protection Unit regions and enables it procedure Enable_Cache; -- Enables instruction and data cache ----------------------------- -- Enable_Event_Bus_Export -- ----------------------------- procedure Enable_Event_Bus_Export is begin -- Set the X bit of the PMCR sys register CP15.Set_PMCR (CP15.Get_PMCR or 16#10#); end Enable_Event_Bus_Export; --------------- -- Setup_MPU -- --------------- procedure Setup_MPU is SRAM_Start : Character; pragma Import (Asm, SRAM_Start, "__gnat_ram_start"); SRAM_End : Character; pragma Import (Asm, SRAM_End, "__gnat_ram_end"); function As_Int is new Ada.Unchecked_Conversion (System.Address, Unsigned_32); SRAM_At_0 : constant Boolean := SRAM_Start'Address = System.Null_Address; SRAM_Size : constant Unsigned_32 := As_Int (SRAM_End'Address) - As_Int (SRAM_Start'Address); -- Cannot use System.Storage_Elements.Storage_Count here as -- System.Storage_Elements does not declare No_Elaboration_Code_All SCTLR : Unsigned_32; MPUIR : Unsigned_32; Num_Rgn : Unsigned_32; Policy : constant Unsigned_32 := NO_CACHE; begin -- First disable the MPU SCTLR := CP15.Get_SCTLR; if (SCTLR and 1) = 1 then SCTLR := SCTLR and 16#FFFF_FFFE#; -- Clear the MPU Enable bit Barriers.DSB; CP15.Set_SCTLR (SCTLR); Barriers.ISB; end if; -- Disable background region for MPU SCTLR := CP15.Get_SCTLR; SCTLR := SCTLR and (not (2 ** 17)); CP15.Set_SCTLR (SCTLR); -- Now will the MPU table MPUIR := CP15.Get_MPUIR; Num_Rgn := Shift_Right (MPUIR and 16#FF00#, 8); -- Region 1: background region CP15.Set_MPU_Region_Number (0); CP15.Set_MPU_Region_Base_Address (16#0000_0000#); CP15.Set_MPU_Region_Size_And_Enable (Shift_Left (16#FF#, 8) or Size_4GB or 1); CP15.Set_MPU_Region_Access_Control (XN or AP_NA_NA or Policy); -- Region 2: FLASH @ 0x0, or SRAM @ 0x0 if mem swapped CP15.Set_MPU_Region_Number (1); CP15.Set_MPU_Region_Base_Address (16#0000_0000#); if SRAM_At_0 then declare Sz : Unsigned_32; begin -- Supported configurations: 256kB SRAM, 512kB SRAM, or 16MB RAM -- at address 0x0. if SRAM_Size <= 256 * 1024 then Sz := Size_256kB; elsif SRAM_Size <= 512 * 1024 then Sz := Size_512kB; else Sz := Size_16MB; end if; CP15.Set_MPU_Region_Size_And_Enable (Sz or 1); end; CP15.Set_MPU_Region_Access_Control (AP_RW_RW or Policy); else CP15.Set_MPU_Region_Size_And_Enable (Size_4MB or 1); CP15.Set_MPU_Region_Access_Control (AP_RO_RO or Policy); end if; -- Region 3: SRAM @ 0x0800_0000 or FLASH is mem swapped CP15.Set_MPU_Region_Number (2); CP15.Set_MPU_Region_Base_Address (16#0800_0000#); if SRAM_At_0 then -- FLASH Region -- Only 512kB of FLASH is accessible in this case CP15.Set_MPU_Region_Size_And_Enable (Size_512kB or 1); CP15.Set_MPU_Region_Access_Control (AP_RO_RO or Policy); else declare Sz : Unsigned_32; begin -- Supported configurations: 256kB or 512kB SRAM. if SRAM_Size <= 256 * 1024 then Sz := Size_256kB; else Sz := Size_512kB; end if; CP15.Set_MPU_Region_Size_And_Enable (Sz or 1); end; CP15.Set_MPU_Region_Access_Control (AP_RW_RW or Policy); end if; -- Region 4: Async RAM CP15.Set_MPU_Region_Number (3); CP15.Set_MPU_Region_Base_Address (16#6000_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_64MB or 1); CP15.Set_MPU_Region_Access_Control (AP_RW_RW or STRONGLY_ORDERED); -- Region 5: SDRAM CP15.Set_MPU_Region_Number (4); CP15.Set_MPU_Region_Base_Address (16#8000_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_128MB or 1); CP15.Set_MPU_Region_Access_Control (AP_RW_RW or Policy or SHARED); -- Region 6: 6MB Flash OTP, ECC, EEPROM Bank CP15.Set_MPU_Region_Number (5); CP15.Set_MPU_Region_Base_Address (16#F000_0000#); -- Disable sub-regions 7 and 8 CP15.Set_MPU_Region_Size_And_Enable (16#C000# or Size_8MB or 1); CP15.Set_MPU_Region_Access_Control (XN or AP_RW_RW or NO_CACHE); -- Region 7: 16MB peripheral segment 2 CP15.Set_MPU_Region_Number (6); CP15.Set_MPU_Region_Base_Address (16#FC00_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_16MB or 1); CP15.Set_MPU_Region_Access_Control (XN or AP_RW_RW or NON_SHAREABLE); -- Region 8: 512B accessible CRC module CP15.Set_MPU_Region_Number (7); CP15.Set_MPU_Region_Base_Address (16#FE00_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_512B or 1); CP15.Set_MPU_Region_Access_Control (XN or AP_RW_RW or NON_SHAREABLE); -- Region 9: 16MB peripheral segment 3, including sys regs CP15.Set_MPU_Region_Number (8); CP15.Set_MPU_Region_Base_Address (16#FF00_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_16MB or 1); CP15.Set_MPU_Region_Access_Control (XN or AP_RW_RW or NON_SHAREABLE); -- Disable the unused regions for J in 9 .. Num_Rgn loop CP15.Set_MPU_Region_Number (J); CP15.Set_MPU_Region_Base_Address (16#0000_0000#); CP15.Set_MPU_Region_Size_And_Enable (Size_32B or 0); CP15.Set_MPU_Region_Access_Control (XN); end loop; -- Enable background region for MPU SCTLR := CP15.Get_SCTLR; SCTLR := SCTLR or (2 ** 17); CP15.Set_SCTLR (SCTLR); -- Enable the MPU SCTLR := CP15.Get_SCTLR; SCTLR := SCTLR or 1; CP15.Set_SCTLR (SCTLR); Barriers.ISB; end Setup_MPU; ---------------- -- Enable_ECC -- ---------------- procedure Enable_ECC is FEDACCTRL1 : Unsigned_32 with Volatile, Import, Address => System'To_Address (16#FFF8_7008#); MINITGCR : Unsigned_32 with Volatile, Import, Address => System'To_Address (16#FFFF_FF5C#); MSIENA : Unsigned_32 with Volatile, Import, Address => System'To_Address (16#FFFF_FF60#); MSTCGSTAT : Unsigned_32 with Volatile, Import, Address => System'To_Address (16#FFFF_FF68#); ACTLR : Unsigned_32; begin -- First enable response to ECC errors indicated by CPU for accesses to -- flash. -- FEDACCTRL1: -- EDACEN [0-3]: error detection and correction enabled -- EPEN [8]: error profiling is disabled -- EZFEN [9]: event on zeros fail enable -- EOFEN [10]: event on ones fail enable -- EDACMODE [16-19]: error correction mode selection as uncorrectable -- errors -- SUSP_IGNR [24]: cpu suspend signal blocks error bits setting and -- un-freezing FEDACCTRL1 := 16#000a_060A#; -- Initialize the CPU RAM ECC locations MINITGCR := 16#A#; -- enable global memroy hw initialization MSIENA := 16#1#; -- enable auto-hw init of SRAM loop -- check the MINIDONE bit exit when (MSTCGSTAT and 16#100#) /= 0; end loop; MINITGCR := 16#5#; -- remove the key from the hw initialization lock -- Enable CPU ECC checking for flash accesses ACTLR := CP15.Get_ACTLR; ACTLR := ACTLR or 16#C000000#; -- DICDI and DIB2DI bits Barriers.DMB; CP15.Set_ACTLR (ACTLR); Barriers.ISB; end Enable_ECC; ------------------ -- Enable_Cache -- ------------------ procedure Enable_Cache is ACTLR : Unsigned_32; SCTLR : Unsigned_32; begin ACTLR := CP15.Get_ACTLR; -- Clear bit 5 (enable ECC) ACTLR := ACTLR and not (2 ** 5); CP15.Set_ACTLR (ACTLR); SCTLR := CP15.Get_SCTLR; SCTLR := SCTLR or (2 ** 2) or (2 ** 12); -- resp D and I bits Barriers.DSB; Cache.Invalidate_DCache; Barriers.DSB; Cache.Invalidate_ICache; Barriers.DSB; CP15.Set_SCTLR (SCTLR); Barriers.ISB; end Enable_Cache; ---------------- -- Board_Init -- ---------------- procedure Board_Init is SYSESR : Unsigned_32 with Volatile, Import, Address => System'To_Address (16#FFFF_FFe4#); begin -- Check reset condition at startup if SYSESR = 0 then -- Reset condition is 0: the boot has already been taken care of, so -- let's just return. return; elsif (SYSESR and 16#8800#) /= 0 then -- Power-on reset or Debug reset: -- do a full system init first System_Init; Enable_Event_Bus_Export; Enable_ECC; -- Finally clear the reset flag SYSESR := 16#8800#; elsif (SYSESR and 16#20#) /= 0 then -- CPU reset: -- do a full system init first System_Init; Enable_Event_Bus_Export; -- Note: leave the ECC settings for RAM and FLASH as those have -- not changed after a CPU reset SYSESR := 16#20#; end if; Setup_MPU; Enable_Cache; end Board_Init; end Board_Init;
reznikmm/matreshka
Ada
3,699
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.Text_User_Index_Mark_Elements is pragma Preelaborate; type ODF_Text_User_Index_Mark is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_User_Index_Mark_Access is access all ODF_Text_User_Index_Mark'Class with Storage_Size => 0; end ODF.DOM.Text_User_Index_Mark_Elements;
persan/A-gst
Ada
15,097
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib.Values; with System; -- with GStreamer.GST_Low_Level.glib_2_0_gobject_gobject_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h; -- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h; with System; with glib; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h; -- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstinterpolationcontrolsource_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontroller_h is -- unsupported macro: GST_TYPE_CONTROLLER (gst_controller_get_type ()) -- arg-macro: function GST_CONTROLLER (obj) -- return G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CONTROLLER, GstController); -- arg-macro: function GST_CONTROLLER_CLASS (klass) -- return G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CONTROLLER, GstControllerClass); -- arg-macro: function GST_IS_CONTROLLER (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CONTROLLER); -- arg-macro: function GST_IS_CONTROLLER_CLASS (klass) -- return G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CONTROLLERE); -- arg-macro: function GST_CONTROLLER_GET_CLASS (obj) -- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CONTROLLER, GstControllerClass); -- GStreamer -- * -- * Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net> -- * -- * gst-controller.h: dynamic parameter control subsystem -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- -- type macros type GstController; type u_GstController_u_gst_reserved_array is array (0 .. 2) of System.Address; --subtype GstController is u_GstController; -- gst/controller/gstcontroller.h:47 type GstControllerClass; type u_GstControllerClass_u_gst_reserved_array is array (0 .. 3) of System.Address; --subtype GstControllerClass is u_GstControllerClass; -- gst/controller/gstcontroller.h:48 -- skipped empty struct u_GstControllerPrivate -- skipped empty struct GstControllerPrivate --* -- * GstController: -- * -- * The instance structure of GstController -- type GstController is record parent : aliased GLIB.Object.GObject; -- gst/controller/gstcontroller.h:59 properties : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/controller/gstcontroller.h:61 lock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/controller/gstcontroller.h:62 object : access GLIB.Object.GObject; -- gst/controller/gstcontroller.h:63 priv : System.Address; -- gst/controller/gstcontroller.h:66 u_gst_reserved : u_GstController_u_gst_reserved_array; -- gst/controller/gstcontroller.h:67 end record; pragma Convention (C_Pass_By_Copy, GstController); -- gst/controller/gstcontroller.h:57 -- List of GstControlledProperty -- Secure property access, elements will access from threads -- the object we control --< private > type GstControllerClass is record parent_class : aliased GLIB.Object.GObject_Class; -- gst/controller/gstcontroller.h:72 u_gst_reserved : u_GstControllerClass_u_gst_reserved_array; -- gst/controller/gstcontroller.h:75 end record; pragma Convention (C_Pass_By_Copy, GstControllerClass); -- gst/controller/gstcontroller.h:70 --< private > function gst_controller_get_type return GLIB.GType; -- gst/controller/gstcontroller.h:78 pragma Import (C, gst_controller_get_type, "gst_controller_get_type"); -- GstController functions function gst_controller_new_valist (object : access GLIB.Object.GObject; var_args : access System.Address) return access GstController; -- gst/controller/gstcontroller.h:82 pragma Import (C, gst_controller_new_valist, "gst_controller_new_valist"); function gst_controller_new_list (object : access GLIB.Object.GObject; list : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList) return access GstController; -- gst/controller/gstcontroller.h:83 pragma Import (C, gst_controller_new_list, "gst_controller_new_list"); function gst_controller_new (object : access GLIB.Object.GObject -- , ... ) return access GstController; -- gst/controller/gstcontroller.h:84 pragma Import (C, gst_controller_new, "gst_controller_new"); function gst_controller_remove_properties_valist (self : access GstController; var_args : access System.Address) return GLIB.gboolean; -- gst/controller/gstcontroller.h:86 pragma Import (C, gst_controller_remove_properties_valist, "gst_controller_remove_properties_valist"); function gst_controller_remove_properties_list (self : access GstController; list : access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList) return GLIB.gboolean; -- gst/controller/gstcontroller.h:88 pragma Import (C, gst_controller_remove_properties_list, "gst_controller_remove_properties_list"); function gst_controller_remove_properties (self : access GstController -- , ... ) return GLIB.gboolean; -- gst/controller/gstcontroller.h:90 pragma Import (C, gst_controller_remove_properties, "gst_controller_remove_properties"); procedure gst_controller_set_disabled (self : access GstController; disabled : GLIB.gboolean); -- gst/controller/gstcontroller.h:92 pragma Import (C, gst_controller_set_disabled, "gst_controller_set_disabled"); procedure gst_controller_set_property_disabled (self : access GstController; property_name : access GLIB.gchar; disabled : GLIB.gboolean); -- gst/controller/gstcontroller.h:93 pragma Import (C, gst_controller_set_property_disabled, "gst_controller_set_property_disabled"); function gst_controller_set_control_source (self : access GstController; property_name : access GLIB.gchar; csource : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstControlSource) return GLIB.gboolean; -- gst/controller/gstcontroller.h:94 pragma Import (C, gst_controller_set_control_source, "gst_controller_set_control_source"); function gst_controller_get_control_source (self : access GstController; property_name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstControlSource; -- gst/controller/gstcontroller.h:95 pragma Import (C, gst_controller_get_control_source, "gst_controller_get_control_source"); function gst_controller_suggest_next_sync (self : access GstController) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/controller/gstcontroller.h:97 pragma Import (C, gst_controller_suggest_next_sync, "gst_controller_suggest_next_sync"); function gst_controller_sync_values (self : access GstController; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GLIB.gboolean; -- gst/controller/gstcontroller.h:98 pragma Import (C, gst_controller_sync_values, "gst_controller_sync_values"); function gst_controller_get (self : access GstController; property_name : access GLIB.gchar; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return access Glib.Values.GValue; -- gst/controller/gstcontroller.h:101 pragma Import (C, gst_controller_get, "gst_controller_get"); function gst_controller_get_value_arrays (self : access GstController; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; value_arrays : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList) return GLIB.gboolean; -- gst/controller/gstcontroller.h:103 pragma Import (C, gst_controller_get_value_arrays, "gst_controller_get_value_arrays"); function gst_controller_get_value_array (self : access GstController; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; value_array : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstValueArray) return GLIB.gboolean; -- gst/controller/gstcontroller.h:105 pragma Import (C, gst_controller_get_value_array, "gst_controller_get_value_array"); -- GObject convenience functions function gst_object_control_properties (object : access GLIB.Object.GObject -- , ... ) return access GstController; -- gst/controller/gstcontroller.h:110 pragma Import (C, gst_object_control_properties, "gst_object_control_properties"); function gst_object_uncontrol_properties (object : access GLIB.Object.GObject -- , ... ) return GLIB.gboolean; -- gst/controller/gstcontroller.h:111 pragma Import (C, gst_object_uncontrol_properties, "gst_object_uncontrol_properties"); function gst_object_get_controller (object : access GLIB.Object.GObject) return access GstController; -- gst/controller/gstcontroller.h:113 pragma Import (C, gst_object_get_controller, "gst_object_get_controller"); function gst_object_set_controller (object : access GLIB.Object.GObject; controller : access GstController) return GLIB.gboolean; -- gst/controller/gstcontroller.h:114 pragma Import (C, gst_object_set_controller, "gst_object_set_controller"); function gst_object_suggest_next_sync (object : access GLIB.Object.GObject) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/controller/gstcontroller.h:116 pragma Import (C, gst_object_suggest_next_sync, "gst_object_suggest_next_sync"); function gst_object_sync_values (object : access GLIB.Object.GObject; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GLIB.gboolean; -- gst/controller/gstcontroller.h:117 pragma Import (C, gst_object_sync_values, "gst_object_sync_values"); function gst_object_set_control_source (object : access GLIB.Object.GObject; property_name : access GLIB.gchar; csource : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstControlSource) return GLIB.gboolean; -- gst/controller/gstcontroller.h:119 pragma Import (C, gst_object_set_control_source, "gst_object_set_control_source"); function gst_object_get_control_source (object : access GLIB.Object.GObject; property_name : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstControlSource; -- gst/controller/gstcontroller.h:120 pragma Import (C, gst_object_get_control_source, "gst_object_get_control_source"); function gst_object_get_value_arrays (object : access GLIB.Object.GObject; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; value_arrays : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList) return GLIB.gboolean; -- gst/controller/gstcontroller.h:122 pragma Import (C, gst_object_get_value_arrays, "gst_object_get_value_arrays"); function gst_object_get_value_array (object : access GLIB.Object.GObject; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; value_array : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontrolsource_h.GstValueArray) return GLIB.gboolean; -- gst/controller/gstcontroller.h:124 pragma Import (C, gst_object_get_value_array, "gst_object_get_value_array"); function gst_object_get_control_rate (object : access GLIB.Object.GObject) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/controller/gstcontroller.h:127 pragma Import (C, gst_object_get_control_rate, "gst_object_get_control_rate"); procedure gst_object_set_control_rate (object : access GLIB.Object.GObject; control_rate : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime); -- gst/controller/gstcontroller.h:128 pragma Import (C, gst_object_set_control_rate, "gst_object_set_control_rate"); -- lib init/done function gst_controller_init (argc : access int; argv : System.Address) return GLIB.gboolean; -- gst/controller/gstcontroller.h:132 pragma Import (C, gst_controller_init, "gst_controller_init"); -- FIXME: deprecated functions function gst_controller_set (self : access GstController; property_name : access GLIB.gchar; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; value : access Glib.Values.GValue) return GLIB.gboolean; -- gst/controller/gstcontroller.h:137 pragma Import (C, gst_controller_set, "gst_controller_set"); function gst_controller_set_from_list (self : access GstController; property_name : access GLIB.gchar; timedvalues : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList) return GLIB.gboolean; -- gst/controller/gstcontroller.h:139 pragma Import (C, gst_controller_set_from_list, "gst_controller_set_from_list"); function gst_controller_unset (self : access GstController; property_name : access GLIB.gchar; timestamp : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime) return GLIB.gboolean; -- gst/controller/gstcontroller.h:142 pragma Import (C, gst_controller_unset, "gst_controller_unset"); function gst_controller_unset_all (self : access GstController; property_name : access GLIB.gchar) return GLIB.gboolean; -- gst/controller/gstcontroller.h:144 pragma Import (C, gst_controller_unset_all, "gst_controller_unset_all"); function gst_controller_get_all (self : access GstController; property_name : access GLIB.gchar) return access constant GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/controller/gstcontroller.h:146 pragma Import (C, gst_controller_get_all, "gst_controller_get_all"); function gst_controller_set_interpolation_mode (self : access GstController; property_name : access GLIB.gchar; mode : GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstinterpolationcontrolsource_h.GstInterpolateMode) return GLIB.gboolean; -- gst/controller/gstcontroller.h:149 pragma Import (C, gst_controller_set_interpolation_mode, "gst_controller_set_interpolation_mode"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_controller_gstcontroller_h;
simonjwright/Quaternions
Ada
790
ads
generic type Real is digits <>; package Generic_Quaternions is type Quaternion is record W : Real; X : Real; Y : Real; Z : Real; end record; function "-" (Q : Quaternion) return Quaternion; function "+" (L, R : Quaternion) return Quaternion; function "-" (L, R : Quaternion) return Quaternion; function "*" (L : Quaternion; R : Real) return Quaternion; function "*" (L : Real; R : Quaternion) return Quaternion; function "*" (L : Quaternion; R : Quaternion) return Quaternion; function "/" (L : Quaternion; R : Real) return Quaternion; function Conjugate (Q : Quaternion) return Quaternion; function Norm (Q : Quaternion) return Real; function Normalize (Q : Quaternion) return Quaternion; end Generic_Quaternions;
Kidev/Ada_Drivers_Library
Ada
1,626
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Vendor : constant String := "SiFive"; -- From board definition Max_Mount_Points : constant := 2; -- From default value Max_Mount_Name_Length : constant := 128; -- From default value Runtime_Profile : constant String := "zfp"; -- From command line Device_Name : constant String := "FE310"; -- From board definition Device_Family : constant String := "FE3"; -- From board definition Runtime_Name : constant String := "zfp-hifive1"; -- From default value Has_Ravenscar_Full_Runtime : constant String := "False"; -- From board definition CPU_Core : constant String := "RISC-V32"; -- From mcu definition Board : constant String := "HiFive1"; -- From command line Has_ZFP_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "False"; -- From board definition Max_Path_Length : constant := 1024; -- From default value Runtime_Name_Suffix : constant String := "hifive1"; -- From board definition Architecture : constant String := "RISC-V"; -- From board definition end ADL_Config;
onox/sdlada
Ada
2,902
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 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. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; with SDL; with SDL.Error; with SDL.Video.Windows; package body SDL.Clipboard is package C renames Interfaces.C; use type C.int; procedure Check_For_Window is Init_Value : constant SDL.Init_Flags := SDL.Was_Initialised and SDL.Enable_Screen; begin if Init_Value /= SDL.Enable_Screen then raise Clipboard_Error with "SDL screen subsystem has not been initialised."; end if; if SDL.Video.Windows.Exist = False then raise Clipboard_Error with "No windows have been created."; end if; end Check_For_Window; function Get return Ada.Strings.UTF_Encoding.UTF_8_String is function SDL_Get_Clipboard_Text return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetClipboardText"; begin Check_For_Window; return C.Strings.Value (SDL_Get_Clipboard_Text); end Get; function Is_Empty return Boolean is function SDL_Has_Clipboard_Text return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_HasClipboardText"; begin Check_For_Window; return (if SDL_Has_Clipboard_Text = SDL_True then False else True); end Is_Empty; procedure Set (Text : in Ada.Strings.UTF_Encoding.UTF_8_String) is function SDL_Set_Clipboard_Text (C_Str : in C.char_array) return C.int with Import => True, Convention => C, External_Name => "SDL_SetClipboardText"; begin Check_For_Window; if SDL_Set_Clipboard_Text (C.To_C (Text)) /= Success then raise Clipboard_Error with SDL.Error.Get; end if; end Set; end SDL.Clipboard;
caqg/linux-home
Ada
8,146
ads
-- Abstract : -- -- Ada language specific indent options and functions -- -- [2] ada-indent-user-options.el -- -- Copyright (C) 2017 - 2022 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. -- 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. pragma License (Modified_GPL); package Wisi.Ada is Language_Protocol_Version : constant String := "4"; -- Defines the data passed to Initialize in Params. -- -- This value must match ada-mode.el -- ada-wisi-language-protocol-version. -- -- Only changes once per ada-mode release. Increment as soon as -- required, record new version in NEWS. -- Indent parameters from [2] Ada_Indent_Default : constant Integer := 3; Ada_Indent : Integer := Ada_Indent_Default; Ada_Indent_Broken_Default : constant Integer := 2; Ada_Indent_Broken : Integer := Ada_Indent_Broken_Default; Ada_Indent_Comment_Col_0_Default : constant Boolean := False; Ada_Indent_Comment_Col_0 : Boolean := Ada_Indent_Comment_Col_0_Default; Ada_Indent_Comment_GNAT_Default : constant Boolean := False; Ada_Indent_Comment_GNAT : Boolean := Ada_Indent_Comment_GNAT_Default; Ada_Indent_Label_Default : constant Integer := -3; Ada_Indent_Label : Integer := Ada_Indent_Label_Default; Ada_Indent_Record_Rel_Type_Default : constant Integer := 3; Ada_Indent_Record_Rel_Type : Integer := Ada_Indent_Record_Rel_Type_Default; Ada_Indent_Renames_Default : constant Integer := 2; Ada_Indent_Renames : Integer := Ada_Indent_Renames_Default; Ada_Indent_Return_Default : constant Integer := 0; Ada_Indent_Return : Integer := Ada_Indent_Return_Default; Ada_Indent_Use_Default : constant Integer := 2; Ada_Indent_Use : Integer := Ada_Indent_Use_Default; Ada_Indent_When_Default : constant Integer := 3; Ada_Indent_When : Integer := Ada_Indent_When_Default; Ada_Indent_With_Default : constant Integer := 2; Ada_Indent_With : Integer := Ada_Indent_With_Default; -- ada-indent-after-trailing-comment is implemented in elisp Ada_Indent_Subprogram_Is_Default : constant Integer := 2; Ada_Indent_Subprogram_Is : Integer := Ada_Indent_Subprogram_Is_Default; -- Other parameters End_Names_Optional_Default : constant Boolean := True; End_Names_Optional : Boolean := End_Names_Optional_Default; type Parse_Data_Type is new Wisi.Parse_Data_Type with null record; overriding function New_User_Data (Template : in Parse_Data_Type) return WisiToken.Syntax_Trees.User_Data_Access is (new Parse_Data_Type); overriding procedure Initialize (Data : in out Parse_Data_Type); overriding procedure Parse_Language_Params (Data : in out Parse_Data_Type; Params : in String); overriding function Insert_After (User_Data : in out Parse_Data_Type; Tree : in WisiToken.Syntax_Trees.Tree'Class; Insert_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Insert_Before_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Comment_Present : in Boolean; Blank_Line_Present : in Boolean) return WisiToken.Insert_Location; -- Must match "ada-refactor-*" in ada-core.el type Refactor_Label is (Method_Object_To_Object_Method, -- 0 Object_Method_To_Method_Object, -- 1 Element_Object_To_Object_Index, -- 2 Object_Index_To_Element_Object, -- 3 Format_Parameter_List); -- 4 overriding function Refactor_Parse (Data : in Parse_Data_Type; Item : in String) return Refactor_Action is (Refactor_Action (Refactor_Label'Pos (Refactor_Label'Value (Item)))); overriding procedure Refactor_Help (Data : in Parse_Data_Type); overriding procedure Refactor (Data : in out Parse_Data_Type; Tree : in out WisiToken.Syntax_Trees.Tree; Action : in Refactor_Action; Edit_Begin_Char : in WisiToken.Buffer_Pos); overriding function Get_Token_IDs (User_Data : in Parse_Data_Type; Command_Line : in String; Last : in out Integer) return WisiToken.Token_ID_Arrays.Vector; ---------- -- The following are declared in ada.wy %elisp_indent, and must match -- Wisi.Language_Indent_Function. function Ada_Indent_Aggregate (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- ada-indent-aggregate -- Args: none function Ada_Indent_Aspect (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Delta_Type; -- ada-indent-aspect -- Args: none function Ada_Indent_Renames_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- ada-indent-renames -- Args: subprogram_token_index function Ada_Indent_Return_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- ada-indent-return -- Args: formal_part_token_index, offset function Ada_Indent_Record_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- ada-indent-record -- Args: anchor_token_index, record_token_index, offset function Ada_Indent_Record_1 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Token : in WisiToken.Syntax_Trees.Valid_Node_Access; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- ada-indent-record* -- Args: anchor_token_ID, record_token_index, offset end Wisi.Ada;
stcarrez/mat
Ada
5,194
adb
----------------------------------------------------------------------- -- mat-memory-tests -- Unit tests for MAT memory -- Copyright (C) 2014, 2015, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with MAT.Expressions; with MAT.Frames.Targets; with MAT.Memory.Targets; package body MAT.Memory.Tests is package Caller is new Util.Test_Caller (Test, "Memory"); -- Builtin and well known definition of test frames. Frame_1_0 : constant MAT.Frames.Frame_Table (1 .. 10) := (1_0, 1_2, 1_3, 1_4, 1_5, 1_6, 1_7, 1_8, 1_9, 1_10); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test MAT.Memory.Probe_Malloc", Test_Probe_Malloc'Access); Caller.Add_Test (Suite, "Test MAT.Memory.Probe_Free", Test_Probe_Free'Access); end Add_Tests; -- ------------------------------ -- Basic consistency checks when creating the test tree -- ------------------------------ procedure Test_Probe_Malloc (T : in out Test) is M : MAT.Memory.Targets.Target_Memory; S : Allocation; R : Allocation_Map; F : MAT.Frames.Targets.Target_Frames; begin S.Size := 4; F.Insert (Frame_1_0, S.Frame); -- Create memory slots: -- [10 .. 14] [20 .. 24] [30 ..34] .. [100 .. 104] for I in 1 .. 10 loop M.Probe_Malloc (MAT.Types.Target_Addr (10 * I), S); end loop; -- Search for a memory region that does not overlap a memory slot. M.Find (15, 19, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 0, Integer (R.Length), "Find must return 0 slots in range [15 .. 19]"); M.Find (1, 9, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 0, Integer (R.Length), "Find must return 0 slots in range [1 .. 9]"); M.Find (105, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 0, Integer (R.Length), "Find must return 0 slots in range [105 .. 1000]"); -- Search with an overlap. M.Find (1, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 10, Integer (R.Length), "Find must return 10 slots in range [1 .. 1000]"); R.Clear; M.Find (1, 19, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 1, Integer (R.Length), "Find must return 1 slot in range [1 .. 19]"); R.Clear; M.Find (13, 19, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 1, Integer (R.Length), "Find must return 1 slot in range [13 .. 19]"); R.Clear; M.Find (100, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 1, Integer (R.Length), "Find must return 1 slot in range [100 .. 1000]"); R.Clear; M.Find (101, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 1, Integer (R.Length), "Find must return 1 slot in range [101 .. 1000]"); end Test_Probe_Malloc; -- ------------------------------ -- Test Probe_Free with update of memory slots. -- ------------------------------ procedure Test_Probe_Free (T : in out Test) is M : MAT.Memory.Targets.Target_Memory; S : Allocation; R : Allocation_Map; Size : MAT.Types.Target_Size; Id : MAT.Events.Event_Id_Type with Unreferenced; F : MAT.Frames.Targets.Target_Frames; begin S.Size := 4; S.Event := 1; F.Insert (Frame_1_0, S.Frame); -- Malloc followed by a free. M.Probe_Malloc (10, S); Id := 12; M.Probe_Free (10, S, Size, Id); M.Find (1, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 0, Integer (R.Length), "Find must return 0 slot after a free"); -- Free the same slot a second time (free error). M.Probe_Free (10, S, Size, Id); -- Malloc followed by a free. M.Probe_Malloc (10, S); M.Probe_Malloc (20, S); M.Probe_Malloc (30, S); M.Probe_Free (20, S, Size, Id); M.Find (1, 1000, MAT.Expressions.EMPTY, R); Util.Tests.Assert_Equals (T, 2, Integer (R.Length), "Find must return 2 slots after a malloc/free sequence"); end Test_Probe_Free; end MAT.Memory.Tests;
reznikmm/matreshka
Ada
6,513
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2017, 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 WebAPI.HTML.Validity_States is pragma Preelaborate; type Validity_State is limited interface; not overriding function Get_Value_Missing (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "valueMissing"; not overriding function Get_Type_Mismatch (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "typeMismatch"; not overriding function Get_Pattern_Mismatch (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "patternMismatch"; not overriding function Get_Too_Long (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "tooLong"; not overriding function Get_Too_Short (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "tooShort"; not overriding function Get_Range_Underflow (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "rangeUnderflow"; not overriding function Get_Range_Overflow (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "rangeOverflow"; not overriding function Get_Step_Mismatch (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "stepMismatch"; not overriding function Get_Bad_Input (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "badInput"; not overriding function Get_Custom_Error (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "customError"; not overriding function Get_Valid (Self : not null access constant Validity_State) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "valid"; end WebAPI.HTML.Validity_States;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
3,639
adb
with STM32_SVD; use STM32_SVD; with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.EXTI; use STM32_SVD.EXTI; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.RTC; use STM32_SVD.RTC; package body STM32GD.RTC is procedure Unlock is begin RTC_Periph.WPR.KEY := 16#CA#; RTC_Periph.WPR.KEY := 16#53#; end Unlock; procedure Lock is begin RTC_Periph.WPR.KEY := 16#FF#; end Lock; procedure Read (Date_Time : out Date_Time_Type) is begin Date_Time.Day := Natural(RTC_Periph.DR.DU) + Natural(RTC_Periph.DR.DT) * 10; Date_Time.Month := Natural(RTC_Periph.DR.MU) + Natural(RTC_Periph.DR.MT) * 10; Date_Time.Year := Natural(RTC_Periph.DR.YU) + Natural(RTC_Periph.DR.YT) * 10; Date_Time.Hour := Natural(RTC_Periph.TR.HU) + Natural(RTC_Periph.TR.HT) * 10; Date_Time.Minute := Natural(RTC_Periph.TR.MNU) + Natural(RTC_Periph.TR.MNT) * 10; Date_Time.Second := Natural(RTC_Periph.TR.SU) + Natural(RTC_Periph.TR.ST) * 10; end Read; procedure Print (Date_Time : Date_Time_Type) is begin -- Put (Integer'Image (Date_Time.Year)); -- Put (Integer'Image (Date_Time.Month)); -- Put (Integer'Image (Date_Time.Day)); -- Put (Integer'Image (Date_Time.Hour)); -- Put (Integer'Image (Date_Time.Minute)); -- Put_Line (Integer'Image (Date_Time.Second)); null; end Print; procedure Add_Seconds (Date_Time : in out Date_Time_Type ; Second_Delta : Second_Delta_Type) is Total_Seconds : Natural; begin Total_Seconds := Date_Time.Second + Date_Time.Minute * 60 + Date_Time.Hour * 60 * 60 + Second_Delta; Date_Time.Second := Total_Seconds mod 60; Date_Time.Minute := Total_Seconds mod (60 * 60) / 60; Date_Time.Hour := Total_Seconds / 3600; if Total_Seconds / (60 * 60) > Hour_Type'Last then Total_Seconds := Total_Seconds - Hour_Type'Last * (60 * 60); end if; Date_Time.Hour := Total_Seconds / (60 * 60); end Add_Seconds; procedure Add_Minutes (Date_Time : in out Date_Time_Type ; Minute_Delta : Minute_Delta_Type) is Total_Minutes : Natural; begin Total_Minutes := Date_Time.Minute + Date_Time.Hour * 60 + Minute_Delta; Date_Time.Minute := Total_Minutes mod 60; if Total_Minutes / 60 > Hour_Type'Last then Total_Minutes := Total_Minutes - Hour_Type'Last * 60; end if; Date_Time.Hour := Total_Minutes / 60; end Add_Minutes; procedure Set_Alarm (Date_Time : Date_Time_Type) is begin Unlock; RTC_Periph.ISR.ALRAF := 0; RTC_Periph.CR.ALRAE := 0; while RTC_Periph.ISR.ALRAWF = 0 loop null; end loop; RTC_Periph.ALRMAR := ( MSK1 => 0, ST => UInt3 (Date_Time.Second / 10), SU => UInt4 (Date_Time.Second mod 10), MSK2 => 0, MNT => UInt3 (Date_Time.Minute / 10), MNU => UInt4 (Date_Time.Minute mod 10), MSK3 => 0, PM => 0, HT => UInt2 (Date_Time.Hour / 10), HU => UInt4 (Date_Time.Hour mod 10), MSK4 => 1, WDSEL => 0, DT => 0, DU => 0); RTC_Periph.CR.ALRAE := 1; RTC_Periph.CR.ALRAIE := 1; Lock; EXTI_Periph.IMR.MR.Arr (17) := 1; EXTI_Periph.RTSR.TR.Arr (17) := 1; end Set_Alarm; procedure Init is begin RCC_Periph.APB1ENR.PWREN := 1; RCC_Periph.CSR.LSION := 1; while RCC_Periph.CSR.LSIRDY = 0 loop null; end loop; PWR_Periph.CR.DBP := 1; RCC_Periph.BDCR.RTCEN := 1; RCC_Periph.BDCR.RTCSEL := 2#10#; end Init; end STM32GD.RTC;
SayCV/rtems-addon-packages
Ada
3,372
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2003,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision$ -- Binding Version 01.00 ------------------------------------------------------------------------------ package Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address is pragma Preelaborate (Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address); type Internet_V4_Address_Field is new Field_Type with null record; procedure Set_Field_Type (Fld : Field; Typ : Internet_V4_Address_Field); pragma Inline (Set_Field_Type); end Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address;
reznikmm/matreshka
Ada
4,343
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ limited with AMF.UML.Call_Operation_Actions; package AMF.Utp.Read_Timer_Actions is pragma Preelaborate; type Utp_Read_Timer_Action is limited interface; type Utp_Read_Timer_Action_Access is access all Utp_Read_Timer_Action'Class; for Utp_Read_Timer_Action_Access'Storage_Size use 0; not overriding function Get_Base_Call_Operation_Action (Self : not null access constant Utp_Read_Timer_Action) return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access is abstract; -- Getter of ReadTimerAction::base_CallOperationAction. -- not overriding procedure Set_Base_Call_Operation_Action (Self : not null access Utp_Read_Timer_Action; To : AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access) is abstract; -- Setter of ReadTimerAction::base_CallOperationAction. -- end AMF.Utp.Read_Timer_Actions;
reznikmm/matreshka
Ada
4,005
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Fo_Keep_Together_Attributes; package Matreshka.ODF_Fo.Keep_Together_Attributes is type Fo_Keep_Together_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Keep_Together_Attributes.ODF_Fo_Keep_Together_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Keep_Together_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Keep_Together_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Keep_Together_Attributes;
gusthoff/fixed_types
Ada
1,448
ads
------------------------------------------------------------------------------- -- -- FIXED TYPES -- -- Main package -- -- The MIT License (MIT) -- -- Copyright (c) 2015 Gustavo A. Hoffmann -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and / -- or sell copies of the Software, and to permit persons to whom the Software -- is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -- IN THE SOFTWARE. ------------------------------------------------------------------------------- package Fixed_Types is end Fixed_Types;
reznikmm/matreshka
Ada
3,694
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_Index_Attributes is pragma Preelaborate; type ODF_Table_Index_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Index_Attribute_Access is access all ODF_Table_Index_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Index_Attributes;
OneWingedShark/Byron
Ada
1,705
adb
pragma Wide_Character_Encoding(UTF8); with -- Lexington dependencies; mainly for printing/debugging. Lexington.Aux, Lexington.Token_Vector_Pkg, Ada.Text_IO, -- Actual Byron dependencies. Byron.Lexer, Byron.Reader, Byron.Parser, Byron.Internals.Types, -- Wide_Wide_Text_IO for debugging. Ada.Wide_Wide_Text_IO.Text_Streams; Procedure Compiler is -- Returns the file "test.adb", already opened. Function Test_File return Ada.Wide_Wide_Text_IO.File_Type is use Ada.Wide_Wide_Text_IO; Begin return Result : File_Type do Open( Result, Name => "test.adb", Mode => In_File); end return; End Test_File; -- A visual separator. Page_Break : constant Wide_Wide_String:= "------------------------------------------"; File : Ada.Wide_Wide_Text_IO.File_Type:= Test_File; Stream : aliased Ada.Wide_Wide_Text_IO.Text_Streams.Stream_Access:= Ada.Wide_Wide_Text_IO.Text_Streams.Stream(File); Tokens : Lexington.Token_Vector_Pkg.Vector; Begin TOKENIZING: Declare Use Byron.Internals.Types; File_Stream : constant Stream_Class := Stream_Class(Stream); Begin Ada.Wide_Wide_Text_IO.Put_Line( Page_Break ); Tokens:= Byron.Lexer( Input => Byron.Reader(File_Stream) ); End TOKENIZING; -- Print the tokens! PRINTING: For Token of Tokens loop declare use all type Lexington.Aux.Token_Pkg.Token; begin Ada.Wide_Wide_Text_IO.Put_Line( Lexington.Aux.Token_Pkg.Print(Token) ); end; End Loop PRINTING; -- Clean-up! Ada.Wide_Wide_Text_IO.Close(File); Ada.Wide_Wide_Text_IO.Put_Line( Page_Break ); Ada.Wide_Wide_Text_IO.Put_Line( "Done." ); End Compiler;
AdaCore/gpr
Ada
45
ads
package API is procedure A_Call; end API;
reznikmm/matreshka
Ada
4,632
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Vertical_Rel_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Vertical_Rel_Attribute_Node is begin return Self : Style_Vertical_Rel_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Vertical_Rel_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Vertical_Rel_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Vertical_Rel_Attribute, Style_Vertical_Rel_Attribute_Node'Tag); end Matreshka.ODF_Style.Vertical_Rel_Attributes;
AdaCore/gpr
Ada
3,960
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- -- Provide common support material for Adalog unit tests with Ada.Containers.Vectors; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Gpr_Parser_Support.Adalog.Logic_Var; with Gpr_Parser_Support.Adalog.Solver; with Gpr_Parser_Support.Adalog.Solver_Interface; generic type T is private; with function Image (I : T) return String is <>; package Gpr_Parser_Support.Adalog.Generic_Main_Support is package Refs is new Gpr_Parser_Support.Adalog.Logic_Var (T, Value_Image => Image); function Create (Name : String) return Refs.Logic_Var; package Solver_Ifc is new Solver_Interface (Refs); package T_Solver is new Gpr_Parser_Support.Adalog.Solver (Solver_Ifc); use Solver_Ifc, T_Solver, Refs; function "+" (R : Relation) return Relation; -- Register R and return it. This is used to keep track of allocated -- relations in testcases, to be released in Finalize. function "-" (S : String) return String_Access; -- Return a dynamically allocated string for S, keeping track of it to be -- released in Finalize. function R_All (Rels : Relation_Array; Dbg_String : String := "") return Relation is (+Create_All (Rels, -Dbg_String)); function R_Any (Rels : Relation_Array; Dbg_String : String := "") return Relation is (+Create_Any (Rels, -Dbg_String)); function "or" (L, R : Relation) return Relation is (+Create_Any ((L, R))); function "and" (L, R : Relation) return Relation is (+Create_All ((L, R))); function Domain (Var : Refs.Logic_Var; Rels : Value_Array; Dbg_String : String := "") return Relation is (+Create_Domain (Var, Rels, -Dbg_String)); function "=" (Var : Refs.Logic_Var; Val : T) return Relation is (+Create_Assign (Var, Val)); function "=" (L, R : Refs.Logic_Var) return Relation is (+Create_Unify (L, R)); function Propagate (L, R : Refs.Logic_Var; Conv : Converter_Type'Class := No_Converter; Dbg_String : String := "") return Relation is (+Create_Propagate (L, R, Conv, -Dbg_String)); function N_Propagate (To : Refs.Logic_Var; Comb : Combiner_Type'Class; Vars : Logic_Var_Array; Dbg_String : String := "") return Relation is (+Create_N_Propagate (To, Comb, Vars, -Dbg_String)); function Unify (L, R : Refs.Logic_Var; Dbg_String : String := "") return Relation is (+Create_Unify (L, R, -Dbg_String)); function Assign (L : Refs.Logic_Var; R : T; Conv : Converter_Type'Class := No_Converter; Dbg_String : String := "") return Relation is (+Create_Assign (L, R, Conv, -Dbg_String)); function Predicate (L : Refs.Logic_Var; P : Predicate_Type'Class; Dbg_String : String := "") return Relation is (+Create_Predicate (L, P, -Dbg_String)); function N_Predicate (Vars : Logic_Var_Array; P : N_Predicate_Type'Class; Dbg_String : String := "") return Relation is (+Create_N_Predicate (Vars, P, -Dbg_String)); function Logic_False return Relation is (+Create_False); function Logic_True return Relation is (+Create_True); procedure Solve_All (Rel : Relation; Timeout : Natural := 0); procedure Run_Main (Main : access procedure); procedure Setup_Traces; procedure Finalize; private package Relation_Vectors is new Ada.Containers.Vectors (Positive, Relation); package Variable_Vectors is new Ada.Containers.Vectors (Positive, Refs.Logic_Var, Refs."="); package String_Access_Vectors is new Ada.Containers.Vectors (Positive, String_Access); Relations : Relation_Vectors.Vector; Variables : Variable_Vectors.Vector; Strings : String_Access_Vectors.Vector; end Gpr_Parser_Support.Adalog.Generic_Main_Support;
srunr/Continued-Fractions
Ada
31,786
ads
-- PACKAGE Extended_Real -- -- package Extended_Real provides: -- An arbitrary precision floating-point data type: e_Real. -- -- Lower limit on precision is 28 decimals. No upper limit is -- enforced. All internal arithmetic is done on 64-bit Integers, -- so it's most efficient on 64-bit CPU's. The package is Pure. -- Floating point attributes (Ada 95) are implemented as function -- calls. The package exports standard floating point operators: -- "*", "+", "/", "**", "Abs", "<", ">", "<=" , ">=", etc. -- The standard operators make it easy to modify existing code to -- use extended precision arithmetic. Procedure calls Mult(X,Y) and -- Square(X) are also provided. They do multiplication "in-place", -- (overwrite X with the result) and are somewhat faster than the -- equivalent X := X*Y, and X := X*X. -- -- To set the precision search below for: -- -- Desired_Decimal_Digit_Precision -- -- package Extended_Real.Elementary_Functions provides: -- Sin, Cos, Sqrt, Arcsin, Arccos, Arctan, Log, Exp, Reciprocal (1/x), -- Reciprocal_Nth_Root (x to the power of -1/N), Divide, and "**" for -- e_Real arguments and e_Real exponents. Routines are Ada 95'ish. -- -- package e_Derivs provides: -- Extended precision routines for taking high order derivatives of -- functions. Functions made from "*", "+", "/", "**", Sin, Cos, -- Sqrt, Arcsin, Arccos, Arctan, Log, Exp, Compose = f(g(x)), -- and Reciprocal can be differentiated to order specified by user. -- -- package Extended_Real.IO provides: -- Text to extended-precision e_Real translation routines, and -- e_Real to Text translation routines. -- -- package Extended_Real.Rand provides: -- a (very) basic Random Number Generator. Really just for making -- test vectors. -- -- procedure e_real_demo_1.adb is: -- an introductory routine that demonstrates use of Extended_Real. -- -- procedure e_function_demo_1.adb is: -- an introductory routine that demonstrates use of -- Extended_Real.Elementary_Functions. -- -- procedure e_jacobi_eigen_demo_1.adb demonstrates: -- extended-precision eigen-decomposition on Hilbert's matrix using -- package e_Jacobi_Eigen. -- -- package e_Jacobi_Eigen is: -- a Jabobi iterative eigen-decomposition routine -- that shows how easy it is to upgrade a floating point routine -- to extended precision. e_Jacobi_Eigen uses package Extended_Real. -- -- good optimization on gcc/GNAT: -- -gnatNp -O3 -march="your machine architecture" -funroll-loops -ffast-math -- (sometimes:-ftree-vectorize -funroll-all-loops -falign-loops=4, -- -falign-loops=3, or -frename-registers are worth trying.) -- -- latest GNAT (gcc 4.3) try -- gnatmake -gnatNp -O3 -march=native -mtune=native -funroll-loops -ffast-math -- -- Always do a preliminary run which exercizes Assertions, and other Checks: -- -gnato -gnatV -gnata -- -- -- Because precision is arbitrary, Extended_Real is not specially -- optimized for any particular precision. The chosen design works best -- in the limit of 100's of decimal digits. If the package had been -- designed for 32 decimal digits of precision, then almost every feature -- of the design would have been different. On the other hand, performance -- seems to be respectable on 64-bit CPU's even at the lower limit (eg -- 28 or 38 decimal digits). (Comparison is with Intel's machine-optimized -- 32 decimal-digit floating point: i.e. Intel Fortran Real*16 on an Intel -- 64-bit CPU.) 32 digit floating point is probably the most often used -- (and most often needed) extended precision floating point. -- Most Fortrans (including the gcc Fortran) don't offer anything higher -- than 18 digit floating point. -- -- Common applications: -- 0. Estimation of error in lower precision floating-point calculations. -- 1. Evaluation of constants for math routines and Table-driven algorithms. -- 2. Evaluation of series solutions of special function, especially when -- the terms are constructed of large factorials and exponentials. -- 3. Evaluation of recurrance relations for special functions. -- -- Generics greatly reduce the work you have to do in modifying programs -- to use extended floating point: -- -- 1. place generic formal declarations -- of the required extended arithmetic functions at the the top of the -- package or subprogram to be modified. -- -- 2. use the unary "-" and "+" routines that convert Real to Extended: -- -- so that declarations -- Number : Generic_Formal_Type := +1.234; -- and statements like -- Z := (+4.567834E+012) * X; -- will be acceptible to both Real and Extended types. -- -- Underflows to Zero. Overflows to Positive or Negative infinity. I am -- still trying to decide if the Infinities are worth the trouble, but the -- trouble isn't great and there seem to be benefits. Sometimes you can -- put off worrying about overflow in intermediate calculation and test -- for it at the end by testing for Positive_Infinity. There are no NaNs. -- -- At the expense of purity, error messages using text_io can be -- re-enabled in the body - see top of body of Extended_Real. -- --*************************************************************************** -- -- SECTION I. -- -- Constants and overflow/underflow/constraint_error conventions. -- -- To test an arbitrary X : e_Real to see if X is Zero or infinity use the -- function Are_Equal (X, Zero) etc. It's written to make the test efficient. -- -- Underflows are to (unsigned) Zero; overflows to (signed) infinity: -- -- Infinity here means a finite number that is too large to represent -- in the floating point, and whose inverse is too small to represent in -- floating point. The following conventions seemed sensible. Treat inf's -- as Constraint Errors if uneasy with them. Assuming X is a positive e_Real: -- 0*inf = 0, inf * inf = inf, X / inf = 0, |X| * -inf = -inf, -- inf + inf = inf, X + inf = inf, -inf * inf = -inf, X - inf = -inf, -- inf > X = True, -inf < X = True, inf > -inf = True, -- (inf = -inf) = False -- -- Constraint_Error: -- -- The following ops have no sensible meaning, so Constraint_Error (ce) is -- raised. -- inf - inf => ce, inf / inf => ce, X / 0 => ce, inf / 0 => ce, -- inf < inf => ce. -- --*************************************************************************** -- SECTION II. -- -- Standard arithmetic operators. -- -- The arithmetic performed by these routines is supposed to be correct out -- to the number of decimals specified by Desired_Decimal_Digit_Precision, -- which you type in at the beginning of the spec. But the arithmetic is -- actually performed on digits well beyond this limit in order to guarantee -- this level of accuracy. The values -- held by these extra digits (guard digits) are usually almost correct. -- None of the following operators rounds away these guard digits. -- Rounding is done explicitly by calling Round_Away_Smallest_Guard_Digit(). -- In particular, none of the following comparison operators ("<", ">=", etc.) -- rounds away guard digits of operands before performing the comparison. -- All of them perform their comparisons out to the final guard digit. -- To reduce much confusion, I decided to leave rounding entirely up to the -- user, with Round_Away_.... Whether it's best to round or not -- depends on the algorithm. In a lot of algorithms it's better to -- round before you use the "Are_Equal" operator, and better not to round -- when you use the "<" and ">" operators. -- -- "=" or Are_Equal(X, Zero) is the most efficient way to find out if X -- is Zero. Same for Infinity. X < Zero is the efficient way find Sign of X. -- X > Zero is efficient way to test positivity of X. Zero < X and -- Zero > X are also handled efficiently. -- --*************************************************************************** -- SECTION III. -- -- Routines for conversion from Real to e_Real and back again. -- -- Makes it easy to write generics that can be instantiated with either -- conventional floating point of this extended floating point. -- The unary + and - are here to make it easier to convert programs from -- ordinary floating point to extended, by making it easy to replace -- -- X : Generic_Float_Type := 1.2345; --here instantiate w/ Float. -- X := 4.5678 * Y; --here instantiate w/ Float. -- -- with -- -- X : Generic_Float_Type := +1.2345; --here instantiate w/ e_Real or Float. -- X := (+4.5678) * Y; --same here. -- -- Now you can instantiate the generic with either e_Real or Float, -- (but you have to add the unary "+" to the list of generic formals.) -- --*************************************************************************** -- SECTION V. -- -- Real * Extended operations. -- -- More efficient operations. The "Real" is not your ordinary real, but -- something in the range 0.0 .. Radix-1, and integer valued, though it -- can have an negative or positive exponent. So it's not very appropriate -- for general use; -- -- The Real * Extended operations can be particularly efficient if -- the Real number is in the same range as a Digit, ie, 0..Radix-1. -- So we define a type e_Digit, a single real number with an -- exponent. These mixed multiplication "*" and "/" ops are used by the -- ascii to real_extended and real_extended to ascii translators, -- and by Newton's method calculations of elementary functions. -- This efficiency only comes if the real number can be represented by -- a single digit: integer values in the range 0..Radix-1, (times -- an exponent in a power-of-2 Radix. e.g. 0.5 is OK, 1.0/3.0 is not.) -- Make_e_Digit will raise a constraint error if the range of the -- intended real number is wrong. -- --********************************************************************** -- INTERNAL FORMAT OF e_Real -- -- Internally the extended numbers are stored in such a way that the -- value of e_Real number X is -- -- Max -- X = Radix**Exp * SUM {Radix**(-I) * Digit(I)}. -- I=0 -- -- Externally, the user sees e_Real (via the Exponent, and Fraction -- attribute functions) as tho' it were normalized. In other words, the -- value of X is -- -- Max -- X = Radix**Exp * SUM {Radix**(-I-1) * Digit(I)} -- I=0 -- -- Exp is called the "normalized" exponent. If Exp is the normalized exponent -- then, say, a binary number would be written: -- -- 0.111011010001 * 2**(Exp). -- -- In other words the first binary digit in the mantissa is of power 2**(-1). -- It is important to know this because the function Real'Exponent(x) returns -- the *normalized* exponent, and the function Real'Fraction(x) returns -- x * 2**(-Exp) where Exp is the normalized exponent. So in the above case, -- 'Fraction would return 0.111011010001. -- Also, in normalized form, the first binary digit of the mantissa is always -- non-zero. --*************************************************************************** generic type Real is digits <>; -- Make it 15 digits or greater. This is checked. -- This is usually the type you are going to replace with e_Real. desired_decimal_digits : Integer := 28; package Extended_Real is pragma Pure (Extended_Real); pragma Assert (Real'Digits >= 15); type e_Real is private; -- The extended precision floating pt type. -- Instructions: -- The only things that need to be adjusted by the user are -- -- Desired_Decimal_Digit_Precision -- and -- Desired_No_Of_Bits_In_Radix -- -- The 2 parameters follow next, along with instructions. Desired_Decimal_Digit_Precision : Integer := (if desired_decimal_digits < 28 then 28 else desired_decimal_digits); -- If you request 28 Decimal Digits, you usually get 29 or more. -- If you request 29 to 37 Decimal Digits, you usually get 38 or more. -- If you request 38 to 46 Decimal Digits, you usually get 47 or more. -- If you request 47 to 55 Decimal Digits, you usually get 56 or more. -- (And so on, in jumps of 9. Assumes Desired_No_Of_Bits_In_Radix = 30.) -- -- The simple operators "*", "+", "/" usually give the best precision. -- They should get the 1st guard digit right, and by themselves: -- If you request 28 Decimal Digits, they're good to about 37 Decimal Digits. -- If you request 37 Decimal Digits, they're good to about 46 Decimal Digits. -- -- Large complicated floating point computations will usually get both -- guard digits wrong and additional error will accumulate, so: -- If you request 28 Decimal Digits, ultimately expect <28 Decimal Digits. -- -- Lower limit on Desired_Decimal_Digit_Precision is 28. pragma Assert (Desired_Decimal_Digit_Precision >= 28); Desired_No_Of_Bits_In_Radix : constant := 30; -- Anything under 31 works, but should be adjusted for best performance: -- 30 is good if Desired_Decimal_Digit_Precision is 28 to 55. -- 29 is good standard setting (use it when Desired_Decimal_Digit_Precision > 55). -- 28 is good if Desired_Decimal_Digit_Precision >> 200. (But experiment.) -- -- 30 is necessary if you want the minimum decimal digits setting: 28. -- (If you choose 29 bits in Radix, you will get more decimals than you expect.) pragma Assert (Desired_No_Of_Bits_In_Radix <= 30); type e_Int is range -2**31+1 .. 2**31-1; subtype e_Integer is e_Int'Base; -- Type of Exponent. Also takes the place of Universal_Integer in the -- "attribute" functions defined below for e_Real. -- Keep it 32-bit. Smallest usually fastest. pragma Assert (e_Integer'Size <= 32); -- try fit e_Reals into small space; not essential, but Larger is slower. Zero : constant e_Real; One : constant e_Real; Positive_Infinity : constant e_Real; Negative_Infinity : constant e_Real; -- To test an arbitrary X : e_Real to see if X is Zero or infinity use the -- function: Are_Equal (X, Zero), or X = Zero etc. Testing for Zero is fast. -- Infinity here means a finite number that is too large to represent in the -- floating point, and whose inverse is too small to represent in floating -- point Zero is positive. -- SECTION II. Standard operators. -- -- To reduce much confusion, rounding is entirely up to the -- user, with Round_Away_Guard_Digits(). Whether it's best to round or not -- depends on the algorithm. For example, in some cases it is better to -- round before you use the "Are_Equal" operator, and better not to round -- when you use the "<" and ">" operators. (see intro.) function "*" (X, Y : e_Real) return e_Real; -- inline can slow it down. function "+" (X, Y : e_Real) return e_Real; -- inline can slow it down. function "-" (X, Y : e_Real) return e_Real; function "+" (X : e_Real) return e_Real; function "-" (X : e_Real) return e_Real; function "/" (X, Y : e_Real) return e_Real; function "**"(X : e_Real; N : Integer) return e_Real; procedure Square (X : in out e_Real); -- Same as X := X * X; (but usually faster if < 120 decimal digits.) procedure Mult (X : in out e_Real; Y : in e_Real); -- Same as X := X * Y; (but usually faster if < 120 decimal digits.) function "Abs" (X : e_Real) return e_Real; function Are_Equal (X, Y : e_Real) return Boolean; -- Return true only if -- equality is exact in the cases of Zero and the 2 infinities. -- Are_Equal(X, Zero) is the most efficient way to find out if X is Zero. -- Same for Infinity. X < Zero is the efficient way find Sign of X. -- X > Zero is efficient way to test positivity of X. Zero < X etc. OK too. function "<" (X, Y : e_Real) return Boolean; function "<=" (X, Y : e_Real) return Boolean; function ">" (X, Y : e_Real) return Boolean; function ">=" (X, Y : e_Real) return Boolean; function "=" (X, Y : e_Real) return Boolean renames Are_Equal; function Are_Not_Equal (X, Y : e_Real) return Boolean; -- not Are_Equal -- SECTION III. Conversions between Real to e_Real. (see intro.) function Make_Real (X : e_Real) return Real; function Make_Extended (X : Real) return e_Real; function "+" (X : Real) return e_Real renames Make_Extended; function "-" (X : Real) return e_Real; -- The above 3 functions are identical, except "-" changes sign of X. -- Makes it easy to write generics that can be instantiated with either -- conventional floating point of this extended floating point, via: -- X : Generic_Float_Type := +1.2345; function "+" (X : Integer) return e_Real; -- Only works in range of Real (15 digits usually). -- -- raises Constraint_Error -- -- if X is greater than about 10**Real'Digits. -- So X = 2**62 raises Constraint_Error if Real'Digits = 15. -- It's really just for making e_Reals out of small ints: +7. -- SECTION IV. Ada9X oriented attributes. -- -- Below: Machine attributes and the function calls (like Truncation). -- More information on the machine model is given in the introduction. -- The machine model is static, so none of the Machine oriented attributes, -- and none of the functions reflect varying precision. (see intro.) -- -- Written in the spirit of the Ada attributes, but the fit is never -- perfect. function Remainder (X, Y : e_Real) return e_Real; function Copy_Sign (Value, Sign : e_Real) return e_Real; function e_Real_Machine_Rounds return Boolean; function e_Real_Machine_Overflows return Boolean; function e_Real_Signed_Zeros return Boolean; function e_Real_Denorm return Boolean; -- These functions always return False. function e_Real_Machine_Emax return e_Integer; function e_Real_Machine_Emin return e_Integer; function e_Real_Machine_Mantissa return e_Integer; -- Always returns Mantissa'Length: all the digits including guards. -- -- NOT binary digits, NOT decimal digits. function e_Real_Machine_Radix return Real; -- Usually 2.0**29 or 2.0**30 for Integer digits; 2.0**24 for Flt pt digits. -- Returns: No_of_Bits_in_Radix (as a Real type). function Leading_Part (X : e_Real; Radix_Digits : e_Integer) return e_Real; -- Example: to set to zero all but the first digit of X use -- First_Digit := Leading_Part (X, 1); function Exponent (X : e_Real) return e_Integer; -- By convention return 0 for Zero. Else return nomalized Expon. -- Returns Max_Exponent+2 for the 2 infinities. -- NOT decimal, and NOT binary Exponent. function Fraction (X : e_Real) return e_Real; function Compose (Fraction : e_Real; Exponent : e_Integer) return e_Real; function Scaling ( X : e_Real; Adjustment : e_Integer) return e_Real; -- Chop off fractional parts. -- -- Rounding, Unbiased_Rounding, Ceiling, Floor return e_Real -- with Zero fractions. function Rounding (X : e_Real) return e_Real; function Unbiased_Rounding (X : e_Real) return e_Real; function Truncation (X : e_Real) return e_Real; function Ceiling (X : e_Real) return e_Real; function Floor (X : e_Real) return e_Real; -- Round away guard digits. -- -- function Machine rounds away the smallest Guard digit. -- There's no one right way to round away Guard Digits or choose -- Model_Epsilon's. Doesn't follow the Ada95 model for rounding -- 64-bit floats. That model doesn't seem to fit very well. function e_Real_Model_Epsilon return e_Real; -- At present this calls: e_Real_Model_Epsilon_2 which is -- 1 unit in the 3rd smallest digit. (The 3rd smallest digit -- is the 1st digit that is larger than the 2 guard digits.) function e_Real_Machine_Epsilon return e_Real; -- At present this calls: e_Real_Model_Epsilon_1 which is -- 1 unit in the 2nd smallest digit. (The 2nd smallest digit -- is the larger of the 2 guard digits.) function Machine (X : e_Real) return e_Real; -- This calls: -- Round_Away_Smallest_Guard_Digit -- function Round_Away_Smallest_Guard_Digit (X : e_Real) return e_Real; function e_Real_Model_Epsilon_1 return e_Real; -- One unit in the 2nd smallest digit. function e_Real_Model_Epsilon_2 return e_Real; -- One unit in the 3rd smallest digit. (The smallest digit that -- is *not* a Guard_Digit. -- -- Guard_Digits = 2 always; assume neither of them is correct: -- if there's 3 digits of Radix 2^30 then eps_2 is 2^(-30). -- if there's 4 digits of Radix 2^30 then eps_2 is 2^(-60). -- if there's 5 digits of Radix 2^30 then eps_2 is 2^(-90) or about 10**-27. -- -- So Eps_2 is the smallest number s/t eps_2+.999999999999 /= .999999999999 -- when you remove both guard digits. -- SECTION V. Digit * Extended operations. -- -- More efficient operations. "Digit" is not your ordinary real, but -- something in the range 0.0 .. Radix-1.0, and integral valued, though it -- can have a negative exponent. So the following is not very appropriate -- for general use; in the '83 version we export it so that it can be used by -- elementary function packages. type e_Digit is private; function "*" (X : e_Digit; Y : e_Real) return e_Real; function "/" (X : e_Real; Y : e_Digit) return e_Real; function Sum_Of (X : e_Digit; Y : e_Real) return e_Real; function "+" (X : e_Digit; Y : e_Real) return e_Real renames Sum_Of; function Scaling (X : e_Digit; Adjustment : e_Integer) return e_Digit; -- Multiply X by Radix**N where N = Adjustment. function Make_Extended (X : e_Digit) return e_Real; function Make_e_Digit (X : Real) return e_Digit; -- X must be a whole number: 0.0, 1.0, 2.0 etc. in the range 0..Radix-1, -- times some integer power of the Radix. So 0.5 is OK, but not 1/3. function Number_Of_Guard_Digits return e_Integer; -- Constant. To get number of digits that are being correctly calculated -- (by conservative estimates) use -- No_Correct_Digits = Present_Precision - Number_Of_Guard_Digits. function Minimum_No_Of_Digits_Allowed return e_Integer; -- Constant. Includes guard digits. private -- -- SECTION VII. Make the Data structure for e_Real. -- -- Using 32-bit ints for the Digits: (don't do it) --No_Of_Usable_Bits_In_Digit : constant := 31; -- bad idea; lots of trouble. --No_Of_Bits_In_Radix : constant := 13; -- can't use 14 or > -- Using 64-bit floats for the Digits: (don't bother) --No_Of_Usable_Bits_In_Digit : constant := 53; -- if using flt pt Mantissa (slow) --No_Of_Bits_In_Radix : constant := 24; -- Using 64-bit ints for the Digits: No_Of_Usable_Bits_In_Digit : constant := 63; -- Integer; must allow neg. vals No_Of_Bits_In_Radix : constant := Desired_No_Of_Bits_In_Radix; -- 30 is good if Desired_Decimal_Digit_Precision is 28 to 55. -- 29 is good standard setting (especially: Desired_Decimal_Digit_Precision > 55). -- 28 is good if Desired_Decimal_Digit_Precision is in the 100's. (But experiment.) Sums_Per_Carry : constant := 2**(No_Of_Usable_Bits_In_Digit-2*No_Of_Bits_In_Radix)-1; -- Sums_Per_Carry : This is number of sums you can accumulate during -- multiplication before the carrys need to be performed. -- -- You can do a large number of X*Y < Radix*Radix products, and then sum -- (Sums_Per_Carry+1) of them before a Carry is necessary in multiplication. -- a implies b is same as not (a) or b: pragma Assert (not (No_Of_Bits_In_Radix = 30) or Sums_Per_Carry <= 8-1); pragma Assert (not (No_Of_Bits_In_Radix = 29) or Sums_Per_Carry <= 32-1); pragma Assert (not (No_Of_Bits_In_Radix = 28) or Sums_Per_Carry <= 128-1); pragma Assert (not (No_Of_Bits_In_Radix = 27) or Sums_Per_Carry <= 512-1); pragma Assert (not (No_Of_Bits_In_Radix = 26) or Sums_Per_Carry <= 2048-1); -- -- Now that we know: No_Of_Bits_In_Radix, -- -- get number of binary digits and extended digits needed to make e_Real. -- Use the following formula for the number of Binary digits needed -- to meet Desired Decimal Digit precision D: -- -- Binary_Digits >= Ceiling (D * Log_Base_2_Of_10) + 1 -- -- where D = Desired_Decimal_Digit_Precision, and -- where Log_Base_2_Of_10 = 3.321928094887362. -- Ceiling of Real numbers with static declarations? -- -- Ceiling (3.321928094887 * D) <= Ceiling (3.322 * D) -- = Ceiling((3322.0 * D) / 1000.0) -- = (3322 * D - 1) / 1000 + 1 -- D is integer valued, so use integer Ceiling (A / B) = (A - 1) / B + 1. -- (for positive A). The above -- steps give us the number of binary digits required: No_Of_B_Digits. -- Next: min number of Radix 2.0**No_Of_Bits_In_Radix digits: No_Of_e_Digits. -- To get No_Of_e_Digits divide by No_Of_Bits_In_Radix and take the Ceiling. -- -- B is for binary, E for extended: ILog_Base_2_Of_10_x_1000 : constant := 3322; -- Round UP. D : Integer := Desired_Decimal_Digit_Precision - 2; No_Of_B_Digits : Integer := (ILog_Base_2_Of_10_x_1000 * D - 1) / 1000 + 2; No_Of_e_Digits : Integer := (No_Of_B_Digits - 1) / No_Of_Bits_In_Radix + 1; -- -- The following parameter settings give us 2 more words in the Mantissa -- than required. These two are essential in getting the full desired -- precision in extensive floating pt calculation, and also in IO, and in -- functions that are evaluated by Newton's method. -- (At least one such guard digit is essential anyway, to compensate for -- leftward shift of the mantissa during normalization.) -- The index of the digits is a subtype of the Exponent type because -- there are frequent conversions between the two. -- -- An assertion verifies that there are 2 guard digits. -- -- e_Integer is used as the type of the index of the extended digits -- because e_Integer is the type of the exponent (defined below). -- There's a close relationship between the exponent of the number and the -- index of the digits of the number. (They are often scaled -- simultaneously, there is a relationship between their ultimate ranges, -- so they are given the same type here.) -- Log_Base_2_Of_10 : constant := 3.321928094887362; -- No_Of_Guard_Digits : constant := 2; -- Guard_Digits are extra digits of precision at the end of the mantissa. -- -- The 2nd Guard_Digit makes -- the Elementary Math Functions full precision (or almost full). -- Also the IO routines need 2 Guard_Digits. pragma Assert (No_Of_Guard_Digits = 2); -- The following are not decimal digits. Ultimate_Correct_Digit : e_Integer := e_Int(No_Of_e_Digits) - e_Int(1); Ultimate_Digit : constant e_Integer := No_Of_Guard_Digits + Ultimate_Correct_Digit; subtype Digits_Base is e_Integer range 0..Ultimate_Digit+1; subtype Digit_Index is Digits_Base range 0..Ultimate_Digit; pragma Assert (Digit_Index'First = 0); -- some of the arithmetic in "+" assumes this. -- The following are not decimal digits. Min_No_Of_Correct_Digits : constant := 3; -- Things stop working if this is less than 3. Min_No_Of_Digits : constant := Min_No_Of_Correct_Digits + 2; -- The 2 is the min number of guard digits. pragma Assert (Ultimate_Digit >= Min_No_Of_Digits - 1); pragma Assert (Ultimate_Digit >= Min_No_Of_Correct_Digits+No_Of_Guard_Digits-1); -- Digits go from 0..Ultimate_Digit Max_Exponent : constant e_Integer := 2 ** (e_Integer'Size - 5); Min_Exponent : constant e_Integer := -Max_Exponent; -- The exponent is usually 16 or 32 bit int. Limits on its range are set -- below what the base type allows: no more than 1/4 the dynamic range -- of the base type. If we use 1/8 of that limit, it allows us to delay -- overflow check to end of most routines (except "**"). If we use 1/32 -- of that limit, it allows us to do IO more simply. So to make -- IO work, at present the requirement is 2 ** (e_Integer'Size - 5). pragma Assert (Max_Exponent <= 2 ** (e_Integer'Size - 5)); -- function e_Real_Machine_Emin returns Min_Exponent -- function e_Real_Machine_Emax returns Max_Exponent --subtype Digit_Type is Real; -- Can use Floats with 53 bit mantissas as Digit_Type. Make 2 changes -- above (search for No_Of_Usable_Bits_In_Digit and follow instructions) -- and 2 changes in body (compiler will tell you where). Also comment -- out next 3 statements. Amazingly, it worked nicely last time I did it. -- It's slow, and it only makes sense when 64 bit ints are bad or missing. type D_Type is range -2**63+1 .. 2**63-1; subtype Digit_Type is D_Type'Base; -- Must allow negative digits. Use 64 bit Integer. pragma Assert (Digit_Type'Last = 2**(Digit_Type'Size-1)-1); pragma Assert (Digit_Type'Size-1 >= No_Of_Usable_Bits_In_Digit); Digit_Zero : constant Digit_Type := Digit_Type (0); Digit_One : constant Digit_Type := Digit_Type (1); Digit_Two : constant Digit_Type := Digit_Type (2); Digit_Radix : constant Digit_Type := Digit_Two**No_Of_Bits_In_Radix; Half_Radix : constant Digit_Type := Digit_Two**(No_Of_Bits_In_Radix-1); Digit_Radix_Squared : constant Digit_Type := Digit_Radix * Digit_Radix; Digit_Radix_Minus_1 : constant Digit_Type := Digit_Radix - Digit_One; type Mantissa is array (Digit_Index) of Digit_Type; type e_Real is record Digit : Mantissa := (others => Digit_Zero); Exp : e_Integer := 0; Is_Zero : Boolean := True; Is_Positive : Boolean := True; Is_Infinite : Boolean := False; end record; --for e_Real'Size use (Digit_Type'Size*Mantissa'Length + e_Integer'Size*2); -- Make e_Real'Size Integer number of 64-bit words. Usually doesn't matter. -- Only for integer Digit_Type. Comment out for Float. pt. Digit types. Zero : constant e_Real := e_Real' ((others => Digit_Zero), 0, True, True, False); One : constant e_Real := e_Real' ((0 => Digit_One, others => Digit_Zero), 0, False, True, False); Positive_Infinity : constant e_Real := e_Real' ((others => Digit_Zero), Max_Exponent+4, False, True, True); Negative_Infinity : constant e_Real := e_Real' ((others => Digit_Zero), Max_Exponent+4, False, False, True); -- For efficiency, we need an optimized (Real * Extended) -- operation. So define type e_Digit, a single real number with -- an exponent. It's a real number that's restricted to integral values -- in the range to 0..Radix-1. type e_Digit is record Digit : Digit_Type := Digit_Zero; Exp : e_Integer := 0; Is_Zero : Boolean := True; Is_Positive : Boolean := True; end record; -- Constants used in body. Real is used for easy communication with e_Real. Real_Zero : constant Real := Real (0.0); Real_One : constant Real := Real (1.0); Real_Radix : constant Real := 2.0**No_Of_Bits_In_Radix; Radix_Minus_1 : constant Real := 2.0**No_Of_Bits_In_Radix - 1.0; Radix_Squared : constant Real := 2.0**(2*No_Of_Bits_In_Radix); Inverse_Radix : constant Real := 2.0**(-No_Of_Bits_In_Radix); Inverse_Radix_Squared : constant Real := Inverse_Radix * Inverse_Radix; end Extended_Real;
eyeonechi/invalid-behaviour-conservative-analysis
Ada
30,701
adb
-- SWEN90010 High Integrity Systems Engineering -- Assignment 3 -- -------------------------------------------------------------------------- -- | Name | Student ID | Student Email | -- -------------------------------------------------------------------------- -- | Margareta Hardiyanti | 852105 | [email protected] | -- | Ivan Ken Weng Chee | 736901 | [email protected] | -- -------------------------------------------------------------------------- with Instruction; use Instruction; with Debug; use Debug; -- used so we can print TAB character with Ada.Characters.Latin_1; package body Machine with SPARK_Mode is -- integer value type IntegerVal is range -(2**31) .. +(2**31 - 1); -- different states of dataval type DataValStates is (Uninitialized, Initialized); -- data values are 32-bit integers -- this is the type of words used in the virtual machine type DataVal (State : DataValStates := Uninitialized) is record case State is -- uninitialised DataVal has integer garbage value when Uninitialized => Garbage : IntegerVal; -- initialised DataVal has integer value when Initialized => Value : IntegerVal; end case; end record; -- register which distinguishes initialised and uninitialised values type Register is array (Reg) of DataVal; -- register of integer values used in executing program type IntegerRegister is array (Reg) of IntegerVal; -- memory which distinguishes initialised and uninitialised values type Memory is array (Addr) of DataVal; -- memory of integer values used in executing program type IntegerMemory is array (Addr) of IntegerVal; -- increases the program counter by an offset procedure IncPC(Ret :in out ReturnCode; Offs : in Offset; PC : in out ProgramCounter) is begin -- only increase PC if previous return is success if Ret = Success then -- check for integer overflow if (Integer(PC) <= Integer(ProgramCounter'Last) - Integer(Offs)) and (Integer(PC) >= Integer(ProgramCounter'First) - Integer(Offs)) then PC := ProgramCounter(Integer(PC) + Integer(Offs)); Ret := Success; else Ret := IllegalProgram; end if; end if; end IncPC; -- performs ADD instruction procedure DoAdd(Rd : in Reg; Rs1 : in Reg; Rs2 : in Reg; Ret : out ReturnCode; Regs : in out IntegerRegister) is begin -- check for integer overflow if (Regs(Rs2) > 0 and then Regs(Rs1) > IntegerVal'Last - Regs(Rs2)) or (Regs(Rs2) < 0 and then Regs(Rs1) < IntegerVal'First - Regs(Rs2)) then Ret := IllegalProgram; else Regs(Rd) := Regs(Rs1) + Regs(Rs2); Ret := Success; end if; end DoAdd; -- performs SUB function procedure DoSub(Rd : in Reg; Rs1 : in Reg; Rs2 : in Reg; Ret : out ReturnCode; Regs : in out IntegerRegister) is begin -- check for integer overflow if (Regs(Rs2) < 0 and then Regs(Rs1) > IntegerVal'Last + Regs(Rs2)) or (Regs(Rs2) > 0 and then Regs(Rs1) < IntegerVal'First + Regs(Rs2)) then Ret := IllegalProgram; else Regs(Rd) := Regs(Rs1) - Regs(Rs2); Ret := Success; end if; end DoSub; -- performs MUL instruction procedure DoMul(Rd : in Reg; Rs1 : in Reg; Rs2 : in Reg; Ret : out ReturnCode; Regs : in out IntegerRegister) is begin if (Regs(Rs1) < 0 and then Regs(Rs2) < 0 and then Regs(Rs1) < IntegerVal'Last / Regs(Rs2)) or (Regs(Rs1) < 0 and then Regs(Rs2) > 0 and then IntegerVal'First / Regs(Rs2) > Regs(Rs1)) or (Regs(Rs2) /= 0 and then Regs(Rs1) > 0 and then Regs(Rs1) > IntegerVal'Last / Regs(Rs2)) then Ret := IllegalProgram; else Regs(Rd) := Regs(Rs1) * Regs(Rs2); Ret := Success; end if; end DoMul; -- performs DIV instruction procedure DoDiv(Rd : in Reg; Rs1 : in Reg; Rs2 : in Reg; Ret : out ReturnCode; Regs : in out IntegerRegister) is begin -- check for dividing by 0 or integer overflow if Regs(Rs2) = 0 or (Regs(Rs1) = IntegerVal'First and Regs(Rs2) = -1) then Ret := IllegalProgram; else Regs(Rd) := Regs(Rs1) / Regs(Rs2); Ret := Success; end if; end DoDiv; -- performs LDR instruction procedure DoLdr(Rd : in Reg; Rs : in Reg; Offs : in Offset; Ret : out ReturnCode; Regs : in out IntegerRegister; Mem : in IntegerMemory) is begin -- check for memory access out-of-bounds if (Integer(Regs (Rs)) > Integer(Addr'Last) - Integer(Offs)) or (Integer(Regs (Rs)) < Integer(Addr'First) - Integer(Offs)) then Ret := IllegalProgram; else Regs(Rd) := Mem(Addr(Regs(Rs) + IntegerVal(Offs))); Ret := Success; end if; end DoLdr; -- performs STR instruction procedure DoStr(Ra : in Reg; Offs : in Offset; Rb : in Reg; Ret : out ReturnCode; Regs : in IntegerRegister; Mem : in out IntegerMemory) is begin -- check for memory access out-of-bounds if (Integer(Regs (Ra) ) > Integer(Addr'Last) - Integer(Offs)) or (Integer(Regs (Ra)) < Integer(Addr'First) - Integer(Offs)) then Ret := IllegalProgram; else Mem(Addr(Regs(Ra) + IntegerVal(Offs))) := Regs(Rb); Ret := Success; end if; end DoStr; -- performs MOV instruction procedure DoMov(Rd : in Reg; Offs : in Offset; Ret : out ReturnCode; Regs : in out IntegerRegister) is begin -- check for offset overflow if Integer(Offs) >= Integer(Offset'First) and Integer(Offs) <= Integer(Offset'Last) then Regs(Rd) := IntegerVal(Offs); Ret := Success; else Ret := IllegalProgram; end if; end DoMov; -- executes the virtual machine procedure ExecuteProgram(Prog : in Program; Cycles : in Integer; Ret : out ReturnCode; Result : out Integer) is -- the current cycle count CycleCount : Integer := 0; -- the current instruction Inst : Instr; -- the registers Regs : IntegerRegister := (others => 0); -- the memory Mem : IntegerMemory := (others => 0); -- the program counter PC : ProgramCounter := ProgramCounter'First; begin Ret := Success; Result := 0; -- exit loop if cycles exhausted or success not returned while (CycleCount < Cycles and Ret = Success) loop Inst := Prog(PC); -- debug print pc and current instruction Put(Integer(PC)); Put(':'); Put(Ada.Characters.Latin_1.HT); DebugPrintInstr(Inst); New_Line; -- call respective procedure based on instruction operand case Inst.Op is when ADD => DoAdd(Inst.AddRd, Inst.AddRs1, Inst.AddRs2, Ret, Regs); IncPC(Ret, 1, PC); when SUB => DoSub(Inst.SubRd, Inst.SubRs1, Inst.SubRs2, Ret, Regs); IncPC(Ret, 1, PC); when MUL => DoMul(Inst.MulRd, Inst.MulRs1, Inst.MulRs2, Ret, Regs); IncPC(Ret, 1, PC); when DIV => DoDiv(Inst.DivRd, Inst.DivRs1, Inst.DivRs2, Ret, Regs); IncPC(Ret, 1, PC); when LDR => DoLdr(Inst.LdrRd, Inst.LdrRs, Inst.LdrOffs, Ret, Regs, Mem); IncPC(Ret, 1, PC); when STR => DoStr(Inst.StrRa, Inst.StrOffs, Inst.StrRb, Ret, Regs, Mem); IncPC(Ret, 1, PC); when MOV => DoMov(Inst.MovRd, Inst.MovOffs, Ret, Regs); IncPC(Ret, 1, PC); when Instruction.RET => Result := Integer(Regs(Inst.RetRs)); Ret := Success; return; when JMP => IncPC(Ret, Inst.JmpOffs, PC); when JZ => if Regs(Inst.JzRa) = 0 then IncPC(Ret, Inst.JzOffs, PC); else IncPC(Ret, 1, PC); end if; when NOP => IncPC(Ret, 1, PC); end case; CycleCount := CycleCount + 1; end loop; -- Cycles instructions executed without a RET or invalid behaviour if Ret = Success then Ret := CyclesExhausted; end if; end ExecuteProgram; -- detects if a register or memory variable is uninitialised function DetectUninitializedVariable(Val : in DataVal) return Boolean is begin return Val.State = Uninitialized; end DetectUninitializedVariable; -- detects invalid ADD instruction behaviour function DetectInvalidAdd(Inst : in Instr; Regs: in Register) return Boolean is begin return -- {Rb : ?, Rc : ?} (DetectUninitializedVariable(Regs(Inst.AddRs1)) and DetectUninitializedVariable(Regs(Inst.AddRs2))) or -- {Rb : 0, Rc : ?} (Regs(Inst.AddRs1).State = Initialized and then Regs(Inst.AddRs2).State = Uninitialized and then Regs(Inst.AddRs1).Value /= 0) or -- {Rb : ?, Rc : 0} (Regs(Inst.AddRs1).State = Uninitialized and then Regs(Inst.AddRs2).State = Initialized and then Regs(Inst.AddRs2).Value /= 0) or -- {Rb : X, Rc : Y} (Regs(Inst.AddRs1).State = Initialized and then Regs(Inst.AddRs2).State = Initialized and then ( -- {Rb : X, Rc : +Y} (Regs(Inst.AddRs2).Value > 0 and then Regs(Inst.AddRs1).Value > IntegerVal'Last - Regs(Inst.AddRs2).Value) or -- {Rb : X, Rc : -Y} (Regs(Inst.AddRs2).Value < 0 and then Regs(Inst.AddRs1).Value < IntegerVal'First - Regs(Inst.AddRs2).Value) )); end DetectInvalidAdd; -- detects invalid SUB instruction behaviour function DetectInvalidSub(Inst : in Instr; Regs: in Register) return Boolean is begin return -- {Rb : ?, Rc : ?} (DetectUninitializedVariable(Regs(Inst.SubRs1)) and DetectUninitializedVariable(Regs(Inst.SubRs2))) or -- {Rb : -1, Rc : ?} (Regs(Inst.SubRs1).State = Initialized and then Regs(Inst.SubRs2).State = Uninitialized and then Regs(Inst.SubRs1).Value /= -1) or -- {Rb : ?, Rc : 0} (Regs(Inst.SubRs1).State = Uninitialized and then Regs(Inst.SubRs2).State = Initialized and then Regs(Inst.SubRs2).Value /= 0) or -- {Rb : X, Rc : Y} (Regs(Inst.SubRs1).State = Initialized and then Regs(Inst.SubRs2).State = Initialized and then ( -- {Rb : X, Rc : -Y} (Regs(Inst.SubRs2).Value < 0 and then (Regs(Inst.SubRs1).Value > IntegerVal'Last + Regs(Inst.SubRs2).Value)) or -- {Rb : X, Rc : +Y} (Regs(Inst.SubRs2).Value > 0 and then (Regs(Inst.SubRs1).Value < IntegerVal'First + Regs(Inst.SubRs2).Value)) )); end DetectInvalidSub; -- detects invalid MUL instruction behaviour function DetectInvalidMul(Inst : in Instr; Regs: in Register) return Boolean is begin return -- {Rb : ?, Rc : ?} (DetectUninitializedVariable(Regs(Inst.MulRs1)) and DetectUninitializedVariable(Regs(Inst.MulRs2))) or -- {Rb : 1, Rc : ?} (Regs(Inst.MulRs1).State = Initialized and then Regs(Inst.MulRs2).State = Uninitialized and then Regs(Inst.MulRs1).Value /= 1) or -- {Rb : 0, Rc : ?} (Regs(Inst.MulRs1).State = Initialized and then Regs(Inst.MulRs2).State = Uninitialized and then Regs(Inst.MulRs1).Value /= 0) or -- {Rb : ?, Rc : 1} (Regs(Inst.MulRs1).State = Uninitialized and then Regs(Inst.MulRs2).State = Initialized and then Regs(Inst.MulRs2).Value /= 1) or -- {Rb : ?, Rc : 0} (Regs(Inst.MulRs1).State = Uninitialized and then Regs(Inst.MulRs2).State = Initialized and then Regs(Inst.MulRs2).Value /= 0) or -- {Rb : X, Rc : Y} (Regs(Inst.MulRs1).State = Initialized and then Regs(Inst.MulRs2).State = Initialized and then ( -- {Rb : +X, Rc : +Y} (Regs(Inst.MulRs1).Value > 0 and then Regs(Inst.MulRs2).Value > 0 and then Regs(Inst.MulRs1).Value > IntegerVal'Last / Regs(Inst.MulRs2).Value) or -- {Rb : -X, Rc : -Y} (Regs(Inst.MulRs1).Value < 0 and then Regs(Inst.MulRs2).Value < 0 and then Regs(Inst.MulRs1).Value > IntegerVal'Last / Regs(Inst.MulRs2).Value) or -- {Rb : -X, Rc : +Y} (Regs(Inst.MulRs1).Value < 0 and then Regs(Inst.MulRs2).Value > 0 and then Regs(Inst.MulRs1).Value < IntegerVal'First / Regs(Inst.MulRs2).Value) or -- {Rb : +X, Rc : -Y} (Regs(Inst.MulRs1).Value > 0 and then Regs(Inst.MulRs2).Value < 0 and then Regs(Inst.MulRs2).Value < IntegerVal'First / Regs(Inst.MulRs1).Value) or -- {Rb : 0, Rc : Y} not (Regs(Inst.MulRs1).Value = 0 and then Regs(Inst.MulRs2).Value > 0 and then Regs(Inst.MulRs1).Value > IntegerVal'Last / Regs(Inst.MulRs2).Value) or -- {Rb : X, Rc : 0} not (Regs(Inst.MulRs2).Value = 0 and then Regs(Inst.MulRs1).Value > 0 and then Regs(Inst.MulRs2).Value > IntegerVal'Last / Regs(Inst.MulRs1).Value) )); end DetectInvalidMul; -- detects invalid DIV instruction behaviour function DetectInvalidDiv(Inst : in Instr; Regs: in Register) return Boolean is begin return -- {Rb : ?, Rc : ?} (DetectUninitializedVariable(Regs(Inst.DivRs1)) and DetectUninitializedVariable(Regs(Inst.DivRs2))) or -- {Rb : X, Rc : ?} (Regs(Inst.DivRs1).State = Initialized and then Regs(Inst.DivRs2).State = Uninitialized) or -- {Rb : ?, Rc : 0} (Regs(Inst.DivRs1).State = Uninitialized and then Regs(Inst.DivRs2).State = Initialized and then Regs(Inst.DivRs2).Value = 0) or -- {Rb : ?, Rc : -1} (Regs(Inst.DivRs1).State = Uninitialized and then Regs(Inst.DivRs2).State = Initialized and then Regs(Inst.DivRs2).Value = -1) or -- {Rb : X, Rc : Y} (Regs(Inst.DivRs1).State = Initialized and then Regs(Inst.DivRs2).State = Initialized and then ( -- {Rb : X, Rc : 0} (Regs(Inst.DivRs2).Value = 0) or -- {Rb : -(2**31), Rc : -1} (Regs(Inst.DivRs1).Value = IntegerVal'First and Regs(Inst.DivRs2).Value = -1) )); end DetectInvalidDiv; -- detects invalid LDR instruction behaviour function DetectInvalidLdr(Inst : in Instr; Regs: in Register) return Boolean is begin return (DetectUninitializedVariable(Regs(Inst.LdrRs))) or (Regs(Inst.LdrRs).State = Initialized and then ( (Regs(Inst.LdrRs).Value < IntegerVal(Addr'First) - IntegerVal(Inst.LdrOffs)) or (Regs(Inst.LdrRs).Value > IntegerVal(Addr'Last) - IntegerVal(Inst.LdrOffs)) )); end DetectInvalidLdr; -- detects invalid STR instruction behaviour function DetectInvalidStr(Inst : in Instr; Regs: in Register) return Boolean is begin return (DetectUninitializedVariable(Regs(Inst.StrRa))) or (Regs(Inst.StrRa).State = Initialized and then ( (Regs(Inst.StrRa).Value < IntegerVal(Addr'First) - IntegerVal(Inst.StrOffs)) or (Regs(Inst.StrRa).Value > IntegerVal(Addr'Last) - IntegerVal(Inst.StrOffs)) )); end DetectInvalidStr; -- detects invalid MOV instruction behaviour function DetectInvalidMov(Inst : in Instr) return Boolean is begin return -- MOV Ra -65536 (Inst.MovOffs < Offset'First) or -- MOV Ra 65536 (Inst.MovOffs > Offset'Last); end DetectInvalidMov; -- detects invalid JMP instruction behaviour function DetectInvalidJmp(Inst : in Instr; PC : in ProgramCounter) return Boolean is begin return -- JMP 0 (infinite loop) (Integer(Inst.JmpOffs) = 0) or -- JMP before program starts (Integer(PC) + Integer(Inst.JmpOffs) < Integer(ProgramCounter'First)) or -- JMP after program ends (Integer(PC) + Integer(Inst.JmpOffs) > Integer(ProgramCounter'Last)); end DetectInvalidJmp; -- detects invalid JZ instruction behaviour function DetectInvalidJz(Inst : in Instr; PC : in ProgramCounter; Regs: in Register) return Boolean is begin return -- {Ra : X} (Regs(Inst.JzRa).State = Initialized and then ( -- JZ 0 X (Regs(Inst.JzRa).Value = 0 and then ( -- JZ 0 0 (infinite loop) (Integer(Inst.JzOffs) = 0) or -- JZ before program starts (Integer(PC) + Integer(Inst.JzOffs) < Integer(ProgramCounter'First)) or -- JZ after program ends (Integer(PC) + Integer(Inst.JzOffs) > Integer(ProgramCounter'Last)) )) or -- JZ /0 X (Regs(Inst.JzRa).Value /= 0 and then ( -- JZ before program starts (Integer(PC) + 1 < Integer(ProgramCounter'First)) or -- JZ after program ends (Integer(PC) + 1 > Integer(ProgramCounter'Last))) ) )) or -- {Ra : ?} (Regs(Inst.JzRa).State = Uninitialized and then ( -- JZ 0 X (Regs(Inst.JzRa).Garbage = 0 and then ( -- JZ 0 0 (infinite loop) (Integer(Inst.JzOffs) = 0) or -- JZ before program starts (Integer(PC) + Integer(Inst.JzOffs) < Integer(ProgramCounter'First)) or -- JZ after program ends (Integer(PC) + Integer(Inst.JzOffs) > Integer(ProgramCounter'Last)) )) or -- JZ /0 X (Regs(Inst.JzRa).Garbage /= 0 and then ( -- JZ before program starts (Integer(PC) + 1 < Integer(ProgramCounter'First)) or -- JZ after program ends (Integer(PC) + 1 > Integer(ProgramCounter'Last))) ) )); end DetectInvalidJz; -- detects if a program has exhausted the given cycles function DetectInvalidCycle(CycleCount : in Integer; Cycles : in Integer) return Boolean is begin return not (CycleCount < Cycles); end DetectInvalidCycle; -- detects invalid program counter values function DetectInvalidPC(PC : in ProgramCounter; Offs : in Offset) return Boolean is begin return -- PC > 65536 (Integer(PC) > Integer(ProgramCounter'Last) - Integer(Offs)) or -- PC < 1 (Integer(PC) < Integer(ProgramCounter'First) - Integer(Offs)); end DetectInvalidPC; -- performs ADD instruction procedure PerformAdd(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Ret : in out Boolean) is begin if not (DetectInvalidAdd(Inst, Regs) or DetectInvalidPC(PC, 1)) then -- {Rb : X, Rc : Y} if Regs(Inst.AddRs1).State = Initialized and then Regs(Inst.AddRs2).State = Initialized then Regs(Inst.AddRd) := (State => Initialized, Value => Regs(Inst.AddRs1).Value + Regs(Inst.AddRs2).Value); -- {Rb : X, Rc : ?} elsif Regs(Inst.AddRs1).State = Initialized and then Regs(Inst.AddRs2).State = Uninitialized then Regs(Inst.AddRd) := (State => Initialized, Value => Regs(Inst.AddRs1).Value + Regs(Inst.AddRs2).Garbage); -- {Rb : ?, Rc : Y} elsif Regs(Inst.AddRs1).State = Uninitialized and then Regs(Inst.AddRs2).State = Initialized then Regs(Inst.AddRd) := (State => Initialized, Value => Regs(Inst.AddRs1).Garbage + Regs(Inst.AddRs2).Value); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformAdd; -- performs ADD instruction procedure PerformSub(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Ret : in out Boolean) is begin if not (DetectInvalidSub(Inst, Regs) or DetectInvalidPC(PC, 1)) then -- {Rb : X, Rc : Y} if Regs(Inst.SubRs1).State = Initialized and then Regs(Inst.SubRs2).State = Initialized then Regs(Inst.SubRd) := (State => Initialized, Value => Regs(Inst.SubRs1).Value - Regs(Inst.SubRs2).Value); -- {Rb : X, Rc : ?} elsif Regs(Inst.SubRs1).State = Initialized and then Regs(Inst.SubRs2).State = Uninitialized then Regs(Inst.SubRd) := (State => Initialized, Value => Regs(Inst.SubRs1).Value - Regs(Inst.SubRs2).Garbage); -- {Rb : ?, Rc : Y} elsif Regs(Inst.SubRs1).State = Uninitialized and then Regs(Inst.SubRs2).State = Initialized then Regs(Inst.SubRd) := (State => Initialized, Value => Regs(Inst.SubRs1).Garbage - Regs(Inst.SubRs2).Value); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformSub; -- performs MUL instruction procedure PerformMul(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Ret : in out Boolean) is begin if not (DetectInvalidMul(Inst, Regs) or DetectInvalidPC(PC, 1)) then -- {Rb : X, Rc : Y} if Regs(Inst.MulRs1).State = Initialized and then Regs(Inst.MulRs2).State = Initialized then Regs(Inst.MulRd) := (State => Initialized, Value => Regs(Inst.MulRs1).Value * Regs(Inst.MulRs2).Value); -- {Rb : X, Rc : ?} elsif Regs(Inst.MulRs1).State = Initialized and then Regs(Inst.MulRs2).State = Uninitialized then Regs(Inst.MulRd) := (State => Initialized, Value => Regs(Inst.MulRs1).Value * Regs(Inst.MulRs2).Garbage); -- {Rb : ?, Rc : Y} elsif Regs(Inst.MulRs1).State = Uninitialized and then Regs(Inst.MulRs2).State = Initialized then Regs(Inst.MulRd) := (State => Initialized, Value => Regs(Inst.MulRs1).Garbage * Regs(Inst.MulRs2).Value); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformMul; -- performs DIV instruction procedure PerformDiv(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Ret : in out Boolean) is begin if not (DetectInvalidDiv(Inst, Regs) or DetectInvalidPC(PC, 1)) then -- {Rb : X, Rc : Y} if Regs(Inst.DivRs1).State = Initialized and Regs(Inst.DivRs2).State = Initialized then Regs(Inst.DivRd) := (State => Initialized, Value => Regs(Inst.DivRs1).Value / Regs(Inst.DivRs2).Value); -- {Rb : ?, Rc : Y} elsif Regs(Inst.DivRs1).State = Uninitialized and then Regs(Inst.DivRs2).State = Initialized then Regs(Inst.DivRd) := (State => Initialized, Value => Regs(Inst.DivRs1).Garbage / Regs(Inst.DivRs2).Value); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformDiv; -- performs LDR instruction procedure PerformLdr(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Mem : in Memory; Ret : in out Boolean) is begin if not (DetectInvalidLdr(Inst, Regs) or DetectInvalidPC(PC, 1)) and Regs(Inst.LdrRs).State = Initialized then -- memory value has been initialised if Mem(Addr(Regs(Inst.LdrRs).Value + IntegerVal(Inst.LdrOffs))).State = Initialized then Regs(Inst.LdrRd) := (State => Initialized, Value => Mem(Addr(Regs(Inst.LdrRs).Value + IntegerVal(Inst.LdrOffs))).Value); -- memory value has not been initialised elsif Mem(Addr(Regs(Inst.LdrRs).Value + IntegerVal(Inst.LdrOffs))).State = Uninitialized then Regs(Inst.LdrRd) := (State => Initialized, Value => Mem(Addr(Regs(Inst.LdrRs).Value + IntegerVal(Inst.LdrOffs))).Garbage); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformLdr; -- performs STR instruction procedure PerformStr(Inst : in Instr; PC : in out ProgramCounter; Regs : in Register; Mem : in out Memory; Ret : in out Boolean) is begin if not (DetectInvalidStr(Inst, Regs) or DetectInvalidPC(PC, 1)) and Regs(Inst.StrRa).State = Initialized then -- register value has been initialised if Regs(Inst.StrRb).State = Initialized then -- initialise memory value Mem(Addr(Regs(Inst.StrRa).Value + IntegerVal(Inst.StrOffs))) := (State => Initialized, Value => Regs(Inst.StrRb).Value); -- register value has not been initialised elsif Regs(Inst.StrRb).State = Uninitialized then -- initialise memory value Mem(Addr(Regs(Inst.StrRa).Value + IntegerVal(Inst.StrOffs))) := (State => Initialized, Value => Regs(Inst.StrRb).Garbage); end if; PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformStr; -- performs MOV instruction procedure PerformMov(Inst : in Instr; PC : in out ProgramCounter; Regs : in out Register; Ret : in out Boolean) is begin if not (DetectInvalidMov(Inst) or DetectInvalidPC(PC, 1)) then -- initialise register value Regs(Inst.MovRd) := (State => Initialized, Value => IntegerVal(Inst.MovOffs)); PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformMov; -- performs RET instruction procedure PerformRet(Ret : out Boolean) is begin Ret := False; end PerformRet; -- performs JMP instruction procedure PerformJmp(Inst : in Instr; PC : in out ProgramCounter; Ret : in out Boolean) is begin if not (DetectInvalidJmp(Inst, PC) or DetectInvalidPC(PC, Inst.JmpOffs)) then PC := ProgramCounter(Integer(PC) + Integer(Inst.JmpOffs)); Ret := False; end if; end PerformJmp; -- performs JZ instruction procedure PerformJz(Inst : in Instr; PC : in out ProgramCounter; Regs : in Register; Ret : in out Boolean) is begin if not DetectInvalidJz(Inst, PC, Regs) then -- {Ra : 0} if (Regs(Inst.JzRa).State = Initialized) and then (Regs(Inst.JzRa).Value = 0) then if not DetectInvalidPC(PC, Inst.JzOffs) then PC := ProgramCounter(Integer(PC) + Integer(Inst.JzOffs)); Ret := False; end if; -- {Ra : /0} elsif (Regs(Inst.JzRa).State = Initialized) and then (Regs(Inst.JzRa).Value /= 0) then if not DetectInvalidPC(PC, 1) then PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; -- {Ra : ?} elsif Regs(Inst.JzRa).State = Uninitialized and Regs(Inst.JzRa).Garbage = 0 then if not DetectInvalidPC(PC, Inst.JzOffs) then PC := ProgramCounter(Integer(PC) + Integer(Inst.JzOffs)); Ret := False; end if; -- {Ra : ?} elsif Regs(Inst.JzRa).State = Uninitialized and Regs(Inst.JzRa).Garbage /= 0 then if not DetectInvalidPC(PC, 1) then PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end if; end if; end PerformJz; -- performs NOP instruction procedure PerformNop(PC : in out ProgramCounter; Ret : in out Boolean) is begin if not DetectInvalidPC(PC, 1) then PC := ProgramCounter(Integer(PC) + Integer(1)); Ret := False; end if; end PerformNop; -- performs dynamic analysis to detect invalid behaviour function DynamicAnalysis(Prog : in Program; Cycles : in Integer) return Boolean is CycleCount : Integer := 0; Inst : Instr; PC : ProgramCounter := ProgramCounter'First; Regs : Register; Mem : Memory; Ret : Boolean := True; begin -- set registers and memory to uninitialised values Regs := (others => (State => Uninitialized, Garbage => 0)); Mem := (others => (State => Uninitialized, Garbage => 0)); while not DetectInvalidCycle(CycleCount, Cycles) loop Inst := Prog(PC); Ret := True; -- debug print pc and current instruction -- Put(Integer(PC)); Put(':'); Put(Ada.Characters.Latin_1.HT); -- DebugPrintInstr(Inst); -- New_Line; -- call respective procedure based on instruction operand case Inst.Op is when ADD => PerformAdd(Inst, PC, Regs, Ret); when SUB => PerformSub(Inst, PC, Regs, Ret); when MUL => PerformMul(Inst, PC, Regs, Ret); when DIV => PerformDiv(Inst, PC, Regs, Ret); when LDR => PerformLdr(Inst, PC, Regs, Mem, Ret); when STR => PerformStr(Inst, PC, Regs, Mem, Ret); when MOV => PerformMov(Inst, PC, Regs, Ret); when Instruction.RET => PerformRet(Ret); exit; when JMP => PerformJmp(Inst, PC, Ret); when JZ => PerformJz(Inst, PC, Regs, Ret); when NOP => PerformNop(PC, Ret); end case; -- terminate early if invalid behaviour detected exit when (Ret = True); CycleCount := CycleCount + 1; end loop; return Ret; end DynamicAnalysis; -- detects invalid behaviour before executing the program function DetectInvalidBehaviour(Prog : in Program; Cycles : in Integer) return Boolean is begin return Ret : Boolean do Ret := DynamicAnalysis(Prog, Cycles); end return; end DetectInvalidBehaviour; end Machine;
zhmu/ananas
Ada
436
adb
-- { dg-do compile } package body Sync2 with SPARK_Mode, Refined_State => (State => (A, P, T)) is A : Integer := 0 with Atomic, Async_Readers, Async_Writers; protected type Prot_Typ is private Comp : Natural := 0; end Prot_Typ; P : Prot_Typ; task type Task_Typ; T : Task_Typ; protected body Prot_Typ is end Prot_Typ; task body Task_Typ is begin null; end Task_Typ; end Sync2;
burratoo/Acton
Ada
11,052
ads
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- FREESCALE MPC5544 -- -- -- -- MPC5554.ESCI -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with System.Storage_Elements; use System.Storage_Elements; package MPC5554.eSCI with Preelaborate is ---------------------------------------------------------------------------- -- Memory Addresses ---------------------------------------------------------------------------- eSCIA_Base_Address : constant Integer_Address := 16#FFFB_0000#; eSCIB_Base_Address : constant Integer_Address := 16#FFFB_0000#; CR1_Offset_Address : constant Integer_Address := 16#0000#; CR2_Offset_Address : constant Integer_Address := 16#0004#; DR_Offset_Address : constant Integer_Address := 16#0006#; SR_Offset_Address : constant Integer_Address := 16#0008#; LCR_Offset_Address : constant Integer_Address := 16#000C#; LTR_Offset_Address : constant Integer_Address := 16#0010#; LRR_Offset_Address : constant Integer_Address := 16#0014#; LPR_Offset_Address : constant Integer_Address := 16#0018#; ---------------------------------------------------------------------------- -- Hardware Features ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- -- eTPU Types --------------------------------------------------------------------------- -- Common Types -- eSCI Control Register 1 (ESCIx_CR1) type Baud_Rate_Type is range 1 .. 8191; type RSRC_Type is (Internal, External); type M_Type is (Eigth_Data_Bits, Nine_Data_Bits); type Wake_Type is (Idle_Line, Address_Mark); type ILT_Type is (After_Start_Bit, After_Stop_Bit); type Parity_T is (Even, Odd); type RWU_Type is (Normal, Wake_Up); type SBK_Type is (No_Break, Send_Break); type Control_1_Type is record Baud_Rate : Baud_Rate_Type; Loop_Select : Enable_Type; Receiver_Source : RSRC_Type; Data_Format_Mode : M_Type; Wake_Up_Condition : Wake_Type; Idle_Line : ILT_Type; Parity : Enable_Type; Parity_Type : Parity_T; Transmitter_Interrupt : Enable_Type; Transmission_Complete_Interrupt : Enable_Type; Receiver_Full_Interrupt : Enable_Type; Idle_Line_Interrupt : Enable_Type; Transmitter : Enable_Type; Receiver : Enable_Type; Receiver_Wake_Up : RWU_Type; Send_Break : SBK_Type; end record; -- eSCI Control Register 2 (ESCIx_CR2) type BRK13_Type is (Break_10_Bits, Break_13_Bits); type BESM13_Type is (At_Clock_9, At_Clock_13); type SBSTP_Type is ( Byte_Completely_Transmitted, Byte_Partially_Transmitted); type Control_2_Type is record Module_Disable : Disable_Type; Fast_Bit_Error_Detection : Enable_Type; Bit_Bus_Error_Stop : Enable_Type; Bit_Error_Interrupt : Enable_Type; RX_DMA_Channel : Enable_Type; TX_DMA_Channel : Enable_Type; Break_Transmit_Character_Length : BRK13_Type; Bit_Error_Sample_Mode : BESM13_Type; Bit_Error_Stop : SBSTP_Type; Overrunn_Error_Interrupt : Enable_Type; Noise_Flag_Interrupt : Enable_Type; Frmae_Error_Interrupt : Enable_Type; Parity_Flag_Interrupt : Enable_Type; end record; -- eSCI Data Register (ESCIx_DR) type Data_Type is record Upper_RX : Boolean; Upper_TX : Boolean; Lower : Character; end record; -- eSCI Status Register (ESCIx_SR) type Flag is (Low, High); type Status_Type is record Transmit_Data_Register_Empty_Flag : Flag; Transmit_Complete_Flag : Flag; Receive_Data_Register_Full_Flag : Flag; Idle_Line_Flag : Flag; Overrun_Flag : Flag; Noise_Flag : Flag; Framing_Error_Flag : Flag; Parity_Error_Flag : Flag; Bit_Error_Flag : Flag; Receiver_Active_Flag : Flag; Recieved_LIN_Data_Flag : Flag; LIN_FSM_Ready_Flag : Flag; LIN_Wake_UP_Flag : Flag; Slave_Time_Out_Flag : Flag; Physcial_Bus_Error_Flag : Flag; CRC_Error_Flag : Flag; Checksum_Error_Flag : Flag; Frame_Complete_Flag : Flag; LIN_Received_Register_Overflow_Flag : Flag; end record; ---------------------------------------------------------------------------- -- Hardware Respresentations ---------------------------------------------------------------------------- for RSRC_Type use (Internal => 0, External => 1); for M_Type use (Eigth_Data_Bits => 0, Nine_Data_Bits => 1); for Wake_Type use (Idle_Line => 0, Address_Mark => 1); for ILT_Type use (After_Start_Bit => 0, After_Stop_Bit => 1); for Parity_T use (Even => 0, Odd => 1); for RWU_Type use (Normal => 0, Wake_Up => 1); for SBK_Type use (No_Break => 0, Send_Break => 1); for Control_1_Type use record Baud_Rate at 0 range 3 .. 15; Loop_Select at 0 range 16 .. 16; Receiver_Source at 0 range 18 .. 18; Data_Format_Mode at 0 range 19 .. 19; Wake_Up_Condition at 0 range 20 .. 20; Idle_Line at 0 range 21 .. 21; Parity at 0 range 22 .. 22; Parity_Type at 0 range 23 .. 23; Transmitter_Interrupt at 0 range 24 .. 24; Transmission_Complete_Interrupt at 0 range 25 .. 25; Receiver_Full_Interrupt at 0 range 26 .. 26; Idle_Line_Interrupt at 0 range 27 .. 27; Transmitter at 0 range 28 .. 28; Receiver at 0 range 29 .. 29; Receiver_Wake_Up at 0 range 30 .. 30; Send_Break at 0 range 31 .. 31; end record; for BRK13_Type use (Break_10_Bits => 0, Break_13_Bits => 1); for BESM13_Type use (At_Clock_9 => 0, At_Clock_13 => 1); for SBSTP_Type use (Byte_Completely_Transmitted => 0, Byte_Partially_Transmitted => 1); for Control_2_Type use record Module_Disable at 0 range 0 .. 0; Fast_Bit_Error_Detection at 0 range 1 .. 1; Bit_Bus_Error_Stop at 0 range 2 .. 2; Bit_Error_Interrupt at 0 range 3 .. 3; RX_DMA_Channel at 0 range 4 .. 4; TX_DMA_Channel at 0 range 5 .. 5; Break_Transmit_Character_Length at 0 range 6 .. 6; Bit_Error_Sample_Mode at 0 range 8 .. 8; Bit_Error_Stop at 0 range 9 .. 9; Overrunn_Error_Interrupt at 0 range 12 .. 12; Noise_Flag_Interrupt at 0 range 13 .. 13; Frmae_Error_Interrupt at 0 range 14 .. 14; Parity_Flag_Interrupt at 0 range 15 .. 15; end record; for Data_Type use record Upper_RX at 0 range 0 .. 0; Upper_TX at 0 range 1 .. 1; Lower at 0 range 8 .. 15; end record; for Flag use (Low => 0, High => 1); for Status_Type use record Transmit_Data_Register_Empty_Flag at 0 range 0 .. 0; Transmit_Complete_Flag at 0 range 1 .. 1; Receive_Data_Register_Full_Flag at 0 range 2 .. 2; Idle_Line_Flag at 0 range 3 .. 3; Overrun_Flag at 0 range 4 .. 4; Noise_Flag at 0 range 5 .. 5; Framing_Error_Flag at 0 range 6 .. 6; Parity_Error_Flag at 0 range 7 .. 7; Bit_Error_Flag at 0 range 11 .. 11; Receiver_Active_Flag at 0 range 15 .. 15; Recieved_LIN_Data_Flag at 0 range 16 .. 16; LIN_FSM_Ready_Flag at 0 range 17 .. 17; LIN_Wake_UP_Flag at 0 range 18 .. 18; Slave_Time_Out_Flag at 0 range 19 .. 19; Physcial_Bus_Error_Flag at 0 range 20 .. 20; CRC_Error_Flag at 0 range 21 .. 21; Checksum_Error_Flag at 0 range 22 .. 22; Frame_Complete_Flag at 0 range 23 .. 23; LIN_Received_Register_Overflow_Flag at 0 range 31 .. 31; end record; ---------------------------------------------------------------------------- -- eTPU Registers ---------------------------------------------------------------------------- A_Control_Register_1 : Control_1_Type; for A_Control_Register_1'Address use System'To_Address (eSCIA_Base_Address + CR1_Offset_Address); A_Control_Register_2 : Control_2_Type; for A_Control_Register_2'Address use System'To_Address (eSCIA_Base_Address + CR2_Offset_Address); A_Data_Register : Data_Type; for A_Data_Register'Address use System'To_Address (eSCIA_Base_Address + DR_Offset_Address); A_Status_Register : Status_Type; for A_Status_Register'Address use System'To_Address (eSCIA_Base_Address + SR_Offset_Address); B_Control_Register_1 : Control_1_Type; for B_Control_Register_1'Address use System'To_Address (eSCIB_Base_Address + CR1_Offset_Address); B_Control_Register_2 : Control_2_Type; for B_Control_Register_2'Address use System'To_Address (eSCIB_Base_Address + CR2_Offset_Address); B_Data_Register : Data_Type; for B_Data_Register'Address use System'To_Address (eSCIB_Base_Address + DR_Offset_Address); B_Status_Register : Status_Type; for B_Status_Register'Address use System'To_Address (eSCIB_Base_Address + SR_Offset_Address); end MPC5554.eSCI;
zhmu/ananas
Ada
3,311
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . S E C U R E _ H A S H E S . S H A 2 _ 3 2 -- -- -- -- B o d y -- -- -- -- Copyright (C) 2009-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package body GNAT.Secure_Hashes.SHA2_32 is use Interfaces; ------------ -- Sigma0 -- ------------ function Sigma0 (X : Word) return Word is begin return Rotate_Right (X, 2) xor Rotate_Right (X, 13) xor Rotate_Right (X, 22); end Sigma0; ------------ -- Sigma1 -- ------------ function Sigma1 (X : Word) return Word is begin return Rotate_Right (X, 6) xor Rotate_Right (X, 11) xor Rotate_Right (X, 25); end Sigma1; -------- -- S0 -- -------- function S0 (X : Word) return Word is begin return Rotate_Right (X, 7) xor Rotate_Right (X, 18) xor Shift_Right (X, 3); end S0; -------- -- S1 -- -------- function S1 (X : Word) return Word is begin return Rotate_Right (X, 17) xor Rotate_Right (X, 19) xor Shift_Right (X, 10); end S1; end GNAT.Secure_Hashes.SHA2_32;
reznikmm/matreshka
Ada
3,759
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Number_Denominator_Value_Attributes is pragma Preelaborate; type ODF_Number_Denominator_Value_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Number_Denominator_Value_Attribute_Access is access all ODF_Number_Denominator_Value_Attribute'Class with Storage_Size => 0; end ODF.DOM.Number_Denominator_Value_Attributes;
reznikmm/matreshka
Ada
4,453
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis.Elements; with Asis.Expressions; package body Properties.Expressions.Short_Circuit is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is Text : League.Strings.Universal_String; Down : League.Strings.Universal_String; begin Down := Engine.Text.Get_Property (Asis.Expressions.Short_Circuit_Operation_Left_Expression (Element), Name); Text.Append (Down); case Asis.Elements.Expression_Kind (Element) is when Asis.An_Or_Else_Short_Circuit => Text.Append (" || "); when Asis.An_And_Then_Short_Circuit => Text.Append (" && "); when others => raise Program_Error; end case; Down := Engine.Text.Get_Property (Asis.Expressions.Short_Circuit_Operation_Right_Expression (Element), Name); Text.Append (Down); return Text; end Code; end Properties.Expressions.Short_Circuit;
ohenley/ada-util
Ada
2,453
ads
----------------------------------------------------------------------- -- util-beans -- Interface Definition with Getter and Setters -- Copyright (C) 2009, 2010, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- = Ada Beans = -- A [Java Bean](http://en.wikipedia.org/wiki/JavaBean) is an object that -- allows to access its properties through getters and setters. Java Beans -- rely on the use of Java introspection to discover the Java Bean object properties. -- -- An Ada Bean has some similarities with the Java Bean as it tries to expose -- an object through a set of common interfaces. Since Ada does not have introspection, -- some developer work is necessary. The Ada Bean framework consists of: -- -- * An `Object` concrete type that allows to hold any data type such -- as boolean, integer, floats, strings, dates and Ada bean objects. -- * A `Bean` interface that exposes a `Get_Value` and `Set_Value` -- operation through which the object properties can be obtained and modified. -- * A `Method_Bean` interface that exposes a set of method bindings -- that gives access to the methods provided by the Ada Bean object. -- -- The benefit of Ada beans comes when you need to get a value or invoke -- a method on an object but you don't know at compile time the object or method. -- That step being done later through some external configuration or presentation file. -- -- The Ada Bean framework is the basis for the implementation of -- Ada Server Faces and Ada EL. It allows the presentation layer to -- access information provided by Ada beans. -- -- @include util-beans-objects.ads -- @include util-beans-objects-datasets.ads -- @include util-beans-basic.ads package Util.Beans is pragma Preelaborate; end Util.Beans;
Fabien-Chouteau/lvgl-ada
Ada
1,028
ads
with Interfaces; use Interfaces; with Interfaces.C.Extensions; package Lv.Color_Types is subtype Color_Int_T is Uint8_T; type Color_T_Comp is record Blue : Extensions.Unsigned_2; Green : Extensions.Unsigned_3; Red : Extensions.Unsigned_3; end record with Pack, Object_Size => 8; pragma Convention (C_Pass_By_Copy, Color_T_Comp); type Color_T (Discr : unsigned := 0) is record case Discr is when 0 => Comp : aliased Color_T_Comp; when others => Full : aliased Color_Int_T; end case; end record with Pack, Object_Size => 8; pragma Convention (C_Pass_By_Copy, Color_T); pragma Unchecked_Union (Color_T); function Color_Make (R8, G8, B8 : Uint8_T) return Color_T is (Discr => 0, Comp => (Extensions.Unsigned_2 (Shift_Right (B8, 6)), Extensions.Unsigned_3 (Shift_Right (G8, 5)), Extensions.Unsigned_3 (Shift_Right (R8, 5)))) with Inline_Always; end Lv.Color_Types;
AdaCore/training_material
Ada
2,503
ads
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 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. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This file provides access to the unique device identifier on the STM32F4 -- microcontrollers from ST Microelectronics. pragma Restrictions (No_Elaboration_Code); package STM32F4.Device_Id is subtype Device_Id_Image is String (1 .. 12); function Unique_Id return Device_Id_Image; type Device_Id_Tuple is array (1 .. 3) of Word with Component_Size => 32; function Unique_Id return Device_Id_Tuple; end STM32F4.Device_Id;
reznikmm/matreshka
Ada
5,262
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.Generic_Collections; package AMF.OCL.Boolean_Literal_Exps.Collections is pragma Preelaborate; package OCL_Boolean_Literal_Exp_Collections is new AMF.Generic_Collections (OCL_Boolean_Literal_Exp, OCL_Boolean_Literal_Exp_Access); type Set_Of_OCL_Boolean_Literal_Exp is new OCL_Boolean_Literal_Exp_Collections.Set with null record; Empty_Set_Of_OCL_Boolean_Literal_Exp : constant Set_Of_OCL_Boolean_Literal_Exp; type Ordered_Set_Of_OCL_Boolean_Literal_Exp is new OCL_Boolean_Literal_Exp_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_OCL_Boolean_Literal_Exp : constant Ordered_Set_Of_OCL_Boolean_Literal_Exp; type Bag_Of_OCL_Boolean_Literal_Exp is new OCL_Boolean_Literal_Exp_Collections.Bag with null record; Empty_Bag_Of_OCL_Boolean_Literal_Exp : constant Bag_Of_OCL_Boolean_Literal_Exp; type Sequence_Of_OCL_Boolean_Literal_Exp is new OCL_Boolean_Literal_Exp_Collections.Sequence with null record; Empty_Sequence_Of_OCL_Boolean_Literal_Exp : constant Sequence_Of_OCL_Boolean_Literal_Exp; private Empty_Set_Of_OCL_Boolean_Literal_Exp : constant Set_Of_OCL_Boolean_Literal_Exp := (OCL_Boolean_Literal_Exp_Collections.Set with null record); Empty_Ordered_Set_Of_OCL_Boolean_Literal_Exp : constant Ordered_Set_Of_OCL_Boolean_Literal_Exp := (OCL_Boolean_Literal_Exp_Collections.Ordered_Set with null record); Empty_Bag_Of_OCL_Boolean_Literal_Exp : constant Bag_Of_OCL_Boolean_Literal_Exp := (OCL_Boolean_Literal_Exp_Collections.Bag with null record); Empty_Sequence_Of_OCL_Boolean_Literal_Exp : constant Sequence_Of_OCL_Boolean_Literal_Exp := (OCL_Boolean_Literal_Exp_Collections.Sequence with null record); end AMF.OCL.Boolean_Literal_Exps.Collections;
reznikmm/matreshka
Ada
4,712
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_Table.Multi_Deletion_Spanned_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Multi_Deletion_Spanned_Attribute_Node is begin return Self : Table_Multi_Deletion_Spanned_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Multi_Deletion_Spanned_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Multi_Deletion_Spanned_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Multi_Deletion_Spanned_Attribute, Table_Multi_Deletion_Spanned_Attribute_Node'Tag); end Matreshka.ODF_Table.Multi_Deletion_Spanned_Attributes;
strenkml/EE368
Ada
1,380
adb
with Memory.RAM; with Util; use Util; separate (Parser) procedure Parse_RAM(parser : in out Parser_Type; result : out Memory_Pointer) is latency : Time_Type := 1; burst : Time_Type := 0; word_size : Positive := 8; word_count : Natural := 0; begin while Get_Type(parser) = Open loop Match(parser, Open); declare name : constant String := Get_Value(parser); begin Match(parser, Literal); declare value : constant String := Get_Value(parser); begin Match(parser, Literal); if name = "latency" then latency := Time_Type'Value(value); elsif name = "burst" then burst := Time_Type'Value(value); elsif name = "word_size" then word_size := Positive'Value(value); elsif name = "word_count" then word_count := Natural'Value(value); else Raise_Error(parser, "invalid ram attribute: " & name); end if; end; end; Match(parser, Close); end loop; result := Memory_Pointer(RAM.Create_RAM(latency, burst, word_size, word_count)); exception when Data_Error | Constraint_Error => Raise_Error(parser, "invalid value in ram"); end Parse_RAM;
reznikmm/gela
Ada
1,238
ads
-- This package provides Unit_Container interface and its methods. with League.Strings; limited with Gela.Compilation_Unit_Sets; limited with Gela.Contexts; package Gela.Unit_Containers is pragma Preelaborate; type Unit_Container is limited interface; -- Container for compilation units type Unit_Container_Access is access all Unit_Container'Class; for Unit_Container_Access'Storage_Size use 0; type Unit_Container_List is array (Positive range <>) of Unit_Container_Access; function Name (Self : Unit_Container) return League.Strings.Universal_String is abstract; -- Return Name of container function Context (Self : Unit_Container) return Gela.Contexts.Context_Access is abstract; -- Return correspondig context function Library_Unit_Declarations (Self : Unit_Container) return Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access is abstract; -- Return set of library unit declarations of container function Compilation_Unit_Bodies (Self : Unit_Container) return Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access is abstract; -- Return set of bodies and subunits of container end Gela.Unit_Containers;
zhmu/ananas
Ada
22,439
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . C H A R A C T E R S . W I D E _ W I D E _ L A T I N _ 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. -- -- -- ------------------------------------------------------------------------------ -- This package provides definitions analogous to those in the RM defined -- package Ada.Characters.Latin_1 except that the type of the constants -- is Wide_Wide_Character instead of Character. The provision of this package -- is in accordance with the implementation permission in RM (A.3.3(27)). package Ada.Characters.Wide_Wide_Latin_1 is pragma Pure; ------------------------ -- Control Characters -- ------------------------ NUL : constant Wide_Wide_Character := Wide_Wide_Character'Val (0); SOH : constant Wide_Wide_Character := Wide_Wide_Character'Val (1); STX : constant Wide_Wide_Character := Wide_Wide_Character'Val (2); ETX : constant Wide_Wide_Character := Wide_Wide_Character'Val (3); EOT : constant Wide_Wide_Character := Wide_Wide_Character'Val (4); ENQ : constant Wide_Wide_Character := Wide_Wide_Character'Val (5); ACK : constant Wide_Wide_Character := Wide_Wide_Character'Val (6); BEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (7); BS : constant Wide_Wide_Character := Wide_Wide_Character'Val (8); HT : constant Wide_Wide_Character := Wide_Wide_Character'Val (9); LF : constant Wide_Wide_Character := Wide_Wide_Character'Val (10); VT : constant Wide_Wide_Character := Wide_Wide_Character'Val (11); FF : constant Wide_Wide_Character := Wide_Wide_Character'Val (12); CR : constant Wide_Wide_Character := Wide_Wide_Character'Val (13); SO : constant Wide_Wide_Character := Wide_Wide_Character'Val (14); SI : constant Wide_Wide_Character := Wide_Wide_Character'Val (15); DLE : constant Wide_Wide_Character := Wide_Wide_Character'Val (16); DC1 : constant Wide_Wide_Character := Wide_Wide_Character'Val (17); DC2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (18); DC3 : constant Wide_Wide_Character := Wide_Wide_Character'Val (19); DC4 : constant Wide_Wide_Character := Wide_Wide_Character'Val (20); NAK : constant Wide_Wide_Character := Wide_Wide_Character'Val (21); SYN : constant Wide_Wide_Character := Wide_Wide_Character'Val (22); ETB : constant Wide_Wide_Character := Wide_Wide_Character'Val (23); CAN : constant Wide_Wide_Character := Wide_Wide_Character'Val (24); EM : constant Wide_Wide_Character := Wide_Wide_Character'Val (25); SUB : constant Wide_Wide_Character := Wide_Wide_Character'Val (26); ESC : constant Wide_Wide_Character := Wide_Wide_Character'Val (27); FS : constant Wide_Wide_Character := Wide_Wide_Character'Val (28); GS : constant Wide_Wide_Character := Wide_Wide_Character'Val (29); RS : constant Wide_Wide_Character := Wide_Wide_Character'Val (30); US : constant Wide_Wide_Character := Wide_Wide_Character'Val (31); ------------------------------------- -- ISO 646 Graphic Wide_Wide_Characters -- ------------------------------------- Space : constant Wide_Wide_Character := ' '; -- WC'Val(32) Exclamation : constant Wide_Wide_Character := '!'; -- WC'Val(33) Quotation : constant Wide_Wide_Character := '"'; -- WC'Val(34) Number_Sign : constant Wide_Wide_Character := '#'; -- WC'Val(35) Dollar_Sign : constant Wide_Wide_Character := '$'; -- WC'Val(36) Percent_Sign : constant Wide_Wide_Character := '%'; -- WC'Val(37) Ampersand : constant Wide_Wide_Character := '&'; -- WC'Val(38) Apostrophe : constant Wide_Wide_Character := '''; -- WC'Val(39) Left_Parenthesis : constant Wide_Wide_Character := '('; -- WC'Val(40) Right_Parenthesis : constant Wide_Wide_Character := ')'; -- WC'Val(41) Asterisk : constant Wide_Wide_Character := '*'; -- WC'Val(42) Plus_Sign : constant Wide_Wide_Character := '+'; -- WC'Val(43) Comma : constant Wide_Wide_Character := ','; -- WC'Val(44) Hyphen : constant Wide_Wide_Character := '-'; -- WC'Val(45) Minus_Sign : Wide_Wide_Character renames Hyphen; Full_Stop : constant Wide_Wide_Character := '.'; -- WC'Val(46) Solidus : constant Wide_Wide_Character := '/'; -- WC'Val(47) -- Decimal digits '0' though '9' are at positions 48 through 57 Colon : constant Wide_Wide_Character := ':'; -- WC'Val(58) Semicolon : constant Wide_Wide_Character := ';'; -- WC'Val(59) Less_Than_Sign : constant Wide_Wide_Character := '<'; -- WC'Val(60) Equals_Sign : constant Wide_Wide_Character := '='; -- WC'Val(61) Greater_Than_Sign : constant Wide_Wide_Character := '>'; -- WC'Val(62) Question : constant Wide_Wide_Character := '?'; -- WC'Val(63) Commercial_At : constant Wide_Wide_Character := '@'; -- WC'Val(64) -- Letters 'A' through 'Z' are at positions 65 through 90 Left_Square_Bracket : constant Wide_Wide_Character := '['; -- WC'Val (91) Reverse_Solidus : constant Wide_Wide_Character := '\'; -- WC'Val (92) Right_Square_Bracket : constant Wide_Wide_Character := ']'; -- WC'Val (93) Circumflex : constant Wide_Wide_Character := '^'; -- WC'Val (94) Low_Line : constant Wide_Wide_Character := '_'; -- WC'Val (95) Grave : constant Wide_Wide_Character := '`'; -- WC'Val (96) LC_A : constant Wide_Wide_Character := 'a'; -- WC'Val (97) LC_B : constant Wide_Wide_Character := 'b'; -- WC'Val (98) LC_C : constant Wide_Wide_Character := 'c'; -- WC'Val (99) LC_D : constant Wide_Wide_Character := 'd'; -- WC'Val (100) LC_E : constant Wide_Wide_Character := 'e'; -- WC'Val (101) LC_F : constant Wide_Wide_Character := 'f'; -- WC'Val (102) LC_G : constant Wide_Wide_Character := 'g'; -- WC'Val (103) LC_H : constant Wide_Wide_Character := 'h'; -- WC'Val (104) LC_I : constant Wide_Wide_Character := 'i'; -- WC'Val (105) LC_J : constant Wide_Wide_Character := 'j'; -- WC'Val (106) LC_K : constant Wide_Wide_Character := 'k'; -- WC'Val (107) LC_L : constant Wide_Wide_Character := 'l'; -- WC'Val (108) LC_M : constant Wide_Wide_Character := 'm'; -- WC'Val (109) LC_N : constant Wide_Wide_Character := 'n'; -- WC'Val (110) LC_O : constant Wide_Wide_Character := 'o'; -- WC'Val (111) LC_P : constant Wide_Wide_Character := 'p'; -- WC'Val (112) LC_Q : constant Wide_Wide_Character := 'q'; -- WC'Val (113) LC_R : constant Wide_Wide_Character := 'r'; -- WC'Val (114) LC_S : constant Wide_Wide_Character := 's'; -- WC'Val (115) LC_T : constant Wide_Wide_Character := 't'; -- WC'Val (116) LC_U : constant Wide_Wide_Character := 'u'; -- WC'Val (117) LC_V : constant Wide_Wide_Character := 'v'; -- WC'Val (118) LC_W : constant Wide_Wide_Character := 'w'; -- WC'Val (119) LC_X : constant Wide_Wide_Character := 'x'; -- WC'Val (120) LC_Y : constant Wide_Wide_Character := 'y'; -- WC'Val (121) LC_Z : constant Wide_Wide_Character := 'z'; -- WC'Val (122) Left_Curly_Bracket : constant Wide_Wide_Character := '{'; -- WC'Val (123) Vertical_Line : constant Wide_Wide_Character := '|'; -- WC'Val (124) Right_Curly_Bracket : constant Wide_Wide_Character := '}'; -- WC'Val (125) Tilde : constant Wide_Wide_Character := '~'; -- WC'Val (126) DEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (127); -------------------------------------- -- ISO 6429 Control Wide_Wide_Characters -- -------------------------------------- IS4 : Wide_Wide_Character renames FS; IS3 : Wide_Wide_Character renames GS; IS2 : Wide_Wide_Character renames RS; IS1 : Wide_Wide_Character renames US; Reserved_128 : constant Wide_Wide_Character := Wide_Wide_Character'Val (128); Reserved_129 : constant Wide_Wide_Character := Wide_Wide_Character'Val (129); BPH : constant Wide_Wide_Character := Wide_Wide_Character'Val (130); NBH : constant Wide_Wide_Character := Wide_Wide_Character'Val (131); Reserved_132 : constant Wide_Wide_Character := Wide_Wide_Character'Val (132); NEL : constant Wide_Wide_Character := Wide_Wide_Character'Val (133); SSA : constant Wide_Wide_Character := Wide_Wide_Character'Val (134); ESA : constant Wide_Wide_Character := Wide_Wide_Character'Val (135); HTS : constant Wide_Wide_Character := Wide_Wide_Character'Val (136); HTJ : constant Wide_Wide_Character := Wide_Wide_Character'Val (137); VTS : constant Wide_Wide_Character := Wide_Wide_Character'Val (138); PLD : constant Wide_Wide_Character := Wide_Wide_Character'Val (139); PLU : constant Wide_Wide_Character := Wide_Wide_Character'Val (140); RI : constant Wide_Wide_Character := Wide_Wide_Character'Val (141); SS2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (142); SS3 : constant Wide_Wide_Character := Wide_Wide_Character'Val (143); DCS : constant Wide_Wide_Character := Wide_Wide_Character'Val (144); PU1 : constant Wide_Wide_Character := Wide_Wide_Character'Val (145); PU2 : constant Wide_Wide_Character := Wide_Wide_Character'Val (146); STS : constant Wide_Wide_Character := Wide_Wide_Character'Val (147); CCH : constant Wide_Wide_Character := Wide_Wide_Character'Val (148); MW : constant Wide_Wide_Character := Wide_Wide_Character'Val (149); SPA : constant Wide_Wide_Character := Wide_Wide_Character'Val (150); EPA : constant Wide_Wide_Character := Wide_Wide_Character'Val (151); SOS : constant Wide_Wide_Character := Wide_Wide_Character'Val (152); Reserved_153 : constant Wide_Wide_Character := Wide_Wide_Character'Val (153); SCI : constant Wide_Wide_Character := Wide_Wide_Character'Val (154); CSI : constant Wide_Wide_Character := Wide_Wide_Character'Val (155); ST : constant Wide_Wide_Character := Wide_Wide_Character'Val (156); OSC : constant Wide_Wide_Character := Wide_Wide_Character'Val (157); PM : constant Wide_Wide_Character := Wide_Wide_Character'Val (158); APC : constant Wide_Wide_Character := Wide_Wide_Character'Val (159); ----------------------------------- -- Other Graphic Wide_Wide_Characters -- ----------------------------------- -- Wide_Wide_Character positions 160 (16#A0#) .. 175 (16#AF#) No_Break_Space : constant Wide_Wide_Character := Wide_Wide_Character'Val (160); NBSP : Wide_Wide_Character renames No_Break_Space; Inverted_Exclamation : constant Wide_Wide_Character := Wide_Wide_Character'Val (161); Cent_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (162); Pound_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (163); Currency_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (164); Yen_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (165); Broken_Bar : constant Wide_Wide_Character := Wide_Wide_Character'Val (166); Section_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (167); Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (168); Copyright_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (169); Feminine_Ordinal_Indicator : constant Wide_Wide_Character := Wide_Wide_Character'Val (170); Left_Angle_Quotation : constant Wide_Wide_Character := Wide_Wide_Character'Val (171); Not_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (172); Soft_Hyphen : constant Wide_Wide_Character := Wide_Wide_Character'Val (173); Registered_Trade_Mark_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (174); Macron : constant Wide_Wide_Character := Wide_Wide_Character'Val (175); -- Wide_Wide_Character positions 176 (16#B0#) .. 191 (16#BF#) Degree_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (176); Ring_Above : Wide_Wide_Character renames Degree_Sign; Plus_Minus_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (177); Superscript_Two : constant Wide_Wide_Character := Wide_Wide_Character'Val (178); Superscript_Three : constant Wide_Wide_Character := Wide_Wide_Character'Val (179); Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (180); Micro_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (181); Pilcrow_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (182); Paragraph_Sign : Wide_Wide_Character renames Pilcrow_Sign; Middle_Dot : constant Wide_Wide_Character := Wide_Wide_Character'Val (183); Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (184); Superscript_One : constant Wide_Wide_Character := Wide_Wide_Character'Val (185); Masculine_Ordinal_Indicator : constant Wide_Wide_Character := Wide_Wide_Character'Val (186); Right_Angle_Quotation : constant Wide_Wide_Character := Wide_Wide_Character'Val (187); Fraction_One_Quarter : constant Wide_Wide_Character := Wide_Wide_Character'Val (188); Fraction_One_Half : constant Wide_Wide_Character := Wide_Wide_Character'Val (189); Fraction_Three_Quarters : constant Wide_Wide_Character := Wide_Wide_Character'Val (190); Inverted_Question : constant Wide_Wide_Character := Wide_Wide_Character'Val (191); -- Wide_Wide_Character positions 192 (16#C0#) .. 207 (16#CF#) UC_A_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (192); UC_A_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (193); UC_A_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (194); UC_A_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (195); UC_A_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (196); UC_A_Ring : constant Wide_Wide_Character := Wide_Wide_Character'Val (197); UC_AE_Diphthong : constant Wide_Wide_Character := Wide_Wide_Character'Val (198); UC_C_Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (199); UC_E_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (200); UC_E_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (201); UC_E_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (202); UC_E_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (203); UC_I_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (204); UC_I_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (205); UC_I_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (206); UC_I_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (207); -- Wide_Wide_Character positions 208 (16#D0#) .. 223 (16#DF#) UC_Icelandic_Eth : constant Wide_Wide_Character := Wide_Wide_Character'Val (208); UC_N_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (209); UC_O_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (210); UC_O_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (211); UC_O_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (212); UC_O_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (213); UC_O_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (214); Multiplication_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (215); UC_O_Oblique_Stroke : constant Wide_Wide_Character := Wide_Wide_Character'Val (216); UC_U_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (217); UC_U_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (218); UC_U_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (219); UC_U_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (220); UC_Y_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (221); UC_Icelandic_Thorn : constant Wide_Wide_Character := Wide_Wide_Character'Val (222); LC_German_Sharp_S : constant Wide_Wide_Character := Wide_Wide_Character'Val (223); -- Wide_Wide_Character positions 224 (16#E0#) .. 239 (16#EF#) LC_A_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (224); LC_A_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (225); LC_A_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (226); LC_A_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (227); LC_A_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (228); LC_A_Ring : constant Wide_Wide_Character := Wide_Wide_Character'Val (229); LC_AE_Diphthong : constant Wide_Wide_Character := Wide_Wide_Character'Val (230); LC_C_Cedilla : constant Wide_Wide_Character := Wide_Wide_Character'Val (231); LC_E_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (232); LC_E_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (233); LC_E_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (234); LC_E_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (235); LC_I_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (236); LC_I_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (237); LC_I_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (238); LC_I_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (239); -- Wide_Wide_Character positions 240 (16#F0#) .. 255 (16#FF) LC_Icelandic_Eth : constant Wide_Wide_Character := Wide_Wide_Character'Val (240); LC_N_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (241); LC_O_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (242); LC_O_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (243); LC_O_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (244); LC_O_Tilde : constant Wide_Wide_Character := Wide_Wide_Character'Val (245); LC_O_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (246); Division_Sign : constant Wide_Wide_Character := Wide_Wide_Character'Val (247); LC_O_Oblique_Stroke : constant Wide_Wide_Character := Wide_Wide_Character'Val (248); LC_U_Grave : constant Wide_Wide_Character := Wide_Wide_Character'Val (249); LC_U_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (250); LC_U_Circumflex : constant Wide_Wide_Character := Wide_Wide_Character'Val (251); LC_U_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (252); LC_Y_Acute : constant Wide_Wide_Character := Wide_Wide_Character'Val (253); LC_Icelandic_Thorn : constant Wide_Wide_Character := Wide_Wide_Character'Val (254); LC_Y_Diaeresis : constant Wide_Wide_Character := Wide_Wide_Character'Val (255); end Ada.Characters.Wide_Wide_Latin_1;
charlie5/cBound
Ada
1,348
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_error_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_error_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_error_cookie_t.Item, Element_Array => xcb.xcb_glx_get_error_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_error_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_error_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_error_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_error_cookie_t;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
2,912
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.RNG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_RNGEN_Field is STM32_SVD.Bit; subtype CR_IE_Field is STM32_SVD.Bit; -- control register type CR_Register is record -- unspecified Reserved_0_1 : STM32_SVD.UInt2 := 16#0#; -- Random number generator enable RNGEN : CR_RNGEN_Field := 16#0#; -- Interrupt enable IE : CR_IE_Field := 16#0#; -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record Reserved_0_1 at 0 range 0 .. 1; RNGEN at 0 range 2 .. 2; IE at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype SR_DRDY_Field is STM32_SVD.Bit; subtype SR_CECS_Field is STM32_SVD.Bit; subtype SR_SECS_Field is STM32_SVD.Bit; subtype SR_CEIS_Field is STM32_SVD.Bit; subtype SR_SEIS_Field is STM32_SVD.Bit; -- status register type SR_Register is record -- Read-only. Data ready DRDY : SR_DRDY_Field := 16#0#; -- Read-only. Clock error current status CECS : SR_CECS_Field := 16#0#; -- Read-only. Seed error current status SECS : SR_SECS_Field := 16#0#; -- unspecified Reserved_3_4 : STM32_SVD.UInt2 := 16#0#; -- Clock error interrupt status CEIS : SR_CEIS_Field := 16#0#; -- Seed error interrupt status SEIS : SR_SEIS_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record DRDY at 0 range 0 .. 0; CECS at 0 range 1 .. 1; SECS at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; CEIS at 0 range 5 .. 5; SEIS at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Random number generator type RNG_Peripheral is record -- control register CR : aliased CR_Register; -- status register SR : aliased SR_Register; -- data register DR : aliased STM32_SVD.UInt32; end record with Volatile; for RNG_Peripheral use record CR at 16#0# range 0 .. 31; SR at 16#4# range 0 .. 31; DR at 16#8# range 0 .. 31; end record; -- Random number generator RNG_Periph : aliased RNG_Peripheral with Import, Address => RNG_Base; end STM32_SVD.RNG;
onox/orka
Ada
3,052
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 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 EGL.Objects.Displays; with EGL.Objects.Surfaces; package EGL.Objects.Contexts is pragma Preelaborate; type Context_Version is record Major, Minor : Natural; end record; type Context_Flags is record Debug : Boolean := False; Robust : Boolean := False; No_Error : Boolean := False; end record; type Buffer_Kind is (None, Back, Front); type Task_Kind is (Current_Task, Any_Task); type Context (Platform : Displays.Platform_Kind) is new EGL_Object with private; function Create_Context (Display : Displays.Display; Version : Context_Version; Flags : Context_Flags) return Context with Pre => Display.Is_Initialized, Post => not Create_Context'Result.Is_Current (Any_Task); function Display (Object : Context) return Displays.Display with Post => Display'Result.Is_Initialized; function Buffer (Object : Context) return Buffer_Kind with Pre => Object.Is_Initialized; function Is_Current (Object : Context; Kind : Task_Kind) return Boolean with Pre => Object.Is_Initialized; procedure Make_Current (Object : Context) with Pre => Object.Is_Initialized, Post => Object.Is_Current (Current_Task); procedure Make_Current (Object : Context; Surface : Surfaces.Surface) with Pre => Object.Is_Initialized and Surface.Is_Initialized, Post => Object.Is_Current (Current_Task); procedure Make_Not_Current (Object : Context) with Pre => Object.Is_Initialized and then Object.Is_Current (Current_Task), Post => not Object.Is_Current (Any_Task); procedure Set_Swap_Interval (Object : Context; Value : Natural) with Pre => Object.Is_Initialized and then Object.Is_Current (Current_Task); type Client_API is private; private type Client_API is (OpenGL_API); for Client_API use (OpenGL_API => 16#30A2#); for Client_API'Size use Enum'Size; for Buffer_Kind use (None => 16#3038#, Back => 16#3084#, Front => 16#3085#); for Buffer_Kind'Size use Int'Size; type Context (Platform : Displays.Platform_Kind) is new EGL_Object with record Display : Displays.Display (Platform); end record; overriding procedure Pre_Finalize (Object : in out Context); function Display (Object : Context) return Displays.Display is (Object.Display); end EGL.Objects.Contexts;
reznikmm/slimp
Ada
1,073
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package Slim.Messages.cont is type Cont_Message is new Message with private; -- Tell the client content information not overriding procedure Set_Metaint (Self : in out Cont_Message; Value : Natural); private subtype Byte is Ada.Streams.Stream_Element; type Cont_Message is new Base_Message (Max_8 => 1, Max_16 => 1, Max_32 => 1, Max_64 => 0) with null record; overriding function Read (Data : not null access League.Stream_Element_Vectors.Stream_Element_Vector) return Cont_Message; overriding procedure Write (Self : Cont_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector); overriding procedure Visit (Self : not null access Cont_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class); end Slim.Messages.cont;
guillaume-lin/tsc
Ada
6,944
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Termcap -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000,2004 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Version Control: -- $Revision: 1.6 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; package body Terminal_Interface.Curses.Termcap is function Get_Entry (Name : String) return Boolean is function tgetent (name : char_array; val : char_array) return C_Int; pragma Import (C, tgetent, "tgetent"); NameTxt : char_array (0 .. Name'Length); Length : size_t; ignored : char_array (0 .. 0) := (0 => nul); result : C_Int; begin To_C (Name, NameTxt, Length); result := tgetent (char_array (ignored), NameTxt); if result = -1 then raise Curses_Exception; else return Boolean'Val (result); end if; end Get_Entry; ------------------------------------------------------------------------------ function Get_Flag (Name : String) return Boolean is function tgetflag (id : char_array) return C_Int; pragma Import (C, tgetflag, "tgetflag"); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); if tgetflag (Txt) = 0 then return False; else return True; end if; end Get_Flag; ------------------------------------------------------------------------------ procedure Get_Number (Name : in String; Value : out Integer; Result : out Boolean) is function tgetnum (id : char_array) return C_Int; pragma Import (C, tgetnum, "tgetnum"); Txt : char_array (0 .. Name'Length); Length : size_t; begin To_C (Name, Txt, Length); Value := Integer (tgetnum (Txt)); if Value = -1 then Result := False; else Result := True; end if; end Get_Number; ------------------------------------------------------------------------------ procedure Get_String (Name : String; Value : out String; Result : out Boolean) is function tgetstr (id : char_array; buf : char_array) return chars_ptr; pragma Import (C, tgetstr, "tgetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; type t is new char_array (0 .. 1024); -- does it need to be 1024? Return_Buffer : t := (others => nul); begin To_C (Name, Txt, Length); Txt2 := tgetstr (Txt, char_array (Return_Buffer)); if Txt2 = Null_Ptr then Result := False; else Value := Fill_String (Txt2); Result := True; end if; end Get_String; function Get_String (Name : String) return Boolean is function tgetstr (Id : char_array; buf : char_array) return chars_ptr; pragma Import (C, tgetstr, "tgetstr"); Txt : char_array (0 .. Name'Length); Length : size_t; Txt2 : chars_ptr; type t is new char_array (0 .. 1024); -- does it need to be 1024? Phony_Txt : t := (others => nul); begin To_C (Name, Txt, Length); Txt2 := tgetstr (Txt, char_array (Phony_Txt)); if Txt2 = Null_Ptr then return False; else return True; end if; end Get_String; ------------------------------------------------------------------------------ function TGoto (Cap : String; Col : Column_Position; Row : Line_Position) return Termcap_String is function tgoto (cap : char_array; col : C_Int; row : C_Int) return chars_ptr; pragma Import (C, tgoto); Txt : char_array (0 .. Cap'Length); Length : size_t; begin To_C (Cap, Txt, Length); return Termcap_String (Fill_String (tgoto (Txt, C_Int (Col), C_Int (Row)))); end TGoto; end Terminal_Interface.Curses.Termcap;
AenBleidd/rappture-runtime
Ada
12,522
ads
------------------------------------------------------------------------------ -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, but -- -- WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public License -- -- along with this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- ------------------------------------------------------------------------------ -- $Id: zlib.ads,v 1.1 2004/08/12 20:24:12 andreas_kupries Exp $ with Ada.Streams; with Interfaces; package ZLib is ZLib_Error : exception; type Compression_Level is new Integer range -1 .. 9; type Flush_Mode is private; type Compression_Method is private; type Window_Bits_Type is new Integer range 8 .. 15; type Memory_Level_Type is new Integer range 1 .. 9; type Unsigned_32 is new Interfaces.Unsigned_32; type Strategy_Type is private; type Header_Type is (None, Auto, Default, GZip); -- Header type usage have a some limitation for inflate. -- See comment for Inflate_Init. subtype Count is Ada.Streams.Stream_Element_Count; ---------------------------------- -- Compression method constants -- ---------------------------------- Deflated : constant Compression_Method; -- Only one method allowed in this ZLib version. --------------------------------- -- Compression level constants -- --------------------------------- No_Compression : constant Compression_Level := 0; Best_Speed : constant Compression_Level := 1; Best_Compression : constant Compression_Level := 9; Default_Compression : constant Compression_Level := -1; -------------------------- -- Flush mode constants -- -------------------------- No_Flush : constant Flush_Mode; -- Regular way for compression, no flush Partial_Flush : constant Flush_Mode; -- will be removed, use Z_SYNC_FLUSH instead Sync_Flush : constant Flush_Mode; -- all pending output is flushed to the output buffer and the output -- is aligned on a byte boundary, so that the decompressor can get all -- input data available so far. (In particular avail_in is zero after the -- call if enough output space has been provided before the call.) -- Flushing may degrade compression for some compression algorithms and so -- it should be used only when necessary. Full_Flush : constant Flush_Mode; -- all output is flushed as with SYNC_FLUSH, and the compression state -- is reset so that decompression can restart from this point if previous -- compressed data has been damaged or if random access is desired. Using -- FULL_FLUSH too often can seriously degrade the compression. Finish : constant Flush_Mode; -- Just for tell the compressor that input data is complete. ------------------------------------ -- Compression strategy constants -- ------------------------------------ -- RLE stategy could be used only in version 1.2.0 and later. Filtered : constant Strategy_Type; Huffman_Only : constant Strategy_Type; RLE : constant Strategy_Type; Default_Strategy : constant Strategy_Type; Default_Buffer_Size : constant := 4096; type Filter_Type is limited private; -- The filter is for compression and for decompression. -- The usage of the type is depend of its initialization. function Version return String; pragma Inline (Version); -- Return string representation of the ZLib version. procedure Deflate_Init (Filter : in out Filter_Type; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Method : in Compression_Method := Deflated; Window_Bits : in Window_Bits_Type := 15; Memory_Level : in Memory_Level_Type := 8; Header : in Header_Type := Default); -- Compressor initialization. -- When Header parameter is Auto or Default, then default zlib header -- would be provided for compressed data. -- When Header is GZip, then gzip header would be set instead of -- default header. -- When Header is None, no header would be set for compressed data. procedure Inflate_Init (Filter : in out Filter_Type; Window_Bits : in Window_Bits_Type := 15; Header : in Header_Type := Default); -- Decompressor initialization. -- Default header type mean that ZLib default header is expecting in the -- input compressed stream. -- Header type None mean that no header is expecting in the input stream. -- GZip header type mean that GZip header is expecting in the -- input compressed stream. -- Auto header type mean that header type (GZip or Native) would be -- detected automatically in the input stream. -- Note that header types parameter values None, GZip and Auto is -- supporting for inflate routine only in ZLib versions 1.2.0.2 and later. -- Deflate_Init is supporting all header types. procedure Close (Filter : in out Filter_Type; Ignore_Error : in Boolean := False); -- Closing the compression or decompressor. -- If stream is closing before the complete and Ignore_Error is False, -- The exception would be raised. generic with procedure Data_In (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); with procedure Data_Out (Item : in Ada.Streams.Stream_Element_Array); procedure Generic_Translate (Filter : in out Filter_Type; In_Buffer_Size : in Integer := Default_Buffer_Size; Out_Buffer_Size : in Integer := Default_Buffer_Size); -- Compressing/decompressing data arrived from Data_In routine -- to the Data_Out routine. User should provide Data_In and Data_Out -- for compression/decompression data flow. -- Compression or decompression depend on initialization of Filter. function Total_In (Filter : in Filter_Type) return Count; pragma Inline (Total_In); -- Return total number of input bytes read so far. function Total_Out (Filter : in Filter_Type) return Count; pragma Inline (Total_Out); -- Return total number of bytes output so far. function CRC32 (CRC : in Unsigned_32; Data : in Ada.Streams.Stream_Element_Array) return Unsigned_32; pragma Inline (CRC32); -- Calculate CRC32, it could be necessary for make gzip format. procedure CRC32 (CRC : in out Unsigned_32; Data : in Ada.Streams.Stream_Element_Array); pragma Inline (CRC32); -- Calculate CRC32, it could be necessary for make gzip format. ------------------------------------------------- -- Below is more complex low level routines. -- ------------------------------------------------- procedure Translate (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); -- Compressing/decompressing the datas from In_Data buffer to the -- Out_Data buffer. -- In_Data is incoming data portion, -- In_Last is the index of last element from In_Data accepted by the -- Filter. -- Out_Data is the buffer for output data from the filter. -- Out_Last is the last element of the received data from Filter. -- To tell the filter that incoming data is complete put the -- Flush parameter to FINISH. function Stream_End (Filter : in Filter_Type) return Boolean; pragma Inline (Stream_End); -- Return the true when the stream is complete. procedure Flush (Filter : in out Filter_Type; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); pragma Inline (Flush); -- Flushing the data from the compressor. generic with procedure Write (Item : in Ada.Streams.Stream_Element_Array); -- User should provide this routine for accept -- compressed/decompressed data. Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; -- Buffer size for Write user routine. procedure Write (Filter : in out Filter_Type; Item : in Ada.Streams.Stream_Element_Array; Flush : in Flush_Mode); -- Compressing/Decompressing data from Item to the -- generic parameter procedure Write. -- Output buffer size could be set in Buffer_Size generic parameter. generic with procedure Read (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- User should provide data for compression/decompression -- thru this routine. Buffer : in out Ada.Streams.Stream_Element_Array; -- Buffer for keep remaining data from the previous -- back read. Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; -- Rest_First have to be initialized to Buffer'Last + 1 -- before usage. procedure Read (Filter : in out Filter_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- Compressing/Decompressing data from generic parameter -- procedure Read to the Item. -- User should provide Buffer for the operation -- and Rest_First variable first time initialized to the Buffer'Last + 1. private use Ada.Streams; type Flush_Mode is new Integer range 0 .. 4; type Compression_Method is new Integer range 8 .. 8; type Strategy_Type is new Integer range 0 .. 3; No_Flush : constant Flush_Mode := 0; Sync_Flush : constant Flush_Mode := 2; Full_Flush : constant Flush_Mode := 3; Finish : constant Flush_Mode := 4; Partial_Flush : constant Flush_Mode := 1; -- will be removed, use Z_SYNC_FLUSH instead Filtered : constant Strategy_Type := 1; Huffman_Only : constant Strategy_Type := 2; RLE : constant Strategy_Type := 3; Default_Strategy : constant Strategy_Type := 0; Deflated : constant Compression_Method := 8; type Z_Stream; type Z_Stream_Access is access all Z_Stream; type Filter_Type is record Strm : Z_Stream_Access; Compression : Boolean; Stream_End : Boolean; Header : Header_Type; CRC : Unsigned_32; Offset : Stream_Element_Offset; -- Offset for gzip header/footer output. Opened : Boolean := False; end record; end ZLib;
charlie5/cBound
Ada
1,470
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_query_pict_formats_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_render_query_pict_formats_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_query_pict_formats_cookie_t.Item, Element_Array => xcb.xcb_render_query_pict_formats_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_render_query_pict_formats_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_query_pict_formats_cookie_t.Pointer, Element_Array => xcb.xcb_render_query_pict_formats_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_query_pict_formats_cookie_t;
1Crazymoney/LearnAda
Ada
228
adb
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO; use Ada.Text_IO; with Mat; -- use Mat; procedure powerof is X : Integer; N : Integer; begin Get( X ); Get( N ); Put( Mat.powerof(X,N) ); end powerof;
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.Text_Description_Attributes is pragma Preelaborate; type ODF_Text_Description_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Description_Attribute_Access is access all ODF_Text_Description_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Description_Attributes;
kjseefried/web-ada
Ada
3,361
ads
with Ada.Finalization; with Ada.IO_Exceptions; with Ada.Streams; with Ada.Unchecked_Deallocation; package Web.Producers is type Template is tagged limited private; function Is_Empty (Object : Template) return Boolean; function Is_Parsed (Object : Template) return Boolean; function Read ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Length : Ada.Streams.Stream_Element_Count; Parsing : Boolean := True) return Template; procedure Parse (Template : in out Producers.Template); procedure Read_Parsed_Information ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Template : in out Producers.Template); procedure Write_Parsed_Information ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Template : in Producers.Template); type Produce_Type is limited private; procedure Start_Produce ( Produce : out Produce_Type; Output : not null access Ada.Streams.Root_Stream_Type'Class; Template : in Producers.Template; Part : in String := ""); function More (Produce : Produce_Type) return Boolean; function Tag (Produce : Produce_Type) return String; function Contents (Produce : Produce_Type) return not null access constant Template; procedure Next (Produce : in out Produce_Type); procedure End_Produce (Produce : in out Produce_Type); procedure Produce ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Template : in Producers.Template; Part : in String := ""; Handler : access procedure ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Tag : in String; Contents : in Producers.Template) := null); generic type Parameter (<>) is limited private; procedure Generic_Produce ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Template : in Producers.Template; Part : in String := ""; Handler : access procedure ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Tag : in String; Contents : in Producers.Template; Params : access Parameter) := null; Params : access Parameter); Status_Error : exception renames Ada.IO_Exceptions.Status_Error; Data_Error : exception renames Ada.IO_Exceptions.Data_Error; private type String_Access is access String; procedure Free is new Ada.Unchecked_Deallocation (String, String_Access); type Node_Array (<>); type Node_Array_Access is access Node_Array; type Node is record Text_First : Positive; Text_Last : Natural; Tag_First : Positive; Tag_Last : Natural; Nodes : Node_Array_Access; end record; type Node_Array is array (Positive range <>) of Node; procedure Free is new Ada.Unchecked_Deallocation (Node_Array, Node_Array_Access); type Data is limited record Reference_Count : Integer; Source : String_Access; Root_Nodes : Node_Array_Access; end record; type Data_Access is access Data; procedure Free is new Ada.Unchecked_Deallocation (Data, Data_Access); type Template is limited new Ada.Finalization.Limited_Controlled with record Data : Data_Access := null; Nodes : Node_Array_Access := null; end record; overriding procedure Finalize (Object : in out Template); type Produce_Type is limited record Output : access Ada.Streams.Root_Stream_Type'Class; Nodes : Node_Array_Access; Position : Natural; Sub_Template : aliased Template; end record; end Web.Producers;
doug16rogers/solitaire
Ada
1,428
adb
with Get_Line; with Solitaire_Operations.Text_Representation; with Ada.Characters.Handling; with Ada.Strings.Unbounded; with Ada.Text_IO; use Ada; use Ada.Characters; use Ada.Strings.Unbounded; procedure Encrypt is Deck_Text : constant Solitaire_Operations.Text_Representation.Short_Card_Deck_String := Get_Line; Deck : Solitaire_Operations.Deck_List; Plain : Unbounded_String := To_Unbounded_String (Handling.To_Upper (Get_Line) ); subtype Letter is Character range 'A' .. 'Z'; begin -- Encrypt Solitaire_Operations.Text_Representation.Set_Deck (Deck => Deck, To => Deck_Text); Compress : for I in reverse 1 .. Length (Plain) loop -- Remove non-letters from plaintext if Element (Plain, I) not in Letter then Delete (Source => Plain, From => I, Through => I); end if; end loop Compress; Expand : loop -- Make plaintext a multiple of 5 characters long by adding Xs to the end exit Expand when Length (Plain) rem 5 = 0; Append (Source => Plain, New_Item => 'X'); end loop Expand; Create : declare Crypto : String (1 .. Length (Plain) ); begin -- Create Solitaire_Operations.Encrypt (Deck => Deck, Plain => To_String (Plain), Crypto => Crypto); Text_IO.Put_Line (Item => Crypto); end Create; exception -- Encrypt when Solitaire_Operations.Text_Representation.Card_Not_Found => Text_IO.Put_Line (Item => "Invalid deck"); end Encrypt;
mitchelhaan/ncurses
Ada
3,916
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Decimal_IO -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.6 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ with Ada.Text_IO; with Terminal_Interface.Curses.Text_IO.Aux; package body Terminal_Interface.Curses.Text_IO.Decimal_IO is package Aux renames Terminal_Interface.Curses.Text_IO.Aux; package DIO is new Ada.Text_IO.Decimal_IO (Num); procedure Put (Win : in Window; Item : in Num; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp) is Buf : String (1 .. Field'Last); Len : Field := Fore + 1 + Aft; begin if Exp > 0 then Len := Len + 1 + Exp; end if; DIO.Put (Buf, Item, Aft, Exp); Aux.Put_Buf (Win, Buf, Len, False); end Put; procedure Put (Item : in Num; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp) is begin Put (Get_Window, Item, Fore, Aft, Exp); end Put; end Terminal_Interface.Curses.Text_IO.Decimal_IO;
reznikmm/matreshka
Ada
3,654
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- 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$ ------------------------------------------------------------------------------ -- Pattern optimizer. It reconstruct tree to simplify tree and to remove -- redundant expressions. private package Matreshka.Internals.Regexps.Compiler.Optimizer is pragma Preelaborate; procedure Optimize (Pattern : not null Shared_Pattern_Access); end Matreshka.Internals.Regexps.Compiler.Optimizer;
stcarrez/ada-util
Ada
8,153
adb
----------------------------------------------------------------------- -- util-streams-buffered-lzma -- LZMA streams -- Copyright (C) 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 Lzma.Check; with Lzma.Container; with Interfaces.C; with Ada.IO_Exceptions; package body Util.Streams.Buffered.Lzma is use type Interfaces.C.size_t; use type Base.lzma_ret; subtype size_t is Interfaces.C.size_t; subtype Offset is Ada.Streams.Stream_Element_Offset; -- ----------------------- -- Initialize the stream to write on the given stream. -- An internal buffer is allocated for writing the stream. -- ----------------------- overriding procedure Initialize (Stream : in out Compress_Stream; Output : access Output_Stream'Class; Size : in Positive) is Result : Base.lzma_ret; begin Output_Buffer_Stream (Stream).Initialize (Output, Size); Stream.Stream.next_out := Stream.Buffer (Stream.Buffer'First)'Unchecked_Access; Stream.Stream.avail_out := Stream.Buffer'Length; Result := Container.lzma_easy_encoder (Stream.Stream'Unchecked_Access, 6, Check.LZMA_CHECK_CRC64); if Result /= Base.LZMA_OK then raise Ada.IO_Exceptions.Device_Error with "Cannot initialize compressor"; end if; end Initialize; -- ----------------------- -- Close the sink. -- ----------------------- overriding procedure Close (Stream : in out Compress_Stream) is begin Stream.Flush; Output_Buffer_Stream (Stream).Close; end Close; -- ----------------------- -- Write the buffer array to the output stream. -- ----------------------- overriding procedure Write (Stream : in out Compress_Stream; Buffer : in Ada.Streams.Stream_Element_Array) is Last_Pos : Ada.Streams.Stream_Element_Offset; Encoded : Boolean := False; Result : Base.lzma_ret; begin loop if Stream.Stream.avail_in = 0 then Stream.Stream.next_in := Buffer (Buffer'First)'Unrestricted_Access; Stream.Stream.avail_in := size_t (Buffer'Length); Encoded := True; end if; Result := Base.lzma_code (Stream.Stream'Unchecked_Access, Base.LZMA_RUN); -- Write the output data when the buffer is full or we reached the end of stream. if Stream.Stream.avail_out = 0 or else Result = Base.LZMA_STREAM_END then Last_Pos := Stream.Buffer'First + Stream.Buffer'Length - Offset (Stream.Stream.avail_out) - 1; Stream.Output.Write (Stream.Buffer (Stream.Buffer'First .. Last_Pos)); Stream.Stream.next_out := Stream.Buffer (Stream.Buffer'First)'Unchecked_Access; Stream.Stream.avail_out := Stream.Buffer'Length; end if; exit when Result /= Base.LZMA_OK or else (Stream.Stream.avail_in = 0 and then Encoded); end loop; end Write; -- ----------------------- -- Flush the buffer by writing on the output stream. -- Raises Data_Error if there is no output stream. -- ----------------------- overriding procedure Flush (Stream : in out Compress_Stream) is Last_Pos : Ada.Streams.Stream_Element_Offset; Result : Base.lzma_ret; begin -- Stream is closed, ignore the flush. if Stream.Buffer = null then return; end if; Stream.Stream.next_in := null; Stream.Stream.avail_in := 0; loop Result := Base.lzma_code (Stream.Stream'Unchecked_Access, Base.LZMA_FINISH); if Stream.Stream.avail_out = 0 or else Result = Base.LZMA_STREAM_END then Last_Pos := Stream.Buffer'First + Stream.Buffer'Length - Offset (Stream.Stream.avail_out) - 1; if Last_Pos >= Stream.Buffer'First then Stream.Output.Write (Stream.Buffer (Stream.Buffer'First .. Last_Pos)); end if; Stream.Stream.next_out := Stream.Buffer (Stream.Buffer'First)'Unchecked_Access; Stream.Stream.avail_out := Stream.Buffer'Length; end if; exit when Result /= Base.LZMA_OK; end loop; end Flush; -- ----------------------- -- Flush the stream and release the buffer. -- ----------------------- overriding procedure Finalize (Object : in out Compress_Stream) is begin Object.Flush; Output_Buffer_Stream (Object).Finalize; Base.lzma_end (Object.Stream'Unchecked_Access); end Finalize; -- ----------------------- -- Initialize the stream to write on the given stream. -- An internal buffer is allocated for writing the stream. -- ----------------------- overriding procedure Initialize (Stream : in out Decompress_Stream; Input : access Input_Stream'Class; Size : in Positive) is Result : Base.lzma_ret; begin Input_Buffer_Stream (Stream).Initialize (Input, Size); Stream.Stream.next_in := Stream.Buffer (Stream.Buffer'First)'Unchecked_Access; Stream.Stream.avail_in := 0; Result := Container.lzma_stream_decoder (Stream.Stream'Unchecked_Access, Long_Long_Integer'Last, Container.LZMA_CONCATENATED); if Result /= Base.LZMA_OK then raise Ada.IO_Exceptions.Device_Error with "Cannot initialize decompressor"; end if; end Initialize; -- ----------------------- -- Write the buffer array to the output stream. -- ----------------------- overriding procedure Read (Stream : in out Decompress_Stream; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is use type Base.lzma_action; Result : Base.lzma_ret; begin Stream.Stream.next_out := Into (Into'First)'Unrestricted_Access; Stream.Stream.avail_out := Into'Length; loop if Stream.Stream.avail_in = 0 and then not Stream.Is_Eof and then Stream.Action = Base.LZMA_RUN then Stream.Fill; if Stream.Write_Pos >= Stream.Read_Pos then Stream.Stream.avail_in := size_t (Stream.Write_Pos - Stream.Read_Pos); Stream.Stream.next_in := Stream.Buffer (Stream.Buffer'First)'Unchecked_Access; else Stream.Stream.avail_in := 0; Stream.Stream.next_in := null; Stream.Action := Base.LZMA_FINISH; end if; end if; Result := Base.lzma_code (Stream.Stream'Unchecked_Access, Stream.Action); if Stream.Stream.avail_out = 0 or else Result = Base.LZMA_STREAM_END then Last := Into'First + Into'Length - Offset (Stream.Stream.avail_out) - 1; return; end if; if Result /= Base.LZMA_OK then raise Ada.IO_Exceptions.Data_Error with "Decompression error"; end if; end loop; end Read; -- ----------------------- -- Flush the stream and release the buffer. -- ----------------------- overriding procedure Finalize (Object : in out Decompress_Stream) is begin Base.lzma_end (Object.Stream'Unchecked_Access); Input_Buffer_Stream (Object).Finalize; end Finalize; end Util.Streams.Buffered.Lzma;
reznikmm/matreshka
Ada
4,017
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_Handle_Polar_Attributes; package Matreshka.ODF_Draw.Handle_Polar_Attributes is type Draw_Handle_Polar_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Handle_Polar_Attributes.ODF_Draw_Handle_Polar_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Handle_Polar_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Handle_Polar_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Handle_Polar_Attributes;
Fabien-Chouteau/lvgl-ada
Ada
1,411
ads
with Interfaces; use Interfaces; with Interfaces.C.Extensions; with System; use System; with Lvgl_Ada_Config; package Lv.Color_Types is type Color_T_Comp is record Blue : Extensions.Unsigned_5; Green : Extensions.Unsigned_6; Red : Extensions.Unsigned_5; end record with Pack, Object_Size => 16; pragma Convention (C_Pass_By_Copy, Color_T_Comp); subtype Color_Int_T is Uint16_T; type Color_T (Discr : unsigned := 0) is record case Discr is when 0 => Comp : aliased Color_T_Comp; when others => Full : aliased Color_Int_T; end case; end record with Pack, Object_Size => 16; pragma Convention (C_Pass_By_Copy, Color_T); pragma Unchecked_Union (Color_T); function Color_Make (R8, G8, B8 : Uint8_T) return Color_T is (Discr => 0, Comp => (if System.Default_Bit_Order = System.Low_Order_First then (Extensions.Unsigned_5 (Shift_Right (R8, 3)), Extensions.Unsigned_6 (Shift_Right (G8, 2)), Extensions.Unsigned_5 (Shift_Right (B8, 3))) else (Extensions.Unsigned_5 (Shift_Right (B8, 3)), Extensions.Unsigned_6 (Shift_Right (G8, 2)), Extensions.Unsigned_5 (Shift_Right (R8, 3))) ) ) with Inline_Always; end Lv.Color_Types;
stcarrez/ada-ado
Ada
41,848
adb
----------------------------------------------------------------------- -- Regtests.Statements.Model -- Regtests.Statements.Model ----------------------------------------------------------------------- -- File generated by Dynamo DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0 ----------------------------------------------------------------------- -- Copyright (C) 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. ----------------------------------------------------------------------- pragma Warnings (Off); with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; pragma Warnings (On); package body Regtests.Statements.Model is pragma Style_Checks ("-mrIu"); pragma Warnings (Off, "formal parameter * is not referenced"); pragma Warnings (Off, "use clause for type *"); pragma Warnings (Off, "use clause for private type *"); use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; function Nullable_Table_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => NULLABLE_TABLE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Nullable_Table_Key; function Nullable_Table_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => NULLABLE_TABLE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Nullable_Table_Key; function "=" (Left, Right : Nullable_Table_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Nullable_Table_Ref'Class; Impl : out Nullable_Table_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Nullable_Table_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Nullable_Table_Ref) is Impl : Nullable_Table_Access; begin Impl := new Nullable_Table_Impl; Impl.Version := 0; Impl.Id_Value := ADO.NO_IDENTIFIER; Impl.Int_Value.Is_Null := True; Impl.Bool_Value.Is_Null := True; Impl.String_Value.Is_Null := True; Impl.Time_Value.Is_Null := True; Impl.Entity_Value.Is_Null := True; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Nullable_Table -- ---------------------------------------- procedure Set_Id (Object : in out Nullable_Table_Ref; Value : in ADO.Identifier) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Nullable_Table_Ref) return ADO.Identifier is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; function Get_Version (Object : in Nullable_Table_Ref) return Integer is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Id_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Identifier) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Identifier (Impl.all, 3, Impl.Id_Value, Value); end Set_Id_Value; function Get_Id_Value (Object : in Nullable_Table_Ref) return ADO.Identifier is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Id_Value; end Get_Id_Value; procedure Set_Int_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Nullable_Integer) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Int_Value, Value); end Set_Int_Value; function Get_Int_Value (Object : in Nullable_Table_Ref) return ADO.Nullable_Integer is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Int_Value; end Get_Int_Value; procedure Set_Bool_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Nullable_Boolean) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Boolean (Impl.all, 5, Impl.Bool_Value, Value); end Set_Bool_Value; function Get_Bool_Value (Object : in Nullable_Table_Ref) return ADO.Nullable_Boolean is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Bool_Value; end Get_Bool_Value; procedure Set_String_Value (Object : in out Nullable_Table_Ref; Value : in String) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 6, Impl.String_Value, Value); end Set_String_Value; procedure Set_String_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Nullable_String) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 6, Impl.String_Value, Value); end Set_String_Value; function Get_String_Value (Object : in Nullable_Table_Ref) return String is Value : constant ADO.Nullable_String := Object.Get_String_Value; begin if Value.Is_Null then return ""; else return Ada.Strings.Unbounded.To_String (Value.Value); end if; end Get_String_Value; function Get_String_Value (Object : in Nullable_Table_Ref) return ADO.Nullable_String is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.String_Value; end Get_String_Value; procedure Set_Time_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Nullable_Time) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 7, Impl.Time_Value, Value); end Set_Time_Value; function Get_Time_Value (Object : in Nullable_Table_Ref) return ADO.Nullable_Time is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Time_Value; end Get_Time_Value; procedure Set_Entity_Value (Object : in out Nullable_Table_Ref; Value : in ADO.Nullable_Entity_Type) is Impl : Nullable_Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Entity_Type (Impl.all, 8, Impl.Entity_Value, Value); end Set_Entity_Value; function Get_Entity_Value (Object : in Nullable_Table_Ref) return ADO.Nullable_Entity_Type is Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Entity_Value; end Get_Entity_Value; -- Copy of the object. procedure Copy (Object : in Nullable_Table_Ref; Into : in out Nullable_Table_Ref) is Result : Nullable_Table_Ref; begin if not Object.Is_Null then declare Impl : constant Nullable_Table_Access := Nullable_Table_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Nullable_Table_Access := new Nullable_Table_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Version := Impl.Version; Copy.Id_Value := Impl.Id_Value; Copy.Int_Value := Impl.Int_Value; Copy.Bool_Value := Impl.Bool_Value; Copy.String_Value := Impl.String_Value; Copy.Time_Value := Impl.Time_Value; Copy.Entity_Value := Impl.Entity_Value; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Nullable_Table_Access := new Nullable_Table_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Nullable_Table_Access := new Nullable_Table_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Nullable_Table_Access := new Nullable_Table_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Reload (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Session'Class; Updated : out Boolean) is Result : ADO.Objects.Object_Record_Access; Impl : Nullable_Table_Access; Query : ADO.SQL.Query; Id : ADO.Identifier; begin if Object.Is_Null then raise ADO.Objects.NULL_ERROR; end if; Object.Prepare_Modify (Result); Impl := Nullable_Table_Impl (Result.all)'Access; Id := ADO.Objects.Get_Key_Value (Impl.all); Query.Bind_Param (Position => 1, Value => Id); Query.Bind_Param (Position => 2, Value => Impl.Version); Query.Set_Filter ("id = ? AND version != ?"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, NULLABLE_TABLE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Updated := True; Impl.Load (Stmt, Session); else Updated := False; end if; end; end Reload; overriding procedure Save (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Nullable_Table_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out Nullable_Table_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access Nullable_Table_Impl) is type Nullable_Table_Impl_Ptr is access all Nullable_Table_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Nullable_Table_Impl, Nullable_Table_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Nullable_Table_Impl_Ptr := Nullable_Table_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out Nullable_Table_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, NULLABLE_TABLE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Nullable_Table_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out Nullable_Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (NULLABLE_TABLE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- ID Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- ID_VALUE Value => Object.Id_Value); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- INT_VALUE Value => Object.Int_Value); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_1_NAME, -- BOOL_VALUE Value => Object.Bool_Value); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_1_NAME, -- STRING_VALUE Value => Object.String_Value); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_1_NAME, -- TIME_VALUE Value => Object.Time_Value); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_1_NAME, -- ENTITY_VALUE Value => Object.Entity_Value); Object.Clear_Modified (8); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out Nullable_Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (NULLABLE_TABLE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- ID Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_2_1_NAME, -- ID_VALUE Value => Object.Id_Value); Query.Save_Field (Name => COL_3_1_NAME, -- INT_VALUE Value => Object.Int_Value); Query.Save_Field (Name => COL_4_1_NAME, -- BOOL_VALUE Value => Object.Bool_Value); Query.Save_Field (Name => COL_5_1_NAME, -- STRING_VALUE Value => Object.String_Value); Query.Save_Field (Name => COL_6_1_NAME, -- TIME_VALUE Value => Object.Time_Value); Query.Save_Field (Name => COL_7_1_NAME, -- ENTITY_VALUE Value => Object.Entity_Value); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out Nullable_Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (NULLABLE_TABLE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Nullable_Table_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Nullable_Table_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Nullable_Table_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "id_value" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Id_Value)); elsif Name = "int_value" then if Impl.Int_Value.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Int_Value.Value)); end if; elsif Name = "bool_value" then if Impl.Bool_Value.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Impl.Bool_Value.Value); end if; elsif Name = "string_value" then if Impl.String_Value.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Impl.String_Value.Value); end if; elsif Name = "time_value" then if Impl.Time_Value.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.Time.To_Object (Impl.Time_Value.Value); end if; elsif Name = "entity_value" then if Impl.Entity_Value.Is_Null then return Util.Beans.Objects.Null_Object; else return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Value.Value)); end if; end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Nullable_Table_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, NULLABLE_TABLE_DEF'Access); begin Stmt.Execute; Nullable_Table_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Nullable_Table_Ref; Impl : constant Nullable_Table_Access := new Nullable_Table_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Nullable_Table_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is pragma Unreferenced (Session); begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Id_Value := Stmt.Get_Identifier (2); Object.Int_Value := Stmt.Get_Nullable_Integer (3); Object.Bool_Value := Stmt.Get_Nullable_Boolean (4); Object.String_Value := Stmt.Get_Nullable_String (5); Object.Time_Value := Stmt.Get_Nullable_Time (6); Object.Entity_Value := Stmt.Get_Nullable_Entity_Type (7); Object.Version := Stmt.Get_Integer (1); ADO.Objects.Set_Created (Object); end Load; function Table_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => TABLE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Table_Key; function Table_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => TABLE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Table_Key; function "=" (Left, Right : Table_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Table_Ref'Class; Impl : out Table_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Table_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Table_Ref) is Impl : Table_Access; begin Impl := new Table_Impl; Impl.Version := 0; Impl.Id_Value := ADO.NO_IDENTIFIER; Impl.Int_Value := 0; Impl.Bool_Value := False; Impl.Time_Value := ADO.DEFAULT_TIME; Impl.Entity_Value := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Table -- ---------------------------------------- procedure Set_Id (Object : in out Table_Ref; Value : in ADO.Identifier) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Table_Ref) return ADO.Identifier is Impl : constant Table_Access := Table_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; function Get_Version (Object : in Table_Ref) return Integer is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Id_Value (Object : in out Table_Ref; Value : in ADO.Identifier) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Identifier (Impl.all, 3, Impl.Id_Value, Value); end Set_Id_Value; function Get_Id_Value (Object : in Table_Ref) return ADO.Identifier is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Id_Value; end Get_Id_Value; procedure Set_Int_Value (Object : in out Table_Ref; Value : in Integer) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Int_Value, Value); end Set_Int_Value; function Get_Int_Value (Object : in Table_Ref) return Integer is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Int_Value; end Get_Int_Value; procedure Set_Bool_Value (Object : in out Table_Ref; Value : in Boolean) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Boolean (Impl.all, 5, Impl.Bool_Value, Value); end Set_Bool_Value; function Get_Bool_Value (Object : in Table_Ref) return Boolean is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Bool_Value; end Get_Bool_Value; procedure Set_String_Value (Object : in out Table_Ref; Value : in String) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 6, Impl.String_Value, Value); end Set_String_Value; procedure Set_String_Value (Object : in out Table_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 6, Impl.String_Value, Value); end Set_String_Value; function Get_String_Value (Object : in Table_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_String_Value); end Get_String_Value; function Get_String_Value (Object : in Table_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.String_Value; end Get_String_Value; procedure Set_Time_Value (Object : in out Table_Ref; Value : in Ada.Calendar.Time) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 7, Impl.Time_Value, Value); end Set_Time_Value; function Get_Time_Value (Object : in Table_Ref) return Ada.Calendar.Time is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Time_Value; end Get_Time_Value; procedure Set_Entity_Value (Object : in out Table_Ref; Value : in ADO.Entity_Type) is Impl : Table_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Entity_Type (Impl.all, 8, Impl.Entity_Value, Value); end Set_Entity_Value; function Get_Entity_Value (Object : in Table_Ref) return ADO.Entity_Type is Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Entity_Value; end Get_Entity_Value; -- Copy of the object. procedure Copy (Object : in Table_Ref; Into : in out Table_Ref) is Result : Table_Ref; begin if not Object.Is_Null then declare Impl : constant Table_Access := Table_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Table_Access := new Table_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Version := Impl.Version; Copy.Id_Value := Impl.Id_Value; Copy.Int_Value := Impl.Int_Value; Copy.Bool_Value := Impl.Bool_Value; Copy.String_Value := Impl.String_Value; Copy.Time_Value := Impl.Time_Value; Copy.Entity_Value := Impl.Entity_Value; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out Table_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Table_Access := new Table_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Table_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Table_Access := new Table_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Table_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Table_Access := new Table_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Reload (Object : in out Table_Ref; Session : in out ADO.Sessions.Session'Class; Updated : out Boolean) is Result : ADO.Objects.Object_Record_Access; Impl : Table_Access; Query : ADO.SQL.Query; Id : ADO.Identifier; begin if Object.Is_Null then raise ADO.Objects.NULL_ERROR; end if; Object.Prepare_Modify (Result); Impl := Table_Impl (Result.all)'Access; Id := ADO.Objects.Get_Key_Value (Impl.all); Query.Bind_Param (Position => 1, Value => Id); Query.Bind_Param (Position => 2, Value => Impl.Version); Query.Set_Filter ("id = ? AND version != ?"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, TABLE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Updated := True; Impl.Load (Stmt, Session); else Updated := False; end if; end; end Reload; overriding procedure Save (Object : in out Table_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Table_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out Table_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access Table_Impl) is type Table_Impl_Ptr is access all Table_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Table_Impl, Table_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Table_Impl_Ptr := Table_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out Table_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, TABLE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Table_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (TABLE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- ID Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_2_NAME, -- ID_VALUE Value => Object.Id_Value); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_2_NAME, -- INT_VALUE Value => Object.Int_Value); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_2_NAME, -- BOOL_VALUE Value => Object.Bool_Value); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_2_NAME, -- STRING_VALUE Value => Object.String_Value); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_2_NAME, -- TIME_VALUE Value => Object.Time_Value); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_2_NAME, -- ENTITY_VALUE Value => Object.Entity_Value); Object.Clear_Modified (8); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (TABLE_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- ID Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_2_2_NAME, -- ID_VALUE Value => Object.Id_Value); Query.Save_Field (Name => COL_3_2_NAME, -- INT_VALUE Value => Object.Int_Value); Query.Save_Field (Name => COL_4_2_NAME, -- BOOL_VALUE Value => Object.Bool_Value); Query.Save_Field (Name => COL_5_2_NAME, -- STRING_VALUE Value => Object.String_Value); Query.Save_Field (Name => COL_6_2_NAME, -- TIME_VALUE Value => Object.Time_Value); Query.Save_Field (Name => COL_7_2_NAME, -- ENTITY_VALUE Value => Object.Entity_Value); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out Table_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (TABLE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Table_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Table_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Table_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "id_value" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Id_Value)); elsif Name = "int_value" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Int_Value)); elsif Name = "bool_value" then return Util.Beans.Objects.To_Object (Impl.Bool_Value); elsif Name = "string_value" then return Util.Beans.Objects.To_Object (Impl.String_Value); elsif Name = "time_value" then return Util.Beans.Objects.Time.To_Object (Impl.Time_Value); elsif Name = "entity_value" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Entity_Value)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Table_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, TABLE_DEF'Access); begin Stmt.Execute; Table_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Table_Ref; Impl : constant Table_Access := new Table_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Table_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is pragma Unreferenced (Session); begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Id_Value := Stmt.Get_Identifier (2); Object.Int_Value := Stmt.Get_Integer (3); Object.Bool_Value := Stmt.Get_Boolean (4); Object.String_Value := Stmt.Get_Unbounded_String (5); Object.Time_Value := Stmt.Get_Time (6); Object.Entity_Value := ADO.Entity_Type (Stmt.Get_Integer (7)); Object.Version := Stmt.Get_Integer (1); ADO.Objects.Set_Created (Object); end Load; end Regtests.Statements.Model;
zhmu/ananas
Ada
409
adb
-- { dg-do run { target hppa*-*-* sparc*-*-* powerpc-*-* powerpc64-*-* } } with Unchecked_Conversion; procedure Unchecked_Convert5 is subtype c_1 is string(1..1); function int2c1 is -- { dg-warning "different sizes" } new unchecked_conversion (source => integer, target => c_1); c1 : c_1; begin c1 := int2c1(16#12#); if c1 (1) /= ASCII.Nul then raise Program_Error; end if; end;
LionelDraghi/smk
Ada
6,508
ads
-- ----------------------------------------------------------------------------- -- Copyright 2018 Lionel Draghi -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- -- This file is part of the List_Image project -- available at https://github.com/LionelDraghi/List_Image -- ----------------------------------------------------------------------------- package List_Image is -- -------------------------------------------------------------------------- -- Style -- -------------------------------------------------------------------------- -- This signature package defines the style of the String returned by the -- Image function. -- -- Prefix, Postfix and Separator parameters are self explaining. -- If Prefix = '(', Postfix = ')', and Separator = ',', Image will be of -- this kind : (A,B,C,D) -- If all parameters are set to "", the image will be : ABCD -- -- Special Prefix and Postfix are possible for null list, and for list with -- a single element. -- This is usefull when you want to want "[A,B,C]" as an image, but you don't -- want "[]" when the list is empty. -- -- A usefull application of this feature is to have well written comments -- regarding singular and plural. -- If you want your image to be "A item found" but "A, B, C items found", -- just set Postfix to " items found", and Postfix_If_Single to -- " item found". -- And by the way, if you want the Image to be "No item found" when the -- list is emtpy, Prefix_If_Empty and Postfix_If_Empty are here for you. -- -- Last_Separator allows to have this kind of output : -- "A, B, C and D" -- -- Note that Separator may be whatever String. You may want to insert an End -- of Line sequence to split the list on several line, the EOL String and -- parameters are provided for that purpose. -- -------------------------------------------------------------------------- generic Prefix : String := ""; Postfix : String := ""; Separator : String := ""; Last_Separator : String := Separator; Prefix_If_Empty : String := Prefix; Postfix_If_Empty : String := Postfix; Prefix_If_Single : String := Prefix; Postfix_If_Single : String := Postfix; EOL : String := ""; package Image_Style is end Image_Style; -- -------------------------------------------------------------------------- -- Predefined single line styles -- -------------------------------------------------------------------------- -- -- Predefined **single line** styles (that are not relying on EOL -- definition), and are not plateform specific, are proposed here after. -- -- - Default_Style : -- > A, B, C -- -- - English_Style : -- > A, B and C -- -- - Bracketed_List_Style : -- > [A, B, C] -- -- - Markdown_Table_Style : -- > | A | B | C | -- Note : Markdown don't define tables, but it's a common extension, -- like in Github Flavored Markdown for example. -- -- -------------------------------------------------------------------------- package Default_Style is new Image_Style (Separator => ", "); package English_Style is new Image_Style (Separator => ", ", Last_Separator => " and "); package Bracketed_List_Style is new Image_Style (Prefix => "[", Postfix => "]", Separator => ", "); package Markdown_Table_Style is new List_Image.Image_Style (Prefix => "|", Separator => "|", Postfix => "|", Prefix_If_Empty => "", Postfix_If_Empty => ""); -- -------------------------------------------------------------------------- -- Predefined Multi-Lines styles -- -------------------------------------------------------------------------- -- -- Predefined (platform dependent) **multi lines** styles -- are proposed in the following child packages : -- - List_Image.Unix_Predefined_Styles -- - List_Image.Windows_Predefined_Styles -- -- Common line terminator definitions are provided here for convenience, -- as there is no easy and standard way in Ada to get the right EOL -- terminator on the current platform (supposing there is one on the -- targeted platform). -- -- -------------------------------------------------------------------------- -- Predefined EOL are (terminator explicit) : LF_EOL : constant String := (1 => ASCII.LF); CRLF_EOL : constant String := ASCII.CR & ASCII.LF; -- or (platform explicit) : Unix_EOL : constant String := LF_EOL; Windows_EOL : constant String := CRLF_EOL; -- -------------------------------------------------------------------------- -- Cursors -- -------------------------------------------------------------------------- generic type Container (<>) is limited private; type Cursor is private; with function First (Self : Container) return Cursor is <>; with function Has_Element (Pos : Cursor) return Boolean is <>; with function Next (Pos : Cursor) return Cursor is <>; package Cursors_Signature is end Cursors_Signature; -- -------------------------------------------------------------------------- -- The Image function -- -------------------------------------------------------------------------- generic with package Cursors is new Cursors_Signature (<>); with function Image (C : Cursors.Cursor) return String is <>; with package Style is new Image_Style (<>); function Image (Cont : in Cursors.Container) return String; end List_Image;
kkirstein/proglang-playground
Ada
735
ads
with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers; with Ada.Containers.Vectors; package Primes is function Is_Prime (N : Natural) return Boolean; function Is_Prime (N : Big_Natural) return Boolean; package Prime_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Natural); package Big_Prime_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Big_Natural); function Get_Primes (Limit : Natural) return Prime_Vectors.Vector; function Get_Primes (Limit : Big_Natural) return Big_Prime_Vectors.Vector; end Primes;
zertovitch/excel-writer
Ada
3,472
adb
with Ada.IO_Exceptions, Ada.Strings.Fixed; package body CSV is use Ada.Strings.Fixed; ---------------- -- Get_Bounds -- ---------------- function Get_Bounds (Item : String; Separator : Character := ',') return Fields_Bounds is In_Quotes : Boolean := False; begin for I in Item'Range loop if Item (I) = '"' then In_Quotes := not In_Quotes; elsif not In_Quotes and Item (I) = Separator then return Bounds'(Item'First, I - 1) & Get_Bounds (Item (I + 1 .. Item'Last), Separator); end if; end loop; return (1 => (Item'First, Item'Last)); end Get_Bounds; ------------- -- Extract -- ------------- function Extract (Item : String; Fields : Fields_Bounds; Column : Positive; Do_Unquote : Boolean := True) return String is Extracted : constant String := Item (Fields (Column).Start .. Fields (Column).Stop); begin if Do_Unquote then return CSV.Unquote (Extracted); else return Extracted; end if; end Extract; ----------- -- Quote -- ----------- function Quote (Item : String) return String is Result : String (Item'First .. Item'Last + Count (Item, """") + 2); Current_Index : Positive; begin Current_Index := Result'First; Result (Current_Index) := '"'; for I in Item'Range loop if Item (I) = '"' then Current_Index := Current_Index + 1; Result (Current_Index) := '"'; end if; Current_Index := Current_Index + 1; Result (Current_Index) := Item (I); end loop; Result (Result'Last) := '"'; return Result; end Quote; ------------- -- Unquote -- ------------- function Unquote (Item : String) return String is use Ada.IO_Exceptions; Result : String (Item'Range); Index_In : Positive; Index_Out : Natural; begin if Item = "" or else Item (Item'First) /= '"' then return Item; end if; Index_In := Item'First + 1; Index_Out := Result'First - 1; while Index_In <= Item'Last - 1 loop if Item (Index_In) = '"' then Index_Out := Index_Out + 1; Result (Index_Out) := '"'; if Item (Index_In + 1) = '"' then Index_In := Index_In + 1; end if; else Index_Out := Index_Out + 1; Result (Index_Out) := Item (Index_In); end if; Index_In := Index_In + 1; end loop; if Item (Item'Last) /= '"' then raise End_Error with "Last character to unquote is not a "" in [" & Item & ']'; end if; return Result (Result'First .. Index_Out); end Unquote; ------------- -- Unquote -- ------------- function Unquote (Item : String; Slice : Bounds; Size : Natural := 0) return String is use Ada.Strings; Raw_Line : constant String := Unquote (Item (Slice.Start .. Slice.Stop)); begin if Size = 0 then return Trim (Raw_Line, Both); elsif Raw_Line'Length < Size then return Raw_Line & (Size - Raw_Line'Length) * ' '; else return Raw_Line (Raw_Line'First .. Raw_Line'First + Size - 1); end if; end Unquote; end CSV;
zhmu/ananas
Ada
2,882
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ I N T R -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Processing for intrinsic subprogram declarations with Types; use Types; package Sem_Intr is procedure Check_Intrinsic_Call (N : Node_Id); -- Perform legality check for intrinsic call N (which is either function -- call or a procedure call node). All the normal semantic checks have -- been performed already. Check_Intrinsic_Call applies any additional -- checks required by the fact that an intrinsic subprogram is involved. procedure Check_Intrinsic_Subprogram (E : Entity_Id; N : Node_Id); -- Special processing for pragma Import or pragma Interface when the -- convention is Intrinsic. E is the Entity_Id of the spec of the -- subprogram, and N is the second (subprogram) argument of the pragma. -- Check_Intrinsic_Subprogram checks that the referenced subprogram is -- known as an intrinsic and has an appropriate profile. If so the flag -- Is_Intrinsic_Subprogram is set, otherwise an error message is posted. end Sem_Intr;
zhmu/ananas
Ada
7,149
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- X R E F _ L I B -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Miscellaneous utilities for the cross-referencing tool with Hostparm; with Xr_Tabls; use Xr_Tabls; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with GNAT.OS_Lib; use GNAT.OS_Lib; with GNAT.Dynamic_Tables; with GNAT.Regexp; use GNAT.Regexp; package Xref_Lib is subtype File_Name_String is String (1 .. Hostparm.Max_Name_Length); subtype Line_String is String (1 .. Hostparm.Max_Line_Length); type ALI_File is limited private; --------------------- -- Directory Input -- --------------------- type Rec_DIR is limited private; -- This one is used for recursive search of .ali files procedure Find_ALI_Files; -- Find all the ali files that we will have to parse, and have them to -- the file list --------------------- -- Search patterns -- --------------------- type Search_Pattern is private; type Search_Pattern_Ptr is access all Search_Pattern; procedure Add_Entity (Pattern : in out Search_Pattern; Entity : String; Glob : Boolean := False); -- Add a new entity to the search pattern (the entity should have the -- form pattern[:file[:line[:column]]], and it is parsed entirely in -- this procedure. Glob indicates if we should use the 'globbing -- patterns' (True) or the full regular expressions (False) procedure Add_Xref_File (File : String); -- Add a new file in the list of files to search for references. File -- is interpreted as a globbing regular expression, which is expanded. Invalid_Argument : exception; -- Exception raised when there is a syntax error in the command line ----------------------- -- Output Algorithms -- ----------------------- procedure Print_Gnatfind (References : Boolean; Full_Path_Name : Boolean); procedure Print_Unused (Full_Path_Name : Boolean); procedure Print_Vi (Full_Path_Name : Boolean); procedure Print_Xref (Full_Path_Name : Boolean); -- The actual print procedures. These functions step through the symbol -- table and print all the symbols if they match the files given on the -- command line (they already match the entities if they are in the -- symbol table) ------------------------ -- General Algorithms -- ------------------------ function Default_Project_File (Dir_Name : String) return String; -- Returns the default Project file name for the directory Dir_Name procedure Search (Pattern : Search_Pattern; Local_Symbols : Boolean; Wide_Search : Boolean; Read_Only : Boolean; Der_Info : Boolean; Type_Tree : Boolean); -- Search every ALI file for entities matching Pattern, and add -- these entities to the internal symbol tables. -- -- If Wide_Search is True, all ALI files found in the object path -- are searched. -- -- If Read_Only is True, read-only ALI files will also be parsed, -- similar to gnatmake -a. -- -- If Der_Info is true, then the derived type information will be -- processed. -- -- If Type_Tree is true, then the type hierarchy will be searched -- going from the pattern to the parent type. procedure Search_Xref (Local_Symbols : Boolean; Read_Only : Boolean; Der_Info : Boolean); -- Search every ali file given in the command line and all their -- dependencies. If Read_Only is True, we parse the read-only ali -- files too. If Der_Mode is true then the derived type information will -- be processed private type Rec_DIR is limited record Dir : GNAT.Directory_Operations.Dir_Type; end record; package Dependencies_Tables is new GNAT.Dynamic_Tables (Table_Component_Type => Xr_Tabls.File_Reference, Table_Index_Type => Natural, Table_Low_Bound => 1, Table_Initial => 400, Table_Increment => 100); use Dependencies_Tables; type Dependencies is new Dependencies_Tables.Instance; type ALI_File is limited record Buffer : String_Access := null; -- Buffer used to read the whole file at once Current_Line : Positive; -- Start of the current line in Buffer Xref_Line : Positive; -- Start of the xref lines in Buffer X_File : Xr_Tabls.File_Reference; -- Stores the cross-referencing file-name ("X..." lines), as an -- index into the dependencies table Dep : Dependencies; -- Store file name associated with each number ("D..." lines) end record; -- The following record type stores all the patterns that are searched for type Search_Pattern is record Entity : GNAT.Regexp.Regexp; -- A regular expression matching the entities we are looking for. -- File is a list of the places where the declaration of the entities -- has to be. When the user enters a file:line:column on the command -- line, it is stored as "Entity_Name Declaration_File:line:column" File_Ref : Xr_Tabls.File_Reference; -- A reference to the source file, if any Initialized : Boolean := False; -- Set to True when Entity has been initialized end record; end Xref_Lib;
onox/orka
Ada
2,595
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with AUnit.Assertions; with AUnit.Test_Caller; with Orka.SIMD.AVX.Doubles; with Orka.SIMD.AVX2.Doubles.Swizzle; package body Test_SIMD_AVX2_Swizzle is use Orka; use Orka.SIMD.AVX.Doubles; use Orka.SIMD.AVX2.Doubles.Swizzle; use AUnit.Assertions; package Caller is new AUnit.Test_Caller (Test); Test_Suite : aliased AUnit.Test_Suites.Test_Suite; function Suite return AUnit.Test_Suites.Access_Test_Suite is Name : constant String := "(SIMD - AVX2 - Swizzle) "; begin Test_Suite.Add_Test (Caller.Create (Name & "Test Permute function", Test_Permute'Access)); return Test_Suite'Access; end Suite; procedure Test_Permute (Object : in out Test) is Elements : constant m256d := (1.0, 2.0, 3.0, 4.0); Mask_0_0_0_0 : constant Unsigned_32 := 0 or 0 * 4 or 0 * 16 or 0 * 64; Mask_2_2_2_2 : constant Unsigned_32 := 2 or 2 * 4 or 2 * 16 or 2 * 64; Mask_1_0_3_2 : constant Unsigned_32 := 1 or 0 * 4 or 3 * 16 or 2 * 64; Mask_2_3_0_1 : constant Unsigned_32 := 2 or 3 * 4 or 0 * 16 or 1 * 64; Expected : constant array (Positive range <>) of m256d := ((1.0, 1.0, 1.0, 1.0), (3.0, 3.0, 3.0, 3.0), (2.0, 1.0, 4.0, 3.0), (3.0, 4.0, 1.0, 2.0)); Results : array (Positive range Expected'Range) of m256d; begin Results (1) := Permute (Elements, Mask_0_0_0_0); Results (2) := Permute (Elements, Mask_2_2_2_2); Results (3) := Permute (Elements, Mask_1_0_3_2); Results (4) := Permute (Elements, Mask_2_3_0_1); for I in Expected'Range loop for J in Index_4D loop declare Message : constant String := "Unexpected Single at " & Index_4D'Image (J); begin Assert (Expected (I) (J) = Results (I) (J), Message); end; end loop; end loop; end Test_Permute; end Test_SIMD_AVX2_Swizzle;
ecalderini/bingada
Ada
428
ads
--***************************************************************************** --* --* PROJECT: BingAda --* --* FILE: q_bingo.ads --* --* AUTHOR: Javier Fuica Fernandez --* --***************************************************************************** package Q_BINGO is C_LAST_NUMBER : constant := 90; subtype T_NUMBER is POSITIVE range 1 .. C_LAST_NUMBER; end Q_BINGO;
reznikmm/torrent
Ada
589
ads
-- Copyright (c) 2020 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- limited with Torrent.Contexts; with Torrent.Connections; package Torrent.Managers is task type Manager (Context : not null access Torrent.Contexts.Context; Recycle : not null access Torrent.Connections.Queue_Interfaces.Queue'Class) is entry Connected (Value : not null Torrent.Connections.Connection_Access); entry Complete; end Manager; end Torrent.Managers;
persan/midnightsun-ctf-LoveLacedLetter
Ada
166
adb
procedure Hide.Decode_generic is use all type Posix.C_String; Source_File :constant String:= Posix.Get_Line; begin Put_Line (Decode ((+Source_File))); end;
AdaCore/libadalang
Ada
64
adb
package body Pkg is package body Inner is separate; end Pkg;
MinimSecure/unum-sdk
Ada
976
ads
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is type Data is record One : Integer; Two : Integer; Three : Integer; Four : Integer; Five : Integer; Six : Integer; end record; procedure Call_Me (D : in out Data); end Pck;
ytomino/vampire
Ada
1,026
adb
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Calendar.Formatting; package body Tabula.Calendar.Time_IO is function Image (Date : Ada.Calendar.Time) return String is begin return Ada.Calendar.Formatting.Image (Date, Time_Zone => Time_Offset); end Image; function Value (Image : String) return Ada.Calendar.Time is begin return Ada.Calendar.Formatting.Value (Image, Time_Zone => Time_Offset); end Value; package Time_IO is new Serialization.IO_Custom ( Ada.Calendar.Time, Image, Value, Triming => False); procedure IO ( Serializer : not null access Serialization.Serializer; Name : in String; Value : in out Ada.Calendar.Time) renames Time_IO.IO; package Duration_IO is new Serialization.IO_Custom ( Duration, Duration'Image, Duration'Value, Triming => True); procedure IO ( Serializer : not null access Serialization.Serializer; Name : in String; Value : in out Duration) renames Duration_IO.IO; end Tabula.Calendar.Time_IO;
reznikmm/matreshka
Ada
3,585
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.DI.Edges.Hash is new AMF.Elements.Generic_Hash (DI_Edge, DI_Edge_Access);
elderdo/AdaRoombot
Ada
457
ads
with Algorithm; use Algorithm; with Communication; use Communication; with Types; use Types; package Botstate is type Bot is tagged record Algo : Algorithm_Ptr; Port : Serial_Port; end record; procedure Init (Self : in out Bot; TTY_Name : in String; Algo_Type : in Algorithm_Type); procedure Start (Self : in Bot); procedure Kill (Self : in out Bot); end Botstate;
msrLi/portingSources
Ada
826
adb
-- Copyright 2010-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/>. with Pck; use Pck; procedure Foo is New_Node : Node_Id; begin New_Node := Pn (1234); -- STOP end Foo;
iyan22/AprendeAda
Ada
2,959
adb
with Lab10_02, Ada.Text_IO; use Lab10_02, Ada.Text_IO; procedure Prueba_Obtener_Num_Vecinos_Por_Vivienda is Bloque1: constant T_Comunidad(1..10) := ((('J','o','n',others=>' '),1,'A'), (('A','i','o','r','a', others=>' '),3,'B'), (('K','o','l','d','o', others=>' '),2,'A'), (('M','i','r','e','n', others=>' '),2,'A'), (('M','i','r','e','i','a',others=>' '),1,'A'), (('I','k','e','r', others=>' '),2,'A'), (('A','r','i','t','z', others=>' '),2,'A'), (('A','n','e', others=>' '),2,'A'), (('L','e','i','r','e', others=>' '),3,'A'), (('L','o','l','a', others=>' '),1,'C')); Res1: constant T_Rascacielos := (1=>('A'=>2, 'C'=>1, others=>0), 2=>('A'=>5, others=>0), 3=>('A'..'B'=>1, others=>0), others=>(others=>0)); Bloque2: constant T_Comunidad(1..20) := ( (('J','o','n', others=>' '),1,'A'), (('A','i','o','r','a', others=>' '),3,'B'), (('K','o','l','d','o', others=>' '),24,'J'), (('M','i','r','e','n', others=>' '),24,'J'), (('M','i','r','e','i','a',others=>' '),1,'A'), (('I','k','e','r', others=>' '),24,'J'), (('A','r','i','t','z', others=>' '),24,'J'), (('A','n','e', others=>' '),24,'J'), (('L','e','i','r','e', others=>' '),3,'A'), (('L','o','l','a', others=>' '),1,'C'), (('J','u','a','n', others=>' '),1,'A'), (('A','i','r','a', others=>' '),3,'B'), (('L','u','i','s', others=>' '),24,'J'), (('M','a','r','i','a', others=>' '),24,'J'), (('M','o','i','r','a', others=>' '),1,'A'), (('I','s','a','b','e','l',others=>' '),24,'J'), (('R','o','b','l','e', others=>' '),24,'J'), (('A','n','a', others=>' '),24,'J'), (('L','e','y','r','e', others=>' '),3,'A'), (('L','o','l','o', others=>' '),1,'C')); Res2: constant T_Rascacielos := (1=>('A'=>4, 'C'=>2, others=>0), 2=>(others=>0), 3=>('A'..'B'=>2, others=>0), 24=>('J'=>10, others=>0), others=>(others=>0)); Res: T_Rascacielos; begin Put(" Bloque 1: "); new_line; new_line; put ("La vivienda con mas personas es la 2A"); new_line; new_line; put ("Tu programa dice: "); new_line; Obtener_Num_Vecinos_Por_Vivienda(Bloque1, Res); new_line; put ("El cambio de la matriz ha sido: "); if Res = Res1 then Put_Line("OK!"); else Put_line("KO!"); end if; New_Line;new_line;new_line; Put(" Bloque 2: "); new_line; new_line; put ("La vivienda con mas personas es la 24J"); new_line; new_line; put ("Tu programa dice: "); new_line; Obtener_Num_Vecinos_Por_Vivienda(Bloque2, Res); new_line; put ("El cambio de la matriz ha sido: "); if Res = Res2 then Put_Line("OK!"); else Put_line("KO!"); end if; end Prueba_Obtener_Num_Vecinos_Por_Vivienda;
reznikmm/matreshka
Ada
6,740
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Page_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Page_Element_Node is begin return Self : Text_Page_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Page_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Page (ODF.DOM.Text_Page_Elements.ODF_Text_Page_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Page_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Page_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Page_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Page (ODF.DOM.Text_Page_Elements.ODF_Text_Page_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Page_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Page (Visitor, ODF.DOM.Text_Page_Elements.ODF_Text_Page_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Page_Element, Text_Page_Element_Node'Tag); end Matreshka.ODF_Text.Page_Elements;
Rodeo-McCabe/orka
Ada
2,996
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[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. private with GL.Low_Level; package GL.Enums.Textures is pragma Preelaborate; type Parameter is (Border_Color, Mag_Filter, Min_Filter, Wrap_S, Wrap_T, Wrap_R, Min_LoD, Max_LoD, Base_Level, Max_Level, Immutable_Levels, Max_Anisotropy, LoD_Bias, Compare_Mode, Compare_Func, Cube_Map_Seamless); type Compare_Kind is (None, Compare_R_To_Texture); type Level_Parameter is (Width, Height, Internal_Format, Depth, Compressed_Image_Size, Compressed, Samples, Fixed_Sample_Locations, Buffer_Offset, Buffer_Size); private for Parameter use (Border_Color => 16#1004#, Mag_Filter => 16#2800#, Min_Filter => 16#2801#, Wrap_S => 16#2802#, Wrap_T => 16#2803#, Wrap_R => 16#8072#, Min_LoD => 16#813A#, Max_LoD => 16#813B#, Base_Level => 16#813C#, Max_Level => 16#813D#, Immutable_Levels => 16#82DF#, Max_Anisotropy => 16#84FE#, LoD_Bias => 16#8501#, Compare_Mode => 16#884C#, Compare_Func => 16#884D#, Cube_Map_Seamless => 16#884F#); for Parameter'Size use Low_Level.Enum'Size; for Compare_Kind use (None => 0, Compare_R_To_Texture => 16#884E#); for Compare_Kind'Size use Low_Level.Enum'Size; for Level_Parameter use (Width => 16#1000#, Height => 16#1001#, Internal_Format => 16#1003#, Depth => 16#8071#, Compressed_Image_Size => 16#86A0#, Compressed => 16#86A1#, Samples => 16#9106#, Fixed_Sample_Locations => 16#9107#, Buffer_Offset => 16#919D#, Buffer_Size => 16#919E#); for Level_Parameter'Size use Low_Level.Enum'Size; end GL.Enums.Textures;
Irvise/Ada_SaxonSOC
Ada
408
ads
-- Main SaxonSOC package -- See https://github.com/SpinalHDL/SaxonSoc/blob/ -- bade201e38363030aab41dbec5565885a2f68dc3/bsp/radiona/ulx3s/smp/include/ -- soc.h#L64 -- with System; package Interfaces.SaxonSOC is pragma Preelaborate; pragma No_Elaboration_Code_All; --------------- -- Base type -- --------------- type Bit is mod 2**1 with Size => 1; end Interfaces.SaxonSOC;
charlie5/cBound
Ada
1,402
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_tex_genfv_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_tex_genfv_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_genfv_cookie_t.Item, Element_Array => xcb.xcb_glx_get_tex_genfv_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_tex_genfv_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_genfv_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_tex_genfv_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_tex_genfv_cookie_t;
reznikmm/matreshka
Ada
3,669
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.Text_Note_Body_Elements is pragma Preelaborate; type ODF_Text_Note_Body is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Note_Body_Access is access all ODF_Text_Note_Body'Class with Storage_Size => 0; end ODF.DOM.Text_Note_Body_Elements;
im-prakher/Amass
Ada
385
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. name = "DNSTable" type = "scrape" function start() setratelimit(1) end function vertical(ctx, domain) scrape(ctx, {url=buildurl(domain)}) end function buildurl(domain) return "https://dnstable.com/domain/" .. domain end
albertklee/SPARKZumo
Ada
2,977
adb
pragma SPARK_Mode; with Interfaces.C; use Interfaces.C; with Sparkduino; use Sparkduino; package body SPARKZumo is Stop : constant := 0; Sample_Rate : constant := 500; procedure RISC_Test is Arr : Sensor_Array; begin loop Zumo_Pushbutton.WaitForButton; Zumo_QTR.Read_Sensors (Sensor_Values => Arr, ReadMode => Emitters_On); for I in Arr'Range loop Serial_Print_Short (Msg => "Sensor" & I'Img & ": ", Val => short (Arr (I))); end loop; end loop; end RISC_Test; procedure Calibration_Sequence is begin for I in 1 .. 4 loop case I is when 1 | 3 => Zumo_Motors.SetSpeed (LeftVelocity => Motor_Speed'First / 3, RightVelocity => Motor_Speed'Last / 3); when others => Zumo_Motors.SetSpeed (LeftVelocity => Motor_Speed'Last / 3, RightVelocity => Motor_Speed'First / 3); end case; for J in 1 .. 80 loop Zumo_QTR.Calibrate (ReadMode => ReadMode); SysDelay (20); end loop; end loop; Zumo_Motors.SetSpeed (LeftVelocity => Stop, RightVelocity => Stop); end Calibration_Sequence; procedure Inits is begin Zumo_LED.Init; Zumo_Pushbutton.Init; Zumo_Motors.Init; Zumo_QTR.Init; -- Zumo_Motion.Init; Initd := True; end Inits; procedure Setup is begin -- Board_Init.Initialize; Inits; Zumo_LED.Yellow_Led (On => True); Zumo_Pushbutton.WaitForButton; Zumo_LED.Yellow_Led (On => False); Calibration_Sequence; -- RISC_Test; Zumo_LED.Yellow_Led (On => True); Zumo_Pushbutton.WaitForButton; -- for I in Zumo_QTR.Cal_Vals_On'Range loop -- Serial_Print_Calibration (Index => I, -- Min => Zumo_QTR.Cal_Vals_On (I).Min, -- Max => Zumo_QTR.Cal_Vals_On (I).Max); -- end loop; -- -- SysDelay (1000); -- Zumo_Pushbutton.WaitForButton; end Setup; procedure WorkLoop is Start, Length : unsigned_long; begin Start := Millis; Line_Finder.LineFinder (ReadMode => ReadMode); Length := Millis - Start; if Length < Sample_Rate then DelayMicroseconds (Time => unsigned (Sample_Rate - Length) * 100); end if; end WorkLoop; procedure Exception_Handler is begin Zumo_Motors.SetSpeed (LeftVelocity => Stop, RightVelocity => Stop); loop Zumo_LED.Yellow_Led (On => True); SysDelay (Time => 500); Zumo_LED.Yellow_Led (On => False); SysDelay (Time => 500); end loop; end Exception_Handler; end SPARKZumo;
sungyeon/drake
Ada
1,700
ads
pragma License (Unrestricted); -- extended unit specialized for Darwin private with C; package Ada.Environment_Encoding.Names is -- Constants for schemes of system-specific text encoding. pragma Preelaborate; UTF_8 : Encoding_Id renames Environment_Encoding.UTF_8; UTF_16 : Encoding_Id renames Environment_Encoding.UTF_16; UTF_32 : Encoding_Id renames Environment_Encoding.UTF_32; UTF_16BE : constant Encoding_Id; UTF_16LE : constant Encoding_Id; UTF_32BE : constant Encoding_Id; UTF_32LE : constant Encoding_Id; Latin_1 : constant Encoding_Id; Windows_31J : constant Encoding_Id; EUC_JP : constant Encoding_Id; private use type C.char_array; UTF_16BE : constant Encoding_Id := Encoding_Id (System.Native_Environment_Encoding.UTF_16BE); UTF_16LE : constant Encoding_Id := Encoding_Id (System.Native_Environment_Encoding.UTF_16LE); UTF_32BE : constant Encoding_Id := Encoding_Id (System.Native_Environment_Encoding.UTF_32BE); UTF_32LE : constant Encoding_Id := Encoding_Id (System.Native_Environment_Encoding.UTF_32LE); Latin_1_Name : aliased constant C.char_array (0 .. 10) := "ISO-8859-1" & C.char'Val (0); Latin_1 : constant Encoding_Id := Latin_1_Name (0)'Access; Windows_31J_Name : aliased constant C.char_array (0 .. 11) := "windows-31j" & C.char'Val (0); -- ibm-943_P15A-2003 Windows_31J : constant Encoding_Id := Windows_31J_Name (0)'Access; EUC_JP_Name : aliased constant C.char_array (0 .. 6) := "EUC-JP" & C.char'Val (0); -- ibm-33722_P12A_P12A-2004_U2 EUC_JP : constant Encoding_Id := EUC_JP_Name (0)'Access; end Ada.Environment_Encoding.Names;
LionelDraghi/smk
Ada
15,002
adb
-- ----------------------------------------------------------------------------- -- smk, the smart make (http://lionel.draghi.free.fr/smk/) -- © 2018, 2019 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- http://www.apache.org/licenses/LICENSE-2.0 -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- ----------------------------------------------------------------------------- with Smk.IO; with Smk.Settings; with Ada.Command_Line; with Ada.Directories; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; with Ada.Directories; with Smk.Smkfiles; use type Smk.Smkfiles.Smk_File_Name; separate (Smk.Main) procedure Analyze_Cmd_Line is -- -------------------------------------------------------------------------- Arg_Counter : Positive := 1; Unidentified_Opt : Unbounded_String := Null_Unbounded_String; -- -------------------------------------------------------------------------- procedure Next_Arg is begin Arg_Counter := Arg_Counter + 1; end Next_Arg; -- -------------------------------------------------------------------------- procedure Set_If_Not_Already_Set (New_Command : in Commands) is begin if Current_Command = None then Current_Command := New_Command; else Put_Error ("More than one command on command line : " & Commands'Image (New_Command) & " and " & Commands'Image (Current_Command), With_Help => True); end if; end Set_If_Not_Already_Set; -- -------------------------------------------------------------------------- function Is_Section_Name (Opt : in String) return Boolean is begin return Ada.Strings.Fixed.Index (Source => Opt, Pattern => ":") /= 0; end Is_Section_Name; -- -------------------------------------------------------------------------- procedure Process_Section_Name (Opt : in String) is Index : constant Natural := Ada.Strings.Fixed.Index (Opt, ":"); Smkfile : constant String := Opt (Opt'First .. Index - 1); Section : constant String := Opt (Index + 1 .. Opt'Last); begin -- maybe either smkfile:section or :section if Smkfile = "" then Settings.Set_Section_Name (Section); else if Ada.Directories.Exists (Smkfile) then Settings.Set_Smkfile_Name (Smkfile); Settings.Set_Section_Name (Section); else Put_Error ("Unknown Smkfile " & Smkfile & " in " & Opt, With_Help => False); end if; end if; end Process_Section_Name; -- -------------------------------------------------------------------------- procedure Unidentified_Opt_Processing is procedure Reset_Unidentified_Opt is begin Unidentified_Opt := Null_Unbounded_String; end Reset_Unidentified_Opt; begin case Current_Command is -- the unrecognized argument processing depends on the -- ongoing command when Read_Smkfile | Status | List_Sources | List_Targets | List_Unused | Whatsnew => declare Opt : constant String := To_String (Unidentified_Opt); begin -- should be the smkfile if Ada.Directories.Exists (Opt) then Settings.Set_Smkfile_Name (Opt); Reset_Unidentified_Opt; else Put_Error ("Unknown Smkfile " & Opt, With_Help => False); end if; end; when List_Previous_Runs | Reset | Version | Help | None | Dump => -- no more argument expected Put_Error ("Unknown option " & To_String (Unidentified_Opt), With_Help => True); when Clean | Build => declare Opt : constant String := To_String (Unidentified_Opt); begin -- may be smkfile or target or section if Ada.Directories.Exists (Opt) then Settings.Set_Smkfile_Name (Opt); Reset_Unidentified_Opt; elsif Is_Section_Name (Opt) then Process_Section_Name (Opt); Reset_Unidentified_Opt; else Settings.Set_Target_Name (Opt); Reset_Unidentified_Opt; end if; end; when Add | Settings.Run => -- the Add case is already process at the beginning of the if, -- this line can't be executed! Put_Error ("Unknown error in command line on :" & To_String (Unidentified_Opt)); end case; end Unidentified_Opt_Processing; -- -------------------------------------------------------------------------- procedure Implicit_Smkfile_Processing is -- if there is no smkfile in the command line, but there is -- no ambiguity because there is only one runfile in the current dir, -- let's load it. begin if not Is_Smkfile_Name_Set and Current_Command not in List_Previous_Runs | Reset | Version | Help then -- Check for implicit Smkfile, except if the command doesn't need it -- IO.Put_Debug_Line ("no smkfile given"); -- No smkfile given on the command line declare use type Ada.Containers.Count_Type; use Runfiles; use Files; use File_Lists; use Smkfiles; Run_List : constant File_Lists.Map := Get_Run_List; begin if Run_List.Length = 1 then -- implicit smkfile: if there's only one in the -- current directory, then, go with it! declare Runfile_Name : constant String := To_Runfile_Name (+Key (Run_List.First)); Run : Runfile; begin -- Put_Error ("1 ***********************"); Settings.Set_Runfile_Name (Runfile_Name); -- Put_Error ("2 ***********************"); Run := Get_Saved_Run (+Runfile_Name); -- Put_Error ("3 ***********************"); Settings.Set_Smkfile_Name (+Run.Smkfile_Name); -- Put_Error ("4 ***********************"); end; elsif Run_List.Length > 1 then Put_Error ("No smkfile given, and more than one runfile in dir", With_Help => False); elsif Ada.Directories.Exists (Default_Smkfile_Name) then Settings.Set_Smkfile_Name (Default_Smkfile_Name); IO.Put_Line ("Using smkfile = " & (Smkfile_Name), Level => Verbose); else Put_Error ("No smkfile given, and no existing runfile in dir", With_Help => False); end if; end; -- elsif Settings.Target_Name /= "" and Current_Command /= Build then -- -- Target_Name is meaningless unless building, so -- -- what we took for the target name was just a typo -- Put_Error ("Unknown smkfile or unknow option " -- & Settings.Target_Name, With_Help => False); end if; end Implicit_Smkfile_Processing; -- -------------------------------------------------------------------------- procedure Put_Settings is function Checkbox (Switch : Boolean) return String is (if Switch then "[X]" else "[ ]"); begin IO.New_Line; IO.Put_Line ("Settings / Command line analysis:"); IO.Put_Line ("---------------------------------"); IO.New_Line; IO.Put_Line (" Verbosity : " & Print_Out_Level'Image (Verbosity)); IO.Put_Line (" Command : " & Commands'Image (Current_Command)); IO.Put_Line (" Smkfile name : " & Smkfile_Name); IO.Put_Line (" Runfile name : " & Runfile_Name); IO.Put_Line (" Strace out file : " & Strace_Outfile_Name); IO.Put_Line (" Section name : " & Section_Name); IO.Put_Line (" Cmd Line : " & Command_Line); IO.Put_Line (" Target name : " & Target_Name); IO.Put_Line (" Unidentified Opt : " & To_String (Unidentified_Opt)); IO.Put_Line (" Initial directory : " & Initial_Directory); IO.New_Line; IO.Put_Line (" System Files : "); for F of System_Files loop IO.Put_Line (" - " & F.all); end loop; IO.New_Line; IO.Put_Line (" Ignore list : "); for F of Ignore_List loop IO.Put_Line (" - " & F.all); end loop; IO.New_Line; IO.Put_Line (" " & Checkbox (Build_Missing_Targets) & " Build_Missing_Targets"); IO.Put_Line (" " & Checkbox (Always_Make) & " Always_Make"); IO.Put_Line (" " & Checkbox (Explain) & " Explain"); IO.Put_Line (" " & Checkbox (Dry_Run) & " Dry_Run"); IO.Put_Line (" " & Checkbox (Keep_Going) & " Keep_Going"); IO.Put_Line (" " & Checkbox (Ignore_Errors) & " Ignore_Errors"); IO.Put_Line (" " & Checkbox (Long_Listing_Format) & " Long_Listing_Format"); -- Put_Line (" " & Checkbox (Recursive) & " Recursive"); IO.Put_Line (" " & Checkbox (Warnings_As_Errors) & " Warnings_As_Errors"); IO.Put_Line (" " & Checkbox (Shorten_File_Names) & " Shorten_File_Names"); IO.Put_Line (" " & Checkbox (Filter_Sytem_Files) & " Filter_Sytem_Files"); IO.New_Line; IO.Put_Line ("---------------------------------"); IO.New_Line; end Put_Settings; begin -- -------------------------------------------------------------------------- -- NB: command line, including arguments should comply with GNU Coding -- standards -- (https://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html) while Arg_Counter <= Ada.Command_Line.Argument_Count loop declare Opt : constant String := Ada.Command_Line.Argument (Arg_Counter); begin -- Commands: if Current_Command = Add or Current_Command = Run then -- all parameters following "add" are considered as part of the -- command line, so there is no analysis of the content Add_To_Command_Line (Opt); elsif Opt = "build" then Set_If_Not_Already_Set (Build); elsif Opt = "st" or Opt = "status" then Set_If_Not_Already_Set (Status); elsif Opt = "clean" then Set_If_Not_Already_Set (Clean); elsif Opt = "reset" then Set_If_Not_Already_Set (Reset); elsif Opt = "version" then Set_If_Not_Already_Set (Version); elsif Opt = "help" or Opt = "-h" or Opt = "--help" then Set_If_Not_Already_Set (Help); elsif Opt = "rs" or Opt = "read-smkfile" then Set_If_Not_Already_Set (Read_Smkfile); elsif Opt = "lr" or Opt = "list-runs" then Set_If_Not_Already_Set (List_Previous_Runs); elsif Opt = "ls" or Opt = "list-sources" then Set_If_Not_Already_Set (List_Sources); elsif Opt = "lt" or Opt = "list-targets" then Set_If_Not_Already_Set (List_Targets); elsif Opt = "lu" or Opt = "list-unused" then Set_If_Not_Already_Set (List_Unused); elsif Opt = "wn" or Opt = "whatsnew" then Set_If_Not_Already_Set (Whatsnew); elsif Opt = "add" then Set_If_Not_Already_Set (Add); elsif Opt = "run" then Set_If_Not_Already_Set (Run); elsif Opt = "dump" then Set_If_Not_Already_Set (Dump); -- Options: elsif Opt = "-mt" or Opt = "--missing-targets" then Settings.Build_Missing_Targets := True; elsif Opt = "-a" or Opt = "--always-make" then Settings.Always_Make := True; elsif Opt = "-e" or Opt = "--explain" then Settings.Explain := True; elsif Opt = "-n" or Opt = "--dry-run" then Settings.Dry_Run := True; elsif Opt = "-sa" or Opt = "--show-all-files" then Settings.Filter_Sytem_Files := False; elsif Opt = "-ds" or Opt = "--dont-shorten" then Settings.Shorten_File_Names := False; elsif Opt = "-i" or Opt = "--ignore-errors" then Settings.Ignore_Errors := True; elsif Opt = "-l" or Opt = "--long-listing" then Settings.Long_Listing_Format := True; elsif Opt = "-k" or Opt = "--keep-going" then Settings.Keep_Going := True; elsif Opt = "-We" or Opt = "--Warnings=error" then Settings.Warnings_As_Errors := True; elsif Opt = "-v" or Opt = "--verbose" then Settings.Verbosity := Verbose; elsif Opt = "-q" or Opt = "--quiet" then Settings.Verbosity := Quiet; elsif Opt = "-d" then -- undocumented option Settings.Verbosity := Debug; else Unidentified_Opt := To_Unbounded_String (Opt); end if; if IO.Some_Error then return; end if; -- No need to further analyze command line, or to do -- Options_Coherency_Tests. end; Next_Arg; end loop; -- -------------------------------------------------------------------------- if Current_Command = None then -- default behavior = build Set_If_Not_Already_Set (Build); end if; -- -------------------------------------------------------------------------- if Unidentified_Opt /= "" then Unidentified_Opt_Processing; end if; -- -------------------------------------------------------------------------- if not Is_Smkfile_Name_Set and (Current_Command = Add or Current_Command = Run) then -- adding to default smkfile if none given Set_Smkfile_Name (Default_Smkfile_Name); end if; -- -------------------------------------------------------------------------- Implicit_Smkfile_Processing; -- -------------------------------------------------------------------------- if Debug_Mode then Put_Settings; end if; end Analyze_Cmd_Line;
reznikmm/matreshka
Ada
4,239
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2019, 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 WebAPI.UI_Events.Input is pragma Preelaborate; type Input_Event is limited interface and WebAPI.UI_Events.UI_Event; not overriding function Get_Is_Composing (Self : not null access constant Input_Event) return Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "isComposing"; -- true if the input event occurs as part of a composition session, -- i.e., after a compositionstart event and before the corresponding -- compositionend event. not overriding function Get_Input_Type (Self : not null access constant Input_Event) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "inputType"; -- inputType holds the type of input. end WebAPI.UI_Events.Input;
reznikmm/matreshka
Ada
5,130
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.Literal_Booleans.Collections is pragma Preelaborate; package UML_Literal_Boolean_Collections is new AMF.Generic_Collections (UML_Literal_Boolean, UML_Literal_Boolean_Access); type Set_Of_UML_Literal_Boolean is new UML_Literal_Boolean_Collections.Set with null record; Empty_Set_Of_UML_Literal_Boolean : constant Set_Of_UML_Literal_Boolean; type Ordered_Set_Of_UML_Literal_Boolean is new UML_Literal_Boolean_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Literal_Boolean : constant Ordered_Set_Of_UML_Literal_Boolean; type Bag_Of_UML_Literal_Boolean is new UML_Literal_Boolean_Collections.Bag with null record; Empty_Bag_Of_UML_Literal_Boolean : constant Bag_Of_UML_Literal_Boolean; type Sequence_Of_UML_Literal_Boolean is new UML_Literal_Boolean_Collections.Sequence with null record; Empty_Sequence_Of_UML_Literal_Boolean : constant Sequence_Of_UML_Literal_Boolean; private Empty_Set_Of_UML_Literal_Boolean : constant Set_Of_UML_Literal_Boolean := (UML_Literal_Boolean_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Literal_Boolean : constant Ordered_Set_Of_UML_Literal_Boolean := (UML_Literal_Boolean_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Literal_Boolean : constant Bag_Of_UML_Literal_Boolean := (UML_Literal_Boolean_Collections.Bag with null record); Empty_Sequence_Of_UML_Literal_Boolean : constant Sequence_Of_UML_Literal_Boolean := (UML_Literal_Boolean_Collections.Sequence with null record); end AMF.UML.Literal_Booleans.Collections;
PhillipDyer/sdlada
Ada
21,065
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 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. -------------------------------------------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; with Interfaces.C; with Interfaces.C.Strings; with SDL.Error; -- with SDL.Video.Surfaces.Makers; -- with SDL.Log; package body SDL.Video.Windows is package C renames Interfaces.C; use type C.int; use type SDL.C_Pointers.Windows_Pointer; use type System.Address; procedure Increment_Windows is begin Total_Windows_Created := Total_Windows_Created + 1; end Increment_Windows; procedure Decrement_Windows is begin Total_Windows_Created := Total_Windows_Created - 1; end Decrement_Windows; overriding procedure Finalize (Self : in out Window) is procedure SDL_Destroy (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_DestroyWindow"; begin -- SDL.Log.Put_Debug ("Windows.Finalize: " & (if Self.Internal = null then "null" else "not null") & -- " " & (if Self.Owns = True then "owns" else "Doesn't own")); -- Make sure we don't delete this twice! if Self.Internal /= null and then Self.Owns then -- SDL.Log.Put_Debug ("Windows.Finalize: Deleting"); SDL_Destroy (Self.Internal); Self.Internal := null; Decrement_Windows; end if; end Finalize; function Get_Brightness (Self : in Window) return Brightness is function SDL_Get_Brightness (W : in SDL.C_Pointers.Windows_Pointer) return C.C_float with Import => True, Convention => C, External_Name => "SDL_GetWindowBrightness"; begin return Brightness (SDL_Get_Brightness (Self.Internal)); end Get_Brightness; procedure Set_Brightness (Self : in out Window; How_Bright : in Brightness) is function SDL_Set_Brightness (W : in SDL.C_Pointers.Windows_Pointer; B : in C.C_float) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowBrightness"; Result : C.int := SDL_Set_Brightness (Self.Internal, C.C_float (How_Bright)); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Brightness; -- TODO: Try to see if we can just see User_Data_Access as the return type from the C function. function To_Data_Access is new Ada.Unchecked_Conversion (Source => System.Address, Target => User_Data_Access); function To_Address is new Ada.Unchecked_Conversion (Source => User_Data_Access, Target => System.Address); -- TODO: Make this and Set_Data generic. function Get_Data (Self : in Window; Name : in String) return User_Data_Access is function SDL_Get_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr) return System.Address with Import => True, Convention => C, External_Name => "SDL_GetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Item : User_Data_Access := To_Data_Access (SDL_Get_Window_Data (Self.Internal, C_Name_Str)); begin C.Strings.Free (C_Name_Str); return Item; end Get_Data; function Set_Data (Self : in out Window; Name : in String; Item : in User_Data_Access) return User_Data_Access is function SDL_Set_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr; User_Data : in System.Address) return System.Address with Import => True, Convention => C, External_Name => "SDL_SetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Previous_Data : User_Data_Access := To_Data_Access (SDL_Set_Window_Data (Self.Internal, C_Name_Str, To_Address (Item))); begin C.Strings.Free (C_Name_Str); return Previous_Data; end Set_Data; function Display_Index (Self : in Window) return Positive is function SDL_Get_Window_Display_Index (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayIndex"; Total : C.int := SDL_Get_Window_Display_Index (Self.Internal); begin if Total < 0 then raise Window_Error with SDL.Error.Get; end if; return Positive (Total); end Display_Index; procedure Get_Display_Mode (Self : in Window; Mode : out SDL.Video.Displays.Mode) is function SDL_Get_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : out SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayMode"; Result : C.int := SDL_Get_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Display_Mode; procedure Set_Display_Mode (Self : in out Window; Mode : in SDL.Video.Displays.Mode) is function SDL_Set_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : in SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowDisplayMode"; Result : C.int := SDL_Set_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Display_Mode; function Get_Flags (Self : in Window) return Window_Flags is function SDL_Get_Window_Flags (W : in SDL.C_Pointers.Windows_Pointer) return Window_Flags with Import => True, Convention => C, External_Name => "SDL_GetWindowFlags"; begin return SDL_Get_Window_Flags (Self.Internal); end Get_Flags; function From_ID (Window_ID : in ID) return Window is function SDL_Get_Window_From_ID (W : in ID) return SDL.C_Pointers.Windows_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowFromID"; begin return W : constant Window := (Ada.Finalization.Limited_Controlled with Internal => SDL_Get_Window_From_ID (Window_ID), Owns => False) do null; end return; end From_ID; procedure Get_Gamma_Ramp (Self : in Window; Red, Green, Blue : out SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Get_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : out SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowGammaRamp"; Result : C.int := SDL_Get_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Gamma_Ramp; procedure Set_Gamma_Ramp (Self : in out Window; Red, Green, Blue : in SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Set_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : in SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowGammaRamp"; Result : C.int := SDL_Set_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Gamma_Ramp; function Is_Grabbed (Self : in Window) return Boolean is function SDL_Get_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer) return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_GetWindowGrab"; begin return (SDL_Get_Window_Grab (Self.Internal) = SDL_True); end Is_Grabbed; procedure Set_Grabbed (Self : in out Window; Grabbed : in Boolean := True) is procedure SDL_Set_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer; G : in SDL_Bool) with Import => True, Convention => C, External_Name => "SDL_SetWindowGrab"; begin SDL_Set_Window_Grab (Self.Internal, (if Grabbed = True then SDL_True else SDL_False)); end Set_Grabbed; function Get_ID (Self : in Window) return ID is function SDL_Get_Window_ID (W : in SDL.C_Pointers.Windows_Pointer) return ID with Import => True, Convention => C, External_Name => "SDL_GetWindowID"; begin return SDL_Get_Window_ID (Self.Internal); end Get_ID; function Get_Maximum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMaximumSize"; W, H : C.int := 0; begin SDL_Get_Window_Maximum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Maximum_Size; procedure Set_Maximum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMaximumSize"; begin SDL_Get_Window_Maximum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Maximum_Size; function Get_Minimum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMinimumSize"; W, H : C.int := 0; begin SDL_Get_Window_Minimum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Minimum_Size; procedure Set_Minimum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMinimumSize"; begin SDL_Get_Window_Minimum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Minimum_Size; function Pixel_Format (Self : in Window) return SDL.Video.Pixel_Formats.Pixel_Format is function SDL_Get_Window_Pixel_Format (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Pixel_Formats.Pixel_Format with Import => True, Convention => C, External_Name => "SDL_GetWindowPixelFormat"; begin return SDL_Get_Window_Pixel_Format (Self.Internal); end Pixel_Format; function Get_Position (Self : in Window) return SDL.Natural_Coordinates is procedure SDL_Get_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : out C.int) with Import => True, Convention => C, External_Name => "SDL_GetWindowPosition"; Position : SDL.Natural_Coordinates := SDL.Zero_Coordinate; begin SDL_Get_Window_Position (Self.Internal, Position.X, Position.Y); return Position; end Get_Position; procedure Set_Position (Self : in out Window; Position : SDL.Natural_Coordinates) is procedure SDL_Set_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowPosition"; begin SDL_Set_Window_Position (Self.Internal, Position.X, Position.Y); end Set_Position; function Get_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowSize"; W, H : C.int := 0; begin SDL_Get_Window_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Size; procedure Set_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowSize"; begin SDL_Get_Window_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Size; function Get_Surface (Self : in Window) return SDL.Video.Surfaces.Surface is function SDL_Get_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowSurface"; use type SDL.Video.Surfaces.Internal_Surface_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer := SDL_Get_Window_Surface (Self.Internal); function Make_Surface_From_Pointer (S : in SDL.Video.Surfaces.Internal_Surface_Pointer) return SDL.Video.Surfaces.Surface with Convention => Ada, Import => True; begin if S = null then raise Window_Error with SDL.Error.Get; end if; return Make_Surface_From_Pointer (S); end Get_Surface; function Get_Title (Self : in Window) return Ada.Strings.UTF_Encoding.UTF_8_String is function SDL_Get_Window_Title (W : in SDL.C_Pointers.Windows_Pointer) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetWindowTitle"; begin return C.Strings.Value (SDL_Get_Window_Title (Self.Internal)); end Get_Title; procedure Set_Title (Self : in Window; Title : in Ada.Strings.UTF_Encoding.UTF_8_String) is procedure SDL_Set_Window_Title (W : in SDL.C_Pointers.Windows_Pointer; C_Str : in C.char_array) with Import => True, Convention => C, External_Name => "SDL_SetWindowTitle"; begin SDL_Set_Window_Title (Self.Internal, C.To_C (Title)); end Set_Title; procedure Hide (Self : in Window) is procedure SDL_Hide_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_HideWindow"; begin SDL_Hide_Window (Self.Internal); end Hide; procedure Show (Self : in Window) is procedure SDL_Show_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_ShowWindow"; begin SDL_Show_Window (Self.Internal); end Show; procedure Maximise (Self : in Window) is procedure SDL_Maximise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MaximizeWindow"; begin SDL_Maximise_Window (Self.Internal); end Maximise; procedure Minimise (Self : in Window) is procedure SDL_Minimise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MinimizeWindow"; begin SDL_Minimise_Window (Self.Internal); end Minimise; procedure Raise_And_Focus (Self : in Window) is procedure SDL_Raise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RaiseWindow"; begin SDL_Raise_Window (Self.Internal); end Raise_And_Focus; procedure Restore (Self : in Window) is procedure SDL_Restore_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RestoreWindow"; begin SDL_Restore_Window (Self.Internal); end Restore; procedure Set_Mode (Self : in out Window; Flags : in Full_Screen_Flags) is function SDL_Window_Full_Screen (W : in SDL.C_Pointers.Windows_Pointer; F : in Full_Screen_Flags) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowFullscreen"; Result : C.int := SDL_Window_Full_Screen (Self.Internal, Flags); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Mode; procedure Set_Icon (Self : in out Window; Icon : in SDL.Video.Surfaces.Surface) is procedure SDL_Set_Window_Icon (W : in SDL.C_Pointers.Windows_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer) with Import => True, Convention => C, External_Name => "SDL_SetWindowIcon"; function Get_Internal_Surface (Self : in SDL.Video.Surfaces.Surface) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => Ada; begin SDL_Set_Window_Icon (Self.Internal, Get_Internal_Surface (Icon)); end Set_Icon; procedure Update_Surface (Self : in Window) is function SDL_Update_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurface"; Result : C.int := SDL_Update_Window_Surface (Self.Internal); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface; procedure Update_Surface_Rectangle (Self : in Window; Rectangle : in SDL.Video.Rectangles.Rectangle) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangle, 1); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangle; procedure Update_Surface_Rectangles (Self : in Window; Rectangles : SDL.Video.Rectangles.Rectangle_Arrays) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle_Arrays; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangles, Rectangles'Length); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangles; function Exist return Boolean is begin if Total_Windows_Created /= Natural'First then return True; end if; return False; end Exist; function Get_Internal_Window (Self : in Window) return SDL.C_Pointers.Windows_Pointer is begin return Self.Internal; end Get_Internal_Window; end SDL.Video.Windows;
MinimSecure/unum-sdk
Ada
1,218
ads
-- Copyright 2013-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is Global_Float : Float := 0.0; Global_Double : Long_Float := 0.0; Global_Long_Double : Long_Long_Float := 0.0; type Small_Struct is record I : Integer; end record; Global_Small_Struct : Small_Struct := (I => 0); procedure Set_Float (F : Float); procedure Set_Double (Dummy : Integer; D : Long_Float); procedure Set_Long_Double (Dummy : Integer; DS: Small_Struct; LD : Long_Long_Float); end Pck;
sungyeon/drake
Ada
248
ads
pragma License (Unrestricted); with Ada.Numerics.Generic_Elementary_Functions; package Ada.Numerics.Long_Long_Elementary_Functions is new Generic_Elementary_Functions (Long_Long_Float); pragma Pure (Ada.Numerics.Long_Long_Elementary_Functions);
tum-ei-rcs/StratoX
Ada
10,317
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- -- S I N G L E _ E N T R Y -- -- -- -- B o d y -- -- -- -- Copyright (C) 1998-2013, AdaCore -- -- -- -- GNARL 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. GNARL 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Turn off subprogram ordering check, since restricted GNARLI -- subprograms are gathered together at end. -- This package provides an optimized version of Protected_Objects.Operations -- and Protected_Objects.Entries making the following assumptions: -- -- PO have only one entry -- There is only one caller at a time (No_Entry_Queue) -- There is no dynamic priority support (No_Dynamic_Priorities) -- No Abort Statements -- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0) -- PO are at library level -- No Requeue -- None of the tasks will terminate (no need for finalization) -- -- This interface is intended to be used in the ravenscar and restricted -- profiles, the compiler is responsible for ensuring that the conditions -- mentioned above are respected, except for the No_Entry_Queue restriction -- that is checked dynamically in this package, since the check cannot be -- performed at compile time (see Protected_Single_Entry_Call, Service_Entry). pragma Polling (Off); -- Turn off polling, we do not want polling to take place during tasking -- operations. It can cause infinite loops and other problems. pragma Suppress (All_Checks); with System.Multiprocessors; with System.Task_Primitives.Operations; -- used for Self -- Get_Priority -- Set_Priority with System.Tasking.Protected_Objects.Multiprocessors; package body System.Tasking.Protected_Objects.Single_Entry is use System.Multiprocessors; package STPO renames System.Task_Primitives.Operations; package STPOM renames System.Tasking.Protected_Objects.Multiprocessors; Multiprocessor : constant Boolean := CPU'Range_Length /= 1; --------------------------------- -- Initialize_Protection_Entry -- --------------------------------- procedure Initialize_Protection_Entry (Object : Protection_Entry_Access; Ceiling_Priority : Integer; Compiler_Info : System.Address; Entry_Body : Entry_Body_Access) is begin Initialize_Protection (Object.Common'Access, Ceiling_Priority); Object.Compiler_Info := Compiler_Info; Object.Call_In_Progress := null; Object.Entry_Body := Entry_Body; Object.Entry_Queue := null; end Initialize_Protection_Entry; ---------------- -- Lock_Entry -- ---------------- procedure Lock_Entry (Object : Protection_Entry_Access) is begin Lock (Object.Common'Access); end Lock_Entry; ---------------------------- -- Protected_Single_Count -- ---------------------------- function Protected_Count_Entry (Object : Protection_Entry) return Natural is begin return Boolean'Pos (Object.Entry_Queue /= null); end Protected_Count_Entry; --------------------------------- -- Protected_Single_Entry_Call -- --------------------------------- procedure Protected_Single_Entry_Call (Object : Protection_Entry_Access; Uninterpreted_Data : System.Address) is Self_Id : constant Task_Id := STPO.Self; begin -- For this run time, pragma Detect_Blocking is always active, so we -- must raise Program_Error if this potentially blocking operation is -- called from a protected action. if Self_Id.Common.Protected_Action_Nesting > 0 then raise Program_Error; end if; Lock_Entry (Object); Self_Id.Entry_Call.Uninterpreted_Data := Uninterpreted_Data; if Object.Entry_Body.Barrier (Object.Compiler_Info, 1) then -- No other task can be executing an entry within this protected -- object. On a single processor implementation (such as this one), -- the ceiling priority protocol and the strictly preemptive priority -- scheduling policy guarantee that protected objects are always -- available when any task tries to use them (otherwise, either the -- currently executing task would not have had a high enough priority -- to be executing, or a blocking operation would have been called -- from within the entry body). pragma Assert (Object.Call_In_Progress = null); Object.Call_In_Progress := Self_Id.Entry_Call'Access; Object.Entry_Body.Action (Object.Compiler_Info, Self_Id.Entry_Call.Uninterpreted_Data, 1); Object.Call_In_Progress := null; -- Entry call is over Unlock_Entry (Object); else if Object.Entry_Queue /= null then -- This violates the No_Entry_Queue restriction, raise -- Program_Error. Unlock_Entry (Object); raise Program_Error; end if; -- There is a potential race condition between the Unlock_Entry and -- the Sleep below (the Wakeup may be called before the Sleep). This -- case is explicitly handled in the Sleep and Wakeup procedures: -- Sleep won't block if Wakeup has been called before. Object.Entry_Queue := Self_Id.Entry_Call'Access; Unlock_Entry (Object); -- Suspend until entry call has been completed. -- On exit, the call will not be queued. Self_Id.Common.State := Entry_Caller_Sleep; STPO.Sleep (Self_Id, Entry_Caller_Sleep); Self_Id.Common.State := Runnable; end if; end Protected_Single_Entry_Call; ----------------------------------- -- Protected_Single_Entry_Caller -- ----------------------------------- function Protected_Single_Entry_Caller (Object : Protection_Entry) return Task_Id is begin return Object.Call_In_Progress.Self; end Protected_Single_Entry_Caller; ------------------- -- Service_Entry -- ------------------- procedure Service_Entry (Object : Protection_Entry_Access) is Entry_Call : constant Entry_Call_Link := Object.Entry_Queue; Caller : Task_Id; begin if Entry_Call /= null and then Object.Entry_Body.Barrier (Object.Compiler_Info, 1) then Object.Entry_Queue := null; -- No other task can be executing an entry within this protected -- object. On a single processor implementation (such as this one), -- the ceiling priority protocol and the strictly preemptive -- priority scheduling policy guarantee that protected objects are -- always available when any task tries to use them (otherwise, -- either the currently executing task would not have had a high -- enough priority to be executing, or a blocking operation would -- have been called from within the entry body). pragma Assert (Object.Call_In_Progress = null); Object.Call_In_Progress := Entry_Call; Object.Entry_Body.Action (Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1); Object.Call_In_Progress := null; Caller := Entry_Call.Self; Unlock_Entry (Object); -- Signal the entry caller that the entry is completed if not Multiprocessor or else Caller.Common.Base_CPU = STPO.Self.Common.Base_CPU then -- Entry caller and servicing tasks are on the same CPU. -- We are allowed to directly wake up the task. STPO.Wakeup (Caller, Entry_Caller_Sleep); else -- The entry caller is on a different CPU. STPOM.Served (Entry_Call); end if; else -- Just unlock the entry Unlock_Entry (Object); end if; end Service_Entry; ------------------ -- Unlock_Entry -- ------------------ procedure Unlock_Entry (Object : Protection_Entry_Access) is begin Unlock (Object.Common'Access); end Unlock_Entry; end System.Tasking.Protected_Objects.Single_Entry;
stcarrez/ada-awa
Ada
2,250
ads
----------------------------------------------------------------------- -- awa-blogs -- Blogs module -- Copyright (C) 2011, 2014, 2015, 2018, 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. ----------------------------------------------------------------------- -- = Blogs Module = -- The `blogs` module is a small blog application which allows users -- to publish articles. A user may own several blogs, each blog having -- a name and its own base URI. Within a blog, the user may write articles -- and publish them. Once published, the articles are visible to -- anonymous users. -- -- The `blogs` module uses several other modules: -- -- * the [Counters Module] to track page display counter to a blog post, -- * the [Tags Module] to associate one or several tags to a blog post, -- * the [Comments Module] to allow users to write comments on a blog post, -- * the [Images Module] to easily add images in blog post. -- -- @include awa-blogs-modules.ads -- @include awa-blogs-beans.ads -- @include-bean blogs.xml -- @include-bean blog-admin-post-list.xml -- @include-bean blog-post-list.xml -- @include-bean blog-comment-list.xml -- @include-bean blog-list.xml -- @include-bean blog-tags.xml -- -- == Queries == -- @include-query blog-admin-post-list.xml -- @include-query blog-post-list.xml -- @include-query blog-comment-list.xml -- @include-query blog-list.xml -- @include-query blog-tags.xml -- @include-query blog-images.xml -- @include-query blog-images-info.xml -- @include-query blog-stat.xml -- -- == Data model == -- [images/awa_blogs_model.png] -- package AWA.Blogs is pragma Pure; end AWA.Blogs;
optikos/oasis
Ada
5,033
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Discrete_Subtype_Indications is function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Constraint : Program.Elements.Constraints .Constraint_Access; Is_Discrete_Subtype_Definition : Boolean := False) return Discrete_Subtype_Indication is begin return Result : Discrete_Subtype_Indication := (Subtype_Mark => Subtype_Mark, Constraint => Constraint, Is_Discrete_Subtype_Definition => Is_Discrete_Subtype_Definition, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Constraint : Program.Elements.Constraints .Constraint_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Is_Discrete_Subtype_Definition : Boolean := False) return Implicit_Discrete_Subtype_Indication is begin return Result : Implicit_Discrete_Subtype_Indication := (Subtype_Mark => Subtype_Mark, Constraint => Constraint, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Is_Discrete_Subtype_Definition => Is_Discrete_Subtype_Definition, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Subtype_Mark (Self : Base_Discrete_Subtype_Indication) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Subtype_Mark; end Subtype_Mark; overriding function Constraint (Self : Base_Discrete_Subtype_Indication) return Program.Elements.Constraints.Constraint_Access is begin return Self.Constraint; end Constraint; overriding function Is_Discrete_Subtype_Definition (Self : Base_Discrete_Subtype_Indication) return Boolean is begin return Self.Is_Discrete_Subtype_Definition; end Is_Discrete_Subtype_Definition; overriding function Is_Part_Of_Implicit (Self : Implicit_Discrete_Subtype_Indication) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Discrete_Subtype_Indication) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Discrete_Subtype_Indication) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Discrete_Subtype_Indication'Class) is begin Set_Enclosing_Element (Self.Subtype_Mark, Self'Unchecked_Access); if Self.Constraint.Assigned then Set_Enclosing_Element (Self.Constraint, Self'Unchecked_Access); end if; null; end Initialize; overriding function Is_Discrete_Subtype_Indication_Element (Self : Base_Discrete_Subtype_Indication) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Discrete_Subtype_Indication_Element; overriding function Is_Discrete_Range_Element (Self : Base_Discrete_Subtype_Indication) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Discrete_Range_Element; overriding function Is_Definition_Element (Self : Base_Discrete_Subtype_Indication) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Definition_Element; overriding procedure Visit (Self : not null access Base_Discrete_Subtype_Indication; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Discrete_Subtype_Indication (Self); end Visit; overriding function To_Discrete_Subtype_Indication_Text (Self : aliased in out Discrete_Subtype_Indication) return Program.Elements.Discrete_Subtype_Indications .Discrete_Subtype_Indication_Text_Access is begin return Self'Unchecked_Access; end To_Discrete_Subtype_Indication_Text; overriding function To_Discrete_Subtype_Indication_Text (Self : aliased in out Implicit_Discrete_Subtype_Indication) return Program.Elements.Discrete_Subtype_Indications .Discrete_Subtype_Indication_Text_Access is pragma Unreferenced (Self); begin return null; end To_Discrete_Subtype_Indication_Text; end Program.Nodes.Discrete_Subtype_Indications;
reznikmm/matreshka
Ada
309
ads
with Types.Taggeds; package Types.Discriminanteds.Tasks is pragma Preelaborate; type Task_Type is limited interface and Discriminanted_Type and Types.Taggeds.Tagged_Type; type Task_Type_Access is access all Task_Type'Class with Storage_Size => 0; end Types.Discriminanteds.Tasks;
DavJo-dotdotdot/Ada_Drivers_Library
Ada
3,367
ads
------------------------------------------------------------------------------ -- -- -- Copyright © AdaCore and other contributors, 2017-2020 -- -- See https://github.com/AdaCore/Ada_Drivers_Library/graphs/contributors -- -- for more information -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with HAL; use HAL; package nRF.ADC is type Bits_Resolution is (Res_8bit, Res_10bit, Res_12bit); type Analog_Pin is range 0 .. 7; type Pin_Input_Selection is (Pin_Quadruple, Pin_Double, Pin_Full, Pin_Half, Pin_One_Third, Pin_One_Forth, Pin_One_Fifth, Pin_One_Sixth); type VDD_Input_Selection is (VDD_One_Fifth, VDD_One_Sixth); type Reference_Selection is (Internal_0V6, VDD_One_Forth); function Do_Pin_Conversion (Pin : Analog_Pin; Input : Pin_Input_Selection; Ref : Reference_Selection; Res : Bits_Resolution) return UInt16; function Do_VDD_Conversion (Input : VDD_Input_Selection; Ref : Reference_Selection; Res : Bits_Resolution) return UInt16; function Busy return Boolean; end nRF.ADC;
ashleygay/adaboy
Ada
2,719
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with processor_hpp; with memory_hpp; with lcd_hpp; with timer_handler_hpp; with Interfaces.C.Extensions; with word_operations_hpp; package gameboy_hpp is package Class_Gameboy is type Gameboy is limited record p : aliased processor_hpp.Class_Processor.Processor; -- gameboy.hpp:43 mem : aliased memory_hpp.Class_Memory.Memory; -- gameboy.hpp:44 the_lcd : aliased lcd_hpp.Class_LCD.LCD; -- gameboy.hpp:45 timers : aliased timer_handler_hpp.Class_TimerHandler.TimerHandler; -- gameboy.hpp:46 running : aliased Extensions.bool; -- gameboy.hpp:48 keys : aliased word_operations_hpp.uint8_t; -- gameboy.hpp:49 end record; pragma Import (CPP, Gameboy); function New_Gameboy return Gameboy; -- gameboy.hpp:18 pragma CPP_Constructor (New_Gameboy, "_ZN7GameboyC1Ev"); procedure step (this : access Gameboy; s : access unsigned_char); -- gameboy.hpp:21 pragma Import (CPP, step, "_ZN7Gameboy4stepEPh"); procedure changeGame (this : access Gameboy; game : access word_operations_hpp.uint8_t); -- gameboy.hpp:23 pragma Import (CPP, changeGame, "_ZN7Gameboy10changeGameEPh"); function isRunning (this : access Gameboy) return Extensions.bool; -- gameboy.hpp:25 pragma Import (CPP, isRunning, "_ZN7Gameboy9isRunningEv"); procedure stop (this : access Gameboy); -- gameboy.hpp:26 pragma Import (CPP, stop, "_ZN7Gameboy4stopEv"); function readyToLaunch (this : access Gameboy) return Extensions.bool; -- gameboy.hpp:30 pragma Import (CPP, readyToLaunch, "_ZN7Gameboy13readyToLaunchEv"); procedure setKeys (this : access Gameboy; value : word_operations_hpp.uint8_t); -- gameboy.hpp:34 pragma Import (CPP, setKeys, "_ZN7Gameboy7setKeysEh"); procedure setJoypadInterrupt (this : access Gameboy); -- gameboy.hpp:36 pragma Import (CPP, setJoypadInterrupt, "_ZN7Gameboy18setJoypadInterruptEv"); procedure wireComponents (this : access Gameboy); -- gameboy.hpp:38 pragma Import (CPP, wireComponents, "_ZN7Gameboy14wireComponentsEv"); procedure clockCycle (this : access Gameboy); -- gameboy.hpp:39 pragma Import (CPP, clockCycle, "_ZN7Gameboy10clockCycleEv"); procedure checkKeys (this : access Gameboy; atomic : word_operations_hpp.uint8_t); -- gameboy.hpp:40 pragma Import (CPP, checkKeys, "_ZN7Gameboy9checkKeysEh"); procedure interruptJOYPAD (this : access Gameboy); -- gameboy.hpp:41 pragma Import (CPP, interruptJOYPAD, "_ZN7Gameboy15interruptJOYPADEv"); end; use Class_Gameboy; end gameboy_hpp;
micahwelf/FLTK-Ada
Ada
2,806
adb
with Interfaces.C, System; use type System.Address; package body FLTK.Images.Bitmaps is procedure free_fl_bitmap (I : in System.Address); pragma Import (C, free_fl_bitmap, "free_fl_bitmap"); pragma Inline (free_fl_bitmap); function fl_bitmap_copy (I : in System.Address; W, H : in Interfaces.C.int) return System.Address; pragma Import (C, fl_bitmap_copy, "fl_bitmap_copy"); pragma Inline (fl_bitmap_copy); function fl_bitmap_copy2 (I : in System.Address) return System.Address; pragma Import (C, fl_bitmap_copy2, "fl_bitmap_copy2"); pragma Inline (fl_bitmap_copy2); procedure fl_bitmap_draw2 (I : in System.Address; X, Y : in Interfaces.C.int); pragma Import (C, fl_bitmap_draw2, "fl_bitmap_draw2"); pragma Inline (fl_bitmap_draw2); procedure fl_bitmap_draw (I : in System.Address; X, Y, W, H, CX, CY : in Interfaces.C.int); pragma Import (C, fl_bitmap_draw, "fl_bitmap_draw"); pragma Inline (fl_bitmap_draw); overriding procedure Finalize (This : in out Bitmap) is begin if This.Void_Ptr /= System.Null_Address and then This in Bitmap'Class then free_fl_bitmap (This.Void_Ptr); This.Void_Ptr := System.Null_Address; end if; Finalize (Image (This)); end Finalize; function Copy (This : in Bitmap; Width, Height : in Natural) return Bitmap'Class is begin return Copied : Bitmap do Copied.Void_Ptr := fl_bitmap_copy (This.Void_Ptr, Interfaces.C.int (Width), Interfaces.C.int (Height)); end return; end Copy; function Copy (This : in Bitmap) return Bitmap'Class is begin return Copied : Bitmap do Copied.Void_Ptr := fl_bitmap_copy2 (This.Void_Ptr); end return; end Copy; procedure Draw (This : in Bitmap; X, Y : in Integer) is begin fl_bitmap_draw2 (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)); end Draw; procedure Draw (This : in Bitmap; X, Y, W, H : in Integer; CX, CY : in Integer := 0) is begin fl_bitmap_draw (This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.int (CX), Interfaces.C.int (CY)); end Draw; end FLTK.Images.Bitmaps;
Intelligente-sanntidssystemer/Ada-prosjekt
Ada
1,301
ads
package Motor is pragma Elaborate_Body; subtype Percentage is Integer range 0 .. 100; type Travel_Directions is (Forward, Backward, Neither); type Travel_Vector is record Power : Percentage; Direction : Travel_Directions; Emergency_Braking : Boolean := False; end record with Size => 32, Atomic; -- The size is bigger than absolutely necessary but we fit the components -- to bytes for the sake of efficiency. The main concern is that the size -- remain such that objects of the record type can be atomically accessed -- because we are just using shared variables rather than protecting them -- with a protected object. for Travel_Vector use record Power at 0 range 0 .. 7; Direction at 0 range 8 .. 15; Emergency_Braking at 0 range 16 .. 23; end record; function Requested_Vector return Travel_Vector with Inline, Volatile_Function; function Requested_Steering_Angle return Integer with Inline, Volatile_Function; -- The units are angles, positive or negative, relative to the major axis of -- the vehicle, which is angle zero. private task Pump with Storage_Size => 1 * 1024, Priority => System_Configuration.Remote_Priority; end Motor;
reznikmm/matreshka
Ada
9,321
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.DG.Canvases; with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.DD_Attributes; with AMF.Visitors.DG_Iterators; with AMF.Visitors.DG_Visitors; package body AMF.Internals.DG_Linear_Gradients is ------------ -- Get_X1 -- ------------ overriding function Get_X1 (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.Real is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_X1 (Self.Element); end Get_X1; ------------ -- Set_X1 -- ------------ overriding procedure Set_X1 (Self : not null access DG_Linear_Gradient_Proxy; To : AMF.Real) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_X1 (Self.Element, To); end Set_X1; ------------ -- Get_X2 -- ------------ overriding function Get_X2 (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.Real is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_X2 (Self.Element); end Get_X2; ------------ -- Set_X2 -- ------------ overriding procedure Set_X2 (Self : not null access DG_Linear_Gradient_Proxy; To : AMF.Real) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_X2 (Self.Element, To); end Set_X2; ------------ -- Get_Y1 -- ------------ overriding function Get_Y1 (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.Real is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Y1 (Self.Element); end Get_Y1; ------------ -- Set_Y1 -- ------------ overriding procedure Set_Y1 (Self : not null access DG_Linear_Gradient_Proxy; To : AMF.Real) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Y1 (Self.Element, To); end Set_Y1; ------------ -- Get_Y2 -- ------------ overriding function Get_Y2 (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.Real is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Y2 (Self.Element); end Get_Y2; ------------ -- Set_Y2 -- ------------ overriding procedure Set_Y2 (Self : not null access DG_Linear_Gradient_Proxy; To : AMF.Real) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Y2 (Self.Element, To); end Set_Y2; -------------- -- Get_Stop -- -------------- overriding function Get_Stop (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.DG.Set_Of_DG_Gradient_Stop is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Stop (Self.Element); end Get_Stop; ---------------- -- Get_Canvas -- ---------------- overriding function Get_Canvas (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.DG.Canvases.DG_Canvas_Access is begin return AMF.DG.Canvases.DG_Canvas_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.DD_Attributes.Internal_Get_Canvas (Self.Element))); end Get_Canvas; ---------------- -- Set_Canvas -- ---------------- overriding procedure Set_Canvas (Self : not null access DG_Linear_Gradient_Proxy; To : AMF.DG.Canvases.DG_Canvas_Access) is begin AMF.Internals.Tables.DD_Attributes.Internal_Set_Canvas (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Canvas; ------------------- -- Get_Transform -- ------------------- overriding function Get_Transform (Self : not null access constant DG_Linear_Gradient_Proxy) return AMF.DG.Sequence_Of_DG_Transform is begin return AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform (Self.Element); end Get_Transform; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant DG_Linear_Gradient_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Enter_Linear_Gradient (AMF.DG.Linear_Gradients.DG_Linear_Gradient_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant DG_Linear_Gradient_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then AMF.Visitors.DG_Visitors.DG_Visitor'Class (Visitor).Leave_Linear_Gradient (AMF.DG.Linear_Gradients.DG_Linear_Gradient_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant DG_Linear_Gradient_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.DG_Iterators.DG_Iterator'Class then AMF.Visitors.DG_Iterators.DG_Iterator'Class (Iterator).Visit_Linear_Gradient (Visitor, AMF.DG.Linear_Gradients.DG_Linear_Gradient_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.DG_Linear_Gradients;
rveenker/sdlada
Ada
2,456
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.Windows.Makers -- -- Constructor subprograms which don't dispatch for Window types. -------------------------------------------------------------------------------------------------------------------- package SDL.Video.Windows.Makers is -- Create a window with the specified title, position, dimensions and -- flags. Put the result in Win. -- -- Raise a SDL.Video.Windows.Window_Error if window creation failed. procedure Create (Win : in out Window; Title : in Ada.Strings.UTF_Encoding.UTF_8_String; Position : in SDL.Natural_Coordinates; Size : in SDL.Positive_Sizes; Flags : in Window_Flags := OpenGL); -- A small wrapper around the above procedure. procedure Create (Win : in out Window; Title : in Ada.Strings.UTF_Encoding.UTF_8_String; X : in SDL.Natural_Coordinate; Y : in SDL.Natural_Coordinate; Width : in SDL.Positive_Dimension; Height : in SDL.Positive_Dimension; Flags : in Window_Flags := OpenGL) with Inline => True; -- Create a window from an existing window created in some other way. procedure Create (Win : in out Window; Native : in Native_Window) with Inline => True; end SDL.Video.Windows.Makers;
stcarrez/ada-util
Ada
6,589
adb
----------------------------------------------------------------------- -- util-properties-bundles -- Test for property bundles -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2021, 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.Test_Caller; with Util.Properties.Basic; with Util.Measures; package body Util.Properties.Bundles.Tests is use Util.Tests; use Util.Properties.Basic; -- Test the bundle procedure Test_Bundle (T : in out Test) is Props : aliased Properties.Manager; Bundle : Properties.Bundles.Manager; V : Integer := 23; begin -- Create a first property (while the bundle is empty) -- Integer_Property.Set (Props.all, "test-integer", 123); -- Assert (Bundle.Exists ("test-integer"), "Invalid properties"); -- -- V := Integer_Property.Get (Bundle, "test-integer"); -- Assert (V = 123, "Property was not inserted"); -- Add a property set to the bundle Bundle.Add_Bundle (Props'Unchecked_Access); Integer_Property.Set (Props, "test-integer-second", 24); V := Integer_Property.Get (Props, "test-integer-second"); T.Assert (V = 24, "Property was not inserted"); V := Integer_Property.Get (Bundle, "test-integer-second"); T.Assert (V = 24, "Property was not inserted"); -- Bundle.Remove ("test-integer-second"); -- Assert (Props.all.Exists ("test-integer-second") = False, -- "The 'test-integer-second' property was not removed"); -- Assert (Bundle.Exists ("test-integer-second") = False, -- "Property not removed from bundle"); end Test_Bundle; procedure Test_Bundle_Loader (T : in out Test) is Factory : Loader; Bundle : Util.Properties.Bundles.Manager; begin Initialize (Factory, Util.Tests.Get_Path ("regtests/bundles")); Load_Bundle (Factory, "bundle", "fr", Bundle); Assert_Equals (T, "Message France", String '(Bundle.Get ("message")), "Load fr bundle failed"); Assert_Equals (T, "Default", String '(Bundle.Get ("message_default")), "Load fr bundle failed"); Load_Bundle (Factory, "bundle", "en_GB", Bundle); Assert_Equals (T, "GB message", String '(Bundle.Get ("message")), "Load en_GB bundle failed"); Assert_Equals (T, "Default", String '(Bundle.Get ("message_default")), "Load en_GB bundle failed"); end Test_Bundle_Loader; -- Test overloading some bundle definition by having incomplete files. procedure Test_Bundle_Overload (T : in out Test) is Factory : Loader; Bundle : Util.Properties.Bundles.Manager; P1 : constant String := Util.Tests.Get_Path ("regtests/bundles"); P2 : constant String := Util.Tests.Get_Path ("bundles"); begin Initialize (Factory, P1 & ";" & P2); Load_Bundle (Factory, "dates", "fr", Bundle); -- Overloaded by regtests/bundles/dates.properties Assert_Equals (T, "New", String '(Bundle.Get ("util.test_variable")), "Load fr bundle failed (not defined)"); Assert_Equals (T, "Jan", String '(Bundle.Get ("util.month1.short")), "Load fr bundle failed (should not be overloaded)"); -- Not overloaded, value comes from bundles/dates_fr.properties Assert_Equals (T, "Mar", String '(Bundle.Get ("util.month3.short")), "Load fr bundle failed"); Load_Bundle (Factory, "dates", "en_GB", Bundle); Assert_Equals (T, "Jan_Overloaded", String '(Bundle.Get ("util.month1.short")), "Load en_GB bundle failed (should be overloaded)"); -- Not overloaded, value comes from bundles/dates_fr.properties Assert_Equals (T, "Mar", String '(Bundle.Get ("util.month3.short")), "Load en_GB bundle failed"); end Test_Bundle_Overload; -- ------------------------------ -- Test bundle resolution perf. -- ------------------------------ procedure Test_Bundle_Perf (T : in out Test) is Factory : Loader; Bundle : Util.Properties.Bundles.Manager; P1 : constant String := Util.Tests.Get_Path ("regtests/bundles"); P2 : constant String := Util.Tests.Get_Path ("bundles"); begin Initialize (Factory, P1 & ";" & P2); declare S1 : Util.Measures.Stamp; begin Load_Bundle (Factory, "dates", "fr", Bundle); Util.Measures.Report (S1, "Load_Bundle (first time)"); end; declare S1 : Util.Measures.Stamp; begin Load_Bundle (Factory, "dates", "fr", Bundle); Util.Measures.Report (S1, "Load_Bundle (second time)"); end; declare S1 : Util.Measures.Stamp; begin for I in 1 .. 1000 loop Load_Bundle (Factory, "dates", "fr", Bundle); end loop; Util.Measures.Report (S1, "Load_Bundle", 1000); end; -- Not overloaded, value comes from bundles/dates_fr.properties Assert_Equals (T, "Mar", String '(Bundle.Get ("util.month3.short")), "Load fr bundle failed"); end Test_Bundle_Perf; package Caller is new Util.Test_Caller (Test, "Properties.Bundles"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Properties.Bundles", Test_Bundle'Access); Caller.Add_Test (Suite, "Test Util.Properties.Bundles.Load_Bundle", Test_Bundle_Loader'Access); Caller.Add_Test (Suite, "Test Util.Properties.Bundles.Load_Bundle (overloading)", Test_Bundle_Overload'Access); Caller.Add_Test (Suite, "Test Util.Properties.Bundles.Load_Bundle (perf)", Test_Bundle_Perf'Access); end Add_Tests; end Util.Properties.Bundles.Tests;