repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
LionelDraghi/smk
Ada
2,394
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.Settings; package body Smk.Assertions is -- -------------------------------------------------------------------------- function Image (A : Condition; Prefix : String := "") return String is begin if Settings.Long_Listing_Format then return (Prefix & "[" & Trigger_Image (A.Trigger) & "] "); else return (Prefix); end if; end Image; -- -------------------------------------------------------------------------- function Count (Cond_List : Condition_Lists.List; Count_Sources : Boolean := False; Count_Targets : Boolean := False; With_System_Files : Boolean := False) return File_Count is C : File_Count := 0; begin for A of Cond_List loop if With_System_Files or else not Is_System (A.File) then if (Count_Sources and then Is_Source (A.File)) or else (Count_Targets and then Is_Target (A.File)) then C := C + 1; end if; end if; end loop; return C; end Count; -- -------------------------------------------------------------------------- function Count_Image (Count : File_Count) return String is Raw : constant String := File_Count'Image (Count); begin return Raw (2 .. Raw'Last); end Count_Image; end Smk.Assertions;
reznikmm/gela
Ada
14,557
adb
with Anagram.Grammars.LR_Parsers; with Gela.Element_Visiters; with Gela.Elements.Associations; with Gela.Elements.Composite_Constraints; with Gela.Elements.Composite_Subtype_Indications; with Gela.Elements.Defining_Expanded_Unit_Names; with Gela.Elements.Expression_Or_Boxes; with Gela.Elements.Identifiers; with Gela.Elements.Prefixes; with Gela.Elements.Scalar_Subtype_Indications; with Gela.Elements.Selector_Names; with Gela.Elements.Subtype_Marks; with Gela.LARL_Parsers.Data; with Gela.LARL_Parsers.On_Reduce; with Gela.LARL_Parsers_Nodes; package body Gela.LARL_Parsers is use Gela.Lexical_Types; Map : constant array (Gela.Lexical_Types.Token_Kind) of Anagram.Grammars.Terminal_Count := (Error => 0, End_Of_Input => 0, Abort_Token => 1, Abs_Token => 2, Abstract_Token => 3, Accept_Token => 4, Access_Token => 5, Aliased_Token => 6, All_Token => 7, Ampersand_Token => 8, And_Token => 9, Apostrophe_Token => 10, Array_Token => 11, Arrow_Token => 12, Assignment_Token => 13, At_Token => 14, Begin_Token => 15, Body_Token => 16, Box_Token => 17, Case_Token => 18, Character_Literal_Token => 19, Colon_Token => 20, Comma_Token => 21, Comment_Token => 22, Constant_Token => 23, Declare_Token => 24, Delay_Token => 25, Delta_Token => 26, Digits_Token => 27, Do_Token => 28, Dot_Token => 29, Double_Dot_Token => 30, Double_Star_Token => 31, Else_Token => 32, Elsif_Token => 33, End_Token => 34, Entry_Token => 35, Equal_Token => 36, Exception_Token => 37, Exit_Token => 38, For_Token => 39, Function_Token => 40, Generic_Token => 41, Goto_Token => 42, Greater_Or_Equal_Token => 43, Greater_Token => 44, Hyphen_Token => 45, Identifier_Token => 46, If_Token => 47, In_Token => 48, Inequality_Token => 49, Interface_Token => 50, Is_Token => 51, Left_Label_Token => 52, Left_Parenthesis_Token => 53, Less_Or_Equal_Token => 54, Less_Token => 55, Limited_Token => 56, Loop_Token => 57, Mod_Token => 58, New_Token => 59, Not_Token => 60, Null_Token => 61, Numeric_Literal_Token => 62, Of_Token => 63, Or_Token => 64, Others_Token => 65, Out_Token => 66, Overriding_Token => 67, Package_Token => 68, Plus_Token => 69, Pragma_Token => 70, Private_Token => 71, Procedure_Token => 72, Protected_Token => 73, Raise_Token => 74, Range_Token => 75, Record_Token => 76, Rem_Token => 77, Renames_Token => 78, Requeue_Token => 79, Return_Token => 80, Reverse_Token => 81, Right_Label_Token => 82, Right_Parenthesis_Token => 83, Select_Token => 84, Semicolon_Token => 85, Separate_Token => 86, Slash_Token => 87, Some_Token => 88, Star_Token => 89, String_Literal_Token => 90, Subtype_Token => 91, Synchronized_Token => 92, Tagged_Token => 93, Task_Token => 94, Terminate_Token => 95, Then_Token => 96, Type_Token => 97, Until_Token => 98, Use_Token => 99, Vertical_Line_Token => 100, When_Token => 101, While_Token => 102, With_Token => 103, Xor_Token => 104); type Input_Wrapper is record Last_Token : Gela.Lexical_Types.Token_Index; Input : Gela.Parsers.Parser_Input_Access; end record; procedure Next_Token (Self : access Input_Wrapper; Token : out Anagram.Grammars.Terminal_Count; Value : out Gela.LARL_Parsers_Nodes.Node); ---------------- -- Infix_Call -- ---------------- function Infix_Call (Self : access Parser_Context; Prefix : Gela.Lexical_Types.Token_Count; Left : Gela.Elements.Expressions.Expression_Access; Right : Gela.Elements.Expressions.Expression_Access := null) return Gela.Elements.Function_Calls.Function_Call_Access is use type Gela.Elements.Expressions.Expression_Access; L : constant Gela.Elements.Expression_Or_Boxes. Expression_Or_Box_Access := Gela.Elements.Expression_Or_Boxes.Expression_Or_Box_Access (Left); R : constant Gela.Elements.Expression_Or_Boxes. Expression_Or_Box_Access := Gela.Elements.Expression_Or_Boxes.Expression_Or_Box_Access (Right); P : Gela.Elements.Prefixes.Prefix_Access; Arg : Gela.Elements.Associations.Association_Access := Self.Factory.Association (Array_Component_Choices => Self.Factory.Discrete_Choice_Sequence, Arrow_Token => 0, Component_Expression => L); Args : constant Gela.Elements.Associations.Association_Sequence_Access := Self.Factory.Association_Sequence; begin Args.Append (Arg); if Right /= null then Arg := Self.Factory.Association (Array_Component_Choices => Self.Factory.Discrete_Choice_Sequence, Arrow_Token => 0, Component_Expression => R); Args.Append (Arg); end if; P := Gela.Elements.Prefixes.Prefix_Access (Self.Factory.Operator_Symbol (Prefix)); return Self.Factory.Function_Call (Prefix => P, Function_Call_Parameters => Self.Factory.Association_List (Left_Token => 0, Record_Component_Associations => Args, Right_Token => 0)); end Infix_Call; ---------------- -- Next_Token -- ---------------- procedure Next_Token (Self : access Input_Wrapper; Token : out Anagram.Grammars.Terminal_Count; Value : out Gela.LARL_Parsers_Nodes.Node) is use Gela.LARL_Parsers_Nodes; Next : Gela.Lexical_Types.Token_Kind; begin Self.Input.Next_Token (Token => Next, Index => Self.Last_Token); Token := Map (Next); Value := +Self.Last_Token; end Next_Token; ----------- -- Parse -- ----------- overriding procedure Parse (Self : in out Parser; Input : not null access Gela.Parsers.Parser_Input'Class; Factory : not null Gela.Element_Factories.Element_Factory_Access; Root : out Gela.Elements.Compilations.Compilation_Access; Last_Token : out Gela.Lexical_Types.Token_Index) is pragma Unreferenced (Self); procedure Do_It is new Anagram.Grammars.LR_Parsers.Parse (Node => Gela.LARL_Parsers_Nodes.Node, Node_Array => Gela.LARL_Parsers_Nodes.Node_Array, Lexer => Input_Wrapper, Parser => Parser_Context, Next_Token => Next_Token, Next_Action => Gela.LARL_Parsers.Data.Next_Action, Go_To => Gela.LARL_Parsers.Data.Go_To, On_Reduce => Gela.LARL_Parsers.On_Reduce); use Gela.LARL_Parsers_Nodes; Result : Gela.LARL_Parsers_Nodes.Node; Success : Boolean; Wrapper : aliased Input_Wrapper := (1, Input); Context : aliased Parser_Context := (Factory => Factory); begin Do_It (Context'Access, Wrapper'Access, Result, Success); if Success then Root := -Result; end if; Last_Token := Wrapper.Last_Token; end Parse; ----------------------------------- -- To_Defining_Program_Unit_Name -- ----------------------------------- function To_Defining_Program_Unit_Name (Self : access Parser_Context; Value : Gela.Elements.Selected_Identifiers.Selected_Identifier_Access) return Gela.Elements.Defining_Program_Unit_Names. Defining_Program_Unit_Name_Access is Selector : constant Gela.Elements.Selector_Names.Selector_Name_Access := Value.Selector; Identifier : constant Gela.Elements.Identifiers.Identifier_Access := Gela.Elements.Identifiers.Identifier_Access (Selector); Result : Gela.Elements.Defining_Expanded_Unit_Names. Defining_Expanded_Unit_Name_Access; begin Result := Self.Factory.Defining_Expanded_Unit_Name (Defining_Prefix => Value.Prefix, Dot_Token => Value.Dot_Token, Defining_Selector => Self.Factory.Defining_Identifier (Identifier_Token => Identifier.Identifier_Token)); return Gela.Elements.Defining_Program_Unit_Names. Defining_Program_Unit_Name_Access (Result); end To_Defining_Program_Unit_Name; -------------------------------- -- To_Aggregate_Or_Expression -- -------------------------------- function To_Aggregate_Or_Expression (Self : access Parser_Context; Value : Gela.Elements.Association_Lists.Association_List_Access) return Gela.Elements.Expressions.Expression_Access is First : Gela.Elements.Associations.Association_Access; Result : access Gela.Elements.Expressions.Expression'Class; begin if Value.Record_Component_Associations.Length = 1 then First := Value.Record_Component_Associations.all.First.Element; if First.Array_Component_Choices.Length = 0 then Result := Self.Factory.Parenthesized_Expression (Left_Token => Value.Last_Token, Expression_Parenthesized => Gela.Elements.Expressions.Expression_Access (First.Component_Expression), Right_Token => Value.Right_Token); else Result := Self.Factory.Record_Aggregate (Value); end if; else Result := Self.Factory.Record_Aggregate (Value); end if; return Result; end To_Aggregate_Or_Expression; --------------------------- -- To_Subtype_Indication -- --------------------------- function To_Subtype_Indication (Self : access Parser_Context; Not_Token : Gela.Lexical_Types.Token_Count; Null_Token : Gela.Lexical_Types.Token_Count; Mark : Gela.Elements.Element_Access; Constraint : Gela.Elements.Scalar_Constraints.Scalar_Constraint_Access) return Gela.Elements.Subtype_Indications.Subtype_Indication_Access is package Visiters is type Visiter is new Gela.Element_Visiters.Visiter with record Factory : not null Gela.Element_Factories.Element_Factory_Access; Subtype_Mark : Gela.Elements.Subtype_Marks.Subtype_Mark_Access; Subtype_Constraint : Gela.Elements.Composite_Constraints. Composite_Constraint_Access; end record; overriding procedure Function_Call (Self : in out Visiter; Node : not null Gela.Elements.Function_Calls.Function_Call_Access); end Visiters; package body Visiters is overriding procedure Function_Call (Self : in out Visiter; Node : not null Gela.Elements.Function_Calls.Function_Call_Access) is Prefix : constant Gela.Elements.Prefixes.Prefix_Access := Node.Prefix; Args : constant Gela.Elements.Association_Lists. Association_List_Access := Node.Function_Call_Parameters; Ass : constant Gela.Elements.Associations. Association_Sequence_Access := Args.Record_Component_Associations; CC : constant Gela.Elements.Composite_Constraints. Composite_Constraint_Access := Self.Factory.Composite_Constraint (Left_Token => Args.Last_Token, Associations => Ass, Right_Token => Args.Right_Token); begin Self.Subtype_Mark := Gela.Elements.Subtype_Marks.Subtype_Mark_Access (Prefix); Self.Subtype_Constraint := CC; end Function_Call; end Visiters; V : Visiters.Visiter := (Self.Factory, null, null); begin if Constraint.Assigned then declare Result : constant Gela.Elements.Scalar_Subtype_Indications .Scalar_Subtype_Indication_Access := Self.Factory.Scalar_Subtype_Indication (Gela.Elements.Subtype_Marks.Subtype_Mark_Access (Mark), Constraint); begin return Gela.Elements.Subtype_Indications.Subtype_Indication_Access (Result); end; else Mark.Visit (V); if not V.Subtype_Mark.Assigned then V.Subtype_Mark := Gela.Elements.Subtype_Marks.Subtype_Mark_Access (Mark); end if; declare Result : constant Gela.Elements.Composite_Subtype_Indications .Composite_Subtype_Indication_Access := Self.Factory.Composite_Subtype_Indication (Not_Token => Not_Token, Null_Token => Null_Token, Subtype_Mark => V.Subtype_Mark, Composite_Constraint => V.Subtype_Constraint); begin return Gela.Elements.Subtype_Indications.Subtype_Indication_Access (Result); end; end if; end To_Subtype_Indication; end Gela.LARL_Parsers;
Fabien-Chouteau/Ada_Drivers_Library
Ada
4,600
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package HAL.Real_Time_Clock is type RTC_Hour is mod 24; type RTC_Minute is mod 60; type RTC_Second is mod 60; type RTC_Time is record Hour : RTC_Hour; Min : RTC_Minute; Sec : RTC_Second; end record; type RTC_Month is (January, February, March, April, May, June, July, August, September, October, November, December); type RTC_Day_Of_Week is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); type RTC_Day is range 1 .. 31; type RTC_Year is range 00 .. 99; type RTC_Date is record Day_Of_Week : RTC_Day_Of_Week; Day : RTC_Day; Month : RTC_Month; Year : RTC_Year; end record; for RTC_Day_Of_Week use (Monday => 1, Tuesday => 2, Wednesday => 3, Thursday => 4, Friday => 5, Saturday => 6, Sunday => 7); for RTC_Month use (January => 1, February => 2, March => 3, April => 4, May => 5, June => 6, July => 7, August => 8, September => 9, October => 10, November => 11, December => 12); type RTC_Device is limited interface; type Any_RTC_Device is access all RTC_Device'Class; procedure Set (This : in out RTC_Device; Time : RTC_Time; Date : RTC_Date) is abstract; procedure Get (This : in out RTC_Device; Time : out RTC_Time; Date : out RTC_Date) is abstract; -- This procedure ensures coherent time and date values function Get_Time (This : RTC_Device) return HAL.Real_Time_Clock.RTC_Time is abstract; function Get_Date (This : RTC_Device) return HAL.Real_Time_Clock.RTC_Date is abstract; end HAL.Real_Time_Clock;
aogrcs/etherscope
Ada
1,187
ads
----------------------------------------------------------------------- -- etherscope-receiver -- Ethernet Packet Receiver -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with System; with Net.Interfaces.STM32; package EtherScope.Receiver is -- The Ethernet interface driver. Ifnet : Net.Interfaces.STM32.STM32_Ifnet; -- The task that waits for packets. task Controller with Storage_Size => (16 * 1024), Priority => System.Default_Priority; end EtherScope.Receiver;
stcarrez/ada-asf
Ada
15,514
ads
----------------------------------------------------------------------- -- asf-contexts.faces -- Faces Contexts -- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Requests; with ASF.Responses; with ASF.Sessions; limited with ASF.Converters; with ASF.Components.Root; limited with ASF.Applications.Main; with ASF.Applications.Messages; with ASF.Applications.Messages.Vectors; with ASF.Contexts.Writer; with ASF.Contexts.Exceptions; limited with ASF.Contexts.Flash; with ASF.Events.Exceptions; with ASF.Events.Phases; with EL.Objects; with EL.Contexts; with Util.Locales; with Util.Beans.Basic; with Ada.Exceptions; with Ada.Strings.Unbounded; private with Ada.Finalization; private with Ada.Strings.Unbounded.Hash; private with Ada.Containers.Hashed_Maps; -- The <b>Faces_Context</b> is an object passed to the component tree and -- bean actions to provide the full context in which the view is rendered -- or evaluated. The faces context gives access to the bean variables, -- the request and its parameters, the response writer to write on the -- output stream. -- -- The <b>Faces_Context</b> is never shared: it is specific to each request. package ASF.Contexts.Faces is use Ada.Strings.Unbounded; type Application_Access is access all ASF.Applications.Main.Application'Class; type Flash_Context_Access is access all ASF.Contexts.Flash.Flash_Context'Class; type Faces_Context is tagged limited private; type Faces_Context_Access is access all Faces_Context'Class; -- Get the response writer to write the response stream. function Get_Response_Writer (Context : Faces_Context) return ASF.Contexts.Writer.Response_Writer_Access; -- Set the response writer to write to the response stream. procedure Set_Response_Writer (Context : in out Faces_Context; Writer : in ASF.Contexts.Writer.Response_Writer_Access); -- Get the EL context for evaluating expressions. function Get_ELContext (Context : in Faces_Context) return EL.Contexts.ELContext_Access; -- Set the EL context for evaluating expressions. procedure Set_ELContext (Context : in out Faces_Context; ELContext : in EL.Contexts.ELContext_Access); -- Set the attribute having given name with the value. procedure Set_Attribute (Context : in out Faces_Context; Name : in String; Value : in EL.Objects.Object); -- Set the attribute having given name with the value. procedure Set_Attribute (Context : in out Faces_Context; Name : in Unbounded_String; Value : in EL.Objects.Object); -- Get the attribute with the given name. function Get_Attribute (Context : in Faces_Context; Name : in String) return EL.Objects.Object; -- Get the attribute with the given name. function Get_Attribute (Context : in Faces_Context; Name : in Unbounded_String) return EL.Objects.Object; -- Get the bean attribute with the given name. -- Returns null if the attribute does not exist or is not a bean. function Get_Bean (Context : in Faces_Context; Name : in String) return Util.Beans.Basic.Readonly_Bean_Access; -- Get a request parameter function Get_Parameter (Context : Faces_Context; Name : String) return String; -- Get the session associated with the current faces context. function Get_Session (Context : in Faces_Context; Create : in Boolean := False) return ASF.Sessions.Session; -- Get the request function Get_Request (Context : Faces_Context) return ASF.Requests.Request_Access; -- Set the request procedure Set_Request (Context : in out Faces_Context; Request : in ASF.Requests.Request_Access); -- Get the response function Get_Response (Context : Faces_Context) return ASF.Responses.Response_Access; -- Set the response procedure Set_Response (Context : in out Faces_Context; Response : in ASF.Responses.Response_Access); -- Signal the JavaServer faces implementation that, as soon as the -- current phase of the request processing lifecycle has been completed, -- control should be passed to the <b>Render Response</b> phase, -- bypassing any phases that have not been executed yet. procedure Render_Response (Context : in out Faces_Context); -- Check whether the <b>Render_Response</b> phase must be processed immediately. function Get_Render_Response (Context : in Faces_Context) return Boolean; -- Signal the JavaServer Faces implementation that the HTTP response -- for this request has already been generated (such as an HTTP redirect), -- and that the request processing lifecycle should be terminated as soon -- as the current phase is completed. procedure Response_Completed (Context : in out Faces_Context); -- Check whether the response has been completed. function Get_Response_Completed (Context : in Faces_Context) return Boolean; -- Get the flash context allowing to add flash attributes. function Get_Flash (Context : in Faces_Context) return Flash_Context_Access; -- Set the flash context. procedure Set_Flash (Context : in out Faces_Context; Flash : in Flash_Context_Access); -- Append the message to the list of messages associated with the specified -- client identifier. If <b>Client_Id</b> is empty, the message is global -- (or not associated with a component) procedure Add_Message (Context : in out Faces_Context; Client_Id : in String; Message : in ASF.Applications.Messages.Message); -- Append the message to the list of messages associated with the specified -- client identifier. If <b>Client_Id</b> is empty, the message is global -- (or not associated with a component) procedure Add_Message (Context : in out Faces_Context; Client_Id : in String; Message : in String; Severity : in Applications.Messages.Severity := Applications.Messages.ERROR); -- Append the messages defined in <b>Messages</b> to the current list of messages -- in the faces context. procedure Add_Messages (Context : in out Faces_Context; Client_Id : in String; Messages : in ASF.Applications.Messages.Vectors.Vector); -- Get an iterator for the messages associated with the specified client -- identifier. If the <b>Client_Id</b> ie empty, an iterator for the -- global messages is returned. function Get_Messages (Context : in Faces_Context; Client_Id : in String) return ASF.Applications.Messages.Vectors.Cursor; -- Returns the maximum severity level recorded for any message that has been queued. -- Returns NONE if no message has been queued. function Get_Maximum_Severity (Context : in Faces_Context) return ASF.Applications.Messages.Severity; -- Get a converter from a name. -- Returns the converter object or null if there is no converter. function Get_Converter (Context : in Faces_Context; Name : in EL.Objects.Object) return access ASF.Converters.Converter'Class; -- Get the application associated with this faces context. function Get_Application (Context : in Faces_Context) return Application_Access; -- Get the current lifecycle phase. function Get_Current_Phase (Context : in Faces_Context) return ASF.Events.Phases.Phase_Type; -- Set the current lifecycle phase. This operation is called by the lifecycle manager -- each time the lifecycle phase changes. procedure Set_Current_Phase (Context : in out Faces_Context; Phase : in ASF.Events.Phases.Phase_Type); -- Get the locale defined by the view root component. -- Returns the NULL_LOCALE if there is no view root component. function Get_Locale (Context : in Faces_Context) return Util.Locales.Locale; -- Set the locale that must be used when rendering the view components. procedure Set_Locale (Context : in out Faces_Context; Locale : in Util.Locales.Locale); -- Get the component view root. function Get_View_Root (Context : in Faces_Context) return ASF.Components.Root.UIViewRoot; -- Get the component view root. procedure Set_View_Root (Context : in out Faces_Context; View : in ASF.Components.Root.UIViewRoot); -- Get the view name associated with the current faces request. -- The view name is obtained from the request and the route mapping definition. -- If a pretty URL configuration was set through the `url-mapping` definition, the view -- name correspond to the `view-id` declaration. Otherwise, the view name corresponds -- to the servlet's path. function Get_View_Name (Context : in Faces_Context) return String; -- Create an identifier for a component. procedure Create_Unique_Id (Context : in out Faces_Context; Id : out Natural); -- Verify the CSRF token validity for the component identified by `Id`. -- Returns True if the token is valid and false if it has expired or is invalid. function Verify_Token (Context : in Faces_Context; Id : in String; Token : in String) return Boolean; -- Create a CSRF token for the component identified by `Id`. -- The token is associated with the web session and signed by the application. function Create_Token (Context : in Faces_Context; Id : in String; Expire : in Duration) return String; -- Set the exception handler that will receive unexpected exceptions and process them. procedure Set_Exception_Handler (Context : in out Faces_Context; Handler : in Exceptions.Exception_Handler_Access); -- Get the exception handler. function Get_Exception_Handler (Context : in Faces_Context) return Exceptions.Exception_Handler_Access; -- Queue an exception event to the exception handler associated with the context. -- The exception event will be processed at the end of the current ASF phase. procedure Queue_Exception (Context : in out Faces_Context; Ex : in Ada.Exceptions.Exception_Occurrence); -- Iterate over the exceptions that have been queued and execute the <b>Process</b> -- procedure. When the procedure returns True in <b>Remove</b, the exception event -- is removed from the queue. The procedure can update the faces context to add some -- error message or redirect to an error page. -- -- The application exception handler uses this procedure to process the exceptions. -- The exception handler is called after each ASF phase. procedure Iterate_Exception (Context : in out Faces_Context'Class; Process : not null access procedure (Event : in Events.Exceptions.Exception_Event'Class; Remove : out Boolean; Context : in out Faces_Context'Class)); -- Returns True if the current request is an AJAX request. function Is_Ajax_Request (Context : in Faces_Context'Class) return Boolean; -- Set the Ajax request status. procedure Set_Ajax_Request (Context : in out Faces_Context'Class; Status : in Boolean); -- Get the current faces context. The faces context is saved -- in a per-thread/task attribute. function Current return Faces_Context_Access; -- Set the current faces context in the per-thread/task attribute. procedure Set_Current (Context : in Faces_Context_Access; Application : in Application_Access); -- Restore the previous faces context. procedure Restore (Context : in Faces_Context_Access); private use ASF.Applications.Messages; type Exception_Queue_Access is access ASF.Contexts.Exceptions.Exception_Queue; -- Map of messages associated with a component package Message_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Vectors.Vector, Hash => Hash, Equivalent_Keys => "=", "=" => Vectors."="); type Faces_Context is new Ada.Finalization.Limited_Controlled with record -- The response writer. Writer : ASF.Contexts.Writer.Response_Writer_Access; -- The expression context; Context : EL.Contexts.ELContext_Access; -- The request Request : ASF.Requests.Request_Access; -- The response Response : ASF.Responses.Response_Access; -- The application Application : Application_Access; -- The exception handler and exception queue. Except_Handler : Exceptions.Exception_Handler_Access; Except_Queue : Exception_Queue_Access; Render_Response : Boolean := False; Response_Completed : Boolean := False; -- True if the view is processed as part of an AJAX request. Ajax : Boolean := False; -- List of messages added indexed by the client identifier. Messages : Message_Maps.Map; -- The maximum severity for the messages that were collected. Max_Severity : Severity := NONE; Root : ASF.Components.Root.UIViewRoot; -- The flash context. Flash : Flash_Context_Access; -- The current lifecycle phase. Phase : ASF.Events.Phases.Phase_Type := ASF.Events.Phases.RESTORE_VIEW; -- The locale defined by the view root component. Unlike JSF, we store the locale -- in the faces context. This is easier for the implementation. Locale : Util.Locales.Locale := Util.Locales.NULL_LOCALE; end record; -- Release any storage held by this context. overriding procedure Finalize (Context : in out Faces_Context); end ASF.Contexts.Faces;
twdroeger/ada-awa
Ada
2,185
ads
----------------------------------------------------------------------- -- awa-blogs-tests -- Unit tests for blogs module -- Copyright (C) 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; with Ada.Strings.Unbounded; package AWA.Blogs.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with record Blog_Ident : Ada.Strings.Unbounded.Unbounded_String; Post_Ident : Ada.Strings.Unbounded.Unbounded_String; Post_Uri : Ada.Strings.Unbounded.Unbounded_String; end record; -- Get some access on the blog as anonymous users. procedure Verify_Anonymous (T : in out Test; Post : in String); -- Test access to the blog as anonymous user. procedure Test_Anonymous_Access (T : in out Test); -- Test creation of blog by simulating web requests. procedure Test_Create_Blog (T : in out Test); -- Test updating a post by simulating web requests. procedure Test_Update_Post (T : in out Test); -- Test updating the publication date by simulating web requests. procedure Test_Update_Publish_Date (T : in out Test); -- Test listing the blog posts. procedure Test_Admin_List_Posts (T : in out Test); -- Test listing the blog comments. procedure Test_Admin_List_Comments (T : in out Test); -- Test getting the JSON blog stats (for graphs). procedure Test_Admin_Blog_Stats (T : in out Test); end AWA.Blogs.Tests;
reznikmm/matreshka
Ada
3,849
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$ ------------------------------------------------------------------------------ package body Properties.Statements.Raise_Statement is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is pragma Unreferenced (Engine, Element, Name); Text : League.Strings.Universal_String; begin Text.Append ("_ec._raise();"); return Text; end Code; end Properties.Statements.Raise_Statement;
francesco-bongiovanni/ewok-kernel
Ada
4,046
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with soc.exti; use soc.exti; with soc.nvic; with soc.syscfg; with soc.gpio; with ewok.exported.gpios; use ewok.exported.gpios; with ewok.exti.handler; package body ewok.exti with spark_mode => off is procedure init is begin ewok.exti.handler.init; soc.exti.init; end init; procedure enable (ref : in ewok.exported.gpios.t_gpio_ref) is line : soc.exti.t_exti_line_index; begin line := soc.exti.t_exti_line_index'val (soc.gpio.t_gpio_pin_index'pos (ref.pin)); soc.exti.enable (line); case ref.pin is when 0 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_0); when 1 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_1); when 2 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_2); when 3 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_3); when 4 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_4); when 5 .. 9 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_5_9); when 10 .. 15 => soc.nvic.enable_irq (soc.nvic.EXTI_Line_10_15); end case; end enable; procedure disable (ref : in ewok.exported.gpios.t_gpio_ref) is line : soc.exti.t_exti_line_index; begin line := soc.exti.t_exti_line_index'val (soc.gpio.t_gpio_pin_index'pos (ref.pin)); soc.exti.disable (line); end disable; function is_used (ref : ewok.exported.gpios.t_gpio_ref) return boolean is line : constant soc.exti.t_exti_line_index := soc.exti.t_exti_line_index'val (soc.gpio.t_gpio_pin_index'pos (ref.pin)); begin return exti_line_registered (line) or soc.exti.is_enabled (line); end is_used; procedure register (conf : in ewok.exported.gpios.t_gpio_config_access; success : out boolean) is line : constant soc.exti.t_exti_line_index := soc.exti.t_exti_line_index'val (soc.gpio.t_gpio_pin_index'pos (conf.all.kref.pin)); begin -- Is EXTI setting required? if not conf.all.settings.set_exti then success := true; return; end if; -- Is EXTI line already registered? if exti_line_registered (line) then success := false; return; end if; -- If the line is already set, thus it's already used. -- We return in error. if soc.exti.is_enabled (line) then success := false; return; end if; -- Configuring the triggers case conf.all.exti_trigger is when GPIO_EXTI_TRIGGER_NONE => success := true; return; when GPIO_EXTI_TRIGGER_RISE => soc.exti.EXTI.RTSR.line(line) := TRIGGER_ENABLED; when GPIO_EXTI_TRIGGER_FALL => soc.exti.EXTI.FTSR.line(line) := TRIGGER_ENABLED; when GPIO_EXTI_TRIGGER_BOTH => soc.exti.EXTI.RTSR.line(line) := TRIGGER_ENABLED; soc.exti.EXTI.FTSR.line(line) := TRIGGER_ENABLED; end case; -- Configuring the SYSCFG register soc.syscfg.set_exti_port (conf.all.kref.pin, conf.all.kref.port); exti_line_registered (line) := true; success := true; end register; end ewok.exti;
sungyeon/drake
Ada
1,087
adb
with Ada.Streams.Naked_Stream_IO.Standard_Files; package body Ada.Streams.Stream_IO.Standard_Files is Standard_Input_Object : aliased File_Type; Standard_Output_Object : aliased File_Type; Standard_Error_Object : aliased File_Type; -- implementation function Standard_Input return not null access constant File_Type is begin return Standard_Input_Object'Access; end Standard_Input; function Standard_Output return not null access constant File_Type is begin return Standard_Output_Object'Access; end Standard_Output; function Standard_Error return not null access constant File_Type is begin return Standard_Error_Object'Access; end Standard_Error; begin Controlled.Reference (Standard_Input_Object).all := Naked_Stream_IO.Standard_Files.Standard_Input; Controlled.Reference (Standard_Output_Object).all := Naked_Stream_IO.Standard_Files.Standard_Output; Controlled.Reference (Standard_Error_Object).all := Naked_Stream_IO.Standard_Files.Standard_Error; end Ada.Streams.Stream_IO.Standard_Files;
reznikmm/matreshka
Ada
7,021
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.Source_Cell_Range_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Source_Cell_Range_Element_Node is begin return Self : Table_Source_Cell_Range_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Source_Cell_Range_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_Table_Source_Cell_Range (ODF.DOM.Table_Source_Cell_Range_Elements.ODF_Table_Source_Cell_Range_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 Table_Source_Cell_Range_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Source_Cell_Range_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Source_Cell_Range_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_Table_Source_Cell_Range (ODF.DOM.Table_Source_Cell_Range_Elements.ODF_Table_Source_Cell_Range_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 Table_Source_Cell_Range_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_Table_Source_Cell_Range (Visitor, ODF.DOM.Table_Source_Cell_Range_Elements.ODF_Table_Source_Cell_Range_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.Table_URI, Matreshka.ODF_String_Constants.Source_Cell_Range_Element, Table_Source_Cell_Range_Element_Node'Tag); end Matreshka.ODF_Table.Source_Cell_Range_Elements;
io7m/coreland-serial_io
Ada
1,529
adb
with Ada.Streams.Stream_IO; with Serial_IO; with Test; procedure T_32_01 is package Stream_IO renames Ada.Streams.Stream_IO; use type Serial_IO.Unsigned_32_t; Output : Stream_IO.File_Type; Input : Stream_IO.File_Type; V : Serial_IO.Unsigned_32_t; begin Stream_IO.Create (Name => "t_32_01.dat", Mode => Stream_IO.Out_File, File => Output); Serial_IO.Unsigned_32_t'Output (Stream_IO.Stream (Output), 16#ffff_ffff#); Serial_IO.Unsigned_32_t'Output (Stream_IO.Stream (Output), 16#7fff_ffff#); Serial_IO.Unsigned_32_t'Output (Stream_IO.Stream (Output), 16#0000_ffff#); Serial_IO.Unsigned_32_t'Output (Stream_IO.Stream (Output), 16#0000_7fff#); Serial_IO.Unsigned_32_t'Output (Stream_IO.Stream (Output), 16#0000_0000#); pragma Warnings (Off); Stream_IO.Close (Output); pragma Warnings (On); Stream_IO.Open (Name => "t_32_01.dat", Mode => Stream_IO.In_File, File => Input); V := Serial_IO.Unsigned_32_t'Input (Stream_IO.Stream (Input)); Test.Assert (V = 16#ffff_ffff#); V := Serial_IO.Unsigned_32_t'Input (Stream_IO.Stream (Input)); Test.Assert (V = 16#7fff_ffff#); V := Serial_IO.Unsigned_32_t'Input (Stream_IO.Stream (Input)); Test.Assert (V = 16#0000_ffff#); V := Serial_IO.Unsigned_32_t'Input (Stream_IO.Stream (Input)); Test.Assert (V = 16#0000_7fff#); V := Serial_IO.Unsigned_32_t'Input (Stream_IO.Stream (Input)); Test.Assert (V = 16#0000_0000#); pragma Warnings (Off); Stream_IO.Close (Input); pragma Warnings (On); end T_32_01;
optikos/oasis
Ada
1,402
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Expressions; with Program.Lexical_Elements; package Program.Elements.Selected_Components is pragma Pure (Program.Elements.Selected_Components); type Selected_Component is limited interface and Program.Elements.Expressions.Expression; type Selected_Component_Access is access all Selected_Component'Class with Storage_Size => 0; not overriding function Prefix (Self : Selected_Component) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Selector (Self : Selected_Component) return not null Program.Elements.Expressions.Expression_Access is abstract; type Selected_Component_Text is limited interface; type Selected_Component_Text_Access is access all Selected_Component_Text'Class with Storage_Size => 0; not overriding function To_Selected_Component_Text (Self : aliased in out Selected_Component) return Selected_Component_Text_Access is abstract; not overriding function Dot_Token (Self : Selected_Component_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Selected_Components;
charlie5/cBound
Ada
1,394
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_is_query_arb_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_is_query_arb_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_is_query_arb_cookie_t.Item, Element_Array => xcb.xcb_glx_is_query_arb_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_is_query_arb_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_is_query_arb_cookie_t.Pointer, Element_Array => xcb.xcb_glx_is_query_arb_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_is_query_arb_cookie_t;
optikos/oasis
Ada
6,205
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Select_Paths; with Program.Element_Vectors; with Program.Elements.Select_Statements; with Program.Element_Visitors; package Program.Nodes.Select_Statements is pragma Preelaborate; type Select_Statement is new Program.Nodes.Node and Program.Elements.Select_Statements.Select_Statement and Program.Elements.Select_Statements.Select_Statement_Text with private; function Create (Select_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Paths : not null Program.Elements.Select_Paths .Select_Path_Vector_Access; Then_Token : Program.Lexical_Elements.Lexical_Element_Access; Abort_Token : Program.Lexical_Elements.Lexical_Element_Access; Then_Abort_Statements : Program.Element_Vectors.Element_Vector_Access; Else_Token : Program.Lexical_Elements.Lexical_Element_Access; Else_Statements : Program.Element_Vectors.Element_Vector_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Select_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Select_Statement; type Implicit_Select_Statement is new Program.Nodes.Node and Program.Elements.Select_Statements.Select_Statement with private; function Create (Paths : not null Program.Elements.Select_Paths .Select_Path_Vector_Access; Then_Abort_Statements : Program.Element_Vectors.Element_Vector_Access; Else_Statements : Program.Element_Vectors.Element_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Select_Statement with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Select_Statement is abstract new Program.Nodes.Node and Program.Elements.Select_Statements.Select_Statement with record Paths : not null Program.Elements.Select_Paths .Select_Path_Vector_Access; Then_Abort_Statements : Program.Element_Vectors.Element_Vector_Access; Else_Statements : Program.Element_Vectors.Element_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Select_Statement'Class); overriding procedure Visit (Self : not null access Base_Select_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Paths (Self : Base_Select_Statement) return not null Program.Elements.Select_Paths.Select_Path_Vector_Access; overriding function Then_Abort_Statements (Self : Base_Select_Statement) return Program.Element_Vectors.Element_Vector_Access; overriding function Else_Statements (Self : Base_Select_Statement) return Program.Element_Vectors.Element_Vector_Access; overriding function Is_Select_Statement_Element (Self : Base_Select_Statement) return Boolean; overriding function Is_Statement_Element (Self : Base_Select_Statement) return Boolean; type Select_Statement is new Base_Select_Statement and Program.Elements.Select_Statements.Select_Statement_Text with record Select_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Then_Token : Program.Lexical_Elements.Lexical_Element_Access; Abort_Token : Program.Lexical_Elements.Lexical_Element_Access; Else_Token : Program.Lexical_Elements.Lexical_Element_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Select_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Select_Statement_Text (Self : aliased in out Select_Statement) return Program.Elements.Select_Statements.Select_Statement_Text_Access; overriding function Select_Token (Self : Select_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Then_Token (Self : Select_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Abort_Token (Self : Select_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Else_Token (Self : Select_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function End_Token (Self : Select_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Select_Token_2 (Self : Select_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Select_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Select_Statement is new Base_Select_Statement with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Select_Statement_Text (Self : aliased in out Implicit_Select_Statement) return Program.Elements.Select_Statements.Select_Statement_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Select_Statement) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Select_Statement) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Select_Statement) return Boolean; end Program.Nodes.Select_Statements;
albinjal/Ada_Project
Ada
1,802
adb
with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with TJa.Sockets; use TJa.Sockets; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Server_Assets_Package; use Server_Assets_Package; with Klient_Assets_Package; use Klient_Assets_Package; procedure Server is --| Servern behöver en Listener_type för att ta emot inkommande anslutningar Lyssnare : Listener_Type; --| Socket_type används för att kunna kommunicera med en klient Socket1, Socket2 : Socket_Type; Emptyprotocoll1, Emptyprotocoll2: Protocoll_Type; begin --| Denna rutin kontrollerar att programmet startas med en parameter. --| Annars kastas ett fel. --| Argumentet skall vara portnummret, programmet kan t.ex. startas med: --| > server 3400 if Argument_Count /= 1 then Raise_Exception(Constraint_Error'Identity, "Usage: " & Command_Name & " port"); end if; --| Initierar lyssnaren på en port (klienter bara utanför "localhost").\ Connect_To_Klients(Socket1, Socket2, Lyssnare, Natural'Value(Argument(1))); -- Fill protocolls empty For x in 1..15 loop Emptyprotocoll1(x) := -1; Emptyprotocoll2(x) := -1; end loop; -- Start main loop Yatzyloop(Socket1, Socket2, Emptyprotocoll1, Emptyprotocoll2, 1); exception --| Lite felhantering when Constraint_Error => Put_Line("Du matade inte in en parameter innehållande portnummer"); when others => --| kanske end_error eller socket_error, det betyder att --| klienten stängt sin socket. Då skall den stängas även --| här. Put_Line("Nu dog klienten"); Close(Socket1); Close(Socket2); end Server;
sungyeon/drake
Ada
927
ads
pragma License (Unrestricted); -- implementation unit required by compiler with System.Packed_Arrays; package System.Compare_Array_Signed_8 is pragma Preelaborate; -- It can not be Pure, subprograms would become __attribute__((const)). type Integer_8 is range -(2 ** 7) .. 2 ** 7 - 1; for Integer_8'Size use 8; package Ordering is new Packed_Arrays.Ordering (Integer_8); -- required to compare arrays by compiler (s-carsi8.ads) function Compare_Array_S8_Unaligned ( Left : Address; Right : Address; Left_Len : Natural; Right_Len : Natural) return Integer renames Ordering.Compare; -- required to compare arrays by compiler (s-carsi8.ads) function Compare_Array_S8 ( Left : Address; Right : Address; Left_Len : Natural; Right_Len : Natural) return Integer renames Ordering.Compare; end System.Compare_Array_Signed_8;
AdaCore/training_material
Ada
927
adb
package body Basics is procedure Bump_Pair (P : in out Pair) is begin P := Pair'(X => P.X + 1, Y => P.Y + 1); end Bump_Pair; procedure Swap_Pair (P : in out Pair) is Base : Base_Pair := P; Tmp : Integer := P.X; begin Base.X := Base.Y; Base.Y := Tmp; P := Base; end Swap_Pair; procedure Bump_Triplet (T : in out Triplet) is begin T.A := T.A + 1; T.B := T.B + 1; T.C := T.C + 1; end Bump_Triplet; procedure Swap_Triplet (T : in out Triplet) is Tmp : Integer := T.A; begin T.A := T.B; T.B := T.C; T.C := Tmp; end Swap_Triplet; procedure Bump_And_Swap_Pair (P : in out Pair) is begin P.Bump_Pair; P.Swap_Pair; end Bump_And_Swap_Pair; procedure Bump_And_Swap_Triplet (T : in out Triplet) is begin T.Bump_Triplet; T.Swap_Triplet; end Bump_And_Swap_Triplet; end Basics;
zhmu/ananas
Ada
5,774
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- D E B U G _ A -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. 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. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; use Debug; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinput; use Sinput; with Output; use Output; package body Debug_A is Debug_A_Depth : Natural := 0; -- Output for the debug A flag is preceded by a sequence of vertical bar -- characters corresponding to the recursion depth of the actions being -- recorded (analysis, expansion, resolution and evaluation of nodes) -- This variable records the depth. Max_Node_Ids : constant := 200; -- Maximum number of Node_Id values that get stacked Node_Ids : array (1 .. Max_Node_Ids) of Node_Id; -- A stack used to keep track of Node_Id values for setting the value of -- Current_Error_Node correctly. Note that if we have more than 200 -- recursion levels, we just don't reset the right value on exit, which -- is not crucial, since this is only for debugging. -- Note that Current_Error_Node must be maintained unconditionally (not -- only when Debug_Flag_A is True), because we want to print a correct sloc -- in bug boxes. Also, Current_Error_Node is not just used for printing bug -- boxes. For example, an incorrect Current_Error_Node can cause some code -- in Rtsfind to malfunction. ----------------------- -- Local Subprograms -- ----------------------- procedure Debug_Output_Astring; -- Outputs Debug_A_Depth number of vertical bars, used to preface messages ------------------- -- Debug_A_Entry -- ------------------- procedure Debug_A_Entry (S : String; N : Node_Id) is begin -- Output debugging information if -gnatda flag set if Debug_Flag_A then Debug_Output_Astring; Write_Str (S); Write_Str ("Node_Id = "); Write_Int (Int (N)); Write_Str (" "); Write_Location (Sloc (N)); Write_Str (" "); Write_Str (Node_Kind'Image (Nkind (N))); Write_Eol; end if; -- Now push the new element Debug_A_Depth := Debug_A_Depth + 1; if Debug_A_Depth <= Max_Node_Ids then Node_Ids (Debug_A_Depth) := N; end if; -- Set Current_Error_Node only if the new node has a decent Sloc -- value, since it is for the Sloc value that we set this anyway. -- If we don't have a decent Sloc value, we leave it unchanged. if Sloc (N) > No_Location then Current_Error_Node := N; end if; end Debug_A_Entry; ------------------ -- Debug_A_Exit -- ------------------ procedure Debug_A_Exit (S : String; N : Node_Id; Comment : String) is begin Debug_A_Depth := Debug_A_Depth - 1; -- We look down the stack to find something with a decent Sloc. (If -- we find nothing, just leave it unchanged which is not so terrible) for J in reverse 1 .. Integer'Min (Max_Node_Ids, Debug_A_Depth) loop if Sloc (Node_Ids (J)) > No_Location then Current_Error_Node := Node_Ids (J); exit; end if; end loop; -- Output debugging information if -gnatda flag set if Debug_Flag_A then Debug_Output_Astring; Write_Str (S); Write_Str ("Node_Id = "); Write_Int (Int (N)); Write_Str (Comment); Write_Eol; end if; end Debug_A_Exit; -------------------------- -- Debug_Output_Astring -- -------------------------- procedure Debug_Output_Astring is Vbars : constant String := "|||||||||||||||||||||||||"; begin if Debug_A_Depth > Vbars'Length then for I in Vbars'Length .. Debug_A_Depth loop Write_Char ('|'); end loop; Write_Str (Vbars); else Write_Str (Vbars (1 .. Debug_A_Depth)); end if; end Debug_Output_Astring; end Debug_A;
reznikmm/matreshka
Ada
4,703
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Control_Implementation_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Control_Implementation_Attribute_Node is begin return Self : Form_Control_Implementation_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Control_Implementation_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Control_Implementation_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Control_Implementation_Attribute, Form_Control_Implementation_Attribute_Node'Tag); end Matreshka.ODF_Form.Control_Implementation_Attributes;
zhmu/ananas
Ada
83,806
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P A R . C H 5 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. 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. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Turn off subprogram body ordering check. Subprograms are in order by RM -- section rather than alphabetical. with Sinfo.CN; use Sinfo.CN; separate (Par) package body Ch5 is -- Local functions, used only in this chapter function P_Case_Statement return Node_Id; function P_Case_Statement_Alternative return Node_Id; function P_Exit_Statement return Node_Id; function P_Goto_Statement return Node_Id; function P_If_Statement return Node_Id; function P_Label return Node_Id; function P_Null_Statement return Node_Id; function P_Assignment_Statement (LHS : Node_Id) return Node_Id; -- Parse assignment statement. On entry, the caller has scanned the left -- hand side (passed in as Lhs), and the colon-equal (or some symbol -- taken to be an error equivalent such as equal). function P_Begin_Statement (Block_Name : Node_Id := Empty) return Node_Id; -- Parse begin-end statement. If Block_Name is non-Empty on entry, it is -- the N_Identifier node for the label on the block. If Block_Name is -- Empty on entry (the default), then the block statement is unlabeled. function P_Declare_Statement (Block_Name : Node_Id := Empty) return Node_Id; -- Parse declare block. If Block_Name is non-Empty on entry, it is -- the N_Identifier node for the label on the block. If Block_Name is -- Empty on entry (the default), then the block statement is unlabeled. function P_For_Statement (Loop_Name : Node_Id := Empty) return Node_Id; -- Parse for statement. If Loop_Name is non-Empty on entry, it is -- the N_Identifier node for the label on the loop. If Loop_Name is -- Empty on entry (the default), then the for statement is unlabeled. function P_Loop_Statement (Loop_Name : Node_Id := Empty) return Node_Id; -- Parse loop statement. If Loop_Name is non-Empty on entry, it is -- the N_Identifier node for the label on the loop. If Loop_Name is -- Empty on entry (the default), then the loop statement is unlabeled. function P_While_Statement (Loop_Name : Node_Id := Empty) return Node_Id; -- Parse while statement. If Loop_Name is non-Empty on entry, it is -- the N_Identifier node for the label on the loop. If Loop_Name is -- Empty on entry (the default), then the while statement is unlabeled. function Set_Loop_Block_Name (L : Character) return Name_Id; -- Given a letter 'L' for a loop or 'B' for a block, returns a name -- of the form L_nn or B_nn where nn is a serial number obtained by -- incrementing the variable Loop_Block_Count. procedure Then_Scan; -- Scan past THEN token, testing for illegal junk after it --------------------------------- -- 5.1 Sequence of Statements -- --------------------------------- -- SEQUENCE_OF_STATEMENTS ::= STATEMENT {STATEMENT} {LABEL} -- Note: the final label is an Ada 2012 addition. -- STATEMENT ::= -- {LABEL} SIMPLE_STATEMENT | {LABEL} COMPOUND_STATEMENT -- SIMPLE_STATEMENT ::= NULL_STATEMENT -- | ASSIGNMENT_STATEMENT | EXIT_STATEMENT -- | GOTO_STATEMENT | PROCEDURE_CALL_STATEMENT -- | RETURN_STATEMENT | ENTRY_CALL_STATEMENT -- | REQUEUE_STATEMENT | DELAY_STATEMENT -- | ABORT_STATEMENT | RAISE_STATEMENT -- | CODE_STATEMENT -- COMPOUND_STATEMENT ::= -- IF_STATEMENT | CASE_STATEMENT -- | LOOP_STATEMENT | BLOCK_STATEMENT -- | ACCEPT_STATEMENT | SELECT_STATEMENT -- This procedure scans a sequence of statements. The caller sets SS_Flags -- to indicate acceptable termination conditions for the sequence: -- SS_Flags.Eftm Terminate on ELSIF -- SS_Flags.Eltm Terminate on ELSE -- SS_Flags.Extm Terminate on EXCEPTION -- SS_Flags.Ortm Terminate on OR -- SS_Flags.Tatm Terminate on THEN ABORT (Token = ABORT on return) -- SS_Flags.Whtm Terminate on WHEN -- SS_Flags.Unco Unconditional terminate after scanning one statement -- In addition, the scan is always terminated by encountering END or the -- end of file (EOF) condition. If one of the six above terminators is -- encountered with the corresponding SS_Flags flag not set, then the -- action taken is as follows: -- If the keyword occurs to the left of the expected column of the end -- for the current sequence (as recorded in the current end context), -- then it is assumed to belong to an outer context, and is considered -- to terminate the sequence of statements. -- If the keyword occurs to the right of, or in the expected column of -- the end for the current sequence, then an error message is output, -- the keyword together with its associated context is skipped, and -- the statement scan continues until another terminator is found. -- Note that the first action means that control can return to the caller -- with Token set to a terminator other than one of those specified by the -- SS parameter. The caller should treat such a case as equivalent to END. -- In addition, the flag SS_Flags.Sreq is set to True to indicate that at -- least one real statement (other than a pragma) is required in the -- statement sequence. During the processing of the sequence, this -- flag is manipulated to indicate the current status of the requirement -- for a statement. For example, it is turned off by the occurrence of a -- statement, and back on by a label (which requires a following statement) -- Error recovery: cannot raise Error_Resync. If an error occurs during -- parsing a statement, then the scan pointer is advanced past the next -- semicolon and the parse continues. function P_Sequence_Of_Statements (SS_Flags : SS_Rec) return List_Id is Statement_Required : Boolean; -- This flag indicates if a subsequent statement (other than a pragma) -- is required. It is initialized from the Sreq flag, and modified as -- statements are scanned (a statement turns it off, and a label turns -- it back on again since a statement must follow a label). -- Note : this final requirement is lifted in Ada 2012. Statement_Seen : Boolean; -- In Ada 2012, a label can end a sequence of statements, but the -- sequence cannot contain only labels. This flag is set whenever a -- label is encountered, to enforce this rule at the end of a sequence. Declaration_Found : Boolean := False; -- This flag is set True if a declaration is encountered, so that the -- error message about declarations in the statement part is only -- given once for a given sequence of statements. Scan_State_Label : Saved_Scan_State; Scan_State : Saved_Scan_State; Statement_List : List_Id; Block_Label : Name_Id; Id_Node : Node_Id; Name_Node : Node_Id; procedure Junk_Declaration; -- Procedure called to handle error of declaration encountered in -- statement sequence. procedure Test_Statement_Required; -- Flag error if Statement_Required flag set ---------------------- -- Junk_Declaration -- ---------------------- procedure Junk_Declaration is begin if (not Declaration_Found) or All_Errors_Mode then Error_Msg_SC -- CODEFIX ("declarations must come before BEGIN"); Declaration_Found := True; end if; Skip_Declaration (Statement_List); end Junk_Declaration; ----------------------------- -- Test_Statement_Required -- ----------------------------- procedure Test_Statement_Required is function All_Pragmas return Boolean; -- Return True if statement list is all pragmas ----------------- -- All_Pragmas -- ----------------- function All_Pragmas return Boolean is S : Node_Id; begin S := First (Statement_List); while Present (S) loop if Nkind (S) /= N_Pragma then return False; else Next (S); end if; end loop; return True; end All_Pragmas; -- Start of processing for Test_Statement_Required begin if Statement_Required then -- Check no statement required after label in Ada 2012, and that -- it is OK to have nothing but pragmas in a statement sequence. if Ada_Version >= Ada_2012 and then not Is_Empty_List (Statement_List) and then ((Nkind (Last (Statement_List)) = N_Label and then Statement_Seen) or else All_Pragmas) then declare Null_Stm : constant Node_Id := Make_Null_Statement (Token_Ptr); begin Set_Comes_From_Source (Null_Stm, False); Append_To (Statement_List, Null_Stm); end; -- If not Ada 2012, or not special case above, give error message else Error_Msg_BC -- CODEFIX ("statement expected"); end if; end if; end Test_Statement_Required; -- Start of processing for P_Sequence_Of_Statements begin Statement_List := New_List; Statement_Required := SS_Flags.Sreq; Statement_Seen := False; loop Ignore (Tok_Semicolon); begin if Style_Check then Style.Check_Indentation; end if; -- Deal with reserved identifier (in assignment or call) if Is_Reserved_Identifier then Save_Scan_State (Scan_State); -- at possible bad identifier Scan; -- and scan past it -- We have an reserved word which is spelled in identifier -- style, so the question is whether it really is intended -- to be an identifier. if -- If followed by a semicolon, then it is an identifier, -- with the exception of the cases tested for below. (Token = Tok_Semicolon and then Prev_Token /= Tok_Return and then Prev_Token /= Tok_Null and then Prev_Token /= Tok_Raise and then Prev_Token /= Tok_End and then Prev_Token /= Tok_Exit) -- If followed by colon, colon-equal, or dot, then we -- definitely have an identifier (could not be reserved) or else Token = Tok_Colon or else Token = Tok_Colon_Equal or else Token = Tok_Dot -- Left paren means we have an identifier except for those -- reserved words that can legitimately be followed by a -- left paren. or else (Token = Tok_Left_Paren and then Prev_Token /= Tok_Case and then Prev_Token /= Tok_Delay and then Prev_Token /= Tok_If and then Prev_Token /= Tok_Elsif and then Prev_Token /= Tok_Return and then Prev_Token /= Tok_When and then Prev_Token /= Tok_While and then Prev_Token /= Tok_Separate) then -- Here we have an apparent reserved identifier and the -- token past it is appropriate to this usage (and would -- be a definite error if this is not an identifier). What -- we do is to use P_Identifier to fix up the identifier, -- and then fall into the normal processing. Restore_Scan_State (Scan_State); -- back to the ID Scan_Reserved_Identifier (Force_Msg => False); -- Not a reserved identifier after all (or at least we can't -- be sure that it is), so reset the scan and continue. else Restore_Scan_State (Scan_State); -- back to the reserved word end if; end if; -- Now look to see what kind of statement we have case Token is -- Case of end or EOF when Tok_End | Tok_EOF => -- These tokens always terminate the statement sequence Test_Statement_Required; exit; -- Case of ELSIF when Tok_Elsif => -- Terminate if Eftm set or if the ELSIF is to the left -- of the expected column of the end for this sequence if SS_Flags.Eftm or else Start_Column < Scopes (Scope.Last).Ecol then Test_Statement_Required; exit; -- Otherwise complain and skip past ELSIF Condition then else Error_Msg_SC ("ELSIF not allowed here"); Scan; -- past ELSIF Discard_Junk_Node (P_Expression_No_Right_Paren); Then_Scan; Statement_Required := False; end if; -- Case of ELSE when Tok_Else => -- Terminate if Eltm set or if the else is to the left -- of the expected column of the end for this sequence if SS_Flags.Eltm or else Start_Column < Scopes (Scope.Last).Ecol then Test_Statement_Required; exit; -- Otherwise complain and skip past else else Error_Msg_SC ("ELSE not allowed here"); Scan; -- past ELSE Statement_Required := False; end if; -- Case of exception when Tok_Exception => Test_Statement_Required; -- If Extm not set and the exception is not to the left of -- the expected column of the end for this sequence, then we -- assume it belongs to the current sequence, even though it -- is not permitted. if not SS_Flags.Extm and then Start_Column >= Scopes (Scope.Last).Ecol then Error_Msg_SC ("exception handler not permitted here"); Scan; -- past EXCEPTION Discard_Junk_List (Parse_Exception_Handlers); end if; -- Always return, in the case where we scanned out handlers -- that we did not expect, Parse_Exception_Handlers returned -- with Token being either end or EOF, so we are OK. exit; -- Case of OR when Tok_Or => -- Terminate if Ortm set or if the or is to the left of the -- expected column of the end for this sequence. if SS_Flags.Ortm or else Start_Column < Scopes (Scope.Last).Ecol then Test_Statement_Required; exit; -- Otherwise complain and skip past or else Error_Msg_SC ("OR not allowed here"); Scan; -- past or Statement_Required := False; end if; -- Case of THEN (deal also with THEN ABORT) when Tok_Then => Save_Scan_State (Scan_State); -- at THEN Scan; -- past THEN -- Terminate if THEN ABORT allowed (ATC case) exit when SS_Flags.Tatm and then Token = Tok_Abort; -- Otherwise we treat THEN as some kind of mess where we did -- not see the associated IF, but we pick up assuming it had -- been there. Restore_Scan_State (Scan_State); -- to THEN Append_To (Statement_List, P_If_Statement); Statement_Required := False; -- Case of WHEN (error because we are not in a case) when Tok_Others | Tok_When => -- Terminate if Whtm set or if the WHEN is to the left of -- the expected column of the end for this sequence. if SS_Flags.Whtm or else Start_Column < Scopes (Scope.Last).Ecol then Test_Statement_Required; exit; -- Otherwise complain and skip when Choice {| Choice} => else Error_Msg_SC ("WHEN not allowed here"); Scan; -- past when Discard_Junk_List (P_Discrete_Choice_List); TF_Arrow; Statement_Required := False; end if; -- Cases of statements starting with an identifier when Tok_Identifier => Check_Bad_Layout; -- Save scan pointers and line number in case block label Id_Node := Token_Node; Block_Label := Token_Name; Save_Scan_State (Scan_State_Label); -- at possible label Scan; -- past Id -- Check for common case of assignment, since it occurs -- frequently, and we want to process it efficiently. if Token = Tok_Colon_Equal then Scan; -- past the colon-equal Append_To (Statement_List, P_Assignment_Statement (Id_Node)); Statement_Required := False; -- Check common case of procedure call, another case that -- we want to speed up as much as possible. elsif Token = Tok_Semicolon then Change_Name_To_Procedure_Call_Statement (Id_Node); Append_To (Statement_List, Id_Node); Scan; -- past semicolon Statement_Required := False; -- Here is the special test for a suspicious label, more -- accurately a suspicious name, which we think perhaps -- should have been a label. If next token is one of -- LOOP, FOR, WHILE, DECLARE, BEGIN, then make an entry -- in the suspicious label table. if Token = Tok_Loop or else Token = Tok_For or else Token = Tok_While or else Token = Tok_Declare or else Token = Tok_Begin then Suspicious_Labels.Append ((Proc_Call => Id_Node, Semicolon_Loc => Prev_Token_Ptr, Start_Token => Token_Ptr)); end if; -- Check for case of "go to" in place of "goto" elsif Token = Tok_Identifier and then Block_Label = Name_Go and then Token_Name = Name_To then Error_Msg_SP -- CODEFIX ("goto is one word"); Append_To (Statement_List, P_Goto_Statement); Statement_Required := False; -- Check common case of = used instead of :=, just so we -- give a better error message for this special misuse. elsif Token = Tok_Equal then T_Colon_Equal; -- give := expected message Append_To (Statement_List, P_Assignment_Statement (Id_Node)); Statement_Required := False; -- Check case of loop label or block label elsif Token = Tok_Colon or else (Token in Token_Class_Labeled_Stmt and then not Token_Is_At_Start_Of_Line) then T_Colon; -- past colon (if there, or msg for missing one) -- Test for more than one label loop exit when Token /= Tok_Identifier; Save_Scan_State (Scan_State); -- at second Id Scan; -- past Id if Token = Tok_Colon then Error_Msg_SP ("only one label allowed on block or loop"); Scan; -- past colon on extra label -- Use the second label as the "real" label Scan_State_Label := Scan_State; -- We will set Error_name as the Block_Label since -- we really don't know which of the labels might -- be used at the end of the loop or block. Block_Label := Error_Name; -- If Id with no colon, then backup to point to the -- Id and we will issue the message below when we try -- to scan out the statement as some other form. else Restore_Scan_State (Scan_State); -- to second Id exit; end if; end loop; -- Loop_Statement (labeled Loop_Statement) if Token = Tok_Loop then Append_To (Statement_List, P_Loop_Statement (Id_Node)); -- While statement (labeled loop statement with WHILE) elsif Token = Tok_While then Append_To (Statement_List, P_While_Statement (Id_Node)); -- Declare statement (labeled block statement with -- DECLARE part) elsif Token = Tok_Declare then Append_To (Statement_List, P_Declare_Statement (Id_Node)); -- Begin statement (labeled block statement with no -- DECLARE part) elsif Token = Tok_Begin then Append_To (Statement_List, P_Begin_Statement (Id_Node)); -- For statement (labeled loop statement with FOR) elsif Token = Tok_For then Append_To (Statement_List, P_For_Statement (Id_Node)); -- Improper statement follows label. If we have an -- expression token, then assume the colon was part -- of a misplaced declaration. elsif Token not in Token_Class_Eterm then Restore_Scan_State (Scan_State_Label); Junk_Declaration; -- Otherwise complain we have inappropriate statement else Error_Msg_AP ("loop or block statement must follow label"); end if; Statement_Required := False; -- Here we have an identifier followed by something -- other than a colon, semicolon or assignment symbol. -- The only valid possibility is a name extension symbol elsif Token in Token_Class_Namext then Restore_Scan_State (Scan_State_Label); -- to Id Name_Node := P_Name; -- Skip junk right parens in this context Ignore (Tok_Right_Paren); -- Check context following call if Token = Tok_Colon_Equal then Scan; -- past colon equal Append_To (Statement_List, P_Assignment_Statement (Name_Node)); Statement_Required := False; -- Check common case of = used instead of := elsif Token = Tok_Equal then T_Colon_Equal; -- give := expected message Append_To (Statement_List, P_Assignment_Statement (Name_Node)); Statement_Required := False; -- Check apostrophe cases elsif Token = Tok_Apostrophe then Append_To (Statement_List, P_Code_Statement (Name_Node)); Statement_Required := False; -- The only other valid item after a name is ; which -- means that the item we just scanned was a call. elsif Token = Tok_Semicolon then Change_Name_To_Procedure_Call_Statement (Name_Node); Append_To (Statement_List, Name_Node); Scan; -- past semicolon Statement_Required := False; -- A slash following an identifier or a selected -- component in this situation is most likely a period -- (see location of keys on keyboard). elsif Token = Tok_Slash and then (Nkind (Name_Node) = N_Identifier or else Nkind (Name_Node) = N_Selected_Component) then Error_Msg_SC -- CODEFIX ("""/"" should be ""."""); Statement_Required := False; raise Error_Resync; -- Else we have a missing semicolon else TF_Semicolon; -- Normal processing as though semicolon were present Change_Name_To_Procedure_Call_Statement (Name_Node); Append_To (Statement_List, Name_Node); Statement_Required := False; end if; -- If junk after identifier, check if identifier is an -- instance of an incorrectly spelled keyword. If so, we -- do nothing. The Bad_Spelling_Of will have reset Token -- to the appropriate keyword, so the next time round the -- loop we will process the modified token. Note that we -- check for ELSIF before ELSE here. That's not accidental. -- We don't want to identify a misspelling of ELSE as -- ELSIF, and in particular we do not want to treat ELSEIF -- as ELSE IF. else Restore_Scan_State (Scan_State_Label); -- to identifier if Bad_Spelling_Of (Tok_Abort) or else Bad_Spelling_Of (Tok_Accept) or else Bad_Spelling_Of (Tok_Case) or else Bad_Spelling_Of (Tok_Declare) or else Bad_Spelling_Of (Tok_Delay) or else Bad_Spelling_Of (Tok_Elsif) or else Bad_Spelling_Of (Tok_Else) or else Bad_Spelling_Of (Tok_End) or else Bad_Spelling_Of (Tok_Exception) or else Bad_Spelling_Of (Tok_Exit) or else Bad_Spelling_Of (Tok_For) or else Bad_Spelling_Of (Tok_Goto) or else Bad_Spelling_Of (Tok_If) or else Bad_Spelling_Of (Tok_Loop) or else Bad_Spelling_Of (Tok_Or) or else Bad_Spelling_Of (Tok_Pragma) or else Bad_Spelling_Of (Tok_Raise) or else Bad_Spelling_Of (Tok_Requeue) or else Bad_Spelling_Of (Tok_Return) or else Bad_Spelling_Of (Tok_Select) or else Bad_Spelling_Of (Tok_When) or else Bad_Spelling_Of (Tok_While) then null; -- If not a bad spelling, then we really have junk else Scan; -- past identifier again -- If next token is first token on line, then we -- consider that we were missing a semicolon after -- the identifier, and process it as a procedure -- call with no parameters. if Token_Is_At_Start_Of_Line then Change_Name_To_Procedure_Call_Statement (Id_Node); Append_To (Statement_List, Id_Node); T_Semicolon; -- to give error message Statement_Required := False; -- Otherwise we give a missing := message and -- simply abandon the junk that is there now. else T_Colon_Equal; -- give := expected message raise Error_Resync; end if; end if; end if; -- Statement starting with operator symbol. This could be -- a call, a name starting an assignment, or a qualified -- expression. when Tok_Operator_Symbol => Check_Bad_Layout; Name_Node := P_Name; -- An attempt at a range attribute or a qualified expression -- must be illegal here (a code statement cannot possibly -- allow qualification by a function name). if Token = Tok_Apostrophe then Error_Msg_SC ("apostrophe illegal here"); raise Error_Resync; end if; -- Scan possible assignment if we have a name if Expr_Form = EF_Name and then Token = Tok_Colon_Equal then Scan; -- past colon equal Append_To (Statement_List, P_Assignment_Statement (Name_Node)); else Change_Name_To_Procedure_Call_Statement (Name_Node); Append_To (Statement_List, Name_Node); end if; TF_Semicolon; Statement_Required := False; -- Label starting with << which must precede real statement -- Note: in Ada 2012, the label may end the sequence. when Tok_Less_Less => if Present (Last (Statement_List)) and then Nkind (Last (Statement_List)) /= N_Label then Statement_Seen := True; end if; Append_To (Statement_List, P_Label); Statement_Required := True; -- Pragma appearing as a statement in a statement sequence when Tok_Pragma => Check_Bad_Layout; Append_To (Statement_List, P_Pragma); -- Abort_Statement when Tok_Abort => Check_Bad_Layout; Append_To (Statement_List, P_Abort_Statement); Statement_Required := False; -- Accept_Statement when Tok_Accept => Check_Bad_Layout; Append_To (Statement_List, P_Accept_Statement); Statement_Required := False; -- Begin_Statement (Block_Statement with no declare, no label) when Tok_Begin => Check_Bad_Layout; Append_To (Statement_List, P_Begin_Statement); Statement_Required := False; -- Case_Statement when Tok_Case => Check_Bad_Layout; Append_To (Statement_List, P_Case_Statement); Statement_Required := False; -- Block_Statement with DECLARE and no label when Tok_Declare => Check_Bad_Layout; Append_To (Statement_List, P_Declare_Statement); Statement_Required := False; -- Delay_Statement when Tok_Delay => Check_Bad_Layout; Append_To (Statement_List, P_Delay_Statement); Statement_Required := False; -- Exit_Statement when Tok_Exit => Check_Bad_Layout; Append_To (Statement_List, P_Exit_Statement); Statement_Required := False; -- Loop_Statement with FOR and no label when Tok_For => Check_Bad_Layout; Append_To (Statement_List, P_For_Statement); Statement_Required := False; -- Goto_Statement when Tok_Goto => Check_Bad_Layout; Append_To (Statement_List, P_Goto_Statement); Statement_Required := False; -- If_Statement when Tok_If => Check_Bad_Layout; Append_To (Statement_List, P_If_Statement); Statement_Required := False; -- Loop_Statement when Tok_Loop => Check_Bad_Layout; Append_To (Statement_List, P_Loop_Statement); Statement_Required := False; -- Null_Statement when Tok_Null => Check_Bad_Layout; Append_To (Statement_List, P_Null_Statement); Statement_Required := False; -- Raise_Statement when Tok_Raise => Check_Bad_Layout; Append_To (Statement_List, P_Raise_Statement); Statement_Required := False; -- Requeue_Statement when Tok_Requeue => Check_Bad_Layout; Append_To (Statement_List, P_Requeue_Statement); Statement_Required := False; -- Return_Statement when Tok_Return => Check_Bad_Layout; Append_To (Statement_List, P_Return_Statement); Statement_Required := False; -- Select_Statement when Tok_Select => Check_Bad_Layout; Append_To (Statement_List, P_Select_Statement); Statement_Required := False; -- While_Statement (Block_Statement with while and no loop) when Tok_While => Check_Bad_Layout; Append_To (Statement_List, P_While_Statement); Statement_Required := False; -- Anything else is some kind of junk, signal an error message -- and then raise Error_Resync, to merge with the normal -- handling of a bad statement. when others => if Token in Token_Class_Declk then Junk_Declaration; else Error_Msg_BC -- CODEFIX ("statement expected"); raise Error_Resync; end if; end case; -- On error resynchronization, skip past next semicolon, and, since -- we are still in the statement loop, look for next statement. We -- set Statement_Required False to avoid an unnecessary error message -- complaining that no statement was found (i.e. we consider the -- junk to satisfy the requirement for a statement being present). exception when Error_Resync => Resync_Past_Semicolon_Or_To_Loop_Or_Then; Statement_Required := False; end; exit when SS_Flags.Unco; end loop; return Statement_List; end P_Sequence_Of_Statements; -------------------- -- 5.1 Statement -- -------------------- --------------------------- -- 5.1 Simple Statement -- --------------------------- -- Parsed by P_Sequence_Of_Statements (5.1) ----------------------------- -- 5.1 Compound Statement -- ----------------------------- -- Parsed by P_Sequence_Of_Statements (5.1) ------------------------- -- 5.1 Null Statement -- ------------------------- -- NULL_STATEMENT ::= null; -- The caller has already checked that the current token is null -- Error recovery: cannot raise Error_Resync function P_Null_Statement return Node_Id is Null_Stmt_Node : Node_Id; begin Null_Stmt_Node := New_Node (N_Null_Statement, Token_Ptr); Scan; -- past NULL TF_Semicolon; return Null_Stmt_Node; end P_Null_Statement; ---------------- -- 5.1 Label -- ---------------- -- LABEL ::= <<label_STATEMENT_IDENTIFIER>> -- STATEMENT_IDENTIFIER ::= DIRECT_NAME -- The IDENTIFIER of a STATEMENT_IDENTIFIER shall be an identifier -- (not an OPERATOR_SYMBOL) -- The caller has already checked that the current token is << -- Error recovery: can raise Error_Resync function P_Label return Node_Id is Label_Node : Node_Id; begin Label_Node := New_Node (N_Label, Token_Ptr); Scan; -- past << Set_Identifier (Label_Node, P_Identifier (C_Greater_Greater)); T_Greater_Greater; Append_Elmt (Label_Node, Label_List); return Label_Node; end P_Label; ------------------------------- -- 5.1 Statement Identifier -- ------------------------------- -- Statement label is parsed by P_Label (5.1) -- Loop label is parsed by P_Loop_Statement (5.5), P_For_Statement (5.5) -- or P_While_Statement (5.5) -- Block label is parsed by P_Begin_Statement (5.6) or -- P_Declare_Statement (5.6) ------------------------------- -- 5.2 Assignment Statement -- ------------------------------- -- ASSIGNMENT_STATEMENT ::= -- variable_NAME := EXPRESSION; -- Error recovery: can raise Error_Resync function P_Assignment_Statement (LHS : Node_Id) return Node_Id is Assign_Node : Node_Id; begin Assign_Node := New_Node (N_Assignment_Statement, Prev_Token_Ptr); Current_Assign_Node := Assign_Node; Set_Name (Assign_Node, LHS); Set_Expression (Assign_Node, P_Expression_No_Right_Paren); TF_Semicolon; Current_Assign_Node := Empty; return Assign_Node; end P_Assignment_Statement; ----------------------- -- 5.3 If Statement -- ----------------------- -- IF_STATEMENT ::= -- if CONDITION then -- SEQUENCE_OF_STATEMENTS -- {elsif CONDITION then -- SEQUENCE_OF_STATEMENTS} -- [else -- SEQUENCE_OF_STATEMENTS] -- end if; -- The caller has checked that the initial token is IF (or in the error -- case of a mysterious THEN, the initial token may simply be THEN, in -- which case, no condition (or IF) was scanned). -- Error recovery: can raise Error_Resync function P_If_Statement return Node_Id is If_Node : Node_Id; Elsif_Node : Node_Id; Loc : Source_Ptr; procedure Add_Elsif_Part; -- An internal procedure used to scan out a single ELSIF part. On entry -- the ELSIF (or an ELSE which has been determined should be ELSIF) is -- scanned out and is in Prev_Token. procedure Check_If_Column; -- An internal procedure used to check that THEN, ELSE, or ELSIF -- appear in the right place if column checking is enabled (i.e. if -- they are the first token on the line, then they must appear in -- the same column as the opening IF). procedure Check_Then_Column; -- This procedure carries out the style checks for a THEN token -- Note that the caller has set Loc to the Source_Ptr value for -- the previous IF or ELSIF token. function Else_Should_Be_Elsif return Boolean; -- An internal routine used to do a special error recovery check when -- an ELSE is encountered. It determines if the ELSE should be treated -- as an ELSIF. A positive decision (TRUE returned, is made if the ELSE -- is followed by a sequence of tokens, starting on the same line as -- the ELSE, which are not expression terminators, followed by a THEN. -- On entry, the ELSE has been scanned out. procedure Add_Elsif_Part is begin if No (Elsif_Parts (If_Node)) then Set_Elsif_Parts (If_Node, New_List); end if; Elsif_Node := New_Node (N_Elsif_Part, Prev_Token_Ptr); Loc := Prev_Token_Ptr; Set_Condition (Elsif_Node, P_Condition); Check_Then_Column; Then_Scan; Set_Then_Statements (Elsif_Node, P_Sequence_Of_Statements (SS_Eftm_Eltm_Sreq)); Append (Elsif_Node, Elsif_Parts (If_Node)); end Add_Elsif_Part; procedure Check_If_Column is begin if RM_Column_Check and then Token_Is_At_Start_Of_Line and then Start_Column /= Scopes (Scope.Last).Ecol then Error_Msg_Col := Scopes (Scope.Last).Ecol; Error_Msg_SC ("(style) this token should be@"); end if; end Check_If_Column; procedure Check_Then_Column is begin if Token = Tok_Then then Check_If_Column; if Style_Check then Style.Check_Then (Loc); end if; end if; end Check_Then_Column; function Else_Should_Be_Elsif return Boolean is Scan_State : Saved_Scan_State; begin if Token_Is_At_Start_Of_Line then return False; else Save_Scan_State (Scan_State); loop if Token in Token_Class_Eterm then Restore_Scan_State (Scan_State); return False; else Scan; -- past non-expression terminating token if Token = Tok_Then then Restore_Scan_State (Scan_State); return True; end if; end if; end loop; end if; end Else_Should_Be_Elsif; -- Start of processing for P_If_Statement begin If_Node := New_Node (N_If_Statement, Token_Ptr); Push_Scope_Stack; Scopes (Scope.Last).Etyp := E_If; Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scopes (Scope.Last).Labl := Error; Scopes (Scope.Last).Node := If_Node; if Token = Tok_If then Loc := Token_Ptr; Scan; -- past IF Set_Condition (If_Node, P_Condition); -- Deal with misuse of IF expression => used instead -- of WHEN expression => if Token = Tok_Arrow then Error_Msg_SC -- CODEFIX ("THEN expected"); Scan; -- past the arrow Pop_Scope_Stack; -- remove unneeded entry raise Error_Resync; end if; Check_Then_Column; else Error_Msg_SC ("no IF for this THEN"); Set_Condition (If_Node, Error); end if; Then_Scan; Set_Then_Statements (If_Node, P_Sequence_Of_Statements (SS_Eftm_Eltm_Sreq)); -- This loop scans out else and elsif parts loop if Token = Tok_Elsif then Check_If_Column; if Present (Else_Statements (If_Node)) then Error_Msg_SP ("ELSIF cannot appear after ELSE"); end if; Scan; -- past ELSIF Add_Elsif_Part; elsif Token = Tok_Else then Check_If_Column; Scan; -- past ELSE if Else_Should_Be_Elsif then Error_Msg_SP -- CODEFIX ("ELSE should be ELSIF"); Add_Elsif_Part; else -- Here we have an else that really is an else if Present (Else_Statements (If_Node)) then Error_Msg_SP ("only one ELSE part allowed"); Append_List (P_Sequence_Of_Statements (SS_Eftm_Eltm_Sreq), Else_Statements (If_Node)); else Set_Else_Statements (If_Node, P_Sequence_Of_Statements (SS_Eftm_Eltm_Sreq)); end if; end if; -- If anything other than ELSE or ELSIF, exit the loop. The token -- had better be END (and in fact it had better be END IF), but -- we will let End_Statements take care of checking that. else exit; end if; end loop; End_Statements; return If_Node; end P_If_Statement; -------------------- -- 5.3 Condition -- -------------------- -- CONDITION ::= boolean_EXPRESSION function P_Condition return Node_Id is begin return P_Condition (P_Expression_No_Right_Paren); end P_Condition; function P_Condition (Cond : Node_Id) return Node_Id is begin -- It is never possible for := to follow a condition, so if we get -- a := we assume it is a mistyped equality. Note that we do not try -- to reconstruct the tree correctly in this case, but we do at least -- give an accurate error message. if Token = Tok_Colon_Equal then while Token = Tok_Colon_Equal loop Error_Msg_SC -- CODEFIX (""":="" should be ""="""); Scan; -- past junk := Discard_Junk_Node (P_Expression_No_Right_Paren); end loop; return Cond; -- Otherwise check for redundant parentheses but do not emit messages -- about expressions that require parentheses (e.g. conditional, -- quantified or declaration expressions). else if Style_Check and then Paren_Count (Cond) > (if Nkind (Cond) in N_Case_Expression | N_Expression_With_Actions | N_If_Expression | N_Quantified_Expression then 1 else 0) then Style.Check_Xtra_Parens (First_Sloc (Cond)); end if; -- And return the result return Cond; end if; end P_Condition; ------------------------- -- 5.4 Case Statement -- ------------------------- -- CASE_STATEMENT ::= -- case EXPRESSION is -- CASE_STATEMENT_ALTERNATIVE -- {CASE_STATEMENT_ALTERNATIVE} -- end case; -- The caller has checked that the first token is CASE -- Can raise Error_Resync function P_Case_Statement return Node_Id is Case_Node : Node_Id; Alternatives_List : List_Id; First_When_Loc : Source_Ptr; begin Case_Node := New_Node (N_Case_Statement, Token_Ptr); Push_Scope_Stack; Scopes (Scope.Last).Etyp := E_Case; Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scopes (Scope.Last).Labl := Error; Scopes (Scope.Last).Node := Case_Node; Scan; -- past CASE Set_Expression (Case_Node, P_Expression_No_Right_Paren); TF_Is; -- Prepare to parse case statement alternatives Alternatives_List := New_List; P_Pragmas_Opt (Alternatives_List); First_When_Loc := Token_Ptr; -- Loop through case statement alternatives loop -- If we have a WHEN or OTHERS, then that's fine keep going. Note -- that it is a semantic check to ensure the proper use of OTHERS if Token = Tok_When or else Token = Tok_Others then Append (P_Case_Statement_Alternative, Alternatives_List); -- If we have an END, then probably we are at the end of the case -- but we only exit if Check_End thinks the END was reasonable. elsif Token = Tok_End then exit when Check_End; -- Here if token is other than WHEN, OTHERS or END. We definitely -- have an error, but the question is whether or not to get out of -- the case statement. We don't want to get out early, or we will -- get a slew of junk error messages for subsequent when tokens. -- If the token is not at the start of the line, or if it is indented -- with respect to the current case statement, then the best guess is -- that we are still supposed to be inside the case statement. We -- complain about the missing WHEN, and discard the junk statements. elsif not Token_Is_At_Start_Of_Line or else Start_Column > Scopes (Scope.Last).Ecol then Error_Msg_BC ("WHEN (case statement alternative) expected"); -- Here is a possibility for infinite looping if we don't make -- progress. So try to process statements, otherwise exit declare Error_Ptr : constant Source_Ptr := Scan_Ptr; begin Discard_Junk_List (P_Sequence_Of_Statements (SS_Whtm)); exit when Scan_Ptr = Error_Ptr and then Check_End; end; -- Here we have a junk token at the start of the line and it is -- not indented. If Check_End thinks there is a missing END, then -- we will get out of the case, otherwise we keep going. else exit when Check_End; end if; end loop; -- Make sure we have at least one alternative if No (First_Non_Pragma (Alternatives_List)) then Error_Msg ("WHEN expected, must have at least one alternative in case", First_When_Loc); return Error; else Set_Alternatives (Case_Node, Alternatives_List); return Case_Node; end if; end P_Case_Statement; ------------------------------------- -- 5.4 Case Statement Alternative -- ------------------------------------- -- CASE_STATEMENT_ALTERNATIVE ::= -- when DISCRETE_CHOICE_LIST => -- SEQUENCE_OF_STATEMENTS -- The caller has checked that the initial token is WHEN or OTHERS -- Error recovery: can raise Error_Resync function P_Case_Statement_Alternative return Node_Id is Case_Alt_Node : Node_Id; begin if Style_Check then Style.Check_Indentation; end if; Case_Alt_Node := New_Node (N_Case_Statement_Alternative, Token_Ptr); T_When; -- past WHEN (or give error in OTHERS case) Set_Discrete_Choices (Case_Alt_Node, P_Discrete_Choice_List); TF_Arrow; Set_Statements (Case_Alt_Node, P_Sequence_Of_Statements (SS_Sreq_Whtm)); return Case_Alt_Node; end P_Case_Statement_Alternative; ------------------------- -- 5.5 Loop Statement -- ------------------------- -- LOOP_STATEMENT ::= -- [LOOP_STATEMENT_IDENTIFIER:] -- [ITERATION_SCHEME] loop -- SEQUENCE_OF_STATEMENTS -- end loop [loop_IDENTIFIER]; -- ITERATION_SCHEME ::= -- while CONDITION -- | for LOOP_PARAMETER_SPECIFICATION -- The parsing of loop statements is handled by one of three functions -- P_Loop_Statement, P_For_Statement or P_While_Statement depending -- on the initial keyword in the construct (excluding the identifier) -- P_Loop_Statement -- This function parses the case where no iteration scheme is present -- The caller has checked that the initial token is LOOP. The parameter -- is the node identifiers for the loop label if any (or is set to Empty -- if there is no loop label). -- Error recovery : cannot raise Error_Resync function P_Loop_Statement (Loop_Name : Node_Id := Empty) return Node_Id is Loop_Node : Node_Id; Created_Name : Node_Id; begin Push_Scope_Stack; Scopes (Scope.Last).Labl := Loop_Name; Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scopes (Scope.Last).Etyp := E_Loop; Loop_Node := New_Node (N_Loop_Statement, Token_Ptr); TF_Loop; if No (Loop_Name) then Created_Name := Make_Identifier (Sloc (Loop_Node), Set_Loop_Block_Name ('L')); Set_Comes_From_Source (Created_Name, False); Set_Has_Created_Identifier (Loop_Node, True); Set_Identifier (Loop_Node, Created_Name); Scopes (Scope.Last).Labl := Created_Name; else Set_Identifier (Loop_Node, Loop_Name); end if; Append_Elmt (Loop_Node, Label_List); Set_Statements (Loop_Node, P_Sequence_Of_Statements (SS_Sreq)); End_Statements (Loop_Node); return Loop_Node; end P_Loop_Statement; -- P_For_Statement -- This function parses a loop statement with a FOR iteration scheme -- The caller has checked that the initial token is FOR. The parameter -- is the node identifier for the block label if any (or is set to Empty -- if there is no block label). -- Note: the caller fills in the Identifier field if a label was present -- Error recovery: can raise Error_Resync function P_For_Statement (Loop_Name : Node_Id := Empty) return Node_Id is Loop_Node : Node_Id; Iter_Scheme_Node : Node_Id; Loop_For_Flag : Boolean; Created_Name : Node_Id; Spec : Node_Id; begin Push_Scope_Stack; Scopes (Scope.Last).Labl := Loop_Name; Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scopes (Scope.Last).Etyp := E_Loop; Loop_For_Flag := (Prev_Token = Tok_Loop); Scan; -- past FOR Iter_Scheme_Node := New_Node (N_Iteration_Scheme, Token_Ptr); Spec := P_Loop_Parameter_Specification; if Nkind (Spec) = N_Loop_Parameter_Specification then Set_Loop_Parameter_Specification (Iter_Scheme_Node, Spec); else Set_Iterator_Specification (Iter_Scheme_Node, Spec); end if; -- The following is a special test so that a miswritten for loop such -- as "loop for I in 1..10;" is handled nicely, without making an extra -- entry in the scope stack. We don't bother to actually fix up the -- tree in this case since it's not worth the effort. Instead we just -- eat up the loop junk, leaving the entry for what now looks like an -- unmodified loop intact. if Loop_For_Flag and then Token = Tok_Semicolon then Error_Msg_SC ("LOOP belongs here, not before FOR"); Pop_Scope_Stack; return Error; -- Normal case else Loop_Node := New_Node (N_Loop_Statement, Token_Ptr); if No (Loop_Name) then Created_Name := Make_Identifier (Sloc (Loop_Node), Set_Loop_Block_Name ('L')); Set_Comes_From_Source (Created_Name, False); Set_Has_Created_Identifier (Loop_Node, True); Set_Identifier (Loop_Node, Created_Name); Scopes (Scope.Last).Labl := Created_Name; else Set_Identifier (Loop_Node, Loop_Name); end if; TF_Loop; Set_Statements (Loop_Node, P_Sequence_Of_Statements (SS_Sreq)); End_Statements (Loop_Node); Set_Iteration_Scheme (Loop_Node, Iter_Scheme_Node); Append_Elmt (Loop_Node, Label_List); return Loop_Node; end if; end P_For_Statement; -- P_While_Statement -- This procedure scans a loop statement with a WHILE iteration scheme -- The caller has checked that the initial token is WHILE. The parameter -- is the node identifier for the block label if any (or is set to Empty -- if there is no block label). -- Error recovery: cannot raise Error_Resync function P_While_Statement (Loop_Name : Node_Id := Empty) return Node_Id is Loop_Node : Node_Id; Iter_Scheme_Node : Node_Id; Loop_While_Flag : Boolean; Created_Name : Node_Id; begin Push_Scope_Stack; Scopes (Scope.Last).Labl := Loop_Name; Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scopes (Scope.Last).Etyp := E_Loop; Loop_While_Flag := (Prev_Token = Tok_Loop); Iter_Scheme_Node := New_Node (N_Iteration_Scheme, Token_Ptr); Scan; -- past WHILE Set_Condition (Iter_Scheme_Node, P_Condition); -- The following is a special test so that a miswritten for loop such -- as "loop while I > 10;" is handled nicely, without making an extra -- entry in the scope stack. We don't bother to actually fix up the -- tree in this case since it's not worth the effort. Instead we just -- eat up the loop junk, leaving the entry for what now looks like an -- unmodified loop intact. if Loop_While_Flag and then Token = Tok_Semicolon then Error_Msg_SC ("LOOP belongs here, not before WHILE"); Pop_Scope_Stack; return Error; -- Normal case else Loop_Node := New_Node (N_Loop_Statement, Token_Ptr); TF_Loop; if No (Loop_Name) then Created_Name := Make_Identifier (Sloc (Loop_Node), Set_Loop_Block_Name ('L')); Set_Comes_From_Source (Created_Name, False); Set_Has_Created_Identifier (Loop_Node, True); Set_Identifier (Loop_Node, Created_Name); Scopes (Scope.Last).Labl := Created_Name; else Set_Identifier (Loop_Node, Loop_Name); end if; Set_Statements (Loop_Node, P_Sequence_Of_Statements (SS_Sreq)); End_Statements (Loop_Node); Set_Iteration_Scheme (Loop_Node, Iter_Scheme_Node); Append_Elmt (Loop_Node, Label_List); return Loop_Node; end if; end P_While_Statement; --------------------------------------- -- 5.5 Loop Parameter Specification -- --------------------------------------- -- LOOP_PARAMETER_SPECIFICATION ::= -- DEFINING_IDENTIFIER in [reverse] DISCRETE_SUBTYPE_DEFINITION -- [Iterator_Filter] -- Error recovery: cannot raise Error_Resync function P_Loop_Parameter_Specification return Node_Id is Loop_Param_Specification_Node : Node_Id; ID_Node : Node_Id; Scan_State : Saved_Scan_State; begin Save_Scan_State (Scan_State); ID_Node := P_Defining_Identifier (C_In); -- If the next token is OF, it indicates an Ada 2012 iterator. If the -- next token is a colon, this is also an Ada 2012 iterator, including -- a subtype indication for the loop parameter. Otherwise we parse the -- construct as a loop parameter specification. Note that the form -- "for A in B" is ambiguous, and must be resolved semantically: if B -- is a discrete subtype this is a loop specification, but if it is an -- expression it is an iterator specification. Ambiguity is resolved -- during analysis of the loop parameter specification. if Token = Tok_Of or else Token = Tok_Colon then Error_Msg_Ada_2012_Feature ("iterator", Token_Ptr); return P_Iterator_Specification (ID_Node); end if; -- The span of the Loop_Parameter_Specification starts at the -- defining identifier. Loop_Param_Specification_Node := New_Node (N_Loop_Parameter_Specification, Sloc (ID_Node)); Set_Defining_Identifier (Loop_Param_Specification_Node, ID_Node); if Token = Tok_Left_Paren then Error_Msg_SC ("subscripted loop parameter not allowed"); Restore_Scan_State (Scan_State); Discard_Junk_Node (P_Name); elsif Token = Tok_Dot then Error_Msg_SC ("selected loop parameter not allowed"); Restore_Scan_State (Scan_State); Discard_Junk_Node (P_Name); end if; T_In; if Token = Tok_Reverse then Scan; -- past REVERSE Set_Reverse_Present (Loop_Param_Specification_Node, True); end if; Set_Discrete_Subtype_Definition (Loop_Param_Specification_Node, P_Discrete_Subtype_Definition); if Token = Tok_When then Error_Msg_Ada_2022_Feature ("iterator filter", Token_Ptr); Scan; -- past WHEN Set_Iterator_Filter (Loop_Param_Specification_Node, P_Condition); end if; return Loop_Param_Specification_Node; exception when Error_Resync => return Error; end P_Loop_Parameter_Specification; ---------------------------------- -- 5.5.1 Iterator_Specification -- ---------------------------------- function P_Iterator_Specification (Def_Id : Node_Id) return Node_Id is Node1 : Node_Id; begin Node1 := New_Node (N_Iterator_Specification, Sloc (Def_Id)); Set_Defining_Identifier (Node1, Def_Id); if Token = Tok_Colon then Scan; -- past : if Token = Tok_Access then Error_Msg_Ada_2022_Feature ("access definition in loop parameter", Token_Ptr); Set_Subtype_Indication (Node1, P_Access_Definition (False)); else Set_Subtype_Indication (Node1, P_Subtype_Indication); end if; end if; if Token = Tok_Of then Set_Of_Present (Node1); Scan; -- past OF elsif Token = Tok_In then Scan; -- past IN elsif Prev_Token = Tok_In and then Present (Subtype_Indication (Node1)) then -- Simplest recovery is to transform it into an element iterator. -- Error message on 'in" has already been emitted when parsing the -- optional constraint. Set_Of_Present (Node1); Error_Msg_N ("subtype indication is only legal on an element iterator", Subtype_Indication (Node1)); else return Error; end if; if Token = Tok_Reverse then Scan; -- past REVERSE Set_Reverse_Present (Node1, True); end if; Set_Name (Node1, P_Name); if Token = Tok_When then Error_Msg_Ada_2022_Feature ("iterator filter", Token_Ptr); Scan; -- past WHEN Set_Iterator_Filter (Node1, P_Condition); end if; return Node1; end P_Iterator_Specification; -------------------------- -- 5.6 Block Statement -- -------------------------- -- BLOCK_STATEMENT ::= -- [block_STATEMENT_IDENTIFIER:] -- [declare -- DECLARATIVE_PART] -- begin -- HANDLED_SEQUENCE_OF_STATEMENTS -- end [block_IDENTIFIER]; -- The parsing of block statements is handled by one of the two functions -- P_Declare_Statement or P_Begin_Statement depending on whether or not -- a declare section is present -- P_Declare_Statement -- This function parses a block statement with DECLARE present -- The caller has checked that the initial token is DECLARE -- Error recovery: cannot raise Error_Resync function P_Declare_Statement (Block_Name : Node_Id := Empty) return Node_Id is Block_Node : Node_Id; Created_Name : Node_Id; begin Block_Node := New_Node (N_Block_Statement, Token_Ptr); Push_Scope_Stack; Scopes (Scope.Last).Etyp := E_Name; Scopes (Scope.Last).Lreq := Present (Block_Name); Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Labl := Block_Name; Scopes (Scope.Last).Sloc := Token_Ptr; Scan; -- past DECLARE if No (Block_Name) then Created_Name := Make_Identifier (Sloc (Block_Node), Set_Loop_Block_Name ('B')); Set_Comes_From_Source (Created_Name, False); Set_Has_Created_Identifier (Block_Node, True); Set_Identifier (Block_Node, Created_Name); Scopes (Scope.Last).Labl := Created_Name; else Set_Identifier (Block_Node, Block_Name); end if; Append_Elmt (Block_Node, Label_List); Parse_Decls_Begin_End (Block_Node); return Block_Node; end P_Declare_Statement; -- P_Begin_Statement -- This function parses a block statement with no DECLARE present -- The caller has checked that the initial token is BEGIN -- Error recovery: cannot raise Error_Resync function P_Begin_Statement (Block_Name : Node_Id := Empty) return Node_Id is Block_Node : Node_Id; Created_Name : Node_Id; begin Block_Node := New_Node (N_Block_Statement, Token_Ptr); Push_Scope_Stack; Scopes (Scope.Last).Etyp := E_Name; Scopes (Scope.Last).Lreq := Present (Block_Name); Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Labl := Block_Name; Scopes (Scope.Last).Sloc := Token_Ptr; if No (Block_Name) then Created_Name := Make_Identifier (Sloc (Block_Node), Set_Loop_Block_Name ('B')); Set_Comes_From_Source (Created_Name, False); Set_Has_Created_Identifier (Block_Node, True); Set_Identifier (Block_Node, Created_Name); Scopes (Scope.Last).Labl := Created_Name; else Set_Identifier (Block_Node, Block_Name); end if; Append_Elmt (Block_Node, Label_List); Scopes (Scope.Last).Ecol := Start_Column; Scopes (Scope.Last).Sloc := Token_Ptr; Scan; -- past BEGIN Set_Handled_Statement_Sequence (Block_Node, P_Handled_Sequence_Of_Statements); End_Statements (Handled_Statement_Sequence (Block_Node)); return Block_Node; end P_Begin_Statement; ------------------------- -- 5.7 Exit Statement -- ------------------------- -- EXIT_STATEMENT ::= -- exit [loop_NAME] [when CONDITION]; -- The caller has checked that the initial token is EXIT -- Error recovery: can raise Error_Resync function P_Exit_Statement return Node_Id is Exit_Node : Node_Id; -- Start of processing for P_Exit_Statement begin Exit_Node := New_Node (N_Exit_Statement, Token_Ptr); Scan; -- past EXIT if Token = Tok_Identifier then Set_Name (Exit_Node, P_Qualified_Simple_Name); elsif Style_Check then -- This EXIT has no name, so check that -- the innermost loop is unnamed too. Check_No_Exit_Name : for J in reverse 1 .. Scope.Last loop if Scopes (J).Etyp = E_Loop then if Present (Scopes (J).Labl) and then Comes_From_Source (Scopes (J).Labl) then -- Innermost loop in fact had a name, style check fails Style.No_Exit_Name (Scopes (J).Labl); end if; exit Check_No_Exit_Name; end if; end loop Check_No_Exit_Name; end if; if Token = Tok_When and then not Missing_Semicolon_On_When then Scan; -- past WHEN Set_Condition (Exit_Node, P_Condition); -- Allow IF instead of WHEN, giving error message elsif Token = Tok_If then T_When; Scan; -- past IF used in place of WHEN Set_Condition (Exit_Node, P_Expression_No_Right_Paren); end if; TF_Semicolon; return Exit_Node; end P_Exit_Statement; ------------------------- -- 5.8 Goto Statement -- ------------------------- -- GOTO_STATEMENT ::= goto label_NAME; -- The caller has checked that the initial token is GOTO (or TO in the -- error case where GO and TO were incorrectly separated). -- Error recovery: can raise Error_Resync function P_Goto_Statement return Node_Id is Goto_Node : Node_Id; begin Goto_Node := New_Node (N_Goto_Statement, Token_Ptr); Scan; -- past GOTO (or TO) Set_Name (Goto_Node, P_Qualified_Simple_Name_Resync); Append_Elmt (Goto_Node, Goto_List); if Token = Tok_When then Error_Msg_GNAT_Extension ("goto when statement"); Scan; -- past WHEN Mutate_Nkind (Goto_Node, N_Goto_When_Statement); Set_Condition (Goto_Node, P_Expression_No_Right_Paren); end if; TF_Semicolon; return Goto_Node; end P_Goto_Statement; --------------------------- -- Parse_Decls_Begin_End -- --------------------------- -- This function parses the construct: -- DECLARATIVE_PART -- begin -- HANDLED_SEQUENCE_OF_STATEMENTS -- end [NAME]; -- The caller has built the scope stack entry, and created the node to -- whose Declarations and Handled_Statement_Sequence fields are to be -- set. On return these fields are filled in (except in the case of a -- task body, where the handled statement sequence is optional, and may -- thus be Empty), and the scan is positioned past the End sequence. -- If the BEGIN is missing, then the parent node is used to help construct -- an appropriate missing BEGIN message. Possibilities for the parent are: -- N_Block_Statement declare block -- N_Entry_Body entry body -- N_Package_Body package body (begin part optional) -- N_Subprogram_Body procedure or function body -- N_Task_Body task body -- Note: in the case of a block statement, there is definitely a DECLARE -- present (because a Begin statement without a DECLARE is handled by the -- P_Begin_Statement procedure, which does not call Parse_Decls_Begin_End. -- Error recovery: cannot raise Error_Resync procedure Parse_Decls_Begin_End (Parent : Node_Id) is Body_Decl : Node_Id; Decls : List_Id; Parent_Nkind : Node_Kind; Spec_Node : Node_Id; HSS : Node_Id; procedure Missing_Begin (Msg : String); -- Called to post a missing begin message. In the normal case this is -- posted at the start of the current token. A special case arises when -- P_Declarative_Items has previously found a missing begin, in which -- case we replace the original error message. procedure Set_Null_HSS (Parent : Node_Id); -- Construct an empty handled statement sequence and install in Parent -- Leaves HSS set to reference the newly constructed statement sequence. ------------------- -- Missing_Begin -- ------------------- procedure Missing_Begin (Msg : String) is begin if Missing_Begin_Msg = No_Error_Msg then Error_Msg_BC (Msg); else Change_Error_Text (Missing_Begin_Msg, Msg); -- Purge any messages issued after than, since a missing begin -- can cause a lot of havoc, and it is better not to dump these -- cascaded messages on the user. Purge_Messages (Get_Location (Missing_Begin_Msg), Prev_Token_Ptr); end if; end Missing_Begin; ------------------ -- Set_Null_HSS -- ------------------ procedure Set_Null_HSS (Parent : Node_Id) is Null_Stm : Node_Id; begin Null_Stm := Make_Null_Statement (Token_Ptr); Set_Comes_From_Source (Null_Stm, False); HSS := Make_Handled_Sequence_Of_Statements (Token_Ptr, Statements => New_List (Null_Stm)); Set_Comes_From_Source (HSS, False); Set_Handled_Statement_Sequence (Parent, HSS); end Set_Null_HSS; -- Start of processing for Parse_Decls_Begin_End begin Decls := P_Declarative_Part; if Ada_Version = Ada_83 then Check_Later_Vs_Basic_Declarations (Decls, During_Parsing => True); end if; -- Here is where we deal with the case of IS used instead of semicolon. -- Specifically, if the last declaration in the declarative part is a -- subprogram body still marked as having a bad IS, then this is where -- we decide that the IS should really have been a semicolon and that -- the body should have been a declaration. Note that if the bad IS -- had turned out to be OK (i.e. a decent begin/end was found for it), -- then the Bad_Is_Detected flag would have been reset by now. Body_Decl := Last (Decls); if Present (Body_Decl) and then Nkind (Body_Decl) = N_Subprogram_Body and then Bad_Is_Detected (Body_Decl) then -- OK, we have the case of a bad IS, so we need to fix up the tree. -- What we have now is a subprogram body with attached declarations -- and a possible statement sequence. -- First step is to take the declarations that were part of the bogus -- subprogram body and append them to the outer declaration chain. -- In other words we append them past the body (which we will later -- convert into a declaration). Append_List (Declarations (Body_Decl), Decls); -- Now take the handled statement sequence of the bogus body and -- set it as the statement sequence for the outer construct. Note -- that it may be empty (we specially allowed a missing BEGIN for -- a subprogram body marked as having a bad IS -- see below). Set_Handled_Statement_Sequence (Parent, Handled_Statement_Sequence (Body_Decl)); -- Next step is to convert the old body node to a declaration node Spec_Node := Specification (Body_Decl); Change_Node (Body_Decl, N_Subprogram_Declaration); Set_Specification (Body_Decl, Spec_Node); -- Final step is to put the declarations for the parent where -- they belong, and then fall through the IF to scan out the -- END statements. Set_Declarations (Parent, Decls); -- This is the normal case (i.e. any case except the bad IS case) -- If we have a BEGIN, then scan out the sequence of statements, and -- also reset the expected column for the END to match the BEGIN. else Set_Declarations (Parent, Decls); if Token = Tok_Begin then if Style_Check then Style.Check_Indentation; end if; Error_Msg_Col := Scopes (Scope.Last).Ecol; if RM_Column_Check and then Token_Is_At_Start_Of_Line and then Start_Column /= Error_Msg_Col then Error_Msg_SC ("(style) BEGIN in wrong column, should be@"); else Scopes (Scope.Last).Ecol := Start_Column; end if; Scopes (Scope.Last).Sloc := Token_Ptr; Scan; -- past BEGIN Set_Handled_Statement_Sequence (Parent, P_Handled_Sequence_Of_Statements); -- No BEGIN present else Parent_Nkind := Nkind (Parent); -- A special check for the missing IS case. If we have a -- subprogram body that was marked as having a suspicious -- IS, and the current token is END, then we simply confirm -- the suspicion, and do not require a BEGIN to be present if Parent_Nkind = N_Subprogram_Body and then Token = Tok_End and then Scopes (Scope.Last).Etyp = E_Suspicious_Is then Scopes (Scope.Last).Etyp := E_Bad_Is; -- Otherwise BEGIN is not required for a package body, so we -- don't mind if it is missing, but we do construct a dummy -- one (so that we have somewhere to set End_Label). -- However if we have something other than a BEGIN which -- looks like it might be statements, then we signal a missing -- BEGIN for these cases as well. We define "something which -- looks like it might be statements" as a token other than -- END, EOF, or a token which starts declarations. elsif Parent_Nkind = N_Package_Body and then (Token = Tok_End or else Token = Tok_EOF or else Token in Token_Class_Declk) then Set_Null_HSS (Parent); -- These are cases in which a BEGIN is required and not present else Set_Null_HSS (Parent); -- Prepare to issue error message Error_Msg_Sloc := Scopes (Scope.Last).Sloc; Error_Msg_Node_1 := Scopes (Scope.Last).Labl; -- Now issue appropriate message if Parent_Nkind = N_Block_Statement then Missing_Begin ("missing BEGIN for DECLARE#!"); elsif Parent_Nkind = N_Entry_Body then Missing_Begin ("missing BEGIN for ENTRY#!"); elsif Parent_Nkind = N_Subprogram_Body then if Nkind (Specification (Parent)) = N_Function_Specification then Missing_Begin ("missing BEGIN for function&#!"); else Missing_Begin ("missing BEGIN for procedure&#!"); end if; -- The case for package body arises only when -- we have possible statement junk present. elsif Parent_Nkind = N_Package_Body then Missing_Begin ("missing BEGIN for package body&#!"); else pragma Assert (Parent_Nkind = N_Task_Body); Missing_Begin ("missing BEGIN for task body&#!"); end if; -- Here we pick up the statements after the BEGIN that -- should have been present but was not. We don't insist -- on statements being present if P_Declarative_Part had -- already found a missing BEGIN, since it might have -- swallowed a lone statement into the declarative part. if Missing_Begin_Msg /= No_Error_Msg and then Token = Tok_End then null; else Set_Handled_Statement_Sequence (Parent, P_Handled_Sequence_Of_Statements); end if; end if; end if; end if; -- Here with declarations and handled statement sequence scanned if Present (Handled_Statement_Sequence (Parent)) then End_Statements (Handled_Statement_Sequence (Parent)); else End_Statements; end if; -- We know that End_Statements removed an entry from the scope stack -- (because it is required to do so under all circumstances). We can -- therefore reference the entry it removed one past the stack top. -- What we are interested in is whether it was a case of a bad IS. -- We can't call Scopes here. if Scope.Table (Scope.Last + 1).Etyp = E_Bad_Is then Error_Msg -- CODEFIX ("|IS should be "";""", Scope.Table (Scope.Last + 1).S_Is); Set_Bad_Is_Detected (Parent, True); end if; end Parse_Decls_Begin_End; ------------------------- -- Set_Loop_Block_Name -- ------------------------- function Set_Loop_Block_Name (L : Character) return Name_Id is begin Name_Buffer (1) := L; Name_Buffer (2) := '_'; Name_Len := 2; Loop_Block_Count := Loop_Block_Count + 1; Add_Nat_To_Name_Buffer (Loop_Block_Count); return Name_Find; end Set_Loop_Block_Name; --------------- -- Then_Scan -- --------------- procedure Then_Scan is begin TF_Then; while Token = Tok_Then loop Error_Msg_SC -- CODEFIX ("redundant THEN"); TF_Then; end loop; if Token = Tok_And or else Token = Tok_Or then Error_Msg_SC ("unexpected logical operator"); Scan; -- past logical operator if (Prev_Token = Tok_And and then Token = Tok_Then) or else (Prev_Token = Tok_Or and then Token = Tok_Else) then Scan; end if; Discard_Junk_Node (P_Expression); end if; if Token = Tok_Then then Scan; end if; end Then_Scan; end Ch5;
leonhxx/pok
Ada
795
ads
-- POK header -- -- The following file is a part of the POK project. Any modification should -- be made according to the POK licence. You CANNOT use this file or a part -- of a file for your own project. -- -- For more information on the POK licence, please see our LICENCE FILE -- -- Please follow the coding guidelines described in doc/CODING_GUIDELINES -- -- Copyright (c) 2007-2021 POK team pragma No_Run_Time; with Interfaces.C; with APEX; use APEX; with APEX.Processes; use APEX.Processes; with APEX.Partitions; use APEX.Partitions; with APEX.Timing; use APEX.Timing; with APEX.Sampling_Ports; use APEX.Sampling_Ports; package Main is procedure Send; procedure Main; pragma Export (C, Main, "main"); end Main;
reznikmm/matreshka
Ada
4,812
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Db_Table_Representations_Elements; package Matreshka.ODF_Db.Table_Representations_Elements is type Db_Table_Representations_Element_Node is new Matreshka.ODF_Db.Abstract_Db_Element_Node and ODF.DOM.Db_Table_Representations_Elements.ODF_Db_Table_Representations with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Table_Representations_Element_Node; overriding function Get_Local_Name (Self : not null access constant Db_Table_Representations_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Db_Table_Representations_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Db_Table_Representations_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Db_Table_Representations_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Db.Table_Representations_Elements;
reznikmm/matreshka
Ada
4,191
ads
------------------------------------------------------------------------------ -- -- -- 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; with Engines.Contexts; with League.Strings; package Properties.Declarations.Ordinary_Type is function Code (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String; function Initialize (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String; function Is_Simple_Type (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Boolean_Property) return Boolean; function Alignment (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Integer_Property) return Integer; end Properties.Declarations.Ordinary_Type;
jwarwick/aoc_2020
Ada
1,389
adb
with AUnit.Assertions; use AUnit.Assertions; with Ada.Containers; use Ada.Containers; package body Day.Test is use Boarding_Pass_Vectors; procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); batch : constant Vector := load_batch("test1.txt"); len : constant Count_Type := length(batch); highest : constant Natural := highest_id(batch); begin Assert(len = 4, "Wrong number of boarding passes, expected 4, got " & Count_Type'IMAGE(len)); Assert(highest = 820, "Wrong highest id, expected 820, got " & Natural'IMAGE(highest)); end Test_Part1; procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); batch : constant Vector := load_batch("test1.txt"); len : constant Count_Type := length(batch); begin Assert(len = 4, "Wrong number of boarding passes, expected 4, got " & Count_Type'IMAGE(len)); end Test_Part2; function Name (T : Test) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Test Day package"); end Name; procedure Register_Tests (T : in out Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Part1'Access, "Test Part 1"); Register_Routine (T, Test_Part2'Access, "Test Part 2"); end Register_Tests; end Day.Test;
sungyeon/drake
Ada
5,462
adb
with Ada.Text_IO.Float_IO; with Ada.Text_IO.Formatting; package body Ada.Text_IO.Complex_IO is package Real_IO is new Float_IO (Complex_Types.Real); procedure Get_From_Field ( From : String; Item : out Complex_Types.Complex; Last : out Positive); procedure Get_From_Field ( From : String; Item : out Complex_Types.Complex; Last : out Positive) is Paren : Boolean; begin Formatting.Get_Tail (From, Last); Paren := From (Last) = '('; if Paren then Last := Last + 1; end if; Real_IO.Get (From (Last .. From'Last), Item.Re, Last); Formatting.Get_Tail (From (Last + 1 .. From'Last), Last); if From (Last) = ',' then Last := Last + 1; end if; Real_IO.Get (From (Last .. From'Last), Item.Im, Last); if Paren then Formatting.Get_Tail (From (Last + 1 .. From'Last), Last); if From (Last) /= ')' then raise Data_Error; end if; end if; end Get_From_Field; -- implementation procedure Get ( File : File_Type; Item : out Complex_Types.Complex; Width : Field := 0) is begin if Width /= 0 then declare S : String (1 .. Width); Last_1 : Natural; Last_2 : Natural; begin Formatting.Get_Field (File, S, Last_1); -- checking the predicate Get_From_Field (S (1 .. Last_1), Item, Last_2); if Last_2 /= Last_1 then raise Data_Error; end if; end; else declare S : constant String := Formatting.Get_Complex_Literal (File); -- checking the predicate Last : Natural; begin Get_From_Field (S, Item, Last); if Last /= S'Last then raise Data_Error; end if; end; end if; end Get; procedure Get ( Item : out Complex_Types.Complex; Width : Field := 0) is begin Get (Current_Input.all, Item, Width); end Get; procedure Put ( File : File_Type; Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is begin Put (File, '('); -- checking the predicate Real_IO.Put (File, Item.Re, Fore, Aft, Exp); Put (File, ','); Real_IO.Put (File, Item.Im, Fore, Aft, Exp); Put (File, ')'); end Put; procedure Put ( Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is begin Put (Current_Output.all, Item, Fore, Aft, Exp); end Put; procedure Overloaded_Get ( From : String; Item : out Complex_Types.Complex; Last : out Positive) renames Get_From_Field; procedure Overloaded_Get ( From : Wide_String; Item : out Complex_Types.Complex; Last : out Positive) is String_From : String (From'Range); begin for I in From'Range loop if Wide_Character'Pos (From (I)) < 16#80# then String_From (I) := Character'Val (Wide_Character'Pos (From (I))); else String_From (I) := Character'Val (16#1A#); -- substitute end if; end loop; Overloaded_Get (String_From, Item, Last); end Overloaded_Get; procedure Overloaded_Get ( From : Wide_Wide_String; Item : out Complex_Types.Complex; Last : out Positive) is String_From : String (From'Range); begin for I in From'Range loop if Wide_Wide_Character'Pos (From (I)) < 16#80# then String_From (I) := Character'Val (Wide_Wide_Character'Pos (From (I))); else String_From (I) := Character'Val (16#1A#); -- substitute end if; end loop; Overloaded_Get (String_From, Item, Last); end Overloaded_Get; procedure Overloaded_Put ( To : out String; Item : Complex_Types.Complex; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is Index : Natural; begin if To'Length < (Aft + Exp) * 2 + 7 then -- "(0.,0.)" raise Layout_Error; end if; To (To'First) := '('; Real_IO.Put (To (To'First + 1 .. To'Last), Index, Item.Re, Aft, Exp); Index := Index + 1; if Index > To'Last then raise Layout_Error; end if; To (Index) := ','; Real_IO.Put (To (Index + 1 .. To'Last - 1), Item.Im, Aft, Exp); To (To'Last) := ')'; end Overloaded_Put; procedure Overloaded_Put ( To : out Wide_String; Item : Complex_Types.Complex; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is String_To : String (To'Range); begin Overloaded_Put (String_To, Item, Aft, Exp); for I in To'Range loop To (I) := Wide_Character'Val (Character'Pos (String_To (I))); end loop; end Overloaded_Put; procedure Overloaded_Put ( To : out Wide_Wide_String; Item : Complex_Types.Complex; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is String_To : String (To'Range); begin Overloaded_Put (String_To, Item, Aft, Exp); for I in To'Range loop To (I) := Wide_Wide_Character'Val (Character'Pos (String_To (I))); end loop; end Overloaded_Put; end Ada.Text_IO.Complex_IO;
charlie5/cBound
Ada
1,395
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_depth_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_depth_iterator_t is -- Item -- type Item is record data : access xcb.xcb_depth_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_depth_iterator_t.Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_depth_iterator_t.Item, Element_Array => xcb.xcb_depth_iterator_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_depth_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_depth_iterator_t.Pointer, Element_Array => xcb.xcb_depth_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_depth_iterator_t;
sungyeon/drake
Ada
3,172
adb
package body Ada.Containers.Unbounded_Priority_Queues is use type Implementation.Node_Access; protected body Queue is procedure Do_Dequeue (Element : out Queue_Interfaces.Element_Type); procedure Do_Dequeue (Element : out Queue_Interfaces.Element_Type) is begin Element := First.Element; First := First.Next; if First = null then Last := null; end if; Current_Length := Current_Length - 1; end Do_Dequeue; -- implementation -- overriding entry Enqueue (New_Item : Queue_Interfaces.Element_Type) when True is New_Node : constant Implementation.Node_Access := new Implementation.Node'( Element => New_Item, Next => null); begin if First = null then First := New_Node; Last := New_Node; else declare The_Priority : constant Queue_Priority := Get_Priority (New_Node.Element); Previous : Implementation.Node_Access := First; begin if Before (The_Priority, Get_Priority (Previous.Element)) then -- insert at first New_Node.Next := First; First := New_Node; else loop if Previous.Next = null then -- insert at last Last.Next := New_Node; Last := New_Node; exit; elsif Before ( The_Priority, Get_Priority (Previous.Next.Element)) then -- insert at Previous.Next New_Node.Next := Previous.Next; Previous.Next := New_Node; exit; else Previous := Previous.Next; end if; end loop; end if; end; end if; Current_Length := Current_Length + 1; if Current_Length > Peak_Length then Peak_Length := Current_Length; end if; end Enqueue; -- overriding entry Dequeue (Element : out Queue_Interfaces.Element_Type) when First /= null is begin Do_Dequeue (Element); end Dequeue; procedure Dequeue_Only_High_Priority ( At_Least : Queue_Priority; Element : in out Queue_Interfaces.Element_Type; Success : out Boolean) is begin Success := First /= null and then not Before (At_Least, Get_Priority (First.Element)); if Success then Do_Dequeue (Element); end if; end Dequeue_Only_High_Priority; -- overriding function Current_Use return Count_Type is begin return Current_Length; end Current_Use; -- overriding function Peak_Use return Count_Type is begin return Peak_Length; end Peak_Use; end Queue; end Ada.Containers.Unbounded_Priority_Queues;
tum-ei-rcs/StratoX
Ada
3,754
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . A D D R E S S _ T O _ A C C E S S _ C O N V E R S I O N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ generic type Object (<>) is limited private; package System.Address_To_Access_Conversions with SPARK_Mode => On is pragma Preelaborate; pragma Compile_Time_Warning (Object'Unconstrained_Array, "Object is unconstrained array type" & ASCII.LF & "To_Pointer results may not have bounds"); type Object_Pointer is access all Object; for Object_Pointer'Size use Standard'Address_Size; pragma No_Strict_Aliasing (Object_Pointer); -- Strictly speaking, this routine should not be used to generate pointers -- to other than proper values of the proper type, but in practice, this -- is done all the time. This pragma stops the compiler from doing some -- optimizations that may cause unexpected results based on the assumption -- of no strict aliasing. function To_Pointer (Value : Address) return Object_Pointer; function To_Address (Value : Object_Pointer) return Address; pragma Import (Intrinsic, To_Pointer); pragma Import (Intrinsic, To_Address); end System.Address_To_Access_Conversions;
wiremoons/AdbT
Ada
1,448
adb
------------------------------------------------------------------------------- -- Program : adbt (Acronym DataBase Tool) -- -- Description : CLI tool to manage an SQLite database of acronyms. -- -- Author : Simon Rowe <[email protected]> -- -- License : MIT Open Source. -- ------------------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; -- local packages below: with Cmd_Flags; procedure AdbT is -------------------------- -- MAIN -------------------------- begin -- print info on how to compile a 'release' version pragma Debug (Put_Line (Standard_Error, "DEBUG: build a 'release' version with: gprclean && gprbuild -XBUILD=release")); -- check for any command line flags to execute if Cmd_Flags.Command_Line_Flags_Exist then Set_Exit_Status (Success); pragma Debug (Put_Line (Standard_Error, "DEBUG: Exit with 'success'.")); return; -- exit as flags found and executed else Put_Line (Standard_Error, "ERROR: no command line option selected. Exit."); Set_Exit_Status (Failure); -- failed as no database found pragma Debug (Put_Line (Standard_Error, "DEBUG: Exit with 'failure'.")); return; -- exit as nothing provided to execute end if; end AdbT;
charlie5/lace
Ada
245
ads
with float_Math; package box2d_Physics -- -- Provides an implementation of the physics interface using a binding to the Box2D C library. -- is pragma Pure; package Math renames float_Math; Error : exception; end box2d_Physics;
reznikmm/matreshka
Ada
4,671
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Xforms_List_Source_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Xforms_List_Source_Attribute_Node is begin return Self : Form_Xforms_List_Source_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Xforms_List_Source_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Xforms_List_Source_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Xforms_List_Source_Attribute, Form_Xforms_List_Source_Attribute_Node'Tag); end Matreshka.ODF_Form.Xforms_List_Source_Attributes;
reznikmm/matreshka
Ada
4,725
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Additional_Column_Statement_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Additional_Column_Statement_Attribute_Node is begin return Self : Db_Additional_Column_Statement_Attribute_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Additional_Column_Statement_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Additional_Column_Statement_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Additional_Column_Statement_Attribute, Db_Additional_Column_Statement_Attribute_Node'Tag); end Matreshka.ODF_Db.Additional_Column_Statement_Attributes;
AdaCore/langkit
Ada
7,130
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Containers; use Ada.Containers; with Ada.Containers.Hashed_Maps; with GNAT.String_Hash; with Langkit_Support.Text; use Langkit_Support.Text; with Langkit_Support.Vectors; -- This package provides a symbol table for text -- (:ada:ref:`Langkit_Support.Text.Text_Type`) identifiers. This is used in -- Langkit for the interning of symbols. -- -- The main interest is to: -- -- 1. Use less memory by interning strings. -- -- 2. Be faster when using the symbol as map keys for example, because hashing -- is faster. package Langkit_Support.Symbols is type Symbol_Table_Record is tagged private; type Symbol_Table is access all Symbol_Table_Record'Class; -- Represents a symbol table. The symbol table is the holder of the memory -- allocated for each symbol, and serves as a single access point if you -- want to find back an existing symbol. No_Symbol_Table : constant Symbol_Table; -- Value to use as a default for unallocated symbol tables type Symbol_Type is new Text_Cst_Access; -- Main symbol type. -- -- .. warning:: For usability reasons, we use the access to the string as a -- symbol type. This is very convenient because you can access the text -- of a symbol without a reference to the symbol table, but is also -- unsafe, because if the symbol table has been freed, the symbol will -- be a dangling pointer. pragma No_Strict_Aliasing (Symbol_Type); function Image (S : Symbol_Type) return Text_Type; -- Return the text associated to this symbol function Image (S : Symbol_Type; With_Quotes : Boolean := False) return String; -- Return the text associated with this symbol, as a string type Thin_Symbol is private; -- Thin symbol type. This type is a bit heavier to use than the main symbol -- type, because you need a reference to the symbol table to get the text -- of the symbol, but: -- -- 1. It consumes less memory (which is the primary reason it is used in -- Langkit). -- -- 2. It is safer, as long as you never store :ada:ref:`Symbol_Type` -- instances returned by :ada:ref:`Get_Symbol` you should be safe. -- -- .. TODO: See if we can get rid of the intermediate operation that -- returns a ``Symbol_Type``. No_Thin_Symbol : constant Thin_Symbol; function Get_Symbol (Self : Symbol_Table; TS : Thin_Symbol) return Symbol_Type; -- Return the Symbol for this :ada:ref:`Thin_Symbol` instance function Create_Symbol_Table return Symbol_Table; -- Allocate a new symbol table and return it function Find (ST : Symbol_Table; T : Text_Type; Create : Boolean := True) return Thin_Symbol with Inline; -- Look for an entry for the ``T`` text in the ``ST`` symbol table. If -- there is such an entry, return it. Otherwise, create it and return it if -- ``Create`` is true. Otherwise, return ``null``. -- -- Non-null returned accesses are guaranteed to be the same if the text -- passed in was the same. function Find (ST : Symbol_Table; T : Text_Type; Create : Boolean := True) return Symbol_Type is (Get_Symbol (ST, Find (ST, T, Create))) with Inline; -- Overload of :ada:ref:`Find` which returns a :ada:ref:`Symbol_Type` -- directly. procedure Destroy (ST : in out Symbol_Table); -- Deallocate a symbol table and all the text returned by the corresponding -- calls to Find. function Hash (ST : Symbol_Type) return Hash_Type; -- Default hash function for symbols. -- -- .. warning:: It assumes that you don't mix symbols from different symbol -- tables, but doesn't verify it! ----------------------------- -- Symbol canonicalization -- ----------------------------- -- All languages do not have the same rules to determine whether two -- identifiers are equivalent: some languages, like C, consider that they -- are equivalent when they are strictly equal in sources, whereas other -- languages, like Ada, consider that they are equivalent if the only thing -- that changes is their casing (``foo`` is treated as the same as -- ``Foo``). -- -- In the context of symbol tables, what we call here "symbolization" is a -- way to implement these various criteria: symbolization turns an -- identifier into a "canonical symbol", which is then used as the symbol -- for this identifier in symbol tables. Two identifiers can have different -- texts but still have the same canonical symbol: in this case they get -- the same symbol value in a symbol table, and thus refer to the same -- entities in lexical environments. -- -- For instance, in Ada, decoding brackets and converting to lower case is -- appropriate, so that the following identifiers all get the same symbol: -- ``Foo`` ``foo`` and ``fo["6f"]``. type Symbolization_Result (Success : Boolean; Size : Natural) is record case Success is when True => Symbol : Text_Type (1 .. Size); -- Text for successfully symbolized identifiers when False => Error_Message : Text_Type (1 .. Size); -- Message describing why symbolization failed end case; end record; -- Holder for results of the symbolization process, conditioned by whether -- this process was successful. function Create_Symbol (Name : Text_Type) return Symbolization_Result is ((Success => True, Size => Name'Length, Symbol => Name)); -- Shortcut to create successful symbolization results function Create_Error (Message : Text_Type) return Symbolization_Result is ((Success => False, Size => Message'Length, Error_Message => Message)); -- Shortcut to create failed symbolization results function Fold_Case (Name : Text_Type) return Symbolization_Result; -- Convert ``Name`` to lowercase (cannot fail). -- -- This is the default symbol canonicalizer when case insensitivity is -- enabled. private type Thin_Symbol is mod 2 ** 32; function Hash is new GNAT.String_Hash.Hash (Char_Type => Wide_Wide_Character, Key_Type => Text_Type, Hash_Type => Ada.Containers.Hash_Type); function String_Hash (T : Symbol_Type) return Ada.Containers.Hash_Type is (Hash (T.all)); function Key_Equal (L, R : Symbol_Type) return Boolean is (L.all = R.all); package Maps is new Ada.Containers.Hashed_Maps (Key_Type => Symbol_Type, Element_Type => Thin_Symbol, Hash => String_Hash, Equivalent_Keys => Key_Equal, "=" => "="); package Symbol_Vectors is new Langkit_Support.Vectors (Symbol_Type); type Symbol_Table_Record is tagged record Symbols_Map : Maps.Map; Symbols : Symbol_Vectors.Vector; end record; No_Symbol_Table : constant Symbol_Table := null; No_Thin_Symbol : constant Thin_Symbol := 0; end Langkit_Support.Symbols;
zertovitch/excel-writer
Ada
2,935
adb
------------------------------------------------------------------------------ -- File: CSV2XLS.adb -- Description: Converts a CSV (text with Comma Separated Values) input -- into an Excel file. You can specify the separator. -- E.g. If you open in Excel a CSV with semicolons as -- separators on a PC with comma being the separator, -- and then apply "Text to columns", the eventual commas in -- the text will already have been used as separators and -- you will end up with a total mess. CSV2XLS prevents this -- issue. -- Syntax: csv2xls {option} <data.csv -- or csv2xls {option} data.csv -- Options: -- -c : comma is the separator -- -s : semicolon is the separator -- -t : tab is the separator -- -f : freeze top row (header line) -- Created: 29-Apr-2014 -- Author: Gautier de Montmollin ------------------------------------------------------------------------------ with CSV; with Excel_Out; with Ada.Command_Line, Ada.Directories, Ada.Text_IO, Ada.Strings.Fixed; procedure CSV2XLS is use Ada.Command_Line, Ada.Directories, Ada.Text_IO, Ada.Strings, Excel_Out; input : File_Type; xl : Excel_Out_File; first : Boolean := True; separator : Character := ','; -- ';', ',' or ASCII.HT begin if Argument_Count = 0 then Create (xl, "From_CSV.xls"); else declare csv_file_name : constant String := Argument (Argument_Count); ext : constant String := Extension (csv_file_name); begin Open (input, In_File, csv_file_name); Set_Input (input); Create (xl, csv_file_name (csv_file_name'First .. csv_file_name'Last - ext'Length) & "xls"); end; end if; -- -- Process options -- for i in 1 .. Argument_Count loop if Argument (i)'Length = 2 and then Argument (i)(1) = '-' then case Argument (i)(2) is when 'c' => separator := ','; when 's' => separator := ';'; when 't' => separator := ASCII.HT; when 'f' => Freeze_Top_Row (xl); when others => null; end case; end if; end loop; -- -- Process the CSV file -- while not End_Of_File loop declare line : constant String := Get_Line; bds : constant CSV.Fields_Bounds := CSV.Get_Bounds (line, separator); begin if first then first := False; end if; for i in bds'Range loop Put (xl, Ada.Strings.Fixed.Trim (CSV.Extract (line, bds, i), Both)); end loop; end; New_Line (xl); end loop; Close (xl); if Is_Open (input) then Close (input); end if; end CSV2XLS;
onox/orka
Ada
1,389
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.Transforms.SIMD_Vectors; with Orka.SIMD.SSE.Singles.Arithmetic; with Orka.SIMD.SSE.Singles.Math; with Orka.SIMD.SSE3.Singles.Arithmetic; with Orka.SIMD.SSE4_1.Singles.Compare; package Orka.Transforms.Singles.Vectors is new Orka.Transforms.SIMD_Vectors (Float_32, SIMD.SSE.Singles.m128, SIMD.SSE.Singles.Arithmetic."*", SIMD.SSE.Singles.Arithmetic."+", SIMD.SSE.Singles.Arithmetic."-", SIMD.SSE.Singles.Arithmetic."-", SIMD.SSE.Singles.Arithmetic."abs", SIMD.SSE3.Singles.Arithmetic.Sum, SIMD.SSE.Singles.Arithmetic.Divide_Or_Zero, SIMD.SSE.Singles.Math.Reciprocal_Sqrt, SIMD.SSE.Singles.Math.Cross_Product, SIMD.SSE4_1.Singles.Compare.Is_Equal); pragma Pure (Orka.Transforms.Singles.Vectors);
onox/orka
Ada
2,391
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2022 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.SIMD.SSE2.Longs.Shift is pragma Pure; function Shift_Bits_Left_Zeros (Elements, Bits : m128l) return m128l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllq128"; -- Shift each element to the left by the given amount of bits from the -- first Double of the Bits register function Shift_Bits_Right_Zeros (Elements, Bits : m128l) return m128l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlq128"; -- Shift each element to the right by the given amount of bits from the -- first Double of the Bits register, shifting in zeros ---------------------------------------------------------------------------- type Bits_Count is new Integer range 1 .. 32; function Shift_Bits_Left_Zeros (Elements : m128l; Bits : Bits_Count) return m128l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psllqi128"; -- Shift each element to the left by the given amount of bits, shifting in zeros function Shift_Bits_Right_Zeros (Elements : m128l; Bits : Bits_Count) return m128l with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrlqi128"; -- Shift each element to the right by the given amount of bits, shifting in zeros ---------------------------------------------------------------------------- function Shift_Elements_Left_Zeros (Elements : m128l) return m128l with Inline_Always; -- Shift each element to the left by one element, shifting in zeros function Shift_Elements_Right_Zeros (Elements : m128l) return m128l with Inline_Always; -- Shift each element to the right by one element, shifting in zeros end Orka.SIMD.SSE2.Longs.Shift;
jrmarino/AdaBase
Ada
532
ads
-- Used for all testcases for MySQL driver with AdaBase.Driver.Base.PostgreSQL; with AdaBase.Statement.Base.PostgreSQL; package Connect is -- All specific drivers renamed to "Database_Driver" subtype Database_Driver is AdaBase.Driver.Base.PostgreSQL.PostgreSQL_Driver; subtype Stmt_Type is AdaBase.Statement.Base.PostgreSQL.PostgreSQL_statement; subtype Stmt_Type_access is AdaBase.Statement.Base.PostgreSQL.PostgreSQL_statement_access; DR : Database_Driver; procedure connect_database; end Connect;
onrik/Amass
Ada
499
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 = "ArchiveIt" type = "archive" function start() setratelimit(1) end function vertical(ctx, domain) crawl(ctx, buildurl(domain), 5) end function resolved(ctx, name, domain, records) crawl(ctx, buildurl(name), 5) end function buildurl(domain) return "https://wayback.archive-it.org/all/" .. os.date("%Y") .. "/" .. domain end
Statkus/json-ada
Ada
26,967
adb
-- 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 Ahven; use Ahven; with JSON.Parsers; with JSON.Streams; with JSON.Types; package body Test_Parsers is package Types is new JSON.Types (Long_Integer, Long_Float); package Parsers is new JSON.Parsers (Types, Check_Duplicate_Keys => True); overriding procedure Initialize (T : in out Test) is begin T.Set_Name ("Parsers"); T.Add_Test_Routine (Test_True_Text'Access, "Parse text 'true'"); T.Add_Test_Routine (Test_False_Text'Access, "Parse text 'false'"); T.Add_Test_Routine (Test_Null_Text'Access, "Parse text 'null'"); T.Add_Test_Routine (Test_Empty_String_Text'Access, "Parse text '""""'"); T.Add_Test_Routine (Test_Non_Empty_String_Text'Access, "Parse text '""test""'"); T.Add_Test_Routine (Test_Number_String_Text'Access, "Parse text '""12.34""'"); T.Add_Test_Routine (Test_Integer_Number_Text'Access, "Parse text '42'"); T.Add_Test_Routine (Test_Float_Number_Text'Access, "Parse text '3.14'"); T.Add_Test_Routine (Test_Empty_Array_Text'Access, "Parse text '[]'"); T.Add_Test_Routine (Test_One_Element_Array_Text'Access, "Parse text '[""test""]'"); T.Add_Test_Routine (Test_Multiple_Elements_Array_Text'Access, "Parse text '[3.14, true]'"); T.Add_Test_Routine (Test_Array_Iterable'Access, "Iterate over '[false, ""test"", 0.271e1]'"); T.Add_Test_Routine (Test_Multiple_Array_Iterable'Access, "Iterate over '{""foo"":[1, ""2""],""bar"":[0.271e1]}'"); T.Add_Test_Routine (Test_Empty_Object_Text'Access, "Parse text '{}'"); T.Add_Test_Routine (Test_One_Member_Object_Text'Access, "Parse text '{""foo"":""bar""}'"); T.Add_Test_Routine (Test_Multiple_Members_Object_Text'Access, "Parse text '{""foo"":1,""bar"":2}'"); T.Add_Test_Routine (Test_Object_Iterable'Access, "Iterate over '{""foo"":1,""bar"":2}'"); T.Add_Test_Routine (Test_Array_Object_Array'Access, "Parse text '[{""foo"":[true, 42]}]'"); T.Add_Test_Routine (Test_Object_Array_Object'Access, "Parse text '{""foo"":[null, {""bar"": 42}]}'"); T.Add_Test_Routine (Test_Object_No_Array'Access, "Test getting array from text '{}'"); T.Add_Test_Routine (Test_Object_No_Object'Access, "Test getting object from text '{}'"); -- Exceptions T.Add_Test_Routine (Test_Array_No_Value_Separator_Exception'Access, "Reject text '[3.14""test""]'"); T.Add_Test_Routine (Test_Array_No_End_Array_Exception'Access, "Reject text '[true'"); T.Add_Test_Routine (Test_No_EOF_After_Array_Exception'Access, "Reject text '[1]2'"); T.Add_Test_Routine (Test_Empty_Text_Exception'Access, "Reject text ''"); T.Add_Test_Routine (Test_Object_No_Value_Separator_Exception'Access, "Reject text '{""foo"":1""bar"":2}'"); T.Add_Test_Routine (Test_Object_No_Name_Separator_Exception'Access, "Reject text '{""foo"",true}'"); T.Add_Test_Routine (Test_Object_Key_No_String_Exception'Access, "Reject text '{42:true}'"); T.Add_Test_Routine (Test_Object_No_Second_Member_Exception'Access, "Reject text '{""foo"":true,}'"); T.Add_Test_Routine (Test_Object_Duplicate_Keys_Exception'Access, "Reject text '{""foo"":1,""foo"":2}'"); T.Add_Test_Routine (Test_Object_No_Value_Exception'Access, "Reject text '{""foo"":}'"); T.Add_Test_Routine (Test_Object_No_End_Object_Exception'Access, "Reject text '{""foo"":true'"); T.Add_Test_Routine (Test_No_EOF_After_Object_Exception'Access, "Reject text '{""foo"":true}[true]'"); end Initialize; use Types; procedure Test_True_Text is Text : aliased String := "true"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Boolean_Kind, "Not a boolean"); Assert (Value.Value, "Expected boolean value to be True"); end Test_True_Text; procedure Test_False_Text is Text : aliased String := "false"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Boolean_Kind, "Not a boolean"); Assert (not Value.Value, "Expected boolean value to be False"); end Test_False_Text; procedure Test_Null_Text is Text : aliased String := "null"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Null_Kind, "Not a null"); end Test_Null_Text; procedure Test_Empty_String_Text is Text : aliased String := """"""; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = String_Kind, "Not a string"); Assert (Value.Value = "", "String value not empty"); end Test_Empty_String_Text; procedure Test_Non_Empty_String_Text is Text : aliased String := """test"""; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = String_Kind, "Not a string"); Assert (Value.Value = "test", "String value not equal to 'test'"); end Test_Non_Empty_String_Text; procedure Test_Number_String_Text is Text : aliased String := """12.34"""; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = String_Kind, "Not a string"); Assert (Value.Value = "12.34", "String value not equal to 12.34''"); end Test_Number_String_Text; procedure Test_Integer_Number_Text is Text : aliased String := "42"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Integer_Kind, "Not an integer"); Assert (Value.Value = 42, "Integer value not equal to 42"); end Test_Integer_Number_Text; procedure Test_Float_Number_Text is Text : aliased String := "3.14"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Float_Kind, "Not a float"); Assert (Value.Value = 3.14, "Float value not equal to 3.14"); end Test_Float_Number_Text; procedure Test_Empty_Array_Text is Text : aliased String := "[]"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Array_Kind, "Not an array"); Assert (Value.Length = 0, "Expected array to be empty"); end Test_Empty_Array_Text; procedure Test_One_Element_Array_Text is Text : aliased String := "[""test""]"; String_Value_Message : constant String := "Expected string at index 1 to be equal to 'test'"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Array_Kind, "Not an array"); Assert (Value.Length = 1, "Expected length of array to be 1, got " & Value.Length'Image); begin Assert (Value.Get (1).Value = "test", String_Value_Message); exception when Constraint_Error => Fail ("Could not get string value at index 1"); end; end Test_One_Element_Array_Text; procedure Test_Multiple_Elements_Array_Text is Text : aliased String := "[3.14, true]"; Float_Value_Message : constant String := "Expected float at index 1 to be equal to 3.14"; Boolean_Value_Message : constant String := "Expected boolean at index 2 to be True"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Array_Kind, "Not an array"); Assert (Value.Length = 2, "Expected length of array to be 2"); begin Assert (Value.Get (1).Value = 3.14, Float_Value_Message); exception when Constraint_Error => Fail ("Could not get float value at index 1"); end; begin Assert (Value.Get (2).Value, Boolean_Value_Message); exception when Constraint_Error => Fail ("Could not get boolean value at index 2"); end; end Test_Multiple_Elements_Array_Text; procedure Test_Array_Iterable is Text : aliased String := "[false, ""test"", 0.271e1]"; Iterations_Message : constant String := "Unexpected number of iterations"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Array_Kind, "Not an array"); Assert (Value.Length = 3, "Expected length of array to be 3"); declare Iterations : Natural := 0; begin for Element of Value loop Iterations := Iterations + 1; if Iterations = 1 then Assert (Element.Kind = Boolean_Kind, "Not a boolean"); Assert (not Element.Value, "Expected boolean value to be False"); elsif Iterations = 2 then Assert (Element.Kind = String_Kind, "Not a string"); Assert (Element.Value = "test", "Expected string value to be 'test'"); elsif Iterations = 3 then Assert (Element.Kind = Float_Kind, "Not a float"); Assert (Element.Value = 2.71, "Expected float value to be 2.71"); end if; end loop; Assert (Iterations = Value.Length, Iterations_Message); end; end Test_Array_Iterable; procedure Test_Multiple_Array_Iterable is Text : aliased String := "{""foo"":[1, ""2""],""bar"":[0.271e1]}"; Iterations_Message : constant String := "Unexpected number of iterations"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 2, "Expected length of object to be 2"); declare Iterations : Natural := 0; begin for Element of Value.Get ("foo") loop Iterations := Iterations + 1; if Iterations = 1 then Assert (Element.Kind = Integer_Kind, "Not an integer"); Assert (Element.Value = 1, "Expected integer value to be 1"); elsif Iterations = 2 then Assert (Element.Kind = String_Kind, "Not a string"); Assert (Element.Value = "2", "Expected string value to be '2'"); end if; end loop; Assert (Iterations = Value.Get ("foo").Length, Iterations_Message); end; declare Iterations : Natural := 0; begin for Element of Value.Get ("bar") loop Iterations := Iterations + 1; if Iterations = 1 then Assert (Element.Kind = Float_Kind, "Not a float"); Assert (Element.Value = 2.71, "Expected float value to be 2.71"); end if; end loop; Assert (Iterations = Value.Get ("bar").Length, Iterations_Message); end; end Test_Multiple_Array_Iterable; procedure Test_Empty_Object_Text is Text : aliased String := "{}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 0, "Expected object to be empty"); end Test_Empty_Object_Text; procedure Test_One_Member_Object_Text is Text : aliased String := "{""foo"":""bar""}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 1, "Expected length of object to be 1"); Assert (Value.Get ("foo").Value = "bar", "Expected string value of 'foo' to be 'bar'"); end Test_One_Member_Object_Text; procedure Test_Multiple_Members_Object_Text is Text : aliased String := "{""foo"":1,""bar"":2}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 2, "Expected length of object to be 2"); Assert (Value.Get ("foo").Value = 1, "Expected integer value of 'foo' to be 1"); Assert (Value.Get ("bar").Value = 2, "Expected integer value of 'bar' to be 2"); end Test_Multiple_Members_Object_Text; procedure Test_Object_Iterable is Text : aliased String := "{""foo"":1,""bar"":2}"; Iterations_Message : constant String := "Unexpected number of iterations"; All_Keys_Message : constant String := "Did not iterate over all expected keys"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 2, "Expected length of object to be 2"); declare Iterations : Natural := 0; Retrieved_Foo : Boolean := False; Retrieved_Bar : Boolean := False; begin for Key of Value loop Iterations := Iterations + 1; if Iterations in 1 .. 2 then Assert (Key.Kind = String_Kind, "Not String"); Assert (Key.Value in "foo" | "bar", "Expected string value to be equal to 'foo' or 'bar'"); Retrieved_Foo := Retrieved_Foo or Key.Value = "foo"; Retrieved_Bar := Retrieved_Bar or Key.Value = "bar"; end if; end loop; Assert (Iterations = Value.Length, Iterations_Message); Assert (Retrieved_Foo and Retrieved_Bar, All_Keys_Message); end; end Test_Object_Iterable; procedure Test_Array_Object_Array is Text : aliased String := "[{""foo"":[true, 42]}]"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Array_Kind, "Not an array"); Assert (Value.Length = 1, "Expected length of array to be 1"); begin declare Object : constant JSON_Value := Value.Get (1); begin Assert (Object.Length = 1, "Expected length of object to be 1"); declare Array_Value : constant JSON_Value := Object.Get ("foo"); begin Assert (Array_Value.Length = 2, "Expected length of array 'foo' to be 2"); Assert (Array_Value.Get (2).Value = 42, "Expected integer value at index 2 to be 42"); end; exception when Constraint_Error => Fail ("Value of 'foo' not an array"); end; exception when Constraint_Error => Fail ("First element in array not an object"); end; end Test_Array_Object_Array; procedure Test_Object_Array_Object is Text : aliased String := "{""foo"":[null, {""bar"": 42}]}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin Assert (Value.Kind = Object_Kind, "Not an object"); Assert (Value.Length = 1, "Expected length of object to be 1"); begin declare Array_Value : constant JSON_Value := Value.Get ("foo"); begin Assert (Array_Value.Length = 2, "Expected length of array 'foo' to be 2"); declare Object : constant JSON_Value := Array_Value.Get (2); begin Assert (Object.Length = 1, "Expected length of object to be 1"); declare Integer_Value : constant JSON_Value := Object.Get ("bar"); begin Assert (Integer_Value.Value = 42, "Expected integer value of 'bar' to be 42"); end; exception when Constraint_Error => Fail ("Element 'bar' in object not an integer"); end; exception when Constraint_Error => Fail ("Value of index 2 not an object"); end; exception when Constraint_Error => Fail ("Element 'foo' in object not an array"); end; end Test_Object_Array_Object; procedure Test_Object_No_Array is Text : aliased String := "{}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin begin declare Object : JSON_Value := Value.Get ("foo"); pragma Unreferenced (Object); begin Fail ("Expected Constraint_Error"); end; exception when Constraint_Error => null; end; begin declare Object : constant JSON_Value := Value.Get_Array_Or_Empty ("foo"); begin Assert (Object.Length = 0, "Expected empty array"); end; exception when Constraint_Error => Fail ("Unexpected Constraint_Error"); end; end Test_Object_No_Array; procedure Test_Object_No_Object is Text : aliased String := "{}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; Value : constant JSON_Value := Parsers.Parse (Stream, Allocator); begin begin declare Object : JSON_Value := Value.Get ("foo"); pragma Unreferenced (Object); begin Fail ("Expected Constraint_Error"); end; exception when Constraint_Error => null; end; begin declare Object : constant JSON_Value := Value.Get_Object_Or_Empty ("foo"); begin Assert (Object.Length = 0, "Expected empty object"); end; exception when Constraint_Error => Fail ("Unexpected Constraint_Error"); end; end Test_Object_No_Object; procedure Test_Empty_Text_Exception is Text : aliased String := ""; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Empty_Text_Exception; procedure Test_Array_No_Value_Separator_Exception is Text : aliased String := "[3.14""test""]"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Array_No_Value_Separator_Exception; procedure Test_Array_No_End_Array_Exception is Text : aliased String := "[true"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Array_No_End_Array_Exception; procedure Test_No_EOF_After_Array_Exception is Text : aliased String := "[1]2"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_No_EOF_After_Array_Exception; procedure Test_Object_No_Value_Separator_Exception is Text : aliased String := "{""foo"":1""bar"":2}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_No_Value_Separator_Exception; procedure Test_Object_No_Name_Separator_Exception is Text : aliased String := "{""foo"",true}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_No_Name_Separator_Exception; procedure Test_Object_Key_No_String_Exception is Text : aliased String := "{42:true}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_Key_No_String_Exception; procedure Test_Object_No_Second_Member_Exception is Text : aliased String := "{""foo"":true,}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_No_Second_Member_Exception; procedure Test_Object_Duplicate_Keys_Exception is Text : aliased String := "{""foo"":1,""foo"":2}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Constraint_Error"); end; exception when Constraint_Error => null; end Test_Object_Duplicate_Keys_Exception; procedure Test_Object_No_Value_Exception is Text : aliased String := "{""foo"":}"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_No_Value_Exception; procedure Test_Object_No_End_Object_Exception is Text : aliased String := "{""foo"":true"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_Object_No_End_Object_Exception; procedure Test_No_EOF_After_Object_Exception is Text : aliased String := "{""foo"":true}[true]"; Stream : JSON.Streams.Stream'Class := JSON.Streams.Create_Stream (Text'Access); Allocator : Types.Memory_Allocator; begin declare Value : JSON_Value := Parsers.Parse (Stream, Allocator); pragma Unreferenced (Value); begin Fail ("Expected Parse_Error"); end; exception when Parsers.Parse_Error => null; end Test_No_EOF_After_Object_Exception; end Test_Parsers;
Tim-Tom/project-euler
Ada
795
adb
with Ada.Text_IO; package body Problem_71 is package IO renames Ada.Text_IO; procedure Solve is -- This problem is obviously pertaining to mediants, stern-brocot trees, and farey sequences. -- Specifically since we're doing constrained sequences, we're dealing with farey and we -- basically want to keep taking the mediant between two numbers over and over again until we -- get a denominator larger than our target. max : constant Integer := 1_000_000; a : Integer := 0; b : Integer := 1; c : constant Integer := 1; d : constant Integer := 3; begin while max - d > b loop a := a + c; b := b + d; end loop; IO.Put_Line(Integer'Image(a) & " / " & Integer'Image(b)); end Solve; end Problem_71;
AdaCore/libadalang
Ada
16,370
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . V E C T O R S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2018, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- In particular, you can freely distribute your programs built with the -- -- GNAT Pro compiler, including any required library run-time units, using -- -- any licensing terms of your choosing. See the AdaCore Software License -- -- for full details. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Iterator_Interfaces; with Ada.Containers.Helpers; private with Ada.Finalization; private with Ada.Streams; generic type Index_Type is range <>; type Element_Type is private; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Vectors is type Hash_Type is mod 2**32; type Count_Type is range 0 .. 2**31 - 1; Capacity_Error : exception; subtype Extended_Index is Index_Type'Base range Index_Type'First - 1 .. Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1; No_Index : constant Extended_Index := Extended_Index'First; type Vector is tagged private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; type Cursor is private; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package Vector_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); Empty_Vector : constant Vector; overriding function "=" (Left, Right : Vector) return Boolean; function To_Vector (Length : Count_Type) return Vector; function To_Vector (New_Item : Element_Type; Length : Count_Type) return Vector; function "&" (Left, Right : Vector) return Vector; function "&" (Left : Vector; Right : Element_Type) return Vector; function "&" (Left : Element_Type; Right : Vector) return Vector; function "&" (Left, Right : Element_Type) return Vector; function Capacity (Container : Vector) return Count_Type; procedure Reserve_Capacity (Container : in out Vector; Capacity : Count_Type); function Length (Container : Vector) return Count_Type; procedure Set_Length (Container : in out Vector; Length : Count_Type); function Is_Empty (Container : Vector) return Boolean; procedure Clear (Container : in out Vector); function To_Cursor (Container : Vector; Index : Extended_Index) return Cursor; function To_Index (Position : Cursor) return Extended_Index; function Element (Container : Vector; Index : Index_Type) return Element_Type; function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out Vector; Index : Index_Type; New_Item : Element_Type); procedure Replace_Element (Container : in out Vector; Position : Cursor; New_Item : Element_Type); procedure Query_Element (Container : Vector; Index : Index_Type; Process : not null access procedure (Element : Element_Type)); procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)); procedure Update_Element (Container : in out Vector; Index : Index_Type; Process : not null access procedure (Element : in out Element_Type)); procedure Update_Element (Container : in out Vector; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased Vector; Position : Cursor) return Constant_Reference_Type; pragma Inline (Constant_Reference); function Reference (Container : aliased in out Vector; Position : Cursor) return Reference_Type; pragma Inline (Reference); function Constant_Reference (Container : aliased Vector; Index : Index_Type) return Constant_Reference_Type; pragma Inline (Constant_Reference); function Reference (Container : aliased in out Vector; Index : Index_Type) return Reference_Type; pragma Inline (Reference); procedure Assign (Target : in out Vector; Source : Vector); function Copy (Source : Vector; Capacity : Count_Type := 0) return Vector; procedure Move (Target : in out Vector; Source : in out Vector); procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Vector); procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Vector); procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Vector; Position : out Cursor); procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Element_Type; Count : Count_Type := 1); procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1); procedure Insert (Container : in out Vector; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1); procedure Insert (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1); procedure Insert (Container : in out Vector; Before : Cursor; Position : out Cursor; Count : Count_Type := 1); procedure Prepend (Container : in out Vector; New_Item : Vector); procedure Prepend (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1); procedure Append (Container : in out Vector; New_Item : Vector); procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1); procedure Insert_Space (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1); procedure Insert_Space (Container : in out Vector; Before : Cursor; Position : out Cursor; Count : Count_Type := 1); procedure Delete (Container : in out Vector; Index : Extended_Index; Count : Count_Type := 1); procedure Delete (Container : in out Vector; Position : in out Cursor; Count : Count_Type := 1); procedure Delete_First (Container : in out Vector; Count : Count_Type := 1); procedure Delete_Last (Container : in out Vector; Count : Count_Type := 1); procedure Reverse_Elements (Container : in out Vector); procedure Swap (Container : in out Vector; I, J : Index_Type); procedure Swap (Container : in out Vector; I, J : Cursor); function First_Index (Container : Vector) return Index_Type; function First (Container : Vector) return Cursor; function First_Element (Container : Vector) return Element_Type; function Last_Index (Container : Vector) return Extended_Index; function Last (Container : Vector) return Cursor; function Last_Element (Container : Vector) return Element_Type; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Previous (Position : Cursor) return Cursor; procedure Previous (Position : in out Cursor); function Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index; function Find (Container : Vector; Item : Element_Type; Position : Cursor := No_Element) return Cursor; function Reverse_Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'Last) return Extended_Index; function Reverse_Find (Container : Vector; Item : Element_Type; Position : Cursor := No_Element) return Cursor; function Contains (Container : Vector; Item : Element_Type) return Boolean; procedure Iterate (Container : Vector; Process : not null access procedure (Position : Cursor)); procedure Reverse_Iterate (Container : Vector; Process : not null access procedure (Position : Cursor)); function Iterate (Container : Vector) return Vector_Iterator_Interfaces.Reversible_Iterator'Class; function Iterate (Container : Vector; Start : Cursor) return Vector_Iterator_Interfaces.Reversible_Iterator'Class; generic with function "<" (Left, Right : Element_Type) return Boolean is <>; package Generic_Sorting is function Is_Sorted (Container : Vector) return Boolean; procedure Sort (Container : in out Vector); procedure Merge (Target : in out Vector; Source : in out Vector); end Generic_Sorting; private pragma Inline (Append); pragma Inline (First_Index); pragma Inline (Last_Index); pragma Inline (Element); pragma Inline (First_Element); pragma Inline (Last_Element); pragma Inline (Query_Element); pragma Inline (Update_Element); pragma Inline (Replace_Element); pragma Inline (Is_Empty); pragma Inline (Contains); pragma Inline (Next); pragma Inline (Previous); use Ada.Containers.Helpers; package Implementation is new Generic_Implementation; use Implementation; type Elements_Array is array (Index_Type range <>) of aliased Element_Type; function "=" (L, R : Elements_Array) return Boolean is abstract; type Elements_Type (Last : Extended_Index) is limited record EA : Elements_Array (Index_Type'First .. Last); end record; type Elements_Access is access all Elements_Type; use Ada.Finalization; use Ada.Streams; type Vector is new Controlled with record Elements : Elements_Access := null; Last : Extended_Index := No_Index; TC : aliased Tamper_Counts; end record; overriding procedure Adjust (Container : in out Vector); overriding procedure Finalize (Container : in out Vector); procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Vector); for Vector'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Container : out Vector); for Vector'Read use Read; type Vector_Access is access all Vector; for Vector_Access'Storage_Size use 0; type Cursor is record Container : Vector_Access; Index : Index_Type := Index_Type'First; end record; procedure Read (Stream : not null access Root_Stream_Type'Class; Position : out Cursor); for Cursor'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Position : Cursor); for Cursor'Write use Write; subtype Reference_Control_Type is Implementation.Reference_Control_Type; -- It is necessary to rename this here, so that the compiler can find it type Constant_Reference_Type (Element : not null access constant Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error". end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type); for Constant_Reference_Type'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type); for Constant_Reference_Type'Read use Read; type Reference_Type (Element : not null access Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error". end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type); for Reference_Type'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type); for Reference_Type'Read use Read; -- Three operations are used to optimize in the expansion of "for ... of" -- loops: the Next(Cursor) procedure in the visible part, and the following -- Pseudo_Reference and Get_Element_Access functions. See Exp_Ch5 for -- details. function Pseudo_Reference (Container : aliased Vector'Class) return Reference_Control_Type; pragma Inline (Pseudo_Reference); -- Creates an object of type Reference_Control_Type pointing to the -- container, and increments the Lock. Finalization of this object will -- decrement the Lock. type Element_Access is access all Element_Type; function Get_Element_Access (Position : Cursor) return not null Element_Access; -- Returns a pointer to the element designated by Position No_Element : constant Cursor := Cursor'(null, Index_Type'First); Empty_Vector : constant Vector := (Controlled with others => <>); type Iterator is new Limited_Controlled and Vector_Iterator_Interfaces.Reversible_Iterator with record Container : Vector_Access; Index : Index_Type'Base; end record with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Vectors;
wiremoons/AdbT
Ada
2,658
adb
------------------------------------------------------------------------------- -- Package : DB_File_Stats -- -- Description : Find the acronyms database file for use with the program. -- -- Author : Simon Rowe <[email protected]> -- -- License : MIT Open Source. -- ------------------------------------------------------------------------------- with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; -- with Text_IO.Editing; with Ada.Strings.Fixed; with Ada.IO_Exceptions; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; package body DB_File_Stats is function Get_File_Size (Dbfile : String) return String is --------------------------------------------------- -- Get the size in bytes of a file name provided --------------------------------------------------- Dbfile_Size : File_Size; begin -- TODO : add exception handling -- -- TODO : add thousands coma formating Dbfile_Size := (Size (Dbfile)); return (Ada.Strings.Fixed.Trim (Dbfile_Size'Image, Ada.Strings.Left)); exception when Ada.Directories.Name_Error => -- error with provided file name New_Line (2); Put (Standard_Error, "ERROR: DB_File_Stats.Get_File_Size() NAME for: '"); Put_Line (Standard_Error, Dbfile & "'."); return ("ERROR"); when Constraint_Error => -- error with provided file name New_Line (2); Put (Standard_Error, "ERROR: DB_File_Stats.Get_File_Size() SIZE for: '"); Put_Line (Standard_Error, Dbfile & "'."); return ("ERROR"); end Get_File_Size; function Get_Full_Directory (Dbfile : String) return String is ----------------------------------------------- -- Get the full directory path of a filename ----------------------------------------------- begin return Full_Name (Dbfile); exception when Ada.IO_Exceptions.Name_Error => -- error with provided file name New_Line (2); Put (Standard_Error, "ERROR: unable to find full path for: '"); Put_Line (Standard_Error, Dbfile & "'."); return "UNKOWN"; end Get_Full_Directory; function Get_File_Mod_Time (Dbfile : String) return String is ----------------------------------------------- -- Get the modification time for the filename ----------------------------------------------- begin return (Image (Modification_Time (Dbfile))); end Get_File_Mod_Time; end DB_File_Stats;
AdaCore/Ada_Drivers_Library
Ada
4,702
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file lis3dsh.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief This file provides a set of functions needed to manage the -- -- LIS3DSH MEMS Accelerometer. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This private package provides an I/O implementation for the LIS3DSH -- accelerometer chip. package body LIS3DSH.SPI is -------------- -- IO_Write -- -------------- overriding procedure IO_Write (This : in out Three_Axis_Accelerometer_SPI; Value : UInt8; WriteAddr : Register_Address) is Status : SPI_Status; begin This.Chip_Select.Clear; This.Port.Transmit (SPI_Data_8b'(UInt8 (WriteAddr or SPI_Write_Flag), Value), Status); This.Chip_Select.Set; if Status /= Ok then -- No error handling... raise Program_Error; end if; end IO_Write; ------------- -- IO_Read -- ------------- overriding procedure IO_Read (This : Three_Axis_Accelerometer_SPI; Value : out UInt8; ReadAddr : Register_Address) is Data : SPI_Data_8b (1 .. 1); Status : SPI_Status; begin This.Chip_Select.Clear; This.Port.Transmit (SPI_Data_8b'(1 => UInt8 (ReadAddr or SPI_Read_Flag)), Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; This.Port.Receive (Data, Status); This.Chip_Select.Set; if Status /= Ok then -- No error handling... raise Program_Error; end if; Value := Data (1); end IO_Read; end LIS3DSH.SPI;
AdaCore/Ada_Drivers_Library
Ada
1,938
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Architecture : constant String := "ARM"; -- From board definition Board : constant String := "STM32F429_Discovery"; -- From command line CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition Device_Family : constant String := "STM32F4"; -- From board definition Device_Name : constant String := "STM32F429ZITx"; -- From board definition Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Has_ZFP_Runtime : constant String := "False"; -- From board definition High_Speed_External_Clock : constant := 8000000; -- From board definition Max_Mount_Name_Length : constant := 128; -- From default value Max_Mount_Points : constant := 2; -- From default value Max_Path_Length : constant := 1024; -- From default value Number_Of_Interrupts : constant := 0; -- From default value Runtime_Name : constant String := "light-tasking-stm32f429disco"; -- From default value Runtime_Name_Suffix : constant String := "stm32f429disco"; -- From board definition Runtime_Profile : constant String := "light-tasking"; -- From command line Use_Startup_Gen : constant Boolean := False; -- From command line Vendor : constant String := "STMicro"; -- From board definition end ADL_Config;
reznikmm/matreshka
Ada
3,961
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Anim_Value_Attributes; package Matreshka.ODF_Anim.Value_Attributes is type Anim_Value_Attribute_Node is new Matreshka.ODF_Anim.Abstract_Anim_Attribute_Node and ODF.DOM.Anim_Value_Attributes.ODF_Anim_Value_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Anim_Value_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Anim_Value_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Anim.Value_Attributes;
neolinux/ardoducky
Ada
154
ads
press gui+r wait 200 write notepad press enter wait 200 ifj $caps capslock write capslock not enabled! goto end :capslock write capslock enabled! :end
stcarrez/ada-awa
Ada
5,508
adb
----------------------------------------------------------------------- -- awa-blogs-tests -- Unit tests for blogs module -- Copyright (C) 2011, 2012, 2013, 2014, 2015, 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 Util.Test_Caller; with ADO; with Security.Contexts; with AWA.Services.Contexts; with AWA.Tests.Helpers.Users; package body AWA.Blogs.Modules.Tests is use ADO; package Caller is new Util.Test_Caller (Test, "Blogs.Services"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Blogs.Services.Create_Blog", Test_Create_Blog'Access); Caller.Add_Test (Suite, "Test AWA.Blogs.Services.Create_Post", Test_Create_Post'Access); end Add_Tests; -- ------------------------------ -- Test creation of a blog -- ------------------------------ procedure Test_Create_Blog (T : in out Test) is Manager : AWA.Blogs.Modules.Blog_Module_Access; Blog_Id : ADO.Identifier; Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "[email protected]"); Manager := AWA.Blogs.Modules.Get_Blog_Module; Manager.Create_Blog (Title => "My blog", Result => Blog_Id); T.Assert (Blog_Id > 0, "Invalid blog identifier"); end Test_Create_Blog; -- ------------------------------ -- Test creating and updating of a blog post -- ------------------------------ procedure Test_Create_Post (T : in out Test) is Manager : AWA.Blogs.Modules.Blog_Module_Access; Blog_Id : ADO.Identifier; Post_Id : ADO.Identifier; Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "[email protected]"); Manager := AWA.Blogs.Modules.Get_Blog_Module; Manager.Create_Blog (Title => "My blog post", Result => Blog_Id); T.Assert (Blog_Id > 0, "Invalid blog identifier"); for I in 1 .. 5 loop Manager.Create_Post (Blog_Id => Blog_Id, Title => "Testing blog title", URI => "testing-blog-title", Text => "The blog content", Summary => "Summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, Comment => False, Status => AWA.Blogs.Models.POST_DRAFT, Result => Post_Id); T.Assert (Post_Id > 0, "Invalid post identifier"); Manager.Update_Post (Post_Id => Post_Id, Title => "New blog post title", URI => "testing-blog-title", Text => "The new post content", Summary => "New summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, Publish_Date => ADO.Nullable_Time '(Is_Null => True, others => <>), Comment => True, Status => AWA.Blogs.Models.POST_DRAFT); -- Keep the last post in the database. exit when I = 5; Manager.Delete_Post (Post_Id => Post_Id); -- Verify that a Not_Found exception is raised if the post was deleted. begin Manager.Update_Post (Post_Id => Post_Id, Title => "Something", Text => "Content", Summary => "Summary", Format => AWA.Blogs.Models.FORMAT_DOTCLEAR, URI => "testing-blog-title", Publish_Date => ADO.Nullable_Time '(Is_Null => True, others => <>), Comment => True, Status => AWA.Blogs.Models.POST_DRAFT); T.Assert (False, "Exception Not_Found was not raised"); exception when Not_Found => null; end; -- Verify that a Not_Found exception is raised if the post was deleted. begin Manager.Delete_Post (Post_Id => Post_Id); T.Assert (False, "Exception Not_Found was not raised"); exception when Not_Found => null; end; end loop; end Test_Create_Post; end AWA.Blogs.Modules.Tests;
msrLi/portingSources
Ada
764
ads
-- Copyright 2008-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is procedure Do_Nothing; end Pck;
wiremoons/apass
Ada
12,061
adb
------------------------------------------------------------------------------- -- BUILD FILE : apass -- -- Description : A CLI password generator written in Ada. -- -- Author : Simon Rowe <[email protected]> -- -- License : MIT Open Source. -- ------------------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Characters.Handling; use Ada.Characters.Handling; with GNATCOLL.Terminal; use GNATCOLL.Terminal; with Ada.Strings.Fixed; with Ada.Numerics.Discrete_Random; package body Password_Manager is -- Add ability to obtain a random number within the range of the array length for Words_List_Array as spec source subtype Max_Words is Integer range 1 .. (Words_List_Array'Length); package Random_Word_Int is new Ada.Numerics.Discrete_Random (Max_Words); Gen_Word : Random_Word_Int.Generator; -- Add ability to generate a single random number between 0 and 99 named 'Random_Integer' when generated subtype Random_Num_Int is Integer range 0 .. 99; package Random_Integer is new Ada.Numerics.Discrete_Random (Random_Num_Int); Gen_Int : Random_Integer.Generator; -- Add ability to obtain a random number within the range of the array length for Marks_List_Array as spec source subtype Max_Marks is Integer range 1 .. (Marks_List_Array'Length); package Random_Marks_Int is new Ada.Numerics.Discrete_Random (Max_Marks); Gen_Mark : Random_Marks_Int.Generator; -- Create a handle to manage colour output where supported Screen : Terminal_Info; function Basic_Password (Number_Of_Words : Positive := 3) return String is ------------------------------------------------------------------------------------------------------------------ -- Basic_Password generates a password from the number of words specified by value of function param -- -- Number_of_Words (default 3). Words are concatenated into a string that is returned. -- ------------------------------------------------------------------------------------------------------------------ Random_Number : Integer := 0; Password_Str : Unbounded_String := Null_Unbounded_String; begin pragma Debug (Put_Line (Standard_Error, "[DEBUG] Words to obtain: " & Integer'Image (Number_Of_Words))); Random_Word_Int.Reset (Gen => Gen_Word); for I in 1 .. Number_Of_Words loop Random_Number := Random_Word_Int.Random (Gen => Gen_Word); pragma Debug (Put (Standard_Error, "[DEBUG] Random number:" & Integer'Image (Random_Number))); pragma Debug (Put_Line (Standard_Error, " is word: " & Words_List_Array (Random_Number))); Append (Password_Str, Words_List_Array (Random_Number)); end loop; return To_String (Password_Str); end Basic_Password; function Capitilised_Password (Number_Of_Words : Positive := 3) return String is ------------------------------------------------------------------------------------------------------------------ -- Capitalised_Password generates a password from the number of words specified by value of function param -- -- Number_of_Words (default 3). Words are title cased and are concatenated into a string that is returned. -- ------------------------------------------------------------------------------------------------------------------ Random_Number : Integer := 0; Password_Str : Unbounded_String := Null_Unbounded_String; begin pragma Debug (Put_Line (Standard_Error, "[DEBUG] Words to obtain: " & Integer'Image (Number_Of_Words))); Random_Word_Int.Reset (Gen => Gen_Word); for I in 1 .. Number_Of_Words loop Random_Number := Random_Word_Int.Random (Gen => Gen_Word); pragma Debug (Put (Standard_Error, "[DEBUG] Random number:" & Integer'Image (Random_Number))); pragma Debug (Put_Line (Standard_Error, " is word: " & Words_List_Array (Random_Number))); Append (Password_Str, Title_Case_String (Words_List_Array (Random_Number))); end loop; return To_String (Password_Str); end Capitilised_Password; function Title_Case_String (Input_Str : String) return String is ------------------------------------------------------------------------------------------------------------------ -- Title_Case_String converts the first letter of the string provided to an upper case letter. -- -- The converted string is returned. If the string is zero length it is just returned as is. -- ------------------------------------------------------------------------------------------------------------------ begin if Input_Str'Length = 0 then return Input_Str; else return To_Upper (Input_Str (Input_Str'First)) & To_Lower (Input_Str (Input_Str'First + 1 .. Input_Str'Last)); end if; end Title_Case_String; procedure Print_Password (Final_Password : String) is --------------------------------------------------------------------------------------------------------------------- -- Print_Password outputs the provided string but displaying it in colour if supported. -- -- Output of colours can also be controlled by command line flag (TODO). Whats colours via settings (TODO) -- --------------------------------------------------------------------------------------------------------------------- begin if Final_Password'Length = 0 then Put_Line (Standard_Error, "ERROR: Zero length password string - no output available."); return; end if; pragma Debug (Put_Line (Standard_Error, "[DEBUG] final password: " & Final_Password)); -- reset screen outputs to known default - otherwise Windows outputs first displayed password -- with a bold white background - rest here fixes that. if Screen.Has_Colors then Set_Color (Self => Screen, Term => Standard_Output, Style => Reset_All, Foreground => Reset, Background => Reset); pragma Debug (Put_Line (Standard_Error, "[DEBUG] Reset : 'Set_Color'")); end if; for C in Final_Password'Range loop if Is_Digit (Final_Password (C)) then -- output of numbers in colour -- pragma Debug (Put (Standard_Error, " [DEBUG] DIGIT: " & Final_Password (C))); if Screen.Has_Colors then Screen.Set_Fg (Color => Green, Term => Standard_Output); Put (Final_Password (C)); Screen.Set_Fg (Color => Reset, Term => Standard_Output); else Put (Final_Password (C)); end if; elsif Is_Punctuation_Connector (Final_Password (C)) or Is_Special (Final_Password (C)) then -- output of punctuation characters including '_' pragma Debug (Put (Standard_Error, " [DEBUG] MARK: " & -- Final_Password (C))); if Screen.Has_Colors then Screen.Set_Fg (Color => Blue, Term => Standard_Output); Put (Final_Password (C)); Screen.Set_Fg (Color => Reset, Term => Standard_Output); else Put (Final_Password (C)); end if; elsif Is_Letter (Final_Password (C)) then -- output of any characters 'a .. z' or 'A .. Z' : NO COLOUR USED pragma Debug (Put (Standard_Error, " -- [DEBUG] LETTER: " & Final_Password (C))); Put (Final_Password (C)); else -- output of anything else not covered by the above specifics pragma Debug (Put (Standard_Error, " [DEBUG] -- OTHER: " & Final_Password (C))); if Screen.Has_Colors then Screen.Set_Fg (Color => Cyan, Term => Standard_Output); Put (Final_Password (C)); Screen.Set_Fg (Color => Reset, Term => Standard_Output); else Put (Final_Password (C)); end if; end if; end loop; -- flush all outputs issued with 'Put' only above --Put_Line (" "); Put (" "); -- reset screen outputs to ensure back to normal if Screen.Has_Colors then Set_Color (Self => Screen, Term => Standard_Output, Style => Reset_All, Foreground => Reset, Background => Reset); pragma Debug (Put_Line (Standard_Error, "[DEBUG] Reset : 'Set_Color'")); end if; end Print_Password; function Get_Random_Number return String is --------------------------------------------------------------------------------------------------------------------- -- Get_Random_Number returns a random number converted to a string. Selected from the 'Random_Num_Int' range. -- -- Leading Integer space trimmed from string before it is returned. -- -- If a single digit random number is generated a leading zero is added so it always returns 'length = 2 -- --------------------------------------------------------------------------------------------------------------------- Tmp_Str : Unbounded_String := Null_Unbounded_String; begin Random_Integer.Reset (Gen => Gen_Int); Tmp_Str := To_Unbounded_String (Ada.Strings.Fixed.Trim (Random_Integer.Random (Gen => Gen_Int)'Image, Ada.Strings.Left)); pragma Debug (Put_Line (Standard_Error, "[DEBUG] Random integer: " & To_String (Tmp_Str))); if Length (Tmp_Str) /= 2 then Insert (Tmp_Str, 1, "0"); return To_String (Tmp_Str); else return To_String (Tmp_Str); end if; end Get_Random_Number; function Get_Random_Mark return String is --------------------------------------------------------------------------------------------------------------------- -- Get_Random_Mark returns a random string (single character) selected from the 'Random_Marks_Int' range. -- -- The selected random string is obtained from the Marks_List_Array contained in spec file. -- --------------------------------------------------------------------------------------------------------------------- begin Random_Marks_Int.Reset (Gen => Gen_Mark); return (Marks_List_Array (Random_Marks_Int.Random (Gen => Gen_Mark))); end Get_Random_Mark; function Total_Words return String is --------------------------------------------------------------------------------------------------------------------- -- Total_Words returns the total number of three letter words available in the 'Words_List_Array'. -- -- Leading Integer space trimmed from string before it is returned. -- --------------------------------------------------------------------------------------------------------------------- begin return (Ada.Strings.Fixed.Trim (Integer'Image (Words_List_Array'Length), Ada.Strings.Left)); end Total_Words; -- Setup the package by enabling screen handle begin -- initialise screen outputs wanted for colour support Screen.Init_For_Stdout (Auto); Screen.Init_For_Stderr (Auto); -- show colour output capabilities in debug mode pragma Debug (Put_Line (Standard_Error, "[DEBUG] Checking for colour terminal support...")); pragma Debug (Put_Line (Standard_Error, "[DEBUG] Colour support: " & (if Screen.Has_Colors then "YES" else "NO"))); pragma Debug (Put_Line (Standard_Error, "[DEBUG] ANSI support: " & (if Screen.Has_ANSI_Colors then "YES" else "NO"))); Screen.Clear_To_End_Of_Line; end Password_Manager;
AaronC98/PlaneSystem
Ada
19,984
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; -- There is two implementations for this spec. One for standard sockets and -- one for SSL socket. Note that the SSL implementation does support standard -- socket too, this is controlled with the Security boolean on rountine -- below. The corresponding implementation will be selected at build time. with Ada.Exceptions; with Ada.Finalization; with Ada.Streams; private with AWS.Utils; private with Interfaces.C; package AWS.Net is use Ada; use Ada.Exceptions; use Ada.Streams; Socket_Error : exception; -- Raised by all routines below, a message will indicate the nature of -- the error. type Socket_Type is abstract new Finalization.Controlled with private; type Socket_Access is access all Socket_Type'Class; type Socket_Set is array (Positive range <>) of Socket_Access; subtype FD_Type is Integer; -- Represents an external socket file descriptor No_Socket : constant := -1; -- Represents closed socket file descriptor type Event_Type is (Error, Input, Output); -- Error - socket is in error state. -- Input - socket ready for read. -- Output - socket available for write. type Event_Set is array (Event_Type) of Boolean; -- Type for get result of events waiting subtype Wait_Event_Type is Event_Type range Input .. Output; type Wait_Event_Set is array (Wait_Event_Type) of Boolean; -- Type for set events to wait, note that Error event would be waited -- anyway. type Family_Type is (Family_Inet, Family_Inet6, Family_Unspec); type Shutmode_Type is (Shut_Read, Shut_Write, Shut_Read_Write); Forever : constant Duration; -- The longest delay possible on the implementation ---------------- -- Initialize -- ---------------- function Socket (Security : Boolean) return Socket_Type'Class; -- Create an uninitialized socket function Socket (Security : Boolean) return not null access Socket_Type'Class; -- Create a dynamically allocated uninitialized socket procedure Bind (Socket : in out Socket_Type; Port : Natural; Host : String := ""; Reuse_Address : Boolean := False; IPv6_Only : Boolean := False; Family : Family_Type := Family_Unspec) is abstract; -- Create the server socket and bind it on the given port. -- Using 0 for the port will tell the OS to allocate a non-privileged -- free port. The port can be later retrieved using Get_Port on the -- bound socket. -- IPv6_Only has meaning only for Family = Family_Inet6 and mean that only -- IPv6 clients allowed to connect. procedure Listen (Socket : Socket_Type; Queue_Size : Positive := 5) is abstract; -- Set the queue size of the socket procedure Accept_Socket (Socket : Socket_Type'Class; New_Socket : in out Socket_Type) is abstract; -- Accept a connection on a socket. If it raises Socket_Error, all -- resources used by new_Socket have been released. -- There is not need to call Free or Shutdown. type Socket_Constructor is not null access function (Security : Boolean) return Socket_Type'Class; procedure Connect (Socket : in out Socket_Type; Host : String; Port : Positive; Wait : Boolean := True; Family : Family_Type := Family_Unspec) is abstract with Pre'Class => Host'Length > 0; -- Connect a socket on a given host/port. If Wait is True Connect will wait -- for the connection to be established for timeout seconds, specified by -- Set_Timeout routine. If Wait is False Connect will return immediately, -- not waiting for the connection to be establised. It is possible to wait -- for the Connection completion by calling Wait routine with Output set to -- True in Events parameter. procedure Socket_Pair (S1, S2 : out Socket_Type); -- Create 2 sockets and connect them together procedure Shutdown (Socket : Socket_Type; How : Shutmode_Type := Shut_Read_Write) is abstract; -- Shutdown the read, write or both side of the socket. -- If How is Both, close it. Does not raise Socket_Error if the socket is -- not connected or already shutdown. procedure Free (Socket : in out Socket_Access); -- Release memory associated with the socket -------- -- IO -- -------- procedure Send (Socket : Socket_Type'Class; Data : Stream_Element_Array); -- Send Data chunk to the socket procedure Send (Sockets : Socket_Set; Data : Stream_Element_Array); -- Send Data to all sockets from the socket set. This call will ensure that -- the data are sent in priority to client waiting for reading. That is, -- slow connection for one sokcet should not delay the fast connections. -- Yet, this routine will return only when the data is sent to all sockets. procedure Send (Socket : Socket_Type; Data : Stream_Element_Array; Last : out Stream_Element_Offset) is abstract; -- Try to place data to Socket's output buffer. If all data cannot be -- placed to the socket output buffer, Last will be lower than Data'Last, -- if no data has been placed into the output buffer, Last is set to -- Data'First - 1. If Data'First is equal to Stream_Element_Offset'First -- then constraint error is raised to follow advice in AI95-227. procedure Receive (Socket : Socket_Type; Data : out Stream_Element_Array; Last : out Stream_Element_Offset) is abstract; -- Read a chunk of data from the socket and set appropriate Last value. -- This call always returns some data and will wait for incoming data only -- if necessary. function Receive (Socket : Socket_Type'Class; Max : Stream_Element_Count := 4096) return Stream_Element_Array; -- Read a chunk of data from the socket and returns it. This call always -- returns some data and will wait for incoming data only if necessary. function Pending (Socket : Socket_Type) return Stream_Element_Count is abstract; -- Returns the number of bytes which are available inside socket -- for immediate read. function Output_Space (Socket : Socket_Type) return Stream_Element_Offset; -- Returns the free space in output buffer in bytes. If OS could not -- provide such information, routine returns -1. function Output_Busy (Socket : Socket_Type) return Stream_Element_Offset; -- How many bytes in the send queue. If OS could not provide such -- information, routine returns -1. ------------ -- Others -- ------------ function Get_FD (Socket : Socket_Type) return FD_Type is abstract; -- Returns the file descriptor associated with the socket function Peer_Addr (Socket : Socket_Type) return String is abstract; -- Returns the peer name/address function Peer_Port (Socket : Socket_Type) return Positive is abstract; -- Returns the port of the peer socket function Get_Addr (Socket : Socket_Type) return String is abstract; -- Returns the name/address of the socket function Get_Port (Socket : Socket_Type) return Positive is abstract; -- Returns the port of the socket function Is_Any_Address (Socket : Socket_Type) return Boolean; -- Return true if the socket accepts connections on any of the hosts's -- network addresses. function Is_IPv6 (Socket : Socket_Type) return Boolean; function Is_Listening (Socket : Socket_Type) return Boolean; -- Returns true if the socket has been marked to accept connections with -- listen. function IPv6_Available return Boolean; -- Returns True if IPv6 available in OS and in AWS socket implementation function Host_Name return String; -- Returns the running host name procedure Set_Send_Buffer_Size (Socket : Socket_Type; Size : Natural) is abstract; -- Set the internal socket send buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. procedure Set_Receive_Buffer_Size (Socket : Socket_Type; Size : Natural) is abstract; -- Set the internal socket receive buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. function Get_Send_Buffer_Size (Socket : Socket_Type) return Natural is abstract; -- Returns the internal socket send buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. function Get_Receive_Buffer_Size (Socket : Socket_Type) return Natural is abstract; -- Returns the internal socket receive buffer size. -- Do not confuse with buffers for the AWS.Net.Buffered operations. function Cipher_Description (Socket : Socket_Type) return String; -- Returns cipher description on SSL implementation or empty string on -- plain socket. procedure Set_Blocking_Mode (Socket : in out Socket_Type; Blocking : Boolean); pragma Obsolescent ("Use Set_Timeout instead"); -- Set the blocking mode for the socket procedure Set_Timeout (Socket : in out Socket_Type; Timeout : Duration) with Inline; -- Sets the timeout for the socket read/write operations procedure Set_No_Delay (Socket : Socket_Type; Value : Boolean := True) is null; -- Set/clear TCP_NODELAY option on socket function Wait (Socket : Socket_Type'Class; Events : Wait_Event_Set) return Event_Set; -- Waiting for Input/Output/Error events. -- Waiting time is defined by Set_Timeout. -- Empty event set in result mean that timeout occured. function Check (Socket : Socket_Type'Class; Events : Wait_Event_Set) return Event_Set; -- Check for Input/Output/Error events availability. -- No wait for socket timeout. function Poll (Socket : Socket_Type'Class; Events : Wait_Event_Set; Timeout : Duration) return Event_Set; -- Wait events on socket descriptor for specified Timeout function Errno (Socket : Socket_Type) return Integer is abstract; -- Returns and clears error state in socket function Is_Timeout (Socket : Socket_Type; E : Exception_Occurrence) return Boolean; -- Returns True if the message associated with the Exception_Occurence for -- a Socket_Error is a timeout. function Is_Timeout (E : Exception_Occurrence) return Boolean; -- As above but without Socket parameter function Is_Peer_Closed (Socket : Socket_Type; E : Exception_Occurrence) return Boolean; -- Returns True if the message associated with the Exception_Occurence for -- a Socket_Error is a "socket closed by peer". -------------------- -- Socket FD sets -- -------------------- type FD_Set (Size : Natural) is abstract tagged private; -- Abstract type for waiting of network events on group of sockets FD type FD_Set_Access is access all FD_Set'Class; function To_FD_Set (Socket : Socket_Type; Events : Wait_Event_Set; Size : Positive := 1) return FD_Set'Class; -- Create appropriate socket FD set and put Socket fd there procedure Add (FD_Set : in out FD_Set_Access; FD : FD_Type; Event : Wait_Event_Set); -- Add FD to the end of FD_Set procedure Free (FD_Set : in out FD_Set_Access) with Inline; -- Deallocate the socket FD set procedure Add (FD_Set : in out Net.FD_Set; FD : FD_Type; Event : Wait_Event_Set) is abstract; -- Add FD to the end of FD_Set procedure Replace (FD_Set : in out Net.FD_Set; Index : Positive; FD : FD_Type) is abstract with Pre'Class => Index <= Length (FD_Set); -- Replaces the socket FD in FD_Set procedure Set_Mode (FD_Set : in out Net.FD_Set; Index : Positive; Mode : Wait_Event_Set) is abstract with Pre'Class => Index <= Length (FD_Set); -- Sets the kind of network events to wait for procedure Set_Event (FD_Set : in out Net.FD_Set; Index : Positive; Event : Wait_Event_Type; Value : Boolean) is abstract with Pre'Class => Index <= Length (FD_Set); function Copy (FD_Set : not null access Net.FD_Set; Size : Natural) return FD_Set_Access is abstract; -- Allocates and copy the given FD_Set with different size procedure Remove (FD_Set : in out Net.FD_Set; Index : Positive) is abstract with Pre'Class => Index <= Length (FD_Set); -- Removes socket FD from Index position. -- Last socket FD in FD_Set is placed at position Index. function Length (FD_Set : Net.FD_Set) return Natural is abstract; -- Returns number of socket FD elements in FD_Set procedure Wait (FD_Set : in out Net.FD_Set; Timeout : Duration; Count : out Natural) is abstract with Post'Class => Count <= Length (FD_Set); -- Wait for network events on the sockets FD set. Count value is the -- number of socket FDs with non empty event set. procedure Next (FD_Set : Net.FD_Set; Index : in out Positive) is abstract with Pre'Class => Index <= Length (FD_Set) + 1, Post'Class => Index <= Length (FD_Set) + 1; -- Looking for an active (for which an event has been detected by routine -- Wait above) socket FD starting from Index and return Index of the found -- active socket FD. Use functions Status to retreive the kind of network -- events for this socket. function Status (FD_Set : Net.FD_Set; Index : Positive) return Event_Set is abstract with Pre'Class => Index <= Length (FD_Set); -- Returns events for the socket FD at position Index procedure Free (Socket : in out Socket_Type) is null; -- Release memory associated with the socket object. This default version -- can be overriden to properly release the memory for the derived -- implementation. The controlled Finalize routine is in charge of calling -- Free. We could not have it in the private part because we could not make -- AWS.Net.SSL.Free overriding this way. function Localhost (IPv6 : Boolean) return String; -- Returns "::1" if IPv6 is true or "127.0.0.1" otherwise private type FD_Set (Size : Natural) is abstract tagged null record; procedure Wait_For (Mode : Wait_Event_Type; Socket : Socket_Type'Class; Timeout : Duration); -- Wait for a socket to be ready for input or output operation. -- Raises Socket_Error if an error or timeout occurs. procedure Wait_For (Mode : Wait_Event_Type; Socket : Socket_Type'Class); -- Idem, but use socket timeout -- This object is to cache data writed to the stream. It is more efficient -- than to write byte by byte on the stream. W_Cache_Size : constant := 2_048; -- This is write the cache size, when the cache is full W_Cache_Size -- bytes will be sent to the socket. This way we avoid flushing a single -- byte as this is not efficient at all with SSL sockets. R_Cache_Size : constant := 4_096; -- This is the read cache size, all data read on the socket are first put -- into a read cache, this makes reading char-by-char the socket more -- efficient. Before reading data, the write cache is flushed. Forever : constant Duration := Duration'Last; Peer_Closed_Message : constant String := "Receive : Socket closed by peer"; function Get_Socket_Errno (E : Exception_Occurrence) return Natural; -- Returns the errno recorded into the exception message type Read_Cache (Max_Size : Stream_Element_Count) is record Buffer : Stream_Element_Array (1 .. Max_Size); First : Stream_Element_Offset := 1; Last : Stream_Element_Offset := 0; end record; type Read_Cache_Access is access Read_Cache; type Write_Cache (Max_Size : Stream_Element_Count) is record Buffer : Stream_Element_Array (1 .. Max_Size); Last : Stream_Element_Offset := 0; end record; type Write_Cache_Access is access Write_Cache; type RW_Data is record Ref_Count : Utils.Counter (Initial_Value => 1); Listening : Boolean := False; -- True if a listening (server) socket R_Cache : Read_Cache_Access; W_Cache : Write_Cache_Access; Can_Wait : Boolean := False; -- Need for OpenSSL send in Mac OS Pack_Size : Stream_Element_Count := 2**15; -- Idem end record; type RW_Data_Access is access RW_Data; type Socket_Type is abstract new Finalization.Controlled with record C : RW_Data_Access; Timeout : Duration := Forever; end record; procedure Raise_Socket_Error (Socket : Socket_Type'Class; Text : String) with No_Return; function Error_Message (Errno : Integer) return String; -- Returns the error message string for the error number Errno. If Errno is -- not known, returns "Unknown system error". -- Controlled primitives overriding procedure Initialize (Socket : in out Socket_Type); overriding procedure Adjust (Socket : in out Socket_Type); overriding procedure Finalize (Socket : in out Socket_Type); function Last_Index (First : Stream_Element_Offset; Count : Natural) return Ada.Streams.Stream_Element_Offset; -- Compute the Last OUT parameter for the various Send / Receive -- subprograms: returns First + Count - 1. -- When First = Stream_Element_Offset'First and Res = 0, Constraint_Error -- is raised. This is consistent with the semantics of stream operations -- as clarified in AI95-227. function IO_Control (Socket : Socket_Type; Code : Interfaces.C.int) return Stream_Element_Offset; -- This routine is necessary for both sockets implementations because -- GNAT.Sockets support only 2 control codes (at least in GNAT GPL 2013). end AWS.Net;
reznikmm/matreshka
Ada
3,600
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.Elements.Generic_Hash; function AMF.OCL.Bag_Types.Hash is new AMF.Elements.Generic_Hash (OCL_Bag_Type, OCL_Bag_Type_Access);
jamiepg1/sdlada
Ada
4,182
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 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; with Interfaces.C.Strings; with Ada.Text_IO; use Ada.Text_IO; with SDL.Error; package body SDL.Video is package C renames Interfaces.C; use type C.int; function Is_Screen_Saver_Enabled return Boolean is function SDL_Is_Screen_Saver_Enabled return C.int with Import => True, Convention => C, External_Name => "SDL_IsScreenSaverEnabled"; begin return (if SDL_Is_Screen_Saver_Enabled = 1 then True else False); end Is_Screen_Saver_Enabled; function Initialise (Name : in String) return Boolean is function SDL_Video_Init (C_Name : in C.Strings.chars_Ptr) return C.int with Import => True, Convention => C, External_Name => "SDL_VideoInit"; C_Str : C.Strings.chars_Ptr := C.Strings.Null_Ptr; Result : C.int; begin if Name /= "" then C_Str := C.Strings.New_String (Name); Result := SDL_Video_Init (C_Name => C_Str); C.Strings.Free (C_Str); else Result := SDL_Video_Init (C_Name => C.Strings.Null_Ptr); end if; return (Result = Success); end Initialise; function Total_Drivers return Positive is function SDL_Get_Num_Video_Drivers return C.int with Import => True, Convention => C, External_Name => "SDL_GetNumVideoDrivers"; Num : constant C.int := SDL_Get_Num_Video_Drivers; begin if Num < 0 then raise Video_Error with SDL.Error.Get; end if; return Positive (Num); end Total_Drivers; function Driver_Name (Index : in Positive) return String is function SDL_Get_Video_Driver (I : in C.int) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetVideoDriver"; -- Index is zero based, so need to subtract 1 to correct it. C_Str : C.Strings.chars_Ptr := SDL_Get_Video_Driver (C.int (Index) - 1); begin return C.Strings.Value (C_Str); end Driver_Name; function Current_Driver_Name return String is function SDL_Get_Current_Video_Driver return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetCurrentVideoDriver"; C_Str : constant C.Strings.chars_ptr := SDL_Get_Current_Video_Driver; use type C.Strings.chars_Ptr; begin if C_Str = C.Strings.Null_ptr then raise Video_Error with SDL.Error.Get; end if; return C.Strings.Value (C_Str); end Current_Driver_Name; function Total_Displays return Positive is function SDL_Get_Num_Video_Displays return C.int with Import => True, Convention => C, External_Name => "SDL_GetNumVideoDisplays"; Num : constant C.int := SDL_Get_Num_Video_Displays; begin if Num <= 0 then raise Video_Error with SDL.Error.Get; end if; return Positive (Num); end Total_Displays; end SDL.Video;
reznikmm/matreshka
Ada
5,526
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.Read_Link_Object_End_Actions.Collections is pragma Preelaborate; package UML_Read_Link_Object_End_Action_Collections is new AMF.Generic_Collections (UML_Read_Link_Object_End_Action, UML_Read_Link_Object_End_Action_Access); type Set_Of_UML_Read_Link_Object_End_Action is new UML_Read_Link_Object_End_Action_Collections.Set with null record; Empty_Set_Of_UML_Read_Link_Object_End_Action : constant Set_Of_UML_Read_Link_Object_End_Action; type Ordered_Set_Of_UML_Read_Link_Object_End_Action is new UML_Read_Link_Object_End_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Read_Link_Object_End_Action : constant Ordered_Set_Of_UML_Read_Link_Object_End_Action; type Bag_Of_UML_Read_Link_Object_End_Action is new UML_Read_Link_Object_End_Action_Collections.Bag with null record; Empty_Bag_Of_UML_Read_Link_Object_End_Action : constant Bag_Of_UML_Read_Link_Object_End_Action; type Sequence_Of_UML_Read_Link_Object_End_Action is new UML_Read_Link_Object_End_Action_Collections.Sequence with null record; Empty_Sequence_Of_UML_Read_Link_Object_End_Action : constant Sequence_Of_UML_Read_Link_Object_End_Action; private Empty_Set_Of_UML_Read_Link_Object_End_Action : constant Set_Of_UML_Read_Link_Object_End_Action := (UML_Read_Link_Object_End_Action_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Read_Link_Object_End_Action : constant Ordered_Set_Of_UML_Read_Link_Object_End_Action := (UML_Read_Link_Object_End_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Read_Link_Object_End_Action : constant Bag_Of_UML_Read_Link_Object_End_Action := (UML_Read_Link_Object_End_Action_Collections.Bag with null record); Empty_Sequence_Of_UML_Read_Link_Object_End_Action : constant Sequence_Of_UML_Read_Link_Object_End_Action := (UML_Read_Link_Object_End_Action_Collections.Sequence with null record); end AMF.UML.Read_Link_Object_End_Actions.Collections;
reznikmm/matreshka
Ada
3,567
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Holders.Generic_Holders; with League.JSON.Objects; package League.Holders.JSON_Objects is new League.Holders.Generic_Holders (League.JSON.Objects.JSON_Object); pragma Preelaborate (League.Holders.JSON_Objects);
AdaCore/gpr
Ada
2,878
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Context; with GPR2.Project.Attribute.Set; with GPR2.Project.Tree; with GPR2.Project.Variable.Set; with GPR2.Project.View; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Display (Prj : Project.View.Object); procedure Display (Att : Project.Attribute.Object); procedure Load (Filename : Filename_Type); ------------- -- Display -- ------------- procedure Display (Att : Project.Attribute.Object) is begin Text_IO.Put (" " & Image (Att.Name.Id.Attr)); if Att.Has_Index then Text_IO.Put (" (" & Att.Index.Text & ")"); end if; Text_IO.Put (" ->"); for V of Att.Values loop Text_IO.Put (" " & V.Text); end loop; Text_IO.New_Line; end Display; procedure Display (Prj : Project.View.Object) is use GPR2.Project.Attribute.Set; use GPR2.Project.Variable.Set.Set; begin Text_IO.Put (String (Prj.Name) & " "); Text_IO.Set_Col (10); Text_IO.Put_Line (Prj.Qualifier'Img); for A of Prj.Attributes (With_Defaults => False) loop Display (A); end loop; if Prj.Has_Variables then for V in Prj.Variables.Iterate loop Text_IO.Put ("V: " & String (Key (V))); Text_IO.Put (" -> "); Text_IO.Put (Element (V).Value.Text); Text_IO.New_Line; end loop; end if; for Pck of Prj.Packages (With_Defaults => False) loop Text_IO.Put_Line (" " & Image (Pck)); for A of Prj.Attributes (Pack => Pck, With_Defaults => False) loop Display (A); end loop; end loop; Text_IO.New_Line; end Display; ---------- -- Load -- ---------- procedure Load (Filename : Filename_Type) is Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj, Create (Filename), Ctx); Display (Prj.Root_Project); exception when GPR2.Project_Error => if Prj.Has_Messages then Text_IO.Put_Line ("Messages found for " & String (Filename)); for M of Prj.Log_Messages.all loop declare Mes : constant String := M.Format; L : constant Natural := Strings.Fixed.Index (Mes, "aggregate-dup"); begin if L /= 0 then Text_IO.Put_Line (Mes (L - 1 .. Mes'Last)); else Text_IO.Put_Line (Mes); end if; end; end loop; Text_IO.New_Line; end if; end Load; Prj : Project.Tree.Object; Ctx : Context.Object; begin Load ("demo.gpr"); end Main;
vpodzime/ada-util
Ada
1,327
ads
----------------------------------------------------------------------- -- util-mail -- Mail Utility Library -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; -- == Introduction == -- The <tt>Util.Mail</tt> package provides various operations related to sending email. package Util.Mail is type Email_Address is record Name : Ada.Strings.Unbounded.Unbounded_String; Address : Ada.Strings.Unbounded.Unbounded_String; end record; -- Parse the email address and separate the name from the address. function Parse_Address (E_Mail : in String) return Email_Address; end Util.Mail;
annexi-strayline/AURA
Ada
8,316
ads
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- 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 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 -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines and utilities for driving the CLI. -- -- Note that these primatives also react to non-terminal executions, and omit -- fancier UI features in those circumstances with Ada.Text_IO; with CLI; with Progress; package UI_Primitives is -- Configuration Progress_Poll_Rate: constant Duration := 0.05; Auto_Queries: Boolean := False; -- If True on entry to User_Query, the Default Response is immediately -- submitted -- Standard Error Routines package STDERR is package TIO renames Ada.Text_IO; procedure Put (File: in TIO.File_Type := TIO.Standard_Error; Item: in String) renames TIO.Put; procedure Put_Line (File : in TIO.File_Type := TIO.Standard_Error; Message: in String) renames TIO.Put_Line; procedure New_Line (File : in TIO.File_Type := TIO.Standard_Error; Spacing: in TIO.Positive_Count := 1) renames TIO.New_Line; end STDERR; -- Static content procedure Print_Banner; procedure Print_Help; -- Line tags type Tag_Type is (EXEC, OK, FAIL, WARN, QUERY, INFO); procedure Put_Tag (Tag: Tag_Type); procedure Put_Exec_Tag (Tag: Tag_Type := EXEC ) renames Put_Tag; procedure Put_OK_Tag (Tag: Tag_Type := OK ) renames Put_Tag; procedure Put_Fail_Tag (Tag: Tag_Type := FAIL ) renames Put_Tag; procedure Put_Warn_Tag (Tag: Tag_Type := WARN ) renames Put_Tag; procedure Put_Query_Tag (Tag: Tag_Type := QUERY) renames Put_Tag; procedure Put_Info_Tag (Tag: Tag_Type := INFO ) renames Put_Tag; procedure Put_Empty_Tag; -- Writes a series of spaces the same length as a tag procedure Put_Divider; -- Outputs a full width string of '-' characters procedure Query_Driver (Prompt : in String; Default : in String; Response: out String; Last : out Natural) with Pre => Default'Length = Response'Length; -- For use with the User_Queries package procedure Immediate_YN_Query (Prompt : in String; Default : in Boolean; Response: out Boolean); -- For use outside of Worker Tasks (such as Scheduling) to initiate an -- immediate Yes/No query via the Query subsystem and the above Query_Driver -- implementation. -- -- " (y/n)" will be appended to Prompt. -- -- Should not be used if any Worker Tasks are active. procedure Dump_Reports; -- Debug procedure Dump_Repositories; procedure Dump_Subsystems; procedure Dump_Library_Units; -- Normal Operations procedure Prep_Tracker (Process_Title: in String; Spinner_Only : in Boolean := False); -- Clears the current line and outputs Process_Title and a dummy progress -- bar in the style of Wait_Tracker. This is used before a sequential action -- that dispatches work orders is executed, particularily when that action -- may take a noticable amount of time. -- -- Prep_Tracker has no effect if output is not to a terminal procedure Wait_Tracker (Process_Title : in String; Tracker : in out Progress.Progress_Tracker; Failures : out Boolean; Timedout : out Boolean; Spinner_Only : in Boolean := False; Process_Timeout: in Duration := 60.0); -- Clears the current line and outputs Process_Title, a progress bar, as -- well as a a numeric completed/total value. -- -- User Queries are handled until the tracker completes. -- -- If Spinner_Only is true, the progress bar and numeric counters are not -- displayed. -- -- This information is updated at Progress_Pool_Rate, until the progress -- tracker completes, or if Progress_Total_Timeout elapses without any -- changes to the tracker values procedure Wait_Tracker_Or_Abort (Process_Title : in String; Tracker : in out Progress.Progress_Tracker; Spinner_Only : in Boolean := False; Process_Timeout: in Duration := 20.0); -- Invokes Wait_Tracker, and reports Timeout or Failed, before raising -- the Scheduling.Process_Failed exception procedure Put_Info (Message: String); -- If the output is a Terminal, this acts as a Put, -- If the output is not a Terminal, this acts as a Put_Line. -- -- The purpose of this operation is to make interactive runs a bit less -- chatty, while scripted or CI/CD retain full output end UI_Primitives;
davidkristola/vole
Ada
4,407
ads
with Interfaces; with Ada.Finalization; with Ada.Streams; with kv.avm.references; use kv.avm.references; limited with kv.avm.Memories; limited with kv.avm.Registers; with kv.avm.Actor_References.Sets; package kv.avm.Tuples is use Interfaces; Immutability_Error : exception; -- A (constant) register map used to create a tuple type Map_Type is new Ada.Finalization.Controlled with private; overriding procedure Adjust (Self : in out Map_Type); overriding procedure Finalize (Self : in out Map_Type); not overriding procedure Set (Self : in out Map_Type; Data : access constant kv.avm.References.Reference_Array_Type); not overriding function Get(Self : Map_Type) return access constant kv.avm.References.Reference_Array_Type; procedure Tuple_Map_Write(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : in Map_Type); for Map_Type'WRITE use Tuple_Map_Write; procedure Tuple_Map_Read(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : out Map_Type); for Map_Type'READ use Tuple_Map_Read; overriding function "="(L, R: Map_Type) return Boolean; type Tuple_Type is new Ada.Finalization.Controlled with private; overriding procedure Initialize (Self : in out Tuple_Type); overriding procedure Adjust (Self : in out Tuple_Type); overriding procedure Finalize (Self : in out Tuple_Type); not overriding procedure Fold (Self : in out Tuple_Type; Data : in kv.avm.Memories.Register_Array_Type); not overriding procedure Fold_Empty (Self : in out Tuple_Type); not overriding procedure Fold_One (Self : in out Tuple_Type; Data : access kv.avm.Registers.Register_Type); not overriding procedure Fold (Self : in out Tuple_Type; Data : in kv.avm.Memories.Memory_Type; Map : in Map_Type'CLASS); not overriding function Peek (Self : in Tuple_Type; Index : in Interfaces.Unsigned_32) return access constant kv.avm.Registers.Register_Type; not overriding function Unfolded(Self : Tuple_Type) return access constant kv.avm.Memories.Register_Set_Type; not overriding function To_String(Self : Tuple_Type) return String; not overriding function Reachable(Self : Tuple_Type) return kv.avm.Actor_References.Sets.Set; not overriding function Length(Self : Tuple_Type) return Natural; overriding function "="(L, R: Tuple_Type) return Boolean; procedure Tuple_Write(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : in Tuple_Type); for Tuple_Type'WRITE use Tuple_Write; procedure Tuple_Read(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS; Item : out Tuple_Type); for Tuple_Type'READ use Tuple_Read; -- A (constant) abstract ("definition" because "abstract" is a reserved word) -- of a tuple. type Definition_Type is new Ada.Finalization.Controlled with private; overriding procedure Initialize (Self : in out Definition_Type); overriding procedure Adjust (Self : in out Definition_Type); overriding procedure Finalize (Self : in out Definition_Type); overriding function "="(L, R: Definition_Type) return Boolean; not overriding procedure Make (Self : in out Definition_Type; Tuple : in Tuple_Type'CLASS); not overriding function To_String(Self : Definition_Type) return String; not overriding function Length(Self : Definition_Type) return Natural; private type Tuple_Reference_Counter_Type; type Tuple_Reference_Counter_Access is access all Tuple_Reference_Counter_Type; type Tuple_Type is new Ada.Finalization.Controlled with record Ref : Tuple_Reference_Counter_Access; end record; type Map_Reference_Counter_Type; type Map_Reference_Counter_Access is access all Map_Reference_Counter_Type; type Map_Type is new Ada.Finalization.Controlled with record Ref : Map_Reference_Counter_Access; end record; type Definition_Reference_Counter_Type; type Definition_Reference_Counter_Access is access all Definition_Reference_Counter_Type; type Definition_Type is new Ada.Finalization.Controlled with record Ref : Definition_Reference_Counter_Access; end record; end kv.avm.Tuples;
bdrewery/synth
Ada
47,200
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Calendar.Arithmetic; with Ada.Calendar.Formatting; with Ada.Direct_IO; with Replicant.Platform; package body PortScan.Buildcycle is package ACA renames Ada.Calendar.Arithmetic; package ACF renames Ada.Calendar.Formatting; package REP renames Replicant; ---------------------- -- initialize_log -- ---------------------- function initialize_log (id : builders) return Boolean is FA : access TIO.File_Type; H_ENV : constant String := "Environment"; H_OPT : constant String := "Options"; CFG1 : constant String := "/etc/make.conf"; CFG2 : constant String := "/etc/mk.conf"; UNAME : constant String := JT.USS (uname_mrv); BENV : constant String := get_environment (id); COPTS : constant String := get_options_configuration (id); PTVAR : JT.Text := get_port_variables (id); begin trackers (id).dynlink.Clear; trackers (id).head_time := CAL.Clock; declare log_path : constant String := log_name (trackers (id).seq_id); begin if AD.Exists (log_path) then AD.Delete_File (log_path); end if; TIO.Create (File => trackers (id).log_handle, Mode => TIO.Out_File, Name => log_path); FA := trackers (id).log_handle'Access; exception when error : others => raise cycle_log_error with "failed to create log " & log_path; end; TIO.Put_Line (FA.all, "=> Building " & get_catport (all_ports (trackers (id).seq_id))); TIO.Put_Line (FA.all, "Started : " & timestamp (trackers (id).head_time)); TIO.Put (FA.all, "Platform: " & UNAME); if BENV = discerr then TIO.Put_Line (FA.all, LAT.LF & "Environment definition failed, " & "aborting entire build"); return False; end if; TIO.Put_Line (FA.all, LAT.LF & log_section (H_ENV, True)); TIO.Put (FA.all, BENV); TIO.Put_Line (FA.all, log_section (H_ENV, False) & LAT.LF); TIO.Put_Line (FA.all, log_section (H_OPT, True)); TIO.Put (FA.all, COPTS); TIO.Put_Line (FA.all, log_section (H_OPT, False) & LAT.LF); dump_port_variables (id => id, content => PTVAR); case software_framework is when ports_collection => TIO.Put_Line (FA.all, log_section (CFG1, True)); TIO.Put (FA.all, dump_make_conf (id, CFG1)); TIO.Put_Line (FA.all, log_section (CFG1, False) & LAT.LF); when pkgsrc => TIO.Put_Line (FA.all, log_section (CFG2, True)); TIO.Put (FA.all, dump_make_conf (id, CFG2)); TIO.Put_Line (FA.all, log_section (CFG2, False) & LAT.LF); end case; return True; end initialize_log; -------------------- -- finalize_log -- -------------------- procedure finalize_log (id : builders) is begin TIO.Put_Line (trackers (id).log_handle, log_section ("Termination", True)); trackers (id).tail_time := CAL.Clock; TIO.Put_Line (trackers (id).log_handle, "Finished: " & timestamp (trackers (id).tail_time)); TIO.Put_Line (trackers (id).log_handle, log_duration (start => trackers (id).head_time, stop => trackers (id).tail_time)); TIO.Close (trackers (id).log_handle); end finalize_log; -------------------- -- log_duration -- -------------------- function log_duration (start, stop : CAL.Time) return String is raw : JT.Text := JT.SUS ("Duration:"); diff_days : ACA.Day_Count; diff_secs : Duration; leap_secs : ACA.Leap_Seconds_Count; use type ACA.Day_Count; begin ACA.Difference (Left => stop, Right => start, Days => diff_days, Seconds => diff_secs, Leap_Seconds => leap_secs); if diff_days > 0 then if diff_days = 1 then JT.SU.Append (raw, " 1 day and " & ACF.Image (Elapsed_Time => diff_secs)); else JT.SU.Append (raw, diff_days'Img & " days and " & ACF.Image (Elapsed_Time => diff_secs)); end if; else JT.SU.Append (raw, " " & ACF.Image (Elapsed_Time => diff_secs)); end if; return JT.USS (raw); end log_duration; ------------------------ -- elapsed_HH_MM_SS -- ------------------------ function elapsed_HH_MM_SS (start, stop : CAL.Time) return String is diff_days : ACA.Day_Count; diff_secs : Duration; leap_secs : ACA.Leap_Seconds_Count; secs_per_hour : constant Integer := 3600; total_hours : Integer; total_minutes : Integer; work_hours : Integer; work_seconds : Integer; use type ACA.Day_Count; begin ACA.Difference (Left => stop, Right => start, Days => diff_days, Seconds => diff_secs, Leap_Seconds => leap_secs); -- Seems the ACF image is shit, so let's roll our own. If more than -- 100 hours, change format to "HHH:MM.M" work_seconds := Integer (diff_secs); total_hours := work_seconds / secs_per_hour; total_hours := total_hours + Integer (diff_days) * 24; if total_hours < 24 then if work_seconds < 0 then return "--:--:--"; else work_seconds := work_seconds - (total_hours * secs_per_hour); total_minutes := work_seconds / 60; work_seconds := work_seconds - (total_minutes * 60); return JT.zeropad (total_hours, 2) & LAT.Colon & JT.zeropad (total_minutes, 2) & LAT.Colon & JT.zeropad (work_seconds, 2); end if; elsif total_hours < 100 then if work_seconds < 0 then return JT.zeropad (total_hours, 2) & ":00:00"; else work_hours := work_seconds / secs_per_hour; work_seconds := work_seconds - (work_hours * secs_per_hour); total_minutes := work_seconds / 60; work_seconds := work_seconds - (total_minutes * 60); return JT.zeropad (total_hours, 2) & LAT.Colon & JT.zeropad (total_minutes, 2) & LAT.Colon & JT.zeropad (work_seconds, 2); end if; else if work_seconds < 0 then return JT.zeropad (total_hours, 3) & ":00.0"; else work_hours := work_seconds / secs_per_hour; work_seconds := work_seconds - (work_hours * secs_per_hour); total_minutes := work_seconds / 60; work_seconds := (work_seconds - (total_minutes * 60)) * 10 / 60; return JT.zeropad (total_hours, 3) & LAT.Colon & JT.zeropad (total_minutes, 2) & '.' & JT.int2str (work_seconds); end if; end if; end elapsed_HH_MM_SS; ------------------- -- elapsed_now -- ------------------- function elapsed_now return String is begin return elapsed_HH_MM_SS (start => start_time, stop => CAL.Clock); end elapsed_now; ----------------------------- -- generic_system_command -- ----------------------------- function generic_system_command (command : String) return JT.Text is content : JT.Text; status : Integer; begin content := Unix.piped_command (command, status); if status /= 0 then raise cycle_cmd_error with "cmd: " & command & " (return code =" & status'Img & ")"; end if; return content; end generic_system_command; --------------------- -- set_uname_mrv -- --------------------- procedure set_uname_mrv is -- valid for all platforms command : constant String := "/usr/bin/uname -mrv"; begin uname_mrv := generic_system_command (command); exception when others => uname_mrv := JT.SUS (discerr); end set_uname_mrv; ---------------- -- get_root -- ---------------- function get_root (id : builders) return String is id_image : constant String := Integer (id)'Img; suffix : String := "/SL00"; begin if id < 10 then suffix (5) := id_image (2); else suffix (4 .. 5) := id_image (2 .. 3); end if; return JT.USS (PM.configuration.dir_buildbase) & suffix; end get_root; ----------------------- -- get_environment -- ----------------------- function get_environment (id : builders) return String is root : constant String := get_root (id); command : constant String := chroot & root & environment_override; begin return JT.USS (generic_system_command (command)); exception when others => return discerr; end get_environment; --------------------------------- -- get_options_configuration -- --------------------------------- function get_options_configuration (id : builders) return String is root : constant String := get_root (id); command : constant String := chroot & root & environment_override & chroot_make_program & " -C " & dir_ports & "/" & get_catport (all_ports (trackers (id).seq_id)); begin case software_framework is when ports_collection => return JT.USS (generic_system_command (command & " showconfig")); when pkgsrc => return JT.USS (generic_system_command (command & " show-options")); end case; exception when others => return discerr; end get_options_configuration; ------------------------ -- split_collection -- ------------------------ function split_collection (line : JT.Text; title : String) return String is -- Support spaces in two ways -- 1) quoted, e.g. TYPING="The Quick Brown Fox" -- 2) Escaped, e.g. TYPING=The\ Quick\ Brown\ Fox meat : JT.Text; waiting : Boolean := True; escaped : Boolean := False; quoted : Boolean := False; keepit : Boolean; counter : Natural := 0; meatlen : Natural := 0; linelen : Natural := JT.SU.Length (line); onechar : String (1 .. 1); meatstr : String (1 .. linelen); begin loop counter := counter + 1; exit when counter > linelen; keepit := True; onechar := JT.SU.Slice (Source => line, Low => counter, High => counter); if onechar (1) = LAT.Reverse_Solidus then -- A) if inside quotes, it's literal -- B) if it's first RS, don't keep but mark escaped -- C) If it's second RS, it's literal, remove escaped -- D) RS can never start a new NV pair if not quoted then if not escaped then keepit := False; end if; escaped := not escaped; end if; elsif escaped then -- E) by definition, next character after an escape is literal -- We know it's not inside quotes. Keep this (could be a space) waiting := False; escaped := not escaped; elsif onechar (1) = LAT.Space then if waiting then keepit := False; else if not quoted then -- name-pair ended, reset waiting := True; quoted := False; onechar (1) := LAT.LF; end if; end if; else waiting := False; if onechar (1) = LAT.Quotation then quoted := not quoted; end if; end if; if keepit then meatlen := meatlen + 1; meatstr (meatlen) := onechar (1); end if; end loop; return log_section (title, True) & LAT.LF & meatstr (1 .. meatlen) & LAT.LF & log_section (title, False) & LAT.LF; end split_collection; -------------------------- -- get_port_variables -- -------------------------- function get_port_variables (id : builders) return JT.Text is root : constant String := get_root (id); command : constant String := chroot & root & environment_override & chroot_make_program & " -C " & dir_ports & "/" & get_catport (all_ports (trackers (id).seq_id)); cmd_fpc : constant String := command & " -VCONFIGURE_ENV -VCONFIGURE_ARGS -VMAKE_ENV -VMAKE_ARGS" & " -VPLIST_SUB -VSUB_LIST"; cmd_nps : constant String := command & " .MAKE.EXPAND_VARIABLES=yes -VCONFIGURE_ENV -VCONFIGURE_ARGS" & " -VMAKE_ENV -VMAKE_FLAGS -VBUILD_MAKE_FLAGS -VPLIST_SUBST" & " -VFILES_SUBST"; begin case software_framework is when ports_collection => return generic_system_command (cmd_fpc); when pkgsrc => return generic_system_command (cmd_nps); end case; exception when others => return JT.SUS (discerr); end get_port_variables; --------------------------- -- dump_port_variables -- --------------------------- procedure dump_port_variables (id : builders; content : JT.Text) is LA : access TIO.File_Type := trackers (id).log_handle'Access; topline : JT.Text; concopy : JT.Text := content; type result_range_fpc is range 1 .. 6; type result_range_nps is range 1 .. 7; begin case software_framework is when ports_collection => for k in result_range_fpc loop JT.nextline (lineblock => concopy, firstline => topline); case k is when 1 => TIO.Put_Line (LA.all, split_collection (topline, "CONFIGURE_ENV")); when 2 => TIO.Put_Line (LA.all, split_collection (topline, "CONFIGURE_ARGS")); when 3 => TIO.Put_Line (LA.all, split_collection (topline, "MAKE_ENV")); when 4 => TIO.Put_Line (LA.all, split_collection (topline, "MAKE_ARGS")); when 5 => TIO.Put_Line (LA.all, split_collection (topline, "PLIST_SUB")); when 6 => TIO.Put_Line (LA.all, split_collection (topline, "SUB_LIST")); end case; end loop; when pkgsrc => for k in result_range_nps loop JT.nextline (lineblock => concopy, firstline => topline); case k is when 1 => TIO.Put_Line (LA.all, split_collection (topline, "CONFIGURE_ENV")); when 2 => TIO.Put_Line (LA.all, split_collection (topline, "CONFIGURE_ARGS")); when 3 => TIO.Put_Line (LA.all, split_collection (topline, "MAKE_ENV")); when 4 => TIO.Put_Line (LA.all, split_collection (topline, "MAKE_FLAGS")); when 5 => TIO.Put_Line (LA.all, split_collection (topline, "BUILD_MAKE_FLAGS")); when 6 => TIO.Put_Line (LA.all, split_collection (topline, "PLIST_SUBST")); when 7 => TIO.Put_Line (LA.all, split_collection (topline, "FILES_SUBST")); end case; end loop; end case; end dump_port_variables; ---------------- -- log_name -- ---------------- function log_name (sid : port_id) return String is catport : constant String := get_catport (all_ports (sid)); begin return JT.USS (PM.configuration.dir_logs) & "/" & JT.part_1 (catport) & "___" & JT.part_2 (catport) & ".log"; end log_name; ----------------- -- dump_file -- ----------------- function dump_file (filename : String) return String is File_Size : Natural := Natural (AD.Size (filename)); subtype File_String is String (1 .. File_Size); package File_String_IO is new Ada.Direct_IO (File_String); File : File_String_IO.File_Type; Contents : File_String; begin File_String_IO.Open (File, Mode => File_String_IO.In_File, Name => filename); File_String_IO.Read (File, Item => Contents); File_String_IO.Close (File); return String (Contents); end dump_file; ---------------------- -- dump_make_conf -- ---------------------- function dump_make_conf (id : builders; conf_file : String) return String is root : constant String := get_root (id); filename : constant String := root & conf_file; begin return dump_file (filename); end dump_make_conf; ------------------ -- initialize -- ------------------ procedure initialize (test_mode : Boolean; jail_env : JT.Text) is begin set_uname_mrv; testing := test_mode; lock_localbase := testing and then Unix.env_variable_defined ("LOCK"); slave_env := jail_env; declare logdir : constant String := JT.USS (PM.configuration.dir_logs); begin if not AD.Exists (logdir) then AD.Create_Path (New_Directory => logdir); end if; exception when error : others => raise cycle_log_error with "failed to create " & logdir; end; obtain_custom_environment; end initialize; ------------------- -- log_section -- ------------------- function log_section (title : String; header : Boolean) return String is hyphens : constant String := (1 .. 50 => '-'); begin if header then return LAT.LF & hyphens & LAT.LF & "-- " & title & LAT.LF & hyphens; else return ""; end if; end log_section; --------------------- -- log_phase_end -- --------------------- procedure log_phase_end (id : builders) is begin TIO.Put_Line (trackers (id).log_handle, "" & LAT.LF); end log_phase_end; ----------------------- -- log_phase_begin -- ----------------------- procedure log_phase_begin (phase : String; id : builders) is hyphens : constant String := (1 .. 80 => '-'); middle : constant String := "-- Phase: " & phase; begin TIO.Put_Line (trackers (id).log_handle, LAT.LF & hyphens & LAT.LF & middle & LAT.LF & hyphens); end log_phase_begin; ----------------------- -- generic_execute -- ----------------------- function generic_execute (id : builders; command : String; dogbite : out Boolean; time_limit : execution_limit) return Boolean is subtype time_cycle is execution_limit range 1 .. time_limit; subtype one_minute is Positive range 1 .. 230; -- lose 10 in rounding type dim_watchdog is array (time_cycle) of Natural; use type Unix.process_exit; watchdog : dim_watchdog; squirrel : time_cycle := time_cycle'First; cycle_done : Boolean := False; pid : Unix.pid_t; status : Unix.process_exit; lock_lines : Natural; quartersec : one_minute := one_minute'First; hangmonitor : constant Boolean := True; synthexec : constant String := host_localbase & "/libexec/synthexec"; truecommand : constant String := synthexec & " " & log_name (trackers (id).seq_id) & " " & command; begin dogbite := False; watchdog (squirrel) := trackers (id).loglines; pid := Unix.launch_process (truecommand); if Unix.fork_failed (pid) then return False; end if; loop delay 0.25; if quartersec = one_minute'Last then quartersec := one_minute'First; -- increment squirrel if squirrel = time_cycle'Last then squirrel := time_cycle'First; cycle_done := True; else squirrel := squirrel + 1; end if; if hangmonitor then lock_lines := trackers (id).loglines; if cycle_done then if watchdog (squirrel) = lock_lines then -- Log hasn't advanced in a full cycle so bail out dogbite := True; Unix.kill_process_tree (process_group => pid); delay 5.0; -- Give some time for error to write to log return False; end if; end if; watchdog (squirrel) := lock_lines; end if; else quartersec := quartersec + 1; end if; status := Unix.process_status (pid); if status = Unix.exited_normally then return True; end if; if status = Unix.exited_with_error then return False; end if; end loop; end generic_execute; ---------------------------- -- log_linked_libraries -- ---------------------------- procedure stack_linked_libraries (id : builders; base, filename : String) is command : String := chroot & base & " /usr/bin/objdump -p " & filename; comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; begin comres := generic_system_command (command); crlen1 := JT.SU.Length (comres); loop JT.nextline (lineblock => comres, firstline => topline); crlen2 := JT.SU.Length (comres); exit when crlen1 = crlen2; crlen1 := crlen2; if not JT.IsBlank (topline) then if JT.contains (topline, "NEEDED") then if not trackers (id).dynlink.Contains (topline) then trackers (id).dynlink.Append (topline); end if; end if; end if; end loop; exception -- the command result was not zero, so it was an expected format -- or static file. Just skip it. (Should never happen) when bad_result : others => null; end stack_linked_libraries; ---------------------------- -- log_linked_libraries -- ---------------------------- procedure log_linked_libraries (id : builders) is procedure log_dump (cursor : string_crate.Cursor); comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; pkgfile : constant String := JT.USS (all_ports (trackers (id).seq_id).package_name); pkgname : constant String := pkgfile (1 .. pkgfile'Last - 4); root : constant String := get_root (id); command : constant String := chroot & root & environment_override & REP.root_localbase & "/sbin/pkg-static query %Fp " & pkgname; procedure log_dump (cursor : string_crate.Cursor) is begin TIO.Put_Line (trackers (id).log_handle, JT.USS (string_crate.Element (Position => cursor))); end log_dump; begin TIO.Put_Line (trackers (id).log_handle, "=> Checking shared library dependencies"); comres := generic_system_command (command); crlen1 := JT.SU.Length (comres); loop JT.nextline (lineblock => comres, firstline => topline); crlen2 := JT.SU.Length (comres); exit when crlen1 = crlen2; crlen1 := crlen2; if REP.Platform.dynamically_linked (root, JT.USS (topline)) then stack_linked_libraries (id, root, JT.USS (topline)); end if; end loop; trackers (id).dynlink.Iterate (log_dump'Access); exception when others => null; end log_linked_libraries; ---------------------------- -- environment_override -- ---------------------------- function environment_override (enable_tty : Boolean := False) return String is function set_terminal (enable_tty : Boolean) return String; function set_terminal (enable_tty : Boolean) return String is begin if enable_tty then return "TERM=cons25 "; end if; return "TERM=dumb "; end set_terminal; PATH : constant String := "PATH=/sbin:/bin:/usr/sbin:/usr/bin:" & REP.root_localbase & "/sbin:" & REP.root_localbase & "/bin "; TERM : constant String := set_terminal (enable_tty); USER : constant String := "USER=root "; HOME : constant String := "HOME=/root "; LANG : constant String := "LANG=C "; FTP : constant String := "SSL_NO_VERIFY_PEER=1 "; PKG8 : constant String := "PORTSDIR=" & dir_ports & " " & "PKG_DBDIR=/var/db/pkg8 " & "PKG_CACHEDIR=/var/cache/pkg8 "; CENV : constant String := JT.USS (customenv); JENV : constant String := JT.USS (slave_env); begin return " /usr/bin/env -i " & USER & HOME & LANG & PKG8 & TERM & FTP & PATH & JENV & CENV; end environment_override; --------------------- -- set_log_lines -- --------------------- procedure set_log_lines (id : builders) is log_path : constant String := log_name (trackers (id).seq_id); command : constant String := "/usr/bin/wc -l " & log_path; comres : JT.Text; begin if not uselog then trackers (id).loglines := 0; return; end if; comres := JT.trim (generic_system_command (command)); declare numtext : constant String := JT.part_1 (S => JT.USS (comres), separator => " "); begin trackers (id).loglines := Natural'Value (numtext); end; exception when others => null; -- just skip this cycle end set_log_lines; ----------------------- -- format_loglines -- ----------------------- function format_loglines (numlines : Natural) return String is begin if numlines < 10000000 then -- 10 million return JT.int2str (numlines); end if; declare kilo : constant Natural := numlines / 1000; kilotxt : constant String := JT.int2str (kilo); begin if numlines < 100000000 then -- 100 million return kilotxt (1 .. 2) & "." & kilotxt (3 .. 5) & 'M'; elsif numlines < 1000000000 then -- 1 billion return kilotxt (1 .. 3) & "." & kilotxt (3 .. 4) & 'M'; else return kilotxt (1 .. 4) & "." & kilotxt (3 .. 3) & 'M'; end if; end; end format_loglines; --------------------- -- elapsed_build -- --------------------- function elapsed_build (id : builders) return String is begin return elapsed_HH_MM_SS (start => trackers (id).head_time, stop => trackers (id).tail_time); end elapsed_build; ----------------------------- -- get_packages_per_hour -- ----------------------------- function get_packages_per_hour (packages_done : Natural; from_when : CAL.Time) return Natural is diff_days : ACA.Day_Count; diff_secs : Duration; leap_secs : ACA.Leap_Seconds_Count; result : Natural; rightnow : CAL.Time := CAL.Clock; work_seconds : Integer; work_days : Integer; use type ACA.Day_Count; begin if packages_done = 0 then return 0; end if; ACA.Difference (Left => rightnow, Right => from_when, Days => diff_days, Seconds => diff_secs, Leap_Seconds => leap_secs); work_seconds := Integer (diff_secs); work_days := Integer (diff_days); work_seconds := work_seconds + (work_days * 3600 * 24); if work_seconds < 0 then -- should be impossible to get here. return 0; end if; result := packages_done * 3600; result := result / work_seconds; return result; exception when others => return 0; end get_packages_per_hour; ------------------------ -- mark_file_system -- ------------------------ procedure mark_file_system (id : builders; action : String) is function attributes (action : String) return String; function attributes (action : String) return String is core : constant String := "uid,gid,mode,md5digest"; begin if action = "preconfig" then return core & ",time"; else return core; end if; end attributes; path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base"; path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" & JT.zeropad (Natural (id), 2); mtfile : constant String := path_mm & "/mtree." & action & ".exclude"; command : constant String := "/usr/sbin/mtree -X " & mtfile & " -cn -k " & attributes (action) & " -p " & path_sm; filename : constant String := path_sm & "/tmp/mtree." & action; result : JT.Text; resfile : TIO.File_Type; begin result := generic_system_command (command); TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename); TIO.Put (resfile, JT.USS (result)); TIO.Close (resfile); exception when cycle_cmd_error => null; when others => if TIO.Is_Open (resfile) then TIO.Close (resfile); end if; end mark_file_system; -------------------------------- -- detect_leftovers_and_MIA -- -------------------------------- function detect_leftovers_and_MIA (id : builders; action : String; description : String) return Boolean is package crate is new AC.Vectors (Index_Type => Positive, Element_Type => JT.Text, "=" => JT.SU."="); package sorter is new crate.Generic_Sorting ("<" => JT.SU."<"); function ignore_modifications return Boolean; procedure print (cursor : crate.Cursor); procedure close_active_modifications; path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base"; path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" & JT.zeropad (Natural (id), 2); mtfile : constant String := path_mm & "/mtree." & action & ".exclude"; filename : constant String := path_sm & "/tmp/mtree." & action; command : constant String := "/usr/sbin/mtree -X " & mtfile & " -f " & filename & " -p " & path_sm; status : Integer; comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; toplen : Natural; skiprest : Boolean; passed : Boolean := True; activemod : Boolean := False; modport : JT.Text := JT.blank; reasons : JT.Text := JT.blank; leftover : crate.Vector; missing : crate.Vector; changed : crate.Vector; function ignore_modifications return Boolean is -- Some modifications need to be ignored -- A) */ls-R -- #ls-R files from texmf are often regenerated -- B) share/xml/catalog.ports -- # xmlcatmgr is constantly updating catalog.ports, ignore -- C) share/octave/octave_packages -- # Octave packages database, blank lines can be inserted -- # between pre-install and post-deinstall -- D) info/dir | */info/dir -- E) lib/gio/modules/giomodule.cache -- # gio modules cache could be modified for any gio modules -- F) etc/gconf/gconf.xml.defaults/%gconf-tree*.xml -- # gconftool-2 --makefile-uninstall-rule is unpredictable -- G) %%PEARDIR%%/.depdb | %%PEARDIR%%/.filemap -- # The is pear database cache -- H) "." with timestamp modification -- # this happens when ./tmp or ./var is used, which is legal filename : constant String := JT.USS (modport); fnlen : constant Natural := filename'Length; begin if filename = "usr/local/share/xml/catalog.ports" or else filename = "usr/local/share/octave/octave_packages" or else filename = "usr/local/info/dir" or else filename = "usr/local/lib/gio/modules/giomodule.cache" or else filename = "usr/local/share/pear/.depdb" or else filename = "usr/local/share/pear/.filemap" then return True; end if; if filename = "." and then JT.equivalent (reasons, "modification") then return True; end if; if fnlen > 17 and then filename (1 .. 10) = "usr/local/" then if filename (fnlen - 4 .. fnlen) = "/ls-R" or else filename (fnlen - 8 .. fnlen) = "/info/dir" then return True; end if; end if; if fnlen > 56 and then filename (1 .. 39) = "usr/local/etc/gconf/gconf.xml.defaults/" and then filename (fnlen - 3 .. fnlen) = ".xml" then if JT.contains (filename, "/%gconf-tree") then return True; end if; end if; return False; end ignore_modifications; procedure close_active_modifications is begin if activemod and then not ignore_modifications then JT.SU.Append (modport, " [ "); JT.SU.Append (modport, reasons); JT.SU.Append (modport, " ]"); if not changed.Contains (modport) then changed.Append (modport); end if; end if; activemod := False; reasons := JT.blank; modport := JT.blank; end close_active_modifications; procedure print (cursor : crate.Cursor) is dossier : constant String := JT.USS (crate.Element (cursor)); begin TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier); end print; begin -- we can't use generic_system_command because exit code /= 0 normally comres := Unix.piped_command (command, status); crlen1 := JT.SU.Length (comres); loop skiprest := False; JT.nextline (lineblock => comres, firstline => topline); crlen2 := JT.SU.Length (comres); exit when crlen1 = crlen2; crlen1 := crlen2; toplen := JT.SU.Length (topline); if not skiprest and then JT.SU.Length (topline) > 6 then declare sx : constant Natural := toplen - 5; caboose : constant String := JT.SU.Slice (topline, sx, toplen); filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 1, sx - 1)); begin if caboose = " extra" then close_active_modifications; if not leftover.Contains (filename) then leftover.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest and then JT.SU.Length (topline) > 7 then declare canopy : constant String := JT.SU.Slice (topline, 1, 7); filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 8, toplen)); begin if canopy = "extra: " then close_active_modifications; if not leftover.Contains (filename) then leftover.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest and then JT.SU.Length (topline) > 10 then declare sx : constant Natural := toplen - 7; caboose : constant String := JT.SU.Slice (topline, sx, toplen); filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 3, sx - 1)); begin if caboose = " missing" then close_active_modifications; if not missing.Contains (filename) then missing.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest then declare line : constant String := JT.USS (topline); blank8 : constant String := " "; sx : constant Natural := toplen - 7; begin if toplen > 5 and then line (1) = LAT.HT then -- reason, but only valid if modification is active if activemod then if JT.IsBlank (reasons) then reasons := JT.SUS (JT.part_1 (line (2 .. toplen), " ")); else JT.SU.Append (reasons, " | "); JT.SU.Append (reasons, JT.part_1 (line (2 .. toplen), " ")); end if; end if; skiprest := True; end if; if not skiprest and then line (toplen) = LAT.Colon then close_active_modifications; activemod := True; modport := JT.SUS (line (1 .. toplen - 1)); skiprest := True; end if; if not skiprest and then JT.SU.Slice (topline, sx, toplen) = " changed" then close_active_modifications; activemod := True; modport := JT.SUS (line (1 .. toplen - 8)); skiprest := True; end if; end; end if; end loop; close_active_modifications; sorter.Sort (Container => changed); sorter.Sort (Container => missing); sorter.Sort (Container => leftover); TIO.Put_Line (trackers (id).log_handle, LAT.LF & "=> Checking for " & "system changes " & description); if not leftover.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Left over files/directories:"); leftover.Iterate (Process => print'Access); end if; if not missing.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Missing files/directories:"); missing.Iterate (Process => print'Access); end if; if not changed.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Modified files/directories:"); changed.Iterate (Process => print'Access); end if; if passed then TIO.Put_Line (trackers (id).log_handle, "Everything is fine."); end if; return passed; end detect_leftovers_and_MIA; ----------------------------- -- interact_with_builder -- ----------------------------- procedure interact_with_builder (id : builders) is root : constant String := get_root (id); command : constant String := chroot & root & environment_override (enable_tty => True) & REP.Platform.interactive_shell; result : Boolean; begin TIO.Put_Line ("Entering interactive test mode at the builder root " & "directory."); TIO.Put_Line ("Type 'exit' when done exploring."); result := Unix.external_command (command); end interact_with_builder; --------------------------------- -- obtain_custom_environment -- --------------------------------- procedure obtain_custom_environment is target_name : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-environment"; fragment : TIO.File_Type; begin customenv := JT.blank; if AD.Exists (target_name) then TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name); while not TIO.End_Of_File (fragment) loop declare Line : String := TIO.Get_Line (fragment); begin if JT.contains (Line, "=") then JT.SU.Append (customenv, JT.trim (Line) & " "); end if; end; end loop; TIO.Close (fragment); end if; exception when others => if TIO.Is_Open (fragment) then TIO.Close (fragment); end if; end obtain_custom_environment; -------------------------------- -- set_localbase_protection -- -------------------------------- procedure set_localbase_protection (id : builders; lock : Boolean) is procedure remount (readonly : Boolean); procedure dismount; smount : constant String := get_root (id); slave_local : constant String := smount & "_localbase"; procedure remount (readonly : Boolean) is cmd_freebsd : String := "/sbin/mount_nullfs "; cmd_dragonfly : String := "/sbin/mount_null "; points : String := slave_local & " " & smount & REP.root_localbase; options : String := "-o ro "; cmd : JT.Text; cmd_output : JT.Text; begin if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then cmd := JT.SUS (cmd_freebsd); else cmd := JT.SUS (cmd_dragonfly); end if; if readonly then JT.SU.Append (cmd, options); end if; JT.SU.Append (cmd, points); if not Unix.piped_mute_command (JT.USS (cmd), cmd_output) then if uselog then TIO.Put_Line (trackers (id).log_handle, "command failed: " & JT.USS (cmd)); if not JT.IsBlank (cmd_output) then TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output)); end if; end if; end if; end remount; procedure dismount is cmd_unmount : constant String := "/sbin/umount " & smount & REP.root_localbase; cmd_output : JT.Text; begin if not Unix.piped_mute_command (cmd_unmount, cmd_output) then if uselog then TIO.Put_Line (trackers (id).log_handle, "command failed: " & cmd_unmount); if not JT.IsBlank (cmd_output) then TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output)); end if; end if; end if; end dismount; begin if lock then dismount; remount (readonly => True); else dismount; remount (readonly => False); end if; end set_localbase_protection; ------------------------------ -- timeout_multiplier_x10 -- ------------------------------ function timeout_multiplier_x10 return Positive is average5 : constant Float := REP.Platform.get_5_minute_load; avefloat : constant Float := average5 / Float (number_cores); begin if avefloat <= 1.0 then return 10; else return Integer (avefloat * 10.0); end if; exception when others => return 10; end timeout_multiplier_x10; --------------------------- -- valid_test_phase #2 -- --------------------------- function valid_test_phase (afterphase : String) return Boolean is begin if afterphase = "extract" or else afterphase = "patch" or else afterphase = "configure" or else afterphase = "build" or else afterphase = "stage" or else afterphase = "install" or else afterphase = "deinstall" then return True; else return False; end if; end valid_test_phase; --------------------------- -- builder_status_core -- --------------------------- function builder_status_core (id : builders; shutdown : Boolean := False; idle : Boolean := False; phasestr : String) return Display.builder_rec is result : Display.builder_rec; phaselen : constant Positive := phasestr'Length; begin -- 123456789 123456789 123456789 123456789 1234 -- SL elapsed phase lines origin -- 01 00:00:00 extract-depends 9999999 www/joe result.id := id; result.slavid := JT.zeropad (Natural (id), 2); result.LLines := (others => ' '); result.phase := (others => ' '); result.origin := (others => ' '); result.shutdown := False; result.idle := False; if shutdown then -- Overrides "idle" if both Shutdown and Idle are True result.Elapsed := "Shutdown"; result.shutdown := True; return result; end if; if idle then result.Elapsed := "Idle "; result.idle := True; return result; end if; declare catport : constant String := get_catport (all_ports (trackers (id).seq_id)); numlines : constant String := format_loglines (trackers (id).loglines); linehead : constant Natural := 8 - numlines'Length; begin result.Elapsed := elapsed_HH_MM_SS (start => trackers (id).head_time, stop => CAL.Clock); result.LLines (linehead .. 7) := numlines; if phaselen <= result.phase'Length then result.phase (1 .. phasestr'Length) := phasestr; else -- special handling for long descriptions if phasestr = "bootstrap-depends" then result.phase (1 .. 14) := "bootstrap-deps"; else result.phase := phasestr (phasestr'First .. phasestr'First + result.phase'Length - 1); end if; end if; if catport'Length > 37 then result.origin (1 .. 36) := catport (1 .. 36); result.origin (37) := LAT.Asterisk; else result.origin (1 .. catport'Length) := catport; end if; end; return result; end builder_status_core; end PortScan.Buildcycle;
jamiepg1/sdlada
Ada
2,915
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 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; 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 C.int 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;
reznikmm/matreshka
Ada
3,684
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.Form_Size_Attributes is pragma Preelaborate; type ODF_Form_Size_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Size_Attribute_Access is access all ODF_Form_Size_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Size_Attributes;
zhmu/ananas
Ada
106
ads
package Compile_Time1_Pkg is type Rec is record I : Integer; end record; end Compile_Time1_Pkg;
AdaCore/training_material
Ada
266
adb
procedure Main is type Acc is access all Integer; O : Acc; procedure Set_Value (V : access Integer) is begin O := Acc (V); end Set_Value; begin declare O2 : aliased Integer := 2; begin Set_Value (O2'Access); end; end Main;
jscparker/math_packages
Ada
4,332
ads
generic package Extended_Real.IO is -- E_real Text translation. function e_Real_Image (X : in e_Real; Aft : in Positive := Positive'Last) return String; -- e_Real to Text translation. -- Minimum length of Aft is 12. If less, it gets set to 12. -- The number of digits in the result is the minimum of the 3 quantities: -- Aft+1, Max_No_Of_Digits, and Max_Practical_String_Length. Aft is -- input by the user: it's the number of decimal digits beyond the -- decimal point. Max_No_Of_Digits is slightly greater than the -- Desired_Decimal_Digit_Precision, the generic parameter. (see below.) -- Text to E_real translation. -- The following Sets define white space. In translation from ASCII to -- e_Real only white space may separate the numbers in ASCII format. -- The present setting is standard white space on UNIX workstations and -- Crays. The parenthesis are used by complex numbers. type Set is Array(Character) of Boolean; pragma Pack (Set); Is_White_Space : constant Set := (' ' | ',' | '(' | ')' => True, others => False); Is_Exp_Symbol : constant Set := ('E' | 'e' | 'D' | 'd' => True, others => False); procedure e_Real_Val (X : in String; Y : out e_Real; Last : out Natural); -- Accepts many non Ada standard formats of the sort found in ascii output -- on common machines. Also accepts formats of the sort one is likely -- to type in at the key board. Accepts the following formats: -- -- INTEGER : 1234567 or +1234567 or -1234567 -- DECIMAL : 12.34567 or -.1234567 or +.1234567 or 1234567. -- EXPONENTIAL : 1234.567E+002 or .1234567E002 or 123467.E-03 -- NON_DECIMAL_EXPONENTIAL : -1234567E-003 -- -- Notice that -- 0) Both the 'E' and the '.' are optional. -- 1) If an 'E' exists, then the '.' may be anywhere to the left of the 'E'. -- 2) The Leading sign is optional if its '+'. -- 3) The sign of the exponent is optional if its '+'. -- 4) The set Is_Exp_Symbol determines which Exp symbols are acceptible. -- -- "Last" is the index of the last character of the Number. The purpose -- is to allow one to read numbers sequentially from a string by inputting -- string X(Last+1..X'Length) once the value of Last is determined. -- -- We leave it up to the extended arithm. package to raise constraint_error -- when the Exponent is out of range. E_Format_Error : Exception; private -- Parameters that determine the maximum size of the output string: No_Of_Decimal_Digits_Per_Chunk : constant := 6; -- 8 is good if Radix is big enough (see next Assert). pragma Assert (10.0**No_Of_Decimal_Digits_Per_Chunk < Radix_Minus_1); -- The Decimal value of e_Real is actually calculated in -- Radix 10.0**No_Of_Decimal_Digits_Per_Chunk. i.e. in chunks of 5-8 digits. Bits_Per_e_Real : constant := No_Of_Bits_In_Radix * Mantissa'Length; Decimal_Digits_Per_e_Real : constant := 1 + (Bits_Per_e_Real*1000 - 1) / 3322; -- Ceiling (Bits_Per_e_Real / 3.322). Chunks_Per_e_Real : constant := 1 + (Decimal_Digits_Per_e_Real - 1) / No_Of_Decimal_Digits_Per_Chunk; -- Ceiling (Decimal_Digits_Per_e_Real / No_Of_Decimal_Digits_Per_Chunk) Max_No_Of_Digits : constant Positive := No_Of_Decimal_Digits_Per_Chunk * Chunks_Per_e_Real - 4; -- -- Notice: it keeps some of the digits beyond the number supposedly held -- in the input e_Real (Item). By keeping these extra digits at the end, -- you reduce the Max error in translating from binary to ascii back to -- binary again. -- -- Subtract 4 because they always seem to be noise anyway. pragma Assert (Max_Exponent <= 2 ** (e_Integer'Size - 5)); -- Just making sure. Doesn't work for excessively large Max_Exponent. pragma Assert (e_Integer'Size <= Integer'Size); -- Essentially requires 32 bit Integer or greater. Max_Practical_String_Length : constant Positive := Max_No_Of_Digits + 19; -- Maximum size of the output strings. -- Set to whatever you think is appropriate. -- Strings this size are actually created, so memory must be sufficient. end Extended_Real.IO;
ficorax/PortAudioAda
Ada
889
adb
with Gtk.Main; package body GA_Waves_Package is function Delete_Event (Widget : access Gtk_Widget_Record'Class; Event : Gdk_Event) return Boolean is pragma Unreferenced (Event); pragma Unreferenced (Widget); begin -- If you return False in the "delete_event" signal handler, -- GtkAda will emit the "destroy" signal. Returning True means -- you don't want the window to be destroyed. This is useful -- for popping up 'are you sure you want to quit?' type -- dialogs. -- Change True to False and the main window will be destroyed -- with a "delete_event". return False; end Delete_Event; -- Another callback procedure Destroy (Widget : access Gtk_Widget_Record'Class) is pragma Unreferenced (Widget); begin Gtk.Main.Main_Quit; end Destroy; end GA_Waves_Package;
francesco-bongiovanni/ewok-kernel
Ada
3,918
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with m4.mpu; with types; package soc.layout with spark_mode => on is FLASH_BASE : constant system_address := 16#0800_0000#; FLASH_SIZE : constant := 1 * MBYTE; SRAM_BASE : constant system_address := 16#1000_0000#; SRAM_SIZE : constant := 64 * KBYTE; BOOTROM_BASE : constant system_address := 16#1FFF_0000#; RAM_BASE : constant system_address := 16#2000_0000#; -- SRAM RAM_SIZE : constant := 128 * KBYTE; PERIPH_BASE : constant system_address := 16#4000_0000#; MEMORY_BANK1_BASE : constant system_address := 16#6000_0000#; MEMORY_BANK2_BASE : constant system_address := MEMORY_BANK1_BASE; APB1PERIPH_BASE : constant system_address := PERIPH_BASE; APB2PERIPH_BASE : constant system_address := PERIPH_BASE + 16#0001_0000#; AHB1PERIPH_BASE : constant system_address := PERIPH_BASE + 16#0002_0000#; AHB2PERIPH_BASE : constant system_address := PERIPH_BASE + 16#1000_0000#; -- -- AHB1 peripherals -- GPIOA_BASE : constant system_address := AHB1PERIPH_BASE + 16#0000#; GPIOB_BASE : constant system_address := AHB1PERIPH_BASE + 16#0400#; GPIOC_BASE : constant system_address := AHB1PERIPH_BASE + 16#0800#; GPIOD_BASE : constant system_address := AHB1PERIPH_BASE + 16#0C00#; GPIOE_BASE : constant system_address := AHB1PERIPH_BASE + 16#1000#; GPIOF_BASE : constant system_address := AHB1PERIPH_BASE + 16#1400#; GPIOG_BASE : constant system_address := AHB1PERIPH_BASE + 16#1800#; GPIOH_BASE : constant system_address := AHB1PERIPH_BASE + 16#1C00#; GPIOI_BASE : constant system_address := AHB1PERIPH_BASE + 16#2000#; DMA1_BASE : constant system_address := AHB1PERIPH_BASE + 16#6000#; DMA2_BASE : constant system_address := AHB1PERIPH_BASE + 16#6400#; -- -- APB2 peripherals -- SYSCFG_BASE : constant system_address := APB2PERIPH_BASE + 16#3800#; -- -- Flash and firmware structure -- -- -- Flip bank FW1_SIZE : constant unsigned_32 := 576*1024; FW1_KERN_BASE : constant unsigned_32 := 16#08020000#; FW1_KERN_SIZE : constant unsigned_32 := 64*1024; FW1_KERN_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_64KB; FW1_USER_BASE : constant unsigned_32 := 16#08080000#; FW1_USER_SIZE : constant unsigned_32 := 512*1024; FW1_USER_REGION_SIZE : constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_512KB; -- DFU 1 DFU1_SIZE : constant unsigned_32 := 320*1024; DFU1_KERN_BASE : constant unsigned_32 := 16#08030000#; DFU1_USER_BASE : constant unsigned_32 := 16#08040000#; DFU1_KERN_SIZE : constant unsigned_32 := 64*1024; DFU1_KERN_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_64KB; DFU1_USER_SIZE : constant unsigned_32 := 256*1024; DFU1_USER_REGION_SIZE: constant m4.mpu.t_region_size := m4.mpu.REGION_SIZE_256KB; -- STM32F429 has 1MB flash that can be mapped at a time, which forbid -- the usage of efficient dual banking. -- This layout does not declare the complete dual bank end soc.layout;
reznikmm/matreshka
Ada
3,636
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Read_Variable_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Read_Variable_Action, UML_Read_Variable_Action_Access);
AdaCore/gpr
Ada
844
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with GPR2.Context; with GPR2.Project.View; with GPR2.Project.Tree; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Display (Prj : Project.View.Object); ------------- -- Display -- ------------- procedure Display (Prj : Project.View.Object) is use Text_IO; begin Put (String (Prj.Name) & " "); Set_Col (10); Put_Line (Prj.Qualifier'Img); Put_Line ("Has Extended: " & Boolean'Image (Prj.Is_Extending)); Put_Line ("Is Extended all: " & Boolean'Image (Prj.Is_Extending_All)); end Display; Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj, Project.Create ("prj2.gpr"), Ctx); Display (Prj.Root_Project); end Main;
reznikmm/matreshka
Ada
52,929
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.OCL_Attributes; with AMF.String_Collections; with AMF.UML.Classifier_Template_Parameters; with AMF.UML.Classifiers.Collections; with AMF.UML.Collaboration_Uses.Collections; with AMF.UML.Comments.Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Features.Collections; with AMF.UML.Generalization_Sets.Collections; with AMF.UML.Generalizations.Collections; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces.Collections; with AMF.UML.Operations.Collections; with AMF.UML.Package_Imports.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements.Collections; with AMF.UML.Properties.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.Redefinable_Template_Signatures; with AMF.UML.String_Expressions; with AMF.UML.Substitutions.Collections; with AMF.UML.Template_Bindings.Collections; with AMF.UML.Template_Parameters; with AMF.UML.Template_Signatures; with AMF.UML.Types; with AMF.UML.Use_Cases.Collections; with AMF.Visitors.OCL_Iterators; with AMF.Visitors.OCL_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.OCL_Sequence_Types is ---------------------- -- Get_Element_Type -- ---------------------- overriding function Get_Element_Type (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access is begin return AMF.UML.Classifiers.UML_Classifier_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Type (Self.Element))); end Get_Element_Type; ---------------------- -- Set_Element_Type -- ---------------------- overriding procedure Set_Element_Type (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Classifiers.UML_Classifier_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Element_Type (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Element_Type; ------------------------- -- Get_Owned_Attribute -- ------------------------- overriding function Get_Owned_Attribute (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property is begin return AMF.UML.Properties.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Attribute (Self.Element))); end Get_Owned_Attribute; ------------------------- -- Get_Owned_Operation -- ------------------------- overriding function Get_Owned_Operation (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation is begin return AMF.UML.Operations.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Operation (Self.Element))); end Get_Owned_Operation; ------------------- -- Get_Attribute -- ------------------- overriding function Get_Attribute (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Properties.Collections.Set_Of_UML_Property is begin return AMF.UML.Properties.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Attribute (Self.Element))); end Get_Attribute; --------------------------- -- Get_Collaboration_Use -- --------------------------- overriding function Get_Collaboration_Use (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use is begin return AMF.UML.Collaboration_Uses.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Collaboration_Use (Self.Element))); end Get_Collaboration_Use; ----------------- -- Get_Feature -- ----------------- overriding function Get_Feature (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature is begin return AMF.UML.Features.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Feature (Self.Element))); end Get_Feature; ----------------- -- Get_General -- ----------------- overriding function Get_General (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_General (Self.Element))); end Get_General; ------------------------ -- Get_Generalization -- ------------------------ overriding function Get_Generalization (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization is begin return AMF.UML.Generalizations.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Generalization (Self.Element))); end Get_Generalization; -------------------------- -- Get_Inherited_Member -- -------------------------- overriding function Get_Inherited_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Inherited_Member (Self.Element))); end Get_Inherited_Member; --------------------- -- Get_Is_Abstract -- --------------------- overriding function Get_Is_Abstract (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Abstract (Self.Element); end Get_Is_Abstract; --------------------- -- Set_Is_Abstract -- --------------------- overriding procedure Set_Is_Abstract (Self : not null access OCL_Sequence_Type_Proxy; To : Boolean) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Abstract (Self.Element, To); end Set_Is_Abstract; --------------------------------- -- Get_Is_Final_Specialization -- --------------------------------- overriding function Get_Is_Final_Specialization (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Final_Specialization (Self.Element); end Get_Is_Final_Specialization; --------------------------------- -- Set_Is_Final_Specialization -- --------------------------------- overriding procedure Set_Is_Final_Specialization (Self : not null access OCL_Sequence_Type_Proxy; To : Boolean) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Final_Specialization (Self.Element, To); end Set_Is_Final_Specialization; ---------------------------------- -- Get_Owned_Template_Signature -- ---------------------------------- overriding function Get_Owned_Template_Signature (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access is begin return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature (Self.Element))); end Get_Owned_Template_Signature; ---------------------------------- -- Set_Owned_Template_Signature -- ---------------------------------- overriding procedure Set_Owned_Template_Signature (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owned_Template_Signature; ------------------------ -- Get_Owned_Use_Case -- ------------------------ overriding function Get_Owned_Use_Case (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is begin return AMF.UML.Use_Cases.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Use_Case (Self.Element))); end Get_Owned_Use_Case; -------------------------- -- Get_Powertype_Extent -- -------------------------- overriding function Get_Powertype_Extent (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set is begin return AMF.UML.Generalization_Sets.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Powertype_Extent (Self.Element))); end Get_Powertype_Extent; ------------------------------ -- Get_Redefined_Classifier -- ------------------------------ overriding function Get_Redefined_Classifier (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Classifier (Self.Element))); end Get_Redefined_Classifier; ------------------------ -- Get_Representation -- ------------------------ overriding function Get_Representation (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access is begin return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Representation (Self.Element))); end Get_Representation; ------------------------ -- Set_Representation -- ------------------------ overriding procedure Set_Representation (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Representation (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Representation; ---------------------- -- Get_Substitution -- ---------------------- overriding function Get_Substitution (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution is begin return AMF.UML.Substitutions.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Substitution (Self.Element))); end Get_Substitution; ---------------------------- -- Get_Template_Parameter -- ---------------------------- overriding function Get_Template_Parameter (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access is begin return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; ------------------ -- Get_Use_Case -- ------------------ overriding function Get_Use_Case (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case is begin return AMF.UML.Use_Cases.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Use_Case (Self.Element))); end Get_Use_Case; ------------------------ -- Get_Element_Import -- ------------------------ overriding function Get_Element_Import (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import is begin return AMF.UML.Element_Imports.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Element_Import (Self.Element))); end Get_Element_Import; ------------------------- -- Get_Imported_Member -- ------------------------- overriding function Get_Imported_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin return AMF.UML.Packageable_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Imported_Member (Self.Element))); end Get_Imported_Member; ---------------- -- Get_Member -- ---------------- overriding function Get_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Member (Self.Element))); end Get_Member; ---------------------- -- Get_Owned_Member -- ---------------------- overriding function Get_Owned_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Member (Self.Element))); end Get_Owned_Member; -------------------- -- Get_Owned_Rule -- -------------------- overriding function Get_Owned_Rule (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is begin return AMF.UML.Constraints.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Rule (Self.Element))); end Get_Owned_Rule; ------------------------ -- Get_Package_Import -- ------------------------ overriding function Get_Package_Import (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import is begin return AMF.UML.Package_Imports.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package_Import (Self.Element))); end Get_Package_Import; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Name; -------------- -- Set_Name -- -------------- overriding procedure Set_Name (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.Optional_String) is begin if To.Is_Empty then AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, null); else AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name (Self.Element, League.Strings.Internals.Internal (To.Value)); end if; end Set_Name; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; -------------------- -- Get_Visibility -- -------------------- overriding function Get_Visibility (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Optional_UML_Visibility_Kind is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility (Self.Element); end Get_Visibility; -------------------- -- Set_Visibility -- -------------------- overriding procedure Set_Visibility (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Optional_UML_Visibility_Kind) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility (Self.Element, To); end Set_Visibility; ----------------------- -- Get_Owned_Comment -- ----------------------- overriding function Get_Owned_Comment (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Comments.Collections.Set_Of_UML_Comment is begin return AMF.UML.Comments.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment (Self.Element))); end Get_Owned_Comment; ----------------------- -- Get_Owned_Element -- ----------------------- overriding function Get_Owned_Element (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element (Self.Element))); end Get_Owned_Element; --------------- -- Get_Owner -- --------------- overriding function Get_Owner (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Elements.UML_Element_Access is begin return AMF.UML.Elements.UML_Element_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner (Self.Element))); end Get_Owner; ----------------- -- Get_Package -- ----------------- overriding function Get_Package (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Packages.UML_Package_Access is begin return AMF.UML.Packages.UML_Package_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Package (Self.Element))); end Get_Package; ----------------- -- Set_Package -- ----------------- overriding procedure Set_Package (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Packages.UML_Package_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Package (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Package; -------------------- -- Get_Visibility -- -------------------- overriding function Get_Visibility (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.UML_Visibility_Kind is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility (Self.Element).Value; end Get_Visibility; -------------------- -- Set_Visibility -- -------------------- overriding procedure Set_Visibility (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.UML_Visibility_Kind) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility (Self.Element, (False, To)); end Set_Visibility; ----------------------------------- -- Get_Owning_Template_Parameter -- ----------------------------------- overriding function Get_Owning_Template_Parameter (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owning_Template_Parameter (Self.Element))); end Get_Owning_Template_Parameter; ----------------------------------- -- Set_Owning_Template_Parameter -- ----------------------------------- overriding procedure Set_Owning_Template_Parameter (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owning_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owning_Template_Parameter; ---------------------------- -- Get_Template_Parameter -- ---------------------------- overriding function Get_Template_Parameter (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; ---------------------------------- -- Get_Owned_Template_Signature -- ---------------------------------- overriding function Get_Owned_Template_Signature (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Template_Signatures.UML_Template_Signature_Access is begin return AMF.UML.Template_Signatures.UML_Template_Signature_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Template_Signature (Self.Element))); end Get_Owned_Template_Signature; ---------------------------------- -- Set_Owned_Template_Signature -- ---------------------------------- overriding procedure Set_Owned_Template_Signature (Self : not null access OCL_Sequence_Type_Proxy; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Owned_Template_Signature (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owned_Template_Signature; -------------------------- -- Get_Template_Binding -- -------------------------- overriding function Get_Template_Binding (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding is begin return AMF.UML.Template_Bindings.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Template_Binding (Self.Element))); end Get_Template_Binding; ----------------- -- Get_Is_Leaf -- ----------------- overriding function Get_Is_Leaf (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin return AMF.Internals.Tables.OCL_Attributes.Internal_Get_Is_Leaf (Self.Element); end Get_Is_Leaf; ----------------- -- Set_Is_Leaf -- ----------------- overriding procedure Set_Is_Leaf (Self : not null access OCL_Sequence_Type_Proxy; To : Boolean) is begin AMF.Internals.Tables.OCL_Attributes.Internal_Set_Is_Leaf (Self.Element, To); end Set_Is_Leaf; --------------------------- -- Get_Redefined_Element -- --------------------------- overriding function Get_Redefined_Element (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is begin return AMF.UML.Redefinable_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefined_Element (Self.Element))); end Get_Redefined_Element; ------------------------------ -- Get_Redefinition_Context -- ------------------------------ overriding function Get_Redefinition_Context (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.OCL_Attributes.Internal_Get_Redefinition_Context (Self.Element))); end Get_Redefinition_Context; ------------- -- Inherit -- ------------- overriding function Inherit (Self : not null access constant OCL_Sequence_Type_Proxy; Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Inherit unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Inherit"; return Inherit (Self, Inhs); end Inherit; ------------------ -- All_Features -- ------------------ overriding function All_Features (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Features.Collections.Set_Of_UML_Feature is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Features unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.All_Features"; return All_Features (Self); end All_Features; ----------------- -- All_Parents -- ----------------- overriding function All_Parents (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Parents unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.All_Parents"; return All_Parents (Self); end All_Parents; ----------------- -- Conforms_To -- ----------------- overriding function Conforms_To (Self : not null access constant OCL_Sequence_Type_Proxy; Other : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Conforms_To"; return Conforms_To (Self, Other); end Conforms_To; ------------- -- General -- ------------- overriding function General (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "General unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.General"; return General (Self); end General; ----------------------- -- Has_Visibility_Of -- ----------------------- overriding function Has_Visibility_Of (Self : not null access constant OCL_Sequence_Type_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Has_Visibility_Of unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Has_Visibility_Of"; return Has_Visibility_Of (Self, N); end Has_Visibility_Of; ------------------------- -- Inheritable_Members -- ------------------------- overriding function Inheritable_Members (Self : not null access constant OCL_Sequence_Type_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Inheritable_Members unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Inheritable_Members"; return Inheritable_Members (Self, C); end Inheritable_Members; ---------------------- -- Inherited_Member -- ---------------------- overriding function Inherited_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Inherited_Member unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Inherited_Member"; return Inherited_Member (Self); end Inherited_Member; ----------------- -- Is_Template -- ----------------- overriding function Is_Template (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Template unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Template"; return Is_Template (Self); end Is_Template; ------------------------- -- May_Specialize_Type -- ------------------------- overriding function May_Specialize_Type (Self : not null access constant OCL_Sequence_Type_Proxy; C : AMF.UML.Classifiers.UML_Classifier_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "May_Specialize_Type unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.May_Specialize_Type"; return May_Specialize_Type (Self, C); end May_Specialize_Type; ------------- -- Parents -- ------------- overriding function Parents (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Parents unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Parents"; return Parents (Self); end Parents; ------------------------ -- Exclude_Collisions -- ------------------------ overriding function Exclude_Collisions (Self : not null access constant OCL_Sequence_Type_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Exclude_Collisions unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Exclude_Collisions"; return Exclude_Collisions (Self, Imps); end Exclude_Collisions; ------------------------- -- Get_Names_Of_Member -- ------------------------- overriding function Get_Names_Of_Member (Self : not null access constant OCL_Sequence_Type_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Names_Of_Member unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Get_Names_Of_Member"; return Get_Names_Of_Member (Self, Element); end Get_Names_Of_Member; -------------------- -- Import_Members -- -------------------- overriding function Import_Members (Self : not null access constant OCL_Sequence_Type_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Import_Members unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Import_Members"; return Import_Members (Self, Imps); end Import_Members; --------------------- -- Imported_Member -- --------------------- overriding function Imported_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Imported_Member unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Imported_Member"; return Imported_Member (Self); end Imported_Member; --------------------------------- -- Members_Are_Distinguishable -- --------------------------------- overriding function Members_Are_Distinguishable (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Members_Are_Distinguishable unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Members_Are_Distinguishable"; return Members_Are_Distinguishable (Self); end Members_Are_Distinguishable; ------------------ -- Owned_Member -- ------------------ overriding function Owned_Member (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Owned_Member unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Owned_Member"; return Owned_Member (Self); end Owned_Member; -------------------- -- All_Namespaces -- -------------------- overriding function All_Namespaces (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.All_Namespaces"; return All_Namespaces (Self); end All_Namespaces; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant OCL_Sequence_Type_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Namespace"; return Namespace (Self); end Namespace; -------------------- -- Qualified_Name -- -------------------- overriding function Qualified_Name (Self : not null access constant OCL_Sequence_Type_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Qualified_Name"; return Qualified_Name (Self); end Qualified_Name; --------------- -- Separator -- --------------- overriding function Separator (Self : not null access constant OCL_Sequence_Type_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Separator unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Separator"; return Separator (Self); end Separator; ------------------------ -- All_Owned_Elements -- ------------------------ overriding function All_Owned_Elements (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.All_Owned_Elements"; return All_Owned_Elements (Self); end All_Owned_Elements; ------------------- -- Must_Be_Owned -- ------------------- overriding function Must_Be_Owned (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Must_Be_Owned"; return Must_Be_Owned (Self); end Must_Be_Owned; ----------------- -- Conforms_To -- ----------------- overriding function Conforms_To (Self : not null access constant OCL_Sequence_Type_Proxy; Other : AMF.UML.Types.UML_Type_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Conforms_To unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Conforms_To"; return Conforms_To (Self, Other); end Conforms_To; ------------------------ -- Is_Compatible_With -- ------------------------ overriding function Is_Compatible_With (Self : not null access constant OCL_Sequence_Type_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Compatible_With"; return Is_Compatible_With (Self, P); end Is_Compatible_With; --------------------------- -- Is_Template_Parameter -- --------------------------- overriding function Is_Template_Parameter (Self : not null access constant OCL_Sequence_Type_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Template_Parameter"; return Is_Template_Parameter (Self); end Is_Template_Parameter; ---------------------------- -- Parameterable_Elements -- ---------------------------- overriding function Parameterable_Elements (Self : not null access constant OCL_Sequence_Type_Proxy) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Parameterable_Elements unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Parameterable_Elements"; return Parameterable_Elements (Self); end Parameterable_Elements; ------------------------ -- Is_Consistent_With -- ------------------------ overriding function Is_Consistent_With (Self : not null access constant OCL_Sequence_Type_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Consistent_With"; return Is_Consistent_With (Self, Redefinee); end Is_Consistent_With; ----------------------------------- -- Is_Redefinition_Context_Valid -- ----------------------------------- overriding function Is_Redefinition_Context_Valid (Self : not null access constant OCL_Sequence_Type_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented"); raise Program_Error with "Unimplemented procedure OCL_Sequence_Type_Proxy.Is_Redefinition_Context_Valid"; return Is_Redefinition_Context_Valid (Self, Redefined); end Is_Redefinition_Context_Valid; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant OCL_Sequence_Type_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Enter_Sequence_Type (AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant OCL_Sequence_Type_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then AMF.Visitors.OCL_Visitors.OCL_Visitor'Class (Visitor).Leave_Sequence_Type (AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant OCL_Sequence_Type_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.OCL_Iterators.OCL_Iterator'Class then AMF.Visitors.OCL_Iterators.OCL_Iterator'Class (Iterator).Visit_Sequence_Type (Visitor, AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.OCL_Sequence_Types;
MinimSecure/unum-sdk
Ada
945
adb
-- Copyright 2015-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pack is function Fun_Rename_Test_Next (I : Integer) return Integer is begin return I + 1; end Fun_Rename_Test_Next; procedure Discard (I : Integer) is begin null; end Discard; end Pack;
sungyeon/drake
Ada
12,220
adb
with Ada.Exception_Identification.From_Here; with System.Address_To_Constant_Access_Conversions; with System.Address_To_Named_Access_Conversions; with System.Zero_Terminated_Strings; with System.Debug; -- assertions with C.errno; package body System.Native_Environment_Encoding is use Ada.Exception_Identification.From_Here; use type Ada.Streams.Stream_Element_Offset; use type C.iconv.iconv_t; -- C.void_ptr use type C.signed_int; use type C.size_t; package char_ptr_Conv is new Address_To_Named_Access_Conversions (C.char, C.char_ptr); package char_const_ptr_Conv is new Address_To_Constant_Access_Conversions (C.char, C.char_const_ptr); procedure Default_Substitute ( Encoding : Encoding_Id; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Default_Substitute ( Encoding : Encoding_Id; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is begin if Encoding = UTF_16_Names (High_Order_First)(0)'Access then Last := Item'First; Item (Last) := 0; Last := Last + 1; Item (Last) := Character'Pos ('?'); elsif Encoding = UTF_16_Names (Low_Order_First)(0)'Access then Last := Item'First; Item (Last) := Character'Pos ('?'); Last := Last + 1; Item (Last) := 0; elsif Encoding = UTF_32_Names (High_Order_First)(0)'Access then Last := Item'First; Item (Last) := 0; Last := Last + 1; Item (Last) := 0; Last := Last + 1; Item (Last) := 0; Last := Last + 1; Item (Last) := Character'Pos ('?'); elsif Encoding = UTF_32_Names (Low_Order_First)(0)'Access then Last := Item'First; Item (Last) := Character'Pos ('?'); Last := Last + 1; Item (Last) := 0; Last := Last + 1; Item (Last) := 0; Last := Last + 1; Item (Last) := 0; else Last := Item'First; Item (Last) := Character'Pos ('?'); end if; end Default_Substitute; -- implementation function Get_Image (Encoding : Encoding_Id) return String is begin return Zero_Terminated_Strings.Value (Encoding); end Get_Image; function Get_Default_Substitute (Encoding : Encoding_Id) return Ada.Streams.Stream_Element_Array is Result : Ada.Streams.Stream_Element_Array ( 0 .. -- from 0 for a result value Max_Substitute_Length - 1); Last : Ada.Streams.Stream_Element_Offset; begin Default_Substitute (Encoding, Result, Last); return Result (Result'First .. Last); end Get_Default_Substitute; function Get_Min_Size_In_Stream_Elements (Encoding : Encoding_Id) return Ada.Streams.Stream_Element_Offset is begin if Encoding = UTF_16_Names (High_Order_First)(0)'Access or else Encoding = UTF_16_Names (Low_Order_First)(0)'Access then return 2; elsif Encoding = UTF_32_Names (High_Order_First)(0)'Access or else Encoding = UTF_32_Names (Low_Order_First)(0)'Access then return 4; else return 1; end if; end Get_Min_Size_In_Stream_Elements; function Get_Current_Encoding return Encoding_Id is begin return UTF_8_Name (0)'Access; end Get_Current_Encoding; procedure Open (Object : in out Converter; From, To : Encoding_Id) is Error : constant C.iconv.iconv_t := C.iconv.iconv_t (System'To_Address (-1)); iconv : C.iconv.iconv_t; begin iconv := C.iconv.iconv_open (To, From); if iconv = Error then Raise_Exception (Name_Error'Identity); end if; Object.iconv := iconv; -- about "From" Object.Min_Size_In_From_Stream_Elements := Get_Min_Size_In_Stream_Elements (From); -- about "To" Default_Substitute (To, Object.Substitute, Object.Substitute_Length); end Open; procedure Close (Object : in out Converter) is pragma Unmodified (Object); begin if Object.iconv /= C.void_ptr (Null_Address) then declare R : C.signed_int; begin R := C.iconv.iconv_close (Object.iconv); pragma Check (Debug, Check => not (R < 0) or else Debug.Runtime_Error ("iconv_close failed")); end; end if; end Close; function Is_Open (Object : Converter) return Boolean is begin return Object.iconv /= C.void_ptr (Null_Address); end Is_Open; function Min_Size_In_From_Stream_Elements_No_Check (Object : Converter) return Ada.Streams.Stream_Element_Offset is begin return Object.Min_Size_In_From_Stream_Elements; end Min_Size_In_From_Stream_Elements_No_Check; function Substitute_No_Check (Object : Converter) return Ada.Streams.Stream_Element_Array is begin return Object.Substitute (1 .. Object.Substitute_Length); end Substitute_No_Check; procedure Set_Substitute_No_Check ( Object : in out Converter; Substitute : Ada.Streams.Stream_Element_Array) is begin if Substitute'Length > Object.Substitute'Length then raise Constraint_Error; end if; Object.Substitute_Length := Substitute'Length; Object.Substitute (1 .. Object.Substitute_Length) := Substitute; end Set_Substitute_No_Check; procedure Convert_No_Check ( Object : Converter; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : Boolean; Status : out Subsequence_Status_Type) is Continuing_Status : Continuing_Status_Type; Finishing_Status : Finishing_Status_Type; begin Convert_No_Check ( Object, Item, Last, Out_Item, Out_Last, Status => Continuing_Status); Status := Subsequence_Status_Type (Continuing_Status); if Finish and then Status = Success and then Last = Item'Last then Convert_No_Check ( Object, Out_Item (Out_Last + 1 .. Out_Item'Last), Out_Last, Finish => True, Status => Finishing_Status); Status := Subsequence_Status_Type (Finishing_Status); end if; end Convert_No_Check; procedure Convert_No_Check ( Object : Converter; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Status : out Continuing_Status_Type) is Pointer : aliased C.char_const_ptr := char_const_ptr_Conv.To_Pointer (Item'Address); Size : aliased C.size_t := Item'Length; Out_Pointer : aliased C.char_ptr := char_ptr_Conv.To_Pointer (Out_Item'Address); Out_Size : aliased C.size_t := Out_Item'Length; errno : C.signed_int; begin if C.iconv.iconv ( Object.iconv, Pointer'Access, Size'Access, Out_Pointer'Access, Out_Size'Access) = C.size_t'Last then errno := C.errno.errno; case errno is when C.errno.E2BIG => Status := Overflow; when C.errno.EINVAL => Status := Truncated; when others => -- C.errno.EILSEQ => Status := Illegal_Sequence; end case; else Status := Success; end if; Last := Item'First + (Item'Length - Ada.Streams.Stream_Element_Offset (Size) - 1); Out_Last := Out_Item'First + ( Out_Item'Length - Ada.Streams.Stream_Element_Offset (Out_Size) - 1); end Convert_No_Check; procedure Convert_No_Check ( Object : Converter; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : True_Only; Status : out Finishing_Status_Type) is pragma Unreferenced (Finish); Out_Pointer : aliased C.char_ptr := char_ptr_Conv.To_Pointer (Out_Item'Address); Out_Size : aliased C.size_t := Out_Item'Length; errno : C.signed_int; begin if C.iconv.iconv ( Object.iconv, null, null, Out_Pointer'Access, Out_Size'Access) = C.size_t'Last then errno := C.errno.errno; case errno is when C.errno.E2BIG => Status := Overflow; when others => -- unknown Raise_Exception (Use_Error'Identity); end case; else Status := Finished; end if; Out_Last := Out_Item'First + ( Out_Item'Length - Ada.Streams.Stream_Element_Offset (Out_Size) - 1); end Convert_No_Check; procedure Convert_No_Check ( Object : Converter; Item : Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Finish : True_Only; Status : out Substituting_Status_Type) is Index : Ada.Streams.Stream_Element_Offset := Item'First; Out_Index : Ada.Streams.Stream_Element_Offset := Out_Item'First; begin loop declare Subsequence_Status : Subsequence_Status_Type; begin Convert_No_Check ( Object, Item (Index .. Item'Last), Last, Out_Item (Out_Index .. Out_Item'Last), Out_Last, Finish => Finish, Status => Subsequence_Status); pragma Assert ( Subsequence_Status in Subsequence_Status_Type (Status_Type'First) .. Subsequence_Status_Type (Status_Type'Last)); case Status_Type (Subsequence_Status) is when Finished => Status := Finished; return; when Success => Status := Success; return; when Overflow => Status := Overflow; return; -- error when Illegal_Sequence => declare Is_Overflow : Boolean; begin Put_Substitute ( Object, Out_Item (Out_Last + 1 .. Out_Item'Last), Out_Last, Is_Overflow); if Is_Overflow then Status := Overflow; return; -- wait a next try end if; end; declare New_Last : Ada.Streams.Stream_Element_Offset := Last + Object.Min_Size_In_From_Stream_Elements; begin if New_Last > Item'Last or else New_Last < Last -- overflow then New_Last := Item'Last; end if; Last := New_Last; end; Index := Last + 1; Out_Index := Out_Last + 1; end case; end; end loop; end Convert_No_Check; procedure Put_Substitute ( Object : Converter; Out_Item : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Is_Overflow : out Boolean) is begin Is_Overflow := Out_Item'Length < Object.Substitute_Length; if Is_Overflow then Out_Last := Out_Item'First - 1; else Out_Last := Out_Item'First + (Object.Substitute_Length - 1); Out_Item (Out_Item'First .. Out_Last) := Object.Substitute (1 .. Object.Substitute_Length); end if; end Put_Substitute; end System.Native_Environment_Encoding;
Brawdunoir/administrative-family-tree-manager
Ada
12,998
adb
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO; use Ada.Text_IO; package body Arbre_Genealogique is --package arbre2 is -- On instancie un arbre binaire -- new Arbre_Binaire (T_Cle => Integer); --use arbre2; -- Afficher des entiers (pour les clés). procedure Afficher_Entier (N : in Integer) is begin Put(N, width => 0); end Afficher_Entier; procedure Afficher_Arbre_Binaire is new arbre.Afficher_Arbre_Binaire (Afficher_Cle => Afficher_Entier); procedure Afficher_Cle_Binaire is new arbre.Afficher_Cle_Binaire (Afficher_Cle => Afficher_Entier); procedure Initialiser_Gen(Arbre: out T_Arbre_Gen; Reg : out T_Registre; Nom : in unbounded_string; Prenom : in unbounded_string; Jour_N : in Integer; Mois_N : in Integer; Annee_N : in Integer; Sexe : in Character) is Donnee : T_Donnee; Cle : Integer; begin Initialiser_Donnee(Donnee, Nom, Prenom, Jour_N, Mois_N, Annee_N, Sexe); Creer_Cle (Reg, Cle, Donnee); Initialiser (Arbre, Cle); Initialiser_Reg (Reg, Cle, Donnee); end Initialiser_Gen; function Est_Vide_Gen (Arbre : in T_Arbre_Gen) return Boolean is begin return Est_Vide(Arbre); end Est_Vide_Gen; function Nombre_Ancetre (Arbre : in T_Arbre_Gen; Cle : in Integer) return Integer is begin return Nombre_Fils (Arbre, Cle); end Nombre_Ancetre; procedure Ajouter_Parent (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre; Cle_Individu : in Integer; Nom : in unbounded_string; Prenom : in unbounded_string; Jour_N : in Integer; Mois_N : in Integer; Annee_N : in Integer; Sexe : in Character) is Donnee : T_Donnee; Cle_Parent : Integer; begin Initialiser_Donnee (Donnee, Nom, Prenom, Jour_N, Mois_N, Annee_N, Sexe); Creer_Cle (Reg, Cle_Parent, Donnee); if Sexe = 'F' then Ajouter_Fils_Gauche (Arbre, Cle_Individu, Cle_Parent); else Ajouter_Fils_Droit (Arbre, Cle_Individu, Cle_Parent); end if; -- on l'insère dans le registre après, car si la clé ou le parent existe déjà, l'exception est propagée -- et l'individu n'est pas ajouté au registre Inserer (Reg, Cle_Parent, Donnee); exception when Cle_Presente_Exception_Bin => raise Cle_Presente_Exception_Gen; when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; when Emplacement_Reserve_Exception_Bin => raise Emplacement_Reserve_Exception_Gen; end Ajouter_Parent; procedure Supprimer (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre; Individu : in Integer) is begin Supprimer(Arbre, Individu); exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Supprimer; procedure Vider (Arbre : in out T_Arbre_Gen; Reg : in out T_Registre) is begin Vider(Arbre); Vider(Reg); end Vider; procedure Afficher_Ancetre_Generation_X (Arbre : in T_Arbre_Gen; X : in Integer; compteur : in out Integer) is begin if compteur > X then Afficher_Cle_Genealogique(Arbre); New_Line; else if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then compteur := compteur + 1; Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))), X, compteur); Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))), X, compteur); elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then compteur := compteur +1; Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre))), X, compteur); elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then compteur := compteur + 1; Afficher_Ancetre_Generation_X(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre))), X, compteur); else null; end if; end if; end Afficher_Ancetre_Generation_X; procedure Ancetre_Generation_X (Arbre : in T_Arbre_Gen; Individu : in Integer; Generation : in Integer) is compteur : Integer; Pointeur_Individu : T_Pointeur_Binaire; begin New_Line; Put("Les ancêtres de "); Put(Individu, width => 0); Put(" de la génération "); Put(Generation, width => 0); Put( " sont : "); New_Line; compteur := 1; Rechercher_Position(T_Pointeur_Binaire(Arbre), Individu, Pointeur_Individu); Afficher_Ancetre_Generation_X (T_Arbre_Gen(Pointeur_Individu), Generation, compteur); exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Ancetre_Generation_X; procedure Ancetres_Sur_N_Generations (Arbre : in T_Arbre_Gen; Individu : in Integer; N : in Integer) is compteur : Integer; Pointeur_Individu : T_Pointeur_Binaire; begin New_Line; Put("Les ancêtres de "); Put(Individu, width => 0); Put(" sur "); Put(N, width => 0); Put( " génération(s) sont : "); New_Line; Rechercher_Position(T_Pointeur_Binaire(Arbre), Individu, Pointeur_Individu); -- On affiche chaque génération X à partir d'Individu for i in 1..N loop compteur := 1; Put("Generation "); Put(i); Put(" :"); New_Line; Afficher_Ancetre_Generation_X (T_Arbre_Gen(Pointeur_Individu), i, compteur); end loop; exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Ancetres_Sur_N_Generations; procedure Afficher_Ancetres_Homonymes (P1 : in T_Arbre_Gen; P2 : in T_Arbre_Gen; Reg : in T_Registre) is begin -- Si P1 et P2 ne sont pas vides... if not Est_Vide_Gen(P1) and not Est_Vide_Gen(P2) then -- S'ils ont le même nom, on les affiche ! if Retourner_Nom(Reg, Retourner_Cle(P1)) = Retourner_Nom(Reg, Retourner_Cle(P2)) then Put_Line (To_String(Retourner_Nom(Reg, Retourner_Cle(P1)))); else null; end if; end if; -- Si les deux sont vides, on a atteint la fin de l'arbre, on s'arrête if Est_Vide_Gen(P1) and Est_Vide_Gen(P2) then null; -- Sinon on va chercher dans tous les ancêtres de P2, si un correspond au premier ancêtre de P1 jusqu'à ce qu'on ai regardé -- tous les ancêtres de P2, et alors on passe aux deuxièmes ancêtres de P1 et on recommence else if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(P2)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P2)) then Afficher_Ancetres_Homonymes (P1, T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P2))), Reg); Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P2))), Reg); elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P2)) then Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P2))), Reg); elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(P2)) then Afficher_Ancetres_Homonymes(P1, T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P2))), Reg); else -- On est arrivé à la fin de l'arbre généalogique de P2 if Est_Vide_Fils_Droit(T_Pointeur_Binaire(P1)) and Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P1)) then null; -- On est arrivé à la fin de l'arbre de P1 elsif Est_Vide_Fils_Droit(T_Pointeur_Binaire(P1)) then -- On recommence en prenant que le fils gauche Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P1))), P2, Reg); elsif Est_Vide_Fils_Gauche(T_Pointeur_Binaire(P1)) then -- Ou bien on recommence en prenant que le fils droit Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P1))), P2, Reg); else -- Ou bien on prend les deux !! Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(P1))), P2, Reg); Afficher_Ancetres_Homonymes(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(P1))), P2, Reg); end if; end if; end if; end Afficher_Ancetres_Homonymes; procedure Ancetres_Homonymes (Arbre : in T_Arbre_Gen; Reg : in T_Registre; Individu1 : in Integer; Individu2 : in Integer) is Pointeur_Individu1 : T_Pointeur_Binaire; Pointeur_Individu2 : T_Pointeur_Binaire; begin Rechercher_Position (T_Pointeur_Binaire(Arbre), Individu1, Pointeur_Individu1); Rechercher_Position (T_Pointeur_Binaire(Arbre), Individu2, Pointeur_Individu2); Afficher_Ancetres_Homonymes (T_Arbre_Gen(Pointeur_Individu1), T_Arbre_Gen(Pointeur_Individu2), Reg); exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Ancetres_Homonymes; procedure Afficher_Orphelins (Arbre : in T_Arbre_Gen) is begin if not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then Afficher_Orphelins(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); else Afficher_Cle_Genealogique(Arbre); New_Line; end if; exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Afficher_Orphelins; procedure Afficher_Monoparental (Arbre : in T_Arbre_Gen) is begin if not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then Afficher_Cle_Genealogique(Arbre); New_Line; Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then Afficher_Cle_Genealogique(Arbre); New_Line; Afficher_Monoparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); else null; end if; exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Afficher_Monoparental; procedure Afficher_Biparental (Arbre : in T_Arbre_Gen) is begin if not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) and not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then Afficher_Cle_Genealogique(Arbre); New_Line; Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Gauche(T_Pointeur_Binaire(Arbre)) then Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Gauche(T_Pointeur_Binaire(Arbre)))); elsif not Est_Vide_Fils_Droit(T_Pointeur_Binaire(Arbre)) then Afficher_Biparental(T_Arbre_Gen(Retourner_Fils_Droit(T_Pointeur_Binaire(Arbre)))); else null; end if; exception when Cle_Absente_Exception_Bin => raise Cle_Absente_Exception_Gen; end Afficher_Biparental; procedure Afficher_Arbre_Genealogique (Arbre : in T_Arbre_Gen) is begin Afficher_Arbre_Binaire(T_Pointeur_Binaire(Arbre)); end Afficher_Arbre_Genealogique; procedure Afficher_Cle_Genealogique (Arbre : in T_Arbre_Gen) is begin Afficher_Cle_Binaire(T_Pointeur_Binaire(Arbre)); end Afficher_Cle_Genealogique; end Arbre_Genealogique;
stcarrez/ada-awa
Ada
1,888
adb
----------------------------------------------------------------------- -- awa-components-redirect -- ASF Core Components -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body AWA.Components.Redirect is -- ------------------------------ -- Get the redirection link -- ------------------------------ function Get_Link (UI : in UIRedirect; Context : in Faces_Context'Class) return Util.Beans.Objects.Object is begin return UI.Get_Attribute (Context, "link"); end Get_Link; -- ------------------------------ -- If the component is rendered, activate the redirection to the -- specified URI. -- ------------------------------ overriding procedure Encode_Begin (UI : in UIRedirect; Context : in out Faces_Context'Class) is begin if not UI.Is_Rendered (Context) then return; end if; declare Link : constant Util.Beans.Objects.Object := UIRedirect'Class (UI).Get_Link (Context); begin Context.Get_Response.Send_Redirect (Location => Util.Beans.Objects.To_String (Link)); end; end Encode_Begin; end AWA.Components.Redirect;
stcarrez/ada-util
Ada
1,041
ads
----------------------------------------------------------------------- -- util-http-clients-curl-tests -- HTTP unit tests for CURL implementation -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Http.Clients.Tests; package Util.Http.Clients.Curl.Tests is new Util.Http.Clients.Tests.Http_Tests (Util.Http.Clients.Curl.Register, "curl");
AdaCore/Ada_Drivers_Library
Ada
8,115
ads
-- This spec has been automatically generated from STM32F46_79x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.FLASH is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ACR_LATENCY_Field is HAL.UInt3; -- Flash access control register type ACR_Register is record -- Latency LATENCY : ACR_LATENCY_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Prefetch enable PRFTEN : Boolean := False; -- Instruction cache enable ICEN : Boolean := False; -- Data cache enable DCEN : Boolean := False; -- Write-only. Instruction cache reset ICRST : Boolean := False; -- Data cache reset DCRST : Boolean := False; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACR_Register use record LATENCY at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; PRFTEN at 0 range 8 .. 8; ICEN at 0 range 9 .. 9; DCEN at 0 range 10 .. 10; ICRST at 0 range 11 .. 11; DCRST at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- Status register type SR_Register is record -- End of operation EOP : Boolean := False; -- Operation error OPERR : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- Write protection error WRPERR : Boolean := False; -- Programming alignment error PGAERR : Boolean := False; -- Programming parallelism error PGPERR : Boolean := False; -- Programming sequence error PGSERR : Boolean := False; -- Proprietary readout protection (PCROP) error RDERR : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- Read-only. Busy BSY : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record EOP at 0 range 0 .. 0; OPERR at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; WRPERR at 0 range 4 .. 4; PGAERR at 0 range 5 .. 5; PGPERR at 0 range 6 .. 6; PGSERR at 0 range 7 .. 7; RDERR at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; BSY at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype CR_SNB_Field is HAL.UInt5; subtype CR_PSIZE_Field is HAL.UInt2; -- Control register type CR_Register is record -- Programming PG : Boolean := False; -- Sector Erase SER : Boolean := False; -- Mass Erase of sectors 0 to 11 MER : Boolean := False; -- Sector number SNB : CR_SNB_Field := 16#0#; -- Program size PSIZE : CR_PSIZE_Field := 16#0#; -- unspecified Reserved_10_14 : HAL.UInt5 := 16#0#; -- Mass Erase of sectors 12 to 23 MER1 : Boolean := False; -- Start STRT : Boolean := False; -- unspecified Reserved_17_23 : HAL.UInt7 := 16#0#; -- End of operation interrupt enable EOPIE : Boolean := False; -- Error interrupt enable ERRIE : Boolean := False; -- unspecified Reserved_26_30 : HAL.UInt5 := 16#0#; -- Lock LOCK : Boolean := True; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record PG at 0 range 0 .. 0; SER at 0 range 1 .. 1; MER at 0 range 2 .. 2; SNB at 0 range 3 .. 7; PSIZE at 0 range 8 .. 9; Reserved_10_14 at 0 range 10 .. 14; MER1 at 0 range 15 .. 15; STRT at 0 range 16 .. 16; Reserved_17_23 at 0 range 17 .. 23; EOPIE at 0 range 24 .. 24; ERRIE at 0 range 25 .. 25; Reserved_26_30 at 0 range 26 .. 30; LOCK at 0 range 31 .. 31; end record; subtype OPTCR_BOR_LEV_Field is HAL.UInt2; subtype OPTCR_RDP_Field is HAL.UInt8; subtype OPTCR_nWRP_Field is HAL.UInt12; -- Flash option control register type OPTCR_Register is record -- Option lock OPTLOCK : Boolean := True; -- Option start OPTSTRT : Boolean := False; -- BOR reset Level BOR_LEV : OPTCR_BOR_LEV_Field := 16#3#; -- Dual-bank Boot option byte BFB2 : Boolean := False; -- WDG_SW User option bytes WDG_SW : Boolean := True; -- nRST_STOP User option bytes nRST_STOP : Boolean := True; -- nRST_STDBY User option bytes nRST_STDBY : Boolean := True; -- Read protect RDP : OPTCR_RDP_Field := 16#AA#; -- Not write protect nWRP : OPTCR_nWRP_Field := 16#FFF#; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Dual-bank on 1 Mbyte Flash memory devices DB1M : Boolean := False; -- Selection of protection mode for nWPRi bits SPRMOD : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OPTCR_Register use record OPTLOCK at 0 range 0 .. 0; OPTSTRT at 0 range 1 .. 1; BOR_LEV at 0 range 2 .. 3; BFB2 at 0 range 4 .. 4; WDG_SW at 0 range 5 .. 5; nRST_STOP at 0 range 6 .. 6; nRST_STDBY at 0 range 7 .. 7; RDP at 0 range 8 .. 15; nWRP at 0 range 16 .. 27; Reserved_28_29 at 0 range 28 .. 29; DB1M at 0 range 30 .. 30; SPRMOD at 0 range 31 .. 31; end record; subtype OPTCR1_nWRP_Field is HAL.UInt12; -- Flash option control register 1 type OPTCR1_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Not write protect nWRP : OPTCR1_nWRP_Field := 16#FFF#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OPTCR1_Register use record Reserved_0_15 at 0 range 0 .. 15; nWRP at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- FLASH type FLASH_Peripheral is record -- Flash access control register ACR : aliased ACR_Register; -- Flash key register KEYR : aliased HAL.UInt32; -- Flash option key register OPTKEYR : aliased HAL.UInt32; -- Status register SR : aliased SR_Register; -- Control register CR : aliased CR_Register; -- Flash option control register OPTCR : aliased OPTCR_Register; -- Flash option control register 1 OPTCR1 : aliased OPTCR1_Register; end record with Volatile; for FLASH_Peripheral use record ACR at 16#0# range 0 .. 31; KEYR at 16#4# range 0 .. 31; OPTKEYR at 16#8# range 0 .. 31; SR at 16#C# range 0 .. 31; CR at 16#10# range 0 .. 31; OPTCR at 16#14# range 0 .. 31; OPTCR1 at 16#18# range 0 .. 31; end record; -- FLASH FLASH_Periph : aliased FLASH_Peripheral with Import, Address => System'To_Address (16#40023C00#); end STM32_SVD.FLASH;
reznikmm/matreshka
Ada
3,714
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.Table_Insertion_Cut_Off_Elements is pragma Preelaborate; type ODF_Table_Insertion_Cut_Off is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Insertion_Cut_Off_Access is access all ODF_Table_Insertion_Cut_Off'Class with Storage_Size => 0; end ODF.DOM.Table_Insertion_Cut_Off_Elements;
reznikmm/matreshka
Ada
3,899
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; with XML.SAX.Simple_Readers; with XML.SAX.String_Input_Sources; with Test_41_Handlers; procedure Test_41 is Input : aliased XML.SAX.String_Input_Sources.String_Input_Source; Handler : aliased Test_41_Handlers.Test_41_Handler; Reader : aliased XML.SAX.Simple_Readers.Simple_Reader; begin Input.Set_String (League.Strings.To_Universal_String ("<?xml version='1.0'?><a></a><b>")); Reader.Set_Error_Handler (Handler'Unchecked_Access); Reader.Parse (Input'Unchecked_Access); Handler.Check (1, 31); end Test_41;
reznikmm/matreshka
Ada
4,583
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Custom1_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Custom1_Attribute_Node is begin return Self : Text_Custom1_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Custom1_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Custom1_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Custom1_Attribute, Text_Custom1_Attribute_Node'Tag); end Matreshka.ODF_Text.Custom1_Attributes;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 3 0 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 30 package System.Pack_30 is pragma Preelaborate; Bits : constant := 30; type Bits_30 is mod 2 ** Bits; for Bits_30'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_30 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_30 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_30 (Arr : System.Address; N : Natural; E : Bits_30; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_30 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_30 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_30 (Arr : System.Address; N : Natural; E : Bits_30; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_30;
coopht/axmpp
Ada
8,513
adb
------------------------------------------------------------------------------ -- -- -- AXMPP Project -- -- -- -- XMPP Library for Ada -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Alexander Basov <[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 Alexander Basov, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package body XMPP.Base64 is subtype Six_Bits is Ada.Streams.Stream_Element range 0 .. 63; From_String : constant array (Character) of Six_Bits := ('A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, 'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, 'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41, 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, 'x' => 49, 'y' => 50, 'z' => 51, '0' => 52, '1' => 53, '2' => 54, '3' => 55, '4' => 56, '5' => 57, '6' => 58, '7' => 59, '8' => 60, '9' => 61, '+' => 62, '/' => 63, others => 0); procedure Decode (Source : String; Target : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is -- decode Source into Target(Target'first .. Last) -- Note: it may be appropriate to prescan Source for '=', -- indicating termination, or for illegitimate characters, -- indicating corruption, before calling Decode. use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Offset; D : Six_Bits; type Slots is mod 4; Slot : Slots := 0; begin Last := Target'First - 1; for SI in Source'Range loop D := From_String (Source (SI)); if D /= 0 or else Source (SI) = 'A' then -- OK source case Slot is when 0 => Last := Last + 1; Target (Last) := 4 * D; -- dddddd00 ........ ........ when 1 => Target (Last) := Target (Last) + D / 16; exit when Last = Target'Last and then (SI = Source'Last or else Source (SI + 1) = '=') and then (D mod 16) = 0; Last := Last + 1; Target (Last) := (D mod 16) * 16; -- dddddddd dddd0000 ........ when 2 => Target (Last) := Target (Last) + D / 4; exit when Last = Target'Last and then (SI = Source'Last or else Source (SI + 1) = '=') and then (D mod 4) = 0; Last := Last + 1; Target (Last) := (D mod 4) * 64; -- dddddddd dddddddd dd000000 when 3 => Target (Last) := Target (Last) + D; -- dddddddd dddddddd dddddddd end case; Slot := Slot + 1; elsif Source (SI) = '=' then exit; -- terminator encountered end if; -- silently ignore whitespace, lf, garbage, ... end loop; end Decode; To_String : constant array (Six_Bits) of Character := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; procedure Encode (Source : Ada.Streams.Stream_Element_Array; Target : out String; Last : out Natural) is -- Target is filled in four character increments, except that -- a CR-LF pair is inserted after every 76 characters. -- Target'length must be at least: -- Output_Quad_Count: constant := (Source'length + 2) / 3; -- Output_Byte_Count: constant := 4 * Output_Quad_Count; -- Target'length = Output_Byte_Count + 2 * (Output_Byte_Count / 76) -- Constraint_Error will be raised if Target isn't long enough. use type Ada.Streams.Stream_Element; D : Six_Bits; type Slots is mod 3; Slot : Slots := 0; Output_Line_Length : Natural := 0; begin Last := Target'First - 1; for SI in Source'Range loop case Slot is when 0 => -- if Output_Line_Length = 76 then -- Last := Last + 2; -- Target (Last - 1) := ASCII.CR; -- Target (Last) := ASCII.LF; -- Output_Line_Length := 0; -- end if; Output_Line_Length := Output_Line_Length + 4; Last := Last + 4; Target (Last - 3) := To_String (Source (SI) / 4); D := (Source (SI) mod 4) * 16; Target (Last - 2) := To_String (D); Target (Last - 1) := '='; Target (Last) := '='; -- dddddd dd0000 = = when 1 => D := D + Source (SI) / 16; Target (Last - 2) := To_String (D); D := (Source (SI) mod 16) * 4; Target (Last - 1) := To_String (D); -- dddddd dddddd dddd00 = when 2 => D := D + Source (SI) / 64; Target (Last - 1) := To_String (D); Target (Last) := To_String (Source (SI) mod 64); -- dddddd dddddd dddddd dddddd end case; Slot := Slot + 1; end loop; end Encode; end XMPP.Base64;
reznikmm/matreshka
Ada
3,639
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Destroy_Object_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Destroy_Object_Action, UML_Destroy_Object_Action_Access);
faelys/natools
Ada
3,750
adb
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Ada.Streams.Stream_IO; with Natools.S_Expressions.Test_Tools; package body Natools.S_Expressions.Enumeration_IO.Tests is package Stream_IO renames Ada.Streams.Stream_IO; package Test_IO is new Typed_IO (Stream_IO.File_Mode); ------------------------- -- Complete Test Suite -- ------------------------- procedure All_Tests (Report : in out NT.Reporter'Class) is begin Basic_Usage (Report); Invalid_Atom (Report); end All_Tests; ---------------------- -- Individual Tests -- ---------------------- procedure Basic_Usage (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Basic usage with Stream_IO.File_Mode"); use type Stream_IO.File_Mode; begin Test_Tools.Test_Atom (Test, To_Atom ("append-file"), Test_IO.Image (Stream_IO.Append_File)); declare Expected : constant Stream_IO.File_Mode := Stream_IO.Out_File; Found : constant Stream_IO.File_Mode := Test_IO.Value (To_Atom ("out-file")); begin if Expected /= Found then Test.Fail ("Test_IO.Value returned " & Stream_IO.File_Mode'Image (Found) & ", expected " & Stream_IO.File_Mode'Image (Expected)); end if; end; exception when Error : others => Test.Report_Exception (Error); end Basic_Usage; procedure Invalid_Atom (Report : in out NT.Reporter'Class) is Test : NT.Test := Report.Item ("Value on invalid atoms"); use type Stream_IO.File_Mode; begin Without_Fallback : declare Found : Stream_IO.File_Mode; begin Found := Test_IO.Value (To_Atom ("invalid-atom")); Test.Fail ("Exception expected, but Value returned " & Stream_IO.File_Mode'Image (Found)); exception when Constraint_Error => null; end Without_Fallback; With_Fallback : declare Expected : constant Stream_IO.File_Mode := Stream_IO.Out_File; Found : constant Stream_IO.File_Mode := Test_IO.Value (To_Atom ("invalid-atom"), Expected); begin if Expected /= Found then Test.Fail ("Test_IO.Value returned " & Stream_IO.File_Mode'Image (Found) & ", expected " & Stream_IO.File_Mode'Image (Expected)); end if; end With_Fallback; exception when Error : others => Test.Report_Exception (Error); end Invalid_Atom; end Natools.S_Expressions.Enumeration_IO.Tests;
AdaCore/libadalang
Ada
395
adb
procedure A is function Bar (X, Y : Integer) return Boolean is function Foo return Integer; begin return X > Y; end Bar; function Bar (X : Integer) return Boolean is begin return X > 42; end Bar; procedure Bar (X : Integer) is function Foo return Integer; begin null; end Bar; B : Boolean; begin B := Bar (1, 2); Bar (1); end A;
reznikmm/matreshka
Ada
4,800
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.Usages.Collections is pragma Preelaborate; package UML_Usage_Collections is new AMF.Generic_Collections (UML_Usage, UML_Usage_Access); type Set_Of_UML_Usage is new UML_Usage_Collections.Set with null record; Empty_Set_Of_UML_Usage : constant Set_Of_UML_Usage; type Ordered_Set_Of_UML_Usage is new UML_Usage_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Usage : constant Ordered_Set_Of_UML_Usage; type Bag_Of_UML_Usage is new UML_Usage_Collections.Bag with null record; Empty_Bag_Of_UML_Usage : constant Bag_Of_UML_Usage; type Sequence_Of_UML_Usage is new UML_Usage_Collections.Sequence with null record; Empty_Sequence_Of_UML_Usage : constant Sequence_Of_UML_Usage; private Empty_Set_Of_UML_Usage : constant Set_Of_UML_Usage := (UML_Usage_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Usage : constant Ordered_Set_Of_UML_Usage := (UML_Usage_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Usage : constant Bag_Of_UML_Usage := (UML_Usage_Collections.Bag with null record); Empty_Sequence_Of_UML_Usage : constant Sequence_Of_UML_Usage := (UML_Usage_Collections.Sequence with null record); end AMF.UML.Usages.Collections;
Asier98/AdaCar
Ada
455
ads
with Digital; use Digital; with Analog; use Analog; with Pins_STM32F446; use Pins_STM32F446; package AdaCar.Entrada_Salida is procedure Init_System; function Lectura_Digital(Canal: Canal_DI) return Estado_Digital; procedure Salida_Digital(Canal: Canal_DO; Valor: Estado_Digital); procedure Comienza_Analogico(Canal: Canal_AI); function Lectura_Analogico(Canal: Canal_AI) return Unidades_AI; end AdaCar.Entrada_Salida;
AdaCore/gpr
Ada
28
ads
package PckAl is end PckAl;
frett27/Ada-Synthetizer
Ada
10,367
adb
-- The Beer-Ware License (revision 42) -- -- Jacob Sparre Andersen <[email protected]> wrote this. As long as you -- retain this notice you can do whatever you want with this stuff. If we meet -- some day, and you think this stuff is worth it, you can buy me a beer in -- return. -- -- Jacob Sparre Andersen with Interfaces.C.Strings; package body Sound.Mono is procedure Close (Line : in out Line_Type) is use type Interfaces.C.int; Error : Interfaces.C.int; begin Error := snd_pcm_close (Line); if Error /= 0 then raise Program_Error with "snd_pcm_close failed: " & Error'Img; end if; end Close; function Is_Open (Line : in Line_Type) return Boolean is use Sound.ALSA; begin case snd_pcm_state (Line) is when Prepared | Running => return True; when Open | Setup | XRun | Draining | Paused | Suspended | Disconnected => return False; end case; end Is_Open; procedure Open (Line : in out Line_Type; Mode : in Line_Mode; Resolution : in out Sample_Frequency; Buffer_Size : in out Duration; Period : in out Duration) is use Interfaces.C, Interfaces.C.Strings, Sound.ALSA; Name : aliased char_array := To_C ("default"); -- To_C ("plughw:0,0"); Error : Interfaces.C.int; Local_Line : aliased Line_Type := Line; Settings : aliased Params_Access; begin Error := snd_pcm_open (pcmp => Local_Line'Access, name => To_Chars_Ptr (Name'Unchecked_Access), stream => Sound.ALSA.Value (Mode), mode => 0); if Error < 0 then declare errMsg : constant Interfaces.C.Strings.chars_ptr := snd_strerror (Error); begin raise Program_Error with "Error code (snd_pcm_open): " & Error'Img & " " & Interfaces.C.Strings.Value (errMsg); end; end if; Error := snd_pcm_hw_params_malloc (Settings'Access); if Error < 0 then declare errMsg : constant Interfaces.C.Strings.chars_ptr := snd_strerror (Error); begin raise Program_Error with "Error code (snd_pcm_hw_params_malloc): " & Error'Img & " " & Interfaces.C.Strings.Value (errMsg); end; end if; Clear_Settings : begin Error := snd_pcm_hw_params_any (pcm => Local_Line, params => Settings); if Error < 0 then declare errMsg : constant Interfaces.C.Strings.chars_ptr := snd_strerror (Error); begin raise Program_Error with "Error code (snd_pcm_hw_params_any): " & Error'Img & " " & Interfaces.C.Strings.Value (errMsg); end; end if; end Clear_Settings; Set_Resampling_Rate : begin Error := snd_pcm_hw_params_set_rate_resample (pcm => Local_Line, params => Settings, val => False); if Error < 0 then declare errMsg : constant Interfaces.C.Strings.chars_ptr := snd_strerror (Error); begin raise Program_Error with "Error code (snd_pcm_hw_params_set_rate_resample): " & Error'Img & " " & Interfaces.C.Strings.Value (errMsg); end; end if; end Set_Resampling_Rate; Set_Sampling_Layout : begin Error := snd_pcm_hw_params_set_access (pcm => Local_Line, params => Settings, val => Read_Write_Interleaved); if Error < 0 then declare errMsg : constant Interfaces.C.Strings.chars_ptr := snd_strerror (Error); begin raise Program_Error with "Error code (snd_pcm_hw_params_set_access): " & Error'Img & " " & Interfaces.C.Strings.Value (errMsg); end; end if; end Set_Sampling_Layout; Set_Recording_Format : begin Error := snd_pcm_hw_params_set_format (pcm => Local_Line, params => Settings, format => Sound.ALSA.Signed_16_Bit); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_format): " & Error'Img; end if; end Set_Recording_Format; Set_Channel_Count : begin Error := snd_pcm_hw_params_set_channels (pcm => Local_Line, params => Settings, val => 1); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_channels): " & Error'Img; end if; end Set_Channel_Count; Set_Sample_Frequency : declare Sample_Rate : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (Resolution); Approximation : aliased Sound.ALSA.Approximation_Direction := 1; begin Error := snd_pcm_hw_params_set_rate_near (pcm => Local_Line, params => Settings, val => Sample_Rate'Access, dir => Approximation'Access); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_rate_near): " & Error'Img; end if; Resolution := Sample_Frequency (Sample_Rate); end Set_Sample_Frequency; Set_Buffer_Time : declare Buffer_Time : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (1_000_000 * Buffer_Size); Approximation : aliased Sound.ALSA.Approximation_Direction := 0; begin Error := snd_pcm_hw_params_set_buffer_time_near (pcm => Local_Line, params => Settings, val => Buffer_Time'Access, dir => Approximation'Access); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_buffer_time_near): " & Error'Img; end if; Buffer_Size := Duration (Buffer_Time) / 1_000_000.0; end Set_Buffer_Time; Set_Period : declare Period_Time : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (1_000_000 * Period); Approximation : aliased Sound.ALSA.Approximation_Direction := 0; begin Error := snd_pcm_hw_params_set_period_time_near (pcm => Local_Line, params => Settings, val => Period_Time'Access, dir => Approximation'Access); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_period_time_near): " & Error'Img; end if; Period := Duration (Period_Time) / 1_000_000.0; end Set_Period; Register_Settings : begin Error := snd_pcm_hw_params (pcm => Local_Line, params => Settings); if Error < 0 then raise Program_Error with "Error code (snd_pcm_hw_params): " & Error'Img; end if; end Register_Settings; Line := Local_Line; end Open; procedure Read (Line : in Line_Type; Item : out Frame_Array; Last : out Natural) is pragma Unmodified (Item); -- As we cheat with "function snd_pcm_readi". function snd_pcm_readi (pcm : in Line_Type; buffer : in Frame_Array; -- actually "out" size : in ALSA.snd_pcm_uframes_t) return ALSA.snd_pcm_sframes_t; pragma Import (C, snd_pcm_readi); use type Sound.ALSA.snd_pcm_sframes_t; Received_Frame_Count : Sound.ALSA.snd_pcm_sframes_t; begin Received_Frame_Count := snd_pcm_readi (pcm => Line, buffer => Item, size => Item'Length); if Received_Frame_Count < 0 then raise Program_Error with "snd_pcm_readi failed: " & Received_Frame_Count'Img; else Last := Item'First - 1 + Natural (Received_Frame_Count); end if; end Read; procedure Write (Line : in Line_Type; Item : in Frame_Array; Last : out Natural) is function snd_pcm_writei (pcm : in Line_Type; buffer : in Frame_Array; size : in ALSA.snd_pcm_uframes_t) return ALSA.snd_pcm_sframes_t; pragma Import (C, snd_pcm_writei); function snd_pcm_recover (pcm : in Line_Type; frames : in ALSA.snd_pcm_sframes_t; i : in Interfaces.C.int) return ALSA.snd_pcm_sframes_t; pragma Import (C, snd_pcm_recover); use type Sound.ALSA.snd_pcm_sframes_t; -- use type Interfaces.C.int; Written_Frame_Count : Sound.ALSA.snd_pcm_sframes_t; -- RetCode : Interfaces.C.int; begin -- RetCode := snd_pcm_drain (Line); -- if RetCode < 0 then -- raise Program_Error with -- "snd_pcm_drain failed: " & Integer'Image (Integer (RetCode)); -- end if; Written_Frame_Count := snd_pcm_writei (pcm => Line, buffer => Item, size => Item'Length); if Written_Frame_Count < 0 then Written_Frame_Count := snd_pcm_recover (Line, Written_Frame_Count, 0); end if; if Written_Frame_Count < 0 then raise Program_Error with "snd_pcm_writei failed: " & Written_Frame_Count'Img; else Last := Item'First - 1 + Natural (Written_Frame_Count); end if; end Write; end Sound.Mono;
zrmyers/VulkanAda
Ada
5,098
adb
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2021 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- with Ada.Text_IO; with Ada.Characters.Latin_1; with Vulkan.Test.Framework; with Vulkan.Math.GenFMatrix; with Vulkan.Math.Mat2x3; with Vulkan.Math.Mat2x2; with Vulkan.Math.GenFType; with Vulkan.Math.Vec2; with Vulkan.Math.Vec3; use Ada.Text_IO; use Ada.Characters.Latin_1; use Vulkan.Math.Mat2x2; use Vulkan.Math.Mat2x3; use Vulkan.Math.GenFType; use Vulkan.Math.Vec2; use Vulkan.Math.Vec3; use Vulkan.Test.Framework; -------------------------------------------------------------------------------- --< @group Vulkan Math Basic Types -------------------------------------------------------------------------------- --< @summary --< This package provides tests for single precision floating point mat2x3. -------------------------------------------------------------------------------- package body Vulkan.Math.Mat2x3.Test is -- Test Mat2x3 procedure Test_Mat2x3 is vec1 : Vkm_Vec2 := Make_Vec2(1.0, 2.0); vec2 : Vkm_Vec3 := Make_Vec3(1.0, 2.0, 3.0); mat1 : Vkm_Mat2x3 := Make_Mat2x3; mat2 : Vkm_Mat2x3 := Make_Mat2x3(0.0, 1.0, 2.0, 3.0, 4.0, 5.0); mat3 : Vkm_Mat2x3 := Make_Mat2x3(vec2, - vec2); mat4 : Vkm_Mat2x3 := Make_Mat2x3(mat2); mat5 : Vkm_Mat2x2 := Make_Mat2x2(5.0); mat6 : Vkm_Mat2x3 := Make_Mat2x3(mat5); mat7 : Vkm_Mat2x2 := Make_Mat2x2( 1.0, -1.0, -1.0, 2.0); begin Put_Line(LF & "Testing Mat2x3 Constructors..."); Put_Line("mat1 " & mat1.Image); Assert_Mat2x3_Equals(mat1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); Put_Line("mat2 " & mat2.Image); Assert_Mat2x3_Equals(mat2, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0); Put_Line("mat3 " & mat3.Image); Assert_Mat2x3_Equals(mat3, 1.0, 2.0, 3.0, -1.0, -2.0, -3.0); Put_Line("mat4 " & mat4.Image); Assert_Mat2x3_Equals(mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0); Put_Line("mat6 " & mat6.Image); Assert_Mat2x3_Equals(mat6, 5.0, 0.0, 0.0, 0.0, 5.0, 0.0); Put_Line("Testing '=' operator..."); Put_Line(" mat2 != mat3"); Assert_Vkm_Bool_Equals(mat2 = mat3, False); Put_Line(" mat4 != mat5"); Assert_Vkm_Bool_Equals(mat4 = mat5, False); Put_Line(" mat4 = mat2"); Assert_Vkm_Bool_Equals(mat4 = mat2, True); Put_Line(" Testing unary '+/-' operator"); Put_Line(" + mat4 = " & Image(+ mat4)); Assert_Mat2x3_Equals(+mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0); Put_Line(" - mat4 = " & Image(- mat4)); Assert_Mat2x3_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0); Put_Line("+(- mat4) = " & Image(+(- mat4))); Assert_Mat2x3_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0); Put_Line("Testing 'abs' operator..."); Put_Line(" abs(- mat4) = " & Image(abs(-mat4))); Assert_Mat2x3_Equals(abs(-mat4), 0.0, 1.0, 2.0, 3.0, 4.0, 5.0); Put_Line("Testing '+' operator..."); Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3)); Assert_Mat2x3_Equals(mat4 + mat3, 1.0, 3.0, 5.0, 2.0, 2.0, 2.0); Put_Line("Testing '-' operator..."); Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3)); Assert_Mat2x3_Equals(mat4 - mat3, -1.0, -1.0, -1.0, 4.0, 6.0, 8.0); Put_Line("Testing '*' operator..."); Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4)); Assert_Mat2x3_Equals(mat7 * mat4, -3.0, -3.0, -3.0, 6.0, 7.0, 8.0); Put_Line(" mat4 * vec2 = " & Image(mat4 * vec2)); Assert_Vec2_Equals(mat4 * vec2, 8.0, 26.0); Put_Line(" vec1 * mat4 = " & Image(vec1 * mat4)); Assert_Vec3_Equals(vec1 * mat4, 6.0, 9.0, 12.0); end Test_Mat2x3; end Vulkan.Math.Mat2x3.Test;
annexi-strayline/ASAP-Simple_HTTP
Ada
14,171
adb
------------------------------------------------------------------------------ -- -- -- Simple HTTP -- -- -- -- Basic HTTP 1.1 support for API endpoints -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2021, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- 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 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 -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Maps; with Ada.Characters.Handling; with Hex.Unsigned_8; separate (Simple_HTTP.RFC_3986) package body URI_Parser is use URI_Strings; ------------------ -- Valid_Escape -- ------------------ -- Given the position of a '%' character, determine if two hex digits follow function Valid_Escape (Sequence: URI_String; Starting: Positive) return Boolean is begin if Starting + 2 > Length (Sequence) then return False; else return Hex.Valid_Hex_String (Slice (Source => Sequence, Low => Starting + 1, High => Starting + 2)); end if; end; -------------- -- Unescape -- -------------- procedure Unescape (Sequence: in out URI_String; Valid : out Boolean) is use Hex, Hex.Unsigned_8; Escaped: URI_String; I: Positive := 1; E: Character; Sequence_Length: constant Natural := Length (Sequence); procedure Unescape_At (Index: Positive) with Inline is begin if Index + 2 > Sequence_Length then raise Constraint_Error with "Invalid URI escape: escape sequence too short."; end if; declare Code: constant String := Slice (Source => Sequence, Low => Index + 1, High => Index + 2); begin if not Valid_Hex_String (Code) then Valid := False; return; end if; Append (Source => Escaped, New_Item => Character'Val (Decode (Code))); end; end Unescape_At; begin Valid := True; -- Short circuit scan if Index (Source => Sequence, Pattern => "%", From => 1) = 0 then -- No escapes here return; end if; while I <= Sequence_Length loop E := Element (Source => Sequence, Index => I); if E = '%' then Unescape_At (I); if not Valid then return; else I := I + 2; end if; else Append (Source => Escaped, New_Item => E); end if; I := I + 1; end loop; Sequence := Escaped; end Unescape; ------------ -- Scheme -- ------------ procedure Scheme (URI : in URI_String; Scheme: out URI_String; Valid : out Boolean) is Scheme_Start: constant Natural := Index (Source => URI, Pattern => ":", From => 1); E: Character; Scheme_String: URI_String; begin Scheme := Null_Bounded_String; if Scheme_Start = 0 then -- short circuit Valid := True; return; end if; for I in 1 .. Scheme_Start - 1 loop E := Element (Source => URI, Index => I); if Is_unreserved (E) then E := Ada.Characters.Handling.To_Lower (E); Append (Source => Scheme, New_Item => E); else Valid := False; return; end if; end loop; Valid := True; end Scheme; --------------------- -- Parse_Authority -- --------------------- procedure Parse_Authority (URI : in URI_String; Default_Port: in Port_Number := 80; Valid : out Boolean; userinfo : out URI_String; host : out URI_String; port : out Port_Number) is separate; ---------- -- Path -- ---------- function Path (Sequence: URI_String) return URI_String is First, Last: Natural; Sequence_Length: constant Natural := Length (Sequence); Path_End_Set: constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set ("?#"); begin -- If there is a "//" then we skip it. Otherwise, we seek to -- the first '/' and until we reach the end or '?' First := Index (Source => Sequence, Pattern => "//", From => 1); if First = 0 then First := 1; else First := First + 2; if First > Sequence_Length then return Null_Bounded_String; end if; end if; First := Index (Source => Sequence, Pattern => "/", From => First); if First = 0 then return Null_Bounded_String; end if; Last := Index (Source => Sequence, Set => Path_End_Set, From => First + 1); if Last = 0 then Last := Length (Sequence); else Last := Last - 1; end if; return Bounded_Slice (Source => Sequence, Low => First, High => Last); end Path; ----------------- -- First_Query -- ----------------- function Valid_Query (Candidate : URI_String; First, Last: Positive) return Boolean is E: Character; begin for I in First .. Last loop E := Element (Source => Candidate, Index => I); if E = Escape_Preamble and then not Valid_Escape (Sequence => Candidate, Starting => I) then return False; elsif not Is_unreserved (E) or else not Is_sub_Delim (E) or else E not in ':' | '@' | '/' | '?' then return False; end if; end loop; return True; end Valid_Query; ---------------------------------------------------------------------- procedure Set_Query_End (Sequence : in URI_String; Sequence_Length : in Natural; First : in Natural; Last : out Natural; Next_Query_Start: out Natural; Valid : out Boolean) is -- Used by both First_Query and Next_Query to set the Last marker, -- as well as Next_Query_String. -- -- For an empty query "?&" / "&&", Last is set to zero, indicating -- a Null_Bounded_String should be returned (by the caller). Query_End_Set: constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set ("&#"); begin Last := Index (Source => Sequence, Set => Query_End_Set, From => First); if Last = 0 then Last := Sequence_Length; Next_Query_Start := 0; Valid := True; elsif Last = First then -- This means we found a query that starts with '&' or '#', since -- First is supposed to be the first character of the actual -- query. Empty "queries" like this are considered to be invalid. Valid := False; else if Last = Sequence_Length or else Element (Source => Sequence, Index => Last) = '#' then -- RFC 3986 indicates that '#' terminates the entire query. -- And, obviously, the end of the URI itself means the same Next_Query_Start := 0; else Next_Query_Start := Last + 1; end if; Last := Last - 1; Valid := True; end if; end Set_Query_End; ---------------------------------------------------------------------- procedure First_Query (URI : in URI_String; Query : out URI_String; Next_Query_Start: out Natural; Valid : out Boolean) is First, Last: Natural; URI_Length: constant Natural := Length (URI); procedure Set_Invalid is begin Query := Null_Bounded_String; Next_Query_Start := 0; Valid := False; end; begin First := Index (Source => URI, Pattern => "?", From => 1); Query := Null_Bounded_String; if First = 0 then Next_Query_Start := 0; Valid := True; return; else First := First + 1; if First > URI_Length then -- Invalid URI - ends with '?' Set_Invalid; return; end if; end if; Set_Query_End (Sequence => URI, Sequence_Length => URI_Length, First => First, Last => Last, Next_Query_Start => Next_Query_Start, Valid => Valid); if not Valid then Set_Invalid; return; else Bounded_Slice (Source => URI, Target => Query, Low => First, High => Last); Valid := True; end if; end First_Query; ---------------- -- Next_Query -- ---------------- procedure Next_Query (URI : in URI_String; Query : out URI_String; Next_Query_Start: in out Natural; Valid : out Boolean) is First, Last: Natural; URI_Length: constant Natural := Length (URI); procedure Set_Invalid is begin Query := Null_Bounded_String; Next_Query_Start := 0; Valid := False; end; begin if Next_Query_Start = 0 or else Next_Query_Start > URI_Length then Set_Invalid; return; end if; First := Next_Query_Start; Set_Query_End (Sequence => URI, Sequence_Length => URI_Length, First => First, Last => Last, Next_Query_Start => Next_Query_Start, Valid => Valid); if not Valid then Set_Invalid; return; else Bounded_Slice (Source => URI, Target => Query, Low => First, High => Last); Valid := True; end if; end Next_Query; end URI_Parser;
reznikmm/matreshka
Ada
4,758
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.OCL.Collection_Literal_Parts; limited with AMF.OCL.Ocl_Expressions; package AMF.OCL.Collection_Ranges is pragma Preelaborate; type OCL_Collection_Range is limited interface and AMF.OCL.Collection_Literal_Parts.OCL_Collection_Literal_Part; type OCL_Collection_Range_Access is access all OCL_Collection_Range'Class; for OCL_Collection_Range_Access'Storage_Size use 0; not overriding function Get_First (Self : not null access constant OCL_Collection_Range) return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is abstract; -- Getter of CollectionRange::first. -- not overriding procedure Set_First (Self : not null access OCL_Collection_Range; To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is abstract; -- Setter of CollectionRange::first. -- not overriding function Get_Last (Self : not null access constant OCL_Collection_Range) return AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access is abstract; -- Getter of CollectionRange::last. -- not overriding procedure Set_Last (Self : not null access OCL_Collection_Range; To : AMF.OCL.Ocl_Expressions.OCL_Ocl_Expression_Access) is abstract; -- Setter of CollectionRange::last. -- end AMF.OCL.Collection_Ranges;
reznikmm/matreshka
Ada
3,795
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.UML.Classifiers; package AMF.OCL.Invalid_Types is pragma Preelaborate; type OCL_Invalid_Type is limited interface and AMF.UML.Classifiers.UML_Classifier; type OCL_Invalid_Type_Access is access all OCL_Invalid_Type'Class; for OCL_Invalid_Type_Access'Storage_Size use 0; end AMF.OCL.Invalid_Types;
reznikmm/matreshka
Ada
9,749
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.DC; with AMF.DG.Canvases; with AMF.DG.Clip_Paths; with AMF.DG.Fills.Collections; with AMF.DG.Graphical_Elements.Collections; with AMF.DG.Groups; with AMF.DG.Markers.Collections; with AMF.DG.Styles.Collections; with AMF.Internals.DG_Elements; with AMF.Visitors; package AMF.Internals.DG_Canvases is type DG_Canvas_Proxy is limited new AMF.Internals.DG_Elements.DG_Element_Proxy and AMF.DG.Canvases.DG_Canvas with null record; overriding function Get_Background_Fill (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Fills.DG_Fill_Access; -- Getter of Canvas::backgroundFill. -- -- a reference to a fill that is used to paint the background of the -- canvas itself. A backgroundFill value is exclusive with a -- backgroundColor value. If both are specified, the backgroundFill value -- is used. If none is specified, no fill is applied (i.e. the canvas -- becomes see-through). overriding procedure Set_Background_Fill (Self : not null access DG_Canvas_Proxy; To : AMF.DG.Fills.DG_Fill_Access); -- Setter of Canvas::backgroundFill. -- -- a reference to a fill that is used to paint the background of the -- canvas itself. A backgroundFill value is exclusive with a -- backgroundColor value. If both are specified, the backgroundFill value -- is used. If none is specified, no fill is applied (i.e. the canvas -- becomes see-through). overriding function Get_Background_Color (Self : not null access constant DG_Canvas_Proxy) return AMF.DC.Optional_DC_Color; -- Getter of Canvas::backgroundColor. -- -- a color that is used to paint the background of the canvas itself. A -- backgroundColor value is exclusive with a backgroundFill value. If both -- are specified, the backgroundFill value is used. If none is specified, -- no fill is applied (i.e. the canvas becomes see-through). overriding procedure Set_Background_Color (Self : not null access DG_Canvas_Proxy; To : AMF.DC.Optional_DC_Color); -- Setter of Canvas::backgroundColor. -- -- a color that is used to paint the background of the canvas itself. A -- backgroundColor value is exclusive with a backgroundFill value. If both -- are specified, the backgroundFill value is used. If none is specified, -- no fill is applied (i.e. the canvas becomes see-through). overriding function Get_Packaged_Fill (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Fills.Collections.Set_Of_DG_Fill; -- Getter of Canvas::packagedFill. -- -- a set of fills packaged by the canvas and referenced by graphical -- elements in the canvas. overriding function Get_Packaged_Marker (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Markers.Collections.Set_Of_DG_Marker; -- Getter of Canvas::packagedMarker. -- -- A set of markers packaged by the canvas and referenced by marked -- elements in the canvas. overriding function Get_Packaged_Style (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Styles.Collections.Set_Of_DG_Style; -- Getter of Canvas::packagedStyle. -- -- a set of styles packaged by the canvas and referenced by graphical -- elements in the canvas as shared styles. overriding function Get_Member (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Graphical_Elements.Collections.Ordered_Set_Of_DG_Graphical_Element; -- Getter of Group::member. -- -- the list of graphical elements that are members of (owned by) this -- group. overriding function Get_Group (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Groups.DG_Group_Access; -- Getter of GraphicalElement::group. -- -- the group element that owns this graphical element. overriding procedure Set_Group (Self : not null access DG_Canvas_Proxy; To : AMF.DG.Groups.DG_Group_Access); -- Setter of GraphicalElement::group. -- -- the group element that owns this graphical element. overriding function Get_Local_Style (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style; -- Getter of GraphicalElement::localStyle. -- -- a list of locally-owned styles for this graphical element. overriding function Get_Shared_Style (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style; -- Getter of GraphicalElement::sharedStyle. -- -- a list of shared styles for this graphical element. overriding function Get_Transform (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Sequence_Of_DG_Transform; -- Getter of GraphicalElement::transform. -- -- a list of zero or more transforms to apply to this graphical element. overriding function Get_Clip_Path (Self : not null access constant DG_Canvas_Proxy) return AMF.DG.Clip_Paths.DG_Clip_Path_Access; -- Getter of GraphicalElement::clipPath. -- -- an optional reference to a clip path element that masks the painting of -- this graphical element. overriding procedure Set_Clip_Path (Self : not null access DG_Canvas_Proxy; To : AMF.DG.Clip_Paths.DG_Clip_Path_Access); -- Setter of GraphicalElement::clipPath. -- -- an optional reference to a clip path element that masks the painting of -- this graphical element. overriding procedure Enter_Element (Self : not null access constant DG_Canvas_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant DG_Canvas_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant DG_Canvas_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.DG_Canvases;
kontena/ruby-packer
Ada
3,733
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.My_Field_Type -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2006,2008 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.16 $ -- $Date: 2008/07/26 18:47:58 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- This is a very simple user defined field type. It accepts only a -- defined character as input into the field. -- package body Sample.My_Field_Type is -- That's simple. There are minimal field validity checks. function Field_Check (Fld : Field; Typ : My_Data) return Boolean is begin if Fld = Null_Field or Typ.Ch = Character'Val (0) then return False; end if; return True; end Field_Check; -- Check exactly against the specified character. function Character_Check (Ch : Character; Typ : My_Data) return Boolean is C : constant Character := Typ.Ch; begin return Ch = C; end Character_Check; end Sample.My_Field_Type;
zhmu/ananas
Ada
2,663
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . H T A B L E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a dummy body, required because if we remove the body we have -- bootstrap path problems (this unit used to have a body, and if we do not -- supply a dummy body, the old incorrect body is picked up during the -- bootstrap process). package body GNAT.HTable is end GNAT.HTable;
Rodeo-McCabe/orka
Ada
7,311
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Numerics.Generic_Elementary_Functions; with Ahven; use Ahven; with GL.Types; with Orka.Transforms.Doubles.Vectors; package body Test_Transforms_Doubles_Vectors is use GL.Types; use Orka; use Orka.Transforms.Doubles.Vectors; use type Vector4; package EF is new Ada.Numerics.Generic_Elementary_Functions (Double); function Is_Equivalent (Expected, Result : GL.Types.Double) return Boolean is Epsilon : constant GL.Types.Double := 2.0 ** (1 - GL.Types.Double'Model_Mantissa); begin return Result in Expected - Epsilon .. Expected + Epsilon; end Is_Equivalent; overriding procedure Initialize (T : in out Test) is begin T.Set_Name ("Vectors"); T.Add_Test_Routine (Test_Add'Access, "Test '+' operator"); T.Add_Test_Routine (Test_Subtract'Access, "Test '-' operator"); T.Add_Test_Routine (Test_Scale'Access, "Test '*' operator"); T.Add_Test_Routine (Test_Absolute'Access, "Test 'abs' operator"); T.Add_Test_Routine (Test_Magnitude'Access, "Test Magnitude function"); T.Add_Test_Routine (Test_Normalize'Access, "Test Normalize function"); T.Add_Test_Routine (Test_Distance'Access, "Test Distance function"); T.Add_Test_Routine (Test_Projection'Access, "Test Projection function"); T.Add_Test_Routine (Test_Perpendicular'Access, "Test Perpendicular function"); T.Add_Test_Routine (Test_Angle'Access, "Test Angle function"); T.Add_Test_Routine (Test_Dot_Product'Access, "Test Dot function"); T.Add_Test_Routine (Test_Cross_Product'Access, "Test Cross function"); end Initialize; procedure Test_Add is Left : constant Vector4 := (2.0, 3.0, 4.0, 0.0); Right : constant Vector4 := (-2.0, 3.0, 0.0, -1.0); Expected : constant Vector4 := (0.0, 6.0, 4.0, -1.0); Result : constant Vector4 := Left + Right; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Add; procedure Test_Subtract is Left : constant Vector4 := (2.0, 3.0, 4.0, 0.0); Right : constant Vector4 := (-2.0, 3.0, 0.0, -1.0); Expected : constant Vector4 := (4.0, 0.0, 4.0, 1.0); Result : constant Vector4 := Left - Right; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Subtract; procedure Test_Scale is Elements : constant Vector4 := (2.0, 3.0, 1.0, 0.0); Expected : constant Vector4 := (4.0, 6.0, 2.0, 0.0); Result : constant Vector4 := 2.0 * Elements; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Scale; procedure Test_Absolute is Elements : constant Vector4 := (-2.0, 0.0, 1.0, -1.0); Expected : constant Vector4 := (2.0, 0.0, 1.0, 1.0); Result : constant Vector4 := abs Elements; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Absolute; procedure Test_Magnitude is Elements : constant Vector4 := (1.0, -2.0, 3.0, -4.0); Expected : constant GL.Types.Double := EF.Sqrt (1.0**2 + (-2.0)**2 + 3.0**2 + (-4.0)**2); Result : constant GL.Types.Double := Magnitude (Elements); begin Assert (Is_Equivalent (Expected, Result), "Unexpected Double " & GL.Types.Double'Image (Result)); end Test_Magnitude; procedure Test_Normalize is Elements : constant Vector4 := (1.0, -2.0, 3.0, -4.0); Expected : constant GL.Types.Double := 1.0; Result : constant GL.Types.Double := Magnitude (Normalize (Elements)); begin Assert (Is_Equivalent (Expected, Result), "Unexpected Double " & GL.Types.Double'Image (Result)); end Test_Normalize; procedure Test_Distance is Left : constant Vector4 := (2.0, 5.0, 0.0, 0.0); Right : constant Vector4 := (2.0, 2.0, 0.0, 0.0); Expected : constant GL.Types.Double := 3.0; Result : constant GL.Types.Double := Distance (Left, Right); begin Assert (Is_Equivalent (Expected, Result), "Unexpected Double " & GL.Types.Double'Image (Result)); end Test_Distance; procedure Test_Projection is Elements : constant Vector4 := (3.0, 4.0, 0.0, 0.0); Direction : constant Vector4 := (0.0, 1.0, 0.0, 0.0); Expected : constant Vector4 := (0.0, 4.0, 0.0, 0.0); Result : constant Vector4 := Projection (Elements, Direction); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Projection; procedure Test_Perpendicular is Elements : constant Vector4 := (3.0, 4.0, 0.0, 0.0); Direction : constant Vector4 := (0.0, 1.0, 0.0, 0.0); Expected : constant Vector4 := (3.0, 0.0, 0.0, 0.0); Result : constant Vector4 := Perpendicular (Elements, Direction); begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Perpendicular; procedure Test_Angle is Left : constant Vector4 := (3.0, 0.0, 0.0, 0.0); Right : constant Vector4 := (0.0, 4.0, 0.0, 0.0); Expected : constant GL.Types.Double := To_Radians (90.0); Result : constant GL.Types.Double := Angle (Left, Right); begin Assert (Is_Equivalent (Expected, Result), "Unexpected Double " & GL.Types.Double'Image (Result)); end Test_Angle; procedure Test_Dot_Product is Left : constant Vector4 := (1.0, 2.0, 3.0, 4.0); Right : constant Vector4 := (2.0, 3.0, 4.0, 5.0); Expected : constant GL.Types.Double := 40.0; Result : constant GL.Types.Double := Dot (Left, Right); begin Assert (Is_Equivalent (Expected, Result), "Unexpected Double " & GL.Types.Double'Image (Result)); end Test_Dot_Product; procedure Test_Cross_Product is Left : constant Vector4 := (2.0, 4.0, 8.0, 0.0); Right : constant Vector4 := (5.0, 6.0, 7.0, 0.0); Expected : constant Vector4 := (-20.0, 26.0, -8.0, 0.0); Result : constant Vector4 := Cross (Left, Right); begin for I in X .. Z loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Cross_Product; end Test_Transforms_Doubles_Vectors;
reznikmm/matreshka
Ada
4,009
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Use_Caption_Attributes; package Matreshka.ODF_Text.Use_Caption_Attributes is type Text_Use_Caption_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Use_Caption_Attributes.ODF_Text_Use_Caption_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Use_Caption_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Use_Caption_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Use_Caption_Attributes;
chinmayshah99/helloworld
Ada
124
adb
-- Hello World in Ada with Text_IO; procedure Hello_World is begin Text_IO.Put_Line("Hello World!"); end Hello_World;
charlie5/aIDE
Ada
2,386
ads
with AdaM.Any, ada.Streams; limited with AdaM.Declaration.of_package; package AdaM.context_Line is type Item is new Any.Item with private; -- View -- type View is access all Item'Class; procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; -- Vector -- package Vectors is new ada.Containers.Vectors (Positive, View); subtype Vector is Vectors.Vector; function to_Source (the_Lines : in Vector) return text_Vectors.Vector; -- Forge -- function new_context_Line (Name : in String := "") return context_Line.view; procedure free (Self : in out context_Line.view); procedure destruct (Self : in out Item); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; function to_Source (Self : in Item) return text_Vectors.Vector; type Package_view is access all Declaration.of_package.item'Class; procedure Package_view_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in Package_view); procedure Package_view_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out Package_view); for Package_view'write use Package_view_write; for Package_view'read use Package_view_read; function my_Package (Self : in Item) return Package_view; procedure Package_is (Self : in out Item; Now : in Package_view); function Name (Self : access Item) return access Text; function Name (Self : in Item) return String; procedure Name_is (Self : in out Item; Now : in String); function is_Used (Self : in Item) return Boolean; procedure is_Used (Self : in out Item; Now : in Boolean); private type Item is new Any.Item with record my_Package : Package_view; package_Name : aliased Text; Used : Boolean; end record; end AdaM.context_Line;
AdaCore/libadalang
Ada
933
adb
procedure P (N : Integer; M : in Integer; O : in out Integer; P : out Integer) --% [x.p_is_constant_object for x in node.f_params] is C : constant Integer := 0; --% node.p_is_constant_object D : Integer := 0; --% node.p_is_constant_object type A is array (Natural range <>) of Integer; E : constant A (1 .. 4) := (1, 2, 3, 4); F : A (1 .. 3) := (1, 2, 3); G, H : A (1 .. 2); Q, R : Integer; begin D := N; --% node.f_dest.p_referenced_decl().p_is_constant_object --% node.f_expr.p_referenced_decl().p_is_constant_object O := D; --% node.f_dest.p_referenced_decl().p_is_constant_object P := M + C + D + O; --% node.f_dest.p_referenced_decl().p_is_constant_object Q := E(1); --% node.f_expr.p_is_constant R := F(1); --% node.f_expr.p_is_constant G := E(1 .. 2); --% node.f_expr.p_is_constant H := F(2 .. 3); --% node.f_expr.p_is_constant end P;
HackInvent/Ada_Drivers_Library
Ada
2,105
ads
-- This spec has been automatically generated from STM32H7x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.CRC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_POLYSIZE_Field is STM32_SVD.UInt2; subtype CR_REV_IN_Field is STM32_SVD.UInt2; -- Control register type CR_Register is record -- Write-only. RESET bit RESET : Boolean := False; -- unspecified Reserved_1_2 : STM32_SVD.UInt2 := 16#0#; -- Polynomial size POLYSIZE : CR_POLYSIZE_Field := 16#0#; -- Reverse input data REV_IN : CR_REV_IN_Field := 16#0#; -- Reverse output data REV_OUT : Boolean := False; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record RESET at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; POLYSIZE at 0 range 3 .. 4; REV_IN at 0 range 5 .. 6; REV_OUT at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cryptographic processor type CRC_Peripheral is record -- Data register DR : aliased STM32_SVD.UInt32; -- Independent Data register IDR : aliased STM32_SVD.UInt32; -- Control register CR : aliased CR_Register; -- Initial CRC value INIT : aliased STM32_SVD.UInt32; -- CRC polynomial POL : aliased STM32_SVD.UInt32; end record with Volatile; for CRC_Peripheral use record DR at 16#0# range 0 .. 31; IDR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; INIT at 16#C# range 0 .. 31; POL at 16#10# range 0 .. 31; end record; -- Cryptographic processor CRC_Periph : aliased CRC_Peripheral with Import, Address => CRC_Base; end STM32_SVD.CRC;