repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
reznikmm/matreshka
Ada
29,166
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$ ------------------------------------------------------------------------------ with League.Strings.Internals; with Matreshka.Internals.Strings; with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UMLDI_Iterators; with AMF.Visitors.UMLDI_Visitors; package body AMF.Internals.UMLDI_UML_Activity_Diagrams is --------------------------- -- Get_Is_Activity_Frame -- --------------------------- overriding function Get_Is_Activity_Frame (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Activity_Frame (Self.Element); end Get_Is_Activity_Frame; --------------------------- -- Set_Is_Activity_Frame -- --------------------------- overriding procedure Set_Is_Activity_Frame (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Activity_Frame (Self.Element, To); end Set_Is_Activity_Frame; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.UML.Activities.UML_Activity_Access is begin return AMF.UML.Activities.UML_Activity_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element (Self.Element))); end Get_Model_Element; ----------------------- -- Set_Model_Element -- ----------------------- overriding procedure Set_Model_Element (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UML.Activities.UML_Activity_Access) is begin raise Program_Error; -- AMF.Internals.Tables.UML_Attributes.Internal_Set_Model_Element -- (Self.Element, -- AMF.Internals.Helpers.To_Element -- (AMF.Elements.Element_Access (To))); end Set_Model_Element; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access is begin return AMF.UML.Behaviors.UML_Behavior_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element (Self.Element))); end Get_Model_Element; ----------------------- -- Set_Model_Element -- ----------------------- overriding procedure Set_Model_Element (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access) is begin raise Program_Error; -- AMF.Internals.Tables.UML_Attributes.Internal_Set_Model_Element -- (Self.Element, -- AMF.Internals.Helpers.To_Element -- (AMF.Elements.Element_Access (To))); end Set_Model_Element; ----------------- -- Get_Heading -- ----------------- overriding function Get_Heading (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access is begin return AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Heading (Self.Element))); end Get_Heading; ----------------- -- Set_Heading -- ----------------- overriding procedure Set_Heading (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UMLDI.UML_Labels.UMLDI_UML_Label_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Heading (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Heading; ------------------ -- Get_Is_Frame -- ------------------ overriding function Get_Is_Frame (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Frame (Self.Element); end Get_Is_Frame; ------------------ -- Set_Is_Frame -- ------------------ overriding procedure Set_Is_Frame (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Frame (Self.Element, To); end Set_Is_Frame; ---------------- -- Get_Is_Iso -- ---------------- overriding function Get_Is_Iso (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Iso (Self.Element); end Get_Is_Iso; ---------------- -- Set_Is_Iso -- ---------------- overriding procedure Set_Is_Iso (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Iso (Self.Element, To); end Set_Is_Iso; ----------------- -- Get_Is_Icon -- ----------------- overriding function Get_Is_Icon (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Icon (Self.Element); end Get_Is_Icon; ----------------- -- Set_Is_Icon -- ----------------- overriding procedure Set_Is_Icon (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Icon (Self.Element, To); end Set_Is_Icon; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is begin return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; --------------------- -- Set_Local_Style -- --------------------- overriding procedure Set_Local_Style (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Local_Style; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin raise Program_Error; return X : AMF.UML.Elements.Collections.Set_Of_UML_Element; -- return -- AMF.UML.Elements.Collections.Wrap -- (AMF.Internals.Element_Collections.Wrap -- (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element -- (Self.Element))); end Get_Model_Element; ----------------------- -- Get_Model_Element -- ----------------------- overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.CMOF.Elements.CMOF_Element_Access is begin return AMF.CMOF.Elements.CMOF_Element_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element (Self.Element))); end Get_Model_Element; --------------------- -- Get_Local_Style -- --------------------- overriding function Get_Local_Style (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.DI.Styles.DI_Style_Access is begin return AMF.DI.Styles.DI_Style_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style (Self.Element))); end Get_Local_Style; --------------------- -- Set_Local_Style -- --------------------- overriding procedure Set_Local_Style (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.DI.Styles.DI_Style_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Local_Style; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return League.Strings.Universal_String is begin null; return League.Strings.Internals.Create (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name (Self.Element)); end Get_Name; -------------- -- Set_Name -- -------------- overriding procedure Set_Name (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : League.Strings.Universal_String) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name (Self.Element, League.Strings.Internals.Internal (To)); end Set_Name; ----------------------- -- Get_Documentation -- ----------------------- overriding function Get_Documentation (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return League.Strings.Universal_String is begin null; return League.Strings.Internals.Create (AMF.Internals.Tables.UML_Attributes.Internal_Get_Documentation (Self.Element)); end Get_Documentation; ----------------------- -- Set_Documentation -- ----------------------- overriding procedure Set_Documentation (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : League.Strings.Universal_String) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Documentation (Self.Element, League.Strings.Internals.Internal (To)); end Set_Documentation; -------------------- -- Get_Resolution -- -------------------- overriding function Get_Resolution (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy) return AMF.Real is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Resolution (Self.Element); end Get_Resolution; -------------------- -- Set_Resolution -- -------------------- overriding procedure Set_Resolution (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.Real) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Resolution (Self.Element, To); end Set_Resolution; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_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 UMLDI_UML_Activity_Diagram_Proxy; To : AMF.Optional_String) is begin if To.Is_Empty then AMF.Internals.Tables.UML_Attributes.Internal_Set_Name (Self.Element, null); else AMF.Internals.Tables.UML_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 UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_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 UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_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_Owned_Comment -- ----------------------- overriding function Get_Owned_Comment (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Owned_Comment (Self.Element))); end Get_Owned_Comment; ----------------------- -- Get_Owned_Element -- ----------------------- overriding function Get_Owned_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Owned_Element (Self.Element))); end Get_Owned_Element; --------------- -- Get_Owner -- --------------- overriding function Get_Owner (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Owner (Self.Element))); end Get_Owner; ----------------------------------- -- Get_Owning_Template_Parameter -- ----------------------------------- overriding function Get_Owning_Template_Parameter (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UML_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 UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_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 UMLDI_UML_Activity_Diagram_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.UML_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access UMLDI_UML_Activity_Diagram_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; -------------------- -- All_Namespaces -- -------------------- overriding function All_Namespaces (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.All_Namespaces"; return All_Namespaces (Self); end All_Namespaces; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.Namespace"; return Namespace (Self); end Namespace; -------------------- -- Qualified_Name -- -------------------- overriding function Qualified_Name (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.Qualified_Name"; return Qualified_Name (Self); end Qualified_Name; --------------- -- Separator -- --------------- overriding function Separator (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.Separator"; return Separator (Self); end Separator; ------------------------ -- All_Owned_Elements -- ------------------------ overriding function All_Owned_Elements (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.All_Owned_Elements"; return All_Owned_Elements (Self); end All_Owned_Elements; ------------------------ -- Is_Compatible_With -- ------------------------ overriding function Is_Compatible_With (Self : not null access constant UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_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 UMLDI_UML_Activity_Diagram_Proxy.Is_Template_Parameter"; return Is_Template_Parameter (Self); end Is_Template_Parameter; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class (Visitor).Enter_UML_Activity_Diagram (AMF.UMLDI.UML_Activity_Diagrams.UMLDI_UML_Activity_Diagram_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class (Visitor).Leave_UML_Activity_Diagram (AMF.UMLDI.UML_Activity_Diagrams.UMLDI_UML_Activity_Diagram_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UMLDI_UML_Activity_Diagram_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.UMLDI_Iterators.UMLDI_Iterator'Class then AMF.Visitors.UMLDI_Iterators.UMLDI_Iterator'Class (Iterator).Visit_UML_Activity_Diagram (Visitor, AMF.UMLDI.UML_Activity_Diagrams.UMLDI_UML_Activity_Diagram_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.UMLDI_UML_Activity_Diagrams;
SayCV/rtems-addon-packages
Ada
6,983
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000-2008,2011 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: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision$ -- $Date$ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- A simplified version of the GNU getopt function -- copyright Free Software Foundtion with Ada.Strings.Fixed; with Ada.Strings.Bounded; with Ada.Text_IO; use Ada.Text_IO; package body ncurses2.getopt is nextchar : Natural := 0; -- Ncurses doesn't use the non option elements so we are spared -- the job of computing those. -- also the user is not allowed to modify argv or argc -- Doing so is Erroneous execution. -- long options are not handled. procedure Qgetopt (retval : out Integer; argc : Integer; argv : stringfunc; -- argv will be the Argument function. optstring : String; optind : in out Integer; -- ignored for ncurses, must be initialized to 1 by -- the caller Optarg : out stringa -- a garbage collector would be useful here. ) is package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200); use BS; optargx : Bounded_String; begin if argc < optind then retval := -1; return; end if; optargx := To_Bounded_String (""); if nextchar = 0 then if argv (optind) = "--" then -- the rest are non-options, we ignore them retval := -1; return; end if; if argv (optind)(1) /= '-' or argv (optind)'Length = 1 then optind := optind + 1; Optarg := new String'(argv (optind)); retval := 1; return; end if; nextchar := 2; -- skip the one hyphen. end if; -- Look at and handle the next short option-character. declare c : Character := argv (optind) (nextchar); temp : constant Natural := Ada.Strings.Fixed.Index (optstring, String'(1 => c)); begin if temp = 0 or c = ':' then Put_Line (Standard_Error, argv (optind) & ": invalid option -- " & c); c := '?'; return; end if; if optstring (temp + 1) = ':' then if optstring (temp + 2) = ':' then -- This is an option that accepts an argument optionally. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); else Optarg := null; end if; else -- This is an option that requires an argument. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); optind := optind + 1; elsif optind = argc then Put_Line (Standard_Error, argv (optind) & ": option requires an argument -- " & c); if optstring (optstring'First) = ':' then c := ':'; else c := '?'; end if; else -- increment it again when taking next ARGV-elt as argument. optind := optind + 1; optargx := To_Bounded_String (argv (optind)); optind := optind + 1; end if; end if; nextchar := 0; else -- no argument for the option if nextchar = argv (optind)'Length then optind := optind + 1; nextchar := 0; else nextchar := nextchar + 1; end if; end if; retval := Character'Pos (c); Optarg := new String'(To_String (optargx)); return; end; end Qgetopt; end ncurses2.getopt;
reznikmm/matreshka
Ada
4,752
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Table_Dependencies_Elements; package Matreshka.ODF_Table.Dependencies_Elements is type Table_Dependencies_Element_Node is new Matreshka.ODF_Table.Abstract_Table_Element_Node and ODF.DOM.Table_Dependencies_Elements.ODF_Table_Dependencies with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Dependencies_Element_Node; overriding function Get_Local_Name (Self : not null access constant Table_Dependencies_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Table_Dependencies_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Table_Dependencies_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Table_Dependencies_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Table.Dependencies_Elements;
shintakezou/langkit
Ada
32,620
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Containers; use Ada.Containers; with Ada.Containers.Hashed_Maps; with Ada.Containers.Ordered_Maps; with Ada.Exceptions; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Langkit_Support.Hashes; use Langkit_Support.Hashes; with Langkit_Support.Lexical_Envs; use Langkit_Support.Lexical_Envs; with Langkit_Support.Symbols; use Langkit_Support.Symbols; with Langkit_Support.Text; use Langkit_Support.Text; with Langkit_Support.Types; use Langkit_Support.Types; with Langkit_Support.Vectors; -- This package implements a scoped lexical environment data structure that -- will then be used in AST nodes. Particularities: -- -- - This data structure implements simple nesting via a Parent_Env link in -- each env. If the parent is null you are at the topmost env. -- -- - You can reference other envs, which are virtually treated like parent -- envs too. -- -- - You can annotate both whole environments and nodes with metadata, giving -- more information about the fnodes. The consequence is that metadata needs -- to be combinable, eg. you need to be able to create a single metadata -- record from two metadata records. -- -- TODO??? For the moment, everything is public, because it is not yet clear -- what the interaction interface will be with the generated library. We might -- want to make the type private at some point (or not). generic with function Get_Unit_Version (Unit : Generic_Unit_Ptr) return Version_Number; -- Used to retrieve the version number of the given Unit, for cache -- invalidation purposes. type Node_Type is private; type Node_Metadata is private; No_Node : Node_Type; Empty_Metadata : Node_Metadata; with function "<" (Left, Right : Node_Type) return Boolean is <>; with function "=" (Left, Right : Node_Type) return Boolean is <>; type Ref_Category is (<>); type Ref_Categories is array (Ref_Category) of Boolean; with function Node_Unit (Node : Node_Type) return Generic_Unit_Ptr is <>; with function Node_Hash (Node : Node_Type) return Hash_Type; with function Metadata_Hash (Metadata : Node_Metadata) return Hash_Type; with function Combine (L, R : Node_Metadata) return Node_Metadata; with function Can_Reach (Node, From : Node_Type) return Boolean is <>; -- Function that will allow filtering nodes depending on the origin node of -- the request. In practice, this is used to implement sequential semantics -- for lexical envs, as-in, node declared after another is not yet visible. with function Is_Rebindable (Node : Node_Type) return Boolean is <>; -- Return whether a lexical environment whose node is Node can be rebound with function Node_Text_Image (Node : Node_Type; Short : Boolean := True) return Text_Type; with function Acquire_Rebinding (Node : Node_Type; Parent : Env_Rebindings; Old_Env, New_Env : Lexical_Env) return Env_Rebindings is <>; -- Allocate if needed, initialize return a record to store env rebindings with procedure Register_Rebinding (Node : Node_Type; Rebinding : Env_Rebindings); -- Register a rebinding to be destroyed when Node is destroyed with function Get_Context_Version (Node : Node_Type) return Version_Number is <>; -- Return the current version number of caches corresponding to Node's -- context, for cache invalidation purposes. type Inner_Env_Assoc is private; with function Get_Key (Self : Inner_Env_Assoc) return Symbol_Type is <>; with function Get_Node (Self : Inner_Env_Assoc) return Node_Type is <>; with function Get_Metadata (Self : Inner_Env_Assoc) return Node_Metadata is <>; type Inner_Env_Assoc_Array is private; with function Length (Self : Inner_Env_Assoc_Array) return Natural is <>; with function Get (Self : Inner_Env_Assoc_Array; Index : Positive) return Inner_Env_Assoc is <>; with procedure Dec_Ref (Self : in out Inner_Env_Assoc_Array) is <>; with function Properties_May_Raise (Exc : Ada.Exceptions.Exception_Occurrence) return Boolean is <>; package Langkit_Support.Lexical_Envs_Impl is All_Cats : Ref_Categories := (others => True); pragma Compile_Time_Error (Ref_Categories'Length > 32, "Categories has to fit in a 32 bits Integer"); function Text_Image (Cats : Ref_Categories) return Text_Type; pragma Suppress (Container_Checks); -- Remove container checks for standard containers -------------- -- Entities -- -------------- type Entity_Info is record Md : Node_Metadata; -- External metadata for the node Rebindings : Env_Rebindings := null; -- Rebindings applying to this entity From_Rebound : Boolean := False; -- Whether this entity has been obtained out of a rebound environment end record with Convention => C; type Entity is record Node : Node_Type; Info : Entity_Info; end record; -- Wrapper structure to contain both the 'real' node that the user wanted -- to store, and its associated metadata. function Create_Entity (Node : Node_Type; Md : Node_Metadata) return Entity; -- Constructor that returns an Entity from an Node_Type and an -- Node_Metadata instances. function Equivalent (L, R : Entity) return Boolean; -- Return whether we can consider that L and R are equivalent entities function Equivalent (L, R : Entity_Info) return Boolean; -- Return whether we can consider that L and R are equivalent entity info ---------------------- -- Lexical_Env Type -- ---------------------- type Lexical_Env_Record; -- Value type for lexical envs type Lexical_Env_Access is access all Lexical_Env_Record; type Lexical_Env_Resolver is access function (Ref : Entity) return Lexical_Env; -- Callback type for the lazy referenced env resolution mechanism ---------------- -- Env_Getter -- ---------------- type Env_Getter (Dynamic : Boolean := False) is record Env : Lexical_Env := Null_Lexical_Env; -- If Dynamic, cache for the resolved lexical environment. To be used -- only when No_Entity_Info is used for the resolution. We consider that -- this cache contains a valid entry when Env is not Null_Lexical_Env -- and that it is not stale. -- -- Note that we process Empty_Env in a very specific way here: resolvers -- often return Empty_Env when they fail to compute the result, for -- instance because of a missing unit. When that unit is parsed, we want -- to invalidate the cache (the Env component) so that the resolver has -- another chance to fetch the result from that new unit. -- -- To achieve this, when putting Empty_Env in the cache, we set -- Env.Version to the version of the owning context, and when trying to -- use the cache, we check that the version is still the same. -- -- We do not have this problem with other envs thanks to their own unit -- version number (Empty_Env is a global singleton, so it does not has a -- owning unit nor an owning context). case Dynamic is when True => Node : Node_Type; Resolver : Lexical_Env_Resolver; -- Data and callable to resolve this getter when False => null; end case; end record; -- Link to an environment. It can be either a simple link (just a pointer) -- or a dynamic link (a function that recomputes the link when needed). See -- the two constructors below. No_Env_Getter : constant Env_Getter := (False, Null_Lexical_Env); procedure Resolve (Self : in out Env_Getter; Info : Entity_Info); -- Resolve the reference for this env getter. Info is forwarded to the -- resolver callback. function Simple_Env_Getter (E : Lexical_Env) return Env_Getter; -- Create a static Env_Getter (i.e. pointer to environment) function Dyn_Env_Getter (Resolver : Lexical_Env_Resolver; Node : Node_Type) return Env_Getter; -- Create a dynamic Env_Getter (i.e. function and closure to compute an -- environment). function Get_Env (Self : in out Env_Getter; Info : Entity_Info) return Lexical_Env; -- Return the environment associated to the Self env getter. If Self is -- dynamic, Info is forwarded to the resolver callback. function Equivalent (L, R : Env_Getter) return Boolean; -- If at least one of L and R is a dynamic env getter, raise a -- Constraint_Error. Otherwise, return whether the pointed environments are -- equal. procedure Inc_Ref (Self : Env_Getter); -- Shortcut to run Inc_Ref of the potentially embedded lexical environment procedure Dec_Ref (Self : in out Env_Getter); -- Shortcut to run Dec_Ref of the potentially embedded lexical environment -------------------- -- Env_Rebindings -- -------------------- function Combine (L, R : Env_Rebindings) return Env_Rebindings; -- Return a new Env_Rebindings that combines rebindings from both L and R function OK_For_Rebindings (Self : Lexical_Env) return Boolean; -- Return whether Self is a lexical environment that can be used in -- environment rebindings (for old or new env). function Append (Self : Env_Rebindings; Old_Env, New_Env : Lexical_Env) return Env_Rebindings with Pre => OK_For_Rebindings (Old_Env) and then OK_For_Rebindings (New_Env); -- Create a new rebindings and register it to Self and to -- Old_Env/New_Env's analysis units. function Append_Rebinding (Self : Env_Rebindings; Old_Env : Lexical_Env; New_Env : Lexical_Env) return Env_Rebindings with Pre => OK_For_Rebindings (Old_Env) and then OK_For_Rebindings (New_Env); function Text_Image (Self : Env_Rebindings) return Text_Type; ---------------------------------- -- Arrays of nodes and entities -- ---------------------------------- package Entity_Vectors is new Langkit_Support.Vectors (Entity, Small_Vector_Capacity => 2); -- Vectors used to store collections of nodes, as values of a lexical -- environment map. We want to use vectors internally. type Node_Array is array (Positive range <>) of Node_Type; subtype Entity_Array is Entity_Vectors.Elements_Array; -- Arrays of wrapped nodes stored in the environment maps ----------------------------- -- Referenced environments -- ----------------------------- type Referenced_Env is record Kind : Ref_Kind := Normal; -- Kind for this referenced env Getter : Env_Getter; -- Closure to fetch the environment that is referenced Being_Visited : Boolean; -- Flag set to true when Referenced_Env is being visited. Used as a -- recursion guard. WARNING: Not thread safe. State : Refd_Env_State := Inactive; -- State of the referenced env, whether active or inactive Categories : Ref_Categories := All_Cats; end record; -- Represents a referenced env package Referenced_Envs_Vectors is new Langkit_Support.Vectors (Referenced_Env); -- Vectors of referenced envs, used to store referenced environments ------------------------------------ -- Lexical environment public API -- ------------------------------------ type Entity_Resolver is access function (Ref : Entity) return Entity; -- Callback type for the lazy entity resolution mechanism. Such functions -- must take a "reference" entity (e.g. a name) and return the referenced -- entity. type Inner_Env_Assocs_Resolver is access function (Self : Entity) return Inner_Env_Assoc_Array; Empty_Env : constant Lexical_Env; -- Empty_Env is a magical lexical environment that will always be empty. We -- allow users to call Add on it anyway as a convenience, but this is a -- no-op. This makes sense as Empty_Env's purpose is to be used to -- represent missing scopes from erroneous trees. function Create_Lexical_Env (Parent : Lexical_Env; Node : Node_Type; Transitive_Parent : Boolean := False; Owner : Generic_Unit_Ptr) return Lexical_Env with Post => Create_Lexical_Env'Result.Kind = Static_Primary; -- Create a new static-primary lexical env function Create_Dynamic_Lexical_Env (Parent : Lexical_Env; Node : Node_Type; Transitive_Parent : Boolean := False; Owner : Generic_Unit_Ptr; Assocs_Getter : Inner_Env_Assocs_Resolver; Assoc_Resolver : Entity_Resolver := null) return Lexical_Env with Pre => Node /= No_Node, Post => Create_Dynamic_Lexical_Env'Result.Kind = Dynamic_Primary; -- Create a new dynamic-primary lexical env procedure Add (Self : Lexical_Env; Key : Symbol_Type; Value : Node_Type; Md : Node_Metadata := Empty_Metadata; Resolver : Entity_Resolver := null) with Pre => Self.Kind = Static_Primary; -- Add Value to the list of values for the key Key, with the metadata Md procedure Remove (Self : Lexical_Env; Key : Symbol_Type; Value : Node_Type) with Pre => Self.Kind = Static_Primary; -- Remove Value from the list of values for the key Key. This does nothing -- if Self is the empty environment. procedure Reference (Self : Lexical_Env; Referenced_From : Node_Type; Resolver : Lexical_Env_Resolver; Kind : Ref_Kind := Normal; Categories : Ref_Categories := All_Cats; Rebindings_Assoc : Boolean := False) with Pre => Self.Kind = Static_Primary; -- Add a dynamic reference from Self to the lexical environment computed -- calling Resolver on Referenced_From. This makes the content of this -- dynamic environment accessible when performing lookups on Self (see the -- Get function). -- -- Unless the reference is transitive, requests with an origin point (From -- parameter), the content will only be visible if: -- -- * Can_Reach (Referenced_From, From) is True. Practically this means -- that the origin point of the request needs to be *after* -- Referenced_From in the file. -- -- If ``Rebindings_Assoc`` is True, then the referenced env will be -- considered just as Self when shedding rebindings. procedure Reference (Self : Lexical_Env; To_Reference : Lexical_Env; Kind : Ref_Kind := Normal; Categories : Ref_Categories := All_Cats; Rebindings_Assoc : Boolean := False) with Pre => Self.Kind = Static_Primary; -- Add a static reference from Self to To_Reference. See above for the -- meaning of arguments. procedure Deactivate_Referenced_Envs (Self : Lexical_Env) with Pre => Self.Kind = Static_Primary; -- Invalidate caches in Self. This: -- -- * invalidates the environment lookup cache; -- * invalidates the cached parent environment link (if the parent link -- is dynamic); -- * deactivate referenced environments. procedure Recompute_Referenced_Envs (Self : Lexical_Env) with Pre => Self.Kind = Static_Primary; -- Recompute the referenced environments for this environment. In other -- words, re-resolve the R.Getter for all referenced environments R in -- Self. -- -- Before calling this, one must call Deactivate_Referenced_Envs on every -- referenced environment reachable from Self: referenced environments in -- Self, but also referenced environments in Self's parents. procedure Reset_Caches (Self : Lexical_Env) with Pre => Self.Kind = Static_Primary; --- Reset the caches for this env function Get (Self : Lexical_Env; Key : Symbol_Type; From : Node_Type := No_Node; Lookup_Kind : Lookup_Kind_Type := Recursive; Categories : Ref_Categories := All_Cats) return Entity_Vectors.Vector; -- Get the array of entities for this Key. If From is given, then nodes -- will be filtered according to the Can_Reach primitive given as parameter -- for the generic package. -- -- If Recursive, look for Key in all Self's parents as well, and in -- referenced envs. Otherwise, limit the search to Self. -- -- If Filter is not null, use it as a filter to disable lookup on envs for -- which Filter.all (From, Env) returns False. -- -- If ``Key`` is null, return every entity in the scope regardless of name. function Get (Self : Lexical_Env; Key : Symbol_Type; From : Node_Type := No_Node; Lookup_Kind : Lookup_Kind_Type := Recursive; Categories : Ref_Categories := All_Cats) return Entity_Array; function Get_First (Self : Lexical_Env; Key : Symbol_Type; From : Node_Type := No_Node; Lookup_Kind : Lookup_Kind_Type := Recursive; Categories : Ref_Categories := All_Cats) return Entity; -- Like Get, but return only the first matching entity. Return a null -- entity if no entity is found. function Orphan (Self : Lexical_Env) return Lexical_Env; -- Return a dynamically allocated copy of Self that has no parent. If Self -- is a grouped environment or if it has any transitive parent, this raises -- a property error. function Parent (Self : Lexical_Env) return Lexical_Env; -- Return the parent lexical env for env Self or Empty_Env if Self has no -- parent. function Env_Node (Self : Lexical_Env) return Node_Type; -- Return the node associated to Self, if any function Group (Envs : Lexical_Env_Array; With_Md : Node_Metadata := Empty_Metadata) return Lexical_Env; -- Return a lexical environment that logically groups together multiple -- lexical environments. Note that this does not modify the input -- environments, however it returns a new owning reference. -- -- If this array is empty, Empty_Env is returned. Note that if Envs'Length -- is greater than 1, the result is dynamically allocated. -- -- If With_Md is passed, the resulting env will have the passed metadata -- instance as default metadata. As a result, any node returned will have -- its metadata combined with the default metadata. function Rebind_Env (Base_Env : Lexical_Env; E_Info : Entity_Info) return Lexical_Env; function Rebind_Env (Base_Env : Lexical_Env; Rebindings : Env_Rebindings) return Lexical_Env; -- Return a new env based on Base_Env to include the given Rebindings procedure Inc_Ref (Self : Lexical_Env); -- If Self is a ref-counted lexical env, increment this reference count. Do -- nothing otherwise. procedure Dec_Ref (Self : in out Lexical_Env); -- If Self is a ref-counted lexical env, decrement this reference count and -- set it to null. Also destroy it if the count drops to 0. Do nothing -- otherwise. function Shed_Rebindings (E_Info : Entity_Info; Env : Lexical_Env) return Entity_Info; -- Return a new entity info from E_Info, shedding env rebindings that are -- not in the parent chain for the env From_Env. function Equivalent (Left, Right : Lexical_Env) return Boolean; -- Return whether L and R are equivalent lexical environments: same -- envs topology, same internal map, etc. --------------------------------------- -- Lexical environment lookup caches -- --------------------------------------- type Lookup_Result_Item is record E : Entity; -- Returned entity Filter_From : Boolean; -- Whether to filter with Can_Reach Override_Filter_Node : Node_Type := No_Node; -- Node to use when filtering with Can_Reach, if different from the -- Entity. end record; -- Lexical environment lookup result item. Lookups return arrays of these. package Lookup_Result_Item_Vectors is new Langkit_Support.Vectors (Lookup_Result_Item, Small_Vector_Capacity => 2); subtype Lookup_Result_Vector is Lookup_Result_Item_Vectors.Vector; Empty_Lookup_Result_Vector : Lookup_Result_Vector renames Lookup_Result_Item_Vectors.Empty_Vector; subtype Lookup_Result_Array is Lookup_Result_Item_Vectors.Elements_Array; Empty_Lookup_Result_Array : Lookup_Result_Array renames Lookup_Result_Item_Vectors.Empty_Array; type Lookup_Cache_Key is record Symbol : Symbol_Type; -- Symbol for this lookup Rebindings : Env_Rebindings; -- Rebindings used for this lookup Metadata : Node_Metadata; -- Metadata used for this lookup Categories : Ref_Categories := All_Cats; end record; -- Key in environment lookup caches. Basically the parameters for the Get -- functiont that are relevant for caching. type Lookup_Cache_Entry_State is (Computing, Computed, None); -- Status of an entry in lexical environment lookup caches. -- -- Computing represents the dummy entry that is inserted during original -- computation. That means that a cache hit that returns a Computing entry -- reveals an infinite recursion (a lexical environment lookup that calls -- itself recursively). -- -- Computed represents an entry whose elements are fine to be used as a -- cache hit. -- -- None represents a cleared cache entry, i.e. getting it out of a cache -- means there's a cache miss. Using this state instead of just removing -- the cache is used to avoid destroying the cache map when clearing -- caches. type Lookup_Cache_Entry is record State : Lookup_Cache_Entry_State; Elements : Lookup_Result_Item_Vectors.Vector; end record; -- Result of a lexical environment lookup No_Lookup_Cache_Entry : constant Lookup_Cache_Entry := (None, Empty_Lookup_Result_Vector); function Hash (Self : Lookup_Cache_Key) return Hash_Type is (Combine (Combine (Hash (Self.Symbol), Hash (Self.Rebindings)), Metadata_Hash (Self.Metadata))); package Lookup_Cache_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Lookup_Cache_Key, Element_Type => Lookup_Cache_Entry, Hash => Hash, Equivalent_Keys => "=", "=" => "="); ---------------------------------------- -- Lexical environment representation -- ---------------------------------------- package Lexical_Env_Vectors is new Langkit_Support.Vectors (Lexical_Env); type Internal_Map_Node is record Node : Node_Type; -- If Resolver is null, this is the node that lexical env lookup must -- return. Otherwise, it is the argument to pass to Resolver in order to -- get the result. Md : Node_Metadata; -- Metadata associated to Node Resolver : Entity_Resolver; end record; package Internal_Map_Node_Vectors is new Langkit_Support.Vectors (Internal_Map_Node); subtype Internal_Map_Node_Array is Internal_Map_Node_Vectors.Elements_Array; package Internal_Map_Node_Maps is new Ada.Containers.Ordered_Maps (Key_Type => Node_Type, Element_Type => Internal_Map_Node); type Internal_Map_Node_Map is access all Internal_Map_Node_Maps.Map; type Internal_Map_Element is record Native_Nodes : Internal_Map_Node_Vectors.Vector; -- List of node that belong to the same unit as the lexical env that -- owns the map. Foreign_Nodes : Internal_Map_Node_Map := null; -- List of nodes that belong to other units (as keys), and associated -- metadata/resolvers when applicable (as values). Nodes are sorted by -- unit filename/sloc range to preserve determinism. -- -- NOTE: The list is null if there is no foreign node. end record; -- Set of nodes associated to a symbol in a lexical environment Empty_Internal_Map_Element : constant Internal_Map_Element := (others => <>); package Internal_Envs is new Ada.Containers.Hashed_Maps (Key_Type => Symbol_Type, Element_Type => Internal_Map_Element, Hash => Hash, Equivalent_Keys => "="); type Internal_Map is access all Internal_Envs.Map; -- Internal maps of Symbols to vectors of nodes procedure Destroy is new Ada.Unchecked_Deallocation (Internal_Envs.Map, Internal_Map); type Lexical_Env_Array_Access is access all Lexical_Env_Array; procedure Destroy is new Ada.Unchecked_Deallocation (Lexical_Env_Array, Lexical_Env_Array_Access); type Lexical_Env_Record (Kind : Lexical_Env_Kind) is new Base_Lexical_Env_Record with record case Kind is when Primary_Kind => Parent : Lexical_Env := Null_Lexical_Env; -- Parent environment for this env. Null by default. Transitive_Parent : Boolean := False; -- Whether the parent link is transitive or not Node : Node_Type := No_Node; -- Node for which this environment was created Rebindings_Pool : Env_Rebindings_Pool := null; -- Cache for all parent-less env rebindings whose Old_Env is the -- lexical environment that owns this pool. As a consequence, this -- is allocated only for primary lexical environments that are -- rebindable. case Kind is when Static_Primary => Lookup_Cache : Lookup_Cache_Maps.Map; -- Cache for lexical environment lookups Lookup_Cache_Valid : Boolean := True; -- Whether Cached_Results contains lookup results that can -- be currently reused (i.e. whether they are not stale). Referenced_Envs : Referenced_Envs_Vectors.Vector; -- A list of environments referenced by this environment Rebindings_Assoc_Ref_Env : Integer := -1; -- If present, index to the Referenced_Envs vector that -- points to an environment we want to look at when shedding -- rebindings. If the referenced env is not none, it will be -- considered in place of Self when shedding rebindings. Map : Internal_Map := null; -- Map containing mappings from symbols to nodes for this -- env instance. If the lexical env is refcounted, then it -- does not own this env. when Dynamic_Primary => Assocs_Getter : Inner_Env_Assocs_Resolver; -- Callback to query environment associations Assoc_Resolver : Entity_Resolver; -- Callback to resolve returned entities when others => null; -- Unreachable end case; when others => Ref_Count : Integer := 1; -- Number of owners. It is initially set to 1. When it drops to 0, -- the env can be destroyed. case Kind is when Primary_Kind => null; -- Unreachable when Orphaned => Orphaned_Env : Lexical_Env; -- Lexical environment that is orphaned when Grouped => Grouped_Envs : Lexical_Env_Array_Access; -- Array of lexical environment that are grouped together Default_Md : Node_Metadata := Empty_Metadata; -- Default metadata to use for lookups when Rebound => Rebound_Env : Lexical_Env; -- Lexical environment that is rebound Rebindings : Env_Rebindings; -- Rebindings for this rebound environment Rebindings_Version : Version_Number; -- Version of Rebindings at the time of creation of this -- rebound env. This is used to determine if the rebindings -- has become stale. end case; end case; end record; function Wrap (Env : Lexical_Env_Access; Owner : Generic_Unit_Ptr := No_Generic_Unit) return Lexical_Env; function Wrap is new Ada.Unchecked_Conversion (Lexical_Env_Access, Generic_Lexical_Env_Ptr); function Unwrap is new Ada.Unchecked_Conversion (Generic_Lexical_Env_Ptr, Lexical_Env_Access); function Unwrap (Self : Lexical_Env) return Lexical_Env_Access is (Unwrap (Self.Env)); procedure Destroy (Self : in out Lexical_Env); -- Deallocate the resources allocated to the Self lexical environment. Must -- not be used directly for ref-counted envs. function Is_Foreign (Self : Lexical_Env; Node : Node_Type) return Boolean is (Unwrap (Self).Node = No_Node or else Node_Unit (Unwrap (Self).Node) /= Node_Unit (Node)) with Pre => Self.Kind in Primary_Kind; -- Return whether Node is a foreign node relative to Self (i.e. whether -- they both belong to different units). This is true even for the empty -- env and the root one, which are not tied to any unit. function Is_Foreign_Not_Empty (Self : Lexical_Env; Node : Node_Type) return Boolean is (Self /= Empty_Env and then Is_Foreign (Self, Node)); -- Same as Is_Foreign, but return False for the empty env function Is_Foreign_Strict (Self : Lexical_Env; Node : Node_Type) return Boolean is (Unwrap (Self).Node /= No_Node and then Is_Foreign (Self, Node)); -- Same as Is_Foreign, but return False for the empty and root envs ------------------- -- Debug helpers -- ------------------- function Lexical_Env_Image (Self : Lexical_Env; Env_Id : String := ""; Parent_Env_Id : String := ""; Dump_Addresses : Boolean := False; Dump_Content : Boolean := True; Prefix : String := ""; Short_Node : Boolean := False) return String; -- Return a textual representation of Self. -- -- If provided, Env_Id and Parent_Env_Id are used to designate Self and its -- parent environment. -- -- If Dump_Addresses, include the hexadecimal address of each represented -- lexical environment. -- -- If Dump_Content, show the inner data in lexical environments: referenced -- environments and internal map for primary environments, pointed -- environment in orphaned environments, etc. If Dump_Content is true, the -- result is a multi-line string, otherwise it's guaranteed to fit on a -- single line. -- -- Prefix is used to prefix each emitted line. function Env_Image (Self : Lexical_Env) return String is (Lexical_Env_Image (Self, Dump_Content => False, Short_Node => True)); function Lexical_Env_Parent_Chain (Self : Lexical_Env) return String; procedure Dump_One_Lexical_Env (Self : Lexical_Env; Env_Id : String := ""; Parent_Env_Id : String := ""; Dump_Addresses : Boolean := False; Dump_Content : Boolean := True); procedure Dump_Lexical_Env_Parent_Chain (Self : Lexical_Env); private function Hash (Env : Lexical_Env_Access) return Hash_Type; Empty_Env_Map : aliased Internal_Envs.Map := Internal_Envs.Empty_Map; Empty_Env_Record : aliased Lexical_Env_Record := (Kind => Static_Primary, Parent => Null_Lexical_Env, Transitive_Parent => False, Node => No_Node, Referenced_Envs => <>, Map => Empty_Env_Map'Access, Rebindings_Pool => null, Lookup_Cache_Valid => False, Lookup_Cache => Lookup_Cache_Maps.Empty_Map, Rebindings_Assoc_Ref_Env => -1); -- Because of circular elaboration issues, we cannot call Hash here to -- compute the real hash. Using a dummy precomputed one is probably enough. Empty_Env : constant Lexical_Env := (Env => Empty_Env_Record'Access, Hash => 0, Kind => Static_Primary, Owner => No_Generic_Unit, Version => 0); end Langkit_Support.Lexical_Envs_Impl;
AdaCore/libadalang
Ada
128
adb
package body Pkg is procedure Dummy is null; begin #if FOO'Defined then null; #else invalid code #end if; end Pkg;
charlie5/aIDE
Ada
1,347
ads
with AdaM.a_Type.record_type, AdaM.subtype_Indication, Ada.Streams; package AdaM.a_Type.derived_type is type Item is new a_Type.record_type.item with private; type View is access all Item'Class; -- Forge -- function new_Type (Name : in String := "") return derived_type.view; overriding procedure destruct (Self : in out Item); procedure free (Self : in out derived_type.view); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; function parent_Subtype (Self : in Item) return subtype_Indication.view; procedure parent_Subtype_is (Self : out Item; Now : in subtype_Indication.view); private type Item is new a_Type.record_type.item with record is_Abstract : Boolean := False; is_Limited : Boolean := False; parent_Subtype : subtype_Indication.view; end record; -- Streams -- 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; end AdaM.a_Type.derived_type;
reznikmm/matreshka
Ada
3,719
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Image_Align_Attributes is pragma Preelaborate; type ODF_Form_Image_Align_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Image_Align_Attribute_Access is access all ODF_Form_Image_Align_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Image_Align_Attributes;
AdaCore/Ada_Drivers_Library
Ada
1,874
ads
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.CRC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype IDR_IDR_Field is HAL.UInt8; -- Independent Data register type IDR_Register is record -- Independent Data register IDR : IDR_IDR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IDR_Register use record IDR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Control register type CR_Register is record -- Write-only. Control regidter CR : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record CR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cyclic Redundancy Check (CRC) unit type CRC_Peripheral is record -- Data register DR : aliased HAL.UInt32; -- Independent Data register IDR : aliased IDR_Register; -- Control register CR : aliased CR_Register; 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; end record; -- Cyclic Redundancy Check (CRC) unit CRC_Periph : aliased CRC_Peripheral with Import, Address => System'To_Address (16#40023000#); end STM32_SVD.CRC;
zenharris/ada-bbs
Ada
808
ads
with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; With Ada.Text_IO.Unbounded_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Text_IO; use Ada.Text_IO; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Texaco; use Texaco; with Display_Warning; package Message.Post is package SU renames Ada.Strings.Unbounded; procedure Quote (Msgid : Unbounded_String); function Pad (InStr : String;PadWdth : Integer) return String; function Generate_UID return Unbounded_String; procedure Post_Message (ReplyID : in Unbounded_String := To_Unbounded_String(""); ReplySubject : in Unbounded_String := To_Unbounded_String("")); end Message.Post;
SietsevanderMolen/fly-thing
Ada
738
ads
generic type Real is digits <>; package Quaternions is type Quaternion is record A, B, C, D : Real; end record; function "abs" (Left : Quaternion) return Real; function Conj (Left : Quaternion) return Quaternion; function "-" (Left : Quaternion) return Quaternion; function "+" (Left, Right : Quaternion) return Quaternion; function "-" (Left, Right : Quaternion) return Quaternion; function "*" (Left : Quaternion; Right : Real) return Quaternion; function "*" (Left : Real; Right : Quaternion) return Quaternion; function "*" (Left, Right : Quaternion) return Quaternion; function Normalize (Q : Quaternion) return Quaternion; function Image (Left : Quaternion) return String; end Quaternions;
albertklee/SPARKZumo
Ada
684
adb
pragma SPARK_Mode; with Interfaces.C; use Interfaces.C; with Sparkduino; use Sparkduino; package body Pwm is Pwm_Resolution : constant := 8; procedure Configure_Timers is begin null; end Configure_Timers; procedure SetRate (Index : Pwm_Index; Value : Word) is Scaled : unsigned; begin Scaled := (unsigned (Value) * ((2 ** Pwm_Resolution) - 1)) / PWM_Max; case Index is when Left => AnalogWrite (Pin => 10, Val => Scaled); when Right => AnalogWrite (Pin => 9, Val => Scaled); end case; end SetRate; end Pwm;
zhmu/ananas
Ada
181
ads
generic type T is private; package Generic_Inst12_Pkg1 is generic procedure Inner_G (Val : T); procedure Proc (Val : T); pragma Inline (Proc); end Generic_Inst12_Pkg1;
reznikmm/matreshka
Ada
3,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Draw_Style_Attributes is pragma Preelaborate; type ODF_Draw_Style_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Style_Attribute_Access is access all ODF_Draw_Style_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Style_Attributes;
flyx/OpenGLAda
Ada
16,373
ads
-- -- Copyright (c) 2002-2003, David Holm -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are -- met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, -- this list of conditions and the following disclaimer in the -- documentation -- and/or other materials provided with the distribution. -- * The names of its contributors may not be used to endorse or promote -- products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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; -- 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 Interfaces.C; with System; package GL.WGL is pragma Preelaborate; WGL_FONT_LINES : constant := 8#0000#; WGL_FONT_POLYGONS : constant := 1; WGL_SWAP_MAIN_PLANE : constant := 1; WGL_SWAP_OVERLAY1 : constant := 2; WGL_SWAP_OVERLAY2 : constant := 4; WGL_SWAP_OVERLAY3 : constant := 8; WGL_SWAP_OVERLAY4 : constant := 16#0010#; WGL_SWAP_OVERLAY5 : constant := 16#0020#; WGL_SWAP_OVERLAY6 : constant := 16#0040#; WGL_SWAP_OVERLAY7 : constant := 16#0080#; WGL_SWAP_OVERLAY8 : constant := 16#0100#; WGL_SWAP_OVERLAY9 : constant := 16#0200#; WGL_SWAP_OVERLAY10 : constant := 16#0400#; WGL_SWAP_OVERLAY11 : constant := 16#0800#; WGL_SWAP_OVERLAY12 : constant := 16#1000#; WGL_SWAP_OVERLAY13 : constant := 16#2000#; WGL_SWAP_OVERLAY14 : constant := 16#4000#; WGL_SWAP_OVERLAY15 : constant := 16#8000#; WGL_SWAP_UNDERLAY1 : constant := 16#0001_0000#; WGL_SWAP_UNDERLAY2 : constant := 16#0002_0000#; WGL_SWAP_UNDERLAY3 : constant := 16#0004_0000#; WGL_SWAP_UNDERLAY4 : constant := 16#0008_0000#; WGL_SWAP_UNDERLAY5 : constant := 16#0010_0000#; WGL_SWAP_UNDERLAY6 : constant := 16#0020_0000#; WGL_SWAP_UNDERLAY7 : constant := 16#0040_0000#; WGL_SWAP_UNDERLAY8 : constant := 16#0080_0000#; WGL_SWAP_UNDERLAY9 : constant := 16#0100_0000#; WGL_SWAP_UNDERLAY10 : constant := 16#0200_0000#; WGL_SWAP_UNDERLAY11 : constant := 16#0400_0000#; WGL_SWAP_UNDERLAY12 : constant := 16#0800_0000#; WGL_SWAP_UNDERLAY13 : constant := 16#1000_0000#; WGL_SWAP_UNDERLAY14 : constant := 16#2000_0000#; WGL_SWAP_UNDERLAY15 : constant := 16#4000_0000#; type Pixel_Format_Descriptor is record nSize : Interfaces.C.short; nVersion : Interfaces.C.short; dwFlags : Interfaces.C.long; iPixelType : Interfaces.C.char; cColorBits : Interfaces.C.char; cRedBits : Interfaces.C.char; cRedShift : Interfaces.C.char; cGreenBits : Interfaces.C.char; cGreenShift : Interfaces.C.char; cBlueBits : Interfaces.C.char; cBlueShift : Interfaces.C.char; cAlphaBits : Interfaces.C.char; cAlphaShift : Interfaces.C.char; cAccumBits : Interfaces.C.char; cAccumRedBits : Interfaces.C.char; cAccumGreenBits : Interfaces.C.char; cAccumBlueBits : Interfaces.C.char; cAccumAlphaBits : Interfaces.C.char; cDepthBits : Interfaces.C.char; cStencilBits : Interfaces.C.char; cAuxBuffers : Interfaces.C.char; iLayerType : Interfaces.C.char; bReserved : Interfaces.C.char; dwLayerMask : Interfaces.C.long; dwVisibleMask : Interfaces.C.long; dwDamageMask : Interfaces.C.long; end record; pragma Convention (C_Pass_By_Copy, Pixel_Format_Descriptor); type Point_Float is record x : Interfaces.C.C_float; y : Interfaces.C.C_float; end record; pragma Convention (C_Pass_By_Copy, Point_Float); type Glyph_Metrics_Float is record gmfBlackBoxX : Interfaces.C.C_float; gmfBlackBoxY : Interfaces.C.C_float; gmfptGlyphOrigin : Point_Float; gmfCellIncX : Interfaces.C.C_float; gmfCellIncY : Interfaces.C.C_float; end record; pragma Convention (C_Pass_By_Copy, Glyph_Metrics_Float); type COLORREF is new Interfaces.C.long; type COLORREF_Type is access all COLORREF; type Layer_Plane_Descriptor is record nSize : Interfaces.C.short; nVersion : Interfaces.C.short; dwFlags : Interfaces.C.long; iPixelType : Interfaces.C.char; cColorBits : Interfaces.C.char; cRedBits : Interfaces.C.char; cRedShift : Interfaces.C.char; cGreenBits : Interfaces.C.char; cGreenShift : Interfaces.C.char; cBlueBits : Interfaces.C.char; cBlueShift : Interfaces.C.char; cAlphaBits : Interfaces.C.char; cAlphaShift : Interfaces.C.char; cAccumBits : Interfaces.C.char; cAccumRedBits : Interfaces.C.char; cAccumGreenBits : Interfaces.C.char; cAccumBlueBits : Interfaces.C.char; cAccumAlphaBits : Interfaces.C.char; cDepthBits : Interfaces.C.char; cStencilBits : Interfaces.C.char; cAuxBuffers : Interfaces.C.char; iLayerPlane : Interfaces.C.char; bReserved : Interfaces.C.char; crTransparent : COLORREF; end record; pragma Convention (C_Pass_By_Copy, Layer_Plane_Descriptor); type Layer_Plane_Descriptor_Type is access all Layer_Plane_Descriptor; type Glyph_Metrics_Float_Type is access all Glyph_Metrics_Float; type Pixel_Format_Descriptor_Type is access all Pixel_Format_Descriptor; type HANDLE is new System.Address; subtype HDC is HANDLE; subtype HGLRC is HANDLE; function wglDeleteContext (Rendering_Context : HGLRC) return Interfaces.C.int; function wglMakeCurrent (Device_Context : HDC; Rendering_Context : HGLRC) return Interfaces.C.int; function wglSetPixelFormat (Device_Context : HDC; Pixel_Format : Interfaces.C.int; Pixel_Format_Desc : access Pixel_Format_Descriptor_Type) return Interfaces.C.int; function wglSwapBuffers (Device_Context : HDC) return Interfaces.C.int; function wglGetCurrentDC return HANDLE; function wglCreateContext (Device_Context : HDC) return HANDLE; function wglCreateLayerContext (Device_Context : HDC; Layer_Plane : Interfaces.C.int) return HANDLE; function wglGetCurrentContext return HANDLE; function wglGetProcAddress (Proc_Desc : Interfaces.C.char_array) return System.Address; function wglChoosePixelFormat (Device_Context : HDC; Pixel_Format_Desc : access Pixel_Format_Descriptor_Type) return Interfaces.C.int; function wglCopyContext (Rendering_Context_Source : HGLRC; Rendering_Context_Dest : HGLRC; Mask : Interfaces.C.unsigned) return Interfaces.C.int; function wglDescribeLayerPlane (Device_Context : HDC; Pixel_Format : Interfaces.C.int; Layer_Plane : Interfaces.C.int; Bytes : Interfaces.C.unsigned; Plane_Desc : Layer_Plane_Descriptor_Type) return Interfaces.C.int; function wglDescribePixelFormat (Device_Context : HDC; Layer_Plane : Interfaces.C.int; Bytes : Interfaces.C.unsigned; Pixel_Format_Desc : Pixel_Format_Descriptor_Type) return Interfaces.C.int; function wglGetLayerPaletteEntries (Device_Context : HDC; Layer_Plane : Interfaces.C.int; Start : Interfaces.C.int; Entries : Interfaces.C.int; Color_Ref : access Interfaces.C.long) return Interfaces.C.int; function wglGetPixelFormat (Device_Context : HDC) return Interfaces.C.int; function wglRealizeLayerPalette (Device_Context : HDC; Layer_Plane : Interfaces.C.int; Realize : Boolean) return Interfaces.C.int; function wglSetLayerPaletteEntries (Device_Context : HDC; Layer_Plane : Interfaces.C.int; Start : Interfaces.C.int; Entries : Interfaces.C.int; Color_Reference : COLORREF_Type) return Interfaces.C.int; function wglShareLists (Existing_Rendering_Context : HGLRC; New_Rendering_Context : HGLRC) return Interfaces.C.int; function wglSwapLayerBuffers (Device_Context : HDC; Planes : Interfaces.C.unsigned) return Interfaces.C.int; function wglUseFontBitmapsA (Device_Context : HDC; First : Interfaces.C.unsigned; Count : Interfaces.C.unsigned; List_Base : Interfaces.C.unsigned) return Interfaces.C.int; function wglUseFontBitmapsW (Device_Context : HDC; First : Interfaces.C.unsigned; Count : Interfaces.C.unsigned; List_Base : Interfaces.C.unsigned) return Interfaces.C.int; function wglUseFontOutlinesA (Device_Context : HDC; First : Interfaces.C.unsigned; Count : Interfaces.C.unsigned; List_Base : Interfaces.C.unsigned; Deviation : Interfaces.C.C_float; Extrusion : Interfaces.C.C_float; Format : Interfaces.C.int; Glyph_Data_Buffer : Glyph_Metrics_Float_Type) return Interfaces.C.int; function wglUseFontOutlinesW (Device_Context : HDC; First : Interfaces.C.unsigned; Count : Interfaces.C.unsigned; List_Base : Interfaces.C.unsigned; Deviation : Interfaces.C.C_float; Extrusion : Interfaces.C.C_float; Format : Interfaces.C.int; Glyph_Data_Buffer : Glyph_Metrics_Float_Type) return Interfaces.C.int; function SwapBuffers (Device_Context : HDC) return Interfaces.C.int; function ChoosePixelFormat (Device_Context : HDC; Pixel_Format_Desc : access Pixel_Format_Descriptor_Type) return Interfaces.C.int; function DescribePixelFormat (Device_Context : HDC; Pixel_Format : Interfaces.C.int; Bytes : Interfaces.C.unsigned; Pixel_Format_Desc : Pixel_Format_Descriptor_Type) return Interfaces.C.int; function GetPixelFormat (Device_Context : HDC) return Interfaces.C.int; function SetPixelFormat (Device_Context : HDC; Pixel_Format : Interfaces.C.int; Pixel_Format_Desc : access Pixel_Format_Descriptor_Type) return Interfaces.C.int; private pragma Import (StdCall, wglDeleteContext, "wglDeleteContext"); pragma Import (StdCall, wglMakeCurrent, "wglMakeCurrent"); pragma Import (StdCall, wglSetPixelFormat, "wglSetPixelFormat"); pragma Import (StdCall, wglSwapBuffers, "wglSwapBuffers"); pragma Import (StdCall, wglGetCurrentDC, "wglGetCurrentDC"); pragma Import (StdCall, wglCreateContext, "wglCreateContext"); pragma Import (StdCall, wglCreateLayerContext, "wglCreateLayerContext"); pragma Import (StdCall, wglGetCurrentContext, "wglGetCurrentContext"); pragma Import (StdCall, wglGetProcAddress, "wglGetProcAddress"); pragma Import (StdCall, wglChoosePixelFormat, "wglChoosePixelFormat"); pragma Import (StdCall, wglCopyContext, "wglCopyContext"); pragma Import (StdCall, wglDescribeLayerPlane, "wglDescribeLayerPlane"); pragma Import (StdCall, wglDescribePixelFormat, "wglDescribePixelFormat"); pragma Import (StdCall, wglGetLayerPaletteEntries, "wglGetLayerPaletteEntries"); pragma Import (StdCall, wglGetPixelFormat, "wglGetPixelFormat"); pragma Import (StdCall, wglRealizeLayerPalette, "wglRealizeLayerPalette"); pragma Import (StdCall, wglSetLayerPaletteEntries, "wglSetLayerPaletteEntries"); pragma Import (StdCall, wglShareLists, "wglShareLists"); pragma Import (StdCall, wglSwapLayerBuffers, "wglSwapLayerBuffers"); pragma Import (StdCall, wglUseFontBitmapsA, "wglUseFontBitmapsA"); pragma Import (StdCall, wglUseFontBitmapsW, "wglUseFontBitmapsW"); pragma Import (StdCall, wglUseFontOutlinesA, "wglUseFontOutlinesA"); pragma Import (StdCall, wglUseFontOutlinesW, "wglUseFontOutlinesW"); pragma Import (StdCall, SwapBuffers, "SwapBuffers"); pragma Import (StdCall, ChoosePixelFormat, "ChoosePixelFormat"); pragma Import (StdCall, DescribePixelFormat, "DescribePixelFormat"); pragma Import (StdCall, GetPixelFormat, "GetPixelFormat"); pragma Import (StdCall, SetPixelFormat, "SetPixelFormat"); end GL.WGL;
persan/A-gst
Ada
3,153
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideocodec_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; with glib; with glib.Values; with System; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideoutils_h is -- GStreamer -- * Copyright (C) 2008 David Schleef <[email protected]> -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- function gst_base_video_rawvideo_convert (state : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideocodec_h.GstVideoState; src_format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat; src_value : GLIB.gint64; dest_format : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat; dest_value : access GLIB.gint64) return GLIB.gboolean; -- gst/video/gstbasevideoutils.h:34 pragma Import (C, gst_base_video_rawvideo_convert, "gst_base_video_rawvideo_convert"); function gst_base_video_encoded_video_convert (state : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideocodec_h.GstVideoState; bytes : GLIB.gint64; time : GLIB.gint64; src_format : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat; src_value : GLIB.gint64; dest_format : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstformat_h.GstFormat; dest_value : access GLIB.gint64) return GLIB.gboolean; -- gst/video/gstbasevideoutils.h:37 pragma Import (C, gst_base_video_encoded_video_convert, "gst_base_video_encoded_video_convert"); function gst_video_state_get_timestamp (state : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideocodec_h.GstVideoState; segment : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment; frame_number : int) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime; -- gst/video/gstbasevideoutils.h:41 pragma Import (C, gst_video_state_get_timestamp, "gst_video_state_get_timestamp"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_video_gstbasevideoutils_h;
stcarrez/ada-security
Ada
4,354
ads
----------------------------------------------------------------------- -- security-openid -- OpenID 2.0 Support -- Copyright (C) 2009, 2010, 2011, 2012, 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. ----------------------------------------------------------------------- -- == OpenID Configuration == -- The Open ID provider needs the following configuration parameters: -- -- openid.realm The OpenID realm parameter passed in the authentication URL. -- openid.callback_url The OpenID return_to parameter. -- private package Security.Auth.OpenID is -- ------------------------------ -- OpenID Manager -- ------------------------------ -- The <b>Manager</b> provides the core operations for the OpenID process. type Manager is new Security.Auth.Manager with private; -- Initialize the OpenID authentication realm. Get the <tt>openid.realm</tt> -- and <tt>openid.callback_url</tt> parameters to configure the realm. overriding procedure Initialize (Realm : in out Manager; Params : in Parameters'Class; Name : in String := PROVIDER_OPENID); -- Discover the OpenID provider that must be used to authenticate the user. -- The <b>Name</b> can be an URL or an alias that identifies the provider. -- A cached OpenID provider can be returned. -- Read the XRDS document from the URI and initialize the OpenID provider end point. -- (See OpenID Section 7.3 Discovery) overriding procedure Discover (Realm : in out Manager; Name : in String; Result : out End_Point); -- Associate the application (relying party) with the OpenID provider. -- The association can be cached. -- (See OpenID Section 8 Establishing Associations) overriding procedure Associate (Realm : in out Manager; OP : in End_Point; Result : out Association); -- Get the authentication URL to which the user must be redirected for authentication -- by the authentication server. overriding function Get_Authentication_URL (Realm : in Manager; OP : in End_Point; Assoc : in Association) return String; -- Verify the authentication result overriding procedure Verify (Realm : in out Manager; Assoc : in Association; Request : in Parameters'Class; Result : out Authentication); -- Verify the authentication result procedure Verify_Discovered (Realm : in out Manager; Assoc : in Association; Request : in Parameters'Class; Result : out Authentication); -- Verify the signature part of the result procedure Verify_Signature (Realm : in Manager; Assoc : in Association; Request : in Parameters'Class; Result : in out Authentication); -- Extract from the XRDS content the OpenID provider URI. -- The default implementation is very basic as it returns the first <URI> -- available in the stream without validating the XRDS document. -- Raises the <b>Invalid_End_Point</b> exception if the URI cannot be found. procedure Extract_XRDS (Realm : in out Manager; Content : in String; Result : out End_Point); private type Manager is new Security.Auth.Manager with record Return_To : Unbounded_String; Realm : Unbounded_String; end record; end Security.Auth.OpenID;
Fabien-Chouteau/lvgl-ada
Ada
4,681
ads
with Lv.Hal.Indev; with Lv.Objx; with Lv.Area; with Lv.Group; package Lv.Indev is -- Initialize the display input device subsystem procedure Init; -- Get the currently processed input device. Can be used in action functions too. -- @return pointer to the currently processed input device or NULL if no input device processing right now function Get_Act return Lv.Hal.Indev.Indev_T; -- Get the type of an input device -- @param indev pointer to an input device -- @return the type of the input device from `lv_hal_indev_type_t` (`LV_INDEV_TYPE_...`) function Get_Type (Indev : Lv.Hal.Indev.Indev_T) return Lv.Hal.Indev.Indev_Type_T; -- Reset one or all input devices -- @param indev pointer to an input device to reset or NULL to reset all of them procedure Reset (Indev : Lv.Hal.Indev.Indev_T); -- Reset the long press state of an input device -- @param indev_proc pointer to an input device procedure Reset_Lpr (Indev_Proc : Lv.Hal.Indev.Indev_T); -- Enable input devices device by type -- @param type Input device type -- @param enable true: enable this type; false: disable this type procedure Enable (Type_P : Lv.Hal.Indev.Indev_Type_T; Enable : U_Bool); -- lv_indev.h:68 -- Set a cursor for a pointer input device (for LV_INPUT_TYPE_POINTER and LV_INPUT_TYPE_BUTTON) -- @param indev pointer to an input device -- @param cur_obj pointer to an object to be used as cursor procedure Set_Cursor (Indev : Lv.Hal.Indev.Indev_T; Cur_Obj : Lv.Objx.Obj_T); -- Set a destination group for a keypad input device (for LV_INDEV_TYPE_KEYPAD) -- @param indev pointer to an input device -- @param group point to a group procedure Set_Group (Indev : LV.HAL.Indev.Indev_T; Group : LV.Group.Instance); -- Set the an array of points for LV_INDEV_TYPE_BUTTON. -- These points will be assigned to the buttons to press a specific point on the screen -- @param indev pointer to an input device -- @param group point to a group procedure Set_Button_Points (Indev : Lv.Hal.Indev.Indev_T; Group : access Lv.Area.Point_T); -- Get the last point of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) -- @param indev pointer to an input device -- @param point pointer to a point to store the result procedure Get_Point (Indev : Lv.Hal.Indev.Indev_T; Point : access Lv.Area.Point_T); -- Get the last key of an input device (for LV_INDEV_TYPE_KEYPAD) -- @param indev pointer to an input device -- @return the last pressed key (0 on error) function Get_Key (Indev : Lv.Hal.Indev.Indev_T) return Uint32_T; -- Check if there is dragging with an input device or not (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) -- @param indev pointer to an input device -- @return true: drag is in progress function Is_Dragging (Indev: Lv.Hal.Indev.Indev_T) return U_Bool; -- Get the vector of dragging of an input device (for LV_INDEV_TYPE_POINTER and LV_INDEV_TYPE_BUTTON) -- @param indev pointer to an input device -- @param point pointer to a point to store the vector procedure Get_Vect (Indev : Lv.Hal.Indev.Indev_T; Point : access Lv.Area.Point_T); -- Get elapsed time since last press -- @param indev pointer to an input device (NULL to get the overall smallest inactivity) -- @return Elapsed ticks (milliseconds) since last press function Get_Inactive_Time (Indev : Lv.Hal.Indev.Indev_T) return Uint32_T; -- Do nothing until the next release -- @param indev pointer to an input device procedure Wait_Release (Indev : Lv.Hal.Indev.Indev_T); ------------- -- Imports -- ------------- pragma Import (C, Init, "lv_indev_init"); pragma Import (C, Get_Act, "lv_indev_get_act"); pragma Import (C, Get_Type, "lv_indev_get_type"); pragma Import (C, Reset, "lv_indev_reset"); pragma Import (C, Reset_Lpr, "lv_indev_reset_lpr"); pragma Import (C, Enable, "lv_indev_enable"); pragma Import (C, Set_Cursor, "lv_indev_set_cursor"); pragma Import (C, Set_Group, "lv_indev_set_group"); pragma Import (C, Set_Button_Points, "lv_indev_set_button_points"); pragma Import (C, Get_Point, "lv_indev_get_point"); pragma Import (C, Get_Key, "lv_indev_get_key"); pragma Import (C, Is_Dragging, "lv_indev_is_dragging"); pragma Import (C, Get_Vect, "lv_indev_get_vect"); pragma Import (C, Get_Inactive_Time, "lv_indev_get_inactive_time"); pragma Import (C, Wait_Release, "lv_indev_wait_release"); end Lv.Indev;
reznikmm/matreshka
Ada
4,623
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.Space_Before_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Space_Before_Attribute_Node is begin return Self : Text_Space_Before_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_Space_Before_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Space_Before_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Space_Before_Attribute, Text_Space_Before_Attribute_Node'Tag); end Matreshka.ODF_Text.Space_Before_Attributes;
AdaCore/gpr
Ada
2,328
ads
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2019-2023, AdaCore -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. 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 COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with GNAT.Regexp; with GPRname.Common; package GPRname.Pattern is use GNAT; use GPRname.Common; type Object is tagged private; -- We introduce this type to make for the fact that GNAT.Regexp doesn't -- give acces to the original string used to compile. function Create (Pattern : Pattern_Type) return Object'Class; -- Creates a Pattern function Pattern (Self : Object) return Pattern_Type; -- Returns the raw string used to compile Self function Regexp (Self : Object) return GNAT.Regexp.Regexp; -- Returns the compiled regex for Self private use Ada.Strings.Unbounded; type Object is tagged record Pattern : Unbounded_String; Regex : GNAT.Regexp.Regexp; end record; function Pattern (Self : Object) return Pattern_Type is (Pattern_Type (To_String (Self.Pattern))); function Regexp (Self : Object) return GNAT.Regexp.Regexp is (Self.Regex); end GPRname.Pattern;
reznikmm/matreshka
Ada
13,390
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A property is a structural feature of a classifier that characterizes -- instances of the classifier. A property related by ownedAttribute to a -- classifier (other than an association) represents an attribute and might -- also represent an association end. It relates an instance of the class to -- a value or set of values of the type of the attribute. A property related -- by memberEnd or its specializations to an association represents an end of -- the association. The type of the property is the type of the end of the -- association. ------------------------------------------------------------------------------ limited with AMF.CMOF.Associations; limited with AMF.CMOF.Classes; limited with AMF.CMOF.Classifiers.Collections; limited with AMF.CMOF.Data_Types; limited with AMF.CMOF.Properties.Collections; limited with AMF.CMOF.Redefinable_Elements; with AMF.CMOF.Structural_Features; package AMF.CMOF.Properties is pragma Preelaborate; type CMOF_Property is limited interface and AMF.CMOF.Structural_Features.CMOF_Structural_Feature; type CMOF_Property_Access is access all CMOF_Property'Class; for CMOF_Property_Access'Storage_Size use 0; not overriding function Get_Is_Read_Only (Self : not null access constant CMOF_Property) return Boolean is abstract; -- Getter of Property::isReadOnly. -- -- If isReadOnly is true, the attribute may not be written to after -- initialization. not overriding procedure Set_Is_Read_Only (Self : not null access CMOF_Property; To : Boolean) is abstract; -- Setter of Property::isReadOnly. -- -- If isReadOnly is true, the attribute may not be written to after -- initialization. not overriding function Get_Default (Self : not null access constant CMOF_Property) return AMF.Optional_String is abstract; -- Getter of Property::default. -- -- Specifies a String that represents a value to be used when no argument -- is supplied for the Property. not overriding procedure Set_Default (Self : not null access CMOF_Property; To : AMF.Optional_String) is abstract; -- Setter of Property::default. -- -- Specifies a String that represents a value to be used when no argument -- is supplied for the Property. not overriding function Get_Is_Composite (Self : not null access constant CMOF_Property) return Boolean is abstract; -- Getter of Property::isComposite. -- -- If isComposite is true, the object containing the attribute is a -- container for the object or value contained in the attribute. not overriding procedure Set_Is_Composite (Self : not null access CMOF_Property; To : Boolean) is abstract; -- Setter of Property::isComposite. -- -- If isComposite is true, the object containing the attribute is a -- container for the object or value contained in the attribute. not overriding function Get_Is_Derived (Self : not null access constant CMOF_Property) return Boolean is abstract; -- Getter of Property::isDerived. -- -- If isDerived is true, the value of the attribute is derived from -- information elsewhere. not overriding procedure Set_Is_Derived (Self : not null access CMOF_Property; To : Boolean) is abstract; -- Setter of Property::isDerived. -- -- If isDerived is true, the value of the attribute is derived from -- information elsewhere. not overriding function Get_Is_Derived_Union (Self : not null access constant CMOF_Property) return Boolean is abstract; -- Getter of Property::isDerivedUnion. -- -- Specifies whether the property is derived as the union of all of the -- properties that are constrained to subset it. not overriding procedure Set_Is_Derived_Union (Self : not null access CMOF_Property; To : Boolean) is abstract; -- Setter of Property::isDerivedUnion. -- -- Specifies whether the property is derived as the union of all of the -- properties that are constrained to subset it. not overriding function Get_Class (Self : not null access constant CMOF_Property) return AMF.CMOF.Classes.CMOF_Class_Access is abstract; -- Getter of Property::class. -- -- References the Class that owns the Property. not overriding procedure Set_Class (Self : not null access CMOF_Property; To : AMF.CMOF.Classes.CMOF_Class_Access) is abstract; -- Setter of Property::class. -- -- References the Class that owns the Property. not overriding function Get_Owning_Association (Self : not null access constant CMOF_Property) return AMF.CMOF.Associations.CMOF_Association_Access is abstract; -- Getter of Property::owningAssociation. -- -- References the owning association of this property, if any. not overriding procedure Set_Owning_Association (Self : not null access CMOF_Property; To : AMF.CMOF.Associations.CMOF_Association_Access) is abstract; -- Setter of Property::owningAssociation. -- -- References the owning association of this property, if any. not overriding function Get_Redefined_Property (Self : not null access constant CMOF_Property) return AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property is abstract; -- Getter of Property::redefinedProperty. -- -- References the properties that are redefined by this property. not overriding function Get_Subsetted_Property (Self : not null access constant CMOF_Property) return AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property is abstract; -- Getter of Property::subsettedProperty. -- -- References the properties of which this property is constrained to be a -- subset. not overriding function Get_Opposite (Self : not null access constant CMOF_Property) return AMF.CMOF.Properties.CMOF_Property_Access is abstract; -- Getter of Property::opposite. -- -- In the case where the property is one navigable end of a binary -- association with both ends navigable, this gives the other end. not overriding procedure Set_Opposite (Self : not null access CMOF_Property; To : AMF.CMOF.Properties.CMOF_Property_Access) is abstract; -- Setter of Property::opposite. -- -- In the case where the property is one navigable end of a binary -- association with both ends navigable, this gives the other end. not overriding function Get_Datatype (Self : not null access constant CMOF_Property) return AMF.CMOF.Data_Types.CMOF_Data_Type_Access is abstract; -- Getter of Property::datatype. -- -- The DataType that owns this Property. not overriding procedure Set_Datatype (Self : not null access CMOF_Property; To : AMF.CMOF.Data_Types.CMOF_Data_Type_Access) is abstract; -- Setter of Property::datatype. -- -- The DataType that owns this Property. not overriding function Get_Association (Self : not null access constant CMOF_Property) return AMF.CMOF.Associations.CMOF_Association_Access is abstract; -- Getter of Property::association. -- -- References the association of which this property is a member, if any. not overriding procedure Set_Association (Self : not null access CMOF_Property; To : AMF.CMOF.Associations.CMOF_Association_Access) is abstract; -- Setter of Property::association. -- -- References the association of which this property is a member, if any. not overriding function Opposite (Self : not null access constant CMOF_Property) return AMF.CMOF.Properties.CMOF_Property_Access is abstract; -- Operation Property::opposite. -- -- If this property is owned by a class, associated with a binary -- association, and the other end of the association is also owned by a -- class, then opposite gives the other end. overriding function Is_Consistent_With (Self : not null access constant CMOF_Property; Redefinee : AMF.CMOF.Redefinable_Elements.CMOF_Redefinable_Element_Access) return Boolean is abstract; -- Operation Property::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two Properties in a -- context in which redefinition is possible, whether redefinition would -- be logically consistent. A redefining property is consistent with a -- redefined property if the type of the redefining property conforms to -- the type of the redefined property, the multiplicity of the redefining -- property (if specified) is contained in the multiplicity of the -- redefined property, and the redefining property is derived if the -- redefined property is derived. not overriding function Subsetting_Context (Self : not null access constant CMOF_Property) return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier is abstract; -- Operation Property::subsettingContext. -- -- The query subsettingContext() gives the context for subsetting a -- property. It consists, in the case of an attribute, of the -- corresponding classifier, and in the case of an association end, all of -- the classifiers at the other ends. not overriding function Is_Navigable (Self : not null access constant CMOF_Property) return Boolean is abstract; -- Operation Property::isNavigable. -- -- The query isNavigable() indicates whether it is possible to navigate -- across the property. not overriding function Is_Attribute (Self : not null access constant CMOF_Property; P : AMF.CMOF.Properties.CMOF_Property_Access) return Boolean is abstract; -- Operation Property::isAttribute. -- -- The query isAttribute() is true if the Property is defined as an -- attribute of some classifier. end AMF.CMOF.Properties;
stcarrez/dynamo
Ada
17,276
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- N L I S T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides facilities for manipulating lists of nodes (see -- package Atree for format and implementation of tree nodes). The Link field -- of the nodes is used as the forward pointer for these lists. See also -- package Elists which provides another form of lists that are not threaded -- through the nodes (and therefore allow nodes to be on multiple lists). with System; with Types; use Types; package Nlists is -- A node list is a list of nodes in a special format that means that -- nodes can be on at most one such list. For each node list, a list -- header is allocated in the lists table, and a List_Id value references -- this header, which may be used to access the nodes in the list using -- the set of routines that define this interface. -- Note: node lists can contain either nodes or entities (extended nodes) -- or a mixture of nodes and extended nodes. function In_Same_List (N1, N2 : Node_Or_Entity_Id) return Boolean; pragma Inline (In_Same_List); -- Equivalent to List_Containing (N1) = List_Containing (N2) function Last_List_Id return List_Id; pragma Inline (Last_List_Id); -- Returns Id of last allocated list header function Lists_Address return System.Address; pragma Inline (Lists_Address); -- Return address of Lists table (used in Back_End for Gigi call) function Num_Lists return Nat; pragma Inline (Num_Lists); -- Number of currently allocated lists function New_List return List_Id; -- Creates a new empty node list. Typically this is used to initialize -- a field in some other node which points to a node list where the list -- is then subsequently filled in using Append calls. function Empty_List return List_Id renames New_List; -- Used in contexts where an empty list (as opposed to an initially empty -- list to be filled in) is required. function New_List (Node : Node_Or_Entity_Id) return List_Id; -- Build a new list initially containing the given node function New_List (Node1 : Node_Or_Entity_Id; Node2 : Node_Or_Entity_Id) return List_Id; -- Build a new list initially containing the two given nodes function New_List (Node1 : Node_Or_Entity_Id; Node2 : Node_Or_Entity_Id; Node3 : Node_Or_Entity_Id) return List_Id; -- Build a new list initially containing the three given nodes function New_List (Node1 : Node_Or_Entity_Id; Node2 : Node_Or_Entity_Id; Node3 : Node_Or_Entity_Id; Node4 : Node_Or_Entity_Id) return List_Id; function New_List (Node1 : Node_Or_Entity_Id; Node2 : Node_Or_Entity_Id; Node3 : Node_Or_Entity_Id; Node4 : Node_Or_Entity_Id; Node5 : Node_Or_Entity_Id) return List_Id; -- Build a new list initially containing the five given nodes function New_List (Node1 : Node_Or_Entity_Id; Node2 : Node_Or_Entity_Id; Node3 : Node_Or_Entity_Id; Node4 : Node_Or_Entity_Id; Node5 : Node_Or_Entity_Id; Node6 : Node_Or_Entity_Id) return List_Id; -- Build a new list initially containing the six given nodes function New_Copy_List (List : List_Id) return List_Id; -- Creates a new list containing copies (made with Atree.New_Copy) of every -- node in the original list. If the argument is No_List, then the returned -- result is No_List. If the argument is an empty list, then the returned -- result is a new empty list. function New_Copy_List_Original (List : List_Id) return List_Id; -- Same as New_Copy_List but copies only nodes coming from source function First (List : List_Id) return Node_Or_Entity_Id; pragma Inline (First); -- Obtains the first element of the given node list or, if the node list -- has no items or is equal to No_List, then Empty is returned. function First_Non_Pragma (List : List_Id) return Node_Or_Entity_Id; -- Used when dealing with a list that can contain pragmas to skip past -- any initial pragmas and return the first element that is not a pragma. -- If the list is empty, or if it contains only pragmas, then Empty is -- returned. It is an error to call First_Non_Pragma with a Node_Id value -- or No_List (No_List is not considered to be the same as an empty list). -- This function also skips N_Null nodes which can result from rewriting -- unrecognized or incorrect pragmas. function Last (List : List_Id) return Node_Or_Entity_Id; pragma Inline (Last); -- Obtains the last element of the given node list or, if the node list -- has no items, then Empty is returned. It is an error to call Last with -- a Node_Id or No_List. (No_List is not considered to be the same as an -- empty node list). function Last_Non_Pragma (List : List_Id) return Node_Or_Entity_Id; -- Obtains the last element of a given node list that is not a pragma. -- If the list is empty, or if it contains only pragmas, then Empty is -- returned. It is an error to call Last_Non_Pragma with a Node_Id or -- No_List. (No_List is not considered to be the same as an empty list). function List_Length (List : List_Id) return Nat; -- Returns number of items in the given list. It is an error to call -- this function with No_List (No_List is not considered to be the same -- as an empty list). function Next (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id; pragma Inline (Next); -- This function returns the next node on a node list, or Empty if Node is -- the last element of the node list. The argument must be a member of a -- node list. procedure Next (Node : in out Node_Or_Entity_Id); pragma Inline (Next); -- Equivalent to Node := Next (Node); function Next_Non_Pragma (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id; -- This function returns the next node on a node list, skipping past any -- pragmas, or Empty if there is no non-pragma entry left. The argument -- must be a member of a node list. This function also skips N_Null nodes -- which can result from rewriting unrecognized or incorrect pragmas. procedure Next_Non_Pragma (Node : in out Node_Or_Entity_Id); pragma Inline (Next_Non_Pragma); -- Equivalent to Node := Next_Non_Pragma (Node); function Prev (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id; pragma Inline (Prev); -- This function returns the previous node on a node list, or Empty -- if Node is the first element of the node list. The argument must be -- a member of a node list. Note: the implementation does maintain back -- pointers, so this function executes quickly in constant time. function Pick (List : List_Id; Index : Pos) return Node_Or_Entity_Id; -- Given a list, picks out the Index'th entry (1 = first entry). The -- caller must ensure that Index is in range. procedure Prev (Node : in out Node_Or_Entity_Id); pragma Inline (Prev); -- Equivalent to Node := Prev (Node); function Prev_Non_Pragma (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id; pragma Inline (Prev_Non_Pragma); -- This function returns the previous node on a node list, skipping any -- pragmas. If Node is the first element of the list, or if the only -- elements preceding it are pragmas, then Empty is returned. The -- argument must be a member of a node list. Note: the implementation -- does maintain back pointers, so this function executes quickly in -- constant time. procedure Prev_Non_Pragma (Node : in out Node_Or_Entity_Id); pragma Inline (Prev_Non_Pragma); -- Equivalent to Node := Prev_Non_Pragma (Node); function Is_Empty_List (List : List_Id) return Boolean; pragma Inline (Is_Empty_List); -- This function determines if a given list id references a node list that -- contains no items. No_List as an argument returns True. function Is_Non_Empty_List (List : List_Id) return Boolean; pragma Inline (Is_Non_Empty_List); -- This function determines if a given list id references a node list that -- contains at least one item. No_List as an argument returns False. function Is_List_Member (Node : Node_Or_Entity_Id) return Boolean; pragma Inline (Is_List_Member); -- This function determines if a given node is a member of a node list. -- It is an error for Node to be Empty, or to be a node list. function List_Containing (Node : Node_Or_Entity_Id) return List_Id; pragma Inline (List_Containing); -- This function provides a pointer to the node list containing Node. -- Node must be a member of a node list. procedure Append (Node : Node_Or_Entity_Id; To : List_Id); -- Appends Node at the end of node list To. Node must be a non-empty node -- that is not already a member of a node list, and To must be a node list. -- An attempt to append an error node is ignored without complaint and the -- list is unchanged. procedure Append_To (To : List_Id; Node : Node_Or_Entity_Id); pragma Inline (Append_To); -- Like Append, but arguments are the other way round procedure Append_List (List : List_Id; To : List_Id); -- Appends node list List to the end of node list To. On return, -- List is reset to be empty. procedure Append_List_To (To : List_Id; List : List_Id); pragma Inline (Append_List_To); -- Like Append_List, but arguments are the other way round procedure Insert_After (After : Node_Or_Entity_Id; Node : Node_Or_Entity_Id); -- Insert Node, which must be a non-empty node that is not already a -- member of a node list, immediately past node After, which must be a -- node that is currently a member of a node list. An attempt to insert -- an error node is ignored without complaint (and the list is unchanged). procedure Insert_List_After (After : Node_Or_Entity_Id; List : List_Id); -- Inserts the entire contents of node list List immediately after node -- After, which must be a member of a node list. On return, the node list -- List is reset to be the empty node list. procedure Insert_Before (Before : Node_Or_Entity_Id; Node : Node_Or_Entity_Id); -- Insert Node, which must be a non-empty node that is not already a -- member of a node list, immediately before Before, which must be a node -- that is currently a member of a node list. An attempt to insert an -- error node is ignored without complaint (and the list is unchanged). procedure Insert_List_Before (Before : Node_Or_Entity_Id; List : List_Id); -- Inserts the entire contents of node list List immediately before node -- Before, which must be a member of a node list. On return, the node list -- List is reset to be the empty node list. procedure Prepend (Node : Node_Or_Entity_Id; To : List_Id); -- Prepends Node at the start of node list To. Node must be a non-empty -- node that is not already a member of a node list, and To must be a -- node list. An attempt to prepend an error node is ignored without -- complaint and the list is unchanged. procedure Prepend_To (To : List_Id; Node : Node_Or_Entity_Id); pragma Inline (Prepend_To); -- Like Prepend, but arguments are the other way round procedure Prepend_List (List : List_Id; To : List_Id); -- Prepends node list List to the start of node list To. On return, -- List is reset to be empty. procedure Prepend_List_To (To : List_Id; List : List_Id); pragma Inline (Prepend_List_To); -- Like Prepend_List, but arguments are the other way round procedure Remove (Node : Node_Or_Entity_Id); -- Removes Node, which must be a node that is a member of a node list, -- from this node list. The contents of Node are not otherwise affected. function Remove_Head (List : List_Id) return Node_Or_Entity_Id; -- Removes the head element of a node list, and returns the node (whose -- contents are not otherwise affected) as the result. If the node list -- is empty, then Empty is returned. function Remove_Next (Node : Node_Or_Entity_Id) return Node_Or_Entity_Id; -- Removes the item immediately following the given node, and returns it -- as the result. If Node is the last element of the list, then Empty is -- returned. Node must be a member of a list. Unlike Remove, Remove_Next -- is fast and does not involve any list traversal. procedure Initialize; -- Called at the start of compilation of each new main source file to -- initialize the allocation of the list table. Note that Initialize -- must not be called if Tree_Read is used. procedure Lock; -- Called to lock tables before back end is called procedure Unlock; -- Unlock tables, in cases where the back end needs to modify them procedure Tree_Read; -- Initializes internal tables from current tree file using the relevant -- Table.Tree_Read routines. Note that Initialize should not be called if -- Tree_Read is used. Tree_Read includes all necessary initialization. procedure Tree_Write; -- Writes out internal tables to current tree file using the relevant -- Table.Tree_Write routines. function Parent (List : List_Id) return Node_Or_Entity_Id; pragma Inline (Parent); -- Node lists may have a parent in the same way as a node. The function -- accesses the Parent value, which is either Empty when a list header -- is first created, or the value that has been set by Set_Parent. procedure Set_Parent (List : List_Id; Node : Node_Or_Entity_Id); pragma Inline (Set_Parent); -- Sets the parent field of the given list to reference the given node function No (List : List_Id) return Boolean; pragma Inline (No); -- Tests given Id for equality with No_List. This allows notations like -- "if No (Statements)" as opposed to "if Statements = No_List". Note that -- an empty list gives False for this test, as opposed to Is_Empty_List -- which gives True either for No_List or for an empty list. function Present (List : List_Id) return Boolean; pragma Inline (Present); -- Tests given Id for inequality with No_List. This allows notations like -- "if Present (Statements)" as opposed to "if Statements /= No_List". procedure Allocate_List_Tables (N : Node_Or_Entity_Id); -- Called when nodes table is expanded to include node N. This call -- makes sure that list structures internal to Nlists are adjusted -- appropriately to reflect this increase in the size of the nodes table. function Next_Node_Address return System.Address; function Prev_Node_Address return System.Address; -- These functions return the addresses of the Next_Node and Prev_Node -- tables (used in Back_End for Gigi). end Nlists;
GLADORG/glad-cli
Ada
1,647
adb
with Ada.Containers; use Ada.Containers; with Ada.Directories; use Ada.Directories; with Blueprint; use Blueprint; with AAA.Strings; use AAA.Strings; with Ada.Command_Line; with Ada.Text_IO; with Templates_Parser; with CLIC.TTY; with Filesystem; with Commands; package body Commands.Destroy is ------------- -- Execute -- ------------- overriding procedure Execute ( Cmd : in out Command; Args : AAA.Strings.Vector) is begin if Args.Length > 1 then declare Name : String := Element (Args, 2); Blueprint : String := Args.First_Element; Blueprint_Path : String := Compose(Get_Blueprint_Folder,Blueprint); Current : String := Current_Directory; begin Templates_Parser.Insert (Commands.Translations, Templates_Parser.Assoc ("NAME", Name)); if Exists (Blueprint_Path) then Iterate (Blueprint_Path, Current, Delete); IO.Put_Line (TT.Success("Successfully deleted " & Blueprint) & " " & TT.Warn (TT.Bold (Name))); else IO.Put_Line (TT.Error("Blueprint" & " " & Blueprint_Path & " " & "not found")); end if; end; else IO.Put_Line(TT.Error("Command requires a blueprint and a name to be specified.")); end if; end Execute; -------------------- -- Setup_Switches -- -------------------- overriding procedure Setup_Switches (Cmd : in out Command; Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; begin null; end Setup_Switches; end Commands.Destroy;
vikasbidhuri1995/DW1000
Ada
17,132
ads
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA -- -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form, except as embedded into a Nordic -- Semiconductor ASA integrated circuit in a product or a software update for -- such product, 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 Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from this -- software without specific prior written permission. -- -- 4. This software, with or without modification, must only be used with a -- Nordic Semiconductor ASA integrated circuit. -- -- 5. Any software provided in binary form under this license must not be -- reverse engineered, decompiled, modified and/or disassembled. -- -- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY -- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR -- ASA 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 spec has been automatically generated from nrf52.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package NRF52.GPIO is pragma Preelaborate; --------------- -- Registers -- --------------- -- Pin 0 type OUT_PIN0_Field is (-- Pin driver is low Low, -- Pin driver is high High) with Size => 1; for OUT_PIN0_Field use (Low => 0, High => 1); -- OUT_PIN array type OUT_PIN_Field_Array is array (0 .. 31) of OUT_PIN0_Field with Component_Size => 1, Size => 32; -- Write GPIO port type OUT_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : OUT_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OUT_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0 type OUTSET_PIN0_Field is (-- Read: pin driver is low Low, -- Read: pin driver is high High) with Size => 1; for OUTSET_PIN0_Field use (Low => 0, High => 1); -- Pin 0 type OUTSET_PIN0_Field_1 is (-- Reset value for the field Outset_Pin0_Field_Reset, -- Write: writing a '1' sets the pin high; writing a '0' has no effect Set) with Size => 1; for OUTSET_PIN0_Field_1 use (Outset_Pin0_Field_Reset => 0, Set => 1); -- OUTSET_PIN array type OUTSET_PIN_Field_Array is array (0 .. 31) of OUTSET_PIN0_Field_1 with Component_Size => 1, Size => 32; -- Set individual bits in GPIO port type OUTSET_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : OUTSET_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OUTSET_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0 type OUTCLR_PIN0_Field is (-- Read: pin driver is low Low, -- Read: pin driver is high High) with Size => 1; for OUTCLR_PIN0_Field use (Low => 0, High => 1); -- Pin 0 type OUTCLR_PIN0_Field_1 is (-- Reset value for the field Outclr_Pin0_Field_Reset, -- Write: writing a '1' sets the pin low; writing a '0' has no effect Clear) with Size => 1; for OUTCLR_PIN0_Field_1 use (Outclr_Pin0_Field_Reset => 0, Clear => 1); -- OUTCLR_PIN array type OUTCLR_PIN_Field_Array is array (0 .. 31) of OUTCLR_PIN0_Field_1 with Component_Size => 1, Size => 32; -- Clear individual bits in GPIO port type OUTCLR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : OUTCLR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OUTCLR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0 type IN_PIN0_Field is (-- Pin input is low Low, -- Pin input is high High) with Size => 1; for IN_PIN0_Field use (Low => 0, High => 1); -- IN_PIN array type IN_PIN_Field_Array is array (0 .. 31) of IN_PIN0_Field with Component_Size => 1, Size => 32; -- Read GPIO port type IN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : IN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0 type DIR_PIN0_Field is (-- Pin set as input Input, -- Pin set as output Output) with Size => 1; for DIR_PIN0_Field use (Input => 0, Output => 1); -- DIR_PIN array type DIR_PIN_Field_Array is array (0 .. 31) of DIR_PIN0_Field with Component_Size => 1, Size => 32; -- Direction of GPIO pins type DIR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : DIR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DIR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Set as output pin 0 type DIRSET_PIN0_Field is (-- Read: pin set as input Input, -- Read: pin set as output Output) with Size => 1; for DIRSET_PIN0_Field use (Input => 0, Output => 1); -- Set as output pin 0 type DIRSET_PIN0_Field_1 is (-- Reset value for the field Dirset_Pin0_Field_Reset, -- Write: writing a '1' sets pin to output; writing a '0' has no effect Set) with Size => 1; for DIRSET_PIN0_Field_1 use (Dirset_Pin0_Field_Reset => 0, Set => 1); -- DIRSET_PIN array type DIRSET_PIN_Field_Array is array (0 .. 31) of DIRSET_PIN0_Field_1 with Component_Size => 1, Size => 32; -- DIR set register type DIRSET_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : DIRSET_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DIRSET_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Set as input pin 0 type DIRCLR_PIN0_Field is (-- Read: pin set as input Input, -- Read: pin set as output Output) with Size => 1; for DIRCLR_PIN0_Field use (Input => 0, Output => 1); -- Set as input pin 0 type DIRCLR_PIN0_Field_1 is (-- Reset value for the field Dirclr_Pin0_Field_Reset, -- Write: writing a '1' sets pin to input; writing a '0' has no effect Clear) with Size => 1; for DIRCLR_PIN0_Field_1 use (Dirclr_Pin0_Field_Reset => 0, Clear => 1); -- DIRCLR_PIN array type DIRCLR_PIN_Field_Array is array (0 .. 31) of DIRCLR_PIN0_Field_1 with Component_Size => 1, Size => 32; -- DIR clear register type DIRCLR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : DIRCLR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DIRCLR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Status on whether PIN0 has met criteria set in PIN_CNF0.SENSE register. -- Write '1' to clear. type LATCH_PIN0_Field is (-- Criteria has not been met Notlatched, -- Criteria has been met Latched) with Size => 1; for LATCH_PIN0_Field use (Notlatched => 0, Latched => 1); -- LATCH_PIN array type LATCH_PIN_Field_Array is array (0 .. 31) of LATCH_PIN0_Field with Component_Size => 1, Size => 32; -- Latch register indicating what GPIO pins that have met the criteria set -- in the PIN_CNF[n].SENSE registers type LATCH_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : NRF52.UInt32; when True => -- PIN as an array Arr : LATCH_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for LATCH_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Select between default DETECT signal behaviour and LDETECT mode type DETECTMODE_DETECTMODE_Field is (-- DETECT directly connected to PIN DETECT signals Default, -- Use the latched LDETECT behaviour Ldetect) with Size => 1; for DETECTMODE_DETECTMODE_Field use (Default => 0, Ldetect => 1); -- Select between default DETECT signal behaviour and LDETECT mode type DETECTMODE_Register is record -- Select between default DETECT signal behaviour and LDETECT mode DETECTMODE : DETECTMODE_DETECTMODE_Field := NRF52.GPIO.Default; -- unspecified Reserved_1_31 : NRF52.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DETECTMODE_Register use record DETECTMODE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Pin direction. Same physical register as DIR register type PIN_CNF_DIR_Field is (-- Configure pin as an input pin Input, -- Configure pin as an output pin Output) with Size => 1; for PIN_CNF_DIR_Field use (Input => 0, Output => 1); -- Connect or disconnect input buffer type PIN_CNF_INPUT_Field is (-- Connect input buffer Connect, -- Disconnect input buffer Disconnect) with Size => 1; for PIN_CNF_INPUT_Field use (Connect => 0, Disconnect => 1); -- Pull configuration type PIN_CNF_PULL_Field is (-- No pull Disabled, -- Pull down on pin Pulldown, -- Pull up on pin Pullup) with Size => 2; for PIN_CNF_PULL_Field use (Disabled => 0, Pulldown => 1, Pullup => 3); -- Drive configuration type PIN_CNF_DRIVE_Field is (-- Standard '0', standard '1' S0S1, -- High drive '0', standard '1' H0S1, -- Standard '0', high drive '1' S0H1, -- High drive '0', high 'drive '1'' H0H1, -- Disconnect '0' standard '1' (normally used for wired-or connections) D0S1, -- Disconnect '0', high drive '1' (normally used for wired-or connections) D0H1, -- Standard '0'. disconnect '1' (normally used for wired-and connections) S0D1, -- High drive '0', disconnect '1' (normally used for wired-and connections) H0D1) with Size => 3; for PIN_CNF_DRIVE_Field use (S0S1 => 0, H0S1 => 1, S0H1 => 2, H0H1 => 3, D0S1 => 4, D0H1 => 5, S0D1 => 6, H0D1 => 7); -- Pin sensing mechanism type PIN_CNF_SENSE_Field is (-- Disabled Disabled, -- Sense for high level High, -- Sense for low level Low) with Size => 2; for PIN_CNF_SENSE_Field use (Disabled => 0, High => 2, Low => 3); -- Description collection[0]: Configuration of GPIO pins type PIN_CNF_Register is record -- Pin direction. Same physical register as DIR register DIR : PIN_CNF_DIR_Field := NRF52.GPIO.Input; -- Connect or disconnect input buffer INPUT : PIN_CNF_INPUT_Field := NRF52.GPIO.Disconnect; -- Pull configuration PULL : PIN_CNF_PULL_Field := NRF52.GPIO.Disabled; -- unspecified Reserved_4_7 : NRF52.UInt4 := 16#0#; -- Drive configuration DRIVE : PIN_CNF_DRIVE_Field := NRF52.GPIO.S0S1; -- unspecified Reserved_11_15 : NRF52.UInt5 := 16#0#; -- Pin sensing mechanism SENSE : PIN_CNF_SENSE_Field := NRF52.GPIO.Disabled; -- unspecified Reserved_18_31 : NRF52.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PIN_CNF_Register use record DIR at 0 range 0 .. 0; INPUT at 0 range 1 .. 1; PULL at 0 range 2 .. 3; Reserved_4_7 at 0 range 4 .. 7; DRIVE at 0 range 8 .. 10; Reserved_11_15 at 0 range 11 .. 15; SENSE at 0 range 16 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Description collection[0]: Configuration of GPIO pins type PIN_CNF_Registers is array (0 .. 31) of PIN_CNF_Register; ----------------- -- Peripherals -- ----------------- -- GPIO Port 1 type GPIO_Peripheral is record -- Write GPIO port OUT_k : aliased OUT_Register; -- Set individual bits in GPIO port OUTSET : aliased OUTSET_Register; -- Clear individual bits in GPIO port OUTCLR : aliased OUTCLR_Register; -- Read GPIO port IN_k : aliased IN_Register; -- Direction of GPIO pins DIR : aliased DIR_Register; -- DIR set register DIRSET : aliased DIRSET_Register; -- DIR clear register DIRCLR : aliased DIRCLR_Register; -- Latch register indicating what GPIO pins that have met the criteria -- set in the PIN_CNF[n].SENSE registers LATCH : aliased LATCH_Register; -- Select between default DETECT signal behaviour and LDETECT mode DETECTMODE : aliased DETECTMODE_Register; -- Description collection[0]: Configuration of GPIO pins PIN_CNF : aliased PIN_CNF_Registers; end record with Volatile; for GPIO_Peripheral use record OUT_k at 16#504# range 0 .. 31; OUTSET at 16#508# range 0 .. 31; OUTCLR at 16#50C# range 0 .. 31; IN_k at 16#510# range 0 .. 31; DIR at 16#514# range 0 .. 31; DIRSET at 16#518# range 0 .. 31; DIRCLR at 16#51C# range 0 .. 31; LATCH at 16#520# range 0 .. 31; DETECTMODE at 16#524# range 0 .. 31; PIN_CNF at 16#700# range 0 .. 1023; end record; -- GPIO Port 1 P0_Periph : aliased GPIO_Peripheral with Import, Address => P0_Base; end NRF52.GPIO;
byllgrim/iictl
Ada
64
adb
with Iictl; procedure Main is begin Iictl.Iictl; end Main;
skill-lang/adaCommon
Ada
1,376
ads
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ iterator over static instances -- -- |___/_|\_\_|_|____| by: Timm Felden -- -- -- pragma Ada_2012; with Skill.Types; with Skill.Types.Pools; package Skill.Iterators.Static_Data is use Skill.Types; use type Skill.Types.Pools.Pool; -- @note in contrast to c++, this implementation uses type erasure as I dont -- see how to solve elaboration otherwise type Iterator is tagged record Current : Skill.Types.Pools.Pool; SecondIndex : Skill_ID_T; LastBlock : Skill_ID_T; Index : Skill_ID_T; Last : Skill_ID_T; end record; function Make (First : Skill.Types.Pools.Pool := null) return Iterator; procedure Init (This : access Iterator'Class; First : Skill.Types.Pools.Pool := null); function Element (This : access Iterator'Class) return Annotation; function Has_Next (This : access Iterator'Class) return Boolean is (This.Index /= This.Last); function Next (This : access Iterator'Class) return Annotation; end Skill.Iterators.Static_Data;
reznikmm/matreshka
Ada
5,277
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with WebAPI.HTML.Elements; package WebAPI.XHR.Form_Datas is pragma Preelaborate; type Form_Data (Form : WebAPI.HTML.Elements.HTML_Element_Access := null) is tagged limited private; -- The FormData object represents an ordered list of entries. -- Each entry consists of a name and a value. not overriding procedure Append (Self : not null access Form_Data; Name : League.Strings.Universal_String; Value : League.Strings.Universal_String) with Import => True, Convention => JavaScript_Method, Link_Name => "append"; not overriding procedure Delete (Self : not null access Form_Data; Name : League.Strings.Universal_String) with Import => True, Convention => JavaScript_Method, Link_Name => "delete"; not overriding function Get (Self : not null access constant Form_Data; Name : League.Strings.Universal_String) return League.Strings.Universal_String with Import => True, Convention => JavaScript_Method, Link_Name => "get"; not overriding function Has (Self : not null access constant Form_Data; Name : League.Strings.Universal_String) return Boolean with Import => True, Convention => JavaScript_Method, Link_Name => "has"; not overriding procedure Set (Self : not null access Form_Data; Name : League.Strings.Universal_String; Value : League.Strings.Universal_String) with Import => True, Convention => JavaScript_Method, Link_Name => "set"; private type Form_Data (Form : WebAPI.HTML.Elements.HTML_Element_Access := null) is tagged limited null record with Export => True, Convention => JavaScript, Link_Name => "FormData"; end WebAPI.XHR.Form_Datas;
stcarrez/ada-awa
Ada
3,087
adb
----------------------------------------------------------------------- -- awa-commands-stop -- Command to stop the web server -- Copyright (C) 2020, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with GNAT.Sockets; with Util.Streams.Sockets; with Util.Streams.Texts; package body AWA.Commands.Stop is -- ------------------------------ -- Setup the command before parsing the arguments and executing it. -- ------------------------------ overriding procedure Setup (Command : in out Command_Type; Config : in out GNAT.Command_Line.Command_Line_Configuration; Context : in out Context_Type) is begin GC.Set_Usage (Config => Config, Usage => Command.Get_Name & " [arguments]", Help => Command.Get_Description); GC.Define_Switch (Config => Config, Output => Command.Management_Port'Access, Switch => "-m:", Long_Switch => "--management-port=", Initial => Command.Management_Port, Argument => "NUMBER", Help => -("The server listening management port on localhost")); AWA.Commands.Setup_Command (Config, Context); end Setup; -- ------------------------------ -- Stop the server by sending a 'stop' command on the management socket. -- ------------------------------ overriding procedure Execute (Command : in out Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Context_Type) is pragma Unreferenced (Name, Args, Context); Address : GNAT.Sockets.Sock_Addr_Type; Stream : aliased Util.Streams.Sockets.Socket_Stream; Writer : Util.Streams.Texts.Print_Stream; begin Address.Addr := GNAT.Sockets.Loopback_Inet_Addr; Address.Port := GNAT.Sockets.Port_Type (Command.Management_Port); Stream.Connect (Address); Writer.Initialize (Stream'Unchecked_Access, 1024); Writer.Write ("stop" & ASCII.CR & ASCII.LF); Writer.Flush; Writer.Close; end Execute; begin Command_Drivers.Driver.Add_Command ("stop", -("stop the web server"), Command'Access); end AWA.Commands.Stop;
stcarrez/dynamo
Ada
13,314
ads
----------------------------------------------------------------------- -- gen-generator -- Code Generator -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Command_Line; with Ada.Strings.Unbounded; with Ada.Strings.Unbounded.Hash; with Ada.Containers.Hashed_Maps; with Util.Beans.Objects; with Util.Properties; with ASF.Applications.Main; with ASF.Contexts.Faces; with ASF.Servlets; with Gen.Model.Packages; with Gen.Model.Projects; with Gen.Artifacts.Hibernate; with Gen.Artifacts.Query; with Gen.Artifacts.Mappings; with Gen.Artifacts.Distribs; with Gen.Artifacts.XMI; with Gen.Artifacts.Yaml; package Gen.Generator is package UBO renames Util.Beans.Objects; -- A fatal error that prevents the generator to proceed has occurred. Fatal_Error : exception; G_URI : constant String := "http://code.google.com/p/ada-ado/generator"; type Package_Type is (PACKAGE_MODEL, PACKAGE_FORMS); type Mapping_File is record Path : UString; Output : Ada.Text_IO.File_Type; end record; type Handler is new ASF.Applications.Main.Application and Gen.Artifacts.Generator with private; -- Initialize the generator procedure Initialize (H : in out Handler; Config_Dir : in UString; Debug : in Boolean); -- Get the configuration properties. function Get_Properties (H : in Handler) return Util.Properties.Manager; -- Report an error and set the exit status accordingly overriding procedure Error (H : in out Handler; Message : in String; Arg1 : in String; Arg2 : in String := ""); overriding procedure Error (H : in out Handler; Message : in String); -- Report an info message. procedure Info (H : in out Handler; Message : in String; Arg1 : in String := ""; Arg2 : in String := ""; Arg3 : in String := ""); -- Read the XML package file procedure Read_Package (H : in out Handler; File : in String); -- Read the model mapping types and initialize the hibernate artifact. procedure Read_Mappings (H : in out Handler); -- Read the XML model file procedure Read_Model (H : in out Handler; File : in String; Silent : in Boolean); -- Read the model and query files stored in the application directory <b>db</b>. procedure Read_Models (H : in out Handler; Dirname : in String); -- Read the XML project file. When <b>Recursive</b> is set, read the GNAT project -- files used by the main project and load all the <b>dynamo.xml</b> files defined -- by these project. procedure Read_Project (H : in out Handler; File : in String; Recursive : in Boolean := False); -- Prepare the model by checking, verifying and initializing it after it is completely known. procedure Prepare (H : in out Handler); -- Finish the generation. Some artifacts could generate other files that take into -- account files generated previously. procedure Finish (H : in out Handler); -- Tell the generator to activate the generation of the given template name. -- The name is a property name that must be defined in generator.properties to -- indicate the template file. Several artifacts can trigger the generation -- of a given template. The template is generated only once. overriding procedure Add_Generation (H : in out Handler; Name : in String; Mode : in Gen.Artifacts.Iteration_Mode; Mapping : in String); -- Enable the generation of the Ada package given by the name. By default all the Ada -- packages found in the model are generated. When called, this enables the generation -- only for the Ada packages registered here. procedure Enable_Package_Generation (H : in out Handler; Name : in String); -- Save the content generated by the template generator. procedure Save_Content (H : in out Handler; File : in String; Content : in UString); -- Generate the code using the template file procedure Generate (H : in out Handler; Mode : in Gen.Artifacts.Iteration_Mode; File : in String; Save : not null access procedure (H : in out Handler; File : in String; Content : in UString)); -- Generate the code using the template file procedure Generate (H : in out Handler; File : in String; Model : in Gen.Model.Definition_Access; Save : not null access procedure (H : in out Handler; File : in String; Content : in UString)); -- Generate all the code for the templates activated through <b>Add_Generation</b>. procedure Generate_All (H : in out Handler); -- Generate all the code generation files stored in the directory procedure Generate_All (H : in out Handler; Mode : in Gen.Artifacts.Iteration_Mode; Name : in String); -- Set the directory where template files are stored. procedure Set_Template_Directory (H : in out Handler; Path : in UString); -- Set the directory where results files are generated. procedure Set_Result_Directory (H : in out Handler; Path : in String); -- Get the result directory path. overriding function Get_Result_Directory (H : in Handler) return String; -- Get the project plugin directory path. function Get_Plugin_Directory (H : in Handler) return String; -- Get the config directory path. overriding function Get_Config_Directory (H : in Handler) return String; -- Get the dynamo installation directory path. function Get_Install_Directory (H : in Handler) return String; -- Return the search directories that the AWA application can use to find files. -- The search directories is built by using the project dependencies. function Get_Search_Directories (H : in Handler) return String; -- Get the exit status -- Returns 0 if the generation was successful -- Returns 1 if there was a generation error function Get_Status (H : in Handler) return Ada.Command_Line.Exit_Status; -- Get the configuration parameter. overriding function Get_Parameter (H : in Handler; Name : in String; Default : in String := "") return String; -- Get the configuration parameter. overriding function Get_Parameter (H : in Handler; Name : in String; Default : in Boolean := False) return Boolean; -- Set the force-save file mode. When False, if the generated file exists already, -- an error message is reported. procedure Set_Force_Save (H : in out Handler; To : in Boolean); -- Set the project name. procedure Set_Project_Name (H : in out Handler; Name : in String); -- Get the project name. function Get_Project_Name (H : in Handler) return String; -- Set the project property. procedure Set_Project_Property (H : in out Handler; Name : in String; Value : in String); -- Get the project property identified by the given name. If the project property -- does not exist, returns the default value. Project properties are loaded -- by <b>Read_Project</b>. function Get_Project_Property (H : in Handler; Name : in String; Default : in String := "") return String; -- Set the global configuration identified by the name by pre-pending the -- environtment variable if it is defined. procedure Set_Configuration (H : in out Handler; Name : in String; Env_Name : in String); -- Save the project description and parameters. procedure Save_Project (H : in out Handler); -- Get the path of the last generated file. function Get_Generated_File (H : in Handler) return String; -- Update the project model through the <b>Process</b> procedure. procedure Update_Project (H : in out Handler; Process : not null access procedure (P : in out Model.Projects.Root_Project_Definition)); -- Scan the dynamo directories and execute the <b>Process</b> procedure with the -- directory path. overriding procedure Scan_Directories (H : in Handler; Process : not null access procedure (Dir : in String)); private use Ada.Strings.Unbounded; use Gen.Artifacts; type Template_Context is record Mode : Gen.Artifacts.Iteration_Mode; Mapping : UString; end record; package Template_Map is new Ada.Containers.Hashed_Maps (Key_Type => UString, Element_Type => Template_Context, Hash => Ada.Strings.Unbounded.Hash, Equivalent_Keys => "="); type Object_Access is access all UBO.Object; type Handler is new ASF.Applications.Main.Application and Gen.Artifacts.Generator with record Conf : ASF.Applications.Config; -- Config directory. Config_Dir : UString; -- Output base directory. Output_Dir : UString; Model : aliased Gen.Model.Packages.Model_Definition; Status : Ada.Command_Line.Exit_Status := 0; -- The file that must be saved (the file attribute in <f:view>. File : Object_Access; -- Indicates whether the file must be saved at each generation or only once. -- This is the mode attribute in <f:view>. Mode : Object_Access; -- Indicates whether the file must be ignored after the generation. -- This is the ignore attribute in <f:view>. It is intended to be used for the package -- body generation to skip that in some cases when it turns out there is no operation. Ignore : Object_Access; -- Whether the AdaMappings.xml file was loaded or not. Type_Mapping_Loaded : Boolean := False; -- The root project document. Project : aliased Gen.Model.Projects.Root_Project_Definition; -- Hibernate XML artifact Hibernate : Gen.Artifacts.Hibernate.Artifact; -- Query generation artifact. Query : Gen.Artifacts.Query.Artifact; -- Type mapping artifact. Mappings : Gen.Artifacts.Mappings.Artifact; -- The distribution artifact. Distrib : Gen.Artifacts.Distribs.Artifact; -- Ada generation from UML-XMI models. XMI : Gen.Artifacts.XMI.Artifact; -- Yaml model files support. Yaml : Gen.Artifacts.Yaml.Artifact; -- The list of templates that must be generated. Templates : Template_Map.Map; -- Force the saving of a generated file, even if a file already exist. Force_Save : Boolean := True; -- A fake servlet for template evaluation. Servlet : ASF.Servlets.Servlet_Access; end record; -- Execute the lifecycle phases on the faces context. overriding procedure Execute_Lifecycle (App : in Handler; Context : in out ASF.Contexts.Faces.Faces_Context'Class); end Gen.Generator;
persan/advent-of-code-2020
Ada
57
ads
package Adventofcode.Day_13 is end Adventofcode.Day_13;
charlie5/lace
Ada
459
ads
with freetype_c.Pointers; package freetype_c.FT_Library is subtype Item is Pointers.FT_LibraryRec_Pointer; type Item_array is array (C.Size_t range <>) of aliased FT_Library.Item; type Pointer is access all freetype_c.FT_Library.Item; type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_Library.Pointer; type pointer_Pointer is access all freetype_c.FT_Library.Pointer; end freetype_c.FT_Library;
reznikmm/matreshka
Ada
551
adb
with AMF.Facility; with AMF.URI_Stores; with League.Application; with XMI.Reader; with AMF.Internals.Factories.UML_Factory; -- This package should be included into partition closure to be able to -- process UML models. with Generators; procedure Demo is Store : AMF.URI_Stores.URI_Store_Access; Generator : Generators.Generator; begin AMF.Facility.Initialize; -- Loading specified model Store := XMI.Reader.Read_File (League.Application.Arguments.Element (1)); -- Generate code Generator.Visit (Store); end Demo;
AdaCore/gpr
Ada
26
ads
package PckA is end PckA;
NCommander/dnscatcher
Ada
9,295
adb
-- Copyright 2019 Michael Casadevall <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to -- deal in the Software without restriction, including without limitation the -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -- sell copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. with Ada.Text_IO; use Ada.Text_IO; with Ada.Unchecked_Deallocation; with Ada.Calendar; use Ada.Calendar; with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; package body DNSCatcher.Utils.Logger is procedure Free_Logger_Msg_Ptr is new Ada.Unchecked_Deallocation (Object => Logger_Message_Packet, Name => Logger_Message_Packet_Ptr); function Format_Log_Level (Use_Color : Boolean; Log_Level : Log_Levels) return Unbounded_String is Color_Prefix : Unbounded_String; Log_Level_Str : Unbounded_String; Now : constant Time := Clock; begin -- Add ANSI color codes if we're using color on Linux if Use_Color then case Log_Level is when EMERGERENCY => Color_Prefix := To_Unbounded_String (ANSI_Light_Red); when ALERT => Color_Prefix := To_Unbounded_String (ANSI_Light_Red); when CRITICAL => Color_Prefix := To_Unbounded_String (ANSI_Light_Red); when ERROR => Color_Prefix := To_Unbounded_String (ANSI_Red); when WARNING => Color_Prefix := To_Unbounded_String (ANSI_Light_Yellow); when NOTICE => Color_Prefix := To_Unbounded_String (ANSI_Yellow); when INFO => Color_Prefix := To_Unbounded_String (ANSI_Green); when DEBUG => Color_Prefix := To_Unbounded_String (ANSI_Light_Blue); end case; Log_Level_Str := Color_Prefix & To_Unbounded_String (Log_Level'Image) & ANSI_Reset; else Log_Level_Str := To_Unbounded_String (Log_Level'Image); end if; return To_Unbounded_String (Image (Date => Now) & " [" & To_String (Log_Level_Str) & "]"); end Format_Log_Level; function Create_String_From_Components (Components : Component_Vector.Vector) return Unbounded_String is Components_String : Unbounded_String; procedure Component_To_String (c : Component_Vector.Cursor) is Scratch_String : Unbounded_String; begin Scratch_String := Components (c); Components_String := Components_String & "[" & Scratch_String & "]"; end Component_To_String; begin -- If there's no component, just leave it blank if Components.Length = 0 then return To_Unbounded_String (""); end if; Components.Iterate (Component_To_String'Access); return Components_String; end Create_String_From_Components; protected body Logger_Queue_Type is -- Handles queue of packets for the logger thread entry Add_Packet (Queue : Logger_Message_Packet_Ptr) when True is begin Queued_Packets.Append (Queue); end Add_Packet; entry Get (Queue : out Logger_Message_Packet_Ptr) when Queued_Packets.Length > 0 is begin Queue := Queued_Packets.First_Element; Queued_Packets.Delete_First; end Get; entry Count (Count : out Integer) when True is begin Count := Integer (Queued_Packets.Length); end Count; entry Empty when True is begin declare procedure Dump_Vector_Data (c : Logger_Message_Packet_Vector.Cursor) is begin Free_Logger_Msg_Ptr (Queued_Packets (c)); end Dump_Vector_Data; begin Queued_Packets.Iterate (Dump_Vector_Data'access); end; end Empty; end Logger_Queue_Type; protected body Logger_Message_Packet is entry Push_Component (Component : String) when True is begin Current_Component.Append (To_Unbounded_String (Component)); end Push_Component; entry Pop_Component when True is begin Current_Component.Delete_Last; end Pop_Component; entry Log_Message (Level : Log_Levels; Msg : String) when True is Msg_Record : Log_Message_Record; begin Msg_Record.Log_Level := Level; Msg_Record.Component := Current_Component.Copy; Msg_Record.Message := To_Unbounded_String (Msg); Logged_Msgs.Append (Msg_Record); end Log_Message; entry Get (Msg : out Log_Message_Record) when Logged_Msgs.Length > 0 is begin Msg := Logged_Msgs.First_Element; Logged_Msgs.Delete_First; end Get; entry Get_All_And_Empty (Queue : out Log_Message_Vector.Vector) when True is begin Queue := Logged_Msgs.Copy; Logged_Msgs.Clear; end Get_All_And_Empty; entry Count (Count : out Integer) when True is begin Count := Integer (Logged_Msgs.Length); end Count; entry Empty when True is begin Logged_Msgs.Clear; end Empty; end Logger_Message_Packet; task body Logger is -- Running task for the logger processing the global message queue Logger_Cfg : Logger_Configuration; Keep_Running : Boolean := False; Current_Queue : Logger_Message_Packet_Ptr; Msg_Packets : Log_Message_Vector.Vector; Msg_String : Unbounded_String; Queues_To_Process : Integer; procedure Process_Queue is procedure Print_Messages (c : Log_Message_Vector.Cursor) is Current_Msg : constant Log_Message_Record := Log_Message_Vector.Element (c); begin -- This is so ugly :( if Log_Levels'Enum_Rep (Logger_Cfg.Log_Level) >= Log_Levels'Enum_Rep (Current_Msg.Log_Level) then Msg_String := Format_Log_Level (Logger_Cfg.Use_Color, Current_Msg.Log_Level); Msg_String := Msg_String & Create_String_From_Components (Current_Msg.Component); Msg_String := Msg_String & " " & Current_Msg.Message; Put_Line (To_String (Msg_String)); end if; end Print_Messages; begin Logger_Queue.Count (Queues_To_Process); while Queues_To_Process > 0 loop Logger_Queue.Get (Current_Queue); -- Get a local copy and then empty it; we don't care past that -- point if Current_Queue /= null then Current_Queue.Get_All_And_Empty (Msg_Packets); Msg_Packets.Iterate (Print_Messages'Access); Free_Logger_Msg_Ptr (Current_Queue); end if; Logger_Queue.Count (Queues_To_Process); end loop; exception -- Not sure if there's a better way to do this, but avoids a race -- condition when Constraint_Error => begin null; end; end Process_Queue; begin -- Set some sane defaults for Logger config if not initialized Logger_Cfg.Log_Level := NOTICE; Logger_Cfg.Use_Color := False; loop -- Processing loop while Keep_Running loop select accept Start do null; end Start; or accept Stop do -- Flush the pending queue Keep_Running := False; Process_Queue; end Stop; else Process_Queue; delay 0.1; end select; end loop; -- Idling loop ready for shutdown while Keep_Running = False loop select accept Initialize (Cfg : Logger_Configuration) do Logger_Cfg := Cfg; end Initialize; or accept Start do Keep_Running := True; end Start; or accept Stop do null; end Stop; or terminate; end select; end loop; end loop; end Logger; end DNSCatcher.Utils.Logger;
sebsgit/textproc
Ada
2,721
ads
with Ada.Containers.Vectors; use Ada.Containers; with Ada.Finalization; with Interfaces.C; with Interfaces.C.Pointers; package PixelArray is pragma Elaborate_Body; pragma Assertion_Policy (Pre => Check, Post => Check, Type_Invariant => Check); type Pixel is range 0 .. 255; Background: constant Pixel := 255; type ImagePlane is tagged limited private; function width(img: ImagePlane) return Natural with Inline; function height(img: ImagePlane) return Natural with Inline; function allocate(width, height: Natural) return ImagePlane with Post => (width = allocate'Result.width); function clone(img: ImagePlane) return ImagePlane; procedure assign(This: in out ImagePlane; other: in ImagePlane) with Inline; procedure set(img: in out ImagePlane; x, y: Natural; px: Pixel) with Pre => (x < img.width and y < img.height), Inline; function get(img: ImagePlane; x, y: Natural) return Pixel with Pre => (x < img.width and y < img.height), Inline; procedure set(img: in out ImagePlane; px: Pixel) with Inline; function isInside(image: in ImagePlane; x, y: in Integer) return Boolean with Inline; function isEqual(source: in ImagePlane; target: in ImagePlane) return Boolean; function distanceRMS(source: in ImagePlane; target: in ImagePlane) return Float with Pre => source.width = target.width and source.height = target.height; function allPixels(img: in ImagePlane; condition: access function(px: Pixel) return Boolean) return Boolean with Pre => (img.width > 0 and img.height > 0); function rescale(img: in ImagePlane; w, h: in Positive) return ImagePlane with Post => rescale'Result.width = w and rescale'Result.height = h; function expand(img: in ImagePlane; w_margin, h_margin: in Positive; color: Pixel) return ImagePlane with Post => expand'Result.width = 2 * w_margin + img.width and expand'Result.height = 2 * h_margin + img.height; function cut(img: in ImagePlane; x, y: in Natural; w, h: in Positive) return ImagePlane with Pre => (x < img.width and y < img.height) and (w <= img.width and h <= img.height), Post => cut'Result.width = w and cut'Result.height = h, Inline; private type Pixel_Buffer is array (Natural range <>) of aliased Interfaces.C.unsigned_char; type Pixel_Buffer_Access is access all Pixel_Buffer; type ImagePlane is limited new Ada.Finalization.Limited_Controlled with record data: aliased Pixel_Buffer_Access; width_d, height_d: Natural := 0; end record; overriding procedure Finalize(This: in out ImagePlane) with Inline; end PixelArray;
jrmarino/zstd-ada
Ada
2,240
adb
with Zstandard.Functions; use Zstandard.Functions; with Ada.Command_line; use Ada.Command_Line; with Ada.Directories; use Ada.Directories; with Ada.Text_IO; use Ada.Text_IO; procedure Demo_Ada is level : Compression_Level := Fastest_Compression; begin if Argument_Count = 0 or else Argument_Count > 2 then Put_Line ("Zstandard version: " & Zstd_Version); Put_Line ("usage:"); Put_Line (Command_Name & " <path/to/file> [compression level=1]"); return; end if; if not Exists (Argument (1)) then Put_Line ("File '" & Argument (1) & "' does not exist, aborting."); return; end if; if Argument_Count = 2 then declare complevel : String renames Argument (2); myint : Integer; begin myint := Integer'Value (complevel); if myint >= 1 and then myint <= 22 then level := Compression_Level (myint); end if; exception when others => null; end; end if; declare path2file : String renames Argument (1); compfile : String := path2file & ".zst"; srcsize : Zstandard.Functions.File_Size; dstsize : Zstandard.Functions.File_Size; goodcomp : Boolean; units : Natural; tenths : Natural; tenthstr : String (1 .. 2); error_msg : String := Compress_File (source_file => path2file, output_file => compfile, source_size => srcsize, output_size => dstsize, successful => goodcomp, quality => level); begin if goodcomp then units := Natural (100 * dstsize / srcsize); tenths := (Natural (10 * dstsize / srcsize)) mod 10; tenthstr := tenths'Img; Put_Line (" original file size:" & srcsize'Img); Put_Line (" compressed file size:" & dstsize'Img); Put_Line ("percentage compressed:" & units'Img & "." & tenthstr (2 ..2)); Put_Line (" new file: " & compfile); else Put_Line (error_msg); end if; end; end Demo_Ada;
sungyeon/drake
Ada
134
ads
pragma License (Unrestricted); with Ada.Unchecked_Conversion; generic function Unchecked_Conversion renames Ada.Unchecked_Conversion;
charlie5/aShell
Ada
483
adb
with Shell.Commands.Safe, Ada.Text_IO; procedure Test_Unused_Safe_Command is use Ada.Text_IO; begin Put_Line ("Begin 'Unused_Safe_Command' test."); declare use Shell.Commands.Safe, Shell.Commands.Safe.Forge; The_Command : Command := To_Command ("ls /non_existent_file") with Unreferenced; begin Stop_Spawn_Client; end; Put_Line ("Success."); Put_Line ("End 'Unused_Safe_Command' test."); end Test_Unused_Safe_Command;
reznikmm/matreshka
Ada
5,064
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Manifestations.Collections is pragma Preelaborate; package UML_Manifestation_Collections is new AMF.Generic_Collections (UML_Manifestation, UML_Manifestation_Access); type Set_Of_UML_Manifestation is new UML_Manifestation_Collections.Set with null record; Empty_Set_Of_UML_Manifestation : constant Set_Of_UML_Manifestation; type Ordered_Set_Of_UML_Manifestation is new UML_Manifestation_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Manifestation : constant Ordered_Set_Of_UML_Manifestation; type Bag_Of_UML_Manifestation is new UML_Manifestation_Collections.Bag with null record; Empty_Bag_Of_UML_Manifestation : constant Bag_Of_UML_Manifestation; type Sequence_Of_UML_Manifestation is new UML_Manifestation_Collections.Sequence with null record; Empty_Sequence_Of_UML_Manifestation : constant Sequence_Of_UML_Manifestation; private Empty_Set_Of_UML_Manifestation : constant Set_Of_UML_Manifestation := (UML_Manifestation_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Manifestation : constant Ordered_Set_Of_UML_Manifestation := (UML_Manifestation_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Manifestation : constant Bag_Of_UML_Manifestation := (UML_Manifestation_Collections.Bag with null record); Empty_Sequence_Of_UML_Manifestation : constant Sequence_Of_UML_Manifestation := (UML_Manifestation_Collections.Sequence with null record); end AMF.UML.Manifestations.Collections;
jhumphry/auto_counters
Ada
1,817
ads
-- kvflyweights_hashtables_spec.ads -- A specification package that summarises the requirements for hashtables -- used in the KVFlyweights -- Copyright (c) 2016, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. pragma Profile (No_Implementation_Extensions); with Ada.Containers; generic type Key(<>) is private; type Key_Access is access Key; type Value_Access is private; type KVFlyweight is limited private; with procedure Insert (F : aliased in out KVFlyweight; Bucket : out Ada.Containers.Hash_Type; K : in Key; Key_Ptr : out Key_Access; Value_Ptr : out Value_Access); with procedure Increment (F : aliased in out KVFlyweight; Bucket : in Ada.Containers.Hash_Type; Key_Ptr : in Key_Access); with procedure Remove (F : in out KVFlyweight; Bucket : in Ada.Containers.Hash_Type; Key_Ptr : in Key_Access); package KVFlyweights_Hashtables_Spec is end KVFlyweights_Hashtables_Spec;
redparavoz/ada-wiki
Ada
6,526
ads
----------------------------------------------------------------------- -- wiki-render-html -- Wiki HTML renderer -- Copyright (C) 2011, 2012, 2013, 2015, 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 Wiki.Attributes; with Wiki.Streams.Html; with Wiki.Strings; with Wiki.Render.Links; -- == HTML Renderer == -- The <tt>Html_Renderer</tt> allows to render a wiki document into an HTML content. -- package Wiki.Render.Html is -- ------------------------------ -- Wiki to HTML renderer -- ------------------------------ type Html_Renderer is new Renderer with private; -- Set the output stream. procedure Set_Output_Stream (Engine : in out Html_Renderer; Stream : in Wiki.Streams.Html.Html_Output_Stream_Access); -- Set the link renderer. procedure Set_Link_Renderer (Engine : in out Html_Renderer; Links : in Wiki.Render.Links.Link_Renderer_Access); -- Set the render TOC flag that controls the TOC rendering. procedure Set_Render_TOC (Engine : in out Html_Renderer; State : in Boolean); -- Render the node instance from the document. overriding procedure Render (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Node : in Wiki.Nodes.Node_Type); -- Get the current section number. function Get_Section_Number (Engine : in Html_Renderer; Prefix : in Wiki.Strings.WString; Separator : in Wiki.Strings.WChar) return Wiki.Strings.WString; -- Add a blockquote (<blockquote>). The level indicates the blockquote nested level. -- The blockquote must be closed at the next header. procedure Add_Blockquote (Engine : in out Html_Renderer; Level : in Natural); -- Render a list item (<li>). Close the previous paragraph and list item if any. -- The list item will be closed at the next list item, next paragraph or next header. procedure Render_List_Item (Engine : in out Html_Renderer; Level : in Positive; Ordered : in Boolean); -- Add a text block with the given format. procedure Add_Text (Engine : in out Html_Renderer; Text : in Wiki.Strings.WString; Format : in Wiki.Format_Map); -- Render a text block that is pre-formatted. procedure Render_Preformatted (Engine : in out Html_Renderer; Text : in Wiki.Strings.WString; Format : in Wiki.Strings.WString); -- Finish the document after complete wiki text has been parsed. overriding procedure Finish (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document); private procedure Close_Paragraph (Engine : in out Html_Renderer); procedure Open_Paragraph (Engine : in out Html_Renderer); type Toc_Number_Array is array (1 .. 6) of Natural; type List_Style_Array is array (1 .. 32) of Boolean; Default_Links : aliased Wiki.Render.Links.Default_Link_Renderer; type Html_Renderer is new Renderer with record Output : Wiki.Streams.Html.Html_Output_Stream_Access := null; Format : Wiki.Format_Map := (others => False); Links : Wiki.Render.Links.Link_Renderer_Access := Default_Links'Access; Has_Paragraph : Boolean := False; Need_Paragraph : Boolean := False; Has_Item : Boolean := False; Enable_Render_TOC : Boolean := False; TOC_Rendered : Boolean := False; Current_Level : Natural := 0; Html_Tag : Wiki.Html_Tag := BODY_TAG; List_Styles : List_Style_Array := (others => False); Quote_Level : Natural := 0; Html_Level : Natural := 0; Current_Section : Toc_Number_Array := (others => 0); Section_Level : Natural := 0; end record; procedure Render_Tag (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Node : in Wiki.Nodes.Node_Type); -- Render a section header in the document. procedure Render_Header (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Header : in Wiki.Strings.WString; Level : in Positive); -- Render the table of content. procedure Render_TOC (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Level : in Natural); -- Render a link. procedure Render_Link (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Title : in Wiki.Strings.WString; Attr : in Wiki.Attributes.Attribute_List); -- Render an image. procedure Render_Image (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Title : in Wiki.Strings.WString; Attr : in Wiki.Attributes.Attribute_List); -- Render a quote. procedure Render_Quote (Engine : in out Html_Renderer; Doc : in Wiki.Documents.Document; Title : in Wiki.Strings.WString; Attr : in Wiki.Attributes.Attribute_List); -- Returns true if the HTML element being included is already contained in a paragraph. -- This include: a, em, strong, small, b, i, u, s, span, ins, del, sub, sup. function Has_Html_Paragraph (Engine : in Html_Renderer) return Boolean; end Wiki.Render.Html;
aherd2985/Amass
Ada
388
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 = "Riddler" type = "scrape" function start() setratelimit(1) end function vertical(ctx, domain) scrape(ctx, {url=buildurl(domain)}) end function buildurl(domain) return "https://riddler.io/search?q=pld:" .. domain end
apple-oss-distributions/old_ncurses
Ada
4,339
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; package body Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada is function Create (Set : Type_Set := Mixed_Case; Case_Sensitive : Boolean := False; Must_Be_Unique : Boolean := False) return Enumeration_Field is I : Enumeration_Info (T'Pos (T'Last) - T'Pos (T'First) + 1); J : Positive := 1; begin I.Case_Sensitive := Case_Sensitive; I.Match_Must_Be_Unique := Must_Be_Unique; for E in T'Range loop I.Names (J) := new String'(T'Image (T (E))); -- The Image attribute defaults to upper case, so we have to handle -- only the other ones... if Set /= Upper_Case then I.Names (J).all := To_Lower (I.Names (J).all); if Set = Mixed_Case then I.Names (J)(I.Names (J).all'First) := To_Upper (I.Names (J)(I.Names (J).all'First)); end if; end if; J := J + 1; end loop; return Create (I, True); end Create; function Value (Fld : Field; Buf : Buffer_Number := Buffer_Number'First) return T is begin return T'Value (Get_Buffer (Fld, Buf)); end Value; end Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada;
AdaCore/training_material
Ada
408
ads
package Pixels is Pixel_Bits : constant Positive := 8; type Pixel_Component_T is range 0 .. (2 ** Pixel_Bits) - 1; type Pixel_T is record R, G, B, A : Pixel_Component_T; end record; function "+" (A, B : Pixel_T) return Pixel_T; function Luminosity (P : Pixel_T) return Pixel_Component_T; -- Returns the pixel luminosity as the mean of its components end Pixels;
reznikmm/matreshka
Ada
3,832
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Style.Footnote_Max_Height is type Style_Footnote_Max_Height_Node is new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record; type Style_Footnote_Max_Height_Access is access all Style_Footnote_Max_Height_Node'Class; overriding function Get_Local_Name (Self : not null access constant Style_Footnote_Max_Height_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Style.Footnote_Max_Height;
BrickBot/Bound-T-H8-300
Ada
3,503
adb
-- Storage.Bounds.Get (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:51 $ -- -- $Log: storage-bounds-get.adb,v $ -- Revision 1.2 2015/10/24 20:05:51 niklas -- Moved to free licence. -- -- Revision 1.1 2013-02-03 12:37:03 niklas -- First version. -- with Arithmetic; package body Storage.Bounds.Get is function Interval_Value (From : String) return Interval_T is use Arithmetic; Min, Max : Limit_T; -- The limits of the interval, by default unlimited. Dot_Dot : Positive := From'Last + 1; -- The index in From of the first "." in the "..", if -- there is a "..", else this initial value. begin if From'Length = 0 then raise Constraint_Error; end if; -- Find the ".." if there is one: for D in From'First .. From'Last - 1 loop if From(D .. D + 1) = ".." then Dot_Dot := D; exit; end if; end loop; -- Take the Min value before the "..", or the single value -- if there is no "..": if Dot_Dot > From'First then -- We have something before the ".." (or there is no ".."). Min := Limit (Value_T'Value (From(From'First .. Dot_Dot - 1))); end if; -- Take the Max value after the "..", or use the single (Min) -- value if there is no "..": if Dot_Dot + 2 <= From'Last then -- We have something after the "..". Max := Limit (Value_T'Value (From(Dot_Dot + 2 .. From'Last))); elsif Dot_Dot > From'Last then -- No "..", singular value = Min. Max := Min; end if; return (Min, Max); end Interval_Value; end Storage.Bounds.Get;
rveenker/sdlada
Ada
21,918
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Ada.Unchecked_Conversion; with Interfaces; with Interfaces.C; with Interfaces.C.Strings; with SDL.Error; -- with SDL.Video.Surfaces.Makers; -- with SDL.Log; package body SDL.Video.Windows is package C renames Interfaces.C; use type Interfaces.Unsigned_32; use type C.int; use type SDL.C_Pointers.Windows_Pointer; use type System.Address; function Undefined_Window_Position (Display : Natural := 0) return SDL.Natural_Coordinate is Mask : constant Interfaces.Unsigned_32 := 16#1FFF_0000#; begin return C.int (Interfaces.Unsigned_32 (Display) or Mask); end Undefined_Window_Position; function Centered_Window_Position (Display : Natural := 0) return SDL.Natural_Coordinate is Mask : constant Interfaces.Unsigned_32 := 16#2FFF_0000#; begin return C.int (Interfaces.Unsigned_32 (Display) or Mask); end Centered_Window_Position; procedure Increment_Windows is begin Total_Windows_Created := Total_Windows_Created + 1; end Increment_Windows; procedure Decrement_Windows is begin Total_Windows_Created := Total_Windows_Created - 1; end Decrement_Windows; overriding procedure Finalize (Self : in out Window) is procedure SDL_Destroy (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_DestroyWindow"; begin -- SDL.Log.Put_Debug ("Windows.Finalize: " & (if Self.Internal = null then "null" else "not null") & -- " " & (if Self.Owns = True then "owns" else "Doesn't own")); -- Make sure we don't delete this twice! if Self.Internal /= null and then Self.Owns then -- SDL.Log.Put_Debug ("Windows.Finalize: Deleting"); SDL_Destroy (Self.Internal); Self.Internal := null; Decrement_Windows; end if; end Finalize; function Get_Brightness (Self : in Window) return Brightness is function SDL_Get_Brightness (W : in SDL.C_Pointers.Windows_Pointer) return C.C_float with Import => True, Convention => C, External_Name => "SDL_GetWindowBrightness"; begin return Brightness (SDL_Get_Brightness (Self.Internal)); end Get_Brightness; procedure Set_Brightness (Self : in out Window; How_Bright : in Brightness) is function SDL_Set_Brightness (W : in SDL.C_Pointers.Windows_Pointer; B : in C.C_float) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowBrightness"; Result : C.int := SDL_Set_Brightness (Self.Internal, C.C_float (How_Bright)); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Brightness; -- TODO: Try to see if we can just see User_Data_Access as the return type from the C function. function To_Data_Access is new Ada.Unchecked_Conversion (Source => System.Address, Target => User_Data_Access); function To_Address is new Ada.Unchecked_Conversion (Source => User_Data_Access, Target => System.Address); -- TODO: Make this and Set_Data generic. function Get_Data (Self : in Window; Name : in String) return User_Data_Access is function SDL_Get_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr) return System.Address with Import => True, Convention => C, External_Name => "SDL_GetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Item : User_Data_Access := To_Data_Access (SDL_Get_Window_Data (Self.Internal, C_Name_Str)); begin C.Strings.Free (C_Name_Str); return Item; end Get_Data; function Set_Data (Self : in out Window; Name : in String; Item : in User_Data_Access) return User_Data_Access is function SDL_Set_Window_Data (W : in SDL.C_Pointers.Windows_Pointer; Name : in C.Strings.chars_ptr; User_Data : in System.Address) return System.Address with Import => True, Convention => C, External_Name => "SDL_SetWindowData"; C_Name_Str : C.Strings.chars_ptr := C.Strings.New_String (Name); Previous_Data : User_Data_Access := To_Data_Access (SDL_Set_Window_Data (Self.Internal, C_Name_Str, To_Address (Item))); begin C.Strings.Free (C_Name_Str); return Previous_Data; end Set_Data; function Display_Index (Self : in Window) return SDL.Video.Displays.Display_Indices is function SDL_Get_Window_Display_Index (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayIndex"; Total : C.int := SDL_Get_Window_Display_Index (Self.Internal); begin if Total < 0 then raise Window_Error with SDL.Error.Get; end if; return SDL.Video.Displays.Display_Indices (Total + 1); end Display_Index; procedure Get_Display_Mode (Self : in Window; Mode : out SDL.Video.Displays.Mode) is function SDL_Get_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : out SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowDisplayMode"; Result : C.int := SDL_Get_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Display_Mode; procedure Set_Display_Mode (Self : in out Window; Mode : in SDL.Video.Displays.Mode) is function SDL_Set_Window_Display_Mode (W : in SDL.C_Pointers.Windows_Pointer; M : in SDL.Video.Displays.Mode) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowDisplayMode"; Result : C.int := SDL_Set_Window_Display_Mode (Self.Internal, Mode); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Display_Mode; function Get_Flags (Self : in Window) return Window_Flags is function SDL_Get_Window_Flags (W : in SDL.C_Pointers.Windows_Pointer) return Window_Flags with Import => True, Convention => C, External_Name => "SDL_GetWindowFlags"; begin return SDL_Get_Window_Flags (Self.Internal); end Get_Flags; function From_ID (Window_ID : in ID) return Window is function SDL_Get_Window_From_ID (W : in ID) return SDL.C_Pointers.Windows_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowFromID"; begin return W : constant Window := (Ada.Finalization.Limited_Controlled with Internal => SDL_Get_Window_From_ID (Window_ID), Owns => False) do null; end return; end From_ID; function From_Hwnd (Hwnd : Long_Integer) return Native_Window is function To_Address is new Ada.Unchecked_Conversion (Source => Long_Integer, Target => System.Address); begin return Native_Window (To_Address (Hwnd)); end From_Hwnd; procedure Get_Gamma_Ramp (Self : in Window; Red, Green, Blue : out SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Get_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : out SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_GetWindowGammaRamp"; Result : C.int := SDL_Get_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Get_Gamma_Ramp; procedure Set_Gamma_Ramp (Self : in out Window; Red, Green, Blue : in SDL.Video.Pixel_Formats.Gamma_Ramp) is function SDL_Set_Window_Gamma_Ramp (W : in SDL.C_Pointers.Windows_Pointer; R, G, B : in SDL.Video.Pixel_Formats.Gamma_Ramp) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowGammaRamp"; Result : C.int := SDL_Set_Window_Gamma_Ramp (Self.Internal, Red, Green, Blue); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Gamma_Ramp; function Is_Grabbed (Self : in Window) return Boolean is function SDL_Get_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer) return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_GetWindowGrab"; begin return (SDL_Get_Window_Grab (Self.Internal) = SDL_True); end Is_Grabbed; procedure Set_Grabbed (Self : in out Window; Grabbed : in Boolean := True) is procedure SDL_Set_Window_Grab (W : in SDL.C_Pointers.Windows_Pointer; G : in SDL_Bool) with Import => True, Convention => C, External_Name => "SDL_SetWindowGrab"; begin SDL_Set_Window_Grab (Self.Internal, (if Grabbed = True then SDL_True else SDL_False)); end Set_Grabbed; function Get_ID (Self : in Window) return ID is function SDL_Get_Window_ID (W : in SDL.C_Pointers.Windows_Pointer) return ID with Import => True, Convention => C, External_Name => "SDL_GetWindowID"; begin return SDL_Get_Window_ID (Self.Internal); end Get_ID; function Get_Maximum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMaximumSize"; W, H : C.int := 0; begin SDL_Get_Window_Maximum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Maximum_Size; procedure Set_Maximum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Maximum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMaximumSize"; begin SDL_Get_Window_Maximum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Maximum_Size; function Get_Minimum_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowMinimumSize"; W, H : C.int := 0; begin SDL_Get_Window_Minimum_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Minimum_Size; procedure Set_Minimum_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Minimum_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowMinimumSize"; begin SDL_Get_Window_Minimum_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Minimum_Size; function Pixel_Format (Self : in Window) return SDL.Video.Pixel_Formats.Pixel_Format is function SDL_Get_Window_Pixel_Format (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Pixel_Formats.Pixel_Format with Import => True, Convention => C, External_Name => "SDL_GetWindowPixelFormat"; begin return SDL_Get_Window_Pixel_Format (Self.Internal); end Pixel_Format; function Get_Position (Self : in Window) return SDL.Natural_Coordinates is procedure SDL_Get_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : out C.int) with Import => True, Convention => C, External_Name => "SDL_GetWindowPosition"; Position : SDL.Natural_Coordinates := SDL.Zero_Coordinate; begin SDL_Get_Window_Position (Self.Internal, Position.X, Position.Y); return Position; end Get_Position; procedure Set_Position (Self : in out Window; Position : SDL.Natural_Coordinates) is procedure SDL_Set_Window_Position (W : in SDL.C_Pointers.Windows_Pointer; X, Y : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowPosition"; begin SDL_Set_Window_Position (Self.Internal, Position.X, Position.Y); end Set_Position; function Get_Size (Self : in Window) return SDL.Sizes is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : out SDL.Dimension) with Import => True, Convention => C, External_Name => "SDL_GetWindowSize"; W, H : C.int := 0; begin SDL_Get_Window_Size (Self.Internal, W, H); return SDL.Sizes'(Width => W, Height => H); end Get_Size; procedure Set_Size (Self : in out Window; Size : in SDL.Sizes) is procedure SDL_Get_Window_Size (Win : in SDL.C_Pointers.Windows_Pointer; W, H : in C.int) with Import => True, Convention => C, External_Name => "SDL_SetWindowSize"; begin SDL_Get_Window_Size (Self.Internal, C.int (Size.Width), C.int (Size.Height)); end Set_Size; function Get_Surface (Self : in Window) return SDL.Video.Surfaces.Surface is function SDL_Get_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "SDL_GetWindowSurface"; use type SDL.Video.Surfaces.Internal_Surface_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer := SDL_Get_Window_Surface (Self.Internal); function Make_Surface_From_Pointer (S : in SDL.Video.Surfaces.Internal_Surface_Pointer) return SDL.Video.Surfaces.Surface with Convention => Ada, Import => True; begin if S = null then raise Window_Error with SDL.Error.Get; end if; return Make_Surface_From_Pointer (S); end Get_Surface; function Get_Title (Self : in Window) return Ada.Strings.UTF_Encoding.UTF_8_String is function SDL_Get_Window_Title (W : in SDL.C_Pointers.Windows_Pointer) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetWindowTitle"; begin return C.Strings.Value (SDL_Get_Window_Title (Self.Internal)); end Get_Title; procedure Set_Title (Self : in Window; Title : in Ada.Strings.UTF_Encoding.UTF_8_String) is procedure SDL_Set_Window_Title (W : in SDL.C_Pointers.Windows_Pointer; C_Str : in C.char_array) with Import => True, Convention => C, External_Name => "SDL_SetWindowTitle"; begin SDL_Set_Window_Title (Self.Internal, C.To_C (Title)); end Set_Title; procedure Hide (Self : in Window) is procedure SDL_Hide_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_HideWindow"; begin SDL_Hide_Window (Self.Internal); end Hide; procedure Show (Self : in Window) is procedure SDL_Show_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_ShowWindow"; begin SDL_Show_Window (Self.Internal); end Show; procedure Maximise (Self : in Window) is procedure SDL_Maximise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MaximizeWindow"; begin SDL_Maximise_Window (Self.Internal); end Maximise; procedure Minimise (Self : in Window) is procedure SDL_Minimise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_MinimizeWindow"; begin SDL_Minimise_Window (Self.Internal); end Minimise; procedure Raise_And_Focus (Self : in Window) is procedure SDL_Raise_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RaiseWindow"; begin SDL_Raise_Window (Self.Internal); end Raise_And_Focus; procedure Restore (Self : in Window) is procedure SDL_Restore_Window (W : in SDL.C_Pointers.Windows_Pointer) with Import => True, Convention => C, External_Name => "SDL_RestoreWindow"; begin SDL_Restore_Window (Self.Internal); end Restore; procedure Set_Mode (Self : in out Window; Flags : in Full_Screen_Flags) is function SDL_Window_Full_Screen (W : in SDL.C_Pointers.Windows_Pointer; F : in Full_Screen_Flags) return C.int with Import => True, Convention => C, External_Name => "SDL_SetWindowFullscreen"; Result : C.int := SDL_Window_Full_Screen (Self.Internal, Flags); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Set_Mode; procedure Set_Icon (Self : in out Window; Icon : in SDL.Video.Surfaces.Surface) is procedure SDL_Set_Window_Icon (W : in SDL.C_Pointers.Windows_Pointer; S : SDL.Video.Surfaces.Internal_Surface_Pointer) with Import => True, Convention => C, External_Name => "SDL_SetWindowIcon"; function Get_Internal_Surface (Self : in SDL.Video.Surfaces.Surface) return SDL.Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => Ada; begin SDL_Set_Window_Icon (Self.Internal, Get_Internal_Surface (Icon)); end Set_Icon; procedure Update_Surface (Self : in Window) is function SDL_Update_Window_Surface (W : in SDL.C_Pointers.Windows_Pointer) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurface"; Result : C.int := SDL_Update_Window_Surface (Self.Internal); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface; procedure Update_Surface_Rectangle (Self : in Window; Rectangle : in SDL.Video.Rectangles.Rectangle) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangle, 1); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangle; procedure Update_Surface_Rectangles (Self : in Window; Rectangles : SDL.Video.Rectangles.Rectangle_Arrays) is function SDL_Update_Window_Surface_Rects (W : in SDL.C_Pointers.Windows_Pointer; R : in SDL.Video.Rectangles.Rectangle_Arrays; L : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_UpdateWindowSurfaceRects"; Result : C.int := SDL_Update_Window_Surface_Rects (Self.Internal, Rectangles, Rectangles'Length); begin if Result /= Success then raise Window_Error with SDL.Error.Get; end if; end Update_Surface_Rectangles; function Exist return Boolean is begin return Total_Windows_Created /= Natural'First; end Exist; function Get_Internal_Window (Self : in Window) return SDL.C_Pointers.Windows_Pointer is begin return Self.Internal; end Get_Internal_Window; end SDL.Video.Windows;
peterfrankjohnson/kernel
Ada
30
ads
package Device is end Device;
charlie5/cBound
Ada
1,530
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_get_atom_name_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; atom : aliased xcb.xcb_atom_t; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_get_atom_name_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_get_atom_name_request_t.Item, Element_Array => xcb.xcb_get_atom_name_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_get_atom_name_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_get_atom_name_request_t.Pointer, Element_Array => xcb.xcb_get_atom_name_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_get_atom_name_request_t;
reznikmm/matreshka
Ada
4,051
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Style_Next_Style_Name_Attributes; package Matreshka.ODF_Style.Next_Style_Name_Attributes is type Style_Next_Style_Name_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Next_Style_Name_Attributes.ODF_Style_Next_Style_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Next_Style_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Next_Style_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Next_Style_Name_Attributes;
stcarrez/ada-keystore
Ada
7,232
ads
----------------------------------------------------------------------- -- keystore-passwords-gpg -- Password protected by GPG -- Copyright (C) 2019, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; with Ada.Strings.Unbounded; with Ada.Finalization; with Util.Strings.Sets; with Keystore.Files; with Keystore.Passwords.Keys; private with Keystore.IO; package Keystore.Passwords.GPG is MAX_ENCRYPT_SIZE : constant := 1024; LIST_COMMAND : constant String := "gpg --list-secret-keys --with-colons --with-fingerprint"; ENCRYPT_COMMAND : constant String := "gpg --encrypt --batch --yes -r $USER"; DECRYPT_COMMAND : constant String := "gpg --decrypt --batch --yes --quiet"; -- Extract the Key ID from the data content when it is encrypted by GPG2. function Extract_Key_Id (Data : in Ada.Streams.Stream_Element_Array) return String; type Context_Type is limited new Ada.Finalization.Limited_Controlled and Slot_Provider and Keys.Key_Provider with private; -- Get the list of GPG secret keys that could be capable for decrypting a content for us. procedure List_GPG_Secret_Keys (Context : in out Context_Type; List : in out Util.Strings.Sets.Set); -- Create a secret to protect the keystore. procedure Create_Secret (Context : in out Context_Type); procedure Create_Secret (Context : in out Context_Type; Image : in Context_Type'Class); procedure Create_Secret (Context : in out Context_Type; Key_Provider : in Keys.Key_Provider'Class); -- Save the GPG secret by encrypting it using the user's GPG key and storing -- the encrypted data in the keystore data header. procedure Save_Secret (Context : in out Context_Type; User : in String; Index : in Keystore.Header_Slot_Index_Type; Wallet : in out Keystore.Files.Wallet_File); -- Load the GPG secrets stored in the keystore header. procedure Load_Secrets (Context : in out Context_Type; Wallet : in out Keystore.Files.Wallet_File); -- Get the password through the Getter operation. overriding procedure Get_Password (From : in Context_Type; Getter : not null access procedure (Password : in Secret_Key)); -- Get the key slot number associated with the GPG password. overriding function Get_Tag (From : in Context_Type) return Tag_Type; -- Returns true if the provider has a GPG password. overriding function Has_Password (From : in Context_Type) return Boolean; -- Move to the next GPG password. overriding procedure Next (From : in out Context_Type); -- Get the key and IV through the Getter operation. overriding procedure Get_Key (From : in Context_Type; Getter : not null access procedure (Key : in Secret_Key; IV : in Secret_Key)); -- Get the Key, IV and signature. overriding procedure Get_Keys (From : in Context_Type; Key : out Secret_Key; IV : out Secret_Key; Sign : out Secret_Key); -- Setup the command to be executed to encrypt the secret with GPG2. procedure Set_Encrypt_Command (Into : in out Context_Type; Command : in String); -- Setup the command to be executed to decrypt the secret with GPG2. procedure Set_Decrypt_Command (Into : in out Context_Type; Command : in String); -- Setup the command to be executed to get the list of available GPG secret keys. procedure Set_List_Key_Command (Into : in out Context_Type; Command : in String); private type Secret_Provider; type Secret_Provider_Access is access all Secret_Provider; type Secret_Provider is limited record Next : Secret_Provider_Access; Tag : Tag_Type; Key : Secret_Key (Length => IO.SIZE_SECRET); IV : Secret_Key (Length => IO.SIZE_IV); end record; -- Positions of values stored in the GPG encrypted data. POS_TAG : constant := 1; POS_TAG_LAST : constant := POS_TAG + 3; POS_LOCK_KEY : constant := POS_TAG_LAST + 1; POS_LOCK_KEY_LAST : constant := POS_LOCK_KEY + IO.SIZE_SECRET - 1; POS_LOCK_IV : constant := POS_LOCK_KEY_LAST + 1; POS_LOCK_IV_LAST : constant := POS_LOCK_IV + IO.SIZE_IV - 1; POS_WALLET_KEY : constant := POS_LOCK_IV_LAST + 1; POS_WALLET_KEY_LAST : constant := POS_WALLET_KEY + IO.SIZE_SECRET - 1; POS_WALLET_IV : constant := POS_WALLET_KEY_LAST + 1; POS_WALLET_IV_LAST : constant := POS_WALLET_IV + IO.SIZE_IV - 1; POS_WALLET_SIGN : constant := POS_WALLET_IV_LAST + 1; POS_WALLET_SIGN_LAST : constant := POS_WALLET_SIGN + IO.SIZE_SECRET - 1; GPG_DATA_SIZE : constant := 4 + IO.SIZE_SECRET * 3 + IO.SIZE_IV * 2; HEADER_KEY_SIZE : constant := IO.SIZE_SECRET + IO.SIZE_IV + IO.SIZE_SECRET; type Context_Type is limited new Ada.Finalization.Limited_Controlled and Slot_Provider and Keys.Key_Provider with record Current : Secret_Provider_Access; First : Secret_Provider_Access; Data : Ada.Streams.Stream_Element_Array (1 .. GPG_DATA_SIZE); Size : Ada.Streams.Stream_Element_Offset; Index : Keystore.Header_Slot_Index_Type := 1; Encrypt_Command : Ada.Strings.Unbounded.Unbounded_String; Decrypt_Command : Ada.Strings.Unbounded.Unbounded_String; List_Key_Command : Ada.Strings.Unbounded.Unbounded_String; Valid_Key : Boolean := False; end record; procedure Create_Secret (Context : in out Context_Type; Data : in Ada.Streams.Stream_Element_Array); procedure Decrypt_GPG_Secret (Context : in out Context_Type; Data : in Ada.Streams.Stream_Element_Array); -- Get the command to encrypt the secret for the given GPG user/keyid. function Get_Encrypt_Command (Context : in Context_Type; User : in String) return String; overriding procedure Initialize (Context : in out Context_Type); overriding procedure Finalize (Context : in out Context_Type); end Keystore.Passwords.GPG;
skill-lang/adaCommon
Ada
1,910
ads
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ stream manipulation package -- -- |___/_|\_\_|_|____| by: Timm Felden, Dennis Przytarski -- -- -- pragma Ada_2012; with Interfaces.C; with Interfaces.C.Pointers; with Skill.Types; limited with Skill.Streams.Reader; limited with Skill.Streams.Writer; with Interfaces.C_Streams; package Skill.Streams is type Unsigned_Char_Array is array (Interfaces.C.size_t range <>) of aliased Interfaces.C.unsigned_char; pragma Convention (C, Unsigned_Char_Array); for Unsigned_Char_Array'Component_Size use Interfaces.C.unsigned_char'Size; function Input (Path : Skill.Types.String_Access) return Skill.Streams.Reader.Input_Stream; function Write (Path : Skill.Types.String_Access) return Skill.Streams.Writer.Output_Stream; function Append (Path : Skill.Types.String_Access) return Skill.Streams.Writer.Output_Stream; private package C renames Interfaces.C; type Uchar_Array is array (C.size_t range <>) of aliased C.unsigned_char; package Uchar is new C.Pointers (Index => C.size_t, Element => C.unsigned_char, Element_Array => Uchar_Array, Default_Terminator => 0); subtype Map_Pointer is not null Uchar.Pointer; -- returns an invalid map pointer, that can be used in empty maps function Invalid_Pointer return Map_Pointer; pragma Inline (Invalid_Pointer); pragma Pure_Function (Invalid_Pointer); type Mmap is record File : Interfaces.C_Streams.FILEs; Length : Interfaces.C.size_t; Map : Uchar.Pointer; end record; end Skill.Streams;
burratoo/Acton
Ada
14,404
ads
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- FREESCALE MPC5544 -- -- -- -- MPC5554.EQADC -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with System; with System.Storage_Elements; use System.Storage_Elements; package MPC5554.eQADC with Preelaborate is ---------------------------------------------------------------------------- -- Memory Addresses ---------------------------------------------------------------------------- eQADC_Base_Address : constant Integer_Address := 16#FFF8_0000#; MCR_Offset_Address : constant Integer_Address := 16#0000#; NMSFR_Offset_Address : constant Integer_Address := 16#0008#; ETDFR_Offset_Address : constant Integer_Address := 16#000C#; CFPR_Offset_Address : constant Integer_Address := 16#0010#; RFPR_Offset_Address : constant Integer_Address := 16#0030#; CFCR_Offset_Address : constant Integer_Address := 16#0050#; IDCR_Offset_Address : constant Integer_Address := 16#0060#; FISR_Offset_Address : constant Integer_Address := 16#0070#; CFTCR_Offset_Address : constant Integer_Address := 16#0090#; CFSSR_Offset_Address : constant Integer_Address := 16#00A0#; CFSR_Offset_Address : constant Integer_Address := 16#00AC#; SSICR_Offset_Address : constant Integer_Address := 16#00B4#; SSIRDR_Offset_Address : constant Integer_Address := 16#00B8#; CF_Offset_Address : constant Integer_Address := 16#0100#; RF_Offset_Address : constant Integer_Address := 16#0300#; ---------------------------------------------------------------------------- -- Hardware Features ---------------------------------------------------------------------------- type FIFO_ID_Register is mod 2 ** 4; Number_Of_FIFOs : constant FIFO_ID_Register := 6; subtype FIFO_ID is FIFO_ID_Register range 0 .. Number_Of_FIFOs; Number_Of_ADCs : constant Integer := 3; type ADC_ID is mod Number_Of_ADCs; ---------------------------------------------------------------------------- -- eQADC Types --------------------------------------------------------------------------- -- Common Types type External_Device_Message is mod 2 ** 26; type eQADC_Data is mod 2 ** 32; type eQADC_Command is mod 2 ** 32; type eQADC_Counter is mod 2 ** 4; type eQADC_Pointer is mod 2 ** 4; type CFIFO_Status is (Idle, Waiting, Triggered); type Select_Type is (Interrupt, eDMA); for Select_Type use (Interrupt => 0, eDMA => 1); -- eQADC Module Configuration Register (EQADC_MCR) type eQADC_Enable_Type is ( SSI_Disable, SSI_Enable_Trans_Disable, SSI_Enable_Trans_Enable); type Debug_Type is (Do_Not_Enter, Enter_FCK_Stop, Enter_FCK_Run); type Module_Configuration_Type is record Synchronous_Serial_Interface : eQADC_Enable_Type; Debug : Debug_Type; end record; -- eQADC External Trigger Digital Filter Register (EQADC_ETDFR) type External_Trigger_Digital_Filter_Type is mod 2 ** 4; -- eQADC CFIFO Control Registers 0-5 (EQADC_CFCRn) type Invalidate_Type is (Do_Nothing, Invalidate); type Operation_Mode_Type is ( Disable, Software_Trigger_Single_Scan, Low_Level_Gated_External_Trigger_Single_Scan, High_Level_Gated_External_Trigger_Single_Scan, Falling_Edge_External_Trigger_Single_Scan, Rising_Edge_External_Trigger_Single_Scan, Edge_External_Trigger_Single_Scan, Software_Trigger_Continuous_Scan, Low_Level_Gated_External_Trigger_Continuous_Scan, High_Level_Gated_External_Trigger_Continuous_Scan, Falling_Edge_External_Trigger_Continuous_Scan, Rising_Edge_External_Trigger_Continuous_Scan, Edge_External_Trigger_Continuous_Scan); type CFIFO_Control_Type is record Single_Scan : Enable_Type; Invalidate : Invalidate_Type; Operation_Mode : Operation_Mode_Type; end record; -- eQADC Interrupt and eDMA Control Registers 0-5 (EQADC_IDCRn) type Interrupt_eDMA_Control_Type is record Non_Coherency_Interrupt : Enable_Type; Trigger_Overrun_Interrupt : Enable_Type; Paused_Interrupt : Enable_Type; End_Of_Queue_Interrupt : Enable_Type; CFIFO_Underflow_Interrupt : Enable_Type; CFIFO_Fill : Enable_Type; CFIFO_Fill_Select : Select_Type; RFIFO_Overflow_Interrupt : Enable_Type; RFIFO_Drain : Enable_Type; RFIFO_Drain_Select : Select_Type; end record; -- eQADC FIFO and Interrupt Status Registers 0-5 (EQADC_IDCRn) type FIFO_Interrupt_Status_Type is record Non_Coherency_Flag : Occurred_Type; Trigger_Overrun_Flag : Occurred_Type; Pause_Flag : Occurred_Type; End_Of_Queue_Flag : Occurred_Type; CFIFO_Underflow_Flag : Occurred_Type; CFIFO_Single_Scan_Status_Bit : Enable_Type; CFIFO_Fill_Flag : Occurred_Type; RFIFO_Overflow_Flag : Occurred_Type; RFIFO_Drain_Flag : Occurred_Type; CFIFO_Entry_Counter : eQADC_Counter; CFIFO_Transfer_Next_Pointer : eQADC_Pointer; RFIFO_Entry_Counter : eQADC_Counter; RFIFO_Pop_Next_Pointer : eQADC_Pointer; end record; type Transfer_Counter is mod 2 ** 11; -- eQADC CFIFO Status Snapshot Registers 0-2 (EQADC_CFSSRn) No_Command : constant FIFO_ID_Register := 2#1111#; type CFIFO_Status_Snapshot_Type is record CFIFO_0_Status : CFIFO_Status; CFIFO_1_Status : CFIFO_Status; CFIFO_2_Status : CFIFO_Status; CFIFO_3_Status : CFIFO_Status; CFIFO_4_Status : CFIFO_Status; CFIFO_5_Status : CFIFO_Status; Last_CFIFO_To_Transfer : FIFO_ID_Register; Transfer_Counter_For_Last_CFIFO_Transfer : eQADC_Counter; end record; -- eQADC CFIFO_Status_Register (EQADC_CFSR) type CFIFO_Status_Type is record CFIFO_0_Status : CFIFO_Status; CFIFO_1_Status : CFIFO_Status; CFIFO_2_Status : CFIFO_Status; CFIFO_3_Status : CFIFO_Status; CFIFO_4_Status : CFIFO_Status; CFIFO_5_Status : CFIFO_Status; end record; -- eQADC SSI Control Register (EQADC_SSICR) type Delay_Type is mod 2 ** 3; type Buad_Type is mod 2 ** 4; type SSI_Control_Type is record Min_Delay_After_Transmission : Delay_Type; Buad_Rate : Buad_Type; end record; ---------------------------------------------------------------------------- -- Hardware Respresentations ---------------------------------------------------------------------------- for eQADC_Enable_Type use (SSI_Disable => 2#00#, SSI_Enable_Trans_Disable => 2#10#, SSI_Enable_Trans_Enable => 2#11#); for Debug_Type use (Do_Not_Enter => 2#00#, Enter_FCK_Stop => 2#10#, Enter_FCK_Run => 2#11#); for CFIFO_Status use (Idle => 2#00#, Waiting => 2#10#, Triggered => 2#11#); for Module_Configuration_Type use record Synchronous_Serial_Interface at 0 range 27 .. 28; Debug at 0 range 30 .. 31; end record; for Invalidate_Type use (Do_Nothing => 0, Invalidate => 1); for Operation_Mode_Type use (Disable => 2#0000#, Software_Trigger_Single_Scan => 2#0001#, Low_Level_Gated_External_Trigger_Single_Scan => 2#0010#, High_Level_Gated_External_Trigger_Single_Scan => 2#0011#, Falling_Edge_External_Trigger_Single_Scan => 2#0100#, Rising_Edge_External_Trigger_Single_Scan => 2#0101#, Edge_External_Trigger_Single_Scan => 2#0110#, Software_Trigger_Continuous_Scan => 2#1001#, Low_Level_Gated_External_Trigger_Continuous_Scan => 2#1010#, High_Level_Gated_External_Trigger_Continuous_Scan => 2#1011#, Falling_Edge_External_Trigger_Continuous_Scan => 2#1100#, Rising_Edge_External_Trigger_Continuous_Scan => 2#1101#, Edge_External_Trigger_Continuous_Scan => 2#1110#); for CFIFO_Control_Type use record Single_Scan at 0 range 5 .. 5; Invalidate at 0 range 6 .. 6; Operation_Mode at 0 range 8 .. 11; end record; for Interrupt_eDMA_Control_Type use record Non_Coherency_Interrupt at 0 range 0 .. 0; Trigger_Overrun_Interrupt at 0 range 1 .. 1; Paused_Interrupt at 0 range 2 .. 2; End_Of_Queue_Interrupt at 0 range 3 .. 3; CFIFO_Underflow_Interrupt at 0 range 4 .. 4; CFIFO_Fill at 0 range 6 .. 6; CFIFO_Fill_Select at 0 range 7 .. 7; RFIFO_Overflow_Interrupt at 0 range 12 .. 12; RFIFO_Drain at 0 range 14 .. 14; RFIFO_Drain_Select at 0 range 15 .. 15; end record; for FIFO_Interrupt_Status_Type use record Non_Coherency_Flag at 0 range 0 .. 0; Trigger_Overrun_Flag at 0 range 1 .. 1; Pause_Flag at 0 range 2 .. 2; End_Of_Queue_Flag at 0 range 3 .. 3; CFIFO_Underflow_Flag at 0 range 4 .. 4; CFIFO_Single_Scan_Status_Bit at 0 range 5 .. 5; CFIFO_Fill_Flag at 0 range 6 .. 6; RFIFO_Overflow_Flag at 0 range 12 .. 12; RFIFO_Drain_Flag at 0 range 14 .. 14; CFIFO_Entry_Counter at 0 range 16 .. 19; CFIFO_Transfer_Next_Pointer at 0 range 20 .. 23; RFIFO_Entry_Counter at 0 range 24 .. 27; RFIFO_Pop_Next_Pointer at 0 range 28 .. 31; end record; for CFIFO_Status_Snapshot_Type use record CFIFO_0_Status at 0 range 0 .. 1; CFIFO_1_Status at 0 range 2 .. 3; CFIFO_2_Status at 0 range 4 .. 5; CFIFO_3_Status at 0 range 6 .. 7; CFIFO_4_Status at 0 range 8 .. 9; CFIFO_5_Status at 0 range 10 .. 11; Last_CFIFO_To_Transfer at 0 range 17 .. 20; Transfer_Counter_For_Last_CFIFO_Transfer at 0 range 21 .. 31; end record; for CFIFO_Status_Type use record CFIFO_0_Status at 0 range 0 .. 1; CFIFO_1_Status at 0 range 2 .. 3; CFIFO_2_Status at 0 range 4 .. 5; CFIFO_3_Status at 0 range 6 .. 7; CFIFO_4_Status at 0 range 8 .. 9; CFIFO_5_Status at 0 range 10 .. 11; end record; for SSI_Control_Type use record Min_Delay_After_Transmission at 0 range 21 .. 23; Buad_Rate at 0 range 28 .. 31; end record; ---------------------------------------------------------------------------- -- eQADC Registers ---------------------------------------------------------------------------- pragma Warnings (Off, "*alignment*"); Module_Control_Register : Module_Configuration_Type; for Module_Control_Register'Address use System'To_Address (eQADC_Base_Address + MCR_Offset_Address); Null_Message_Send_Format_Register : External_Device_Message; for Null_Message_Send_Format_Register'Address use System'To_Address (eQADC_Base_Address + NMSFR_Offset_Address); External_Trigger_Digital_Filter_Register : External_Trigger_Digital_Filter_Type; for External_Trigger_Digital_Filter_Register'Address use System'To_Address (eQADC_Base_Address + ETDFR_Offset_Address); Command_FIFO_Push_Registers : array (FIFO_ID) of aliased eQADC_Command; for Command_FIFO_Push_Registers'Address use System'To_Address (eQADC_Base_Address + CFPR_Offset_Address); Result_FIFO_Push_Registers : array (FIFO_ID) of aliased eQADC_Data; for Result_FIFO_Push_Registers'Address use System'To_Address (eQADC_Base_Address + RFPR_Offset_Address); Command_FIFO_Control_Registers : array (FIFO_ID) of aliased CFIFO_Control_Type; for Command_FIFO_Control_Registers'Address use System'To_Address (eQADC_Base_Address + CFCR_Offset_Address); Interrupt_eDMA_Control_Registers : array (FIFO_ID) of aliased Interrupt_eDMA_Control_Type; for Interrupt_eDMA_Control_Registers'Address use System'To_Address (eQADC_Base_Address + IDCR_Offset_Address); FIFO_Interrupt_Status_Registers : array (FIFO_ID) of aliased FIFO_Interrupt_Status_Type; for FIFO_Interrupt_Status_Registers'Address use System'To_Address (eQADC_Base_Address + FISR_Offset_Address); CFIFO_Transfer_Counter_Registers : array (FIFO_ID) of aliased Transfer_Counter; for CFIFO_Transfer_Counter_Registers'Address use System'To_Address (eQADC_Base_Address + CFTCR_Offset_Address); CFIFO_Status_Snapshot_Registers : array (FIFO_ID) of aliased CFIFO_Status_Snapshot_Type; for CFIFO_Status_Snapshot_Registers'Address use System'To_Address (eQADC_Base_Address + CFSSR_Offset_Address); CFIFO_Status_Register : CFIFO_Status_Type; for CFIFO_Status_Register'Address use System'To_Address (eQADC_Base_Address + CFSR_Offset_Address); SSI_Control_Register : SSI_Control_Type; for SSI_Control_Register'Address use System'To_Address (eQADC_Base_Address + SSICR_Offset_Address); SSI_Receive_Data_Register : External_Device_Message; for SSI_Receive_Data_Register'Address use System'To_Address (eQADC_Base_Address + SSIRDR_Offset_Address); end MPC5554.eQADC;
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_Start_Value_Attributes; package Matreshka.ODF_Text.Start_Value_Attributes is type Text_Start_Value_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Start_Value_Attributes.ODF_Text_Start_Value_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Start_Value_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Start_Value_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Start_Value_Attributes;
reznikmm/matreshka
Ada
3,973
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.Config_Name_Attributes; package Matreshka.ODF_Config.Name_Attributes is type Config_Name_Attribute_Node is new Matreshka.ODF_Config.Abstract_Config_Attribute_Node and ODF.DOM.Config_Name_Attributes.ODF_Config_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Config_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Config_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Config.Name_Attributes;
onox/json-ada
Ada
3,349
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Command_Line; with Ada.Strings.Fixed; with Ada.Text_IO; with JSON.Types; with JSON.Parsers; procedure Pretty_Print is package ACL renames Ada.Command_Line; package TIO renames Ada.Text_IO; package Types is new JSON.Types (Long_Integer, Long_Float); package Parsers is new JSON.Parsers (Types); type Indent_Type is range 2 .. 8; procedure Print (Value : Types.JSON_Value; Indent : Indent_Type := 4; Level : Positive := 1) is use all type Types.Value_Kind; use Ada.Strings.Fixed; Index : Positive := 1; Spaces : constant Natural := Natural (Indent); begin case Value.Kind is when Object_Kind => if Value.Length > 0 then Ada.Text_IO.Put_Line ("{"); for E of Value loop if Index > 1 then Ada.Text_IO.Put_Line (","); end if; -- Print key and element Ada.Text_IO.Put (Spaces * Level * ' ' & E.Image & ": "); Print (Value (E.Value), Indent, Level + 1); Index := Index + 1; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "}"); else Ada.Text_IO.Put ("{}"); end if; when Array_Kind => if Value.Length > 0 then Ada.Text_IO.Put_Line ("["); for E of Value loop if Index > 1 then Ada.Text_IO.Put_Line (","); end if; -- Print element Ada.Text_IO.Put (Spaces * Level * ' '); Print (E, Indent, Level + 1); Index := Index + 1; end loop; Ada.Text_IO.New_Line; Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "]"); else Ada.Text_IO.Put ("[]"); end if; when others => Ada.Text_IO.Put (Value.Image); end case; end Print; File_Only : constant Boolean := ACL.Argument_Count = 1; Is_Quiet : constant Boolean := ACL.Argument_Count = 2 and then ACL.Argument (1) = "-q"; begin if not (File_Only or Is_Quiet) then TIO.Put_Line ("Usage: [-q] <path to .json file>"); ACL.Set_Exit_Status (ACL.Failure); return; end if; declare Parser : Parsers.Parser := Parsers.Create_From_File (ACL.Argument (ACL.Argument_Count)); Value : constant Types.JSON_Value := Parser.Parse; begin if not Is_Quiet then Print (Value, Indent => 4); end if; end; end Pretty_Print;
zhmu/ananas
Ada
1,558
ads
with Vect1_Pkg; package Vect1 is -- Unconstrained array types are vectorizable, possibly with special -- help for the programmer type Varray is array (Integer range <>) of Long_Float; for Varray'Alignment use 16; function "+" (X, Y : Varray) return Varray; procedure Add (X, Y : Varray; R : out Varray); procedure Add (X, Y : not null access Varray; R : not null access Varray); -- Constrained array types are vectorizable type Sarray is array (1 .. 4) of Long_Float; for Sarray'Alignment use 16; function "+" (X, Y : Sarray) return Sarray; procedure Add (X, Y : Sarray; R : out Sarray); procedure Add (X, Y : not null access Sarray; R : not null access Sarray); type Darray1 is array (1 .. Vect1_Pkg.N) of Long_Float; for Darray1'Alignment use 16; function "+" (X, Y : Darray1) return Darray1; procedure Add (X, Y : Darray1; R : out Darray1); procedure Add (X, Y : not null access Darray1; R : not null access Darray1); type Darray2 is array (Vect1_Pkg.K .. 4) of Long_Float; for Darray2'Alignment use 16; function "+" (X, Y : Darray2) return Darray2; procedure Add (X, Y : Darray2; R : out Darray2); procedure Add (X, Y : not null access Darray2; R : not null access Darray2); type Darray3 is array (Vect1_Pkg.K .. Vect1_Pkg.N) of Long_Float; for Darray3'Alignment use 16; function "+" (X, Y : Darray3) return Darray3; procedure Add (X, Y : Darray3; R : out Darray3); procedure Add (X, Y : not null access Darray3; R : not null access Darray3); end Vect1;
rveenker/sdlada
Ada
128
adb
package body Maths is function Add (A, B : in Integer) return Integer is begin return A + B; end Add; end Maths;
reznikmm/matreshka
Ada
6,840
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Connector_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Connector_Element_Node is begin return Self : Draw_Connector_Element_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Draw_Connector_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Draw_Connector (ODF.DOM.Draw_Connector_Elements.ODF_Draw_Connector_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Connector_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Connector_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Draw_Connector_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Draw_Connector (ODF.DOM.Draw_Connector_Elements.ODF_Draw_Connector_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Draw_Connector_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Draw_Connector (Visitor, ODF.DOM.Draw_Connector_Elements.ODF_Draw_Connector_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Connector_Element, Draw_Connector_Element_Node'Tag); end Matreshka.ODF_Draw.Connector_Elements;
reznikmm/matreshka
Ada
3,780
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.Data_Types; package AMF.OCL.Tuple_Types is pragma Preelaborate; type OCL_Tuple_Type is limited interface and AMF.UML.Data_Types.UML_Data_Type; type OCL_Tuple_Type_Access is access all OCL_Tuple_Type'Class; for OCL_Tuple_Type_Access'Storage_Size use 0; end AMF.OCL.Tuple_Types;
AdaCore/gpr
Ada
63
ads
with Toto; package Whatever is procedure Me; end Whatever;
osannolik/ada-canopen
Ada
2,738
ads
with Ada.Finalization; with ACO.CANopen; with ACO.States; with ACO.Messages; with ACO.OD; with ACO.OD_Types; private with Ada.Real_Time; private with ACO.Events; package ACO.Nodes is type Node_Base (Id : ACO.Messages.Node_Nr; Handler : not null access ACO.CANopen.Handler; Od : not null access ACO.OD.Object_Dictionary'Class) is abstract new Ada.Finalization.Limited_Controlled with private; procedure Set_State (This : in out Node_Base; State : in ACO.States.State) is abstract; -- Local: Set state in OD, maybe send boot -- Remote: Set state in OD, send nmt command to node id of remote function Get_State (This : Node_Base) return ACO.States.State is abstract; -- Local: Get state from OD -- Remote: Get state from OD procedure Start (This : in out Node_Base) is abstract; procedure Write (This : in out Node_Base; Index : in ACO.OD_Types.Object_Index; Subindex : in ACO.OD_Types.Object_Subindex; An_Entry : in ACO.OD_Types.Entry_Base'Class) is abstract; procedure Read (This : in out Node_Base; Index : in ACO.OD_Types.Object_Index; Subindex : in ACO.OD_Types.Object_Subindex; To_Entry : out ACO.OD_Types.Entry_Base'Class) is abstract; private procedure On_Message_Dispatch (This : in out Node_Base; Msg : in ACO.Messages.Message) is null; procedure Periodic_Actions (This : in out Node_Base; T_Now : in Ada.Real_Time.Time) is null; type Tick_Subscriber (Node_Ref : not null access Node_Base'Class) is new ACO.Events.Handler_Event_Listener (ACO.Events.Tick) with null record; overriding procedure On_Event (This : in out Tick_Subscriber; Data : in ACO.Events.Handler_Event_Data); type Message_Subscriber (Node_Ref : not null access Node_Base'Class) is new ACO.Events.Handler_Event_Listener (ACO.Events.Received_Message) with null record; overriding procedure On_Event (This : in out Message_Subscriber; Data : in ACO.Events.Handler_Event_Data); type Node_Base (Id : ACO.Messages.Node_Nr; Handler : not null access ACO.CANopen.Handler; Od : not null access ACO.OD.Object_Dictionary'Class) is abstract new Ada.Finalization.Limited_Controlled with record Periodic_Action_Indication : aliased Tick_Subscriber (Node_Base'Access); New_Message_Indication : aliased Message_Subscriber (Node_Base'Access); end record; overriding procedure Initialize (This : in out Node_Base); overriding procedure Finalize (This : in out Node_Base); end ACO.Nodes;
reznikmm/matreshka
Ada
5,594
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.Standard_Profile_L2.Model_Libraries.Collections is pragma Preelaborate; package Standard_Profile_L2_Model_Library_Collections is new AMF.Generic_Collections (Standard_Profile_L2_Model_Library, Standard_Profile_L2_Model_Library_Access); type Set_Of_Standard_Profile_L2_Model_Library is new Standard_Profile_L2_Model_Library_Collections.Set with null record; Empty_Set_Of_Standard_Profile_L2_Model_Library : constant Set_Of_Standard_Profile_L2_Model_Library; type Ordered_Set_Of_Standard_Profile_L2_Model_Library is new Standard_Profile_L2_Model_Library_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_Standard_Profile_L2_Model_Library : constant Ordered_Set_Of_Standard_Profile_L2_Model_Library; type Bag_Of_Standard_Profile_L2_Model_Library is new Standard_Profile_L2_Model_Library_Collections.Bag with null record; Empty_Bag_Of_Standard_Profile_L2_Model_Library : constant Bag_Of_Standard_Profile_L2_Model_Library; type Sequence_Of_Standard_Profile_L2_Model_Library is new Standard_Profile_L2_Model_Library_Collections.Sequence with null record; Empty_Sequence_Of_Standard_Profile_L2_Model_Library : constant Sequence_Of_Standard_Profile_L2_Model_Library; private Empty_Set_Of_Standard_Profile_L2_Model_Library : constant Set_Of_Standard_Profile_L2_Model_Library := (Standard_Profile_L2_Model_Library_Collections.Set with null record); Empty_Ordered_Set_Of_Standard_Profile_L2_Model_Library : constant Ordered_Set_Of_Standard_Profile_L2_Model_Library := (Standard_Profile_L2_Model_Library_Collections.Ordered_Set with null record); Empty_Bag_Of_Standard_Profile_L2_Model_Library : constant Bag_Of_Standard_Profile_L2_Model_Library := (Standard_Profile_L2_Model_Library_Collections.Bag with null record); Empty_Sequence_Of_Standard_Profile_L2_Model_Library : constant Sequence_Of_Standard_Profile_L2_Model_Library := (Standard_Profile_L2_Model_Library_Collections.Sequence with null record); end AMF.Standard_Profile_L2.Model_Libraries.Collections;
io7m/coreland-opengl-ada
Ada
984
adb
with OpenGL.Thin; package body OpenGL.Light is function Enum_Value (Index : in Light_Index_t) return Thin.Enumeration_t is begin case Index is when Light_0 => return Thin.GL_LIGHT0; when Light_1 => return Thin.GL_LIGHT1; when Light_2 => return Thin.GL_LIGHT2; when Light_3 => return Thin.GL_LIGHT3; when Light_4 => return Thin.GL_LIGHT4; when Light_5 => return Thin.GL_LIGHT5; when Light_6 => return Thin.GL_LIGHT6; when Light_7 => return Thin.GL_LIGHT7; end case; end Enum_Value; procedure Enable (Index : in Light_Index_t) is begin Thin.Enable (Enum_Value (Index)); end Enable; procedure Disable (Index : in Light_Index_t) is begin Thin.Disable (Enum_Value (Index)); end Disable; function Is_Enabled (Index : in Light_Index_t) return Boolean is use type Thin.Boolean_t; begin return Thin.Is_Enabled (Enum_Value (Index)) = Thin.Boolean_t'Val (1); end Is_Enabled; end OpenGL.Light;
stcarrez/hestia
Ada
2,896
ads
----------------------------------------------------------------------- -- hestia-network -- Hestia Network Manager -- Copyright (C) 2016, 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 System; with Interfaces; with Ada.Real_Time; with Net.Buffers; with Net.Interfaces.STM32; with Net.DHCP; with Net.NTP; with Net.DNS; package Hestia.Network is use type Interfaces.Unsigned_32; -- Reserve 32 network buffers. NET_BUFFER_SIZE : constant Interfaces.Unsigned_32 := Net.Buffers.NET_ALLOC_SIZE * 32; -- The Ethernet interface driver. Ifnet : aliased Net.Interfaces.STM32.STM32_Ifnet; -- Initialize and start the network stack. procedure Initialize; -- Do the network housekeeping and return the next deadline. procedure Process (Deadline : out Ada.Real_Time.Time); -- Get the NTP time reference. function Get_Time return Net.NTP.NTP_Reference; private -- The task that waits for packets. task Controller with Storage_Size => (16 * 1024), Priority => System.Default_Priority; type NTP_Client_Type is limited new Net.DNS.Query with record -- The TTL deadline for the resolved DNS entry. Ttl_Deadline : Ada.Real_Time.Time; -- The NTP client connection and port. Server : aliased Net.NTP.Client; Port : Net.Uint16 := Net.NTP.NTP_PORT; end record; -- Save the answer received from the DNS server. This operation is called for each answer -- found in the DNS response packet. The Index is incremented at each answer. For example -- a DNS server can return a CNAME_RR answer followed by an A_RR: the operation is called -- two times. -- -- This operation can be overriden to implement specific actions when an answer is received. overriding procedure Answer (Request : in out NTP_Client_Type; Status : in Net.DNS.Status_Type; Response : in Net.DNS.Response_Type; Index : in Natural); -- The DHCP client used by Hestia. Dhcp : aliased Net.DHCP.Client; -- NTP client based on the NTP server provided by DHCP option (or static). Time_Ntp : aliased NTP_Client_Type; end Hestia.Network;
charlie5/lace
Ada
8,276
ads
generic package any_math.any_Algebra.any_linear.any_d3 is pragma Pure; ------------ --- Vector_3 -- function Distance (From, To : in Vector_3) return Real; function Midpoint (From, To : in Vector_3) return Vector_3; function Interpolated (From, To : in Vector_3; Percent : in unit_Percentage) return Vector_3; function Angle_between_pre_Norm (U, V : in Vector_3) return Radians; -- -- Given that the vectors 'U' and 'V' are already normalized, returns a positive angle between 0 and 180 degrees. function Angle (Point_1, Point_2, Point_3 : in Vector_3) return Radians; -- -- Returns the angle between the vector Point_1 to Point_2 and the vector Point_3 to Point_2. -------------- --- Matrix_3x3 -- z_Up_to_y_Up : constant Matrix_3x3; -- Provides a rotation which may be multiplied y_Up_to_z_Up : constant Matrix_3x3; -- by a vector to change co-ordinate systems. function to_Matrix (Row_1, Row_2, Row_3 : in Vector_3) return Matrix_3x3; function forward_Direction (Matrix : in Matrix_3x3) return Vector_3; function up_Direction (Matrix : in Matrix_3x3) return Vector_3; function right_Direction (Matrix : in Matrix_3x3) return Vector_3; procedure re_Orthonormalise (Matrix : in out Matrix_3x3); ------------- --- Rotations -- function x_Rotation_from (Angle : in Radians) return Matrix_3x3; function y_Rotation_from (Angle : in Radians) return Matrix_3x3; function z_Rotation_from (Angle : in Radians) return Matrix_3x3; function xyz_Rotation (x_Angle, y_Angle, z_Angle : in Real) return Matrix_3x3; function xyz_Rotation (Angles : in Vector_3) return Matrix_3x3; function to_Rotation (Axis : in Vector_3; Angle : in Real) return Matrix_3x3; function to_Rotation (Axis_x, Axis_y, Axis_z : in Real; Rotation : in Radians) return Matrix_3x3; -- -- Returns a rotation matrix describing a given rotation about an axis. -- (TODO: Make this obsolescent and use the vector Axis version instead.) --------- --- Euler -- type Euler is new Vector_3; -- -- 1: Roll -- 2: Pitch -- 3: Yaw function to_Rotation (Angles : in Euler) return Matrix_3x3; -- -- The euler angles are used to produce a rotation matrix. The euler -- angles are applied in ZYX order. That is, a vector is first rotated -- about X, then Y and then Z. ----------- --- General -- function Look_at (Eye, Center, Up : in Vector_3) return Matrix_4x4; function to_Viewport_Transform (Origin, Extent : in Vector_2) return Matrix_4x4; function to_Perspective (FoVy : in Degrees; Aspect, zNear, zFar : in Real) return Matrix_4x4; ------------- --- Transform -- function to_Translation_Matrix (Translation : in Vector_3) return Matrix_4x4; function to_Transform (Matrix : in Matrix_4x4) return Transform_3d; function "*" (Left : in Transform_3d; Right : in Vector_3) return Vector_3; function "*" (Left : in Vector_3; Right : in Transform_3d) return Vector_3; function "*" (Left : in Transform_3d; Right : in Transform_3d) return Transform_3d; function "*" (Left : in Vector_3; Right : in Matrix_4x4) return Vector_3; function Invert (Transform : in Transform_3d) return Transform_3d; function inverse_Transform (Transform : in Transform_3d; Vector : in Vector_3) return Vector_3; -------------- --- Quaternion -- procedure set_from_Matrix_3x3 (Quat : out Quaternion; Matrix : in Matrix_3x3); function to_Quaternion (Matrix : in Matrix_3x3) return Quaternion; function to_Matrix (Quat : in Quaternion) return Matrix_3x3; function Norm (Quat : in Quaternion) return Real; function Versor (Quat : in Quaternion) return Quaternion; -- Produces the unit quaternion of Quat. function Farthest (Quat : in Quaternion; qd : in Quaternion) return Quaternion; -- TODO: Document this. function Invert (Quat : in Quaternion) return Quaternion; function Angle (Quat : in Quaternion) return Radians; function Axis (Quat : in Quaternion) return Vector_3; function "*" (Left, Right : in Quaternion) return Real; -- Dot product. function "*" (Left, Right : in Quaternion) return Quaternion; -- Cross product. function "+" (Left, Right : in Quaternion) return Quaternion; function "-" (Left, Right : in Quaternion) return Quaternion; function "-" (Quat : in Quaternion) return Quaternion; function "*" (Left : in Quaternion; Right : in Vector_3) return Quaternion; function "*" (Left : in Vector_3; Right : in Quaternion) return Quaternion; function "*" (Left : in Quaternion; Right : in Real) return Quaternion; function Interpolated (From, To : in Quaternion; Percent : in unit_Percentage) return Quaternion; -- -- Return the quaternion which is the result of spherical linear interpolation (Slerp) between Initial and Final. -- Percent is the ratio between 'From' and 'To' to interpolate. -- If Percent = 0.0 the result is Initial. -- If Percent = 100.0 the result is Final. -- Interpolates assuming constant velocity. ------------ --- Vector_4 -- function "/" (Left, Right : in Vector_4) return Vector_4; function max_Axis (Vector : in Vector_4) return Integer; function closest_Axis (Vector : in Vector_4) return Integer; function to_transform_Matrix (Transform : in Transform_3d) return Matrix_4x4; function to_transform_Matrix (Rotation : in Matrix_3x3; Translation : in Vector_3) return Matrix_4x4; function to_rotate_Matrix (Rotation : in Matrix_3x3) return Matrix_4x4; function to_translate_Matrix (Translation : in Vector_3) return Matrix_4x4; function to_scale_Matrix (Scale : in Vector_3) return Matrix_4x4; ---------------------- --- Transform Matrices -- function get_Rotation (Transform : in Matrix_4x4) return Matrix_3x3; procedure set_Rotation (Transform : in out Matrix_4x4; To : in Matrix_3x3); function get_Translation (Transform : in Matrix_4x4) return Vector_3; procedure set_Translation (Transform : in out Matrix_4x4; To : in Vector_3); function inverse_Rotation (Rotation : in Matrix_3x3) return Matrix_3x3; function inverse_Transform (Transform : in Matrix_4x4) return Matrix_4x4; -------------- --- un-Project -- type Rectangle is record Min : Integers (1 .. 2); -- Bottom left corner. Max : Integers (1 .. 2); -- Upper right corner. end record; function unProject (From : in Vector_3; Model : in Matrix_4x4; Projection : in Matrix_4x4; Viewport : in Rectangle) return Vector_3; -- -- Maps the 'From' window space coordinates into object space coordinates using Model, Projection and Viewport. private z_Up_to_y_Up : constant Matrix_3x3 := [[1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0]]; y_Up_to_z_Up : constant Matrix_3x3 := [[1.0, 0.0, 0.0], [0.0, 0.0, -1.0], [0.0, 1.0, 0.0]]; pragma Inline ("+"); pragma Inline ("-"); pragma Inline ("*"); end any_math.any_Algebra.any_linear.any_d3;
AdaCore/libadalang
Ada
781
adb
procedure View is package P is type T is tagged null record; type T2 is new T with record A, B : Integer; end record; end P; V : P.T'Class := P.T2'(1, 2); V2 : constant P.T'Class := V; V3 : P.T'Class := V; X : Integer; begin P.T2 (V3).A := P.T2 (V2).A; --% node.f_dest.p_is_constant --% node.f_expr.p_is_constant P.T2 (V).A := P.T2 (V3).A; --% node.f_dest.p_is_constant --% node.f_expr.p_is_constant P.T2 (View.V3).A := P.T2 (View.V2).A; --% node.f_dest.p_is_constant --% node.f_expr.p_is_constant P.T2 (View.V).A := P.T2 (View.V3).A; --% node.f_dest.p_is_constant --% node.f_expr.p_is_constant X := Integer (1.6); --% node.f_dest.p_is_constant --% node.f_expr.p_is_constant end View;
charlie5/cBound
Ada
1,812
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_minmax_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; context_tag : aliased xcb.xcb_glx_context_tag_t; target : aliased Interfaces.Unsigned_32; format : aliased Interfaces.Unsigned_32; the_type : aliased Interfaces.Unsigned_32; swap_bytes : aliased Interfaces.Unsigned_8; reset : aliased Interfaces.Unsigned_8; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_minmax_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_minmax_request_t.Item, Element_Array => xcb.xcb_glx_get_minmax_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_minmax_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_minmax_request_t.Pointer, Element_Array => xcb.xcb_glx_get_minmax_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_minmax_request_t;
greifentor/archimedes-legacy
Ada
21,518
ads
<Diagramm> <AdditionalSQLCode> <SQLCode> <AdditionalSQLCodePostChanging></AdditionalSQLCodePostChanging> <AdditionalSQLCodePostReducing></AdditionalSQLCodePostReducing> <AdditionalSQLCodePreChanging></AdditionalSQLCodePreChanging> <AdditionalSQLCodePreExtending></AdditionalSQLCodePreExtending> </SQLCode> </AdditionalSQLCode> <Colors> <Anzahl>23</Anzahl> <Color0> <B>255</B> <G>0</G> <Name>blau</Name> <R>0</R> </Color0> <Color1> <B>221</B> <G>212</G> <Name>blaugrau</Name> <R>175</R> </Color1> <Color10> <B>192</B> <G>192</G> <Name>hellgrau</Name> <R>192</R> </Color10> <Color11> <B>255</B> <G>0</G> <Name>kamesinrot</Name> <R>255</R> </Color11> <Color12> <B>0</B> <G>200</G> <Name>orange</Name> <R>255</R> </Color12> <Color13> <B>255</B> <G>247</G> <Name>pastell-blau</Name> <R>211</R> </Color13> <Color14> <B>186</B> <G>245</G> <Name>pastell-gelb</Name> <R>255</R> </Color14> <Color15> <B>234</B> <G>255</G> <Name>pastell-gr&amp;uuml;n</Name> <R>211</R> </Color15> <Color16> <B>255</B> <G>211</G> <Name>pastell-lila</Name> <R>244</R> </Color16> <Color17> <B>191</B> <G>165</G> <Name>pastell-rot</Name> <R>244</R> </Color17> <Color18> <B>175</B> <G>175</G> <Name>pink</Name> <R>255</R> </Color18> <Color19> <B>0</B> <G>0</G> <Name>rot</Name> <R>255</R> </Color19> <Color2> <B>61</B> <G>125</G> <Name>braun</Name> <R>170</R> </Color2> <Color20> <B>0</B> <G>0</G> <Name>schwarz</Name> <R>0</R> </Color20> <Color21> <B>255</B> <G>255</G> <Name>t&amp;uuml;rkis</Name> <R>0</R> </Color21> <Color22> <B>255</B> <G>255</G> <Name>wei&amp;szlig;</Name> <R>255</R> </Color22> <Color3> <B>64</B> <G>64</G> <Name>dunkelgrau</Name> <R>64</R> </Color3> <Color4> <B>84</B> <G>132</G> <Name>dunkelgr&amp;uuml;n</Name> <R>94</R> </Color4> <Color5> <B>0</B> <G>255</G> <Name>gelb</Name> <R>255</R> </Color5> <Color6> <B>0</B> <G>225</G> <Name>goldgelb</Name> <R>255</R> </Color6> <Color7> <B>128</B> <G>128</G> <Name>grau</Name> <R>128</R> </Color7> <Color8> <B>0</B> <G>255</G> <Name>gr&amp;uuml;n</Name> <R>0</R> </Color8> <Color9> <B>255</B> <G>212</G> <Name>hellblau</Name> <R>191</R> </Color9> </Colors> <ComplexIndices> <IndexCount>0</IndexCount> </ComplexIndices> <DataSource> <Import> <DBName></DBName> <Description></Description> <Domains>false</Domains> <Driver></Driver> <Name></Name> <Referenzen>false</Referenzen> <User></User> </Import> </DataSource> <DatabaseConnections> <Count>2</Count> <DatabaseConnection0> <DBExecMode>POSTGRESQL</DBExecMode> <Driver>org.postgresql.Driver</Driver> <Name>Test-DB (Postgre)</Name> <Quote>"</Quote> <SetDomains>false</SetDomains> <SetNotNull>true</SetNotNull> <SetReferences>true</SetReferences> <URL>jdbc:postgresql://mykene/TEST_OLI_ISIS_2</URL> <UserName>op1</UserName> </DatabaseConnection0> <DatabaseConnection1> <DBExecMode>HSQL</DBExecMode> <Driver>org.hsqldb.jdbcDriver</Driver> <Name>Test-DB (HSQL)</Name> <Quote>"</Quote> <SetDomains>false</SetDomains> <SetNotNull>true</SetNotNull> <SetReferences>true</SetReferences> <URL>jdbc:hsqldb:unittests/db/tst</URL> <UserName>sa</UserName> </DatabaseConnection1> </DatabaseConnections> <DefaultComment> <Anzahl>0</Anzahl> </DefaultComment> <Domains> <Anzahl>4</Anzahl> <Domain0> <Datatype>-5</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>0</Length> <NKS>0</NKS> <Name>Ident</Name> <Parameters></Parameters> </Domain0> <Domain1> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>500</Length> <NKS>0</NKS> <Name>LongName</Name> <Parameters></Parameters> </Domain1> <Domain2> <Datatype>12</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>200</Length> <NKS>0</NKS> <Name>Name</Name> <Parameters></Parameters> </Domain2> <Domain3> <Datatype>2</Datatype> <History></History> <Initialwert>NULL</Initialwert> <Kommentar></Kommentar> <Length>8</Length> <NKS>2</NKS> <Name>Price</Name> <Parameters></Parameters> </Domain3> </Domains> <Factories> <Object>archimedes.legacy.scheme.DefaultObjectFactory</Object> </Factories> <Pages> <PerColumn>5</PerColumn> <PerRow>10</PerRow> </Pages> <Parameter> <AdditionalSQLScriptListener></AdditionalSQLScriptListener> <Applicationname></Applicationname> <AufgehobeneAusblenden>false</AufgehobeneAusblenden> <Autor>&amp;lt;null&amp;gt;</Autor> <Basepackagename></Basepackagename> <CodeFactoryClassName></CodeFactoryClassName> <Codebasispfad>.\</Codebasispfad> <DBVersionDBVersionColumn></DBVersionDBVersionColumn> <DBVersionDescriptionColumn></DBVersionDescriptionColumn> <DBVersionTablename></DBVersionTablename> <History></History> <Kommentar>&amp;lt;null&amp;gt;</Kommentar> <Name>TST</Name> <Optionen> <Anzahl>0</Anzahl> </Optionen> <PflichtfelderMarkieren>false</PflichtfelderMarkieren> <ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen> <RelationColorExternalTables>hellgrau</RelationColorExternalTables> <RelationColorRegular>schwarz</RelationColorRegular> <SchemaName>TST</SchemaName> <Schriftgroessen> <Tabelleninhalte>12</Tabelleninhalte> <Ueberschriften>24</Ueberschriften> <Untertitel>12</Untertitel> </Schriftgroessen> <Scripte> <AfterWrite>&amp;lt;null&amp;gt;</AfterWrite> </Scripte> <TechnischeFelderAusgrauen>false</TechnischeFelderAusgrauen> <TransienteFelderAusgrauen>false</TransienteFelderAusgrauen> <UdschebtiBaseClassName></UdschebtiBaseClassName> <Version>1</Version> <Versionsdatum>08.12.2015</Versionsdatum> <Versionskommentar>&amp;lt;null&amp;gt;</Versionskommentar> </Parameter> <Sequences> <Count>0</Count> </Sequences> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Tabellen> <Anzahl>1</Anzahl> <Tabelle0> <Aufgehoben>false</Aufgehoben> <Codegenerator> <AuswahlMembers> <Anzahl>0</Anzahl> </AuswahlMembers> <CompareMembers> <Anzahl>0</Anzahl> </CompareMembers> <Equalsmembers> <Anzahl>0</Anzahl> </Equalsmembers> <HashCodeMembers> <Anzahl>0</Anzahl> </HashCodeMembers> <NReferenzen> <Anzahl>0</Anzahl> </NReferenzen> <OrderMembers> <Anzahl>0</Anzahl> </OrderMembers> <ToComboStringMembers> <Anzahl>0</Anzahl> </ToComboStringMembers> <ToStringMembers> <Anzahl>0</Anzahl> </ToStringMembers> </Codegenerator> <ExternalTable>false</ExternalTable> <Farben> <Hintergrund>wei&amp;szlig;</Hintergrund> <Schrift>schwarz</Schrift> </Farben> <FirstGenerationDone>false</FirstGenerationDone> <History>@changed OLI - Added.$BR$@changed OLI - Added column: Id.</History> <InDevelopment>false</InDevelopment> <Kommentar></Kommentar> <NMRelation>false</NMRelation> <Name>Author</Name> <Options> <Count>0</Count> </Options> <Panels> <Anzahl>1</Anzahl> <Panel0> <PanelClass></PanelClass> <PanelNumber>0</PanelNumber> <TabMnemonic>1</TabMnemonic> <TabTitle>1.Daten</TabTitle> <TabToolTipText>Hier k&ouml;nnen Sie die Daten des Objekt warten</TabToolTipText> </Panel0> </Panels> <Spalten> <Anzahl>4</Anzahl> <Codegenerator> <ActiveInApplication>false</ActiveInApplication> <AdditionalCreateConstraints></AdditionalCreateConstraints> <Codegeneratoroptionen></Codegeneratoroptionen> <Codeverzeichnis>.</Codeverzeichnis> <Codieren>true</Codieren> <DynamicCode>true</DynamicCode> <Inherited>false</Inherited> <Kontextname></Kontextname> <UniqueFormula></UniqueFormula> </Codegenerator> <Spalte0> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>true</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Author</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>true</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte0> <Spalte1> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue>'n/a'</IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Address</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte1> <Spalte2> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Ident</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>AuthorId</Name> <NotNull>false</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>true</Unique> </Spalte2> <Spalte3> <AlterInBatch>false</AlterInBatch> <Aufgehoben>false</Aufgehoben> <CanBeReferenced>false</CanBeReferenced> <Disabled>false</Disabled> <Domain>Name</Domain> <Editordescriptor> <Editormember>false</Editormember> <LabelText></LabelText> <MaxCharacters>0</MaxCharacters> <Mnemonic></Mnemonic> <Position>0</Position> <ReferenceWeight>keine</ReferenceWeight> <RessourceIdentifier></RessourceIdentifier> <ToolTipText></ToolTipText> </Editordescriptor> <ForeignKey>false</ForeignKey> <Global>false</Global> <GlobalId>false</GlobalId> <HideReference>false</HideReference> <History>@changed OLI - Added.</History> <IndexSearchMember>false</IndexSearchMember> <Indexed>false</Indexed> <IndividualDefaultValue></IndividualDefaultValue> <Kodiert>false</Kodiert> <Kommentar></Kommentar> <Konsistenz> <Writeablemember>false</Writeablemember> </Konsistenz> <LastModificationField>false</LastModificationField> <ListItemField>false</ListItemField> <Name>Name</Name> <NotNull>true</NotNull> <PanelNumber>0</PanelNumber> <Parameter></Parameter> <PrimaryKey>false</PrimaryKey> <RemovedStateField>false</RemovedStateField> <SequenceForKeyGeneration></SequenceForKeyGeneration> <SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints> <TechnicalField>false</TechnicalField> <Transient>false</Transient> <Unique>false</Unique> </Spalte3> </Spalten> <Stereotype> <Anzahl>0</Anzahl> </Stereotype> <Views> <Anzahl>1</Anzahl> <View0> <Name>Main</Name> <X>150</X> <Y>150</Y> </View0> </Views> </Tabelle0> </Tabellen> <Views> <Anzahl>1</Anzahl> <View0> <Beschreibung>Diese Sicht beinhaltet alle Tabellen des Schemas</Beschreibung> <Name>Main</Name> <ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen> <Tabelle0>Book</Tabelle0> <Tabelle1>Author</Tabelle1> <Tabelle2>Publisher</Tabelle2> <Tabelle3>AuthorPublisher</Tabelle3> <Tabelle4>TestTable</Tabelle4> <Tabellenanzahl>5</Tabellenanzahl> <TechnischeSpaltenVerstecken>false</TechnischeSpaltenVerstecken> </View0> </Views> </Diagramm>
optikos/oasis
Ada
1,788
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Clauses; with Program.Lexical_Elements; with Program.Elements.Expressions; package Program.Elements.Use_Clauses is pragma Pure (Program.Elements.Use_Clauses); type Use_Clause is limited interface and Program.Elements.Clauses.Clause; type Use_Clause_Access is access all Use_Clause'Class with Storage_Size => 0; not overriding function Clause_Names (Self : Use_Clause) return not null Program.Elements.Expressions.Expression_Vector_Access is abstract; not overriding function Has_All (Self : Use_Clause) return Boolean is abstract; not overriding function Has_Type (Self : Use_Clause) return Boolean is abstract; type Use_Clause_Text is limited interface; type Use_Clause_Text_Access is access all Use_Clause_Text'Class with Storage_Size => 0; not overriding function To_Use_Clause_Text (Self : aliased in out Use_Clause) return Use_Clause_Text_Access is abstract; not overriding function Use_Token (Self : Use_Clause_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function All_Token (Self : Use_Clause_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Type_Token (Self : Use_Clause_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Use_Clause_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Use_Clauses;
iyan22/AprendeAda
Ada
260
adb
procedure diviporrestas(dividendo: in Integer; divisor: in Integer; resultado, resto: out Integer) is begin Resto:=Dividendo; resultado:=0; loop exit when divisor > resto; resto:=resto-divisor; resultado:=resultado+1; end loop; end diviporrestas;
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.Draw_Start_Color_Attributes; package Matreshka.ODF_Draw.Start_Color_Attributes is type Draw_Start_Color_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Start_Color_Attributes.ODF_Draw_Start_Color_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Start_Color_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Start_Color_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Start_Color_Attributes;
AdaCore/libadalang
Ada
40
ads
package Pkg is procedure P; end Pkg;
radekwlsk/concurrent-railroad-ada
Ada
7,175
adb
-- -- Radoslaw Kowalski 221454 -- package body Trains is --type Route_Array is array (Integer range <>) of Integer; --type Route_Ptr is access Route_Array; procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr) is From_Index : constant Integer := Self.Index; To_Index : constant Integer := (Self.Index + 1) mod Self.Route'Length; begin From := Self.Route (From_Index+1); To := Self.Route (To_Index+1); end Connection; function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float is begin Self.Att.Unlock; Self.Att := T; if T.Get_Type = Turntable then Self.Index := (Self.Index + 1) mod Self.Route'Length; end if; return Self.Att.Action_Time(Self.Speed); end Move_To; function As_String(Self: Train_Ptr) return String is begin return "Train" & Trim(Integer'Image (Self.Id), Left) & " " & SU.To_String (Self.Name); end As_String; function As_Verbose_String(Self: Train_Ptr) return String is Id : String := Integer'Image (Self.Id); Name : String := SU.To_String (Self.Name); Speed : String := Integer'Image (Self.Speed); Cap : String := Integer'Image (Self.Capacity); Route : String := As_String(Self.Route); Att : String := Self.Att.As_String; begin return "rails.Train:" & Name & ":" & Id (2 .. Id'Last) & "{speed:" & Speed (2 .. Speed'Last) & ", " & "cap:" & Cap (2 .. Cap'Last) & ", " & "route:" & Route & ", " & "at:" & Att & "}"; end As_Verbose_String; function New_Train ( Id : Integer; Name : SU.Unbounded_String; Speed : Integer; Capacity : Integer; Route : Route_Array ) return Train_Ptr is T : Train_Ptr; begin T := new Train(Route'Length); T.Id := Id; T.Name := Name; T.Speed := Speed; T.Capacity := Capacity; T.Route := Route; T.Index := 0; T.Att := Route (0); T.Att.Lock; return T; end New_Train; task body Simulation is Seconds_Per_Hour : Integer; Start : Calendar.Time; Clock : array(1..2) of Integer; Verbose : Boolean; Train : Train_Ptr; Connections : Connections_Ptr; First : Track_Ptr; Second : Track_Ptr; Time : Float; Current_Rails : Tracks_Ptr; Success : Boolean; Now : String(1 .. 8); function Clock_Time return String is D : Duration; SH : Float; SM : Float; SS : Float; F : Float; H : Integer; M : Integer; S : Integer; H_String : SU.Unbounded_String; M_String : SU.Unbounded_String; S_String : SU.Unbounded_String; begin D := Calendar."-"(Calendar.Clock, Start); SH := Float (D) / Float (Seconds_Per_Hour); F := SH - Float'Floor (SH); SH := Float'Floor (SH); SM := 60.0 * F; F := SM - Float'Floor (SM); SS := 60.0 * F; H := Integer (SH) + Clock (1); H := H mod 24; M := Integer (SM) + Clock (2); if M > 59 then H := H + 1; end if; M := M mod 60; S := Integer (SS); H_String := SU.To_Unbounded_String (Trim(Integer'Image (H), Left)); M_String := SU.To_Unbounded_String (Trim(Integer'Image (M), Left)); S_String := SU.To_Unbounded_String (Trim(Integer'Image (S), Left)); if SU.Length (H_String) = 1 then H_String := SU."&"('0', H_String); end if; if SU.Length (M_String) = 1 then M_String := SU."&"('0', M_String); end if; if SU.Length (S_String) = 1 then S_String := SU."&"('0', S_String); end if; return SU.To_String (H_String) & ":" & SU.To_String (M_String) & ":" & SU.To_String (S_String); end Clock_Time; procedure Print (S : String) is begin if Verbose then Put_Line (S); end if; end Print; begin accept Init( S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean ) do Start := S; Seconds_Per_Hour := SPH; Clock (1) := H; Clock (2) := M; Verbose := V; end Init; accept Simulate(T : in Train_Ptr; C : in Connections_Ptr) do Train := T; Connections := C; end Simulate; while TRUE loop Connection(Train, First, Second); Current_Rails := Connections(First.Get_Id, Second.Get_Id); Loop1: loop for R in Current_Rails'Range loop Current_Rails (R).Get_Lock(Success); case Success is when TRUE => Now := Clock_Time; -- TODO: save to statistics if arriving at station Time := Float (Seconds_Per_Hour) * Move_To(Train, Current_Rails (R)); Print(Now & " " & As_String(Train) & " travels along " & Current_Rails (R).As_String); delay Duration(Time); exit Loop1 when Success = TRUE; when FALSE => goto Continue1; end case; <<Continue1>> end loop; --Time := Float (Seconds_Per_Hour) * 0.25; --Put_Line(Clock_Time & " " & As_String(Train) & " have nowhere to go, it will wait for " & Float'Image (Time) & "s"); --delay Duration(Time); end loop Loop1; Loop2: loop Second.Get_Lock(Success); case Success is when TRUE => Now := Clock_Time; -- TODO: save to statistics if leaving station Time := Float (Seconds_Per_Hour) * Move_To(Train, Second); Print(Now & " " & As_String(Train) & " rotates at " & Second.As_String); delay Duration(Time); exit Loop2 when Success = TRUE; when FALSE => --Time := Float (Seconds_Per_Hour) * 0.25; --Put_Line(Clock_Time & " " & As_String(Train) & " have nowhere to go, it will wait for " & Float'Image (Time) & "s"); --delay Duration(Time); goto Continue2; end case; <<Continue2>> end loop Loop2; end loop; end Simulation; end Trains;
zhmu/ananas
Ada
9,051
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 4 0 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_40 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_40; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; -- The following declarations are for the case where the address -- passed to GetU_40 or SetU_40 is not guaranteed to be aligned. -- These routines are used when the packed array is itself a -- component of a packed record, and therefore may not be aligned. type ClusterU is new Cluster; for ClusterU'Alignment use 1; type ClusterU_Ref is access ClusterU; type Rev_ClusterU is new ClusterU with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_ClusterU_Ref is access Rev_ClusterU; ------------ -- Get_40 -- ------------ function Get_40 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_40 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_40; ------------- -- GetU_40 -- ------------- function GetU_40 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_40 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end GetU_40; ------------ -- Set_40 -- ------------ procedure Set_40 (Arr : System.Address; N : Natural; E : Bits_40; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_40; ------------- -- SetU_40 -- ------------- procedure SetU_40 (Arr : System.Address; N : Natural; E : Bits_40; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : ClusterU_Ref with Address => A'Address, Import; RC : Rev_ClusterU_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end SetU_40; end System.Pack_40;
reznikmm/matreshka
Ada
3,832
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Style.Font_Family_Generic is type Style_Font_Family_Generic_Node is new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record; type Style_Font_Family_Generic_Access is access all Style_Font_Family_Generic_Node'Class; overriding function Get_Local_Name (Self : not null access constant Style_Font_Family_Generic_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Style.Font_Family_Generic;
Fabien-Chouteau/Ada_Drivers_Library
Ada
3,050
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package HAL.Block_Drivers is type Block_Driver is limited interface; type Any_Block_Driver is access all Block_Driver'Class; subtype Block is UInt8_Array; Block_Size : constant := 512; -- Size of a block, for block number. function Read (This : in out Block_Driver; Block_Number : UInt64; Data : out Block) return Boolean is abstract with Pre'Class => Data'Length mod Block_Size = 0; function Write (This : in out Block_Driver; Block_Number : UInt64; Data : Block) return Boolean is abstract with Pre'Class => Data'Length mod Block_Size = 0; end HAL.Block_Drivers;
docandrew/troodon
Ada
19,334
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with freetype_config_integer_types; with System; with stddef_h; package fttypes is -- arg-macro: function FT_MAKE_TAG (_x1, _x2, _x3, _x4) -- return FT_Tag) ( ( (FT_ULong)_x1 << 24 ) or ( (FT_ULong)_x2 << 16 ) or ( (FT_ULong)_x3 << 8 ) or (FT_ULong)_x4 ; -- arg-macro: function FT_IS_EMPTY (list) -- return (list).head = 0 ; -- arg-macro: function FT_BOOL (x) -- return (FT_Bool)( (x) /= 0 ) ; -- unsupported macro: FT_ERR_XCAT(x,y) x ## y -- arg-macro: procedure FT_ERR_CAT (x, y) -- FT_ERR_XCAT( x, y ) -- arg-macro: procedure FT_ERR (e) -- FT_ERR_CAT( FT_ERR_PREFIX, e ) -- arg-macro: function FT_ERROR_BASE (x) -- return (x) and 16#FF# ; -- arg-macro: function FT_ERROR_MODULE (x) -- return (x) and 16#FF00# ; -- arg-macro: function FT_ERR_EQ (x, e) -- return FT_ERROR_BASE( x ) = FT_ERROR_BASE( FT_ERR( e ) ) ; -- arg-macro: function FT_ERR_NEQ (x, e) -- return FT_ERROR_BASE( x ) /= FT_ERROR_BASE( FT_ERR( e ) ) ; --*************************************************************************** -- * -- * fttypes.h -- * -- * FreeType simple types definitions (specification only). -- * -- * Copyright (C) 1996-2020 by -- * David Turner, Robert Wilhelm, and Werner Lemberg. -- * -- * This file is part of the FreeType project, and may only be used, -- * modified, and distributed under the terms of the FreeType project -- * license, LICENSE.TXT. By continuing to use, modify, or distribute -- * this file you indicate that you have read the license and -- * understand and accept it fully. -- * -- --************************************************************************* -- * -- * @section: -- * basic_types -- * -- * @title: -- * Basic Data Types -- * -- * @abstract: -- * The basic data types defined by the library. -- * -- * @description: -- * This section contains the basic data types defined by FreeType~2, -- * ranging from simple scalar types to bitmap descriptors. More -- * font-specific structures are defined in a different section. -- * -- * @order: -- * FT_Byte -- * FT_Bytes -- * FT_Char -- * FT_Int -- * FT_UInt -- * FT_Int16 -- * FT_UInt16 -- * FT_Int32 -- * FT_UInt32 -- * FT_Int64 -- * FT_UInt64 -- * FT_Short -- * FT_UShort -- * FT_Long -- * FT_ULong -- * FT_Bool -- * FT_Offset -- * FT_PtrDist -- * FT_String -- * FT_Tag -- * FT_Error -- * FT_Fixed -- * FT_Pointer -- * FT_Pos -- * FT_Vector -- * FT_BBox -- * FT_Matrix -- * FT_FWord -- * FT_UFWord -- * FT_F2Dot14 -- * FT_UnitVector -- * FT_F26Dot6 -- * FT_Data -- * -- * FT_MAKE_TAG -- * -- * FT_Generic -- * FT_Generic_Finalizer -- * -- * FT_Bitmap -- * FT_Pixel_Mode -- * FT_Palette_Mode -- * FT_Glyph_Format -- * FT_IMAGE_TAG -- * -- --************************************************************************* -- * -- * @type: -- * FT_Bool -- * -- * @description: -- * A typedef of unsigned char, used for simple booleans. As usual, -- * values 1 and~0 represent true and false, respectively. -- subtype FT_Bool is unsigned_char; -- /usr/include/freetype2/freetype/fttypes.h:108 --************************************************************************* -- * -- * @type: -- * FT_FWord -- * -- * @description: -- * A signed 16-bit integer used to store a distance in original font -- * units. -- -- distance in FUnits subtype FT_FWord is short; -- /usr/include/freetype2/freetype/fttypes.h:120 --************************************************************************* -- * -- * @type: -- * FT_UFWord -- * -- * @description: -- * An unsigned 16-bit integer used to store a distance in original font -- * units. -- -- unsigned distance subtype FT_UFWord is unsigned_short; -- /usr/include/freetype2/freetype/fttypes.h:132 --************************************************************************* -- * -- * @type: -- * FT_Char -- * -- * @description: -- * A simple typedef for the _signed_ char type. -- subtype FT_Char is signed_char; -- /usr/include/freetype2/freetype/fttypes.h:143 --************************************************************************* -- * -- * @type: -- * FT_Byte -- * -- * @description: -- * A simple typedef for the _unsigned_ char type. -- subtype FT_Byte is unsigned_char; -- /usr/include/freetype2/freetype/fttypes.h:154 --************************************************************************* -- * -- * @type: -- * FT_Bytes -- * -- * @description: -- * A typedef for constant memory areas. -- type FT_Bytes is access all FT_Byte; -- /usr/include/freetype2/freetype/fttypes.h:165 --************************************************************************* -- * -- * @type: -- * FT_Tag -- * -- * @description: -- * A typedef for 32-bit tags (as used in the SFNT format). -- subtype FT_Tag is freetype_config_integer_types.FT_UInt32; -- /usr/include/freetype2/freetype/fttypes.h:176 --************************************************************************* -- * -- * @type: -- * FT_String -- * -- * @description: -- * A simple typedef for the char type, usually used for strings. -- subtype FT_String is char; -- /usr/include/freetype2/freetype/fttypes.h:187 --************************************************************************* -- * -- * @type: -- * FT_Short -- * -- * @description: -- * A typedef for signed short. -- subtype FT_Short is short; -- /usr/include/freetype2/freetype/fttypes.h:198 --************************************************************************* -- * -- * @type: -- * FT_UShort -- * -- * @description: -- * A typedef for unsigned short. -- subtype FT_UShort is unsigned_short; -- /usr/include/freetype2/freetype/fttypes.h:209 --************************************************************************* -- * -- * @type: -- * FT_Int -- * -- * @description: -- * A typedef for the int type. -- subtype FT_Int is int; -- /usr/include/freetype2/freetype/fttypes.h:220 --************************************************************************* -- * -- * @type: -- * FT_UInt -- * -- * @description: -- * A typedef for the unsigned int type. -- subtype FT_UInt is unsigned; -- /usr/include/freetype2/freetype/fttypes.h:231 --************************************************************************* -- * -- * @type: -- * FT_Long -- * -- * @description: -- * A typedef for signed long. -- subtype FT_Long is long; -- /usr/include/freetype2/freetype/fttypes.h:242 --************************************************************************* -- * -- * @type: -- * FT_ULong -- * -- * @description: -- * A typedef for unsigned long. -- subtype FT_ULong is unsigned_long; -- /usr/include/freetype2/freetype/fttypes.h:253 --************************************************************************* -- * -- * @type: -- * FT_F2Dot14 -- * -- * @description: -- * A signed 2.14 fixed-point type used for unit vectors. -- subtype FT_F2Dot14 is short; -- /usr/include/freetype2/freetype/fttypes.h:264 --************************************************************************* -- * -- * @type: -- * FT_F26Dot6 -- * -- * @description: -- * A signed 26.6 fixed-point type used for vectorial pixel coordinates. -- subtype FT_F26Dot6 is long; -- /usr/include/freetype2/freetype/fttypes.h:275 --************************************************************************* -- * -- * @type: -- * FT_Fixed -- * -- * @description: -- * This type is used to store 16.16 fixed-point values, like scaling -- * values or matrix coefficients. -- subtype FT_Fixed is long; -- /usr/include/freetype2/freetype/fttypes.h:287 --************************************************************************* -- * -- * @type: -- * FT_Error -- * -- * @description: -- * The FreeType error code type. A value of~0 is always interpreted as a -- * successful operation. -- subtype FT_Error is int; -- /usr/include/freetype2/freetype/fttypes.h:299 --************************************************************************* -- * -- * @type: -- * FT_Pointer -- * -- * @description: -- * A simple typedef for a typeless pointer. -- type FT_Pointer is new System.Address; -- /usr/include/freetype2/freetype/fttypes.h:310 --************************************************************************* -- * -- * @type: -- * FT_Offset -- * -- * @description: -- * This is equivalent to the ANSI~C `size_t` type, i.e., the largest -- * _unsigned_ integer type used to express a file size or position, or a -- * memory block size. -- subtype FT_Offset is stddef_h.size_t; -- /usr/include/freetype2/freetype/fttypes.h:323 --************************************************************************* -- * -- * @type: -- * FT_PtrDist -- * -- * @description: -- * This is equivalent to the ANSI~C `ptrdiff_t` type, i.e., the largest -- * _signed_ integer type used to express the distance between two -- * pointers. -- -- Troodon: not needed --subtype FT_PtrDist is stddef_h.ptrdiff_t; -- /usr/include/freetype2/freetype/fttypes.h:336 --************************************************************************* -- * -- * @struct: -- * FT_UnitVector -- * -- * @description: -- * A simple structure used to store a 2D vector unit vector. Uses -- * FT_F2Dot14 types. -- * -- * @fields: -- * x :: -- * Horizontal coordinate. -- * -- * y :: -- * Vertical coordinate. -- type FT_UnitVector_u is record x : aliased FT_F2Dot14; -- /usr/include/freetype2/freetype/fttypes.h:357 y : aliased FT_F2Dot14; -- /usr/include/freetype2/freetype/fttypes.h:358 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:355 subtype FT_UnitVector is FT_UnitVector_u; -- /usr/include/freetype2/freetype/fttypes.h:360 --************************************************************************* -- * -- * @struct: -- * FT_Matrix -- * -- * @description: -- * A simple structure used to store a 2x2 matrix. Coefficients are in -- * 16.16 fixed-point format. The computation performed is: -- * -- * ``` -- * x' = x*xx + y*xy -- * y' = x*yx + y*yy -- * ``` -- * -- * @fields: -- * xx :: -- * Matrix coefficient. -- * -- * xy :: -- * Matrix coefficient. -- * -- * yx :: -- * Matrix coefficient. -- * -- * yy :: -- * Matrix coefficient. -- type FT_Matrix_u is record xx : aliased FT_Fixed; -- /usr/include/freetype2/freetype/fttypes.h:392 xy : aliased FT_Fixed; -- /usr/include/freetype2/freetype/fttypes.h:392 yx : aliased FT_Fixed; -- /usr/include/freetype2/freetype/fttypes.h:393 yy : aliased FT_Fixed; -- /usr/include/freetype2/freetype/fttypes.h:393 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:390 subtype FT_Matrix is FT_Matrix_u; -- /usr/include/freetype2/freetype/fttypes.h:395 --************************************************************************* -- * -- * @struct: -- * FT_Data -- * -- * @description: -- * Read-only binary data represented as a pointer and a length. -- * -- * @fields: -- * pointer :: -- * The data. -- * -- * length :: -- * The length of the data in bytes. -- type FT_Data_u is record pointer : access FT_Byte; -- /usr/include/freetype2/freetype/fttypes.h:415 length : aliased FT_Int; -- /usr/include/freetype2/freetype/fttypes.h:416 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:413 subtype FT_Data is FT_Data_u; -- /usr/include/freetype2/freetype/fttypes.h:418 --************************************************************************* -- * -- * @functype: -- * FT_Generic_Finalizer -- * -- * @description: -- * Describe a function used to destroy the 'client' data of any FreeType -- * object. See the description of the @FT_Generic type for details of -- * usage. -- * -- * @input: -- * The address of the FreeType object that is under finalization. Its -- * client data is accessed through its `generic` field. -- type FT_Generic_Finalizer is access procedure (arg1 : System.Address) with Convention => C; -- /usr/include/freetype2/freetype/fttypes.h:435 --************************************************************************* -- * -- * @struct: -- * FT_Generic -- * -- * @description: -- * Client applications often need to associate their own data to a -- * variety of FreeType core objects. For example, a text layout API -- * might want to associate a glyph cache to a given size object. -- * -- * Some FreeType object contains a `generic` field, of type `FT_Generic`, -- * which usage is left to client applications and font servers. -- * -- * It can be used to store a pointer to client-specific data, as well as -- * the address of a 'finalizer' function, which will be called by -- * FreeType when the object is destroyed (for example, the previous -- * client example would put the address of the glyph cache destructor in -- * the `finalizer` field). -- * -- * @fields: -- * data :: -- * A typeless pointer to any client-specified data. This field is -- * completely ignored by the FreeType library. -- * -- * finalizer :: -- * A pointer to a 'generic finalizer' function, which will be called -- * when the object is destroyed. If this field is set to `NULL`, no -- * code will be called. -- type FT_Generic_u is record data : System.Address; -- /usr/include/freetype2/freetype/fttypes.h:469 finalizer : FT_Generic_Finalizer; -- /usr/include/freetype2/freetype/fttypes.h:470 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:467 subtype FT_Generic is FT_Generic_u; -- /usr/include/freetype2/freetype/fttypes.h:472 --************************************************************************* -- * -- * @macro: -- * FT_MAKE_TAG -- * -- * @description: -- * This macro converts four-letter tags that are used to label TrueType -- * tables into an unsigned long, to be used within FreeType. -- * -- * @note: -- * The produced values **must** be 32-bit integers. Don't redefine this -- * macro. -- --*********************************************************************** --*********************************************************************** -- -- L I S T M A N A G E M E N T -- --*********************************************************************** --*********************************************************************** --************************************************************************* -- * -- * @section: -- * list_processing -- * -- --************************************************************************* -- * -- * @type: -- * FT_ListNode -- * -- * @description: -- * Many elements and objects in FreeType are listed through an @FT_List -- * record (see @FT_ListRec). As its name suggests, an FT_ListNode is a -- * handle to a single list element. -- type FT_ListNodeRec_u; type FT_ListNode is access all FT_ListNodeRec_u; -- /usr/include/freetype2/freetype/fttypes.h:523 --************************************************************************* -- * -- * @type: -- * FT_List -- * -- * @description: -- * A handle to a list record (see @FT_ListRec). -- type FT_ListRec_u; type FT_List is access all FT_ListRec_u; -- /usr/include/freetype2/freetype/fttypes.h:534 --************************************************************************* -- * -- * @struct: -- * FT_ListNodeRec -- * -- * @description: -- * A structure used to hold a single list element. -- * -- * @fields: -- * prev :: -- * The previous element in the list. `NULL` if first. -- * -- * next :: -- * The next element in the list. `NULL` if last. -- * -- * data :: -- * A typeless pointer to the listed object. -- type FT_ListNodeRec_u is record prev : FT_ListNode; -- /usr/include/freetype2/freetype/fttypes.h:557 next : FT_ListNode; -- /usr/include/freetype2/freetype/fttypes.h:558 data : System.Address; -- /usr/include/freetype2/freetype/fttypes.h:559 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:555 subtype FT_ListNodeRec is FT_ListNodeRec_u; -- /usr/include/freetype2/freetype/fttypes.h:561 --************************************************************************* -- * -- * @struct: -- * FT_ListRec -- * -- * @description: -- * A structure used to hold a simple doubly-linked list. These are used -- * in many parts of FreeType. -- * -- * @fields: -- * head :: -- * The head (first element) of doubly-linked list. -- * -- * tail :: -- * The tail (last element) of doubly-linked list. -- type FT_ListRec_u is record head : FT_ListNode; -- /usr/include/freetype2/freetype/fttypes.h:582 tail : FT_ListNode; -- /usr/include/freetype2/freetype/fttypes.h:583 end record with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/fttypes.h:580 subtype FT_ListRec is FT_ListRec_u; -- /usr/include/freetype2/freetype/fttypes.h:585 -- -- concatenate C tokens -- see `ftmoderr.h` for descriptions of the following macros -- END end fttypes;
charlie5/lace
Ada
444
ads
package freetype_c.FT_Vector is type Item is record X : aliased FT_Pos; Y : aliased FT_Pos; end record; type Item_array is array (C.Size_t range <>) of aliased FT_Vector.Item; type Pointer is access all FT_Vector.Item; type Pointer_array is array (C.Size_t range <>) of aliased FT_Vector.Pointer; type pointer_Pointer is access all freetype_c.FT_Vector.Pointer; end freetype_c.FT_Vector;
optikos/oasis
Ada
4,313
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Elsif_Paths is function Create (Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Condition : not null Program.Elements.Expressions.Expression_Access; Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Statements : not null Program.Element_Vectors.Element_Vector_Access) return Elsif_Path is begin return Result : Elsif_Path := (Elsif_Token => Elsif_Token, Condition => Condition, Then_Token => Then_Token, Statements => Statements, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Condition : not null Program.Elements.Expressions .Expression_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Elsif_Path is begin return Result : Implicit_Elsif_Path := (Condition => Condition, Statements => Statements, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Condition (Self : Base_Elsif_Path) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Condition; end Condition; overriding function Statements (Self : Base_Elsif_Path) return not null Program.Element_Vectors.Element_Vector_Access is begin return Self.Statements; end Statements; overriding function Elsif_Token (Self : Elsif_Path) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Elsif_Token; end Elsif_Token; overriding function Then_Token (Self : Elsif_Path) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Then_Token; end Then_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Elsif_Path) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Elsif_Path) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Elsif_Path) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Elsif_Path'Class) is begin Set_Enclosing_Element (Self.Condition, Self'Unchecked_Access); for Item in Self.Statements.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Elsif_Path_Element (Self : Base_Elsif_Path) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Elsif_Path_Element; overriding function Is_Path_Element (Self : Base_Elsif_Path) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Path_Element; overriding procedure Visit (Self : not null access Base_Elsif_Path; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Elsif_Path (Self); end Visit; overriding function To_Elsif_Path_Text (Self : aliased in out Elsif_Path) return Program.Elements.Elsif_Paths.Elsif_Path_Text_Access is begin return Self'Unchecked_Access; end To_Elsif_Path_Text; overriding function To_Elsif_Path_Text (Self : aliased in out Implicit_Elsif_Path) return Program.Elements.Elsif_Paths.Elsif_Path_Text_Access is pragma Unreferenced (Self); begin return null; end To_Elsif_Path_Text; end Program.Nodes.Elsif_Paths;
stcarrez/ada-util
Ada
2,712
ads
----------------------------------------------------------------------- -- util-properties-json -- read json files into properties -- Copyright (C) 2013, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- == Reading JSON property files == -- The `Util.Properties.JSON` package provides operations to read a JSON -- content and put the result in a property manager. The JSON content is flattened -- into a set of name/value pairs. The JSON structure is reflected in the name. -- Example: -- -- { "id": "1", id -> 1 -- "info": { "name": "search", info.name -> search -- "count": "12", info.count -> 12 -- "data": { "value": "empty" }}, info.data.value -> empty -- "count": 1 count -> 1 -- } -- -- To get the value of a JSON property, the user can use the flatten name. For example: -- -- Value : constant String := Props.Get ("info.data.value"); -- -- The default separator to construct a flatten name is the dot (`.`) but this can be -- changed easily when loading the JSON file by specifying the desired separator: -- -- Util.Properties.JSON.Read_JSON (Props, "config.json", "|"); -- -- Then, the property will be fetch by using: -- -- Value : constant String := Props.Get ("info|data|value"); -- package Util.Properties.JSON is -- Parse the JSON content and put the flattened content in the property manager. procedure Parse_JSON (Manager : in out Util.Properties.Manager'Class; Content : in String; Flatten_Separator : in String := "."); -- Read the JSON file into the property manager. -- The JSON content is flatten into Flatten the JSON content and add the properties. procedure Read_JSON (Manager : in out Util.Properties.Manager'Class; Path : in String; Flatten_Separator : in String := "."); end Util.Properties.JSON;
AdaCore/libadalang
Ada
194
adb
with Options; with Vectors; procedure Foo is package Int_Options is new Options (Integer); V : Int_Options.Option_Vectors.Vector; begin Int_Options.Option_Vectors.Clear (V); end Foo;
kraileth/ravenadm
Ada
130,896
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Utilities; with Ada.Characters.Latin_1; with Ada.Directories; with Parameters; with Unix; package body Port_Specification.Transform is package UTL renames Utilities; package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; -------------------------------------------------------------------------------------------- -- apply_directives -------------------------------------------------------------------------------------------- procedure apply_directives (specs : in out Portspecs; variant : String; arch_standard : supported_arch; osmajor : String) is procedure copy_option_over (position : option_crate.Cursor); procedure copy_option_over (position : option_crate.Cursor) is procedure augment (field : spec_option; directive : string_crate.Vector); procedure grow_plist_sub (name : String; currently_ON : Boolean); procedure handle_broken; rec : Option_Helper renames option_crate.Element (position); procedure augment (field : spec_option; directive : string_crate.Vector) is procedure transfer (position : string_crate.Cursor); procedure transfer (position : string_crate.Cursor) is item : HT.Text renames string_crate.Element (position); itemstr : String := HT.USS (item); special : HT.Text; begin if rec.currently_set_ON then case field is when buildrun_depends_on => specs.buildrun_deps.Append (item); when build_depends_on => specs.build_deps.Append (item); when build_target_on => specs.build_target.Append (item); when cflags_on => specs.cflags.Append (item); when cmake_args_on => specs.cmake_args.Append (item); when configure_args_on => specs.config_args.Append (item); when configure_env_on => specs.config_env.Append (item); when cppflags_on => specs.cppflags.Append (item); when cxxflags_on => specs.cxxflags.Append (item); when df_index_on => specs.df_index.Append (item); when extract_only_on => specs.extract_only.Append (item); when extra_patches_on => specs.extra_patches.Append (item); when gnome_comp_on => specs.gnome_comps.Append (item); when info_on => specs.info.Append (item); when install_target_on => specs.install_tgt.Append (item); when keywords_on => specs.keywords.Append (item); when ldflags_on => specs.ldflags.Append (item); when make_args_on => specs.make_args.Append (item); when make_env_on => specs.make_env.Append (item); when patchfiles_on => specs.patchfiles.Append (item); when plist_sub_on => specs.plist_sub.Append (item); when php_ext_on => specs.php_extensions.Append (item); when qmake_args_on => specs.qmake_args.Append (item); when run_depends_on => specs.run_deps.Append (item); when sub_files_on => specs.sub_files.Append (item); when sub_list_on => specs.sub_list.Append (item); when test_target_on => specs.test_tgt.Append (item); when makefile_on => specs.mk_verbatim.Append (item); when only_for_opsys_on => specs.inc_opsys.Append (item); when xorg_comp_on => specs.xorg_comps.Append (item); when uses_on => declare stripped : String := HT.part_1 (itemstr, ":"); text_stripped : HT.Text := HT.SUS (stripped); begin specs.uses.Append (item); if not specs.uses_base.Contains (text_stripped) then specs.uses_base.Append (text_stripped); end if; end; when cmake_bool_f_both => special := HT.SUS ("-D" & itemstr & ":BOOL=false"); specs.cmake_args.Append (special); when cmake_bool_t_both => special := HT.SUS ("-D" & itemstr & ":BOOL-true"); specs.cmake_args.Append (special); when configure_enable_both => special := HT.SUS ("--enable-" & itemstr); specs.config_args.Append (special); when configure_with_both => special := HT.SUS ("--with-" & itemstr); specs.config_args.Append (special); when others => null; end case; else case field is when buildrun_depends_off => specs.buildrun_deps.Append (item); when build_depends_off => specs.build_deps.Append (item); when build_target_off => specs.build_target.Append (item); when run_depends_off => specs.run_deps.Append (item); when cmake_args_off => specs.cmake_args.Append (item); when cflags_off => specs.cflags.Append (item); when cppflags_off => specs.cppflags.Append (item); when cxxflags_off => specs.cxxflags.Append (item); when ldflags_off => specs.ldflags.Append (item); when configure_args_off => specs.config_args.Append (item); when configure_env_off => specs.config_env.Append (item); when df_index_off => specs.df_index.Append (item); when extract_only_off => specs.extract_only.Append (item); when extra_patches_off => specs.extra_patches.Append (item); when gnome_comp_off => specs.gnome_comps.Append (item); when info_off => specs.info.Append (item); when install_target_off => specs.install_tgt.Append (item); when keywords_off => specs.keywords.Append (item); when makefile_off => specs.mk_verbatim.Append (item); when make_args_off => specs.make_args.Append (item); when make_env_off => specs.make_env.Append (item); when patchfiles_off => specs.patchfiles.Append (item); when plist_sub_off => specs.plist_sub.Append (item); when php_ext_off => specs.php_extensions.Append (item); when qmake_args_off => specs.qmake_args.Append (item); when sub_files_off => specs.sub_files.Append (item); when sub_list_off => specs.sub_list.Append (item); when test_target_off => specs.test_tgt.Append (item); when xorg_comp_off => specs.xorg_comps.Append (item); when cmake_bool_f_both => special := HT.SUS ("-D" & itemstr & ":BOOL-true"); specs.cmake_args.Append (special); when cmake_bool_t_both => special := HT.SUS ("-D" & itemstr & ":BOOL=false"); specs.cmake_args.Append (special); when configure_enable_both => special := HT.SUS ("--disable-" & itemstr); specs.config_args.Append (special); when configure_with_both => special := HT.SUS ("--without-" & itemstr); specs.config_args.Append (special); when uses_off => declare stripped : String := HT.part_1 (itemstr, ":"); text_stripped : HT.Text := HT.SUS (stripped); begin specs.uses.Append (item); if not specs.uses_base.Contains (text_stripped) then specs.uses_base.Append (text_stripped); end if; end; when others => null; end case; end if; end transfer; begin directive.Iterate (Process => transfer'Access); end augment; procedure grow_plist_sub (name : String; currently_ON : Boolean) is comment : constant String := LAT.Quotation & "@comment " & LAT.Quotation; WON : constant String := "-ON="; WOFF : constant String := "-OFF="; begin if currently_ON then specs.plist_sub.Append (HT.SUS (name & WON)); specs.plist_sub.Append (HT.SUS (name & WOFF & comment)); else specs.plist_sub.Append (HT.SUS (name & WOFF)); specs.plist_sub.Append (HT.SUS (name & WON & comment)); end if; end grow_plist_sub; procedure handle_broken is procedure grow (Key : HT.Text; Element : in out group_list); index : HT.Text := HT.SUS (broken_all); procedure grow (Key : HT.Text; Element : in out group_list) is begin Element.list.Append (rec.BROKEN_ON); end grow; begin if not HT.IsBlank (rec.BROKEN_ON) then if not specs.broken.Contains (index) then specs.establish_group (sp_broken, broken_all); end if; specs.broken.Update_Element (Position => specs.broken.Find (index), Process => grow'Access); end if; end handle_broken; begin if HT.equivalent (rec.option_name, options_none) then return; end if; if rec.currently_set_ON then handle_broken; augment (buildrun_depends_on, rec.BUILDRUN_DEPENDS_ON); augment (build_depends_on, rec.BUILD_DEPENDS_ON); augment (build_target_on, rec.BUILD_TARGET_ON); augment (cflags_off, rec.CFLAGS_OFF); augment (cflags_on, rec.CFLAGS_ON); augment (cmake_args_on, rec.CMAKE_ARGS_ON); augment (configure_args_on, rec.CONFIGURE_ARGS_ON); augment (configure_env_on, rec.CONFIGURE_ENV_ON); augment (cppflags_on, rec.CPPFLAGS_ON); augment (cxxflags_on, rec.CXXFLAGS_ON); augment (df_index_on, rec.DF_INDEX_ON); augment (extract_only_on, rec.EXTRACT_ONLY_ON); augment (extra_patches_on, rec.EXTRA_PATCHES_ON); augment (gnome_comp_on, rec.GNOME_COMPONENTS_ON); augment (info_on, rec.INFO_ON); augment (install_target_on, rec.INSTALL_TARGET_ON); augment (keywords_on, rec.KEYWORDS_ON); augment (ldflags_on, rec.LDFLAGS_ON); augment (makefile_on, rec.MAKEFILE_ON); augment (make_args_on, rec.MAKE_ARGS_ON); augment (make_env_on, rec.MAKE_ENV_ON); augment (only_for_opsys_on, rec.ONLY_FOR_OPSYS_ON); augment (patchfiles_on, rec.PATCHFILES_ON); augment (plist_sub_on, rec.PLIST_SUB_ON); augment (php_ext_on, rec.PHP_EXTENSIONS_ON); augment (qmake_args_on, rec.QMAKE_ARGS_ON); augment (run_depends_on, rec.RUN_DEPENDS_ON); augment (sub_files_on, rec.SUB_FILES_ON); augment (sub_list_on, rec.SUB_LIST_ON); augment (test_target_on, rec.TEST_TARGET_ON); augment (uses_on, rec.USES_ON); augment (xorg_comp_on, rec.XORG_COMPONENTS_ON); else augment (buildrun_depends_off, rec.BUILDRUN_DEPENDS_OFF); augment (build_depends_off, rec.BUILD_DEPENDS_OFF); augment (build_target_off, rec.BUILD_TARGET_OFF); augment (cflags_off, rec.CFLAGS_OFF); augment (cppflags_off, rec.CPPFLAGS_OFF); augment (cxxflags_off, rec.CXXFLAGS_OFF); augment (ldflags_off, rec.LDFLAGS_OFF); augment (cmake_args_off, rec.CMAKE_ARGS_OFF); augment (configure_args_off, rec.CONFIGURE_ARGS_OFF); augment (configure_env_off, rec.CONFIGURE_ENV_OFF); augment (df_index_off, rec.DF_INDEX_OFF); augment (extract_only_off, rec.EXTRACT_ONLY_OFF); augment (extra_patches_off, rec.EXTRA_PATCHES_OFF); augment (gnome_comp_off, rec.GNOME_COMPONENTS_OFF); augment (info_off, rec.INFO_OFF); augment (install_target_off, rec.INSTALL_TARGET_OFF); augment (keywords_off, rec.KEYWORDS_OFF); augment (makefile_off, rec.MAKEFILE_OFF); augment (make_args_off, rec.MAKE_ARGS_OFF); augment (make_env_off, rec.MAKE_ENV_OFF); augment (patchfiles_off, rec.PATCHFILES_OFF); augment (plist_sub_off, rec.PLIST_SUB_OFF); augment (php_ext_off, rec.PHP_EXTENSIONS_OFF); augment (qmake_args_off, rec.QMAKE_ARGS_OFF); augment (run_depends_off, rec.RUN_DEPENDS_OFF); augment (sub_files_off, rec.SUB_FILES_OFF); augment (sub_list_off, rec.SUB_LIST_OFF); augment (test_target_off, rec.TEST_TARGET_OFF); augment (uses_off, rec.USES_OFF); augment (xorg_comp_off, rec.XORG_COMPONENTS_OFF); end if; augment (cmake_bool_f_both, rec.CMAKE_BOOL_F_BOTH); augment (cmake_bool_t_both, rec.CMAKE_BOOL_T_BOTH); augment (configure_enable_both, rec.CONFIGURE_ENABLE_BOTH); augment (configure_with_both, rec.CONFIGURE_WITH_BOTH); grow_plist_sub (HT.USS (rec.option_name), rec.currently_set_ON); end copy_option_over; skip_compiler_packages : constant Boolean := Unix.env_variable_defined ("SKIPCCRUN"); begin specs.ops_helpers.Iterate (Process => copy_option_over'Access); apply_extraction_deps (specs); apply_opsys_dependencies (specs); apply_cpe_module (specs, arch_standard, osmajor); apply_gmake_module (specs); apply_scons_module (specs); apply_makeinfo_module (specs); apply_readline_module (specs); apply_libiconv_module (specs); apply_libtool_module (specs); apply_pkgconfig_module (specs); apply_gprbuild_module (specs); apply_ncurses_module (specs); apply_info_presence (specs); apply_gettext_runtime_module (specs); apply_gettext_tools_module (specs); apply_gnome_icons_module (specs); apply_mime_info_module (specs); apply_autoconf_module (specs); apply_execinfo_module (specs); apply_display_module (specs); apply_sqlite_module (specs); apply_cmake_module (specs); apply_imake_module (specs); apply_perl_module (specs); apply_bdb_module (specs); apply_ssl_module (specs); apply_clang_module (specs); apply_bison_module (specs); apply_mysql_module (specs); apply_pgsql_module (specs); apply_meson_module (specs); apply_ninja_module (specs); apply_fonts_module (specs); apply_python_module (specs); apply_cran_module (specs); apply_ruby_module (specs); apply_zlib_module (specs); apply_zstd_module (specs); apply_mesa_module (specs); apply_jpeg_module (specs); apply_tiff_module (specs); apply_pcre_module (specs); apply_lua_module (specs); apply_tcl_module (specs); apply_php_module (specs); apply_png_module (specs); apply_gif_module (specs); apply_gem_module (specs); apply_lz4_module (specs); apply_lzo_module (specs); apply_bz2_module (specs); apply_expat_module (specs); apply_cargo_module (specs); apply_gtkdoc_module (specs); apply_schemas_module (specs); apply_firebird_module (specs); apply_desktop_utils_module (specs); apply_gnome_components_dependencies (specs); apply_sdl_components_dependencies (specs); apply_xorg_components_dependencies (specs); apply_php_extension_dependencies (specs); if not skip_compiler_packages then apply_gcc_run_module (specs, variant, "ada", "ada_run"); apply_gcc_run_module (specs, variant, "c++", "cxx_run"); apply_gcc_run_module (specs, variant, "fortran", "fortran_run"); apply_gcc_run_module (specs, variant, "cclibs", "libs"); apply_gcc_run_module (specs, variant, "compiler", "complete"); if platform_type = sunos or else platform_type = macos then -- Solaris 10 doesn't use dl_iterate_phdr, so many packages have executables that -- requires libgcc_s.so. Rather than specify potentially hundreds of C_USES -- keywords, just make gcc8:libs:standard a run depends of every package (including -- gcc6, gcc7, gcc8 and later). add_exrun_cclibs (specs, variant); end if; end if; apply_curly_bracket_conversions (specs); apply_default_version_transformations (specs); convert_exrun_versions (specs); end apply_directives; -------------------------------------------------------------------------------------------- -- set_option_defaults -------------------------------------------------------------------------------------------- procedure set_option_defaults (specs : in out Portspecs; variant : String; opsys : supported_opsys; arch_standard : supported_arch; osrelease : String) is procedure vopt_set (position : string_crate.Cursor); procedure varstd_set (position : string_crate.Cursor); procedure opsys_set (position : string_crate.Cursor); procedure set_on (Key : HT.Text; Element : in out Option_Helper); variant_text : HT.Text := HT.SUS (variant); all_text : HT.Text := HT.SUS (options_all); arch_text : HT.Text := HT.SUS (UTL.cpu_arch (arch_standard)); opsys_text : HT.Text := HT.SUS (UTL.lower_opsys (opsys)); procedure set_on (Key : HT.Text; Element : in out Option_Helper) is begin Element.set_ON_by_default := True; end set_on; procedure vopt_set (position : string_crate.Cursor) is -- ignore =OFF versions (defaults already to False, only consider =ON item : String := HT.USS (string_crate.Element (position)); begin if HT.trails (item, "=ON") then declare option_name : String := HT.partial_search (item, 0, "="); option_text : HT.Text := HT.SUS (option_name); begin if specs.ops_helpers.Contains (option_text) then specs.ops_helpers.Update_Element (Position => specs.ops_helpers.Find (option_text), Process => set_on'Access); end if; end; end if; end vopt_set; procedure varstd_set (position : string_crate.Cursor) is option_name : String := HT.USS (string_crate.Element (position)); option_text : HT.Text := HT.SUS (option_name); begin if specs.ops_helpers.Contains (option_text) then specs.ops_helpers.Update_Element (Position => specs.ops_helpers.Find (option_text), Process => set_on'Access); end if; end varstd_set; procedure opsys_set (position : string_crate.Cursor) is -- Assume option name is valid option_name : String := HT.USS (string_crate.Element (position)); option_text : HT.Text; num_slash : Natural := HT.count_char (option_name, LAT.Solidus); begin if num_slash > 0 then if num_slash = 1 then declare opt_name : HT.Text := HT.SUS (HT.part_1 (option_name, "/")); spec_version : String := HT.part_2 (option_name, "/"); begin if GTE (gen_release => osrelease, spec_release => spec_version) then option_text := opt_name; end if; end; else declare opt_name : HT.Text := HT.SUS (HT.part_1 (option_name, "/")); temp_P2 : String := HT.part_2 (option_name, "/"); spec_version : String := HT.part_1 (temp_P2); arch_str : String := HT.part_2 (temp_P2); meets_ver : Boolean := spec_version = "" or else GTE (osrelease, spec_version); meets_arch : Boolean := HT.contains (arch_str, UTL.cpu_arch (arch_standard)); begin if meets_ver and then meets_arch then option_text := opt_name; end if; end; end if; else option_text := HT.SUS (option_name); end if; if specs.ops_helpers.Contains (option_text) then specs.ops_helpers.Update_Element (Position => specs.ops_helpers.Find (option_text), Process => set_on'Access); end if; end opsys_set; begin if variant = variant_standard then if specs.options_on.Contains (all_text) then specs.options_on.Element (all_text).list.Iterate (Process => varstd_set'Access); end if; if specs.options_on.Contains (arch_text) then specs.options_on.Element (arch_text).list.Iterate (Process => varstd_set'Access); end if; if not specs.skip_opsys_dep then if specs.options_on.Contains (opsys_text) then specs.options_on.Element (opsys_text).list.Iterate (Process => opsys_set'Access); end if; end if; else if not specs.variantopts.Contains (variant_text) then -- Variant does not exist, silently exit return; end if; specs.variantopts.Element (variant_text).list.Iterate (Process => vopt_set'Access); end if; end set_option_defaults; -------------------------------------------------------------------------------------------- -- set_option_to_default_values -------------------------------------------------------------------------------------------- procedure set_option_to_default_values (specs : in out Portspecs) is procedure copy_setting (position : option_crate.Cursor); procedure copy_setting (position : option_crate.Cursor) is procedure set_option (Key : HT.Text; Element : in out Option_Helper); procedure set_option (Key : HT.Text; Element : in out Option_Helper) is begin Element.currently_set_ON := Element.set_ON_by_default; end set_option; begin specs.ops_helpers.Update_Element (Position => position, Process => set_option'Access); end copy_setting; begin specs.ops_helpers.Iterate (Process => copy_setting'Access); end set_option_to_default_values; -------------------------------------------------------------------------------------------- -- define_option_setting -------------------------------------------------------------------------------------------- procedure define_option_setting (specs : in out Portspecs; option : String; value : Boolean) is procedure set_option (Key : HT.Text; Element : in out Option_Helper); optname_text : HT.Text := HT.SUS (option); procedure set_option (Key : HT.Text; Element : in out Option_Helper) is begin Element.currently_set_ON := value; end set_option; begin if specs.ops_helpers.Contains (optname_text) then specs.ops_helpers.Update_Element (Position => specs.ops_helpers.Find (optname_text), Process => set_option'Access); end if; end define_option_setting; -------------------------------------------------------------------------------------------- -- release_format -------------------------------------------------------------------------------------------- function release_format (candidate : String) return Boolean is fullstop : Boolean := False; begin for X in candidate'Range loop case candidate (X) is when '.' => if fullstop then return False; end if; if X = candidate'First or else X = candidate'Last then return False; end if; fullstop := True; when '0' .. '9' => null; when others => return False; end case; end loop; return True; end release_format; -------------------------------------------------------------------------------------------- -- centurian_release -------------------------------------------------------------------------------------------- function centurian_release (release : String) return Natural is -- Requires release is validated by release_format() X : String := HT.part_1 (release, "."); Y : String := HT.part_2 (release, "."); RX : Natural := Integer'Value (X) * 100; RY : Natural := 0; begin if Y = "" then RY := Integer'Value (Y); end if; return (RX + RY); end centurian_release; -------------------------------------------------------------------------------------------- -- LTE -------------------------------------------------------------------------------------------- function LTE (gen_release, spec_release : String) return Boolean is GR : Natural := 999900; SR : Natural := 0; begin if release_format (gen_release) then GR := centurian_release (gen_release); end if; if release_format (spec_release) then SR := centurian_release (spec_release); end if; return (GR <= SR); end LTE; -------------------------------------------------------------------------------------------- -- GTE -------------------------------------------------------------------------------------------- function GTE (gen_release, spec_release : String) return Boolean is GR : Natural := 0; SR : Natural := 999900; begin if release_format (gen_release) then GR := centurian_release (spec_release); end if; if release_format (spec_release) then SR := centurian_release (spec_release); end if; return (GR >= SR); end GTE; -------------------------------------------------------------------------------------------- -- set_outstanding_ignore -------------------------------------------------------------------------------------------- procedure set_outstanding_ignore (specs : in out Portspecs; variant : String; opsys : supported_opsys; arch_standard : supported_arch; osrelease : String; osmajor : String) is -- Copy relevant arch broken to "all" index -- Copy relevant opsys broken to "all" index (may be funtion of release or arch) procedure check (position : list_crate.Cursor); procedure check_ignore; cpu_ia64 : constant String := UTL.cpu_arch (x86_64) & "_"; cpu_ia32 : constant String := UTL.cpu_arch (i386) & "_"; cpu_armv8 : constant String := UTL.cpu_arch (aarch64) & "_"; separator : constant String := ": "; index : HT.Text := HT.SUS (broken_all); procedure check (position : list_crate.Cursor) is procedure check_list (position : string_crate.Cursor); broken_Key : String := HT.USS (list_crate.Element (position).group); procedure check_list (position : string_crate.Cursor) is procedure grow (Key : HT.Text; Element : in out group_list); reason : String := HT.USS (string_crate.Element (position)); used : Boolean := False; split : Boolean := True; procedure grow (Key : HT.Text; Element : in out group_list) is begin if split then Element.list.Append (HT.SUS (HT.part_2 (reason, ": "))); else Element.list.Append (string_crate.Element (position)); end if; end grow; begin if broken_Key = UTL.cpu_arch (arch_standard) then used := True; split := False; elsif broken_Key = UTL.lower_opsys (opsys) then if HT.leads (reason, "REL_") then used := (HT.partial_search (reason, 4, separator) = osmajor); elsif HT.leads (reason, "GTE_") then used := GTE (gen_release => osrelease, spec_release => HT.partial_search (reason, 4, separator)); elsif HT.leads (reason, "LTE_") then used := LTE (gen_release => osmajor, spec_release => HT.partial_search (reason, 4, separator)); elsif HT.leads (reason, cpu_ia64) then used := (HT.partial_search (reason, cpu_ia64'Length, separator) = osmajor); elsif HT.leads (reason, cpu_ia32) then used := (HT.partial_search (reason, cpu_ia32'Length, separator) = osmajor); elsif HT.leads (reason, cpu_armv8) then used := (HT.partial_search (reason, cpu_armv8'Length, separator) = osmajor); else used := True; split := False; end if; end if; if used then if not specs.broken.Contains (index) then specs.establish_group (sp_broken, broken_all); end if; specs.broken.Update_Element (Position => specs.broken.Find (index), Process => grow'Access); end if; end check_list; begin if not specs.skip_opsys_dep then list_crate.Element (position).list.Iterate (Process => check_list'Access); end if; end check; procedure check_ignore is procedure grow (Key : HT.Text; Element : in out group_list); procedure append_ignore; reason : HT.Text; procedure grow (Key : HT.Text; Element : in out group_list) is begin Element.list.Append (reason); end grow; procedure append_ignore is begin -- Call after "reason" is set if not specs.broken.Contains (index) then specs.establish_group (sp_broken, broken_all); end if; specs.broken.Update_Element (Position => specs.broken.Find (index), Process => grow'Access); end append_ignore; LIST_SSL_FAILURE : constant String := "Does not build with SSL default '"; LIST_MYSQL_FAILURE : constant String := "Does not build with MySQL default '"; LIST_PGSQL_FAILURE : constant String := "Does not build with PGSQL default '"; begin if not specs.skip_opsys_dep then if specs.exc_opsys.Contains (HT.SUS (UTL.lower_opsys (opsys))) or else (not specs.inc_opsys.Is_Empty and then not specs.inc_opsys.Contains (HT.SUS (UTL.lower_opsys (opsys)))) then reason := HT.SUS ("Specification excludes " & UTL.mixed_opsys (opsys) & " OS"); append_ignore; end if; if specs.exc_arch.Contains (HT.SUS (UTL.cpu_arch (arch_standard))) then reason := HT.SUS ("Specification excludes " & UTL.cpu_arch (arch_standard) & " architecture"); append_ignore; end if; end if; -- Handle BROKEN_SSL directive if HT.equivalent (Parameters.configuration.def_ssl, ports_default) then if specs.broken_ssl.Contains (HT.SUS (default_ssl)) then reason := HT.SUS (LIST_SSL_FAILURE & default_ssl & "'"); append_ignore; end if; else if specs.broken_ssl.Contains (Parameters.configuration.def_ssl) then reason := HT.SUS (LIST_SSL_FAILURE & HT.USS (Parameters.configuration.def_ssl) & "'"); append_ignore; end if; end if; -- Handle BROKEN_MYSQL directive if HT.equivalent (Parameters.configuration.def_mysql_group, ports_default) then if specs.broken_mysql.Contains (HT.SUS (default_mysql)) then reason := HT.SUS (LIST_MYSQL_FAILURE & default_mysql & "'"); append_ignore; end if; else if specs.broken_mysql.Contains (Parameters.configuration.def_mysql_group) then reason := HT.SUS (LIST_MYSQL_FAILURE & HT.USS (Parameters.configuration.def_mysql_group) & "'"); append_ignore; end if; end if; -- Handle BROKEN_PGSQL directive if HT.equivalent (Parameters.configuration.def_postgresql, ports_default) then if specs.broken_pgsql.Contains (HT.SUS (default_pgsql)) then reason := HT.SUS (LIST_PGSQL_FAILURE & default_pgsql & "'"); append_ignore; end if; else if specs.broken_pgsql.Contains (Parameters.configuration.def_postgresql) then reason := HT.SUS (LIST_PGSQL_FAILURE & HT.USS (Parameters.configuration.def_postgresql) & "'"); append_ignore; end if; end if; end check_ignore; begin specs.broken.Iterate (Process => check'Access); check_ignore; end set_outstanding_ignore; -------------------------------------------------------------------------------------------- -- apply_cpe_module -------------------------------------------------------------------------------------------- procedure apply_cpe_module (specs : in out Portspecs; arch_standard : supported_arch; osmajor : String) is function retrieve (key : String; default_value : String) return String; function arch_default return String; function other_default return String; text_cpe : HT.Text := HT.SUS ("cpe"); function retrieve (key : String; default_value : String) return String is key_text : HT.Text := HT.SUS (key); begin if specs.catch_all.Contains (key_text) then return HT.USS (specs.catch_all.Element (key_text).list.First_Element); else return default_value; end if; end retrieve; function arch_default return String is begin case arch_standard is when x86_64 => return "x64"; when i386 => return "x86"; when aarch64 => return "aarch64"; end case; end arch_default; function other_default return String is begin if specs.revision = 0 then return ""; else return LAT.Colon & HT.int2str (specs.revision); end if; end other_default; begin if not specs.uses.Contains (text_cpe) then return; end if; declare cpe_product : String := retrieve ("CPE_PRODUCT", HT.lowercase (specs.get_namebase)); cpe_vendor : String := retrieve ("CPE_VENDOR", cpe_product); cpe_version : String := retrieve ("CPE_VERSION", HT.lowercase (HT.USS (specs.version))); cpe_tgt_sw : String := retrieve ("CPE_TARGET_SW", UTL.lower_opsys (platform_type) & osmajor); default_note : String := "cpe:2.3" & LAT.Colon & retrieve ("CPE_PART", "a") & LAT.Colon & cpe_vendor & LAT.Colon & cpe_product & LAT.Colon & cpe_version & LAT.Colon & retrieve ("CPE_UPDATE", "") & LAT.Colon & retrieve ("CPE_EDITION", "") & LAT.Colon & retrieve ("CPE_LANG", "") & LAT.Colon & retrieve ("CPE_SW_EDITION", "") & LAT.Colon & cpe_tgt_sw & LAT.Colon & retrieve ("CPE_TARGET_HW", arch_default) & retrieve ("CPE_OTHER", other_default); begin specs.pkg_notes.Insert (text_cpe, HT.SUS (retrieve ("CPE_STR", default_note))); end; end apply_cpe_module; -------------------------------------------------------------------------------------------- -- generic_build_module -------------------------------------------------------------------------------------------- procedure generic_build_module (specs : in out Portspecs; module : String; dependency : String) is begin if specs.uses_base.Contains (HT.SUS (module)) then add_build_depends (specs, dependency); end if; end generic_build_module; -------------------------------------------------------------------------------------------- -- generic_library_module -------------------------------------------------------------------------------------------- procedure generic_library_module (specs : in out Portspecs; module : String; dependency : String) is begin if specs.uses_base.Contains (HT.SUS (module)) then add_buildrun_depends (specs, dependency); end if; end generic_library_module; -------------------------------------------------------------------------------------------- -- generic_run_module -------------------------------------------------------------------------------------------- procedure generic_run_module (specs : in out Portspecs; module : String; dependency : String) is begin if specs.uses_base.Contains (HT.SUS (module)) then add_run_depends (specs, dependency); end if; end generic_run_module; -------------------------------------------------------------------------------------------- -- apply_scons_module -------------------------------------------------------------------------------------------- procedure apply_scons_module (specs : in out Portspecs) is module : String := "scons"; dependency : String := "scons:single:standard"; begin generic_build_module (specs, module, dependency); end apply_scons_module; -------------------------------------------------------------------------------------------- -- apply_gmake_module -------------------------------------------------------------------------------------------- procedure apply_gmake_module (specs : in out Portspecs) is module : String := "gmake"; dependency : String := "gmake:single:ravensys"; begin generic_build_module (specs, module, dependency); end apply_gmake_module; -------------------------------------------------------------------------------------------- -- apply_cargo_module -------------------------------------------------------------------------------------------- procedure apply_cargo_module (specs : in out Portspecs) is module : String := "cargo"; dependency : String := "rust:single:standard"; begin generic_build_module (specs, module, dependency); end apply_cargo_module; -------------------------------------------------------------------------------------------- -- apply_ninja_module -------------------------------------------------------------------------------------------- procedure apply_ninja_module (specs : in out Portspecs) is module : String := "ninja"; dependency : String renames NINJA; begin generic_build_module (specs, module, dependency); end apply_ninja_module; -------------------------------------------------------------------------------------------- -- apply_meson_module -------------------------------------------------------------------------------------------- procedure apply_meson_module (specs : in out Portspecs) is module : String := "meson"; dependency : String := "meson:single:standard"; begin generic_build_module (specs, module, dependency); generic_build_module (specs, module, NINJA); end apply_meson_module; -------------------------------------------------------------------------------------------- -- apply_zlib_module -------------------------------------------------------------------------------------------- procedure apply_zlib_module (specs : in out Portspecs) is module : String := "zlib"; prefix : String := "zlib"; begin generic_split_module (specs, module, prefix); end apply_zlib_module; -------------------------------------------------------------------------------------------- -- apply_mesa_module -------------------------------------------------------------------------------------------- procedure apply_mesa_module (specs : in out Portspecs) is module : String := "mesa"; dependency : String := "mesa:libs:standard"; begin generic_library_module (specs, module, dependency); end apply_mesa_module; -------------------------------------------------------------------------------------------- -- apply_makeinfo_module -------------------------------------------------------------------------------------------- procedure apply_makeinfo_module (specs : in out Portspecs) is module : String := "makeinfo"; dependency : String := "texinfo:single:standard"; begin generic_build_module (specs, module, dependency); end apply_makeinfo_module; -------------------------------------------------------------------------------------------- -- apply_readline_module -------------------------------------------------------------------------------------------- procedure apply_readline_module (specs : in out Portspecs) is module : String := "readline"; dependency : String := "readline:single:standard"; begin generic_library_module (specs, module, dependency); end apply_readline_module; -------------------------------------------------------------------------------------------- -- apply_sqlite_module -------------------------------------------------------------------------------------------- procedure apply_sqlite_module (specs : in out Portspecs) is module : String := "sqlite"; dependency : String := "sqlite:single:standard"; begin generic_library_module (specs, module, dependency); end apply_sqlite_module; -------------------------------------------------------------------------------------------- -- apply_execinfo_module -------------------------------------------------------------------------------------------- procedure apply_execinfo_module (specs : in out Portspecs) is module : String := "execinfo"; dependency : String := "libexecinfo:single:standard"; begin if platform_type /= macos then -- MacOS has Mach-O formatted files while libexecinfo only -- functions under the ELF format, so it's both unbuildable and unusable on mac. if specs.uses_base.Contains (HT.SUS (module)) then if argument_present (specs, module, BUILD) then add_build_depends (specs, dependency); else add_buildrun_depends (specs, dependency); end if; end if; end if; end apply_execinfo_module; -------------------------------------------------------------------------------------------- -- apply_cmake_module -------------------------------------------------------------------------------------------- procedure apply_cmake_module (specs : in out Portspecs) is module : String := "cmake"; dependency : String := "cmake:single:standard"; begin if specs.uses_base.Contains (HT.SUS (module)) then if argument_present (specs, module, RUN) then add_buildrun_depends (specs, dependency); else add_build_depends (specs, dependency); end if; end if; end apply_cmake_module; -------------------------------------------------------------------------------------------- -- apply_imake_module -------------------------------------------------------------------------------------------- procedure apply_imake_module (specs : in out Portspecs) is module : String := "imake"; dependency : String := "imake:single:standard"; begin generic_build_module (specs, module, dependency); end apply_imake_module; -------------------------------------------------------------------------------------------- -- apply_clang_module -------------------------------------------------------------------------------------------- procedure apply_clang_module (specs : in out Portspecs) is module : String := "clang"; dependency : String := "clang:complete:standard"; begin generic_build_module (specs, module, dependency); end apply_clang_module; -------------------------------------------------------------------------------------------- -- apply_gtkdoc_module -------------------------------------------------------------------------------------------- procedure apply_gtkdoc_module (specs : in out Portspecs) is module : String := "gtk-doc"; dependency : String := "gtk-doc:single:standard"; begin generic_build_module (specs, module, dependency); end apply_gtkdoc_module; -------------------------------------------------------------------------------------------- -- apply_cran_module -------------------------------------------------------------------------------------------- procedure apply_cran_module (specs : in out Portspecs) is module : String := "cran"; cran_build : String := "R:primary:standard"; cran_run : String := "R:complete:standard"; begin generic_build_module (specs, module, cran_build); generic_run_module (specs, module, cran_run); end apply_cran_module; -------------------------------------------------------------------------------------------- -- apply_gcc_run_module -------------------------------------------------------------------------------------------- procedure apply_gcc_run_module (specs : in out Portspecs; variant : String; module : String; gccsubpackage : String) is procedure scan (position : string_crate.Cursor); dependency : String := default_compiler & ":" & gccsubpackage & ":" & variant_standard; procedure scan (position : string_crate.Cursor) is subpackage : String := HT.USS (string_crate.Element (position)); begin if argument_present (specs, module, subpackage) then add_exrun_depends (specs, dependency, subpackage); end if; end scan; begin if specs.uses_base.Contains (HT.SUS (module)) then specs.subpackages.Element (HT.SUS (variant)).list.Iterate (scan'Access); end if; end apply_gcc_run_module; -------------------------------------------------------------------------------------------- -- add_exrun_cclibs -------------------------------------------------------------------------------------------- procedure add_exrun_cclibs (specs : in out Portspecs; variant : String) is prime_pkg : HT.Text; primary_found : Boolean := False; begin -- Calculate "primary" package for item in Positive range 1 .. specs.get_subpackage_length (variant) loop declare subpackage : String := specs.get_subpackage_item (variant, item); begin if not primary_found and then subpackage /= spkg_complete and then subpackage /= spkg_examples and then subpackage /= spkg_nls and then subpackage /= spkg_docs then prime_pkg := HT.SUS (subpackage); primary_found := True; end if; end; end loop; -- Abort if primary package was never determined. Spec file is wrong? if not primary_found then return; end if; declare dependency : String := default_compiler & ":libs:" & variant_standard; begin -- Check if cclibs:<subpackage> has already been set, and abort if so if specs.extra_rundeps.Contains (prime_pkg) and then specs.extra_rundeps.Element (prime_pkg).list.Contains (HT.SUS (dependency)) then return; end if; -- set cclibs:<primary subpackage> add_exrun_depends (specs, dependency, HT.USS (prime_pkg)); end; end add_exrun_cclibs; -------------------------------------------------------------------------------------------- -- apply_firebird_module -------------------------------------------------------------------------------------------- procedure apply_firebird_module (specs : in out Portspecs) is function determine_dependency return String; module : String := "firebird"; function determine_dependency return String is suffix : String := ":client:standard"; setting : constant String := HT.USS (Parameters.configuration.def_mysql_group); begin if argument_present (specs, module, "server") then suffix := ":server:standard"; end if; if setting = "3.0" then return "firebird30" & suffix; else -- case: setting = ports_default -- case: setting = default_firebird -- case: setting = invalid value return "firebird25" & suffix; end if; end determine_dependency; dependency : String := determine_dependency; begin generic_library_module (specs, module, dependency); end apply_firebird_module; -------------------------------------------------------------------------------------------- -- apply_mysql_module -------------------------------------------------------------------------------------------- procedure apply_mysql_module (specs : in out Portspecs) is function determine_dependency return String; module : String := "mysql"; function determine_dependency return String is begin if argument_present (specs, module, "server") then return determine_mysql_package (True); else return determine_mysql_package (False); end if; end determine_dependency; dependency : String := determine_dependency; begin if specs.uses_base.Contains (HT.SUS (module)) then if argument_present (specs, module, "build") then add_build_depends (specs, dependency); else add_buildrun_depends (specs, dependency); end if; end if; end apply_mysql_module; -------------------------------------------------------------------------------------------- -- apply_pgsql_module -------------------------------------------------------------------------------------------- procedure apply_pgsql_module (specs : in out Portspecs) is procedure set_dependency (subpackage : String); procedure set_dependency_on_subpackage (subpackage : String); module : String := "pgsql"; namebase : String := determine_pgsql_namebase; build_only : Boolean := argument_present (specs, module, BUILD); procedure set_dependency (subpackage : String) is dependency : String := namebase & ":" & subpackage & ":standard"; begin if build_only then add_build_depends (specs, dependency); else add_buildrun_depends (specs, dependency); end if; end set_dependency; procedure set_dependency_on_subpackage (subpackage : String) is begin if argument_present (specs, module, subpackage) then set_dependency (subpackage); end if; end set_dependency_on_subpackage; begin if specs.uses_base.Contains (HT.SUS (module)) then if no_arguments_present (specs, module) then set_dependency ("client"); elsif argument_present (specs, module, "all") then -- ignore everything else set_dependency (spkg_complete); else set_dependency_on_subpackage ("server"); set_dependency_on_subpackage ("plperl"); set_dependency_on_subpackage ("plpython"); set_dependency_on_subpackage ("pltcl"); set_dependency_on_subpackage ("contrib"); if not argument_present (specs, module, "server") then set_dependency_on_subpackage ("client"); end if; end if; end if; end apply_pgsql_module; -------------------------------------------------------------------------------------------- -- apply_ncurses_module -------------------------------------------------------------------------------------------- procedure apply_ncurses_module (specs : in out Portspecs) is module : String := "ncurses"; full_dependency : String := "ncurses:primary:standard"; static_dependency : String := "ncurses:primary:static"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then add_buildrun_depends (specs, full_dependency); elsif argument_present (specs, module, "static") then add_build_depends (specs, static_dependency); end if; end apply_ncurses_module; -------------------------------------------------------------------------------------------- -- apply_libtool_module -------------------------------------------------------------------------------------------- procedure apply_libtool_module (specs : in out Portspecs) is module : String := "libtool"; dependency : String := "libtool:single:standard"; begin if specs.uses_base.Contains (HT.SUS (module)) and then argument_present (specs, module, BUILD) then add_build_depends (specs, dependency); end if; end apply_libtool_module; -------------------------------------------------------------------------------------------- -- generic_split_module -------------------------------------------------------------------------------------------- procedure generic_split_module (specs : in out Portspecs; module : String; depprefix : String) is shared_dependency : String := depprefix & ":shared:standard"; static_dependency : String := depprefix & ":static:standard"; begin if specs.uses_base.Contains (HT.SUS (module)) then add_build_depends (specs, static_dependency); if not argument_present (specs, module, BUILD) then add_buildrun_depends (specs, shared_dependency); end if; end if; end generic_split_module; -------------------------------------------------------------------------------------------- -- apply_libiconv_module -------------------------------------------------------------------------------------------- procedure apply_libiconv_module (specs : in out Portspecs) is module : String := "iconv"; dep_prefix : String := "libiconv"; begin generic_split_module (specs, module, dep_prefix); end apply_libiconv_module; -------------------------------------------------------------------------------------------- -- apply_zstd_module -------------------------------------------------------------------------------------------- procedure apply_zstd_module (specs : in out Portspecs) is module : String := "zstd"; dep_prefix : String := "Zstandard"; begin generic_split_module (specs, module, dep_prefix); end apply_zstd_module; -------------------------------------------------------------------------------------------- -- apply_lz4_module -------------------------------------------------------------------------------------------- procedure apply_lz4_module (specs : in out Portspecs) is module : String := "lz4"; dep_prefix : String := "lz4"; begin generic_split_module (specs, module, dep_prefix); end apply_lz4_module; -------------------------------------------------------------------------------------------- -- apply_lzo_module -------------------------------------------------------------------------------------------- procedure apply_lzo_module (specs : in out Portspecs) is module : String := "lzo"; dep_prefix : String := "lzo"; begin generic_split_module (specs, module, dep_prefix); end apply_lzo_module; -------------------------------------------------------------------------------------------- -- apply_bz2_module -------------------------------------------------------------------------------------------- procedure apply_bz2_module (specs : in out Portspecs) is module : String := "bz2"; dep_prefix : String := "bzip2"; begin generic_split_module (specs, module, dep_prefix); end apply_bz2_module; -------------------------------------------------------------------------------------------- -- apply_expat_module -------------------------------------------------------------------------------------------- procedure apply_expat_module (specs : in out Portspecs) is module : String := "expat"; dep_prefix : String := "expat"; begin generic_split_module (specs, module, dep_prefix); end apply_expat_module; -------------------------------------------------------------------------------------------- -- apply_pcre_module -------------------------------------------------------------------------------------------- procedure apply_pcre_module (specs : in out Portspecs) is module : String := "pcre"; dep_prefix : String := "pcre"; begin generic_split_module (specs, module, dep_prefix); end apply_pcre_module; -------------------------------------------------------------------------------------------- -- apply_info_presence -------------------------------------------------------------------------------------------- procedure apply_info_presence (specs : in out Portspecs) is dependency : String := "indexinfo:single:standard"; begin if not specs.info.Is_Empty then add_buildrun_depends (specs, dependency); end if; end apply_info_presence; -------------------------------------------------------------------------------------------- -- apply_pkgconfig_module -------------------------------------------------------------------------------------------- procedure apply_pkgconfig_module (specs : in out Portspecs) is module : String := "pkgconfig"; dependency : String := "pkgconf:single:standard"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) or else argument_present (specs, module, BUILD) then add_build_depends (specs, dependency); else if argument_present (specs, module, BUILDRUN) then add_buildrun_depends (specs, dependency); elsif argument_present (specs, module, RUN) then add_run_depends (specs, dependency); end if; end if; end apply_pkgconfig_module; -------------------------------------------------------------------------------------------- -- apply_autoconf_module -------------------------------------------------------------------------------------------- procedure apply_autoconf_module (specs : in out Portspecs) is module : String := "autoreconf"; AUTOCONF : String := "autoconf:single:standard"; AUTOMAKE : String := "automake:single:standard"; LIBTOOL : String := "libtool:single:standard"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; add_build_depends (specs, AUTOCONF); add_build_depends (specs, AUTOMAKE); if not argument_present (specs, module, BUILD) then add_build_depends (specs, LIBTOOL); end if; end apply_autoconf_module; -------------------------------------------------------------------------------------------- -- apply_gprbuild_module -------------------------------------------------------------------------------------------- procedure apply_gprbuild_module (specs : in out Portspecs) is module : String := "gprbuild"; dependency : String := "gprbuild:primary:standard"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) or else argument_present (specs, module, BUILD) then add_build_depends (specs, dependency); else if argument_present (specs, module, BUILDRUN) then add_buildrun_depends (specs, dependency); elsif argument_present (specs, module, RUN) then add_run_depends (specs, dependency); end if; end if; end apply_gprbuild_module; -------------------------------------------------------------------------------------------- -- apply_display_module -------------------------------------------------------------------------------------------- procedure apply_display_module (specs : in out Portspecs) is module : String := "display"; begin if specs.uses_base.Contains (HT.SUS (module)) then add_build_depends (specs, "xorg-server:single:virtual"); add_build_depends (specs, "xorg-misc-bitmap-fonts:single:standard"); add_build_depends (specs, "xorg-font-alias:single:standard"); add_build_depends (specs, "daemonize:single:standard"); end if; end apply_display_module; -------------------------------------------------------------------------------------------- -- apply_gnome_icons_module -------------------------------------------------------------------------------------------- procedure apply_gnome_icons_module (specs : in out Portspecs) is module : String := "gnome-icons"; dependency : String := "gtk-update-icon-cache:single:standard"; begin generic_run_module (specs, module, dependency); end apply_gnome_icons_module; -------------------------------------------------------------------------------------------- -- apply_mime_info_module -------------------------------------------------------------------------------------------- procedure apply_mime_info_module (specs : in out Portspecs) is module : String := "mime-info"; dependency : String := "shared-mime-info:primary:standard"; begin generic_library_module (specs, module, dependency); end apply_mime_info_module; -------------------------------------------------------------------------------------------- -- apply_schemas_module -------------------------------------------------------------------------------------------- procedure apply_schemas_module (specs : in out Portspecs) is module : String := "schemas"; dependency : String renames GNOMELIB; begin generic_run_module (specs, module, dependency); end apply_schemas_module; -------------------------------------------------------------------------------------------- -- apply_desktop_utils_module -------------------------------------------------------------------------------------------- procedure apply_desktop_utils_module (specs : in out Portspecs) is module : String := "desktop-utils"; dependency : String := "desktop-file-utils:single:standard"; begin generic_library_module (specs, module, dependency); end apply_desktop_utils_module; -------------------------------------------------------------------------------------------- -- apply_gettext_tools_module -------------------------------------------------------------------------------------------- procedure apply_gettext_tools_module (specs : in out Portspecs) is module : String := "gettext-tools"; dependency : String := "gettext:tools:standard"; begin generic_3B_module (specs, module, dependency); end apply_gettext_tools_module; -------------------------------------------------------------------------------------------- -- apply_gettext_runtime_module -------------------------------------------------------------------------------------------- procedure apply_gettext_runtime_module (specs : in out Portspecs) is module : String := "gettext-runtime"; dependency : String := "gettext:runtime:standard"; asprintf : String := "gettext:asprintf:standard"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; generic_3BR_module (specs, module, dependency); if argument_present (specs, module, "asprintf") then generic_3BR_module (specs, module, asprintf); end if; end apply_gettext_runtime_module; -------------------------------------------------------------------------------------------- -- apply_python_module -------------------------------------------------------------------------------------------- procedure apply_python_module (specs : in out Portspecs) is procedure set_snake_ports (build_only : Boolean; python_port, py_variant : String); module : constant String := "python"; PY27 : constant String := "py27"; PY38 : constant String := "py38"; PY39 : constant String := "py39"; autopython : constant String := "autoselect-python:single:standard"; use_pip : Boolean := False; use_setup : Boolean := False; procedure set_snake_ports (build_only : Boolean; python_port, py_variant : String) is begin if build_only then add_build_depends (specs, python_port); else add_buildrun_depends (specs, python_port); end if; if use_pip then add_build_depends (specs, "python-pip:single:" & py_variant); end if; if use_setup then add_build_depends (specs, "python-setuptools:single:" & py_variant); end if; specs.used_python := HT.SUS (py_variant); end set_snake_ports; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; -- When changing python defaults, don't forget to alter convert_exrun_versions() too. if argument_present (specs, module, "wheel") then use_pip := True; end if; if argument_present (specs, module, "sutools") then use_setup := True; end if; if argument_present (specs, module, "build") then if argument_present (specs, module, PY27) then set_snake_ports (True, PYTHON27, PY27); elsif argument_present (specs, module, PY39) then set_snake_ports (True, PYTHON39, PY39); else -- default to py38 set_snake_ports (True, PYTHON38, PY38); end if; else if argument_present (specs, module, PY27) then set_snake_ports (False, PYTHON27, PY27); elsif argument_present (specs, module, PY39) then set_snake_ports (False, PYTHON39, PY39); else -- default to py38 set_snake_ports (False, PYTHON38, PY38); end if; end if; add_build_depends (specs, autopython); end apply_python_module; -------------------------------------------------------------------------------------------- -- apply_ruby_module -------------------------------------------------------------------------------------------- procedure apply_ruby_module (specs : in out Portspecs) is module : constant String := "ruby"; v26 : constant String := "v26"; v27 : constant String := "v27"; v30 : constant String := "v30"; begin if not specs.uses_base.Contains (HT.SUS (module)) or else argument_present (specs, module, "interp") then return; end if; if argument_present (specs, module, "build") then if argument_present (specs, module, v30) then add_build_depends (specs, RUBY30); specs.used_ruby := HT.SUS (RUBY30); elsif argument_present (specs, module, v26) then add_build_depends (specs, RUBY26); specs.used_ruby := HT.SUS (RUBY26); else -- default to current default add_build_depends (specs, RUBY27); specs.used_ruby := HT.SUS (RUBY27); end if; else if argument_present (specs, module, v30) then add_buildrun_depends (specs, RUBY30); specs.used_ruby := HT.SUS (RUBY30); elsif argument_present (specs, module, v26) then add_buildrun_depends (specs, RUBY26); specs.used_ruby := HT.SUS (RUBY26); else -- default to current default add_buildrun_depends (specs, RUBY27); specs.used_ruby := HT.SUS (RUBY27); end if; end if; end apply_ruby_module; -------------------------------------------------------------------------------------------- -- apply_fonts_module -------------------------------------------------------------------------------------------- procedure apply_fonts_module (specs : in out Portspecs) is module : String := "fonts"; fontconfig : String := "fontconfig:primary:standard"; mkfontscale : String := "xorg-mkfontscale:single:standard"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) or else argument_present (specs, module, "fontsdir") then add_buildrun_depends (specs, mkfontscale); return; end if; if argument_present (specs, module, "fc") then add_buildrun_depends (specs, fontconfig); return; end if; if argument_present (specs, module, "fcfontsdir") then add_buildrun_depends (specs, fontconfig); add_buildrun_depends (specs, mkfontscale); end if; end apply_fonts_module; -------------------------------------------------------------------------------------------- -- apply_bison_module -------------------------------------------------------------------------------------------- procedure apply_bison_module (specs : in out Portspecs) is module : String := "bison"; dependency : String := "bison:primary:standard"; begin generic_3B_module (specs, module, dependency); end apply_bison_module; -------------------------------------------------------------------------------------------- -- generic_3BR_module -------------------------------------------------------------------------------------------- procedure generic_3BR_module (specs : in out Portspecs; module : String; dependency : String) is -- Defaults to BUILDRUN, takes explicit "build", "run", "buildrun" hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := False; hit_both := True; hit_run := False; else hit_build := argument_present (specs, module, BUILD); hit_both := argument_present (specs, module, BUILDRUN); hit_run := argument_present (specs, module, RUN); if not (hit_build or else hit_both or else hit_run) then hit_both := True; end if; end if; if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); else add_run_depends (specs, dependency); end if; end generic_3BR_module; -------------------------------------------------------------------------------------------- -- generic_3B_module -------------------------------------------------------------------------------------------- procedure generic_3B_module (specs : in out Portspecs; module : String; dependency : String) is hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := True; hit_both := False; hit_run := False; else hit_build := argument_present (specs, module, BUILD); hit_both := argument_present (specs, module, BUILDRUN); hit_run := argument_present (specs, module, RUN); if not (hit_build or else hit_both or else hit_run) then hit_build := True; end if; end if; if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); else add_run_depends (specs, dependency); end if; end generic_3B_module; -------------------------------------------------------------------------------------------- -- apply_jpeg_module -------------------------------------------------------------------------------------------- procedure apply_jpeg_module (specs : in out Portspecs) is module : String := "jpeg"; dependency : String := "jpeg-turbo:primary:standard"; begin generic_3BR_module (specs, module, dependency); end apply_jpeg_module; -------------------------------------------------------------------------------------------- -- apply_png_module -------------------------------------------------------------------------------------------- procedure apply_png_module (specs : in out Portspecs) is module : String := "png"; dependency : String := "png:single:standard"; begin generic_3BR_module (specs, module, dependency); end apply_png_module; -------------------------------------------------------------------------------------------- -- apply_gif_module -------------------------------------------------------------------------------------------- procedure apply_gif_module (specs : in out Portspecs) is module : String := "gif"; dependency : String := "giflib:single:standard"; begin generic_3BR_module (specs, module, dependency); end apply_gif_module; -------------------------------------------------------------------------------------------- -- apply_tiff_module -------------------------------------------------------------------------------------------- procedure apply_tiff_module (specs : in out Portspecs) is module : String := "tiff"; dependency : String := "tiff:primary:standard"; begin generic_3BR_module (specs, module, dependency); end apply_tiff_module; -------------------------------------------------------------------------------------------- -- apply_gem_module -------------------------------------------------------------------------------------------- procedure apply_gem_module (specs : in out Portspecs) is module : String := "gem"; defver : String (1 .. 2) := default_ruby (default_ruby'First) & default_ruby (default_ruby'Last); flavor : String := "v" & defver; begin if specs.uses_base.Contains (HT.SUS (module)) then if not no_arguments_present (specs, module) then if argument_present (specs, module, "v26") then flavor := "v26"; elsif argument_present (specs, module, "v27") then flavor := "v27"; elsif argument_present (specs, module, "v30") then flavor := "v30"; end if; end if; add_buildrun_depends (specs, "ruby-rubygems:single:" & flavor); end if; end apply_gem_module; -------------------------------------------------------------------------------------------- -- apply_php_module -------------------------------------------------------------------------------------------- procedure apply_php_module (specs : in out Portspecs) is module : constant String := "php"; std_suffix : constant String := ":single:standard"; -- This defver works until PHP 10 is released defver : String (1 .. 2) := default_php (default_php'First) & default_php (default_php'Last); flavor : String := "php" & defver; hit_build : Boolean := False; hit_phpize : Boolean := False; hit_ext : Boolean := False; hit_zend : Boolean := False; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if not no_arguments_present (specs, module) then if argument_present (specs, module, "80") then flavor := "php80"; elsif argument_present (specs, module, "74") then flavor := "php74"; elsif argument_present (specs, module, "73") then flavor := "php73"; end if; hit_build := argument_present (specs, module, BUILD); hit_phpize := argument_present (specs, module, "phpize"); hit_ext := argument_present (specs, module, "ext"); hit_zend := argument_present (specs, module, "zend"); end if; if hit_build or else hit_phpize or else hit_ext or else hit_zend then add_buildrun_depends (specs, flavor & std_suffix); else add_run_depends (specs, flavor & std_suffix); end if; if hit_phpize or else hit_ext or else hit_zend then add_build_depends (specs, "autoconf" & std_suffix); end if; end apply_php_module; -------------------------------------------------------------------------------------------- -- apply_lua_module -------------------------------------------------------------------------------------------- procedure apply_lua_module (specs : in out Portspecs) is function pick_lua return String; module : String := "lua"; hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; function pick_lua return String is LUA52 : String := "lua52:single:standard"; LUA53 : String := "lua53:single:standard"; LUA54 : String := "lua54:single:standard"; def_setting : String := HT.USS (Parameters.configuration.def_lua); begin if argument_present (specs, module, "5.2") then return LUA52; elsif argument_present (specs, module, "5.3") then return LUA53; elsif argument_present (specs, module, "5.4") then return LUA54; end if; -- No valid argument present, use configured setting if def_setting = "5.2" then return LUA52; elsif def_setting = "5.4" then return LUA54; else -- current default: lua53 return LUA53; end if; end pick_lua; dependency : String := pick_lua; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := False; hit_both := True; hit_run := False; else hit_build := argument_present (specs, module, BUILD); hit_both := argument_present (specs, module, BUILDRUN); hit_run := argument_present (specs, module, RUN); if not (hit_build or else hit_both or else hit_run) then hit_both := True; end if; end if; if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); else add_run_depends (specs, dependency); end if; specs.used_lua := HT.SUS (HT.specific_field (dependency, 1, ":")); end apply_lua_module; -------------------------------------------------------------------------------------------- -- apply_tcl_module -------------------------------------------------------------------------------------------- procedure apply_tcl_module (specs : in out Portspecs) is function pick_tcl (actually_tk : Boolean) return String; procedure install_package (dependency : String); module : String := "tcl"; hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; install_tk : Boolean; -- When changing tcl defaults, don't forget to alter convert_exrun_versions() too. function pick_tcl (actually_tk : Boolean) return String is def_setting : String := HT.USS (Parameters.configuration.def_tcl_tk); begin if argument_present (specs, module, "8.5") then return TCL85; elsif argument_present (specs, module, "8.6") or else def_setting = ports_default or else def_setting = "8.6" then if actually_tk then return TK86; else return TCL86; end if; else if actually_tk then return TK85; else return TCL85; end if; end if; end pick_tcl; procedure install_package (dependency : String) is begin if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); else add_run_depends (specs, dependency); end if; end install_package; tcl_package : String := pick_tcl (actually_tk => False); tk_package : String := pick_tcl (actually_tk => True); begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := False; hit_both := True; hit_run := False; install_tk := False; else hit_build := argument_present (specs, module, BUILD); hit_both := argument_present (specs, module, BUILDRUN); hit_run := argument_present (specs, module, RUN); install_tk := argument_present (specs, module, "tk"); if not (hit_build or else hit_both or else hit_run) then hit_both := True; end if; end if; install_package (tcl_package); if install_tk then install_package (tk_package); end if; end apply_tcl_module; -------------------------------------------------------------------------------------------- -- apply_ssl_module -------------------------------------------------------------------------------------------- procedure apply_ssl_module (specs : in out Portspecs) is hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; module : constant String := "ssl"; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := False; hit_both := True; hit_run := False; else hit_build := argument_present (specs, module, BUILD); hit_both := argument_present (specs, module, BUILDRUN); hit_run := argument_present (specs, module, RUN); if not (hit_build or else hit_both or else hit_run) then hit_both := True; end if; end if; declare normvar : constant String := Parameters.ssl_selection (Parameters.configuration); dependency : constant String := specs.get_ssl_variant (normvar) & ":single:standard"; begin if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); else add_run_depends (specs, dependency); end if; end; end apply_ssl_module; -------------------------------------------------------------------------------------------- -- apply_bdb_module -------------------------------------------------------------------------------------------- procedure apply_bdb_module (specs : in out Portspecs) is module : String := "bdb"; dep_static_5 : String := "db5:static:standard"; dep_shared_5 : String := "db5:shared:standard"; dep_static_6 : String := "db6:static:standard"; dep_shared_6 : String := "db6:shared:standard"; dep_static_7 : String := "db18:static:standard"; dep_shared_7 : String := "db18:shared:standard"; need_static : Boolean := False; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if argument_present (specs, module, "static") then need_static := True; end if; if argument_present (specs, module, "6") then add_build_depends (specs, dep_static_6); if not need_static then add_buildrun_depends (specs, dep_shared_6); end if; elsif argument_present (specs, module, "18") then add_build_depends (specs, dep_static_7); if not need_static then add_buildrun_depends (specs, dep_shared_7); end if; else add_build_depends (specs, dep_static_5); if not need_static then add_buildrun_depends (specs, dep_shared_5); end if; end if; end apply_bdb_module; -------------------------------------------------------------------------------------------- -- apply_perl_module -------------------------------------------------------------------------------------------- procedure apply_perl_module (specs : in out Portspecs) is function retrieve_dependency return String; module : constant String := "perl"; pmodbuild : constant String := "perl-Module-Build:single:"; pmodbuildtiny : constant String := "perl-Module-Build-Tiny:single:"; perl_530 : constant String := "530"; perl_532 : constant String := "532"; dep_suffix : String := " "; hit_run : Boolean; hit_build : Boolean; hit_both : Boolean; hit_bmod : Boolean; hit_bmodtiny : Boolean; hit_config : Boolean; function retrieve_dependency return String is rport_default : String := "perl-" & default_perl; suffix : String := ":primary:standard"; def_setting : String := HT.USS (Parameters.configuration.def_perl); override_dep : String := "perl-" & def_setting; begin if argument_present (specs, module, perl_532) then dep_suffix := perl_532; return "perl-5.32" & suffix; elsif argument_present (specs, module, perl_530) then dep_suffix := perl_530; return "perl-5.30" & suffix; else if def_setting = ports_default then dep_suffix := HT.replace_char (default_perl, LAT.Full_Stop, ""); return rport_default & suffix; else dep_suffix := HT.replace_char (def_setting, LAT.Full_Stop, ""); return override_dep & suffix; end if; end if; end retrieve_dependency; dependency : String := retrieve_dependency; begin if not specs.uses_base.Contains (HT.SUS (module)) then return; end if; if no_arguments_present (specs, module) then hit_build := False; hit_both := True; hit_run := False; hit_bmod := False; hit_bmodtiny := False; hit_config := False; else hit_build := argument_present (specs, module, BUILD); hit_run := argument_present (specs, module, RUN); hit_bmod := argument_present (specs, module, "buildmod"); hit_bmodtiny := argument_present (specs, module, "buildmodtiny"); hit_config := argument_present (specs, module, "configure"); hit_both := hit_config or else (hit_run and hit_bmod) or else (hit_run and hit_bmodtiny); if hit_bmod or else hit_bmodtiny then hit_build := True; end if; if not (hit_build or else hit_both or else hit_run) then hit_both := True; end if; end if; if hit_both or else (hit_build and hit_run) then add_buildrun_depends (specs, dependency); elsif hit_build then add_build_depends (specs, dependency); elsif hit_run then add_run_depends (specs, dependency); end if; if hit_bmod then if specs.get_namebase /= "perl-Module-Build" then add_build_depends (specs, pmodbuild & dep_suffix); end if; elsif hit_bmodtiny then if specs.get_namebase /= "perl-Module-Build-Tiny" then add_build_depends (specs, pmodbuildtiny & dep_suffix); end if; end if; specs.used_perl := HT.SUS (dep_suffix); end apply_perl_module; -------------------------------------------------------------------------------------------- -- apply_opsys_dependencies -------------------------------------------------------------------------------------------- procedure apply_opsys_dependencies (specs : in out Portspecs) is procedure scan_dep (position : string_crate.Cursor); procedure scan_use (position : string_crate.Cursor); type deptype is (os_build, os_run, os_buildrun); dt : deptype; key_opsys : HT.Text := HT.SUS (UTL.lower_opsys (platform_type)); procedure scan_dep (position : string_crate.Cursor) is dependency : String := HT.USS (string_crate.Element (position)); begin case dt is when os_build => add_build_depends (specs, dependency); when os_run => add_run_depends (specs, dependency); when os_buildrun => add_buildrun_depends (specs, dependency); end case; end scan_dep; procedure scan_use (position : string_crate.Cursor) is text_value : HT.Text renames string_crate.Element (position); text_stripped : HT.Text := HT.SUS (HT.part_1 (HT.USS (text_value), ":")); begin specs.uses.Append (text_value); if not specs.uses_base.Contains (text_stripped) then specs.uses_base.Append (text_stripped); end if; end scan_use; begin if specs.skip_opsys_dep then return; end if; if specs.opsys_b_deps.Contains (key_opsys) then dt := os_build; specs.opsys_b_deps.Element (key_opsys).list.Iterate (scan_dep'Access); end if; if specs.opsys_r_deps.Contains (key_opsys) then dt := os_run; specs.opsys_r_deps.Element (key_opsys).list.Iterate (scan_dep'Access); end if; if specs.opsys_br_deps.Contains (key_opsys) then dt := os_buildrun; specs.opsys_br_deps.Element (key_opsys).list.Iterate (scan_dep'Access); end if; if specs.opsys_c_uses.Contains (key_opsys) then specs.opsys_c_uses.Element (key_opsys).list.Iterate (scan_use'Access); end if; end apply_opsys_dependencies; -------------------------------------------------------------------------------------------- -- apply_curly_bracket_conversions -------------------------------------------------------------------------------------------- procedure apply_curly_bracket_conversions (specs : in out Portspecs) is procedure apply_to_list1 (position : list_crate.Cursor); procedure apply_to_list2 (position : list_crate.Cursor); procedure apply_to_list3 (position : list_crate.Cursor); procedure apply_to_list4 (position : list_crate.Cursor); procedure apply_to_list5 (position : list_crate.Cursor); procedure alter (Key : HT.Text; Element : in out group_list); procedure alter (Key : HT.Text; Element : in out group_list) is begin apply_cbc_string_crate (Element.list); end alter; procedure apply_to_list1 (position : list_crate.Cursor) is begin specs.catch_all.Update_Element (Position => position, Process => alter'Access); end apply_to_list1; procedure apply_to_list2 (position : list_crate.Cursor) is begin specs.extract_head.Update_Element (Position => position, Process => alter'Access); end apply_to_list2; procedure apply_to_list3 (position : list_crate.Cursor) is begin specs.extract_tail.Update_Element (Position => position, Process => alter'Access); end apply_to_list3; procedure apply_to_list4 (position : list_crate.Cursor) is begin specs.var_opsys.Update_Element (Position => position, Process => alter'Access); end apply_to_list4; procedure apply_to_list5 (position : list_crate.Cursor) is begin specs.var_arch.Update_Element (Position => position, Process => alter'Access); end apply_to_list5; begin UTL.apply_cbc_string (specs.install_wrksrc); UTL.apply_cbc_string (specs.build_wrksrc); UTL.apply_cbc_string (specs.patch_wrksrc); UTL.apply_cbc_string (specs.config_wrksrc); UTL.apply_cbc_string (specs.config_prefix); UTL.apply_cbc_string (specs.config_script); UTL.apply_cbc_string (specs.config_target); UTL.apply_cbc_string (specs.distname); UTL.apply_cbc_string (specs.prefix); apply_cbc_string_crate (specs.config_args); apply_cbc_string_crate (specs.config_env); apply_cbc_string_crate (specs.make_args); apply_cbc_string_crate (specs.make_env); apply_cbc_string_crate (specs.test_args); apply_cbc_string_crate (specs.test_env); apply_cbc_string_crate (specs.cflags); apply_cbc_string_crate (specs.cxxflags); apply_cbc_string_crate (specs.cppflags); apply_cbc_string_crate (specs.ldflags); apply_cbc_string_crate (specs.cmake_args); apply_cbc_string_crate (specs.qmake_args); apply_cbc_string_crate (specs.test_args); apply_cbc_string_crate (specs.lic_files); apply_cbc_string_crate (specs.lic_source); apply_cbc_string_crate (specs.lic_terms); apply_cbc_string_crate (specs.plist_sub); apply_cbc_string_crate (specs.mk_verbatim); apply_cbc_string_crate (specs.sub_list); apply_cbc_string_crate (specs.users); apply_cbc_string_crate (specs.groups); apply_cbc_string_crate (specs.mandirs); specs.catch_all.Iterate (apply_to_list1'Access); specs.extract_head.Iterate (apply_to_list2'Access); specs.extract_tail.Iterate (apply_to_list3'Access); specs.var_opsys.Iterate (apply_to_list4'Access); specs.var_arch.Iterate (apply_to_list5'Access); end apply_curly_bracket_conversions; -------------------------------------------------------------------------------------------- -- apply_cbc_string_crate -------------------------------------------------------------------------------------------- procedure apply_cbc_string_crate (crate : in out string_crate.Vector) is procedure check (position : string_crate.Cursor); procedure swap_braces (Element : in out HT.Text); procedure swap_braces (Element : in out HT.Text) is begin UTL.apply_cbc_string (Element); end swap_braces; procedure check (position : string_crate.Cursor) is begin crate.Update_Element (position, swap_braces'Access); end check; begin crate.Iterate (check'Access); end apply_cbc_string_crate; -------------------------------------------------------------------------------------------- -- argument_present -------------------------------------------------------------------------------------------- function argument_present (specs : Portspecs; module, argument : String) return Boolean is procedure scan (position : string_crate.Cursor); found : Boolean := False; procedure scan (position : string_crate.Cursor) is value_text : HT.Text renames string_crate.Element (position); value : String := HT.USS (value_text); begin if not found and then HT.count_char (value, LAT.Colon) = 1 then declare modulestr : String := HT.part_1 (value, ":"); begin if modulestr = module then declare argumentstr : String := HT.part_2 (value, ":"); num_commas : Natural := HT.count_char (argumentstr, LAT.Comma); begin if num_commas = 0 then found := (argument = argumentstr); else for x in 1 .. num_commas + 1 loop if argument = HT.specific_field (argumentstr, x, ",") then found := True; exit; end if; end loop; end if; end; end if; end; end if; end scan; begin specs.uses.Iterate (scan'Access); return found; end argument_present; -------------------------------------------------------------------------------------------- -- no_arguments_present -------------------------------------------------------------------------------------------- function no_arguments_present (specs : Portspecs; module : String) return Boolean is procedure scan (position : string_crate.Cursor); found : Boolean := False; procedure scan (position : string_crate.Cursor) is value_text : HT.Text renames string_crate.Element (position); value : String := HT.USS (value_text); begin if not found and then HT.count_char (value, LAT.Colon) = 1 then declare modulestr : String := HT.part_1 (value, ":"); begin if modulestr = module then found := True; end if; end; end if; end scan; begin specs.uses.Iterate (scan'Access); return not found; end no_arguments_present; -------------------------------------------------------------------------------------------- -- argument_present -------------------------------------------------------------------------------------------- procedure shift_extra_patches (specs : Portspecs; extract_dir : String) is num_extra_patch : Natural := specs.get_list_length (sp_extra_patches); patchdir : constant String := extract_dir & "/patches"; begin if num_extra_patch > 0 then if not DIR.Exists (patchdir) then DIR.Create_Directory (patchdir); end if; end if; for item in 1 .. num_extra_patch loop declare patch : String := specs.get_list_item (sp_extra_patches, item); xp_loc : String := extract_dir & "/files/" & patch; begin if DIR.Exists (xp_loc) then DIR.Rename (Old_Name => xp_loc, New_Name => patchdir & "/patch-zzz-" & patch); end if; end; end loop; end shift_extra_patches; -------------------------------------------------------------------------------------------- -- add_build_depends -------------------------------------------------------------------------------------------- procedure add_build_depends (specs : in out Portspecs; dependency : String) is dependency_text : HT.Text := HT.SUS (dependency); begin if not specs.build_deps.Contains (dependency_text) then specs.build_deps.Append (dependency_text); end if; end add_build_depends; -------------------------------------------------------------------------------------------- -- add_buildrun_depends -------------------------------------------------------------------------------------------- procedure add_buildrun_depends (specs : in out Portspecs; dependency : String) is dependency_text : HT.Text := HT.SUS (dependency); begin if not specs.buildrun_deps.Contains (dependency_text) then specs.buildrun_deps.Append (dependency_text); end if; end add_buildrun_depends; -------------------------------------------------------------------------------------------- -- add_run_depends -------------------------------------------------------------------------------------------- procedure add_run_depends (specs : in out Portspecs; dependency : String) is dependency_text : HT.Text := HT.SUS (dependency); begin if not specs.run_deps.Contains (dependency_text) then specs.run_deps.Append (dependency_text); end if; end add_run_depends; -------------------------------------------------------------------------------------------- -- add_exrun_depends -------------------------------------------------------------------------------------------- procedure add_exrun_depends (specs : in out Portspecs; dependency, subpackage : String) is procedure grow (Key : HT.Text; Element : in out group_list); dependency_text : HT.Text := HT.SUS (dependency); group : HT.Text := HT.SUS (subpackage); procedure grow (Key : HT.Text; Element : in out group_list) is begin Element.list.Append (dependency_text); end grow; begin if not specs.extra_rundeps.Contains (group) then specs.establish_group (sp_exrun, subpackage); end if; if not specs.extra_rundeps.Element (group).list.Contains (dependency_text) then specs.extra_rundeps.Update_Element (Position => specs.extra_rundeps.Find (group), Process => grow'Access); end if; end add_exrun_depends; -------------------------------------------------------------------------------------------- -- convert_exrun_versions -------------------------------------------------------------------------------------------- procedure convert_exrun_versions (specs : in out Portspecs) is procedure convert1 (position1 : list_crate.Cursor); procedure convert2 (Key : HT.Text; Element : in out group_list); procedure convert3 (Element : in out HT.Text); procedure convert3 (Element : in out HT.Text) is exrundep : String := HT.USS (Element); begin if exrundep = "ssl" then declare setting : String := HT.USS (Parameters.configuration.def_ssl); begin if setting = ports_default then Element := HT.SUS ("libressl:single:standard"); else Element := HT.SUS (setting & ":single:standard"); end if; end; elsif exrundep = "python" then if specs.buildrun_deps.Contains (HT.SUS (PYTHON27)) then Element := HT.SUS (PYTHON27); elsif specs.buildrun_deps.Contains (HT.SUS (PYTHON39)) then Element := HT.SUS (PYTHON39); else Element := HT.SUS (PYTHON38); end if; elsif exrundep = "tcl" then if specs.buildrun_deps.Contains (HT.SUS (TCL85)) then Element := HT.SUS (TCL85); else Element := HT.SUS (TCL86); end if; elsif exrundep = "perl" then declare setting : String := HT.USS (Parameters.configuration.def_perl); suffix : String := ":primary:standard"; begin if setting = ports_default then Element := HT.SUS ("perl-" & default_perl & suffix); else Element := HT.SUS ("perl-" & setting & suffix); end if; end; elsif exrundep = "mysql" then -- only mysql:client is supported by EXRUN Element := HT.SUS (determine_mysql_package (False)); elsif exrundep = "pgsql" then -- only pgsql:client is supported by EXRUN Element := HT.SUS (determine_pgsql_namebase & ":client:standard"); end if; end convert3; procedure convert2 (Key : HT.Text; Element : in out group_list) is txt_ssl : HT.Text := HT.SUS ("ssl"); txt_python : HT.Text := HT.SUS ("python"); txt_tcl : HT.Text := HT.SUS ("tcl"); txt_perl : HT.Text := HT.SUS ("perl"); txt_mysql : HT.Text := HT.SUS ("mysql"); txt_pgsql : HT.Text := HT.SUS ("pgsql"); begin if Element.list.Contains (txt_ssl) then Element.list.Update_Element (Position => Element.list.Find (txt_ssl), Process => convert3'Access); end if; if Element.list.Contains (txt_python) then Element.list.Update_Element (Position => Element.list.Find (txt_python), Process => convert3'Access); end if; if Element.list.Contains (txt_tcl) then Element.list.Update_Element (Position => Element.list.Find (txt_tcl), Process => convert3'Access); end if; if Element.list.Contains (txt_perl) then Element.list.Update_Element (Position => Element.list.Find (txt_perl), Process => convert3'Access); end if; if Element.list.Contains (txt_mysql) then Element.list.Update_Element (Position => Element.list.Find (txt_mysql), Process => convert3'Access); end if; if Element.list.Contains (txt_pgsql) then Element.list.Update_Element (Position => Element.list.Find (txt_pgsql), Process => convert3'Access); end if; end convert2; procedure convert1 (position1 : list_crate.Cursor) is begin specs.extra_rundeps.Update_Element (Position => position1, Process => convert2'Access); end convert1; begin specs.extra_rundeps.Iterate (convert1'Access); end convert_exrun_versions; -------------------------------------------------------------------------------------------- -- apply_extraction_deps -------------------------------------------------------------------------------------------- procedure apply_extraction_deps (specs : in out Portspecs) is begin -- unzip is already in base if not specs.extract_7z.Is_Empty then add_build_depends (specs, "p7zip:primary:standard"); end if; -- TODO: placeholder for LHA end apply_extraction_deps; -------------------------------------------------------------------------------------------- -- transform_defaults -------------------------------------------------------------------------------------------- function transform_defaults (dep, pyx, plx, lux, rbx : String) return String is function name_subpackage return String; trailer : constant String := HT.specific_field (dep, 3, ":"); function name_subpackage return String is begin return HT.specific_field (dep, 1, ":") & ":" & HT.specific_field (dep, 2, ":") & ":"; end name_subpackage; begin if trailer = "python_default" then declare setting : String := HT.USS (Parameters.configuration.def_python3); begin if setting = ports_default or else setting = default_python3 then return name_subpackage & "py38"; else return name_subpackage & "py39"; end if; end; elsif trailer = "perl_default" then declare setting : String := HT.USS (Parameters.configuration.def_perl); begin if setting = ports_default or else setting = default_perl then return name_subpackage & "530"; else return name_subpackage & "532"; end if; end; elsif trailer = "lua_default" then declare setting : String := HT.USS (Parameters.configuration.def_lua); begin if setting = "5.2" then return name_subpackage & "lua52"; elsif setting = "5.4" then return name_subpackage & "lua54"; else -- ports_default or default_lua ("5.3") return name_subpackage & "lua53"; end if; end; elsif trailer = "ruby_default" then declare setting : String := HT.USS (Parameters.configuration.def_ruby); begin if setting = "2.6" then return name_subpackage & "v26"; elsif setting = "3.0" then return name_subpackage & "v30"; else -- ports_default or default_python ("2.7") return name_subpackage & "v27"; end if; end; elsif trailer = "python_used" then return name_subpackage & pyx; elsif trailer = "perl_used" then return name_subpackage & plx; elsif trailer = "lua_used" then return name_subpackage & lux; elsif trailer = "ruby_used" then return name_subpackage & rbx; else return dep; end if; end transform_defaults; -------------------------------------------------------------------------------------------- -- apply_default_version_transformations -------------------------------------------------------------------------------------------- procedure apply_default_version_transformations (specs : in out Portspecs) is procedure check_build (position : string_crate.Cursor); procedure check_buildrun (position : string_crate.Cursor); procedure check_run (position : string_crate.Cursor); procedure alter (Element : in out HT.Text); transformed_dep : HT.Text; pyx : constant String := HT.USS (specs.used_python); plx : constant String := HT.USS (specs.used_perl); lux : constant String := HT.USS (specs.used_lua); rbx : constant String := HT.USS (specs.used_ruby); procedure alter (Element : in out HT.Text) is begin Element := transformed_dep; end alter; procedure check_build (position : string_crate.Cursor) is dep : String := HT.USS (string_crate.Element (position)); xdep : String := transform_defaults (dep, pyx, plx, lux, rbx); begin if xdep /= dep then transformed_dep := HT.SUS (xdep); specs.build_deps.Update_Element (position, alter'Access); end if; end check_build; procedure check_buildrun (position : string_crate.Cursor) is dep : String := HT.USS (string_crate.Element (position)); xdep : String := transform_defaults (dep, pyx, plx, lux, rbx); begin if xdep /= dep then transformed_dep := HT.SUS (xdep); specs.buildrun_deps.Update_Element (position, alter'Access); end if; end check_buildrun; procedure check_run (position : string_crate.Cursor) is dep : String := HT.USS (string_crate.Element (position)); xdep : String := transform_defaults (dep, pyx, plx, lux, rbx); begin if xdep /= dep then transformed_dep := HT.SUS (xdep); specs.run_deps.Update_Element (position, alter'Access); end if; end check_run; begin specs.build_deps.Iterate (check_build'Access); specs.buildrun_deps.Iterate (check_buildrun'Access); specs.run_deps.Iterate (check_run'Access); end apply_default_version_transformations; -------------------------------------------------------------------------------------------- -- apply_gnome_components_dependencies -------------------------------------------------------------------------------------------- procedure apply_gnome_components_dependencies (specs : in out Portspecs) is -- May require several iterations -- First pass: set top-level requirements -- repeat subsequent passes on "components" until no changes made -- Use "component" array to define gnome component imports procedure initial_setup (position : string_crate. Cursor); procedure implicate (comp : gnome_type); procedure import (comp : gnome_type); procedure implies (comp : gnome_type); defpy : constant String := "py" & HT.replace_char (default_python3, '.', ""); ss : constant String := ":single:standard"; ps : constant String := ":primary:standard"; component : array (gnome_type) of Boolean := (others => False); new_data : Boolean; procedure implies (comp : gnome_type) is begin if not component (comp) then component (comp) := True; new_data := True; end if; end implies; procedure initial_setup (position : string_crate. Cursor) is component_text : HT.Text renames string_crate.Element (position); comp : gnome_type := determine_gnome_component (HT.USS (component_text)); begin component (comp) := True; end initial_setup; procedure implicate (comp : gnome_type) is begin case comp is when atk => implies (glib); when dconf => implies (glib); when gdkpixbuf => implies (glib); when glibmm => implies (glib); when gtk2 => implies (atk); implies (pango); when gtk3 => implies (atk); implies (pango); when gtkmm30 => implies (gtk3); when gtkmm40 => implies (gtk4); when gtksourceview3 => implies (gtk3); implies (libxml2); when introspection => implies (glib); when libglade => implies (libxml2); implies (gtk2); when libgsf => implies (glib); implies (libxml2); when libidl => implies (glib); when librsvg => implies (libgsf); implies (gdkpixbuf); implies (pango); when libxslt => implies (libxml2); when orbit2 => implies (libidl); when pygobject => implies (glib); when vte => implies (gtk3); when others => null; end case; end implicate; procedure import (comp : gnome_type) is begin case comp is when invalid_component => null; -- should be impossible when atk => add_buildrun_depends (specs, "atk" & ps); when atkmm => add_buildrun_depends (specs, "atkmm" & ss); when atkmm16 => add_buildrun_depends (specs, "atkmm16" & ss); when cairo => add_buildrun_depends (specs, "cairo" & ss); when cairomm => add_buildrun_depends (specs, "cairomm" & ss); when cairomm10 => add_buildrun_depends (specs, "cairomm10" & ss); when dconf => add_buildrun_depends (specs, "dconf" & ps); when gconf => add_buildrun_depends (specs, "gconf" & ps); when gdkpixbuf => add_buildrun_depends (specs, "gdk-pixbuf" & ps); when glib => add_buildrun_depends (specs, GNOMELIB); add_buildrun_depends (specs, "gettext:runtime:standard"); when glibmm => add_buildrun_depends (specs, "glibmm" & ss); when glibmm24 => add_buildrun_depends (specs, "glibmm24" & ss); when gtk2 => add_buildrun_depends (specs, "gtk2" & ps); when gtk3 => add_buildrun_depends (specs, "gtk3" & ps); when gtk4 => add_buildrun_depends (specs, "gtk4" & ps); when gtkmm30 => add_buildrun_depends (specs, "gtkmm30" & ss); when gtkmm40 => add_buildrun_depends (specs, "gtkmm40" & ss); when gtksourceview3 => add_buildrun_depends (specs, "gtksourceview3" & ps); when intltool => add_build_depends (specs, "intltool" & ss); when introspection => add_build_depends (specs, "gobject-introspection" & ss); specs.make_env.Append (HT.SUS ("GI_SCANNER_DISABLE_CACHE=1")); specs.make_env.Append (HT.SUS ("XDG_CACHE_HOME=${WRKDIR}")); when libcroco => add_buildrun_depends (specs, "libcroco" & ps); when libglade => add_buildrun_depends (specs, "libglade" & ss); when libgsf => add_buildrun_depends (specs, "libgsf" & ps); when libidl => add_buildrun_depends (specs, "libIDL" & ss); when librsvg => add_buildrun_depends (specs, "librsvg" & ps); when libsigcxx2 => add_buildrun_depends (specs, "libsigcxx" & ps); when libxmlxx2 => add_buildrun_depends (specs, "libxmlxx2" & ss); when libxml2 => add_buildrun_depends (specs, "libxml2" & ss); when libxslt => add_buildrun_depends (specs, "libxslt" & ss); when orbit2 => add_buildrun_depends (specs, "ORBit2" & ps); when pango => add_buildrun_depends (specs, "pango" & ps); when pangomm => add_buildrun_depends (specs, "pangomm" & ss); when pangomm14 => add_buildrun_depends (specs, "pangomm14" & ss); when pygobject => add_buildrun_depends (specs, "python-PyGObject:single:" & defpy); when vte => add_buildrun_depends (specs, "vte" & ps); end case; end import; begin specs.gnome_comps.Iterate (initial_setup'Access); loop new_data := False; for x in gnome_type'Range loop if component (x) then implicate (x); end if; end loop; exit when not new_data; end loop; for x in gnome_type'Range loop if component (x) then import (x); end if; end loop; end apply_gnome_components_dependencies; -------------------------------------------------------------------------------------------- -- apply_sdl_components_dependencies -------------------------------------------------------------------------------------------- procedure apply_sdl_components_dependencies (specs : in out Portspecs) is procedure import (position : string_crate.Cursor); ss : constant String := ":single:standard"; menv1 : HT.Text := HT.SUS ("SDL_CONFIG=""${LOCALBASE}/bin/sdl-config"""); menv2 : HT.Text := HT.SUS ("SDL_CONFIG=""${LOCALBASE}/bin/sdl2-config"""); procedure import (position : string_crate.Cursor) is component_text : HT.Text renames string_crate.Element (position); comp : sdl_type := determine_sdl_component (HT.USS (component_text)); begin case comp is when invalid_component => null; -- should be impossible when sdl1 => null; when sdl2 => null; when gfx1 => add_buildrun_depends (specs, "sdl1_gfx" & ss); when gfx2 => add_buildrun_depends (specs, "sdl2_gfx" & ss); when image1 => add_buildrun_depends (specs, "sdl1_image" & ss); when image2 => add_buildrun_depends (specs, "sdl2_image" & ss); when mixer1 => add_buildrun_depends (specs, "sdl1_mixer" & ss); when mixer2 => add_buildrun_depends (specs, "sdl2_mixer" & ss); when net1 => add_buildrun_depends (specs, "sdl1_net" & ss); when net2 => add_buildrun_depends (specs, "sdl2_net" & ss); when ttf1 => add_buildrun_depends (specs, "sdl1_ttf" & ss); when ttf2 => add_buildrun_depends (specs, "sdl2_ttf" & ss); end case; case comp is when sdl1 | gfx1 | image1 | mixer1 | net1 | ttf1 => add_buildrun_depends (specs, "sdl1:primary:standard"); specs.make_env.Append (menv1); specs.config_env.Append (menv1); when sdl2 | gfx2 | image2 | mixer2 | net2 | ttf2 => add_buildrun_depends (specs, "sdl2:single:standard"); specs.make_env.Append (menv2); specs.config_env.Append (menv2); when invalid_component => null; end case; end import; begin specs.sdl_comps.Iterate (import'Access); end apply_sdl_components_dependencies; -------------------------------------------------------------------------------------------- -- apply_xorg_components_dependencies -------------------------------------------------------------------------------------------- procedure apply_xorg_components_dependencies (specs : in out Portspecs) is procedure import (position : string_crate.Cursor); -- All xorg components have this format : xorg-{COMPONENT}:single:standard -- All xorg components ending in "proto" are build-only depends -- The rest are considered libraries (buildrun type) -- All libraries depend on pkgconfig and xorg-macros uses_xorg : Boolean := False; ss : constant String := ":single:standard"; procedure import (position : string_crate.Cursor) is component_text : HT.Text renames string_crate.Element (position); component : constant String := HT.USS (component_text); dependency : constant String := "xorg-" & component & ss; begin if HT.trails (component, "proto") then add_build_depends (specs, dependency); else add_buildrun_depends (specs, dependency); end if; uses_xorg := True; end import; begin specs.xorg_comps.Iterate (import'Access); if uses_xorg and then not HT.trails (specs.get_namebase, "proto") then add_build_depends (specs, "xorg-macros" & ss); add_build_depends (specs, "pkgconf" & ss); end if; end apply_xorg_components_dependencies; -------------------------------------------------------------------------------------------- -- apply_php_extension_dependencies -------------------------------------------------------------------------------------------- procedure apply_php_extension_dependencies (specs : in out Portspecs) is procedure import (position : string_crate.Cursor); php_module : constant String := "php"; std_suffix : constant String := ":single:standard"; hit_build : Boolean := False; hit_ext : Boolean := False; -- This defver works until PHP 10 is released defver : String (1 .. 2) := default_php (default_php'First) & default_php (default_php'Last); flavor : String := "php" & defver; procedure import (position : string_crate.Cursor) is extension_text : HT.Text renames string_crate.Element (position); extension : constant String := HT.USS (extension_text); dependency : constant String := flavor & "-" & extension & std_suffix; begin if hit_build or else hit_ext then add_buildrun_depends (specs, dependency); else add_run_depends (specs, dependency); end if; end import; begin if not no_arguments_present (specs, php_module) then if argument_present (specs, php_module, "80") then flavor := "php80"; elsif argument_present (specs, php_module, "74") then flavor := "php74"; elsif argument_present (specs, php_module, "73") then flavor := "php73"; end if; end if; hit_build := argument_present (specs, php_module, BUILD); hit_ext := argument_present (specs, php_module, "ext"); specs.php_extensions.Iterate (import'Access); end apply_php_extension_dependencies; -------------------------------------------------------------------------------------------- -- determine_mysql_package -------------------------------------------------------------------------------------------- function determine_mysql_package (server : Boolean) return String is suffix : String := ":client:standard"; setting : constant String := HT.USS (Parameters.configuration.def_mysql_group); begin if server then suffix := ":server:standard"; end if; if setting = "oracle-5.6" then return "mysql56" & suffix; elsif setting = "oracle-5.7" then return "mysql57" & suffix; elsif setting = "mariadb-10.2" then return "mariadb102" & suffix; elsif setting = "mariadb-10.3" then return "mariadb103" & suffix; elsif setting = "mariadb-10.4" then return "mariadb104" & suffix; elsif setting = "mariadb-10.5" then return "mariadb105" & suffix; elsif setting = "percona-5.6" then return "percona56" & suffix; elsif setting = "percona-5.7" then return "percona57" & suffix; elsif setting = "percona-8.0" then return "percona80" & suffix; else -- case: setting = ports_default -- case: setting = default_mysql -- case: setting = invalid value return "mysql80" & suffix; end if; end determine_mysql_package; -------------------------------------------------------------------------------------------- -- determine_pgsql_namebase -------------------------------------------------------------------------------------------- function determine_pgsql_namebase return String is setting : constant String := HT.USS (Parameters.configuration.def_postgresql); begin if setting = "9.6" then return "postgresql96"; elsif setting = "10" then return "postgresql10"; elsif setting = "11" then return "postgresql11"; elsif setting = "13" then return "postgresql13"; else -- case: setting = ports_default -- case: setting = default_pgsql (12 right now) -- case: setting = invalid value return "postgresql12"; end if; end determine_pgsql_namebase; end Port_Specification.Transform;
reznikmm/matreshka
Ada
3,624
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.Feature_Call_Exps.Hash is new AMF.Elements.Generic_Hash (OCL_Feature_Call_Exp, OCL_Feature_Call_Exp_Access);
persan/a-libusb1
Ada
63
adb
procedure usb.tests.main is begin null; end usb.tests.main;
AdaCore/libadalang
Ada
620
adb
package Test is type My_Int is range 0 .. 20_000; type My_Float is digits 12; type My_Record is record A, B : My_Int; F : My_Float; end record; procedure Foo is C, D, E : My_Float; Z : My_Int; G : My_Record; function Bar (A : My_Int; B : My_Float) return My_Float; function Bar (A : My_Float; B : My_Record) return My_Float; function Baz return My_Int; function Baz return My_Float; begin begin C := Bar (Baz, G); D := Bar (Baz, Baz); E := G.F; end; pragma Test_Block; end Foo; end Test;
AdaCore/Ada_Drivers_Library
Ada
4,740
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, 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 body MicroBit.Display.Symbols is ---------------- -- Left_Arrow -- ---------------- procedure Left_Arrow is begin Set (0, 2); Set (1, 2); Set (2, 2); Set (3, 2); Set (4, 2); Set (1, 2); Set (1, 1); Set (2, 0); Set (1, 3); Set (2, 4); end Left_Arrow; ----------------- -- Right_Arrow -- ----------------- procedure Right_Arrow is begin Set (0, 2); Set (1, 2); Set (2, 2); Set (3, 2); Set (4, 2); Set (3, 1); Set (2, 0); Set (3, 3); Set (2, 4); end Right_Arrow; -------------- -- Up_Arrow -- -------------- procedure Up_Arrow is begin Set (2, 0); Set (2, 1); Set (2, 2); Set (2, 3); Set (2, 4); Set (1, 1); Set (0, 2); Set (3, 1); Set (4, 2); end Up_Arrow; ---------------- -- Down_Arrow -- ---------------- procedure Down_Arrow is begin Set (2, 0); Set (2, 1); Set (2, 2); Set (2, 3); Set (2, 4); Set (1, 3); Set (0, 2); Set (3, 3); Set (4, 2); end Down_Arrow; ----------- -- Smile -- ----------- procedure Smile is begin Set (1, 1); Set (3, 1); Set (0, 3); Set (1, 4); Set (2, 4); Set (3, 4); Set (4, 3); end Smile; ----------- -- Frown -- ----------- procedure Frown is begin Set (0, 4); Set (1, 1); Set (1, 3); Set (2, 3); Set (3, 1); Set (3, 3); Set (4, 4); end Frown; ----------- -- Cross -- ----------- procedure Cross is begin Set (0, 0); Set (1, 1); Set (2, 2); Set (3, 3); Set (4, 4); Set (0, 4); Set (1, 3); Set (3, 1); Set (4, 0); end Cross; --------------- -- Checkmark -- --------------- procedure Checkmark is begin Set (4, 1); Set (3, 2); Set (2, 3); Set (1, 4); Set (0, 3); end Checkmark; ----------- -- Heart -- ----------- procedure Heart is begin Set (0, 1); Set (0, 2); Set (1, 0); Set (1, 3); Set (2, 1); Set (2, 4); Set (3, 0); Set (3, 3); Set (4, 1); Set (4, 2); end Heart; end MicroBit.Display.Symbols;
SSOCsoft/Log_Reporter
Ada
2,145
ads
With NSO.JSON, Ada.Containers.Ordered_Maps, Ada.Calendar, Gnoga.Gui.Base, Gnoga.Gui.Element.Form, Gnoga.Gui.Element.Common; Limited with Report_Form; Package NSO.Types.Report_Objects.Observation_Report with Elaborate_Body is Package Instrument_Mode_Pkg is new Ada.Containers.Indefinite_Ordered_Maps( "<" => Ada.Strings.Less_Case_Insensitive, "=" => String_Set."=", Key_Type => String, Element_Type => String_Set.Set ); ------------------- -- REPORT DATA -- ------------------- Subtype Report_Data is Instrument_Mode_Pkg.Map; -- record -- Frequency : String_Vector.Vector:= String_Vector.Empty_Vector; -- End record; ------------------ -- REPORT MAP -- ------------------ Package Report_Map is new Ada.Containers.Indefinite_Ordered_Maps( "=" => Instrument_Mode_Pkg."=", "<" => Ada.Calendar."<", Key_Type => Ada.Calendar.Time, Element_Type => Report_Data ); ---------------------------------------- -- OBSERVATION REPORT GNOGA ELEMENT -- ---------------------------------------- Type Observation_Report is new Abstract_Report with record --Gnoga.Gui.Element.Common.DIV_Type with Date : Gnoga.Gui.Element.Form.Date_Type; Time : Gnoga.Gui.Element.Form.Time_Type; end record; overriding procedure Create (Report : in out Observation_Report; Parent : in out Gnoga.Gui.Base.Base_Type'Class; Content : in String := ""; ID : in String := "" ); overriding procedure Add_Self( Self : in Observation_Report; Form : in out Gnoga.Gui.Element.Form.Form_Type'Class ); Function Report( Data : JSON.Instance'Class ) return Report_Map.Map; Function Report( Object : Report_Map.Map ) return String; Private Overriding Function Get_Name( Self : Observation_Report ) return String; End NSO.Types.Report_Objects.Observation_Report;
aeszter/lox-spark
Ada
3,444
adb
with Command_Line; use Command_Line; with SPARK.Text_IO; use SPARK.Text_IO; with Error_Reporter; with Scanners; with Tokens; procedure Lox with SPARK_Mode is procedure Run (Source : String) with Pre => Source'First >= 1 and then Source'Last < Integer'Last; procedure Run_File (Path : String); procedure Run_Prompt; procedure Run (Source : String) is Token_List : Tokens.Lists.List (100); Position : Tokens.Lists.Cursor; begin Scanners.Scan_Tokens (Source, Token_List); Position := Tokens.Lists.First (Token_List); while Tokens.Lists.Has_Element (Token_List, Position) and then Is_Writable (Standard_Output) and then Status (Standard_Output) = Success loop Put_Line (Tokens.To_String (Tokens.Lists.Element (Token_List, Position))); Tokens.Lists.Next (Token_List, Position); end loop; end Run; procedure Run_File (Path : String) is Source_File : File_Type; Source : String (1 .. 10_240) := (others => ' '); Source_Line : String (1 .. 1_024); Last : Natural; Position : Natural := 1; Line_No : Natural := 0; begin if Is_Open (Source_File) then Error_Reporter.Error (Line_No => 1, Message => "Source file already open"); return; end if; if not Is_Open (Source_File) then Error_Reporter.Error (Line_No => 1, Message => "Could not open source file"); return; end if; Open (The_File => Source_File, The_Mode => In_File, The_Name => Path); while not End_Of_File (Source_File) loop Get_Line (File => Source_File, Item => Source_Line, Last => Last); if Line_No < Integer'Last then Line_No := Line_No + 1; else Error_Reporter.Error (Line_No => Line_No, Message => "Too many lines of source code"); return; end if; if Position <= Source'Last - Last then Source (Position .. Position + Last - 1) := Source_Line (1 .. Last); Source (Position + Last) := Scanners.LF; Position := Position + Last + 1; else Error_Reporter.Error (Line_No => Line_No, Message => "Source code too large for buffer"); return; end if; end loop; Run (Source (Source'First .. Position - 1)); if Error_Reporter.Had_Error then Command_Line.Set_Exit_Status (65); end if; end Run_File; procedure Run_Prompt is Source_Line : String (1 .. 1024); Last : Natural; begin loop if Status (Standard_Output) /= Success then Error_Reporter.Error (Line_No => 1, Message => "Session ended"); return; end if; Put ("> "); Get_Line (Item => Source_Line, Last => Last); Run (Source_Line (Source_Line'First .. Last)); Error_Reporter.Clear_Error; end loop; end Run_Prompt; begin if Argument_Count > 1 then if Status (Standard_Output) = Success then Put_Line ("Usage: lox [script]"); end if; elsif Argument_Count = 1 then Run_File (Argument (1)); else Run_Prompt; end if; end Lox;
zhmu/ananas
Ada
2,912
adb
with Ada.Text_IO; use Ada.Text_IO; package body Elab5_Pkg is -------------------------------------------------- -- Call to call, instantiation, task activation -- -------------------------------------------------- procedure Suppressed_Call_1 is package Inst is new ABE_Gen; T : ABE_Task; begin ABE_Call; end Suppressed_Call_1; function Elaborator_1 return Boolean is begin pragma Warnings ("L"); Suppressed_Call_1; pragma Warnings ("l"); return True; end Elaborator_1; Elab_1 : constant Boolean := Elaborator_1; procedure Suppressed_Call_2 is package Inst is new ABE_Gen; T : ABE_Task; begin ABE_Call; end Suppressed_Call_2; function Elaborator_2 return Boolean is begin Suppressed_Call_2; return True; end Elaborator_2; Elab_2 : constant Boolean := Elaborator_2; procedure Suppressed_Call_3 is package Inst is new ABE_Gen; T : ABE_Task; begin ABE_Call; end Suppressed_Call_3; function Elaborator_3 return Boolean is begin Suppressed_Call_3; return True; end Elaborator_3; Elab_3 : constant Boolean := Elaborator_3; ----------------------------------------------------------- -- Instantiation to call, instantiation, task activation -- ----------------------------------------------------------- package body Suppressed_Generic is procedure Force_Body is begin null; end Force_Body; package Inst is new ABE_Gen; T : ABE_Task; begin ABE_Call; end Suppressed_Generic; function Elaborator_4 return Boolean is pragma Warnings ("L"); package Inst is new Suppressed_Generic; pragma Warnings ("l"); begin return True; end Elaborator_4; Elab_4 : constant Boolean := Elaborator_4; ------------------------------------------------------------- -- Task activation to call, instantiation, task activation -- ------------------------------------------------------------- task body Suppressed_Task is package Inst is new ABE_Gen; T : ABE_Task; begin ABE_Call; end Suppressed_Task; function Elaborator_5 return Boolean is pragma Warnings ("L"); T : Suppressed_Task; pragma Warnings ("l"); begin return True; end Elaborator_5; Elab_5 : constant Boolean := Elaborator_5; function Elaborator_6 return Boolean is T : Suppressed_Task; pragma Warnings (Off, T); begin return True; end Elaborator_6; Elab_6 : constant Boolean := Elaborator_6; procedure ABE_Call is begin Put_Line ("ABE_Call"); end ABE_Call; package body ABE_Gen is procedure Force_Body is begin null; end Force_Body; begin Put_Line ("ABE_Gen"); end ABE_Gen; task body ABE_Task is begin Put_Line ("ABE_Task"); end ABE_Task; end Elab5_Pkg;
reznikmm/matreshka
Ada
36,229
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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; with AMF.CMOF.Associations; with AMF.CMOF.Classes.Collections; with AMF.CMOF.Data_Types; with AMF.CMOF.Packages; with AMF.CMOF.Properties.Collections; with AMF.CMOF.Redefinable_Elements.Collections; with AMF.CMOF.Types; with AMF.Elements.Collections; with AMF.Extents.Collections; with AMF.Facility; with AMF.Holders.Reflective_Collections; with AMF.Reflective_Collections; with Generator.Arguments; with Generator.Attribute_Mapping; with Generator.Names; package body Generator.Analyzer is procedure Analyze_Model (Metamodel_Info : not null Metamodel_Information_Access); procedure Classify_Elements (Info : not null Metamodel_Information_Access; Elements : AMF.Elements.Collections.Set_Of_Element); -- Classify elements of the metamodel by classes and fill corresponding -- members of information. procedure Compute_All_Properties (Extents : in out AMF.Extents.Collections.Set_Of_Extent; Class : not null AMF.CMOF.Classes.CMOF_Class_Access); -- Computes all attributes of the class, assigns slot and collections. procedure Compute_Metamodel_Name (Metamodel_Info : not null Metamodel_Information_Access); -- Compute metamodel names for each element. procedure Assign_Element_Numbers (Metamodel_Info : not null Metamodel_Information_Access); -- Assigns numbers to each element and to each string. procedure Collect_Attributes (Metamodel_Info : not null Metamodel_Information_Access); -- Collection information about attributes of classes. procedure Assign_Member_Numbers; -- Assign member numbers for attributes of elements. procedure Extract_String_Data (Metamodel_Info : not null Metamodel_Information_Access); -- Assigns numbers to each element and to each string. type Boolean_Array is array (Positive range <>) of Boolean; type Attribute_Group_Information (Length : Natural) is record Index : Positive; Mask : Boolean_Array (1 .. Length); end record; type Attribute_Group_Access is access all Attribute_Group_Information; function Hash (Item : Attribute_Group_Access) return Ada.Containers.Hash_Type; package Property_Attribute_Group_Maps is new Ada.Containers.Hashed_Maps (AMF.CMOF.Properties.CMOF_Property_Access, Attribute_Group_Access, AMF.CMOF.Properties.Hash, AMF.CMOF.Properties."="); package Attribute_Group_Sets is new Ada.Containers.Hashed_Sets (Attribute_Group_Access, Hash, "="); Attribute_Group : Property_Attribute_Group_Maps.Map; Member_Groups : Attribute_Group_Sets.Set; Collection_Groups : Attribute_Group_Sets.Set; ------------------- -- Analyze_Model -- ------------------- procedure Analyze_Model (Metamodel_Info : not null Metamodel_Information_Access) is Elements : constant AMF.Elements.Collections.Set_Of_Element := Metamodel_Info.Extent.Elements; begin Metamodel_Infos.Insert (Metamodel_Info.Extent, Metamodel_Info); Classify_Elements (Metamodel_Info, Elements); -- Compute complete set of properties for each class. for J in 1 .. Elements.Length loop if Elements.Element (J).all in AMF.CMOF.Classes.CMOF_Class'Class then declare Class : AMF.CMOF.Classes.CMOF_Class_Access := AMF.CMOF.Classes.CMOF_Class_Access (Elements.Element (J)); begin Compute_All_Properties (Used_Extents, Class); end; end if; end loop; -- Compute name of metamodel. Compute_Metamodel_Name (Metamodel_Info); -- Looking up for root package of the metamodel. for J in 1 .. Elements.Length loop if Elements.Element (J).all in AMF.CMOF.Packages.CMOF_Package'Class then Metamodel_Info.Root_Package := AMF.CMOF.Packages.CMOF_Package_Access (Elements.Element (J)); exit; end if; end loop; -- Assign numbers for metamodel's elements. Assign_Element_Numbers (Metamodel_Info); -- Extracts string data. Extract_String_Data (Metamodel_Info); end Analyze_Model; -------------------- -- Analyze_Module -- -------------------- procedure Analyze_Module is Metamodel_Info : Metamodel_Information_Access; begin for J in 1 .. Integer (Module_Info.Extents.Length) loop Metamodel_Info := new Metamodel_Information; Metamodel_Info.Extent := Module_Info.Extents.Element (J); -- Save metamodel info of the first specified metamodel in the global -- variable. if Generator.Metamodel_Info = null then Generator.Metamodel_Info := Metamodel_Info; end if; Analyze_Model (Metamodel_Info); end loop; -- Assign numbers for members and collections. for J in 1 .. Integer (Module_Info.Extents.Length) loop Metamodel_Info := Metamodel_Infos.Element (Module_Info.Extents.Element (J)); -- Prepare to assign member's numbers for attributes. Collect_Attributes (Metamodel_Info); end loop; Assign_Member_Numbers; -- Process all used extents. declare Position : AMF.Extents.Collections.Extent_Sets.Cursor := Used_Extents.First; Extent : AMF.Extents.Extent_Access; begin while AMF.Extents.Collections.Extent_Sets.Has_Element (Position) loop Extent := AMF.Extents.Collections.Extent_Sets.Element (Position); if not Metamodel_Infos.Contains (Extent) then Metamodel_Info := new Metamodel_Information; Metamodel_Info.Extent := Extent; Metamodel_Infos.Insert (Extent, Metamodel_Info); Compute_Metamodel_Name (Metamodel_Info); Classify_Elements (Metamodel_Info, Extent.Elements); Assign_Element_Numbers (Metamodel_Info); end if; AMF.Extents.Collections.Extent_Sets.Next (Position); end loop; end; end Analyze_Module; ---------------------------- -- Assign_Element_Numbers -- ---------------------------- procedure Assign_Element_Numbers (Metamodel_Info : not null Metamodel_Information_Access) is procedure Assign_Ordered_Set (Position : CMOF_Named_Element_Ordered_Sets.Cursor); procedure Assign_Collection_Of_Element_Property (Position : CMOF_Named_Element_Ordered_Sets.Cursor); procedure Assign_Owned_By_Class_Property (Position : CMOF_Named_Element_Ordered_Sets.Cursor); procedure Assign_Set (Position : CMOF_Element_Sets.Cursor); Elements : AMF.Elements.Collections.Set_Of_Element := Metamodel_Info.Extent.Elements; Last : Natural := 0; ------------------------ -- Assign_Ordered_Set -- ------------------------ procedure Assign_Ordered_Set (Position : CMOF_Named_Element_Ordered_Sets.Cursor) is Element : constant AMF.CMOF.Elements.CMOF_Element_Access := AMF.CMOF.Elements.CMOF_Element_Access (CMOF_Named_Element_Ordered_Sets.Element (Position)); begin if not Metamodel_Info.Element_Numbers.Contains (Element) then Last := Last + 1; Metamodel_Info.Element_Numbers.Insert (Element, Last); Metamodel_Info.Number_Element.Insert (Last, Element); end if; end Assign_Ordered_Set; ------------------------------------------- -- Assign_Collection_Of_Element_Property -- ------------------------------------------- procedure Assign_Collection_Of_Element_Property (Position : CMOF_Named_Element_Ordered_Sets.Cursor) is Class : constant AMF.CMOF.Classes.CMOF_Class_Access := AMF.CMOF.Classes.CMOF_Class_Access (CMOF_Named_Element_Ordered_Sets.Element (Position)); Attributes : constant AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property := Class.Get_Owned_Attribute; Attribute_Type : AMF.CMOF.Types.CMOF_Type_Access; Properties : CMOF_Named_Element_Ordered_Sets.Set; begin for J in 1 .. Attributes.Length loop Attribute_Type := Attributes.Element (J).Get_Type; if not Use_Member_Slot (Attributes.Element (J)) and Attribute_Type.all in AMF.CMOF.Classes.CMOF_Class'Class then Properties.Insert (AMF.CMOF.Named_Elements.CMOF_Named_Element_Access (Attributes.Element (J))); end if; end loop; Properties.Iterate (Assign_Ordered_Set'Access); end Assign_Collection_Of_Element_Property; ------------------------------------ -- Assign_Owned_By_Class_Property -- ------------------------------------ procedure Assign_Owned_By_Class_Property (Position : CMOF_Named_Element_Ordered_Sets.Cursor) is Class : constant AMF.CMOF.Classes.CMOF_Class_Access := AMF.CMOF.Classes.CMOF_Class_Access (CMOF_Named_Element_Ordered_Sets.Element (Position)); Attributes : constant AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property := Class.Get_Owned_Attribute; Properties : CMOF_Named_Element_Ordered_Sets.Set; begin for J in 1 .. Attributes.Length loop Properties.Insert (AMF.CMOF.Named_Elements.CMOF_Named_Element_Access (Attributes.Element (J))); end loop; Properties.Iterate (Assign_Ordered_Set'Access); end Assign_Owned_By_Class_Property; ---------------- -- Assign_Set -- ---------------- procedure Assign_Set (Position : CMOF_Element_Sets.Cursor) is Element : constant AMF.CMOF.Elements.CMOF_Element_Access := CMOF_Element_Sets.Element (Position); begin if not Metamodel_Info.Element_Numbers.Contains (Element) then Last := Last + 1; Metamodel_Info.Element_Numbers.Insert (Element, Last); Metamodel_Info.Number_Element.Insert (Last, Element); end if; end Assign_Set; Element : AMF.CMOF.Elements.CMOF_Element_Access; begin -- Assign numbers for classes and their owned properties. Metamodel_Info.First_Class := Last + 1; Sort (Metamodel_Info.Classes).Iterate (Assign_Ordered_Set'Access); Metamodel_Info.Last_Class := Last; Metamodel_Info.First_Class_Property := Last + 1; Sort (Metamodel_Info.Classes).Iterate (Assign_Collection_Of_Element_Property'Access); Metamodel_Info.Last_Multiple_Class_Property := Last; Sort (Metamodel_Info.Classes).Iterate (Assign_Owned_By_Class_Property'Access); Metamodel_Info.Last_Class_Property := Last; -- Assign numbers for associations. Metamodel_Info.Associations.Iterate (Assign_Set'Access); -- Assign numbers for other elements. for J in 1 .. Elements.Length loop Element := AMF.CMOF.Elements.CMOF_Element_Access (Elements.Element (J)); if not Metamodel_Info.Element_Numbers.Contains (Element) then Last := Last + 1; Metamodel_Info.Element_Numbers.Insert (Element, Last); Metamodel_Info.Number_Element.Insert (Last, Element); end if; end loop; Metamodel_Info.Last_Element := Last; -- XXX This code is disabled, because of non-applicability of current -- implementation to module architecture. -- -- -- Disable generation of attributes and constructors when there are no -- -- classes in the metamodel. -- -- if Metamodel_Info.Classes.Is_Empty then -- Generator.Arguments.Generate_Attributes := False; -- Generator.Arguments.Generate_Constructors := False; -- Generator.Arguments.Generate_Reflection := False; -- end if; end Assign_Element_Numbers; --------------------------- -- Assign_Member_Numbers -- --------------------------- procedure Assign_Member_Numbers is procedure Pack (Map : in out Property_Attribute_Group_Maps.Map; Set : in out Attribute_Group_Sets.Set); function Count (Item : Boolean_Array) return Natural; ---------- -- Pack -- ---------- procedure Pack (Map : in out Property_Attribute_Group_Maps.Map; Set : in out Attribute_Group_Sets.Set) is Attribute : AMF.CMOF.Properties.CMOF_Property_Access; Position : Attribute_Group_Sets.Cursor := Set.First; Selected : Attribute_Group_Access; Merged : Attribute_Group_Access; Result : Attribute_Group_Sets.Set; Aux : CMOF_Property_Sets.Set; begin while not Set.Is_Empty loop Position := Set.First; if Attribute_Group_Sets.Has_Element (Position) then Selected := Attribute_Group_Sets.Element (Position); Attribute_Group_Sets.Next (Position); end if; while Attribute_Group_Sets.Has_Element (Position) loop if Count (Selected.Mask) < Count (Attribute_Group_Sets.Element (Position).Mask) then Selected := Attribute_Group_Sets.Element (Position); end if; Attribute_Group_Sets.Next (Position); end loop; -- Remove selected group from source set and insert it into result -- set. Set.Delete (Selected); Result.Insert (Selected); -- Allocate new number for group. Selected.Index := Natural (Result.Length); -- Pack selected group with another when possible. loop Position := Set.First; Merged := null; -- Lookup for another group witch can be packed with selected -- one. while Attribute_Group_Sets.Has_Element (Position) loop if Count (Selected.Mask and Attribute_Group_Sets.Element (Position).Mask) = 0 then if Merged = null or else Count (Merged.Mask) < Count (Attribute_Group_Sets.Element (Position).Mask) then Merged := Attribute_Group_Sets.Element (Position); end if; end if; Attribute_Group_Sets.Next (Position); end loop; exit when Merged = null; -- Remove merged group from source set of groups. Set.Delete (Merged); -- Recompute new mask of group after pack. Selected.Mask := Selected.Mask or Merged.Mask; -- Fix attribute to group mapping. declare Position : Property_Attribute_Group_Maps.Cursor := Map.First; begin while Property_Attribute_Group_Maps.Has_Element (Position) loop if Property_Attribute_Group_Maps.Element (Position) = Merged then Aux.Insert (Property_Attribute_Group_Maps.Key (Position)); end if; Property_Attribute_Group_Maps.Next (Position); end loop; end; declare Position : CMOF_Property_Sets.Cursor := Aux.First; begin while CMOF_Property_Sets.Has_Element (Position) loop Attribute := CMOF_Property_Sets.Element (Position); Map.Delete (Attribute); Map.Insert (Attribute, Selected); CMOF_Property_Sets.Next (Position); end loop; end; Aux.Clear; end loop; end loop; Set := Result; end Pack; ----------- -- Count -- ----------- function Count (Item : Boolean_Array) return Natural is begin return Result : Natural := 0 do for J in Item'Range loop if Item (J) then Result := Result + 1; end if; end loop; end return; end Count; begin -- Calculate masks. declare Class : AMF.CMOF.Classes.CMOF_Class_Access; Class_Position : CMOF_Class_Sets.Cursor := Module_Info.Classes.First; Info : Class_Information_Access; Current : Positive := 1; Attribute_Position : CMOF_Property_Sets.Cursor; Attribute : AMF.CMOF.Properties.CMOF_Property_Access; begin while CMOF_Class_Sets.Has_Element (Class_Position) loop Class := CMOF_Class_Sets.Element (Class_Position); if not Class.Get_Is_Abstract then Info := Class_Info.Element (Class); Attribute_Position := Info.All_Attributes.First; while CMOF_Property_Sets.Has_Element (Attribute_Position) loop Attribute := CMOF_Property_Sets.Element (Attribute_Position); Attribute_Group.Element (Attribute).Mask (Current) := True; CMOF_Property_Sets.Next (Attribute_Position); end loop; Current := Current + 1; end if; CMOF_Class_Sets.Next (Class_Position); end loop; end; -- Pack members. Pack (Attribute_Group, Member_Groups); Pack (Attribute_Group, Collection_Groups); -- Store results. declare Attribute : AMF.CMOF.Properties.CMOF_Property_Access; Attribute_Info : Attribute_Group_Access; Position : Property_Attribute_Group_Maps.Cursor := Attribute_Group.First; begin while Property_Attribute_Group_Maps.Has_Element (Position) loop Attribute := Property_Attribute_Group_Maps.Key (Position); Attribute_Info := Property_Attribute_Group_Maps.Element (Position); if Use_Member_Slot (Attribute) then Module_Info.Attribute_Member.Insert (Attribute, Attribute_Info.Index); Module_Info.Member_Count := Integer'Max (Module_Info.Member_Count, Attribute_Info.Index); else Module_Info.Attribute_Collection.Insert (Attribute, Attribute_Info.Index); end if; Property_Attribute_Group_Maps.Next (Position); end loop; end; end Assign_Member_Numbers; ----------------------- -- Classify_Elements -- ----------------------- procedure Classify_Elements (Info : not null Metamodel_Information_Access; Elements : AMF.Elements.Collections.Set_Of_Element) is Element : AMF.CMOF.Elements.CMOF_Element_Access; The_Class : AMF.CMOF.Classes.CMOF_Class_Access; begin -- Classify elements and fills All_Classes and All_Associations sets. for J in 1 .. Elements.Length loop Element := AMF.CMOF.Elements.CMOF_Element_Access (Elements.Element (J)); if Element.all in AMF.CMOF.Associations.CMOF_Association'Class then Info.Associations.Insert (Element); elsif Element.all in AMF.CMOF.Classes.CMOF_Class'Class then The_Class := AMF.CMOF.Classes.CMOF_Class_Access (Element); Info.Classes.Insert (Element); if not The_Class.Get_Is_Abstract then Info.Non_Abstract_Classes.Insert (The_Class); end if; if Module_Info.Extents.Contains (Info.Extent) then Module_Info.Classes.Insert (The_Class); end if; elsif Element.all in AMF.CMOF.Data_Types.CMOF_Data_Type'Class then Info.Data_Types.Insert (Element); elsif Element.all in AMF.CMOF.Packages.CMOF_Package'Class then Info.Packages.Insert (Element); end if; end loop; end Classify_Elements; ------------------------ -- Collect_Attributes -- ------------------------ procedure Collect_Attributes (Metamodel_Info : not null Metamodel_Information_Access) is procedure Analyze_Class (Class : not null AMF.CMOF.Classes.CMOF_Class_Access); -- Analyze superclasses and attributes of the specified class. ------------------- -- Analyze_Class -- ------------------- procedure Analyze_Class (Class : not null AMF.CMOF.Classes.CMOF_Class_Access) is Superclasses : constant AMF.CMOF.Classes.Collections.Set_Of_CMOF_Class := Class.Get_Super_Class; Attributes : constant AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property := Class.Get_Owned_Attribute; Attribute_Type : AMF.CMOF.Types.CMOF_Type_Access; Attribute : AMF.CMOF.Properties.CMOF_Property_Access; Redefines : AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property; Attribute_Info : Attribute_Group_Access; begin for J in 1 .. Superclasses.Length loop Analyze_Class (Superclasses.Element (J)); end loop; for J in 1 .. Attributes.Length loop Attribute := Attributes.Element (J); Attribute_Type := Attribute.Get_Type; Attribute_Info := null; -- Attribute can be analyzed already, skip it then. if not Attribute_Group.Contains (Attribute) then Redefines := Attribute.Get_Redefined_Property; if Attribute_Type.all not in AMF.CMOF.Classes.CMOF_Class'Class then -- For attributes of non-Class type we reused -- member/collection for redefined and equally named -- attributes. if not Redefines.Is_Empty then -- Attribute redefines another one, use the same -- attribute information. Attribute_Info := Attribute_Group.Element (Redefines.Element (1)); else -- Lookup for another analyzed attribute which is not -- distinguishable as Ada subprogram. declare Position : Property_Attribute_Group_Maps.Cursor := Attribute_Group.First; Other_Attribute : AMF.CMOF.Properties.CMOF_Property_Access; Other_Class : AMF.CMOF.Classes.CMOF_Class_Access; begin while Property_Attribute_Group_Maps.Has_Element (Position) loop Other_Attribute := Property_Attribute_Group_Maps.Key (Position); Other_Class := Other_Attribute.Get_Class; if not Attribute_Mapping.Is_Ada_Distinguishable (Attribute, Other_Attribute, Internal) then Attribute_Info := Property_Attribute_Group_Maps.Element (Position); exit; end if; Property_Attribute_Group_Maps.Next (Position); end loop; end; end if; end if; if Attribute_Info = null then if Use_Member_Slot (Attribute) then Attribute_Info := new Attribute_Group_Information' (Length => Natural (Module_Info.Classes.Length), Index => Natural (Member_Groups.Length) + 1, Mask => (others => False)); Member_Groups.Insert (Attribute_Info); else Attribute_Info := new Attribute_Group_Information' (Length => Natural (Module_Info.Classes.Length), Index => Natural (Collection_Groups.Length) + 1, Mask => (others => False)); Collection_Groups.Insert (Attribute_Info); end if; end if; Attribute_Group.Insert (Attribute, Attribute_Info); end if; end loop; end Analyze_Class; begin -- Group attributes by unique setter/getter subprogram. declare Position : CMOF_Element_Sets.Cursor := Metamodel_Info.Classes.First; begin while CMOF_Element_Sets.Has_Element (Position) loop Analyze_Class (AMF.CMOF.Classes.CMOF_Class_Access (CMOF_Element_Sets.Element (Position))); CMOF_Element_Sets.Next (Position); end loop; end; end Collect_Attributes; ---------------------------- -- Compute_All_Properties -- ---------------------------- procedure Compute_All_Properties (Extents : in out AMF.Extents.Collections.Set_Of_Extent; Class : not null AMF.CMOF.Classes.CMOF_Class_Access) is procedure Process_Class (Class : not null AMF.CMOF.Classes.CMOF_Class_Access); -- Process specified class and all its superclasses. Info : not null Class_Information_Access := new Class_Information'(Class, others => <>); ------------------- -- Process_Class -- ------------------- procedure Process_Class (Class : not null AMF.CMOF.Classes.CMOF_Class_Access) is Superclasses : AMF.CMOF.Classes.Collections.Set_Of_CMOF_Class := Class.Get_Super_Class; Attributes : AMF.CMOF.Properties.Collections.Ordered_Set_Of_CMOF_Property := Class.Get_Owned_Attribute; Redefines : AMF.CMOF.Properties.Collections.Set_Of_CMOF_Property; Attribute : AMF.CMOF.Properties.CMOF_Property_Access; Attribute_Type : AMF.CMOF.Types.CMOF_Type_Access; begin -- Process superclasses for J in 1 .. Superclasses.Length loop Process_Class (Superclasses.Element (J)); end loop; -- Add class's extent into the set of used extents. Extents.Include (AMF.Elements.Element_Access (Class).Extent); -- Process class's attributes for J in 1 .. Attributes.Length loop Attribute := Attributes.Element (J); Redefines := Attribute.Get_Redefined_Property; Attribute_Type := Attribute.Get_Type; -- Add property into set of all attributes. if not Info.All_Attributes.Contains (Attribute) then Info.All_Attributes.Insert (Attribute); end if; -- Add redefined attribute into the set of redefined attributes. for J in 1 .. Redefines.Length loop if not Info.Redefined_Attributes.Contains (Redefines.Element (J)) then Info.Redefined_Attributes.Include (Redefines.Element (J)); end if; end loop; end loop; end Process_Class; begin if Class.Get_Is_Abstract then -- Ignore abstract classes. return; end if; Process_Class (Class); Class_Info.Insert (Class, Info); Module_Info.Non_Abstract_Classes.Insert (Class); end Compute_All_Properties; ---------------------------- -- Compute_Metamodel_Name -- ---------------------------- procedure Compute_Metamodel_Name (Metamodel_Info : not null Metamodel_Information_Access) is Elements : constant AMF.Elements.Collections.Set_Of_Element := Metamodel_Info.Extent.Elements; begin -- Looking for first instance of CMOF::Package and use its name to -- compute metamodel name of analyzed extent. for J in 1 .. Elements.Length loop if Elements.Element (J).all in AMF.CMOF.Packages.CMOF_Package'Class then Metamodel_Info.Ada_Name := League.Strings.To_Universal_String (Generator.Names.To_Ada_Identifier (AMF.CMOF.Packages.CMOF_Package'Class (Elements.Element (J).all).Get_Name.Value)); exit; end if; end loop; end Compute_Metamodel_Name; ------------------------- -- Extract_String_Data -- ------------------------- procedure Extract_String_Data (Metamodel_Info : not null Metamodel_Information_Access) is package String_Sets is new Ada.Containers.Hashed_Sets (League.Strings.Universal_String, League.Strings.Hash, League.Strings."=", League.Strings."="); procedure Extract_String_Data (Position : CMOF_Element_Sets.Cursor); procedure Assign_String (Position : String_Sets.Cursor); Elements : AMF.Elements.Collections.Set_Of_Element := Metamodel_Info.Extent.Elements; Strings : String_Sets.Set; Last : Natural := 0; ------------------- -- Assign_String -- ------------------- procedure Assign_String (Position : String_Sets.Cursor) is Element : constant League.Strings.Universal_String := String_Sets.Element (Position); begin Metamodel_Info.String_Numbers.Insert (Element, Last); Metamodel_Info.Number_Strings.Insert (Last, Element); Last := Last + 1; end Assign_String; Element : AMF.CMOF.Elements.CMOF_Element_Access; ------------------------- -- Extract_String_Data -- ------------------------- procedure Extract_String_Data (Position : CMOF_Element_Sets.Cursor) is Property : constant AMF.CMOF.Properties.CMOF_Property_Access := AMF.CMOF.Properties.CMOF_Property_Access (CMOF_Element_Sets.Element (Position)); Property_Type : constant AMF.CMOF.Types.CMOF_Type_Access := Property.Get_Type; Value : League.Holders.Holder; Collection : AMF.Reflective_Collections.Reflective_Collection; String_Value : League.Strings.Universal_String; begin if Property_Type.Get_Name.Value = +"String" and then not Property.Get_Is_Derived then Value := AMF.Elements.Abstract_Element'Class (Element.all).Get (Property); if Property.Is_Multivalued then Collection := AMF.Holders.Reflective_Collections.Element (Value); for J in 1 .. Collection.Length loop String_Value := League.Holders.Element (Collection.Element (J)); if not String_Value.Is_Empty then Strings.Include (String_Value); end if; end loop; else if not League.Holders.Is_Empty (Value) then String_Value := League.Holders.Element (Value); if not String_Value.Is_Empty then Strings.Include (String_Value); end if; end if; end if; end if; end Extract_String_Data; begin -- Collect string data. for J in 1 .. Elements.Length loop Element := AMF.CMOF.Elements.CMOF_Element_Access (Elements.Element (J)); Class_Properties_Except_Redefined (AMF.Elements.Abstract_Element'Class (Element.all).Get_Meta_Class).Iterate (Extract_String_Data'Access); end loop; -- Assign number for strings. Strings.Iterate (Assign_String'Access); end Extract_String_Data; ---------- -- Hash -- ---------- function Hash (Item : Attribute_Group_Access) return Ada.Containers.Hash_Type is begin return Ada.Containers.Hash_Type (Item.Index); end Hash; end Generator.Analyzer;
godunko/adawebpack
Ada
6,057
adb
------------------------------------------------------------------------------ -- -- -- AdaWebPack -- -- -- ------------------------------------------------------------------------------ -- Copyright © 2021, Vadim Godunko -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- ------------------------------------------------------------------------------ with System; with Web.Strings.WASM_Helpers; package body WASM.Objects.Attributes is ----------------- -- Get_Boolean -- ----------------- function Get_Boolean (Self : Object_Reference'Class; Name : WASM.Attributes.Attribute_Index) return Boolean is use type Interfaces.Unsigned_32; function Imported (Object : WASM.Objects.Object_Identifier; Attribute : WASM.Attributes.Attribute_Index) return Interfaces.Unsigned_32 with Import => True, Convention => C, Link_Name => "__adawebpack___boolean_getter"; begin return Imported (Self.Identifier, Name) /= 0; end Get_Boolean; ---------------- -- Get_Object -- ---------------- function Get_Object (Self : Object_Reference'Class; Name : WASM.Attributes.Attribute_Index) return WASM.Objects.Object_Identifier is function Imported (Object : WASM.Objects.Object_Identifier; Attribute : WASM.Attributes.Attribute_Index) return WASM.Objects.Object_Identifier with Import => True, Convention => C, Link_Name => "__adawebpack___object_getter"; begin return Imported (Self.Identifier, Name); end Get_Object; ---------------- -- Get_String -- ---------------- function Get_String (Self : Object_Reference'Class; Name : WASM.Attributes.Attribute_Index) return Web.Strings.Web_String is function Imported (Object : WASM.Objects.Object_Identifier; Attribute : WASM.Attributes.Attribute_Index) return System.Address with Import => True, Convention => C, Link_Name => "__adawebpack___string_getter"; begin return Web.Strings.WASM_Helpers.To_Ada (Imported (Self.Identifier, Name)); end Get_String; ----------------- -- Set_Boolean -- ----------------- procedure Set_Boolean (Self : Object_Reference'Class; Name : WASM.Attributes.Attribute_Index; To : Boolean) is procedure Imported (Object : WASM.Objects.Object_Identifier; Attribute : WASM.Attributes.Attribute_Index; To : Interfaces.Unsigned_32) with Import => True, Convention => C, Link_Name => "__adawebpack___boolean_setter"; begin Imported (Self.Identifier, Name, Boolean'Pos (To)); end Set_Boolean; ---------------- -- Set_String -- ---------------- procedure Set_String (Self : Object_Reference'Class; Name : WASM.Attributes.Attribute_Index; To : Web.Strings.Web_String) is procedure Imported (Object : WASM.Objects.Object_Identifier; Attribute : WASM.Attributes.Attribute_Index; Address : System.Address; Size : Interfaces.Unsigned_32) with Import => True, Convention => C, Link_Name => "__adawebpack___string_setter"; A : System.Address; S : Interfaces.Unsigned_32; begin Web.Strings.WASM_Helpers.To_JS (To, A, S); Imported (Self.Identifier, Name, A, S); end Set_String; end WASM.Objects.Attributes;
AdaCore/libadalang
Ada
405
adb
procedure Test is package Foo is type T is null record; function "=" (A, B : T) return Boolean is (True); end Foo; package Bar is type U is new Foo.T; end Bar; use Bar; A, B : U; begin if A /= B then raise Program_Error; end if; pragma Test_Statement; if "/=" (A, B) then raise Program_Error; end if; pragma Test_Statement; end Test;
zhmu/ananas
Ada
4,992
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY COMPONENTS -- -- -- -- S Y S T E M . C O M P A R E _ A R R A Y _ S I G N E D _ 1 6 -- -- -- -- B o d y -- -- -- -- Copyright (C) 2002-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Address_Operations; use System.Address_Operations; with Ada.Unchecked_Conversion; package body System.Compare_Array_Signed_16 is type Word is mod 2 ** 32; -- Used to process operands by words type Half is range -(2 ** 15) .. (2 ** 15) - 1; for Half'Size use 16; -- Used to process operands by half words type Uhalf is new Half; for Uhalf'Alignment use 1; -- Used to process operands when unaligned type WP is access Word; type HP is access Half; type UP is access Uhalf; function W is new Ada.Unchecked_Conversion (Address, WP); function H is new Ada.Unchecked_Conversion (Address, HP); function U is new Ada.Unchecked_Conversion (Address, UP); ----------------------- -- Compare_Array_S16 -- ----------------------- function Compare_Array_S16 (Left : System.Address; Right : System.Address; Left_Len : Natural; Right_Len : Natural) return Integer is Clen : Natural := Natural'Min (Left_Len, Right_Len); -- Number of elements left to compare L : Address := Left; R : Address := Right; -- Pointers to next elements to compare begin -- Go by words if possible if ModA (OrA (Left, Right), 4) = 0 then while Clen > 1 and then W (L).all = W (R).all loop Clen := Clen - 2; L := AddA (L, 4); R := AddA (R, 4); end loop; end if; -- Case of going by aligned half words if ModA (OrA (Left, Right), 2) = 0 then while Clen /= 0 loop if H (L).all /= H (R).all then if H (L).all > H (R).all then return +1; else return -1; end if; end if; Clen := Clen - 1; L := AddA (L, 2); R := AddA (R, 2); end loop; -- Case of going by unaligned half words else while Clen /= 0 loop if U (L).all /= U (R).all then if U (L).all > U (R).all then return +1; else return -1; end if; end if; Clen := Clen - 1; L := AddA (L, 2); R := AddA (R, 2); end loop; end if; -- Here if common section equal, result decided by lengths if Left_Len = Right_Len then return 0; elsif Left_Len > Right_Len then return +1; else return -1; end if; end Compare_Array_S16; end System.Compare_Array_Signed_16;
reznikmm/matreshka
Ada
4,641
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2017, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Services; with League.Strings; with League.String_Vectors; with Matreshka.Servlet_Servers.AWS_Servers; with Matreshka.Servlet_Containers; package Spikedog.Service is type Service is new Services.Service with private; -- Windows Service to run Spikedog server private protected type Semaphore is entry Acquire; entry Release; private Busy : Boolean := True; end Semaphore; type Service is new Services.Service with record AWS_Server : aliased Matreshka.Servlet_Servers.AWS_Servers.AWS_Server; Container : Matreshka.Servlet_Containers.Servlet_Container_Access := new Matreshka.Servlet_Containers.Servlet_Container; Stop_Flag : Semaphore; Application_Name : League.Strings.Universal_String := League.Strings.To_Universal_String ("Spikedog Application Server"); end record; overriding function Name (Self : Service) return League.Strings.Universal_String; overriding procedure Run (Self : in out Service; Args : League.String_Vectors.Universal_String_Vector; Status : Services.Status_Listener_Access); overriding procedure Control (Self : in out Service; Control : Services.Control_Kind; Status : Services.Status_Listener_Access); end Spikedog.Service;
reznikmm/matreshka
Ada
4,708
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Table_Dde_Link_Elements; package Matreshka.ODF_Table.Dde_Link_Elements is type Table_Dde_Link_Element_Node is new Matreshka.ODF_Table.Abstract_Table_Element_Node and ODF.DOM.Table_Dde_Link_Elements.ODF_Table_Dde_Link with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Dde_Link_Element_Node; overriding function Get_Local_Name (Self : not null access constant Table_Dde_Link_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Table_Dde_Link_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Table_Dde_Link_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Table_Dde_Link_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Table.Dde_Link_Elements;
damaki/SPARKNaCl
Ada
1,572
adb
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Core; use SPARKNaCl.Core; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Secretbox; use SPARKNaCl.Secretbox; with SPARKNaCl.Stream; with Ada.Text_IO; use Ada.Text_IO; with System.Assertions; use System.Assertions; procedure Secretbox3 is Firstkey : constant Core.Salsa20_Key := Construct ((16#1b#, 16#27#, 16#55#, 16#64#, 16#73#, 16#e9#, 16#85#, 16#d4#, 16#62#, 16#cd#, 16#51#, 16#19#, 16#7a#, 16#9a#, 16#46#, 16#c7#, 16#60#, 16#09#, 16#54#, 16#9e#, 16#ac#, 16#64#, 16#74#, 16#f2#, 16#06#, 16#c4#, 16#ee#, 16#08#, 16#44#, 16#f6#, 16#83#, 16#89#)); Nonce : constant Stream.HSalsa20_Nonce := (16#69#, 16#69#, 16#6e#, 16#e9#, 16#55#, 16#b6#, 16#2b#, 16#73#, 16#cd#, 16#62#, 16#bd#, 16#a8#, 16#75#, 16#fc#, 16#73#, 16#d6#, 16#82#, 16#19#, 16#e0#, 16#03#, 16#6b#, 16#7a#, 16#0b#, 16#37#); -- C too short C : constant Byte_Seq (0 .. 15) := (16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#); M : Byte_Seq (0 .. 15); S : Boolean; begin S := False; Open (M, S, C, Nonce, Firstkey); if S then Put_Line ("Status is " & Img (S)); DH ("M is", M); else Put_Line ("Precondition failure expected OK"); end if; exception when Assert_Failure => Put_Line ("Precondition failure expected OK"); end Secretbox3;
MinimSecure/unum-sdk
Ada
991
ads
-- 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/>. with Ada.Finalization; package Bar is type Object_Type is new Ada.Finalization.Controlled with record Value : Boolean; end record; function Get_Str (S1 : String; S2 : String := "") return Object_Type; procedure Do_Nothing (C : Character); end Bar;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Office_Document_Styles_Elements is pragma Preelaborate; type ODF_Office_Document_Styles is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Office_Document_Styles_Access is access all ODF_Office_Document_Styles'Class with Storage_Size => 0; end ODF.DOM.Office_Document_Styles_Elements;
AdaCore/training_material
Ada
516
adb
procedure Main is --$ begin cut procedure P is type T1 is tagged null record; procedure Not_Prim (A : T1) is null; type T2 is new T1 with null record; O1 : T1; O2 : T2; begin -- Not a primitive Not_Prim (O1); -- Would not compile -- Not_Prim (O2); end P; --$ end cut -- Works for non-tagged types type T_Int is new Integer; procedure Prim (A : T_Int) is null; type T2_Int is new T_Int; A : T2_Int; begin Prim (A); end Main;
stcarrez/hestia
Ada
9,357
adb
----------------------------------------------------------------------- -- hestia-display-scheduler -- Display information about the system -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with BMP_Fonts; with Interfaces; with Hestia.Network; with Hestia.Time; with UI.Texts; package body Hestia.Display.Scheduler is use type Interfaces.Unsigned_32; use type Interfaces.Unsigned_64; use UI.Texts; use type Net.Uint16; use type Hestia.Scheduler.Day_Time; use type Hestia.Scheduler.State_Type; use Hestia.Scheduler; -- Convert the integer to a string without a leading space. function Image (Value : in Natural) return String; function Image (Value : in Natural) return String is Result : constant String := Natural'Image (Value); begin return Result (Result'First + 1 .. Result'Last); end Image; use Ada.Real_Time; ONE_MS : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (1); TOUCH_DELAY : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Milliseconds (600); -- ------------------------------ -- Draw the layout presentation frame. -- ------------------------------ overriding procedure On_Restore (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is W : constant Natural := Buffer.Width; H : constant Natural := Buffer.Height; D2 : constant Natural := W / 6; begin Display.Back_Button.Pos := (0, 0); Display.Back_Button.Width := 100; Display.Back_Button.Height := 30; Display.Slide_Button.Pos := (0, H - 60); Display.Slide_Button.Width := W; Display.Slide_Button.Height := 60; Display.Schedule_Area.Pos := (0, 120); Display.Schedule_Area.Width := W; Display.Schedule_Area.Height := 80; Display.Start_Time.Day := Hestia.Time.Monday; Display.Start_Time.Hour := 0; Display.Start_Time.Minute := 0; Display.Delta_Time := 12 * 24; Display.End_Time := Display.Start_Time + Display.Delta_Time; Display.Width := W; Display.Last_Touch := Ada.Real_Time.Clock; Display.Touch_Disable := True; Buffer.Set_Source (UI.Texts.Background); Buffer.Fill; UI.Texts.Current_Font := BMP_Fonts.Font16x24; UI.Texts.Draw_String (Buffer => Buffer, Start => Display.Back_Button.Pos, Width => Display.Back_Button.Width, Msg => "Back", Justify => UI.Texts.CENTER); Display.Deadline := Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds (1000); end On_Restore; function Get_X (Display : in Display_Type; Date : in Hestia.Scheduler.Day_Time) return Natural is R : Integer := Display.Delta_Time; Dt : Integer := Date - Display.Start_Time; begin Dt := Dt * Display.Width; return Dt / R; end Get_X; function Get_Time (Display : in Display_Type; X : in Natural) return Day_Time is Dt : constant Natural := (Display.Delta_Time * X) / Display.Width; begin return Display.Start_Time + Dt; end Get_Time; -- Refresh the current display. overriding procedure On_Refresh (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class; Deadline : out Ada.Real_Time.Time) is use type Net.Uint32; W : constant Natural := Buffer.Width; H : constant Natural := Buffer.Height; D : constant Natural := W / 24; D2 : constant Natural := W / 6; Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; Start : Hestia.Scheduler.Day_Time; X1, X2 : Natural; Prev : Hestia.Scheduler.State_Type; New_State : Hestia.Scheduler.State_Type; begin Buffer.Set_Source (Line_Color); Buffer.Fill_Rect ((Position => (0, 60 - 3), Width => W, Height => 3)); Buffer.Fill_Rect ((Position => (0, 120), Width => W, Height => 2)); Buffer.Fill_Rect ((Position => (0, 200), Width => W, Height => 2)); Buffer.Set_Source (UI.Texts.Background); Buffer.Fill_Rect ((Position => (0, 100), Width => W, Height => 16)); Buffer.Set_Source (Hot_Color); Buffer.Fill_Rect ((Position => (120, 121), Width => 150, Height => 78)); Buffer.Fill_Rect ((Position => (W - 70, 121), Width => 69, Height => 78)); UI.Texts.Current_Font := BMP_Fonts.Font16x24; Start := Display.Get_Time (W / 2); UI.Texts.Draw_String (Buffer, Start => (0, 70), Width => W, Msg => Hestia.Time.Day_Names (Start.Day), Justify => UI.Texts.CENTER); UI.Texts.Current_Font := BMP_Fonts.Font12x12; Start := Display.Start_Time; while Start < Display.End_Time loop New_State := Hestia.Scheduler.Get_State (Start, Display.Port); X1 := Display.Get_X (Start); X2 := Display.Get_X (Start + Hestia.Scheduler.Unit); if New_State /= Prev and X1 - 20 + 100 < W and X1 > 20 then UI.Texts.Draw_String (Buffer, Start => (X1 - 20, 100), Width => 100, Msg => Hestia.Scheduler.Format_Time (Start)); end if; if New_State = Hestia.Scheduler.ON then Buffer.Set_Source (Hot_Color); else Buffer.Set_Source (Cold_Color); end if; Buffer.Fill_Rect ((Position => (X1, 121), Width => X2 - X1, Height => 78)); Prev := New_State; Start := Start + Hestia.Scheduler.Unit; end loop; if Display.Touch_Disable and Now - Display.Last_Touch < TOUCH_DELAY then Display.Touch_Disable := False; end if; Deadline := Display.Deadline; end On_Refresh; -- Handle touch events on the display. overriding procedure On_Touch (Display : in out Display_Type; Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class; States : in HAL.Touch_Panel.TP_State) is use UI.Buttons; Now : Ada.Real_Time.Time := Ada.Real_Time.Clock; X : constant Natural := States (States'First).X; Y : constant Natural := States (States'First).Y; Dx : Integer; Dy : Integer; begin if UI.Buttons.Contains (Display.Back_Button, X, Y) then UI.Displays.Pop_Display; elsif UI.Buttons.Contains (Display.Slide_Button, X, Y) then if States'Length > 0 then Dx := States (States'Last).X - X; Dy := States (States'Last).Y - Y; if Dx > 0 then Display.Start_Time := Display.Start_Time + Hestia.Scheduler.Unit; Display.End_Time := Display.End_Time + Hestia.Scheduler.Unit; elsif Dx < 0 then Display.Start_Time := Display.Start_Time + Hestia.Scheduler.Unit; Display.End_Time := Display.End_Time + Hestia.Scheduler.Unit; end if; end if; elsif UI.Buttons.Contains (Display.Schedule_Area, X, Y) and not Display.Touch_Disable then if Now - Display.Last_Touch > TOUCH_DELAY then if Hestia.Scheduler.Get_State (Display.Get_Time (X), Display.Port) = ON then Display.Last_State := OFF; else Display.Last_State := ON; end if; end if; Display.Last_Touch := Now; for Dx in -4 .. 4 loop if X >= Dx and X + Dx < Display.Width then declare T : Day_Time := Display.Get_Time (X + Dx); begin Hestia.Scheduler.Set_State (T, Display.Port, Display.Last_State); end; end if; end loop; Display.Refresh (Buffer, UI.Displays.REFRESH_BOTH); end if; end On_Touch; -- Set the zone for the schedule. procedure Set_Zone (Display : in out Display_Type; Port : in Ports.Zone_Type) is begin Display.Port := Port; end Set_Zone; end Hestia.Display.Scheduler;