repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
faelys/ada-syslog
Ada
1,788
ads
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Syslog.Transport.UDP provides a transporter that sends messages over UDP -- -- to a given host, using GNAT.Sockets. -- ------------------------------------------------------------------------------ package Syslog.Transport.UDP is Transport : constant Transporter; procedure Connect (Hostname : in String; Port : in Natural := 514); private procedure Send (Message : in String); Transport : constant Transporter := Send'Access; end Syslog.Transport.UDP;
zhmu/ananas
Ada
1,286
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . N U M E R I C S . S H O R T _ C O M P L E X _ T Y P E S -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Complex_Types; package Ada.Numerics.Short_Complex_Types is new Ada.Numerics.Generic_Complex_Types (Short_Float); pragma Pure (Short_Complex_Types);
optikos/oasis
Ada
13,117
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Element_Visitors; with Program.Elements.Component_Definitions; with Program.Elements.Defining_Identifiers; with Program.Elements.Defining_Names; with Program.Elements.Enumeration_Literal_Specifications; with Program.Elements.Enumeration_Types; -- with Program.Elements.Expressions; with Program.Elements.Exception_Declarations; with Program.Elements.Floating_Point_Types; with Program.Elements.Identifiers; with Program.Elements.Package_Declarations; with Program.Elements.Signed_Integer_Types; with Program.Elements.Subtype_Declarations; with Program.Elements.Subtype_Indications; with Program.Elements.Type_Declarations; with Program.Elements.Unconstrained_Array_Types; with Program.Lexical_Elements; with Program.Plain_Lexical_Elements; with Program.Resolvers; with Program.Symbols; with Program.Visibility; procedure Program.Resolve_Standard (Unit : not null Program.Compilation_Units.Compilation_Unit_Access; Env : aliased in out Program.Visibility.Context) is function To_Symbol (Name : access Program.Elements.Element'Class) return Program.Symbols.Symbol; package Visitors is type Visitor (Env : not null access Program.Visibility.Context) is new Program.Element_Visitors.Element_Visitor with record Type_Name : Program.Elements.Defining_Names.Defining_Name_Access; Type_View : Program.Visibility.View; Meta_Char : Program.Visibility.Meta_Character_Literal_Kind := Program.Visibility.Meta_Character; end record; procedure Visit_Each_Child (Self : in out Visitor; Element : access Program.Elements.Element'Class); overriding procedure Enumeration_Literal_Specification (Self : in out Visitor; Element : not null Program.Elements.Enumeration_Literal_Specifications .Enumeration_Literal_Specification_Access); overriding procedure Enumeration_Type (Self : in out Visitor; Element : not null Program.Elements.Enumeration_Types .Enumeration_Type_Access); overriding procedure Exception_Declaration (Self : in out Visitor; Element : not null Program.Elements.Exception_Declarations .Exception_Declaration_Access); overriding procedure Floating_Point_Type (Self : in out Visitor; Element : not null Program.Elements.Floating_Point_Types .Floating_Point_Type_Access); overriding procedure Package_Declaration (Self : in out Visitor; Element : not null Program.Elements.Package_Declarations .Package_Declaration_Access); overriding procedure Signed_Integer_Type (Self : in out Visitor; Element : not null Program.Elements.Signed_Integer_Types .Signed_Integer_Type_Access); overriding procedure Subtype_Declaration (Self : in out Visitor; Element : not null Program.Elements.Subtype_Declarations .Subtype_Declaration_Access); overriding procedure Type_Declaration (Self : in out Visitor; Element : not null Program.Elements.Type_Declarations .Type_Declaration_Access); overriding procedure Unconstrained_Array_Type (Self : in out Visitor; Element : not null Program.Elements.Unconstrained_Array_Types .Unconstrained_Array_Type_Access); end Visitors; package body Visitors is --------------------------------------- -- Enumeration_Literal_Specification -- --------------------------------------- overriding procedure Enumeration_Literal_Specification (Self : in out Visitor; Element : not null Program.Elements.Enumeration_Literal_Specifications .Enumeration_Literal_Specification_Access) is Symbol : constant Program.Symbols.Symbol := Program.Resolvers.To_Symbol (Element.Name); begin if Symbol in Program.Symbols.Character_Literal_Symbol then Self.Env.Create_Character_Literal (Symbol, Element.Name, Self.Meta_Char, Self.Type_View); if Self.Meta_Char not in Visibility.Meta_Wide_Wide_Character then Self.Meta_Char := Visibility.Meta_Character_Literal_Kind'Succ (Self.Meta_Char); end if; else Self.Env.Create_Enumeration_Literal (Symbol, Element.Name, Self.Type_View); end if; end Enumeration_Literal_Specification; ---------------------- -- Enumeration_Type -- ---------------------- overriding procedure Enumeration_Type (Self : in out Visitor; Element : not null Program.Elements.Enumeration_Types .Enumeration_Type_Access) is begin Self.Env.Create_Enumeration_Type (Symbol => Program.Resolvers.To_Symbol (Self.Type_Name), Name => Self.Type_Name); Self.Type_View := Self.Env.Latest_View; Self.Visit_Each_Child (Element); end Enumeration_Type; --------------------------- -- Exception_Declaration -- --------------------------- overriding procedure Exception_Declaration (Self : in out Visitor; Element : not null Program.Elements.Exception_Declarations .Exception_Declaration_Access) is Name : constant Program.Elements.Defining_Identifiers .Defining_Identifier_Access := Element.Names.To_Defining_Identifier (1); begin Self.Env.Create_Exception (Symbol => Program.Resolvers.To_Symbol (Name), Name => Program.Elements.Defining_Names.Defining_Name_Access (Name)); end Exception_Declaration; ------------------------- -- Floating_Point_Type -- ------------------------- overriding procedure Floating_Point_Type (Self : in out Visitor; Element : not null Program.Elements.Floating_Point_Types .Floating_Point_Type_Access) is pragma Unreferenced (Element); begin Self.Env.Create_Float_Point_Type (Symbol => Program.Resolvers.To_Symbol (Self.Type_Name), Name => Self.Type_Name); end Floating_Point_Type; ------------------------- -- Package_Declaration -- ------------------------- overriding procedure Package_Declaration (Self : in out Visitor; Element : not null Program.Elements.Package_Declarations .Package_Declaration_Access) is begin Self.Env.Create_Package (Symbol => Program.Symbols.Standard, Name => Element.Name); Self.Visit_Each_Child (Element); end Package_Declaration; ------------------------- -- Signed_Integer_Type -- ------------------------- overriding procedure Signed_Integer_Type (Self : in out Visitor; Element : not null Program.Elements.Signed_Integer_Types .Signed_Integer_Type_Access) is pragma Unreferenced (Element); begin Self.Env.Create_Signed_Integer_Type (Symbol => Program.Resolvers.To_Symbol (Self.Type_Name), Name => Self.Type_Name); end Signed_Integer_Type; ------------------------- -- Subtype_Declaration -- ------------------------- overriding procedure Subtype_Declaration (Self : in out Visitor; Element : not null Program.Elements.Subtype_Declarations .Subtype_Declaration_Access) is Subtype_Name : constant Program.Elements.Defining_Names .Defining_Name_Access := Program.Elements.Defining_Names.Defining_Name_Access (Element.Name); Subtype_Mark_Symbol : constant Program.Symbols.Symbol := To_Symbol (Element.Subtype_Indication.Subtype_Mark); Subtype_Mark_Views : constant Program.Visibility.View_Array := Self.Env.Immediate_Visible (Subtype_Mark_Symbol); begin Self.Env.Create_Subtype (Symbol => Program.Resolvers.To_Symbol (Subtype_Name), Name => Subtype_Name, Subtype_Mark => Subtype_Mark_Views (1), Has_Constraint => Element.Subtype_Indication.Constraint.Assigned); Self.Visit_Each_Child (Element); end Subtype_Declaration; ---------------------- -- Type_Declaration -- ---------------------- overriding procedure Type_Declaration (Self : in out Visitor; Element : not null Program.Elements.Type_Declarations .Type_Declaration_Access) is begin Self.Type_Name := Program.Elements.Defining_Names.Defining_Name_Access (Element.Name); Self.Visit_Each_Child (Element); Self.Type_Name := null; end Type_Declaration; ------------------------------ -- Unconstrained_Array_Type -- ------------------------------ overriding procedure Unconstrained_Array_Type (Self : in out Visitor; Element : not null Program.Elements.Unconstrained_Array_Types .Unconstrained_Array_Type_Access) is Index_Symbol : constant Program.Symbols.Symbol := To_Symbol (Element.Index_Subtypes.Element (1)); Index_View : constant Program.Visibility.View := Self.Env.Immediate_Visible (Index_Symbol) (1); Component_Symbol : constant Program.Symbols.Symbol := To_Symbol (Element.Component_Definition); Component_View : constant Program.Visibility.View := Self.Env.Immediate_Visible (Component_Symbol) (1); begin Self.Env.Create_Array_Type (Symbol => Program.Resolvers.To_Symbol (Self.Type_Name), Name => Self.Type_Name, Indexes => (1 => Index_View), Component => Component_View); end Unconstrained_Array_Type; ---------------------- -- Visit_Each_Child -- ---------------------- procedure Visit_Each_Child (Self : in out Visitor; Element : access Program.Elements.Element'Class) is begin for Cursor in Element.Each_Child loop Cursor.Element.Visit (Self); end loop; end Visit_Each_Child; end Visitors; function To_Symbol (Name : access Program.Elements.Element'Class) return Program.Symbols.Symbol is type Getter is new Program.Element_Visitors.Element_Visitor with record Result : Program.Symbols.Symbol := Program.Symbols.No_Symbol; end record; overriding procedure Identifier (Self : in out Getter; Element : not null Program.Elements.Identifiers.Identifier_Access); overriding procedure Component_Definition (Self : in out Getter; Element : not null Program.Elements.Component_Definitions .Component_Definition_Access); overriding procedure Subtype_Indication (Self : in out Getter; Element : not null Program.Elements.Subtype_Indications .Subtype_Indication_Access); -------------------------- -- Component_Definition -- -------------------------- overriding procedure Component_Definition (Self : in out Getter; Element : not null Program.Elements.Component_Definitions .Component_Definition_Access) is begin Element.Subtype_Indication.Visit (Self); end Component_Definition; ---------------- -- Identifier -- ---------------- overriding procedure Identifier (Self : in out Getter; Element : not null Program.Elements.Identifiers.Identifier_Access) is Token : constant Program.Lexical_Elements.Lexical_Element_Access := Element.To_Identifier_Text.Identifier_Token; begin Self.Result := Program.Plain_Lexical_Elements.Lexical_Element (Token.all).Symbol; end Identifier; ------------------------ -- Subtype_Indication -- ------------------------ overriding procedure Subtype_Indication (Self : in out Getter; Element : not null Program.Elements.Subtype_Indications .Subtype_Indication_Access) is begin Element.Subtype_Mark.Visit (Self); end Subtype_Indication; G : Getter; begin Name.Visit (G); pragma Assert (G.Result not in Program.Symbols.No_Symbol); return G.Result; end To_Symbol; Visitor : Visitors.Visitor (Env'Access); Root : constant Program.Elements.Element_Access := Unit.Unit_Declaration; begin Env.Create_Empty_Context; Root.Visit (Visitor); end Program.Resolve_Standard;
AdaCore/Ada_Drivers_Library
Ada
3,820
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_rng.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief Header file of RNG HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides the API for the random number generator on the STM32F4 -- (ARM Cortex M4F) microcontrollers from ST Microelectronics. -- -- Random numbers are acquired by polling the on-board generator. package STM32.RNG.Polling is procedure Initialize_RNG with Post => not RNG_Interrupt_Enabled; -- Must be called once, prior to any call to get a random number via -- polling. Both necessary and sufficient. -- Enables the clock as well. function Random return UInt32; -- Polls the RNG directly to get the next available number. -- NB: call Initialize_RNG before any calls to this function. end STM32.RNG.Polling;
charlie5/aIDE
Ada
1,278
ads
with Ada.Strings.unbounded, Ada.Containers.vectors; package AdaM is -- Text -- subtype Text is ada.Strings.Unbounded.Unbounded_String; function "+" (the_Text : in Text) return String renames ada.Strings.Unbounded.To_String; function "+" (the_String : in String) return Text renames ada.Strings.Unbounded.To_Unbounded_String; use type Text; package text_Vectors is new ada.Containers.Vectors (Positive, Text); subtype text_Lines is text_Vectors.Vector; procedure put (the_Lines : in text_Lines); -- Ids -- type Id is range 0 .. 1_000_000; null_Id : constant Id; -- Exceptions -- Error : exception; -- Identifiers -- type Identifier is new String; function "+" (Id : in Identifier) return String is (String (Id)); function "+" (the_String : in String) return Identifier is (Identifier (the_String)); function "+" (the_Text : in Text) return Identifier is (Identifier (String' (+the_Text))); -- renames ada.Strings.Unbounded.To_String; -- -- function "+" (Id : in Identifier) return Text -- is ( -- renames ada.Strings.Unbounded.To_Unbounded_String; private for Id'Size use 32; null_Id : constant Id := Id'First; end AdaM;
HeisenbugLtd/si_units
Ada
3,095
ads
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); with Ada.Text_IO; -------------------------------------------------------------------------------- -- Image subprograms for metric (SI) physical values. -- -- Please note that the rather unusual prefixes centi, deci, Deka, and Hecto -- are not supported by these subprograms. You can use the Scaling package to -- convert between differently prefixed value and work from there, though. -------------------------------------------------------------------------------- package SI_Units.Metric is type Prefixes is (yocto, zepto, atto, femto, pico, nano, micro, milli, None, kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta); -- Prefixes supported in instantiated Image subprograms. Magnitude : constant := 1000.0; -- Magnitude change when trying to find the best representation for a given -- value. -- -- Generic image function for different types. -- -- Parameters: -- -- Item - the type you want an Image function instantiated for. -- Default_Aft - the default number of digits after the decimal point -- (regardless of the prefix finally used). -- Unit - The name of your unit, e.g. "Hz", "m" or such (also see -- package SI_Units.Names). -- generic type Item is delta <>; Default_Aft : in Ada.Text_IO.Field; Unit : in Unit_Name; function Fixed_Image (Value : in Item; Aft : in Ada.Text_IO.Field := Default_Aft) return String with Global => null; -- Image subroutine that can be instantiated for fixed types. generic type Item is digits <>; Default_Aft : in Ada.Text_IO.Field; Unit : in Unit_Name; function Float_Image (Value : in Item; Aft : in Ada.Text_IO.Field := Default_Aft) return String with Global => null; -- Image subroutine that can be instantiated for floating point types. generic type Item is range <>; Default_Aft : in Ada.Text_IO.Field; Unit : in Unit_Name; function Integer_Image (Value : in Item; Aft : in Ada.Text_IO.Field := Default_Aft) return String with Global => null; -- Image subroutine that can be instantiated for integer types. generic type Item is mod <>; Default_Aft : in Ada.Text_IO.Field; Unit : in Unit_Name; function Mod_Image (Value : in Item; Aft : in Ada.Text_IO.Field := Default_Aft) return String with Global => null; -- Image subroutine that can be instantiated for modular types. end SI_Units.Metric;
Fabien-Chouteau/GESTE
Ada
15,884
ads
package GESTE_Fonts.FreeSerif6pt7b is Font : constant Bitmap_Font_Ref; private FreeSerif6pt7bBitmaps : aliased constant Font_Bitmap := ( 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#05#, 16#00#, 16#A0#, 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#, 16#00#, 16#02#, 16#80#, 16#50#, 16#3F#, 16#02#, 16#40#, 16#FC#, 16#0A#, 16#01#, 16#40#, 16#28#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#D0#, 16#18#, 16#03#, 16#00#, 16#18#, 16#05#, 16#01#, 16#A0#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#9C#, 16#13#, 16#02#, 16#AC#, 16#6A#, 16#82#, 16#D0#, 16#52#, 16#11#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#02#, 16#40#, 16#48#, 16#06#, 16#E0#, 16#88#, 16#7A#, 16#09#, 16#81#, 16#10#, 16#3D#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#80#, 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#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#80#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#D0#, 16#0C#, 16#03#, 16#C0#, 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#, 16#00#, 16#04#, 16#00#, 16#80#, 16#FC#, 16#02#, 16#00#, 16#40#, 16#08#, 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#, 16#00#, 16#00#, 16#00#, 16#20#, 16#04#, 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#1C#, 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#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#40#, 16#08#, 16#02#, 16#00#, 16#40#, 16#08#, 16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#80#, 16#90#, 16#21#, 16#04#, 16#20#, 16#84#, 16#09#, 16#01#, 16#20#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#03#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#01#, 16#10#, 16#02#, 16#00#, 16#40#, 16#10#, 16#04#, 16#01#, 16#10#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#10#, 16#04#, 16#01#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#20#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#, 16#20#, 16#1C#, 16#02#, 16#80#, 16#90#, 16#1F#, 16#80#, 16#40#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#80#, 16#1C#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#20#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#03#, 16#00#, 16#C0#, 16#1E#, 16#06#, 16#40#, 16#CC#, 16#08#, 16#81#, 16#20#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#81#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#80#, 16#90#, 16#1C#, 16#01#, 16#80#, 16#48#, 16#09#, 16#01#, 16#20#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#04#, 16#81#, 16#10#, 16#33#, 16#02#, 16#40#, 16#78#, 16#01#, 16#00#, 16#60#, 16#18#, 16#04#, 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#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 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#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#01#, 16#C0#, 16#C0#, 16#0C#, 16#00#, 16#60#, 16#02#, 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#07#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#F0#, 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#10#, 16#01#, 16#80#, 16#0C#, 16#00#, 16#C0#, 16#60#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#04#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#03#, 16#18#, 16#CB#, 16#12#, 16#A2#, 16#94#, 16#52#, 16#8D#, 16#E0#, 16#C0#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#30#, 16#07#, 16#01#, 16#20#, 16#26#, 16#07#, 16#C1#, 16#0C#, 16#73#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#CC#, 16#19#, 16#83#, 16#C0#, 16#66#, 16#0C#, 16#41#, 16#98#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#02#, 16#20#, 16#84#, 16#10#, 16#46#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#80#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#8C#, 16#10#, 16#42#, 16#08#, 16#41#, 16#08#, 16#21#, 16#08#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#84#, 16#11#, 16#03#, 16#E0#, 16#44#, 16#08#, 16#01#, 16#08#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#84#, 16#11#, 16#03#, 16#E0#, 16#44#, 16#08#, 16#01#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#82#, 16#30#, 16#80#, 16#10#, 16#06#, 16#3C#, 16#C1#, 16#08#, 16#21#, 16#84#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#70#, 16#84#, 16#10#, 16#83#, 16#F0#, 16#42#, 16#08#, 16#41#, 16#08#, 16#7B#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#C0#, 16#18#, 16#03#, 16#00#, 16#60#, 16#0C#, 16#01#, 16#80#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#70#, 16#C8#, 16#12#, 16#02#, 16#80#, 16#78#, 16#09#, 16#81#, 16#98#, 16#7B#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#08#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#0C#, 16#C3#, 16#1C#, 16#62#, 16#94#, 16#5A#, 16#89#, 16#91#, 16#32#, 16#74#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#38#, 16#E4#, 16#1C#, 16#82#, 16#D0#, 16#4E#, 16#08#, 16#C1#, 16#08#, 16#71#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#06#, 16#20#, 16#82#, 16#30#, 16#46#, 16#08#, 16#C1#, 16#08#, 16#21#, 16#88#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#80#, 16#88#, 16#11#, 16#02#, 16#20#, 16#78#, 16#08#, 16#01#, 16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#06#, 16#20#, 16#82#, 16#30#, 16#46#, 16#08#, 16#41#, 16#08#, 16#20#, 16#88#, 16#0E#, 16#00#, 16#40#, 16#06#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#88#, 16#11#, 16#82#, 16#20#, 16#78#, 16#09#, 16#01#, 16#18#, 16#7B#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#80#, 16#80#, 16#18#, 16#01#, 16#C0#, 16#0C#, 16#10#, 16#81#, 16#30#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E1#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#30#, 16#C4#, 16#10#, 16#82#, 16#10#, 16#42#, 16#0C#, 16#40#, 16#88#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#30#, 16#84#, 16#08#, 16#81#, 16#10#, 16#14#, 16#02#, 16#80#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#E6#, 16#88#, 16#99#, 16#91#, 16#32#, 16#3A#, 16#83#, 16#30#, 16#44#, 16#08#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#70#, 16#44#, 16#0D#, 16#00#, 16#C0#, 16#1C#, 16#04#, 16#81#, 16#08#, 16#73#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#30#, 16#C4#, 16#09#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#20#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#E1#, 16#08#, 16#02#, 16#00#, 16#80#, 16#10#, 16#04#, 16#01#, 16#08#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#01#, 16#00#, 16#10#, 16#02#, 16#00#, 16#40#, 16#04#, 16#00#, 16#80#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#60#, 16#14#, 16#02#, 16#40#, 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#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#80#, 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#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#80#, 16#10#, 16#0E#, 16#02#, 16#40#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#0C#, 16#00#, 16#80#, 16#1E#, 16#02#, 16#60#, 16#44#, 16#08#, 16#81#, 16#20#, 16#38#, 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#0E#, 16#02#, 16#00#, 16#80#, 16#10#, 16#03#, 16#20#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#10#, 16#1E#, 16#02#, 16#40#, 16#88#, 16#11#, 16#03#, 16#20#, 16#3C#, 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#1C#, 16#04#, 16#C0#, 16#F8#, 16#10#, 16#03#, 16#20#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#00#, 16#80#, 16#3C#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 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#1E#, 16#02#, 16#40#, 16#48#, 16#06#, 16#03#, 16#00#, 16#3C#, 16#08#, 16#81#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#1E#, 16#02#, 16#40#, 16#48#, 16#09#, 16#01#, 16#20#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#10#, 16#06#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#08#, 16#03#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#17#, 16#02#, 16#80#, 16#60#, 16#0A#, 16#01#, 16#20#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 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#36#, 16#C3#, 16#68#, 16#49#, 16#09#, 16#21#, 16#24#, 16#7E#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#36#, 16#03#, 16#40#, 16#48#, 16#09#, 16#01#, 16#20#, 16#7E#, 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#1E#, 16#02#, 16#40#, 16#8C#, 16#18#, 16#81#, 16#20#, 16#38#, 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#36#, 16#03#, 16#60#, 16#44#, 16#08#, 16#81#, 16#20#, 16#3C#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#02#, 16#40#, 16#88#, 16#11#, 16#03#, 16#20#, 16#3C#, 16#00#, 16#80#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#14#, 16#03#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 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#1C#, 16#04#, 16#80#, 16#40#, 16#06#, 16#02#, 16#40#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#38#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#30#, 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#36#, 16#02#, 16#40#, 16#48#, 16#09#, 16#01#, 16#20#, 16#3E#, 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#33#, 16#02#, 16#40#, 16#48#, 16#06#, 16#00#, 16#C0#, 16#10#, 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#36#, 16#42#, 16#48#, 16#4A#, 16#0B#, 16#40#, 16#90#, 16#12#, 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#3E#, 16#02#, 16#80#, 16#20#, 16#0A#, 16#01#, 16#20#, 16#6E#, 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#3B#, 16#02#, 16#40#, 16#48#, 16#06#, 16#00#, 16#C0#, 16#08#, 16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#04#, 16#80#, 16#20#, 16#08#, 16#01#, 16#20#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#40#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#01#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 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#60#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#); Font_D : aliased constant Bitmap_Font := ( Bytes_Per_Glyph => 19, Glyph_Width => 11, Glyph_Height => 14, Data => FreeSerif6pt7bBitmaps'Access); Font : constant Bitmap_Font_Ref := Font_D'Access; end GESTE_Fonts.FreeSerif6pt7b;
zrmyers/GLFWAda
Ada
3,545
ads
with Interfaces.C; private package Glfw.Window_Hints is -- Return Codes that can be passed back from GLFW operations type Enum_Window_Hints is ( FOCUSED, RESIZABLE, VISIBLE, DECORATED, AUTO_ICONIFY, FLOATING, MAXIMIZED, CENTER_CURSOR, TRANSPARENT_FRAMEBUFFER, FOCUS_ON_SHOW, RED_BITS, GREEN_BITS, BLUE_BITS, ALPHA_BITS, DEPTH_BITS, STENCIL_BITS, ACCUM_RED_BITS, ACCUM_GREEN_BITS, ACCUM_BLUE_BITS, ACCUM_ALPHA_BITS, AUX_BUFFERS, STEREO, SAMPLES, SRGB_CAPABLE, REFRESH_RATE, DOUBLEBUFFER, CLIENT_API, CONTEXT_VERSION_MAJOR, CONTEXT_VERSION_MINOR, CONTEXT_ROBUSTNESS, OPENGL_FORWARD_COMPAT, OPENGL_DEBUG_CONTEXT, OPENGL_PROFILE, CONTEXT_RELEASE_BEHAVIOR, CONTEXT_NO_ERROR, CONTEXT_CREATION_API, SCALE_TO_MONITOR, COCOA_RETINA_FRAMEBUFFER, COCOA_FRAME_NAME, COCOA_GRAPHICS_SWITCHING, X11_CLASS_NAME, X11_INSTANCE_NAME ); -- Values to use for Return_Codes enumeration. for Enum_Window_Hints use ( FOCUSED => 16#00020001#, RESIZABLE => 16#00020003#, VISIBLE => 16#00020004#, DECORATED => 16#00020005#, AUTO_ICONIFY => 16#00020006#, FLOATING => 16#00020007#, MAXIMIZED => 16#00020008#, CENTER_CURSOR => 16#00020009#, TRANSPARENT_FRAMEBUFFER => 16#0002000a#, FOCUS_ON_SHOW => 16#0002000c#, RED_BITS => 16#00021001#, GREEN_BITS => 16#00021002#, BLUE_BITS => 16#00021003#, ALPHA_BITS => 16#00021004#, DEPTH_BITS => 16#00021005#, STENCIL_BITS => 16#00021006#, ACCUM_RED_BITS => 16#00021007#, ACCUM_GREEN_BITS => 16#00021008#, ACCUM_BLUE_BITS => 16#00021009#, ACCUM_ALPHA_BITS => 16#0002100a#, AUX_BUFFERS => 16#0002100b#, STEREO => 16#0002100c#, SAMPLES => 16#0002100d#, SRGB_CAPABLE => 16#0002100e#, REFRESH_RATE => 16#0002100f#, DOUBLEBUFFER => 16#00021010#, CLIENT_API => 16#00022001#, CONTEXT_VERSION_MAJOR => 16#00022002#, CONTEXT_VERSION_MINOR => 16#00022003#, CONTEXT_ROBUSTNESS => 16#00022005#, OPENGL_FORWARD_COMPAT => 16#00022006#, OPENGL_DEBUG_CONTEXT => 16#00022007#, OPENGL_PROFILE => 16#00022008#, CONTEXT_RELEASE_BEHAVIOR => 16#00022009#, CONTEXT_NO_ERROR => 16#0002200a#, CONTEXT_CREATION_API => 16#0002200b#, SCALE_TO_MONITOR => 16#0002200c#, COCOA_RETINA_FRAMEBUFFER => 16#00023001#, COCOA_FRAME_NAME => 16#00023002#, COCOA_GRAPHICS_SWITCHING => 16#00023003#, X11_CLASS_NAME => 16#00024001#, X11_INSTANCE_NAME => 16#00024002# ); for Enum_Window_Hints'Size use Interfaces.C.int'Size; end Glfw.Window_Hints;
reznikmm/matreshka
Ada
6,356
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ private with Ada.Containers.Vectors; with Ada.Tags; private with League.Regexps; with League.Strings; with XML.SAX.Writers; private with Wiki.Block_Parsers; package Wiki.Parsers is ----------------- -- Wiki_Parser -- ----------------- type Wiki_Parser is tagged limited private; procedure Parse (Self : in out Wiki_Parser'Class; Data : League.Strings.Universal_String; Writer : in out XML.SAX.Writers.SAX_Writer'Class); -- Parses given string. Generated stream contains only events for parsed -- text, and need to be wrapped by <HTML><BODY>/etc tags. Caller is -- responsible to map default prefix (or some other prefix) to XHTML -- namespace URI. procedure Register_Block_Parser (Regexp_String : League.Strings.Universal_String; Total_Groups : Positive; Markup_Group : Natural; Text_Group : Positive; Tag : Ada.Tags.Tag); -- Registers custom block parser. Regexp_String is regular expression to -- detect start of custom block. Text_Group is number of group in regular -- expression which is used to detect position of first significant -- character of text on block's start line. Total_Groups is total number of -- groups used in regular expression. Tag is tag of the custom block parser -- to create its instance. procedure Register_Paragraph_Block_Parser (Regexp_String : League.Strings.Universal_String; Total_Groups : Positive; Text_Group : Positive; Tag : Ada.Tags.Tag); -- Register custom block parser for base paragraph block. Only one parser -- can be registered in this way. private type Block_Expression_Item is record Match_Group : Positive; Markup_Group : Natural; Text_Group : Positive; -- Regular expression's groups to extract: -- - matching of block element's regular expression -- - markup part of block element (it is optional part) -- - text part of block element Is_Start : Boolean; -- Regular expression detects start of new block element of this kind. -- Note, ordinary paragraph has same expression for both start and -- continuation, so it is not set for it till another way to distinguish -- this case will be found. Parser_Tag : Ada.Tags.Tag; end record; package Block_Expression_Vectors is new Ada.Containers.Vectors (Positive, Block_Expression_Item); package Block_Parser_Vectors is new Ada.Containers.Vectors (Positive, Wiki.Block_Parsers.Block_Parser_Access, Wiki.Block_Parsers."="); type Wiki_Parser is tagged limited record Block_Regexp : League.Regexps.Regexp_Pattern; Block_Info : Block_Expression_Vectors.Vector; Separator_Group : Positive; Block_State : Wiki.Block_Parsers.Block_Parser_Access; Block_Stack : Block_Parser_Vectors.Vector; Is_Separated : Boolean; end record; end Wiki.Parsers;
jhumphry/SPARK_SipHash
Ada
5,596
adb
-- Test_SipHash -- a short test program for an Ada implementation of the algorithm described in -- "SipHash: a fast short-input PRF" -- by Jean-Philippe Aumasson and Daniel J. Bernstein -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Containers; with Interfaces, Interfaces.C, Interfaces.C.Strings; use Interfaces; with System.Storage_Elements; use System.Storage_Elements; with SipHash24, SipHash24_String_Hashing, SipHash.General; with SipHash24_c; procedure Test_SipHash is package U64_IO is new Ada.Text_IO.Modular_IO(Interfaces.Unsigned_64); use U64_IO; package ACH_IO is new Ada.Text_IO.Modular_IO(Ada.Containers.Hash_Type); use ACH_IO; -- This matches the test vector setup in the paper. K : constant Storage_Array := (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); M : constant Storage_Array := (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14); Result : Unsigned_64; C_K : aliased SipHash24_c.U8_Array(0..15) := (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); C_M : aliased SipHash24_c.U8_Array(0..14) := (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14); C_Output : aliased SipHash24_c.U8_Array8 := (others => 0); C_Result : Unsigned_64; Discard : C.int; Expected_Result : constant Unsigned_64 := 16#a129ca6149be45e5#; -- Testing use on strings Test_String : constant String := "Lorem ipsum dolor sit amet."; Test_C_String : C.Strings.chars_ptr := C.Strings.New_String(Test_String); -- Testing use on an example record type. type Example_Type is record Flag : Boolean; Counter : Natural; end record; function SipHash24_Example_Type is new SipHash24.General(T => Example_Type, Hash_Type => Unsigned_64); Example_Value : Example_Type := (Flag => True, Counter => 3); begin Put_Line("Testing SipHash routines."); New_Line; Put_Line("Test vector described in Appendix A to the paper " & "'SipHash: a fast short-input PRF'"); Put_Line("by Jean-Philippe Aumasson and Daniel J. Bernstein."); SipHash24.Set_Key(K); Put("Result received from Ada routine for the test vector: "); Put(SipHash24.SipHash(M), Base => 16); New_Line; Discard := SipHash24_c.C_SipHash24( c_in => C_M(0)'Access, inlen => C_M'Length, k => C_K(0)'Access, c_out => C_Output(0)'Access, outlen => 8 ); C_Result := SipHash24_c.U8_Array8_to_U64(C_Output); Put("Result received from reference C routine for the test vector: "); Put(C_Result, Base => 16); New_Line; Put("Result expected for the test vector: "); Put(Expected_Result, Base => 16); New_Line; New_Line; Put_Line("Testing hash of a string value: '" & Test_String & "'"); Put("Result received from Ada routine (truncated for use in Ada.Containers): "); Put(SipHash24_String_Hashing.String_Hash(Test_String), Base => 16); New_Line; Discard := SipHash24_c.C_SipHash24( c_in => SipHash24_c.chars_ptr_to_U8_Access(Test_C_String), inlen => Test_String'Length, k => C_K(0)'Access, c_out => C_Output(0)'Access, outlen => 8 ); C_Result := SipHash24_c.U8_Array8_to_U64(C_Output); Put("Result received from reference C routine: "); Put(C_Result, Base => 16); New_Line; C.Strings.Free(Test_C_String); New_Line; Put_Line("Testing hash of a small record type (Flag => true, Counter => 3)."); Put("Result received from Ada routine: "); Put(SipHash24_Example_Type(Example_Value), Base => 16); New_Line; Put_Line("Incrementing counter and re-hashing."); Example_Value.Counter := Example_Value.Counter + 1; Put("Result received from Ada routine: "); Put(SipHash24_Example_Type(Example_Value), Base => 16); New_Line; New_Line; Put_Line("Testing Ada vs C routine for input lengths from 1 to 2000 bytes."); for I in 1..2000 loop declare M : System.Storage_Elements.Storage_Array(0..Storage_Offset(I-1)); C_M : aliased SipHash24_c.U8_Array(0..I-1); begin for J in 0..I-1 loop M(Storage_Offset(J)) := Storage_Element(J mod 256); C_M(J) := Unsigned_8(J mod 256); end loop; Result := SipHash24.SipHash(M); Discard := SipHash24_c.C_SipHash24( c_in => C_M(0)'Access, inlen => Interfaces.C.size_t(I), k => C_K(0)'Access, c_out => C_Output(0)'Access, outlen => 8 ); C_Result := SipHash24_c.U8_Array8_to_U64(C_Output); if Result /= C_Result then Put("Difference in result for: "); Put(I); New_Line; Put("Ada code gives: "); Put(Result, Base => 16); Put(" C code gives: "); Put(C_Result, Base => 16); New_Line; end if; end; if I mod 200 = 0 then Put("Tested lengths up to: "); Put(I); New_Line; end if; end loop; end Test_SipHash;
AdaCore/gpr
Ada
3,050
adb
-- -- Copyright (C) 2020-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Directories; with Ada.Exceptions; with Ada.Text_IO; with GPR2.Project.View; with GPR2.Project.Tree; with GPR2.Project.Attribute_Index; with GPR2.Project.Attribute.Set; with GPR2.Project.Name_Values; with GPR2.Project.Registry.Attribute; with GPR2.Project.Registry.Pack; with GPR2.Project.Variable.Set; with GPR2.Context; with GNAT.Traceback.Symbolic; procedure Main is use Ada; use GPR2; use GPR2.Project; use GPR2.Project.Registry.Attribute; use all type GPR2.Project.Name_Values.Value_Kind; procedure Display (Prj : Project.View.Object; Full : Boolean := True); ------------- -- Display -- ------------- procedure Display (Prj : Project.View.Object; Full : Boolean := True) is use GPR2.Project.Attribute.Set; use GPR2.Project.Variable.Set.Set; procedure Put_Attributes (Attrs : Attribute.Set.Object); -------------------- -- Put_Attributes -- -------------------- procedure Put_Attributes (Attrs : Attribute.Set.Object) is Attr : Attribute.Object; begin for A in Attrs.Iterate (With_Defaults => True) loop Attr := Attribute.Set.Element (A); Text_IO.Put ("A: " & Image (Attr.Name.Id.Attr)); if Attr.Has_Index then if Attr.Index.Is_Any_Index then Text_IO.Put (" ()"); else Text_IO.Put (" [" & String (Attr.Index.Text) & ']'); end if; end if; Text_IO.Put (" " & (if Attr.Is_Default then '~' else '-') & ">"); for V of Attribute.Set.Element (A).Values loop declare Value : constant Value_Type := V.Text; function No_Last_Slash (Dir : String) return String is (if Dir'Length > 0 and then Dir (Dir'Last) in '\' | '/' then Dir (Dir'First .. Dir'Last - 1) else Dir); begin Text_IO.Put (" " & (if No_Last_Slash (Value) = No_Last_Slash (Directories.Current_Directory) then "{Current_Directory}" else Value)); end; end loop; Text_IO.New_Line; end loop; end Put_Attributes; begin Text_IO.Put (String (Prj.Name) & " "); Text_IO.Set_Col (10); Text_IO.Put_Line (Prj.Qualifier'Img); if Full then Put_Attributes (Prj.Attributes (With_Config => False)); for P of Prj.Packages (With_Defaults => False, With_Config => False) loop Text_IO.Put_Line (Image (P)); Put_Attributes (Prj.Attributes (Pack => P, With_Defaults => False, With_Config => False)); end loop; end if; end Display; Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load_Autoconf (Prj, Create ("demo.gpr"), Ctx); Display (Prj.Root_Project); end Main;
reznikmm/matreshka
Ada
3,953
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_Fill_Attributes; package Matreshka.ODF_Draw.Fill_Attributes is type Draw_Fill_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Fill_Attributes.ODF_Draw_Fill_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Fill_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Fill_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Fill_Attributes;
Fabien-Chouteau/Ada_Drivers_Library
Ada
3,033
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Interrupts; use Ada.Interrupts; with Ada.Interrupts.Names; use Ada.Interrupts.Names; with STM32.Device; use STM32.Device; with Serial_IO.Nonblocking; use Serial_IO; package Peripherals_Nonblocking is Peripheral : aliased Serial_IO.Peripheral_Descriptor := (Transceiver => USART_1'Access, Transceiver_AF => GPIO_AF_USART1_7, Tx_Pin => PB6, Rx_Pin => PB7); Transceiver_Interrupt : constant Interrupt_ID := USART1_Interrupt; COM : Nonblocking.Serial_Port (Transceiver_Interrupt, Peripheral'Access); end Peripherals_Nonblocking;
zenharris/ada-bbs
Ada
566
ads
with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Text_IO; use Ada.Text_IO; package Process_Menu is type String_Access is access String; type Function_Access is access function return Boolean; type Menu_Record is record Prompt : String_Access; Func : access procedure; --Function_Access; end record; type Menu_Type is array (Positive range <>) of Menu_Record; procedure Open_Menu (Function_Number : Column_Position; Menu_Array : Menu_Type; Win : Window := Standard_Window); end Process_Menu;
sparre/aShell
Ada
508
adb
with Shell.Directory_Iteration, Ada.Directories, Ada.Text_IO; procedure Test_Iterate_Directory is use Ada.Text_IO; begin Put_Line ("Start test."); New_Line (2); declare use Shell.Directory_Iteration, Ada .Directories; begin for Each of To_Directory ("/home/rod") loop Put_Line (Full_Name (Each)); -- Display the full name of each file. end loop; end; New_Line (2); Put_Line ("End test."); end Test_Iterate_Directory;
sparre/JSA
Ada
600
adb
separate (JSA.Generic_Optional_Value) protected body Buffer is procedure Clear is begin if Stored.Set then Stored := (Set => False); Changed := True; end if; end Clear; entry Get (Item : out Instance) when Changed is begin Item := Stored; Changed := False; end Get; procedure Set (Item : in Element) is begin if Stored.Set and then Stored.Value = Item then null; else Stored := (Set => True, Value => Item); Changed := True; end if; end Set; end Buffer;
reznikmm/lace
Ada
7,017
ads
-- SPDX-FileCopyrightText: 2021 Max Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Elements; package Lace.Element_Flat_Kinds is pragma Pure; type Element_Flat_Kind is (Pragma_Kind, Defining_Name_Kind, Defining_Identifier_Kind, Defining_Character_Literal_Kind, Defining_Operator_Symbol_Kind, Defining_Expanded_Name_Kind, Declaration_Kind, Type_Declaration_Kind, Task_Type_Declaration_Kind, Protected_Type_Declaration_Kind, Subtype_Declaration_Kind, Object_Declaration_Kind, Single_Task_Declaration_Kind, Single_Protected_Declaration_Kind, Number_Declaration_Kind, Enumeration_Literal_Specification_Kind, Discriminant_Specification_Kind, Component_Declaration_Kind, Loop_Parameter_Specification_Kind, Generalized_Iterator_Specification_Kind, Element_Iterator_Specification_Kind, Procedure_Declaration_Kind, Function_Declaration_Kind, Parameter_Specification_Kind, Procedure_Body_Declaration_Kind, Function_Body_Declaration_Kind, Return_Object_Specification_Kind, Package_Declaration_Kind, Package_Body_Declaration_Kind, Object_Renaming_Declaration_Kind, Exception_Renaming_Declaration_Kind, Procedure_Renaming_Declaration_Kind, Function_Renaming_Declaration_Kind, Package_Renaming_Declaration_Kind, Generic_Package_Renaming_Declaration_Kind, Generic_Procedure_Renaming_Declaration_Kind, Generic_Function_Renaming_Declaration_Kind, Task_Body_Declaration_Kind, Protected_Body_Declaration_Kind, Entry_Declaration_Kind, Entry_Body_Declaration_Kind, Entry_Index_Specification_Kind, Procedure_Body_Stub_Kind, Function_Body_Stub_Kind, Package_Body_Stub_Kind, Task_Body_Stub_Kind, Protected_Body_Stub_Kind, Exception_Declaration_Kind, Choice_Parameter_Specification_Kind, Generic_Package_Declaration_Kind, Generic_Procedure_Declaration_Kind, Generic_Function_Declaration_Kind, Package_Instantiation_Kind, Procedure_Instantiation_Kind, Function_Instantiation_Kind, Formal_Object_Declaration_Kind, Formal_Type_Declaration_Kind, Formal_Procedure_Declaration_Kind, Formal_Function_Declaration_Kind, Formal_Package_Declaration_Kind, Definition_Kind, Type_Definition_Kind, Subtype_Indication_Kind, Constraint_Kind, Component_Definition_Kind, Discrete_Range_Kind, Discrete_Subtype_Indication_Kind, Discrete_Range_Attribute_Reference_Kind, Discrete_Simple_Expression_Range_Kind, Unknown_Discriminant_Part_Kind, Known_Discriminant_Part_Kind, Record_Definition_Kind, Null_Component_Kind, Variant_Part_Kind, Variant_Kind, Others_Choice_Kind, Anonymous_Access_Definition_Kind, Anonymous_Access_To_Object_Kind, Anonymous_Access_To_Procedure_Kind, Anonymous_Access_To_Function_Kind, Private_Type_Definition_Kind, Private_Extension_Definition_Kind, Incomplete_Type_Definition_Kind, Task_Definition_Kind, Protected_Definition_Kind, Formal_Type_Definition_Kind, Aspect_Specification_Kind, Real_Range_Specification_Kind, Expression_Kind, Numeric_Literal_Kind, String_Literal_Kind, Identifier_Kind, Operator_Symbol_Kind, Character_Literal_Kind, Explicit_Dereference_Kind, Infix_Operator_Kind, Function_Call_Kind, Indexed_Component_Kind, Slice_Kind, Selected_Component_Kind, Attribute_Reference_Kind, Record_Aggregate_Kind, Extension_Aggregate_Kind, Array_Aggregate_Kind, Short_Circuit_Operation_Kind, Membership_Test_Kind, Null_Literal_Kind, Parenthesized_Expression_Kind, Raise_Expression_Kind, Type_Conversion_Kind, Qualified_Expression_Kind, Allocator_Kind, Case_Expression_Kind, If_Expression_Kind, Quantified_Expression_Kind, Association_Kind, Discriminant_Association_Kind, Record_Component_Association_Kind, Array_Component_Association_Kind, Parameter_Association_Kind, Formal_Package_Association_Kind, Statement_Kind, Null_Statement_Kind, Assignment_Statement_Kind, If_Statement_Kind, Case_Statement_Kind, Loop_Statement_Kind, While_Loop_Statement_Kind, For_Loop_Statement_Kind, Block_Statement_Kind, Exit_Statement_Kind, Goto_Statement_Kind, Call_Statement_Kind, Simple_Return_Statement_Kind, Extended_Return_Statement_Kind, Accept_Statement_Kind, Requeue_Statement_Kind, Delay_Statement_Kind, Terminate_Alternative_Statement_Kind, Select_Statement_Kind, Abort_Statement_Kind, Raise_Statement_Kind, Code_Statement_Kind, Path_Kind, Elsif_Path_Kind, Case_Path_Kind, Select_Path_Kind, Case_Expression_Path_Kind, Elsif_Expression_Path_Kind, Clause_Kind, Use_Clause_Kind, With_Clause_Kind, Representation_Clause_Kind, Component_Clause_Kind, Derived_Type_Kind, Derived_Record_Extension_Kind, Enumeration_Type_Kind, Signed_Integer_Type_Kind, Modular_Type_Kind, Root_Type_Kind, Floating_Point_Type_Kind, Ordinary_Fixed_Point_Type_Kind, Decimal_Fixed_Point_Type_Kind, Unconstrained_Array_Type_Kind, Constrained_Array_Type_Kind, Record_Type_Kind, Interface_Type_Kind, Object_Access_Type_Kind, Procedure_Access_Type_Kind, Function_Access_Type_Kind, Formal_Private_Type_Definition_Kind, Formal_Derived_Type_Definition_Kind, Formal_Discrete_Type_Definition_Kind, Formal_Signed_Integer_Type_Definition_Kind, Formal_Modular_Type_Definition_Kind, Formal_Floating_Point_Definition_Kind, Formal_Ordinary_Fixed_Point_Definition_Kind, Formal_Decimal_Fixed_Point_Definition_Kind, Formal_Unconstrained_Array_Type_Kind, Formal_Constrained_Array_Type_Kind, Formal_Access_Type_Kind, Formal_Object_Access_Type_Kind, Formal_Procedure_Access_Type_Kind, Formal_Function_Access_Type_Kind, Formal_Interface_Type_Kind, Access_Type_Kind, Range_Attribute_Reference_Kind, Simple_Expression_Range_Kind, Digits_Constraint_Kind, Delta_Constraint_Kind, Index_Constraint_Kind, Discriminant_Constraint_Kind, Attribute_Definition_Clause_Kind, Enumeration_Representation_Clause_Kind, Record_Representation_Clause_Kind, At_Clause_Kind, Exception_Handler_Kind); function Flat_Kind (Element : not null Program.Elements.Element_Access) return Element_Flat_Kind; end Lace.Element_Flat_Kinds;
reznikmm/matreshka
Ada
4,013
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Fo_Keep_With_Next_Attributes; package Matreshka.ODF_Fo.Keep_With_Next_Attributes is type Fo_Keep_With_Next_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Keep_With_Next_Attributes.ODF_Fo_Keep_With_Next_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Keep_With_Next_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Keep_With_Next_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Keep_With_Next_Attributes;
stcarrez/ada-asf
Ada
1,601
ads
----------------------------------------------------------------------- -- asf-contexts-writer-string -- A simple string writer -- Copyright (C) 2009, 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Texts; -- Implements a <b>ResponseWriter</b> that puts the result in a string. -- The response content can be retrieved after the response is rendered. package ASF.Contexts.Writer.String is -- ------------------------------ -- String Writer -- ------------------------------ type String_Writer is new Response_Writer with private; overriding procedure Initialize (Stream : in out String_Writer); -- Get the response function Get_Response (Stream : in String_Writer) return Unbounded_String; private type String_Writer is new Response_Writer with record Content : aliased Util.Streams.Texts.Print_Stream; end record; end ASF.Contexts.Writer.String;
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.Svg_String_Attributes is pragma Preelaborate; type ODF_Svg_String_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Svg_String_Attribute_Access is access all ODF_Svg_String_Attribute'Class with Storage_Size => 0; end ODF.DOM.Svg_String_Attributes;
AdaDoom3/wayland_ada_binding
Ada
17,530
adb
------------------------------------------------------------------------------ -- Copyright (C) 2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Unchecked_Deallocation; with Ada.Containers; use Ada.Containers; package body Conts.Maps.Impl with SPARK_Mode => Off is pragma Assertion_Policy (Pre => Suppressible, Ghost => Suppressible, Post => Ignore); Min_Size : constant Count_Type := 2 ** 3; -- Minimum size for maps. Must be a power of 2. procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Slot_Table, Slot_Table_Access); function Find_Slot (Self : Base_Map'Class; Key : Keys.Element_Type; H : Hash_Type) return Hash_Type; -- Probe the table and look for the place where the element with that -- key would be inserted (or already exists). ----------- -- Model -- ----------- function Model (Self : Base_Map'Class) return M.Map is R : M.Map; C : Cursor; begin -- If Self is empty, so is its model. if Self.Table = null then return R; end if; -- Search for the first non-empty slot in Self. C.Index := Self.Table'First; while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; -- Loop over the content of Self. while C.Index <= Self.Table'Last loop pragma Assert (Self.Table (C.Index).Kind = Full); -- Store the current element in R. declare S : constant Slot := Self.Table (C.Index); K : constant Key_Type := Keys.To_Element (Keys.To_Constant_Returned (S.Key)); V : constant Element_Type := Elements.To_Element (Elements.To_Constant_Returned (S.Value)); begin R := M.Add (R, K, V); end; -- Go to the next non-empty slot. C := (Index => C.Index + 1); while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; end loop; return R; end Model; ------------ -- S_Keys -- ------------ function S_Keys (Self : Base_Map'Class) return K.Sequence is R : K.Sequence; C : Cursor; begin -- If Self is empty, so is its sequence of keys. if Self.Table = null then return R; end if; -- Search for the first non-empty slot in Self. C.Index := Self.Table'First; while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; -- Loop over the content of Self. while C.Index <= Self.Table'Last loop pragma Assert (Self.Table (C.Index).Kind = Full); -- Store the current key in R. declare S : constant Slot := Self.Table (C.Index); L : constant Key_Type := Keys.To_Element (Keys.To_Constant_Returned (S.Key)); begin R := K.Add (R, L); end; -- Go to the next non-empty slot. C := (Index => C.Index + 1); while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; end loop; return R; end S_Keys; --------------- -- Positions -- --------------- function Positions (Self : Base_Map'Class) return P_Map is R : P.Map; C : Cursor; I : Count_Type := 0; begin -- If Self is empty, so is its position map. if Self.Table = null then return (Content => R); end if; -- Search for the first non-empty slot in Self. C.Index := Self.Table'First; while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; -- Loop over the content of Self. while C.Index <= Self.Table'Last loop pragma Assert (Self.Table (C.Index).Kind = Full); -- Store the current cursor in R at position I + 1. I := I + 1; R := P.Add (R, C, I); -- Go to the next non-empty slot. C := (Index => C.Index + 1); while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; end loop; return (Content => R); end Positions; ---------------------------- -- Lift_Abstraction_Level -- ---------------------------- procedure Lift_Abstraction_Level (Self : Base_Map'Class) is null; --------------- -- Find_Slot -- --------------- function Find_Slot (Self : Base_Map'Class; Key : Keys.Element_Type; H : Hash_Type) return Hash_Type is Candidate : Hash_Type := H and Self.Table'Last; First_Dummy : Hash_Type := Hash_Type'Last; S : Slot; Prob : Probing; begin Prob.Initialize_Probing (Hash => H, Size => Self.Table'Last); loop S := Self.Table (Candidate); case S.Kind is when Empty => exit; when Dummy => -- In case of dummy entry we need to follow the search, -- but keep track of the first dummy entry in a sequence -- of dummy entries if First_Dummy = Hash_Type'Last then First_Dummy := Candidate; end if; when Full => exit when S.Hash = H and then "=" (Key, S.Key); end case; Candidate := Prob.Next_Probing (Candidate) and Self.Table'Last; end loop; if First_Dummy /= Hash_Type'Last then return First_Dummy; else return Candidate; end if; end Find_Slot; ------------ -- Assign -- ------------ procedure Assign (Self : in out Base_Map'Class; Source : Base_Map'Class) is begin Self.Used := Source.Used; Self.Fill := Source.Fill; Self.Table := Source.Table; Self.Adjust; end Assign; ------------ -- Adjust -- ------------ procedure Adjust (Self : in out Base_Map) is Tmp : constant Slot_Table_Access := Self.Table; begin if Tmp /= null then if Elements.Copyable and then Keys.Copyable then Self.Table := new Slot_Table'(Tmp.all); else Self.Table := new Slot_Table (Tmp'Range); for E in Self.Table'Range loop if Tmp (E).Kind = Full then Self.Table (E) := (Hash => Tmp (E).Hash, Kind => Full, Key => (if Keys.Copyable then Tmp (E).Key else Keys.Copy (Tmp (E).Key)), Value => (if Elements.Copyable then Tmp (E).Value else Elements.Copy (Tmp (E).Value))); else Self.Table (E) := Tmp (E); end if; end loop; end if; end if; end Adjust; -------------- -- Finalize -- -------------- procedure Finalize (Self : in out Base_Map) is begin Clear (Self); end Finalize; ----------- -- First -- ----------- function First (Self : Base_Map'Class) return Cursor is C : Cursor; begin if Self.Table = null then return No_Element; end if; C.Index := Self.Table'First; loop if C.Index > Self.Table'Last then return No_Element; end if; if Self.Table (C.Index).Kind = Full then return C; end if; C.Index := C.Index + 1; end loop; end First; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : Base_Map'Class; Position : Cursor) return Boolean is begin return Position.Index <= Self.Table'Last; end Has_Element; ---------- -- Next -- ---------- function Next (Self : Base_Map'Class; Position : Cursor) return Cursor is C : Cursor := (Index => Position.Index + 1); begin while C.Index <= Self.Table'Last and then Self.Table (C.Index).Kind /= Full loop C.Index := C.Index + 1; end loop; return C; end Next; --------- -- Key -- --------- function Key (Self : Base_Map'Class; Position : Cursor) return Constant_Returned_Key_Type is P : Slot renames Self.Table (Position.Index); begin return Keys.To_Constant_Returned (P.Key); end Key; ------------- -- Element -- ------------- function Element (Self : Base_Map'Class; Position : Cursor) return Constant_Returned_Type is P : Slot renames Self.Table (Position.Index); begin return Elements.To_Constant_Returned (P.Value); end Element; -------------- -- Capacity -- -------------- function Capacity (Self : Base_Map'Class) return Count_Type is begin if Self.Table = null then return 0; else return Self.Table'Length; end if; end Capacity; ------------ -- Length -- ------------ function Length (Self : Base_Map'Class) return Count_Type is (Self.Used); ------------ -- Resize -- ------------ procedure Resize (Self : in out Base_Map'Class; New_Size : Count_Type) is Size : Hash_Type := Hash_Type (Min_Size); -- We need at least Length elements Min_New_Size : constant Hash_Type := Hash_Type'Max (Hash_Type (New_Size), Hash_Type (Self.Used)); Tmp : Slot_Table_Access; Candidate : Hash_Type; Prob : Probing; begin -- Find smallest valid size greater than New_Size while Size < Min_New_Size loop Size := Size * 2; end loop; Tmp := Self.Table; Self.Table := new Slot_Table (0 .. Size - 1); -- Reinsert all the elements in the new table. We do not need to -- recompute their hashes, which are unchanged an cached. Since we -- know there are no duplicate keys either, we can simplify the -- search for the slot, in particular no need to compare the keys. -- There are also no dummy slots if Tmp /= null then for E in Tmp'Range loop if Tmp (E).Kind = Full then Prob.Initialize_Probing (Hash => Tmp (E).Hash, Size => Self.Table'Last); Candidate := Tmp (E).Hash and Self.Table'Last; loop if Self.Table (Candidate).Kind = Empty then Self.Table (Candidate) := (Hash => Tmp (E).Hash, Kind => Full, Key => Tmp (E).Key, Value => Tmp (E).Value); exit; end if; Candidate := Prob.Next_Probing (Candidate) and Self.Table'Last; end loop; end if; end loop; Unchecked_Free (Tmp); end if; end Resize; --------- -- Set -- --------- procedure Set (Self : in out Base_Map'Class; Key : Keys.Element_Type; Value : Elements.Element_Type) is H : constant Hash_Type := Hash (Key); Used : constant Count_Type := Self.Used; New_Size : Count_Type; begin -- Need at least one empty slot pragma Assert (Self.Fill <= Self.Capacity); -- If the table was never allocated, do it now if Self.Table = null then Resize (Self, Min_Size); end if; -- Do the actual insert. Find_Slot expects to find an empy slot -- eventually, and the less full the table the more chance of -- finding this slot early on. But we can't systematically resize -- now, because replacing an element, for instance, doesn't need -- any resizing (so we would be wasting time or worse grow the table -- for nothing), nor does reusing a Dummy slot. -- So we really can only resize after the call to Find_Slot, which -- means we might be resizing even though the user won't be adding a -- new element ever after. declare Index : constant Hash_Type := Find_Slot (Self, Key, H); S : Slot renames Self.Table (Index); begin case S.Kind is when Empty => S := (Hash => H, Kind => Full, Key => Keys.To_Stored (Key), Value => Elements.To_Stored (Value)); Self.Used := Self.Used + 1; Self.Fill := Self.Fill + 1; when Dummy => S := (Hash => H, Kind => Full, Key => Keys.To_Stored (Key), Value => Elements.To_Stored (Value)); Self.Used := Self.Used + 1; when Full => Elements.Release (S.Value); S.Value := Elements.To_Stored (Value); end case; end; -- If the table is now too full, we need to resize it for the next -- time we want to insert an element. if Self.Used > Used then New_Size := Resize_Strategy (Used => Self.Used, Fill => Self.Fill, Capacity => Self.Capacity); if New_Size /= 0 then Resize (Self, New_Size); end if; end if; end Set; --------- -- Get -- --------- function Get (Self : Base_Map'Class; Key : Keys.Element_Type) return Elements.Constant_Returned_Type is begin if Self.Table /= null then declare H : constant Hash_Type := Hash (Key); Index : constant Hash_Type := Find_Slot (Self, Key, H); begin if Self.Table (Index).Kind = Full then return Elements.To_Constant_Returned (Self.Table (Index).Value); end if; end; end if; raise Constraint_Error with "Key not in map"; end Get; -------------- -- Contains -- -------------- function Contains (Self : Base_Map'Class; Key : Key_Type) return Boolean is begin if Self.Table /= null then declare H : constant Hash_Type := Hash (Key); Index : constant Hash_Type := Find_Slot (Self, Key, H); begin if Self.Table (Index).Kind = Full then return True; end if; end; end if; return False; end Contains; ------------ -- Delete -- ------------ procedure Delete (Self : in out Base_Map'Class; Key : Keys.Element_Type) is begin if Self.Table /= null then declare H : constant Hash_Type := Hash (Key); Index : constant Hash_Type := Find_Slot (Self, Key, H); S : Slot renames Self.Table (Index); begin if S.Kind = Full then Keys.Release (S.Key); Elements.Release (S.Value); S.Kind := Dummy; Self.Used := Self.Used - 1; -- unchanged: Self.Fill end if; end; end if; end Delete; ----------- -- Clear -- ----------- procedure Clear (Self : in out Base_Map'Class) is begin if Self.Table /= null then for S of Self.Table.all loop if S.Kind = Full then Keys.Release (S.Key); Elements.Release (S.Value); end if; end loop; Unchecked_Free (Self.Table); Self.Used := 0; Self.Fill := 0; end if; end Clear; end Conts.Maps.Impl;
reznikmm/matreshka
Ada
4,697
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_Number.Decimal_Replacement_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Number_Decimal_Replacement_Attribute_Node is begin return Self : Number_Decimal_Replacement_Attribute_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Number_Decimal_Replacement_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Decimal_Replacement_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Number_URI, Matreshka.ODF_String_Constants.Decimal_Replacement_Attribute, Number_Decimal_Replacement_Attribute_Node'Tag); end Matreshka.ODF_Number.Decimal_Replacement_Attributes;
apple-oss-distributions/old_ncurses
Ada
3,104
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 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: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.m; use ncurses2.m; with GNAT.OS_Lib; use GNAT.OS_Lib; procedure ncurses is begin OS_Exit (main); end ncurses;
tum-ei-rcs/StratoX
Ada
1,552
adb
-- Institution: Technische Universität München -- Department: Realtime Computer Systems (RCS) -- Project: StratoX -- -- Authors: Emanuel Regnath ([email protected]) with STM32.Device; -- @summary -- Target-specific mapping for HIL of Clock package body HIL.Clock with SPARK_Mode => Off is procedure configure is begin -- GPIOs STM32.Device.Enable_Clock(STM32.Device.GPIO_A ); STM32.Device.Enable_Clock(STM32.Device.GPIO_B); STM32.Device.Enable_Clock(STM32.Device.GPIO_C); STM32.Device.Enable_Clock(STM32.Device.GPIO_D); STM32.Device.Enable_Clock(STM32.Device.GPIO_E); -- SPI STM32.Device.Enable_Clock(STM32.Device.SPI_2); -- I2C --STM32.Device.Enable_Clock( STM32.Device.I2C_1 ); -- I2C -- USARTs STM32.Device.Enable_Clock( STM32.Device.USART_1 ); STM32.Device.Enable_Clock( STM32.Device.USART_2 ); STM32.Device.Enable_Clock( STM32.Device.USART_3 ); STM32.Device.Enable_Clock( STM32.Device.UART_4 ); STM32.Device.Enable_Clock( STM32.Device.USART_7 ); -- Timers STM32.Device.Enable_Clock (STM32.Device.Timer_2); STM32.Device.Reset (STM32.Device.Timer_2); end configure; -- get number of systicks since POR function getSysTick return Natural is begin null; return 0; end getSysTick; -- get system time since POR function getSysTime return Ada.Real_Time.Time is begin return Ada.Real_Time.Clock; end getSysTime; end HIL.Clock;
reznikmm/matreshka
Ada
8,780
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Elements; with AMF.Internals.UML_Multiplicity_Elements; with AMF.UML.Connectable_Elements; with AMF.UML.Connector_Ends; with AMF.UML.Multiplicity_Elements; with AMF.UML.Properties; with AMF.Visitors; package AMF.Internals.UML_Connector_Ends is package UML_Multiplicity_Elements is new AMF.Internals.UML_Multiplicity_Elements (AMF.Internals.UML_Elements.UML_Element_Proxy); type UML_Connector_End_Proxy is limited new UML_Multiplicity_Elements.UML_Multiplicity_Element_Proxy and AMF.UML.Connector_Ends.UML_Connector_End with null record; overriding function Get_Defining_End (Self : not null access constant UML_Connector_End_Proxy) return AMF.UML.Properties.UML_Property_Access; -- Getter of ConnectorEnd::definingEnd. -- -- A derived association referencing the corresponding association end on -- the association which types the connector owing this connector end. -- This association is derived by selecting the association end at the -- same place in the ordering of association ends as this connector end. overriding function Get_Part_With_Port (Self : not null access constant UML_Connector_End_Proxy) return AMF.UML.Properties.UML_Property_Access; -- Getter of ConnectorEnd::partWithPort. -- -- Indicates the role of the internal structure of a classifier with the -- port to which the connector end is attached. overriding procedure Set_Part_With_Port (Self : not null access UML_Connector_End_Proxy; To : AMF.UML.Properties.UML_Property_Access); -- Setter of ConnectorEnd::partWithPort. -- -- Indicates the role of the internal structure of a classifier with the -- port to which the connector end is attached. overriding function Get_Role (Self : not null access constant UML_Connector_End_Proxy) return AMF.UML.Connectable_Elements.UML_Connectable_Element_Access; -- Getter of ConnectorEnd::role. -- -- The connectable element attached at this connector end. When an -- instance of the containing classifier is created, a link may (depending -- on the multiplicities) be created to an instance of the classifier that -- types this connectable element. overriding procedure Set_Role (Self : not null access UML_Connector_End_Proxy; To : AMF.UML.Connectable_Elements.UML_Connectable_Element_Access); -- Setter of ConnectorEnd::role. -- -- The connectable element attached at this connector end. When an -- instance of the containing classifier is created, a link may (depending -- on the multiplicities) be created to an instance of the classifier that -- types this connectable element. overriding function Defining_End (Self : not null access constant UML_Connector_End_Proxy) return AMF.UML.Properties.UML_Property_Access; -- Operation ConnectorEnd::definingEnd. -- -- Missing derivation for ConnectorEnd::/definingEnd : Property overriding function Compatible_With (Self : not null access constant UML_Connector_End_Proxy; Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::compatibleWith. -- -- The operation compatibleWith takes another multiplicity as input. It -- checks if one multiplicity is compatible with another. overriding function Includes_Cardinality (Self : not null access constant UML_Connector_End_Proxy; C : Integer) return Boolean; -- Operation MultiplicityElement::includesCardinality. -- -- The query includesCardinality() checks whether the specified -- cardinality is valid for this multiplicity. overriding function Includes_Multiplicity (Self : not null access constant UML_Connector_End_Proxy; M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) return Boolean; -- Operation MultiplicityElement::includesMultiplicity. -- -- The query includesMultiplicity() checks whether this multiplicity -- includes all the cardinalities allowed by the specified multiplicity. overriding function Iss (Self : not null access constant UML_Connector_End_Proxy; Lowerbound : Integer; Upperbound : Integer) return Boolean; -- Operation MultiplicityElement::is. -- -- The operation is determines if the upper and lower bound of the ranges -- are the ones given. overriding procedure Enter_Element (Self : not null access constant UML_Connector_End_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Connector_End_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Connector_End_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Connector_Ends;
RREE/ada-util
Ada
8,691
ads
----------------------------------------------------------------------- -- util-systems-os -- Unix system operations -- Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017, 2018, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with System; with Interfaces.C; with Interfaces.C.Strings; with Util.Processes; with Util.Systems.Constants; with Util.Systems.Types; -- The <b>Util.Systems.Os</b> package defines various types and operations which are specific -- to the OS (Unix). package Util.Systems.Os is -- The directory separator. Directory_Separator : constant Character := '/'; -- The path separator. Path_Separator : constant Character := ':'; -- The line ending separator. Line_Separator : constant String := "" & ASCII.LF; use Util.Systems.Constants; subtype Ptr is Interfaces.C.Strings.chars_ptr; subtype Ptr_Array is Interfaces.C.Strings.chars_ptr_array; type Ptr_Ptr_Array is access all Ptr_Array; subtype File_Type is Util.Systems.Types.File_Type; -- Standard file streams Posix, X/Open standard values. STDIN_FILENO : constant File_Type := 0; STDOUT_FILENO : constant File_Type := 1; STDERR_FILENO : constant File_Type := 2; -- File is not opened use type Util.Systems.Types.File_Type; -- This use clause is required by GNAT 2018 for the -1! NO_FILE : constant File_Type := -1; -- The following values should be externalized. They are valid for GNU/Linux. F_SETFL : constant Interfaces.C.int := Util.Systems.Constants.F_SETFL; FD_CLOEXEC : constant Interfaces.C.int := Util.Systems.Constants.FD_CLOEXEC; -- These values are specific to Linux. O_RDONLY : constant Interfaces.C.int := Util.Systems.Constants.O_RDONLY; O_WRONLY : constant Interfaces.C.int := Util.Systems.Constants.O_WRONLY; O_RDWR : constant Interfaces.C.int := Util.Systems.Constants.O_RDWR; O_CREAT : constant Interfaces.C.int := Util.Systems.Constants.O_CREAT; O_EXCL : constant Interfaces.C.int := Util.Systems.Constants.O_EXCL; O_TRUNC : constant Interfaces.C.int := Util.Systems.Constants.O_TRUNC; O_APPEND : constant Interfaces.C.int := Util.Systems.Constants.O_APPEND; type Size_T is mod 2 ** Standard'Address_Size; type Ssize_T is range -(2 ** (Standard'Address_Size - 1)) .. +(2 ** (Standard'Address_Size - 1)) - 1; function Close (Fd : in File_Type) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "close"; function Read (Fd : in File_Type; Buf : in System.Address; Size : in Size_T) return Ssize_T with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "read"; function Write (Fd : in File_Type; Buf : in System.Address; Size : in Size_T) return Ssize_T with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "write"; -- System exit without any process cleaning. -- (destructors, finalizers, atexit are not called) procedure Sys_Exit (Code : in Integer) with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "exit"; -- Fork a new process function Sys_Fork return Util.Processes.Process_Identifier with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fork"; -- Fork a new process (vfork implementation) function Sys_VFork return Util.Processes.Process_Identifier with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fork"; -- Execute a process with the given arguments. function Sys_Execvp (File : in Ptr; Args : in Ptr_Array) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "execvp"; -- Execute a process with the given arguments. function Sys_Execve (File : in Ptr; Args : in Ptr_Array; Envp : in Ptr_Array) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "execve"; -- Wait for the process <b>Pid</b> to finish and return function Sys_Waitpid (Pid : in Integer; Status : in System.Address; Options : in Integer) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "waitpid"; -- Create a bi-directional pipe function Sys_Pipe (Fds : in System.Address) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "pipe"; -- Make <b>fd2</b> the copy of <b>fd1</b> function Sys_Dup2 (Fd1, Fd2 : in File_Type) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "dup2"; -- Close a file function Sys_Close (Fd : in File_Type) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "close"; -- Open a file function Sys_Open (Path : in Ptr; Flags : in Interfaces.C.int; Mode : in Util.Systems.Types.mode_t) return File_Type with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "open"; -- Change the file settings function Sys_Fcntl (Fd : in File_Type; Cmd : in Interfaces.C.int; Flags : in Interfaces.C.int) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fcntl"; function Sys_Kill (Pid : in Integer; Signal : in Integer) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "kill"; function Sys_Stat (Path : in Ptr; Stat : access Util.Systems.Types.Stat_Type) return Integer with Import => True, Convention => C, Link_Name => Util.Systems.Types.STAT_NAME; function Sys_Fstat (Fs : in File_Type; Stat : access Util.Systems.Types.Stat_Type) return Integer with Import => True, Convention => C, Link_Name => Util.Systems.Types.FSTAT_NAME; function Sys_Lseek (Fs : in File_Type; Offset : in Util.Systems.Types.off_t; Mode : in Util.Systems.Types.Seek_Mode) return Util.Systems.Types.off_t with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "lseek"; function Sys_Ftruncate (Fs : in File_Type; Length : in Util.Systems.Types.off_t) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "ftruncate"; function Sys_Truncate (Path : in Ptr; Length : in Util.Systems.Types.off_t) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "truncate"; function Sys_Fchmod (Fd : in File_Type; Mode : in Util.Systems.Types.mode_t) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "fchmod"; -- Change permission of a file. function Sys_Chmod (Path : in Ptr; Mode : in Util.Systems.Types.mode_t) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "chmod"; -- Change working directory. function Sys_Chdir (Path : in Ptr) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "chdir"; -- Rename a file (the Ada.Directories.Rename does not allow to use -- the Unix atomic file rename!) function Sys_Rename (Oldpath : in Ptr; Newpath : in Ptr) return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "rename"; -- Libc errno. The __get_errno function is provided by the GNAT runtime. function Errno return Integer with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "__get_errno"; function Strerror (Errno : in Integer) return Interfaces.C.Strings.chars_ptr with Import => True, Convention => C, Link_Name => SYMBOL_PREFIX & "strerror"; end Util.Systems.Os;
reznikmm/matreshka
Ada
3,784
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Label_Position_Negative_Attributes is pragma Preelaborate; type ODF_Chart_Label_Position_Negative_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Label_Position_Negative_Attribute_Access is access all ODF_Chart_Label_Position_Negative_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Label_Position_Negative_Attributes;
mirror/ncurses
Ada
4,127
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 2000-2006,2009 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.4 $ -- $Date: 2020/02/02 23:34:34 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Bounded; use Ada.Strings.Bounded; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Terminal_Interface.Curses; generic Max : Natural; -- type mystring is private; -- type myint is package ncurses2.genericPuts is package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (Max); use BS; procedure myGet (Win : Terminal_Interface.Curses.Window := Terminal_Interface.Curses.Standard_Window; Str : out BS.Bounded_String; Len : Integer := -1); procedure myPut (Str : out BS.Bounded_String; i : Integer; Base : Number_Base := 10); -- the default should be Ada.Text_IO.Integer_IO.Default_Base -- but Default_Base is hidden in the generic so doesn't exist! procedure myAdd (Str : BS.Bounded_String); procedure Fill_String (Cp : chars_ptr; Str : out BS.Bounded_String); end ncurses2.genericPuts;
onox/sdlada
Ada
4,906
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- private with SDL.C_Pointers; package body SDL.Inputs.Keyboards is package C renames Interfaces.C; function Get_Focus return SDL.Video.Windows.ID is function SDL_Get_Window_ID (W : in SDL.C_Pointers.Windows_Pointer) return SDL.Video.Windows.ID with Import => True, Convention => C, External_Name => "SDL_GetWindowID"; function SDL_Get_Keyboard_Focus return SDL.C_Pointers.Windows_Pointer with Import => True, Convention => C, External_Name => "SDL_GetKeyboardFocus"; begin return SDL_Get_Window_ID (SDL_Get_Keyboard_Focus); end Get_Focus; function Get_Modifiers return SDL.Events.Keyboards.Key_Modifiers is function SDL_Get_Mod_State return SDL.Events.Keyboards.Key_Modifiers with Import => True, Convention => C, External_Name => "SDL_GetModState"; begin return SDL_Get_Mod_State; end Get_Modifiers; procedure Set_Modifiers (Modifiers : in SDL.Events.Keyboards.Key_Modifiers) is procedure SDL_Set_Mod_State (Modifiers : in SDL.Events.Keyboards.Key_Modifiers) with Import => True, Convention => C, External_Name => "SDL_SetModState"; begin SDL_Set_Mod_State (Modifiers); end Set_Modifiers; function Supports_Screen_Keyboard return Boolean is function SDL_Has_Screen_Keyboard_Support return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_HasScreenKeyboardSupport"; Result : SDL_Bool := SDL_Has_Screen_Keyboard_Support; begin if Result = SDL_True then return True; end if; return False; end Supports_Screen_Keyboard; function Is_Screen_Keyboard_Visible (Window : in SDL.Video.Windows.Window) return Boolean is function Get_Internal_Window (Self : in SDL.Video.Windows.Window) return SDL.C_Pointers.Windows_Pointer with Convention => Ada, Import => True; function SDL_Screen_Keyboard_Shown (Window : in SDL.C_Pointers.Windows_Pointer) return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_IsScreenKeyboardShown"; Result : SDL_Bool := SDL_Screen_Keyboard_Shown (Get_Internal_Window (Window)); begin if Result = SDL_True then return True; end if; return False; end Is_Screen_Keyboard_Visible; function Is_Text_Input_Enabled return Boolean is function SDL_Is_Text_Input_Active return SDL_Bool with Import => True, Convention => C, External_Name => "SDL_IsTextInputActive"; Result : SDL_Bool := SDL_Is_Text_Input_Active; begin if Result = SDL_True then return True; end if; return False; end Is_Text_Input_Enabled; procedure Set_Text_Input_Rectangle (Rectangle : in SDL.Video.Rectangles.Rectangle) is procedure SDL_Set_Text_Input_Rect (Rectangle : in SDL.Video.Rectangles.Rectangle) with Import => True, Convention => C, External_Name => "SDL_SetTextInputRect"; begin SDL_Set_Text_Input_Rect (Rectangle); end Set_Text_Input_Rectangle; procedure Start_Text_Input is procedure SDL_Start_Text_Input with Import => True, Convention => C, External_Name => "SDL_StartTextInput"; begin SDL_Start_Text_Input; end Start_Text_Input; procedure Stop_Text_Input is procedure SDL_Stop_Text_Input with Import => True, Convention => C, External_Name => "SDL_StopTextInput"; begin SDL_Stop_Text_Input; end Stop_Text_Input; end SDL.Inputs.Keyboards;
stcarrez/atlas
Ada
31,631
adb
----------------------------------------------------------------------- -- Atlas.Reviews.Models -- Atlas.Reviews.Models ----------------------------------------------------------------------- -- File generated by Dynamo DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0 ----------------------------------------------------------------------- -- Copyright (C) 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- pragma Warnings (Off); with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Time; with ASF.Events.Faces.Actions; pragma Warnings (On); package body Atlas.Reviews.Models is pragma Style_Checks ("-mrIu"); pragma Warnings (Off, "formal parameter * is not referenced"); pragma Warnings (Off, "use clause for type *"); pragma Warnings (Off, "use clause for private type *"); use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; function Review_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => REVIEW_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Review_Key; function Review_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => REVIEW_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Review_Key; function "=" (Left, Right : Review_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Review_Ref'Class; Impl : out Review_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Review_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Review_Ref) is Impl : Review_Access; begin Impl := new Review_Impl; Impl.Version := 0; Impl.Create_Date := ADO.DEFAULT_TIME; Impl.Allow_Comments := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Review -- ---------------------------------------- procedure Set_Id (Object : in out Review_Ref; Value : in ADO.Identifier) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Review_Ref) return ADO.Identifier is Impl : constant Review_Access := Review_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; function Get_Version (Object : in Review_Ref) return Integer is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Title (Object : in out Review_Ref; Value : in String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Title, Value); end Set_Title; procedure Set_Title (Object : in out Review_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Title, Value); end Set_Title; function Get_Title (Object : in Review_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Title); end Get_Title; function Get_Title (Object : in Review_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Title; end Get_Title; procedure Set_Text (Object : in out Review_Ref; Value : in String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Text, Value); end Set_Text; procedure Set_Text (Object : in out Review_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Text, Value); end Set_Text; function Get_Text (Object : in Review_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Text); end Get_Text; function Get_Text (Object : in Review_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Text; end Get_Text; procedure Set_Create_Date (Object : in out Review_Ref; Value : in Ada.Calendar.Time) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 5, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Review_Ref) return Ada.Calendar.Time is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Allow_Comments (Object : in out Review_Ref; Value : in Integer) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Allow_Comments, Value); end Set_Allow_Comments; function Get_Allow_Comments (Object : in Review_Ref) return Integer is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Allow_Comments; end Get_Allow_Comments; procedure Set_Site (Object : in out Review_Ref; Value : in String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 7, Impl.Site, Value); end Set_Site; procedure Set_Site (Object : in out Review_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 7, Impl.Site, Value); end Set_Site; function Get_Site (Object : in Review_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Site); end Get_Site; function Get_Site (Object : in Review_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Site; end Get_Site; procedure Set_Reviewer (Object : in out Review_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : Review_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 8, Impl.Reviewer, Value); end Set_Reviewer; function Get_Reviewer (Object : in Review_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Reviewer; end Get_Reviewer; -- Copy of the object. procedure Copy (Object : in Review_Ref; Into : in out Review_Ref) is Result : Review_Ref; begin if not Object.Is_Null then declare Impl : constant Review_Access := Review_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Review_Access := new Review_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Version := Impl.Version; Copy.Title := Impl.Title; Copy.Text := Impl.Text; Copy.Create_Date := Impl.Create_Date; Copy.Allow_Comments := Impl.Allow_Comments; Copy.Site := Impl.Site; Copy.Reviewer := Impl.Reviewer; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out Review_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Review_Access := new Review_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Review_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Review_Access := new Review_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Review_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Review_Access := new Review_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Reload (Object : in out Review_Ref; Session : in out ADO.Sessions.Session'Class; Updated : out Boolean) is Result : ADO.Objects.Object_Record_Access; Impl : Review_Access; Query : ADO.SQL.Query; Id : ADO.Identifier; begin if Object.Is_Null then raise ADO.Objects.NULL_ERROR; end if; Object.Prepare_Modify (Result); Impl := Review_Impl (Result.all)'Access; Id := ADO.Objects.Get_Key_Value (Impl.all); Query.Bind_Param (Position => 1, Value => Id); Query.Bind_Param (Position => 2, Value => Impl.Version); Query.Set_Filter ("id = ? AND version != ?"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, REVIEW_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Updated := True; Impl.Load (Stmt, Session); else Updated := False; end if; end; end Reload; overriding procedure Save (Object : in out Review_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Review_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out Review_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access Review_Impl) is type Review_Impl_Ptr is access all Review_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Review_Impl, Review_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Review_Impl_Ptr := Review_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out Review_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, REVIEW_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Review_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out Review_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (REVIEW_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- title Value => Object.Title); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- text Value => Object.Text); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_1_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_1_NAME, -- allow_comments Value => Object.Allow_Comments); Object.Clear_Modified (6); end if; if Object.Is_Modified (7) then Stmt.Save_Field (Name => COL_6_1_NAME, -- site Value => Object.Site); Object.Clear_Modified (7); end if; if Object.Is_Modified (8) then Stmt.Save_Field (Name => COL_7_1_NAME, -- reviewer_id Value => Object.Reviewer); Object.Clear_Modified (8); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out Review_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (REVIEW_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_2_1_NAME, -- title Value => Object.Title); Query.Save_Field (Name => COL_3_1_NAME, -- text Value => Object.Text); Query.Save_Field (Name => COL_4_1_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_5_1_NAME, -- allow_comments Value => Object.Allow_Comments); Query.Save_Field (Name => COL_6_1_NAME, -- site Value => Object.Site); Query.Save_Field (Name => COL_7_1_NAME, -- reviewer_id Value => Object.Reviewer); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out Review_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (REVIEW_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Review_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Review_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Review_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "title" then return Util.Beans.Objects.To_Object (Impl.Title); elsif Name = "text" then return Util.Beans.Objects.To_Object (Impl.Text); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); elsif Name = "allow_comments" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Allow_Comments)); elsif Name = "site" then return Util.Beans.Objects.To_Object (Impl.Site); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Review_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, REVIEW_DEF'Access); begin Stmt.Execute; Review_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Review_Ref; Impl : constant Review_Access := new Review_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Review_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Title := Stmt.Get_Unbounded_String (2); Object.Text := Stmt.Get_Unbounded_String (3); Object.Create_Date := Stmt.Get_Time (4); Object.Allow_Comments := Stmt.Get_Integer (5); Object.Site := Stmt.Get_Unbounded_String (6); if not Stmt.Is_Null (7) then Object.Reviewer.Set_Key_Value (Stmt.Get_Identifier (7), Session); end if; Object.Version := Stmt.Get_Integer (1); ADO.Objects.Set_Created (Object); end Load; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in List_Info; Name : in String) return Util.Beans.Objects.Object is begin if Name = "id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id)); elsif Name = "title" then return Util.Beans.Objects.To_Object (From.Title); elsif Name = "site" then return Util.Beans.Objects.To_Object (From.Site); elsif Name = "date" then return Util.Beans.Objects.Time.To_Object (From.Date); elsif Name = "allow_comments" then return Util.Beans.Objects.To_Object (From.Allow_Comments); elsif Name = "reviewer_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Reviewer_Id)); elsif Name = "reviewer_name" then return Util.Beans.Objects.To_Object (From.Reviewer_Name); elsif Name = "reviewer_email" then return Util.Beans.Objects.To_Object (From.Reviewer_Email); elsif Name = "text" then return Util.Beans.Objects.To_Object (From.Text); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out List_Info; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "id" then Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "title" then Item.Title := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "site" then Item.Site := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "date" then Item.Date := Util.Beans.Objects.Time.To_Time (Value); elsif Name = "allow_comments" then Item.Allow_Comments := Util.Beans.Objects.To_Boolean (Value); elsif Name = "reviewer_id" then Item.Reviewer_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value)); elsif Name = "reviewer_name" then Item.Reviewer_Name := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "reviewer_email" then Item.Reviewer_Email := Util.Beans.Objects.To_Unbounded_String (Value); elsif Name = "text" then Item.Text := Util.Beans.Objects.To_Unbounded_String (Value); end if; end Set_Value; -- -------------------- -- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>. -- -------------------- procedure List (Object : in out List_Info_List_Bean'Class; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is begin List (Object.List, Session, Context); end List; -- -------------------- -- The list of reviews. -- -------------------- procedure List (Object : in out List_Info_Vector; Session : in out ADO.Sessions.Session'Class; Context : in out ADO.Queries.Context'Class) is procedure Read (Into : in out List_Info); Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context); Pos : Positive := 1; procedure Read (Into : in out List_Info) is begin Into.Id := Stmt.Get_Identifier (0); Into.Title := Stmt.Get_Unbounded_String (1); Into.Site := Stmt.Get_Unbounded_String (2); Into.Date := Stmt.Get_Time (3); Into.Allow_Comments := Stmt.Get_Boolean (4); Into.Reviewer_Id := Stmt.Get_Identifier (5); Into.Reviewer_Name := Stmt.Get_Unbounded_String (6); Into.Reviewer_Email := Stmt.Get_Unbounded_String (7); Into.Text := Stmt.Get_Unbounded_String (8); end Read; begin Stmt.Execute; List_Info_Vectors.Clear (Object); while Stmt.Has_Elements loop Object.Insert_Space (Before => Pos); Object.Update_Element (Index => Pos, Process => Read'Access); Pos := Pos + 1; Stmt.Next; end loop; end List; procedure Op_Save (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Save (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Review_Bean'Class (Bean).Save (Outcome); end Op_Save; package Binding_Review_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Review_Bean, Method => Op_Save, Name => "save"); procedure Op_Delete (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Delete (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Review_Bean'Class (Bean).Delete (Outcome); end Op_Delete; package Binding_Review_Bean_2 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Review_Bean, Method => Op_Delete, Name => "delete"); procedure Op_Load (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Review_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Review_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Review_Bean_3 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Review_Bean, Method => Op_Load, Name => "load"); Binding_Review_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Review_Bean_1.Proxy'Access, 2 => Binding_Review_Bean_2.Proxy'Access, 3 => Binding_Review_Bean_3.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Review_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Review_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Review_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "title" then Item.Set_Title (Util.Beans.Objects.To_String (Value)); elsif Name = "text" then Item.Set_Text (Util.Beans.Objects.To_String (Value)); elsif Name = "create_date" then Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value)); elsif Name = "allow_comments" then Item.Set_Allow_Comments (Util.Beans.Objects.To_Integer (Value)); elsif Name = "site" then Item.Set_Site (Util.Beans.Objects.To_String (Value)); end if; end Set_Value; procedure Op_Load (Bean : in out Review_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); procedure Op_Load (Bean : in out Review_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is begin Review_List_Bean'Class (Bean).Load (Outcome); end Op_Load; package Binding_Review_List_Bean_1 is new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Review_List_Bean, Method => Op_Load, Name => "load"); Binding_Review_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (1 => Binding_Review_List_Bean_1.Proxy'Access ); -- ------------------------------ -- This bean provides some methods that can be used in a Method_Expression. -- ------------------------------ overriding function Get_Method_Bindings (From : in Review_List_Bean) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Review_List_Bean_Array'Access; end Get_Method_Bindings; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Review_List_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "page" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page)); elsif Name = "count" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count)); elsif Name = "page_size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Set the value identified by the name -- ------------------------------ overriding procedure Set_Value (Item : in out Review_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = "page" then Item.Page := Util.Beans.Objects.To_Integer (Value); elsif Name = "count" then Item.Count := Util.Beans.Objects.To_Integer (Value); elsif Name = "page_size" then Item.Page_Size := Util.Beans.Objects.To_Integer (Value); end if; end Set_Value; end Atlas.Reviews.Models;
zhmu/ananas
Ada
14,598
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . O S _ I N T E R F A C E -- -- -- -- S p e c -- -- -- -- Copyright (C) 1991-2017, Florida State University -- -- Copyright (C) 1995-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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is a NT (native) version of this package -- This package encapsulates all direct interfaces to OS services -- that are needed by the tasking run-time (libgnarl). For non tasking -- oriented services consider declaring them into system-win32. -- PLEASE DO NOT add any with-clauses to this package or remove the pragma -- Preelaborate. This package is designed to be a bottom-level (leaf) package. with Ada.Unchecked_Conversion; with Interfaces.C; with Interfaces.C.Strings; with System.Win32; package System.OS_Interface is pragma Preelaborate; pragma Linker_Options ("-mthreads"); subtype int is Interfaces.C.int; subtype long is Interfaces.C.long; subtype LARGE_INTEGER is System.Win32.LARGE_INTEGER; ------------------- -- General Types -- ------------------- subtype PSZ is Interfaces.C.Strings.chars_ptr; Null_Void : constant Win32.PVOID := System.Null_Address; ------------------------- -- Handles for objects -- ------------------------- subtype Thread_Id is Win32.HANDLE; ----------- -- Errno -- ----------- NO_ERROR : constant := 0; FUNC_ERR : constant := -1; ------------- -- Signals -- ------------- Max_Interrupt : constant := 31; type Signal is new int range 0 .. Max_Interrupt; for Signal'Size use int'Size; SIGINT : constant := 2; -- interrupt (Ctrl-C) SIGILL : constant := 4; -- illegal instruction (not reset) SIGFPE : constant := 8; -- floating point exception SIGSEGV : constant := 11; -- segmentation violation SIGTERM : constant := 15; -- software termination signal from kill SIGBREAK : constant := 21; -- break (Ctrl-Break) SIGABRT : constant := 22; -- used by abort, replace SIGIOT in the future type sigset_t is private; type isr_address is access procedure (sig : int); pragma Convention (C, isr_address); function intr_attach (sig : int; handler : isr_address) return long; pragma Import (C, intr_attach, "signal"); Intr_Attach_Reset : constant Boolean := True; -- True if intr_attach is reset after an interrupt handler is called procedure kill (sig : Signal); pragma Import (C, kill, "raise"); ------------ -- Clock -- ------------ procedure QueryPerformanceFrequency (lpPerformanceFreq : access LARGE_INTEGER); pragma Import (Stdcall, QueryPerformanceFrequency, "QueryPerformanceFrequency"); -- According to the spec, on XP and later than function cannot fail, -- so we ignore the return value and import it as a procedure. ------------- -- Threads -- ------------- type Thread_Body is access function (arg : System.Address) return System.Address; pragma Convention (C, Thread_Body); function Thread_Body_Access is new Ada.Unchecked_Conversion (System.Address, Thread_Body); procedure SwitchToThread; pragma Import (Stdcall, SwitchToThread, "SwitchToThread"); function GetThreadTimes (hThread : Win32.HANDLE; lpCreationTime : access Long_Long_Integer; lpExitTime : access Long_Long_Integer; lpKernelTime : access Long_Long_Integer; lpUserTime : access Long_Long_Integer) return Win32.BOOL; pragma Import (Stdcall, GetThreadTimes, "GetThreadTimes"); ----------------------- -- Critical sections -- ----------------------- type CRITICAL_SECTION is private; ------------------------------------------------------------- -- Thread Creation, Activation, Suspension And Termination -- ------------------------------------------------------------- type PTHREAD_START_ROUTINE is access function (pThreadParameter : Win32.PVOID) return Win32.DWORD; pragma Convention (Stdcall, PTHREAD_START_ROUTINE); function To_PTHREAD_START_ROUTINE is new Ada.Unchecked_Conversion (System.Address, PTHREAD_START_ROUTINE); function CreateThread (pThreadAttributes : access Win32.SECURITY_ATTRIBUTES; dwStackSize : Win32.DWORD; pStartAddress : PTHREAD_START_ROUTINE; pParameter : Win32.PVOID; dwCreationFlags : Win32.DWORD; pThreadId : access Win32.DWORD) return Win32.HANDLE; pragma Import (Stdcall, CreateThread, "CreateThread"); function BeginThreadEx (pThreadAttributes : access Win32.SECURITY_ATTRIBUTES; dwStackSize : Win32.DWORD; pStartAddress : PTHREAD_START_ROUTINE; pParameter : Win32.PVOID; dwCreationFlags : Win32.DWORD; pThreadId : not null access Win32.DWORD) return Win32.HANDLE; pragma Import (C, BeginThreadEx, "_beginthreadex"); Debug_Process : constant := 16#00000001#; Debug_Only_This_Process : constant := 16#00000002#; Create_Suspended : constant := 16#00000004#; Detached_Process : constant := 16#00000008#; Create_New_Console : constant := 16#00000010#; Create_New_Process_Group : constant := 16#00000200#; Create_No_window : constant := 16#08000000#; Profile_User : constant := 16#10000000#; Profile_Kernel : constant := 16#20000000#; Profile_Server : constant := 16#40000000#; Stack_Size_Param_Is_A_Reservation : constant := 16#00010000#; function GetExitCodeThread (hThread : Win32.HANDLE; pExitCode : not null access Win32.DWORD) return Win32.BOOL; pragma Import (Stdcall, GetExitCodeThread, "GetExitCodeThread"); function ResumeThread (hThread : Win32.HANDLE) return Win32.DWORD; pragma Import (Stdcall, ResumeThread, "ResumeThread"); function SuspendThread (hThread : Win32.HANDLE) return Win32.DWORD; pragma Import (Stdcall, SuspendThread, "SuspendThread"); procedure ExitThread (dwExitCode : Win32.DWORD); pragma Import (Stdcall, ExitThread, "ExitThread"); procedure EndThreadEx (dwExitCode : Win32.DWORD); pragma Import (C, EndThreadEx, "_endthreadex"); function TerminateThread (hThread : Win32.HANDLE; dwExitCode : Win32.DWORD) return Win32.BOOL; pragma Import (Stdcall, TerminateThread, "TerminateThread"); function GetCurrentThread return Win32.HANDLE; pragma Import (Stdcall, GetCurrentThread, "GetCurrentThread"); function GetCurrentProcess return Win32.HANDLE; pragma Import (Stdcall, GetCurrentProcess, "GetCurrentProcess"); function GetCurrentThreadId return Win32.DWORD; pragma Import (Stdcall, GetCurrentThreadId, "GetCurrentThreadId"); function TlsAlloc return Win32.DWORD; pragma Import (Stdcall, TlsAlloc, "TlsAlloc"); function TlsGetValue (dwTlsIndex : Win32.DWORD) return Win32.PVOID; pragma Import (Stdcall, TlsGetValue, "TlsGetValue"); function TlsSetValue (dwTlsIndex : Win32.DWORD; pTlsValue : Win32.PVOID) return Win32.BOOL; pragma Import (Stdcall, TlsSetValue, "TlsSetValue"); function TlsFree (dwTlsIndex : Win32.DWORD) return Win32.BOOL; pragma Import (Stdcall, TlsFree, "TlsFree"); TLS_Nothing : constant := Win32.DWORD'Last; procedure ExitProcess (uExitCode : Interfaces.C.unsigned); pragma Import (Stdcall, ExitProcess, "ExitProcess"); function WaitForSingleObject (hHandle : Win32.HANDLE; dwMilliseconds : Win32.DWORD) return Win32.DWORD; pragma Import (Stdcall, WaitForSingleObject, "WaitForSingleObject"); function WaitForSingleObjectEx (hHandle : Win32.HANDLE; dwMilliseconds : Win32.DWORD; fAlertable : Win32.BOOL) return Win32.DWORD; pragma Import (Stdcall, WaitForSingleObjectEx, "WaitForSingleObjectEx"); Wait_Infinite : constant := Win32.DWORD'Last; WAIT_TIMEOUT : constant := 16#0000_0102#; WAIT_FAILED : constant := 16#FFFF_FFFF#; ------------------------------------ -- Semaphores, Events and Mutexes -- ------------------------------------ function CreateSemaphore (pSemaphoreAttributes : access Win32.SECURITY_ATTRIBUTES; lInitialCount : Interfaces.C.long; lMaximumCount : Interfaces.C.long; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, CreateSemaphore, "CreateSemaphoreA"); function OpenSemaphore (dwDesiredAccess : Win32.DWORD; bInheritHandle : Win32.BOOL; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, OpenSemaphore, "OpenSemaphoreA"); function ReleaseSemaphore (hSemaphore : Win32.HANDLE; lReleaseCount : Interfaces.C.long; pPreviousCount : access Win32.LONG) return Win32.BOOL; pragma Import (Stdcall, ReleaseSemaphore, "ReleaseSemaphore"); function CreateEvent (pEventAttributes : access Win32.SECURITY_ATTRIBUTES; bManualReset : Win32.BOOL; bInitialState : Win32.BOOL; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, CreateEvent, "CreateEventA"); function OpenEvent (dwDesiredAccess : Win32.DWORD; bInheritHandle : Win32.BOOL; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, OpenEvent, "OpenEventA"); function SetEvent (hEvent : Win32.HANDLE) return Win32.BOOL; pragma Import (Stdcall, SetEvent, "SetEvent"); function ResetEvent (hEvent : Win32.HANDLE) return Win32.BOOL; pragma Import (Stdcall, ResetEvent, "ResetEvent"); function PulseEvent (hEvent : Win32.HANDLE) return Win32.BOOL; pragma Import (Stdcall, PulseEvent, "PulseEvent"); function CreateMutex (pMutexAttributes : access Win32.SECURITY_ATTRIBUTES; bInitialOwner : Win32.BOOL; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, CreateMutex, "CreateMutexA"); function OpenMutex (dwDesiredAccess : Win32.DWORD; bInheritHandle : Win32.BOOL; pName : PSZ) return Win32.HANDLE; pragma Import (Stdcall, OpenMutex, "OpenMutexA"); function ReleaseMutex (hMutex : Win32.HANDLE) return Win32.BOOL; pragma Import (Stdcall, ReleaseMutex, "ReleaseMutex"); --------------------------------------------------- -- Accessing properties of Threads and Processes -- --------------------------------------------------- ----------------- -- Priorities -- ----------------- function SetThreadPriority (hThread : Win32.HANDLE; nPriority : Interfaces.C.int) return Win32.BOOL; pragma Import (Stdcall, SetThreadPriority, "SetThreadPriority"); function GetThreadPriority (hThread : Win32.HANDLE) return Interfaces.C.int; pragma Import (Stdcall, GetThreadPriority, "GetThreadPriority"); function SetPriorityClass (hProcess : Win32.HANDLE; dwPriorityClass : Win32.DWORD) return Win32.BOOL; pragma Import (Stdcall, SetPriorityClass, "SetPriorityClass"); procedure SetThreadPriorityBoost (hThread : Win32.HANDLE; DisablePriorityBoost : Win32.BOOL); pragma Import (Stdcall, SetThreadPriorityBoost, "SetThreadPriorityBoost"); Normal_Priority_Class : constant := 16#00000020#; Idle_Priority_Class : constant := 16#00000040#; High_Priority_Class : constant := 16#00000080#; Realtime_Priority_Class : constant := 16#00000100#; Thread_Priority_Idle : constant := -15; Thread_Priority_Lowest : constant := -2; Thread_Priority_Below_Normal : constant := -1; Thread_Priority_Normal : constant := 0; Thread_Priority_Above_Normal : constant := 1; Thread_Priority_Highest : constant := 2; Thread_Priority_Time_Critical : constant := 15; Thread_Priority_Error_Return : constant := Interfaces.C.long'Last; private type sigset_t is new Interfaces.C.unsigned_long; type CRITICAL_SECTION is record DebugInfo : System.Address; LockCount : Long_Integer; RecursionCount : Long_Integer; OwningThread : Win32.HANDLE; -- The above three fields control entering and exiting the critical -- section for the resource. LockSemaphore : Win32.HANDLE; SpinCount : Interfaces.C.size_t; end record; end System.OS_Interface;
reznikmm/matreshka
Ada
4,816
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Database_Row_Number_Elements; package Matreshka.ODF_Text.Database_Row_Number_Elements is type Text_Database_Row_Number_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Database_Row_Number_Elements.ODF_Text_Database_Row_Number with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Database_Row_Number_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Database_Row_Number_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Database_Row_Number_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Database_Row_Number_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Database_Row_Number_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Database_Row_Number_Elements;
pchapin/augusta
Ada
399
adb
procedure Main is X : Integer; Y : Integer; Z : Integer; B : Boolean; begin -- All correct if X + Y < Z then while True loop null; end loop; B := Y < Z; end if; -- All wrong! :) if X + Y then while True < False loop X := Y < Z; B := 1; X := Y + 2*B; B := X - Y; end loop; end if; end Main;
reznikmm/matreshka
Ada
29,866
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package is low level bindings to Firebird library. ------------------------------------------------------------------------------ with System; with Interfaces.C; package Matreshka.Internals.SQL_Drivers.Firebird is ----------- -- Types -- ----------- type Isc_Database_Handle is new System.Address; type Isc_Database_Handle_Access is access constant Isc_Database_Handle; pragma Convention (C, Isc_Database_Handle_Access); Null_Isc_Database_Handle : constant Isc_Database_Handle := Isc_Database_Handle (System.Null_Address); type Isc_Transaction_Handle is new System.Address; type Isc_Transaction_Handle_Access is access constant Isc_Transaction_Handle; pragma Convention (C, Isc_Transaction_Handle_Access); Null_Isc_Transaction_Handle : constant Isc_Transaction_Handle := Isc_Transaction_Handle (System.Null_Address); type Isc_Stmt_Handle is new System.Address; Null_Isc_Stmt_Handle : constant Isc_Stmt_Handle := Isc_Stmt_Handle (System.Null_Address); subtype Isc_Address is System.Address; Zero : constant Isc_Address := System.Null_Address; subtype Isc_Short is Interfaces.C.short; type Isc_Short_Access is access all Isc_Short; pragma Convention (C, Isc_Short_Access); subtype Isc_Ushort is Interfaces.Unsigned_16; subtype Isc_Long is Interfaces.C.long; type Isc_Result_Code is new Isc_Long; type Isc_Results is array (1 .. 20) of aliased Isc_Result_Code; pragma Convention (C, Isc_Results); type Isc_Result_Codes is array (Positive range <>) of Isc_Result_Code; type Isc_Results_Access is access constant Isc_Result_Code; pragma Convention (C, Isc_Results_Access); subtype Isc_String is Interfaces.C.char_array; type Isc_String_Access is access all Isc_String; type Isc_Teb is record Db_Handle : access Isc_Database_Handle := null; Tpb_Length : Isc_Long := 0; Tpb : access Isc_String := null; end record; pragma Convention (C, Isc_Teb); type Isc_Tebs is array (Integer range <>) of Isc_Teb; pragma Convention (C, Isc_Tebs); subtype Isc_Db_Dialect is Interfaces.Unsigned_16 range 1 .. 3; Isc_Sqlda_Current_Version : constant := 1; Current_Metanames_Length : constant := 32; type Isc_Field_Index is new Isc_Short range 0 .. Isc_Short'Last; subtype Isc_Valid_Field_Index is Isc_Field_Index range 1 .. Isc_Field_Index'Last; -- for allow XSQLVAR:sqltype bits manipulation subtype Isc_Num_Bits is Natural range 0 .. 15; type Isc_Sqltype is array (Isc_Num_Bits) of Boolean; pragma Pack (Isc_Sqltype); for Isc_Sqltype'Size use 16; Isc_Sqlind_Flag : constant Isc_Num_Bits := 0; Isc_Type_Text : constant Isc_Sqltype := (False, False, True, False, False, False, True, True, True, others => False); -- 452; 111000100 Isc_Type_Varying : constant Isc_Sqltype := (False, False, False, False, False, False, True, True, True, others => False); -- 448; 111000000 Isc_Type_Short : constant Isc_Sqltype := (False, False, True, False, True, True, True, True, True, others => False); -- 500; 111110100 Isc_Type_Long : constant Isc_Sqltype := (False, False, False, False, True, True, True, True, True, others => False); -- 496; 111110000 Isc_Type_Float : constant Isc_Sqltype := (False, True, False, False, False, True, True, True, True, others => False); -- 482; 111100010 Isc_Type_Double : constant Isc_Sqltype := (False, False, False, False, False, True, True, True, True, others => False); -- 480; 111100000 Isc_Type_D_Float : constant Isc_Sqltype := (False, True, False, False, True, False, False, False, False, True, others => False); -- 530; 1000010010 Isc_Type_Timestamp : constant Isc_Sqltype := (False, True, True, True, True, True, True, True, True, others => False); -- 510; 111111110 Isc_Type_Blob : constant Isc_Sqltype := (False, False, False, True, False, False, False, False, False, True, others => False); -- 520; 1000001000 Isc_Type_Array : constant Isc_Sqltype := (False, False, True, True, True, False, False, False, False, True, others => False); -- 540; 1000011100 Isc_Type_Quad : constant Isc_Sqltype := (False, True, True, False, False, True, False, False, False, True, others => False); -- 550; 1000100110 Isc_Type_Time : constant Isc_Sqltype := (False, False, False, False, True, True, False, False, False, True, others => False); -- 560; 1000110000 Isc_Type_Date : constant Isc_Sqltype := (False, True, False, True, True, True, False, False, False, True, others => False); -- 570; 1000111010 Isc_Type_Int64 : constant Isc_Sqltype := (False, False, True, False, False, False, True, False, False, True, others => False); -- 580; 1001000100 Isc_Type_Boolean : constant Isc_Sqltype := (False, True, True, True, False, False, True, False, False, True, others => False); -- 590; 1001001110 Isc_Type_Empty : constant Isc_Sqltype := (others => False); -- 0; Isc_Type_Empty1 : constant Isc_Sqltype := (True, others => False); -- 1; Isc_Type_Min : constant Isc_Sqltype := (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True); -- -1; Empty_Metanames_String : constant Isc_String (1 .. Current_Metanames_Length) := (others => Interfaces.C.nul); type Isc_Sqlvar is record Sqltype : Isc_Sqltype := Isc_Type_Empty; -- datatype of field Sqlscale : Isc_Short := 0; -- scale factor Sqlsubtype : Isc_Short := 0; -- BLOBs & Text types only Sqllen : Isc_Short := 0; -- length of data area Sqldata : Isc_Address := Zero; -- address of data Sqlind : Isc_Short_Access := null; -- address of indicator variable Sqlname_Length : Isc_Short := 0; -- length of sqlname field -- name of field, name length + space for NULL Sqlname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Relname_Length : Isc_Short := 0; -- length of relation name -- field's relation name + space for NULL Relname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Ownname_Length : Isc_Short := 0; -- length of owner name -- relation's owner name + space for NULL Ownname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; Aliasname_Length : Isc_Short := 0; -- length of alias name -- relation's alias name + space for NULL Aliasname : Isc_String (1 .. Current_Metanames_Length) := Empty_Metanames_String; end record; pragma Convention (C, Isc_Sqlvar); type Isc_Sqlvars is array (Isc_Valid_Field_Index) of aliased Isc_Sqlvar; pragma Convention (C, Isc_Sqlvars); pragma Suppress (Index_Check, Isc_Sqlvars); type Isc_Sqlda is record -- version of this XSQLDA Version : Isc_Short := Isc_Sqlda_Current_Version; -- XSQLDA name field Sqldaid : Isc_String (1 .. 8) := (others => Interfaces.C.nul); Sqldabc : Isc_Long := 0; -- length in bytes of SQLDA Sqln : Isc_Field_Index := 1; -- number of fields allocated Sqld : Isc_Field_Index := 0; -- used number of fields Sqlvar : Isc_Sqlvars; -- first field of 1..n array of fields end record; pragma Convention (C, Isc_Sqlda); -- Constants -- Buffer_Length : constant := 512; Huge_Buffer_Length : constant := Buffer_Length * 20; Isc_True : constant := 1; -- Database parameter block stuff -- subtype Isc_Dpb_Code is Interfaces.C.char; Isc_Dpb_Version1 : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (1); Isc_Dpb_Cdd_Pathname : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (1); Isc_Dpb_Allocation : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (2); Isc_Dpb_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (3); Isc_Dpb_Page_Size : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (4); Isc_Dpb_Num_Buffers : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (5); Isc_Dpb_Buffer_Length : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (6); Isc_Dpb_Debug : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (7); Isc_Dpb_Garbage_Collect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (8); Isc_Dpb_Verify : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (9); Isc_Dpb_Sweep : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (10); Isc_Dpb_Enable_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (11); Isc_Dpb_Disable_Journal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (12); Isc_Dpb_Dbkey_Scope : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (13); Isc_Dpb_Number_Of_Users : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (14); Isc_Dpb_Trace : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (15); Isc_Dpb_No_Garbage_Collect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (16); Isc_Dpb_Damaged : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (17); Isc_Dpb_License : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (18); Isc_Dpb_Sys_User_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (19); Isc_Dpb_Encrypt_Key : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (20); Isc_Dpb_Activate_Shadow : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (21); Isc_Dpb_Sweep_Interval : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (22); Isc_Dpb_Delete_Shadow : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (23); Isc_Dpb_Force_Write : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (24); Isc_Dpb_Begin_Log : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (25); Isc_Dpb_Quit_Log : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (26); Isc_Dpb_No_Reserve : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (27); Isc_Dpb_User_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (28); Isc_Dpb_Password : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (29); Isc_Dpb_Password_Enc : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (30); Isc_Dpb_Sys_User_Name_Enc : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (31); Isc_Dpb_Interp : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (32); Isc_Dpb_Online_Dump : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (33); Isc_Dpb_Old_File_Size : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (34); Isc_Dpb_Old_Num_Files : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (35); Isc_Dpb_Old_File : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (36); Isc_Dpb_Old_Start_Page : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (37); Isc_Dpb_Old_Start_Seqno : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (38); Isc_Dpb_Old_Start_File : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (39); Isc_Dpb_Drop_Walfile : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (40); Isc_Dpb_Old_Dump_Id : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (41); Isc_Dpb_Wal_Backup_Dir : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (42); Isc_Dpb_Wal_Chkptlen : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (43); Isc_Dpb_Wal_Numbufs : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (44); Isc_Dpb_Wal_Bufsize : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (45); Isc_Dpb_Wal_Grp_Cmt_Wait : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (46); Isc_Dpb_Lc_Messages : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (47); Isc_Dpb_Lc_Ctype : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (48); Isc_Dpb_Cache_Manager : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (49); Isc_Dpb_Shutdown : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (50); Isc_Dpb_Online : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (51); Isc_Dpb_Shutdown_Delay : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (52); Isc_Dpb_Reserved : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (53); Isc_Dpb_Overwrite : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (54); Isc_Dpb_Sec_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (55); Isc_Dpb_Disable_Wal : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (56); Isc_Dpb_Connect_Timeout : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (57); Isc_Dpb_Dummy_Packet_Interval : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (58); Isc_Dpb_Gbak_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (59); Isc_Dpb_Sql_Role_Name : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (60); Isc_Dpb_Set_Page_Buffers : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (61); Isc_Dpb_Working_Directory : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (62); Isc_Dpb_Sql_Dialect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (63); Isc_Dpb_Set_Db_Readonly : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (64); Isc_Dpb_Set_Db_Sql_Dialect : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (65); Isc_Dpb_Gfix_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (66); Isc_Dpb_Gstat_Attach : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (67); Isc_Dpb_Set_Db_Charset : constant Isc_Dpb_Code := Isc_Dpb_Code'Val (68); -- Isc_DPB_Verify specific flags -- subtype Isc_Dpb_Vcode is Interfaces.C.char; Isc_Dpb_Pages : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (1); Isc_Dpb_Records : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (2); Isc_Dpb_Indices : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (4); Isc_Dpb_Transactions : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (8); Isc_Dpb_No_Update : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (16); Isc_Dpb_Repair : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (32); Isc_DPB_Ignore : constant Isc_Dpb_Vcode := Isc_Dpb_Vcode'Val (64); -- Transaction parameter block stuff -- subtype Isc_Tpb_Code is Interfaces.C.char; Isc_Tpb_Version1 : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (1); Isc_Tpb_Version3 : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (3); Isc_Tpb_Consistency : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (1); Isc_Tpb_Concurrency : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (2); Isc_Tpb_Shared : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (3); Isc_Tpb_Protected : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (4); Isc_Tpb_Exclusive : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (5); Isc_Tpb_Wait : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (6); Isc_Tpb_Nowait : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (7); Isc_Tpb_Read : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (8); Isc_Tpb_Write : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (9); Isc_Tpb_Lock_Read : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (10); Isc_Tpb_Lock_Write : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (11); Isc_Tpb_Verb_Time : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (12); Isc_Tpb_Commit_Time : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (13); Isc_Tpb_Ignore_Limbo : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (14); Isc_Tpb_Read_Committed : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (15); Isc_Tpb_Autocommit : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (16); Isc_Tpb_Rec_Version : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (17); Isc_Tpb_No_Rec_Version : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (18); Isc_Tpb_Restart_Requests : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (19); Isc_Tpb_No_Auto_Undo : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (20); Isc_Tpb_No_Savepoint : constant Isc_Tpb_Code := Isc_Tpb_Code'Val (21); -- IB 7.5 Isc_Tpb_Last_Code : constant Isc_Tpb_Code := Isc_Tpb_No_Savepoint; type Isc_Stmt_Free_Code is new Isc_Short; pragma Convention (C, Isc_Stmt_Free_Code); Isc_Sql_Close : constant Isc_Stmt_Free_Code := 1; Isc_Sql_Drop : constant Isc_Stmt_Free_Code := 2; type Isc_Character_Set is (UNKNOWN, NONE, OCTETS, ASCII, UNICODE_FSS, SJIS_0208, EUCJ_0208, DOS737, DOS437, DOS850, DOS865, DOS860, DOS863, DOS775, DOS858, DOS862, DOS864, NEXT, ISO8859_1, ISO8859_2, ISO8859_3, ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, ISO8859_13, KSC_5601, DOS852, DOS857, DOS861, DOS866, DOS869, CYRL, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, BIG_5, GB_2312, WIN1255, WIN1256, WIN1257, UFT8); Isc_Charsets_Count : constant Isc_Short := 60; type Isc_Character_Sets is array (0 .. Isc_Charsets_Count) of Isc_Character_Set; Character_Set : constant Isc_Character_Sets := (NONE, OCTETS, ASCII, UNICODE_FSS, UFT8, SJIS_0208, EUCJ_0208, UNKNOWN, UNKNOWN, DOS737, DOS437, DOS850, DOS865, DOS860, DOS863, DOS775, DOS858, DOS862, DOS864, NEXT, UNKNOWN, ISO8859_1, ISO8859_2, ISO8859_3, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, ISO8859_4, ISO8859_5, ISO8859_6, ISO8859_7, ISO8859_8, ISO8859_9, ISO8859_13, UNKNOWN, UNKNOWN, UNKNOWN, KSC_5601, DOS852, DOS857, DOS861, DOS866, DOS869, CYRL, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, BIG_5, GB_2312, WIN1255, WIN1256, WIN1257); -- Error codes -- Isc_Dsql_Cursor_Err : constant Isc_Result_Code := 335544572; Isc_Bad_Stmt_Handle : constant Isc_Result_Code := 335544485; Isc_Dsql_Cursor_Close_Err : constant Isc_Result_Code := 335544577; -- Info -- subtype Isc_Info_Request is Interfaces.C.char; Isc_Info_Sql_Stmt_Type : constant Isc_Info_Request := Isc_Info_Request'Val (21); Frb_Info_Att_Charset : constant Isc_Info_Request := Isc_Info_Request'Val (101); -- methods -- function Isc_Attach_Database (Status : access Isc_Results; Db_Name_Length : Isc_Short; Db_Name : Isc_String; Db_Handle : access Isc_Database_Handle; Parms_Length : Isc_Short; Parms : Isc_String) return Isc_Result_Code; function Isc_Detach_Database (Status : access Isc_Results; Handle : access Isc_Database_Handle) return Isc_Result_Code; function Isc_Sqlcode (Status : Isc_Results) return Isc_Long; procedure Isc_Sql_Interprete (Sqlcode : Isc_Short; Buffer : access Isc_String; Buffer_Length : Isc_Short); function Isc_Interprete (Buffer : access Isc_String; Status : access Isc_Results_Access) return Isc_Result_Code; function Isc_Commit_Retaining (Status : access Isc_Results; Handle : access Isc_Transaction_Handle) return Isc_Result_Code; function Isc_Start_Multiple (Status : access Isc_Results; Handle : access Isc_Transaction_Handle; Tebs_Count : Isc_Short; Teb : access Isc_Tebs) return Isc_Result_Code; function Isc_Rollback_Transaction (Status : access Isc_Results; Handle : access Isc_Transaction_Handle) return Isc_Result_Code; function Isc_Dsql_Fetch (Status : access Isc_Results; Handle : access Isc_Stmt_Handle; Version : Isc_Db_Dialect; Sqlda : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Free_Statement (Status : access Isc_Results; Handle : access Isc_Stmt_Handle; Code : Isc_Stmt_Free_Code) return Isc_Result_Code; function Isc_Dsql_Alloc_Statement2 (Status : access Isc_Results; Db : Isc_Database_Handle_Access; Stmt : access Isc_Stmt_Handle) return Isc_Result_Code; function Isc_Dsql_Prepare (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Length : Isc_Ushort; Statement : Isc_String; Dialect : Isc_Ushort; Xsqlda : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Sql_Info (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Items_Length : Isc_Short; Items : Isc_String; Buffer_Length : Isc_Short; Buffer : access Isc_String) return Isc_Result_Code; function Isc_Vax_Integer (Buffer : Isc_String; Length : Isc_Short) return Isc_Long; function Isc_Dsql_Set_Cursor_Name (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Name : Isc_String; Itype : Isc_Ushort) return Isc_Result_Code; function Isc_Dsql_Describe_Bind (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Describe (Status : access Isc_Results; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Rec : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute_Immediate (Status : access Isc_Results; Db : Isc_Database_Handle_Access; Tr : Isc_Transaction_Handle_Access; Length : Isc_Short; Statement : Isc_String; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda) return Isc_Result_Code; function Isc_Dsql_Execute2 (Status : access Isc_Results; Tr : Isc_Transaction_Handle_Access; Stmt : access Isc_Stmt_Handle; Version : Isc_Ushort; Params : access Isc_Sqlda; Fields : access Isc_Sqlda) return Isc_Result_Code; function Isc_Database_Info (Status : access Isc_Results; Handle : access Isc_Database_Handle; Length : Isc_Short; Items : Isc_String; Buf_Length : Isc_Short; Buf : access Isc_String) return Isc_Result_Code; ----------- -- Utils -- ----------- function Get_Error (Status : access Isc_Results) return League.Strings.Universal_String; function Check_For_Error (Status : access Isc_Results; Codes : Isc_Result_Codes) return Boolean; function To_Isc_String (Item : League.Strings.Universal_String) return Isc_String; function Is_Datetime_Type (Sql_Type : Isc_Sqltype) return Boolean; function Is_Numeric_Type (Sql_Type : Isc_Sqltype) return Boolean; ------------------------- -- Time & Date Support -- ------------------------- type Isc_Date is new Isc_Long; type Isc_Time is new Interfaces.Unsigned_32; type Isc_Timestamp is record Timestamp_Date : Isc_Date; Timestamp_Time : Isc_Time; end record; pragma Convention (C, Isc_Timestamp); Isc_Time_Seconds_Precision_Scale : constant := 4; MSecs_Per_Sec : constant := 10**Isc_Time_Seconds_Precision_Scale; -- C_Time -- type C_Time is record Tm_Sec : Interfaces.C.int := 0; Tm_Min : Interfaces.C.int := 0; Tm_Hour : Interfaces.C.int := 0; Tm_Mday : Interfaces.C.int := 0; Tm_Mon : Interfaces.C.int := 0; Tm_Year : Interfaces.C.int := 0; Tm_Wday : Interfaces.C.int := 0; Tm_Yday : Interfaces.C.int := 0; Tm_Isdst : Interfaces.C.int := 0; Tm_Gmtoff : Interfaces.C.int := 0; Tm_Zone : System.Address := System.Null_Address; end record; pragma Convention (C, C_Time); procedure Isc_Encode_Sql_Time (C_Date : access C_Time; Ib_Date : access Isc_Time); procedure Isc_Encode_Sql_Date (C_Date : access C_Time; Ib_Date : access Isc_Date); procedure Isc_Encode_Timestamp (C_Date : access C_Time; Ib_Date : access Isc_Timestamp); procedure Isc_Decode_Timestamp (Ib_Date : access Isc_Timestamp; C_Date : access C_Time); procedure Isc_Decode_Sql_Date (Ib_Date : access Isc_Date; C_Date : access C_Time); procedure Isc_Decode_Sql_Time (Ib_Date : access Isc_Time; C_Date : access C_Time); private pragma Import (Stdcall, Isc_Attach_Database, "isc_attach_database"); pragma Import (Stdcall, Isc_Detach_Database, "isc_detach_database"); pragma Import (Stdcall, Isc_Sqlcode, "isc_sqlcode"); pragma Import (Stdcall, Isc_Sql_Interprete, "isc_sql_interprete"); pragma Import (Stdcall, Isc_Interprete, "isc_interprete"); pragma Import (Stdcall, Isc_Commit_Retaining, "isc_commit_retaining"); pragma Import (Stdcall, Isc_Start_Multiple, "isc_start_multiple"); pragma Import (Stdcall, Isc_Dsql_Fetch, "isc_dsql_fetch"); pragma Import (Stdcall, Isc_Dsql_Free_Statement, "isc_dsql_free_statement"); pragma Import (Stdcall, Isc_Dsql_Prepare, "isc_dsql_prepare"); pragma Import (Stdcall, Isc_Dsql_Sql_Info, "isc_dsql_sql_info"); pragma Import (Stdcall, Isc_Vax_Integer, "isc_vax_integer"); pragma Import (Stdcall, Isc_Dsql_Describe_Bind, "isc_dsql_describe_bind"); pragma Import (Stdcall, Isc_Dsql_Describe, "isc_dsql_describe"); pragma Import (Stdcall, Isc_Dsql_Execute, "isc_dsql_execute"); pragma Import (Stdcall, Isc_Dsql_Execute2, "isc_dsql_execute2"); pragma Import (Stdcall, Isc_Encode_Sql_Time, "isc_encode_sql_time"); pragma Import (Stdcall, Isc_Encode_Timestamp, "isc_encode_timestamp"); pragma Import (Stdcall, Isc_Encode_Sql_Date, "isc_encode_sql_date"); pragma Import (Stdcall, Isc_Decode_Timestamp, "isc_decode_timestamp"); pragma Import (Stdcall, Isc_Decode_Sql_Date, "isc_decode_sql_date"); pragma Import (Stdcall, Isc_Decode_Sql_Time, "isc_decode_sql_time"); pragma Import (Stdcall, Isc_Database_Info, "isc_database_info"); pragma Import (Stdcall, Isc_Rollback_Transaction, "isc_rollback_transaction"); pragma Import (Stdcall, Isc_Dsql_Alloc_Statement2, "isc_dsql_alloc_statement2"); pragma Import (Stdcall, Isc_Dsql_Set_Cursor_Name, "isc_dsql_set_cursor_name"); pragma Import (Stdcall, Isc_Dsql_Execute_Immediate, "isc_dsql_execute_immediate"); end Matreshka.Internals.SQL_Drivers.Firebird;
reznikmm/matreshka
Ada
10,045
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ private with Ada.Containers.Hashed_Maps; private with Ada.Containers.Ordered_Maps; private with Ada.Containers.Vectors; with League.Characters; with League.Strings.Hash; with XML.SAX.Attributes; with XML.SAX.Output_Destinations; with XML.SAX.Writers; package XML.SAX.Pretty_Writers is type SAX_Output_Destination_Access is access all XML.SAX.Output_Destinations.SAX_Output_Destination'Class; type XML_Version is (XML_1_0, XML_1_1); type XML_Pretty_Writer is limited new XML.SAX.Writers.SAX_Writer with private; not overriding procedure Set_Version (Self : in out XML_Pretty_Writer; Version : XML_Version); not overriding procedure Set_Offset (Self : in out XML_Pretty_Writer; Offset : Natural); -- Sets offset for indentation. not overriding procedure Set_Value_Delimiter (Self : in out XML_Pretty_Writer; Delimiter : League.Characters.Universal_Character); -- Sets value delimiter for attributes. -- '"' (apostrophe) is used by default procedure Set_Output_Destination (Self : in out XML_Pretty_Writer'Class; Output : not null SAX_Output_Destination_Access); -- Sets output destination to be used to output generated stream. overriding procedure Characters (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Comment (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean); overriding procedure End_CDATA (Self : in out XML_Pretty_Writer; Success : in out Boolean); overriding procedure End_Document (Self : in out XML_Pretty_Writer; Success : in out Boolean); overriding procedure End_DTD (Self : in out XML_Pretty_Writer; Success : in out Boolean); overriding procedure End_Element (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Success : in out Boolean); overriding procedure End_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean); overriding procedure End_Prefix_Mapping (Self : in out XML_Pretty_Writer; Prefix : League.Strings.Universal_String := League.Strings.Empty_Universal_String; Success : in out Boolean); overriding function Error_String (Self : XML_Pretty_Writer) return League.Strings.Universal_String; overriding procedure Ignorable_Whitespace (Self : in out XML_Pretty_Writer; Text : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Processing_Instruction (Self : in out XML_Pretty_Writer; Target : League.Strings.Universal_String; Data : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Skipped_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Start_CDATA (Self : in out XML_Pretty_Writer; Success : in out Boolean); overriding procedure Start_Document (Self : in out XML_Pretty_Writer; Success : in out Boolean); overriding procedure Start_DTD (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Start_Element (Self : in out XML_Pretty_Writer; Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Attributes : XML.SAX.Attributes.SAX_Attributes; Success : in out Boolean); overriding procedure Start_Entity (Self : in out XML_Pretty_Writer; Name : League.Strings.Universal_String; Success : in out Boolean); overriding procedure Start_Prefix_Mapping (Self : in out XML_Pretty_Writer; Prefix : League.Strings.Universal_String := League.Strings.Empty_Universal_String; Namespace_URI : League.Strings.Universal_String; Success : in out Boolean); private package Mappings is new Ada.Containers.Hashed_Maps (League.Strings.Universal_String, League.Strings.Universal_String, League.Strings.Hash, League.Strings."=", League.Strings."="); package Banks is new Ada.Containers.Ordered_Maps (League.Strings.Universal_String, League.Strings.Universal_String, League.Strings."<", League.Strings."="); type Element_Record is record Namespace_URI : League.Strings.Universal_String; Local_Name : League.Strings.Universal_String; Qualified_Name : League.Strings.Universal_String; Mapping : Mappings.Map; end record; package Element_Vector is new Ada.Containers.Vectors (Natural, Element_Record); procedure Merge (Current : in out Mappings.Map; Bank : Banks.Map); -- Merges namespaces declared for current element into the set of all -- namespaces. type XML_Pretty_Writer is limited new XML.SAX.Writers.SAX_Writer with record Nesting : Natural := 0; Version : XML_Version := XML_1_0; Tag_Opened : Boolean := False; DTD_Opened : Boolean := False; Error : League.Strings.Universal_String; Destination : SAX_Output_Destination_Access; Indent : Natural := 0; Offset : Natural := 0; Chars : Boolean := False; -- Indent, offset and chars are used for automatic indentation. Stack : Element_Vector.Vector; -- Stack of elements. Requested_NS : Banks.Map; -- Set of namespace mappings requested for the next element. Current : Element_Record; -- Current processing element including effective namespace mapping. Delimiter : League.Characters.Universal_Character := League.Characters.To_Universal_Character ('''); -- Delimiter for atribute='value'. end record; function Escape (Self : XML_Pretty_Writer; Text : League.Strings.Universal_String; Escape_All : Boolean := False) return League.Strings.Universal_String; -- Replaces special characters by their entity references. end XML.SAX.Pretty_Writers;
reznikmm/matreshka
Ada
4,663
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.Text_Path_Allowed_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Text_Path_Allowed_Attribute_Node is begin return Self : Draw_Text_Path_Allowed_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Text_Path_Allowed_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Text_Path_Allowed_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Text_Path_Allowed_Attribute, Draw_Text_Path_Allowed_Attribute_Node'Tag); end Matreshka.ODF_Draw.Text_Path_Allowed_Attributes;
google-code/ada-security
Ada
7,031
adb
----------------------------------------------------------------------- -- security-oauth-jwt -- OAuth Java Web Token -- Copyright (C) 2013 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.Calendar.Conversions; with Interfaces.C; with Util.Encoders; with Util.Strings; with Util.Serialize.IO; with Util.Properties.JSON; with Util.Log.Loggers; package body Security.OAuth.JWT is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.OAuth.JWT"); function Get_Time (From : in Util.Properties.Manager; Name : in String) return Ada.Calendar.Time; -- Decode the part using base64url and parse the JSON content into the property manager. procedure Decode_Part (Into : in out Util.Properties.Manager; Name : in String; Data : in String); function Get_Time (From : in Util.Properties.Manager; Name : in String) return Ada.Calendar.Time is Value : constant String := From.Get (Name); begin return Ada.Calendar.Conversions.To_Ada_Time (Interfaces.C.long'Value (Value)); end Get_Time; -- ------------------------------ -- Get the issuer claim from the token (the "iss" claim). -- ------------------------------ function Get_Issuer (From : in Token) return String is begin return From.Claims.Get ("iss"); end Get_Issuer; -- ------------------------------ -- Get the subject claim from the token (the "sub" claim). -- ------------------------------ function Get_Subject (From : in Token) return String is begin return From.Claims.Get ("sub"); end Get_Subject; -- ------------------------------ -- Get the audience claim from the token (the "aud" claim). -- ------------------------------ function Get_Audience (From : in Token) return String is begin return From.Claims.Get ("aud"); end Get_Audience; -- ------------------------------ -- Get the expiration claim from the token (the "exp" claim). -- ------------------------------ function Get_Expiration (From : in Token) return Ada.Calendar.Time is begin return Get_Time (From.Claims, "exp"); end Get_Expiration; -- ------------------------------ -- Get the not before claim from the token (the "nbf" claim). -- ------------------------------ function Get_Not_Before (From : in Token) return Ada.Calendar.Time is begin return Get_Time (From.Claims, "nbf"); end Get_Not_Before; -- ------------------------------ -- Get the issued at claim from the token (the "iat" claim). -- ------------------------------ function Get_Issued_At (From : in Token) return Ada.Calendar.Time is begin return Get_Time (From.Claims, "iat"); end Get_Issued_At; -- ------------------------------ -- Get the authentication time claim from the token (the "auth_time" claim). -- ------------------------------ function Get_Authentication_Time (From : in Token) return Ada.Calendar.Time is begin return Get_Time (From.Claims, "auth_time"); end Get_Authentication_Time; -- ------------------------------ -- Get the JWT ID claim from the token (the "jti" claim). -- ------------------------------ function Get_JWT_ID (From : in Token) return String is begin return From.Claims.Get ("jti"); end Get_JWT_ID; -- ------------------------------ -- Get the authorized clients claim from the token (the "azp" claim). -- ------------------------------ function Get_Authorized_Presenters (From : in Token) return String is begin return From.Claims.Get ("azp"); end Get_Authorized_Presenters; -- ------------------------------ -- Get the claim with the given name from the token. -- ------------------------------ function Get_Claim (From : in Token; Name : in String; Default : in String := "") return String is begin return From.Claims.Get (Name, Default); end Get_Claim; -- ------------------------------ -- Decode the part using base64url and parse the JSON content into the property manager. -- ------------------------------ procedure Decode_Part (Into : in out Util.Properties.Manager; Name : in String; Data : in String) is Decoder : constant Util.Encoders.Encoder := Util.Encoders.Create (Util.Encoders.BASE_64_URL); Content : constant String := Decoder.Decode (Data); begin Log.Debug ("Decoding {0}: {1}", Name, Content); Util.Properties.JSON.Parse_JSON (Into, Content); end Decode_Part; -- ------------------------------ -- Decode a string representing an encoded JWT token according to the JWT specification: -- -- Section 7. Rules for Creating and Validating a JWT -- -- The JWT token is composed of 3 parts encoded in Base64url and separated by '.' . -- The first part represents the header, the second part the claims and the last part -- the signature. The <tt>Decode</tt> operation splits the parts, decodes them, -- parses the JSON content represented by the header and the claims. -- The <tt>Decode</tt> operation does not verify the signature (yet!). -- -- Return the decoded token or raise an exception. -- ------------------------------ function Decode (Content : in String) return Token is Pos1 : constant Natural := Util.Strings.Index (Content, '.'); Pos2 : Natural; Result : Token; begin if Pos1 = 0 then Log.Error ("Invalid JWT token: missing '.' separator. JWT: {0}", Content); raise Invalid_Token with "Missing header separator"; end if; Pos2 := Util.Strings.Index (Content, '.', Pos1 + 1); if Pos2 = 0 then Log.Error ("Invalid JWT token: missing second '.' separator. JWT: {0}", Content); raise Invalid_Token with "Missing signature separator"; end if; Decode_Part (Result.Header, "header", Content (Content'First .. Pos1 - 1)); Decode_Part (Result.Claims, "claims", Content (Pos1 + 1 .. Pos2 - 1)); return Result; exception when Util.Serialize.IO.Parse_Error => raise Invalid_Token with "Invalid JSON content"; end Decode; end Security.OAuth.JWT;
reznikmm/matreshka
Ada
3,606
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Time_Events.Hash is new AMF.Elements.Generic_Hash (UML_Time_Event, UML_Time_Event_Access);
Heziode/lsystem-editor
Ada
2,248
adb
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[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.Strings; with Ada.Strings.Unbounded; package body LSE.Model.L_System.Error.Missing_Save is function Initialize (Line, Column : Positive) return Instance is begin return Instance '(Error_Type.Missing_Save, Line, Column); end Initialize; function Get_Error (This : Instance) return String is use Ada.Strings; use Ada.Strings.Unbounded; Str_Line : constant Unbounded_String := Trim (To_Unbounded_String (Positive'Image (This.Line)), Left); Str_Column : constant Unbounded_String := Trim (To_Unbounded_String (Positive'Image (This.Column)), Left); begin return "Missing restore character for save character defined at line " & To_String (Str_Line) & " column " & To_String (Str_Column); end Get_Error; end LSE.Model.L_System.Error.Missing_Save;
jquorning/iNow
Ada
1,280
ads
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Ada.Calendar; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; with Interfaces; with Types; package Database.Events is package US renames Ada.Strings.Unbounded; type Event_Kind is (Created, Startet, Stalled, Done, Text, Deadline, Milestone); type Event_Id is new Interfaces.Integer_64; procedure Add_Event (Job : in Types.Job_Id; Stamp : in Ada.Calendar.Time; Kind : in Event_Kind; Id : out Event_Id); type Event_Info is record Stamp : US.Unbounded_String; Kind : US.Unbounded_String; end record; package Event_Lists is new Ada.Containers.Vectors (Positive, Event_Info); function Get_Job_Events (Job : in Types.Job_Id) return Event_Lists.Vector; function Is_Done (Job : in Types.Job_Id) return Boolean; -- Is last event in events for Job a DONE. end Database.Events;
reznikmm/matreshka
Ada
4,681
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_Number.Denominator_Value_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Number_Denominator_Value_Attribute_Node is begin return Self : Number_Denominator_Value_Attribute_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Number_Denominator_Value_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Denominator_Value_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Number_URI, Matreshka.ODF_String_Constants.Denominator_Value_Attribute, Number_Denominator_Value_Attribute_Node'Tag); end Matreshka.ODF_Number.Denominator_Value_Attributes;
reznikmm/matreshka
Ada
3,770
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- 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$ ------------------------------------------------------------------------------ package body Servlet.FastCGI_Requests is ------------------------ -- Is_Async_Supported -- ------------------------ overriding function Is_Async_Supported (Self : not null access FastCGI_Servlet_Request) return Boolean is pragma Unreferenced (Self); begin -- FastCGI support asynchronous processing of requests. return True; end Is_Async_Supported; end Servlet.FastCGI_Requests;
zhmu/ananas
Ada
167
adb
-- { dg-do compile } -- { dg-options "-O2" } with Inline15_Gen; procedure Inline15 is package Inst is new Inline15_Gen; begin Inst.Call_Func; end Inline15;
sparre/aShell
Ada
1,677
adb
with Ada.Environment_Variables; with Ada.Text_IO; with Shell; procedure Environment_Test_Runner is use Ada.Text_IO; begin Put_Line ("Start tests."); New_Line (2); Test_1: declare Name : constant String := "aShell_Test_Variable"; Value : constant String := "Working"; Commands : constant String := "env | grep " & Name; Expected : constant String := Name & "=" & Value; use Shell; Piped_Commands : Command_Array := To_Commands (Commands); begin Put_Line ("Test 1 ~ Run piped commands => »" & Commands & "«"); Ada.Environment_Variables.Set (Name => Name, Value => Value); Put_Line ("Expected output:"); Put_Line (Expected); Put_Line ("Actual output:"); Run (Piped_Commands); delay 1.0; Put_Line ("End test 1"); end Test_1; New_Line (2); Test_2: declare Name : constant String := "aShell_Test_Variable"; Value : constant String := "Changed"; Commands : constant String := "env | grep " & Name; Expected : constant String := Name & "=" & Value; use Shell; Piped_Commands : Command_Array := To_Commands (Commands); begin Put_Line ("Test 2 ~ Run piped commands => »" & Commands & "«"); Ada.Environment_Variables.Set (Name => Name, Value => Value); Put_Line ("Expected output:"); Put_Line (Expected); Put_Line ("Actual output:"); Run (Piped_Commands); delay 1.0; Put_Line ("End test 2"); end Test_2; New_Line (2); Put_Line ("End tests."); end Environment_Test_Runner;
jhumphry/auto_counters
Ada
5,387
ads
-- unique_ptrs.ads -- A "unique pointer" type similar to that in C++ -- Copyright (c) 2016-2023, 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.Finalization; generic type T (<>) is limited private; with procedure Delete (X : in out T) is null; package Unique_Ptrs is type T_Ptr is access T; subtype T_Ptr_Not_Null is not null T_Ptr; type T_Const_Ptr is access constant T; Unique_Ptr_Error : exception; -- Unique_Ptr_Error indicates an attempt to create a null Unique_Ptr or an -- attempt to create one directly without going through the Make_Unique_Ptr -- function. type Unique_Ptr(Element : not null access T) is new Ada.Finalization.Limited_Controlled with private with Implicit_Dereference => Element; -- Unique_Ptr is an implementation of a generalised reference type that -- automatically releases the storage associated with the underlying value -- when the Unique_Ptr is destroyed. Unique_Ptr can only point to values -- created in a storage pool, not static values or local stack values. function Get (U : in Unique_Ptr) return T_Ptr with Inline; -- Returns a named access value that points to the target of the Unique_Ptr. -- This should not be saved as it can become invalid without warning when -- the original Unique_Ptr is destroyed. In particular do not attempt to -- duplicate Unique_Ptr by passing the result to Make_Unique_Ptr as the -- result will be erroneous. function Make_Unique_Ptr (X : T_Ptr_Not_Null) return Unique_Ptr with Inline; -- Make_Unique_Ptr creates a Unique_Ptr from an access value to an object -- stored in a pool. Note that mixing the use of regular access values and -- Unique_Ptr types is not wise, as the storage may be reclaimed when the -- Unique_Ptr is destroyed, leaving the access values invalid. type Unique_Const_Ptr(Element : not null access constant T) is new Ada.Finalization.Limited_Controlled with private with Implicit_Dereference => Element; -- Unique_Const_Ptr is an implementation of a generalised reference type -- that automatically releases the storage associated with the underlying -- constant value when the Unique_Ptr is destroyed. Unique_Const_Ptr can -- only point to values created in a storage pool, not static values or -- local stack values. function Get (U : in Unique_Const_Ptr) return T_Const_Ptr with Inline; -- Returns a named access to constant value that points to the target of the -- Unique_Const_Ptr. This should not be saved as it can become invalid -- without warning when the original Unique_Const_Ptr is destroyed. function Make_Unique_Const_Ptr (X : T_Ptr_Not_Null) return Unique_Const_Ptr with Inline; -- Make_Unique_Const_Ptr creates a Unique_Const_Ptr from an access value to -- an object stored in a pool. Note that mixing the use of regular access -- values and Unique_Const_Ptr types is not wise, as the storage may be -- reclaimed when the Unique_Const_Ptr is destroyed, leaving the access -- values invalid. -- -- Unique_Const_Ptr differs from a regular access-to-const type in that -- it must be able to call the Delete function and destroy the storage -- associated with the target. Therefore they can only point at variables, -- not constants. private -- Note - These definitions store the pointer twice. It is necessary -- to have access discriminants in order to have the syntaxic sugar of -- Implicit_Dereference. However, an anonymous access discriminant of this -- type will trigger runtime access scope checks when a program is compiled -- with these checks enabled. These checks will typically fail anytime an -- attempt is used to convert them to the T_Ptr or T_Const_Ptr types, even -- when an Unchecked_Conversion is used (at least in recent versions of -- GNAT). The only solution I have found so far is to store the pointer -- twice. type Unique_Ptr(Element : not null access T) is new Ada.Finalization.Limited_Controlled with record Underlying_Element : T_Ptr; end record; overriding procedure Initialize (Object : in out Unique_Ptr); overriding procedure Finalize (Object : in out Unique_Ptr); type Unique_Const_Ptr(Element : not null access constant T) is new Ada.Finalization.Limited_Controlled with record Underlying_Element : T_Const_Ptr; end record; overriding procedure Initialize (Object : in out Unique_Const_Ptr); overriding procedure Finalize (Object : in out Unique_Const_Ptr); end Unique_Ptrs;
burratoo/Acton
Ada
1,155
adb
------------------------------------------------------------------------------------------ -- -- -- ACTON PROCESSOR SUPPORT PACKAGE -- -- ST STM32F4 -- -- -- -- GNAT_EXCEPTION -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package body GNAT_Exception is procedure Last_Chance_Handler (Msg : System.Address; Line : Integer) is pragma Unreferenced (Msg, Line); begin loop null; end loop; end Last_Chance_Handler; end GNAT_Exception;
Fabien-Chouteau/samd51-hal
Ada
26,251
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.DAC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Control A type DAC_CTRLA_Register is record -- Software Reset SWRST : Boolean := False; -- Enable DAC Controller ENABLE : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_CTRLA_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; end record; -- Reference Selection for DAC0/1 type CTRLB_REFSELSelect is (-- External reference unbuffered VREFPU, -- Analog supply VDDANA, -- External reference buffered VREFPB, -- Internal bandgap reference INTREF) with Size => 2; for CTRLB_REFSELSelect use (VREFPU => 0, VDDANA => 1, VREFPB => 2, INTREF => 3); -- Control B type DAC_CTRLB_Register is record -- Differential mode enable DIFF : Boolean := False; -- Reference Selection for DAC0/1 REFSEL : CTRLB_REFSELSelect := SAM_SVD.DAC.VDDANA; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_CTRLB_Register use record DIFF at 0 range 0 .. 0; REFSEL at 0 range 1 .. 2; Reserved_3_7 at 0 range 3 .. 7; end record; -- DAC_EVCTRL_STARTEI array type DAC_EVCTRL_STARTEI_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_EVCTRL_STARTEI type DAC_EVCTRL_STARTEI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- STARTEI as a value Val : HAL.UInt2; when True => -- STARTEI as an array Arr : DAC_EVCTRL_STARTEI_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_EVCTRL_STARTEI_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_EVCTRL_EMPTYEO array type DAC_EVCTRL_EMPTYEO_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_EVCTRL_EMPTYEO type DAC_EVCTRL_EMPTYEO_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EMPTYEO as a value Val : HAL.UInt2; when True => -- EMPTYEO as an array Arr : DAC_EVCTRL_EMPTYEO_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_EVCTRL_EMPTYEO_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_EVCTRL_INVEI array type DAC_EVCTRL_INVEI_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_EVCTRL_INVEI type DAC_EVCTRL_INVEI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- INVEI as a value Val : HAL.UInt2; when True => -- INVEI as an array Arr : DAC_EVCTRL_INVEI_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_EVCTRL_INVEI_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_EVCTRL_RESRDYEO array type DAC_EVCTRL_RESRDYEO_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_EVCTRL_RESRDYEO type DAC_EVCTRL_RESRDYEO_Field (As_Array : Boolean := False) is record case As_Array is when False => -- RESRDYEO as a value Val : HAL.UInt2; when True => -- RESRDYEO as an array Arr : DAC_EVCTRL_RESRDYEO_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_EVCTRL_RESRDYEO_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Event Control type DAC_EVCTRL_Register is record -- Start Conversion Event Input DAC 0 STARTEI : DAC_EVCTRL_STARTEI_Field := (As_Array => False, Val => 16#0#); -- Data Buffer Empty Event Output DAC 0 EMPTYEO : DAC_EVCTRL_EMPTYEO_Field := (As_Array => False, Val => 16#0#); -- Enable Invertion of DAC 0 input event INVEI : DAC_EVCTRL_INVEI_Field := (As_Array => False, Val => 16#0#); -- Result Ready Event Output 0 RESRDYEO : DAC_EVCTRL_RESRDYEO_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_EVCTRL_Register use record STARTEI at 0 range 0 .. 1; EMPTYEO at 0 range 2 .. 3; INVEI at 0 range 4 .. 5; RESRDYEO at 0 range 6 .. 7; end record; -- DAC_INTENCLR_UNDERRUN array type DAC_INTENCLR_UNDERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENCLR_UNDERRUN type DAC_INTENCLR_UNDERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- UNDERRUN as a value Val : HAL.UInt2; when True => -- UNDERRUN as an array Arr : DAC_INTENCLR_UNDERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENCLR_UNDERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENCLR_EMPTY array type DAC_INTENCLR_EMPTY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENCLR_EMPTY type DAC_INTENCLR_EMPTY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EMPTY as a value Val : HAL.UInt2; when True => -- EMPTY as an array Arr : DAC_INTENCLR_EMPTY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENCLR_EMPTY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENCLR_RESRDY array type DAC_INTENCLR_RESRDY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENCLR_RESRDY type DAC_INTENCLR_RESRDY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- RESRDY as a value Val : HAL.UInt2; when True => -- RESRDY as an array Arr : DAC_INTENCLR_RESRDY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENCLR_RESRDY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENCLR_OVERRUN array type DAC_INTENCLR_OVERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENCLR_OVERRUN type DAC_INTENCLR_OVERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- OVERRUN as a value Val : HAL.UInt2; when True => -- OVERRUN as an array Arr : DAC_INTENCLR_OVERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENCLR_OVERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Enable Clear type DAC_INTENCLR_Register is record -- Underrun 0 Interrupt Enable UNDERRUN : DAC_INTENCLR_UNDERRUN_Field := (As_Array => False, Val => 16#0#); -- Data Buffer 0 Empty Interrupt Enable EMPTY : DAC_INTENCLR_EMPTY_Field := (As_Array => False, Val => 16#0#); -- Result 0 Ready Interrupt Enable RESRDY : DAC_INTENCLR_RESRDY_Field := (As_Array => False, Val => 16#0#); -- Overrun 0 Interrupt Enable OVERRUN : DAC_INTENCLR_OVERRUN_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_INTENCLR_Register use record UNDERRUN at 0 range 0 .. 1; EMPTY at 0 range 2 .. 3; RESRDY at 0 range 4 .. 5; OVERRUN at 0 range 6 .. 7; end record; -- DAC_INTENSET_UNDERRUN array type DAC_INTENSET_UNDERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENSET_UNDERRUN type DAC_INTENSET_UNDERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- UNDERRUN as a value Val : HAL.UInt2; when True => -- UNDERRUN as an array Arr : DAC_INTENSET_UNDERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENSET_UNDERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENSET_EMPTY array type DAC_INTENSET_EMPTY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENSET_EMPTY type DAC_INTENSET_EMPTY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EMPTY as a value Val : HAL.UInt2; when True => -- EMPTY as an array Arr : DAC_INTENSET_EMPTY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENSET_EMPTY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENSET_RESRDY array type DAC_INTENSET_RESRDY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENSET_RESRDY type DAC_INTENSET_RESRDY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- RESRDY as a value Val : HAL.UInt2; when True => -- RESRDY as an array Arr : DAC_INTENSET_RESRDY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENSET_RESRDY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTENSET_OVERRUN array type DAC_INTENSET_OVERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTENSET_OVERRUN type DAC_INTENSET_OVERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- OVERRUN as a value Val : HAL.UInt2; when True => -- OVERRUN as an array Arr : DAC_INTENSET_OVERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTENSET_OVERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Enable Set type DAC_INTENSET_Register is record -- Underrun 0 Interrupt Enable UNDERRUN : DAC_INTENSET_UNDERRUN_Field := (As_Array => False, Val => 16#0#); -- Data Buffer 0 Empty Interrupt Enable EMPTY : DAC_INTENSET_EMPTY_Field := (As_Array => False, Val => 16#0#); -- Result 0 Ready Interrupt Enable RESRDY : DAC_INTENSET_RESRDY_Field := (As_Array => False, Val => 16#0#); -- Overrun 0 Interrupt Enable OVERRUN : DAC_INTENSET_OVERRUN_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_INTENSET_Register use record UNDERRUN at 0 range 0 .. 1; EMPTY at 0 range 2 .. 3; RESRDY at 0 range 4 .. 5; OVERRUN at 0 range 6 .. 7; end record; -- DAC_INTFLAG_UNDERRUN array type DAC_INTFLAG_UNDERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTFLAG_UNDERRUN type DAC_INTFLAG_UNDERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- UNDERRUN as a value Val : HAL.UInt2; when True => -- UNDERRUN as an array Arr : DAC_INTFLAG_UNDERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTFLAG_UNDERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTFLAG_EMPTY array type DAC_INTFLAG_EMPTY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTFLAG_EMPTY type DAC_INTFLAG_EMPTY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EMPTY as a value Val : HAL.UInt2; when True => -- EMPTY as an array Arr : DAC_INTFLAG_EMPTY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTFLAG_EMPTY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTFLAG_RESRDY array type DAC_INTFLAG_RESRDY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTFLAG_RESRDY type DAC_INTFLAG_RESRDY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- RESRDY as a value Val : HAL.UInt2; when True => -- RESRDY as an array Arr : DAC_INTFLAG_RESRDY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTFLAG_RESRDY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_INTFLAG_OVERRUN array type DAC_INTFLAG_OVERRUN_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_INTFLAG_OVERRUN type DAC_INTFLAG_OVERRUN_Field (As_Array : Boolean := False) is record case As_Array is when False => -- OVERRUN as a value Val : HAL.UInt2; when True => -- OVERRUN as an array Arr : DAC_INTFLAG_OVERRUN_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_INTFLAG_OVERRUN_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Interrupt Flag Status and Clear type DAC_INTFLAG_Register is record -- Result 0 Underrun UNDERRUN : DAC_INTFLAG_UNDERRUN_Field := (As_Array => False, Val => 16#0#); -- Data Buffer 0 Empty EMPTY : DAC_INTFLAG_EMPTY_Field := (As_Array => False, Val => 16#0#); -- Result 0 Ready RESRDY : DAC_INTFLAG_RESRDY_Field := (As_Array => False, Val => 16#0#); -- Result 0 Overrun OVERRUN : DAC_INTFLAG_OVERRUN_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_INTFLAG_Register use record UNDERRUN at 0 range 0 .. 1; EMPTY at 0 range 2 .. 3; RESRDY at 0 range 4 .. 5; OVERRUN at 0 range 6 .. 7; end record; -- DAC_STATUS_READY array type DAC_STATUS_READY_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_STATUS_READY type DAC_STATUS_READY_Field (As_Array : Boolean := False) is record case As_Array is when False => -- READY as a value Val : HAL.UInt2; when True => -- READY as an array Arr : DAC_STATUS_READY_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_STATUS_READY_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_STATUS_EOC array type DAC_STATUS_EOC_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_STATUS_EOC type DAC_STATUS_EOC_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EOC as a value Val : HAL.UInt2; when True => -- EOC as an array Arr : DAC_STATUS_EOC_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_STATUS_EOC_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Status type DAC_STATUS_Register is record -- Read-only. DAC 0 Startup Ready READY : DAC_STATUS_READY_Field; -- Read-only. DAC 0 End of Conversion EOC : DAC_STATUS_EOC_Field; -- unspecified Reserved_4_7 : HAL.UInt4; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_STATUS_Register use record READY at 0 range 0 .. 1; EOC at 0 range 2 .. 3; Reserved_4_7 at 0 range 4 .. 7; end record; -- DAC_SYNCBUSY_DATA array type DAC_SYNCBUSY_DATA_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_SYNCBUSY_DATA type DAC_SYNCBUSY_DATA_Field (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.UInt2; when True => -- DATA as an array Arr : DAC_SYNCBUSY_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_SYNCBUSY_DATA_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- DAC_SYNCBUSY_DATABUF array type DAC_SYNCBUSY_DATABUF_Field_Array is array (0 .. 1) of Boolean with Component_Size => 1, Size => 2; -- Type definition for DAC_SYNCBUSY_DATABUF type DAC_SYNCBUSY_DATABUF_Field (As_Array : Boolean := False) is record case As_Array is when False => -- DATABUF as a value Val : HAL.UInt2; when True => -- DATABUF as an array Arr : DAC_SYNCBUSY_DATABUF_Field_Array; end case; end record with Unchecked_Union, Size => 2; for DAC_SYNCBUSY_DATABUF_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- Synchronization Busy type DAC_SYNCBUSY_Register is record -- Read-only. Software Reset SWRST : Boolean; -- Read-only. DAC Enable Status ENABLE : Boolean; -- Read-only. Data DAC 0 DATA : DAC_SYNCBUSY_DATA_Field; -- Read-only. Data Buffer DAC 0 DATABUF : DAC_SYNCBUSY_DATABUF_Field; -- unspecified Reserved_6_31 : HAL.UInt26; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DAC_SYNCBUSY_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; DATA at 0 range 2 .. 3; DATABUF at 0 range 4 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- Current Control type DACCTRL_CCTRLSelect is (-- 100kSPS CC100K, -- 500kSPS CC1M, -- 1MSPS CC12M) with Size => 2; for DACCTRL_CCTRLSelect use (CC100K => 0, CC1M => 1, CC12M => 2); -- Refresh period type DACCTRL_REFRESHSelect is (-- Do not Refresh REFRESH_0, -- Refresh every 30 us REFRESH_1, -- Refresh every 60 us REFRESH_2, -- Refresh every 90 us REFRESH_3, -- Refresh every 120 us REFRESH_4, -- Refresh every 150 us REFRESH_5, -- Refresh every 180 us REFRESH_6, -- Refresh every 210 us REFRESH_7, -- Refresh every 240 us REFRESH_8, -- Refresh every 270 us REFRESH_9, -- Refresh every 300 us REFRESH_10, -- Refresh every 330 us REFRESH_11, -- Refresh every 360 us REFRESH_12, -- Refresh every 390 us REFRESH_13, -- Refresh every 420 us REFRESH_14, -- Refresh every 450 us REFRESH_15) with Size => 4; for DACCTRL_REFRESHSelect use (REFRESH_0 => 0, REFRESH_1 => 1, REFRESH_2 => 2, REFRESH_3 => 3, REFRESH_4 => 4, REFRESH_5 => 5, REFRESH_6 => 6, REFRESH_7 => 7, REFRESH_8 => 8, REFRESH_9 => 9, REFRESH_10 => 10, REFRESH_11 => 11, REFRESH_12 => 12, REFRESH_13 => 13, REFRESH_14 => 14, REFRESH_15 => 15); -- Sampling Rate type DACCTRL_OSRSelect is (-- No Over Sampling OSR_1, -- 2x Over Sampling Ratio OSR_2, -- 4x Over Sampling Ratio OSR_4, -- 8x Over Sampling Ratio OSR_8, -- 16x Over Sampling Ratio OSR_16, -- 32x Over Sampling Ratio OSR_32) with Size => 3; for DACCTRL_OSRSelect use (OSR_1 => 0, OSR_2 => 1, OSR_4 => 2, OSR_8 => 3, OSR_16 => 4, OSR_32 => 5); -- DAC n Control type DAC_DACCTRL_Register is record -- Left Adjusted Data LEFTADJ : Boolean := False; -- Enable DAC0 ENABLE : Boolean := False; -- Current Control CCTRL : DACCTRL_CCTRLSelect := SAM_SVD.DAC.CC100K; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- Standalone Filter FEXT : Boolean := False; -- Run in Standby RUNSTDBY : Boolean := False; -- Dithering Mode DITHER : Boolean := False; -- Refresh period REFRESH : DACCTRL_REFRESHSelect := SAM_SVD.DAC.REFRESH_0; -- unspecified Reserved_12_12 : HAL.Bit := 16#0#; -- Sampling Rate OSR : DACCTRL_OSRSelect := SAM_SVD.DAC.OSR_1; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for DAC_DACCTRL_Register use record LEFTADJ at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CCTRL at 0 range 2 .. 3; Reserved_4_4 at 0 range 4 .. 4; FEXT at 0 range 5 .. 5; RUNSTDBY at 0 range 6 .. 6; DITHER at 0 range 7 .. 7; REFRESH at 0 range 8 .. 11; Reserved_12_12 at 0 range 12 .. 12; OSR at 0 range 13 .. 15; end record; -- DAC n Control type DAC_DACCTRL_Registers is array (0 .. 1) of DAC_DACCTRL_Register; -- DAC n Data -- DAC n Data type DAC_DATA_Registers is array (0 .. 1) of HAL.UInt16; -- DAC n Data Buffer -- DAC n Data Buffer type DAC_DATABUF_Registers is array (0 .. 1) of HAL.UInt16; -- Debug Control type DAC_DBGCTRL_Register is record -- Debug Run DBGRUN : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for DAC_DBGCTRL_Register use record DBGRUN at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- Filter Result -- Filter Result type DAC_RESULT_Registers is array (0 .. 1) of HAL.UInt16; ----------------- -- Peripherals -- ----------------- -- Digital-to-Analog Converter type DAC_Peripheral is record -- Control A CTRLA : aliased DAC_CTRLA_Register; -- Control B CTRLB : aliased DAC_CTRLB_Register; -- Event Control EVCTRL : aliased DAC_EVCTRL_Register; -- Interrupt Enable Clear INTENCLR : aliased DAC_INTENCLR_Register; -- Interrupt Enable Set INTENSET : aliased DAC_INTENSET_Register; -- Interrupt Flag Status and Clear INTFLAG : aliased DAC_INTFLAG_Register; -- Status STATUS : aliased DAC_STATUS_Register; -- Synchronization Busy SYNCBUSY : aliased DAC_SYNCBUSY_Register; -- DAC n Control DACCTRL : aliased DAC_DACCTRL_Registers; -- DAC n Data DATA : aliased DAC_DATA_Registers; -- DAC n Data Buffer DATABUF : aliased DAC_DATABUF_Registers; -- Debug Control DBGCTRL : aliased DAC_DBGCTRL_Register; -- Filter Result RESULT : aliased DAC_RESULT_Registers; end record with Volatile; for DAC_Peripheral use record CTRLA at 16#0# range 0 .. 7; CTRLB at 16#1# range 0 .. 7; EVCTRL at 16#2# range 0 .. 7; INTENCLR at 16#4# range 0 .. 7; INTENSET at 16#5# range 0 .. 7; INTFLAG at 16#6# range 0 .. 7; STATUS at 16#7# range 0 .. 7; SYNCBUSY at 16#8# range 0 .. 31; DACCTRL at 16#C# range 0 .. 31; DATA at 16#10# range 0 .. 31; DATABUF at 16#14# range 0 .. 31; DBGCTRL at 16#18# range 0 .. 7; RESULT at 16#1C# range 0 .. 31; end record; -- Digital-to-Analog Converter DAC_Periph : aliased DAC_Peripheral with Import, Address => DAC_Base; end SAM_SVD.DAC;
AdaCore/libadalang
Ada
295
adb
with Vector; procedure Main is package My_Vector is new Vector (Integer); package My_Vector_2 is new Vector (Float); use My_Vector; use My_Vector_2; begin declare V : My_Vector.Vector'Class := Create; begin V.Append (12); end; pragma Test_Block; end Main;
zhmu/ananas
Ada
468
adb
-- { dg-do compile } with System; procedure Addr10 is type Limited_Type is limited record Element : Integer; end record; function Initial_State return Limited_Type is ((Element => 0)); type Double_Limited_Type is record A : Limited_Type; end record; Double_Limited : Double_Limited_Type := (A => Initial_State) with Volatile, Address => System'To_Address (16#1234_5678#); begin null; end Addr10;
reznikmm/matreshka
Ada
11,831
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-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 WebAPI.DOM.Event_Targets; with WebAPI.HTML.Documents; with WebAPI.HTML.Frame_Request_Callbacks; package WebAPI.HTML.Windows is pragma Preelaborate; type Window is limited interface and WebAPI.DOM.Event_Targets.Event_Target; type Window_Access is access all Window'Class with Storage_Size => 0; not overriding function Get_Document (Self : not null access Window) return WebAPI.HTML.Documents.Document_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "document"; -- APIs for creating and navigating browsing contexts by name not overriding function Open (Self : not null access WebAPI.HTML.Windows.Window; URL : WebAPI.DOM_String; Name : WebAPI.DOM_String; Features : WebAPI.DOM_String) return WebAPI.HTML.Windows.Window_Access is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "open"; -- Opens a window to show url (defaults to about:blank), and returns it. -- The target argument gives the name of the new window. If a window -- exists with that name already, it is reused. The features argument -- can be used to influence the rendering of the new window. not overriding function Get_Name (Self : not null access Window) return WebAPI.DOM_String is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "name"; -- Returns the name of the window. Can be set, to change the name. not overriding procedure Set_Name (Self : not null access Window; Value : WebAPI.DOM_String) is abstract with Import => True, Convention => JavaScript_Property_Setter, Link_Name => "name"; not overriding procedure Close (Self : not null access WebAPI.HTML.Windows.Window) is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "close"; -- Closes the window. not overriding function Get_Closed (Self : not null access Window) return WebAPI.DOM_Boolean is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "closed"; -- Returns true if the window has been closed, false otherwise. not overriding procedure Stop (Self : not null access WebAPI.HTML.Windows.Window) is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "stop"; -- Cancels the document load. -- other browsing contexts not overriding function Get_Opener (Self : not null access Window) return WebAPI.HTML.Windows.Window_Access is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "opener"; -- The opener IDL attribute on the Window object, on getting, must return -- the WindowProxy object of the browsing context from which the current -- browsing context was created (its opener browsing context), if there is -- one, if it is still available, and if the current browsing context has -- not disowned its opener; otherwise, it must return null. not overriding procedure Set_Opener (Self : not null access Window; Value : WebAPI.HTML.Windows.Window_Access) is abstract with Import => True, Convention => JavaScript_Property_Setter, Link_Name => "opener"; -- On setting, if the new value is null then the current browsing context -- must disown its opener; function Request_Animation_Frame (Self : not null access Window'Class; Callback : not null access WebAPI.HTML.Frame_Request_Callbacks.Frame_Request_Callback'Class) return WebAPI.DOM_Long with Import => True, Convention => JavaScript_Function, Link_Name => "_ec._requestAnimationFrame"; procedure Request_Animation_Frame (Self : not null access Window'Class; Callback : not null access WebAPI.HTML.Frame_Request_Callbacks.Frame_Request_Callback'Class) with Import => True, Convention => JavaScript_Function, Link_Name => "_ec._requestAnimationFrame"; -- This subprogram is used to signal to the user agent that a script-based -- animation needs to be resampled. not overriding procedure Cancel_Animation_Frame (Self : not null access Window; Handle : WebAPI.DOM_Long) is abstract with Import => True, Convention => JavaScript_Method, Link_Name => "cancelAnimationFrame"; -- This subprogram is used to cancel a previously made request to schedule -- an animation frame update. ---------------------------------- -- CSSOM View Module extensions -- ---------------------------------- -- [NewObject] MediaQueryList matchMedia(DOMString query); -- [SameObject, Replaceable] readonly attribute Screen screen; -- -- // browsing context -- void moveTo(long x, long y); -- void moveBy(long x, long y); -- void resizeTo(long x, long y); -- void resizeBy(long x, long y); not overriding function Get_Inner_Width (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "innerWidth"; not overriding function Get_Inner_Height (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "innerHeight"; not overriding function Get_Scroll_X (Self : not null access Window) return WebAPI.DOM_Double is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "scrollX"; not overriding function Get_Page_X_Offset (Self : not null access Window) return WebAPI.DOM_Double is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "pageXOffset"; not overriding function Get_Scroll_Y (Self : not null access Window) return WebAPI.DOM_Double is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "scrollY"; not overriding function Get_Page_Y_Offset (Self : not null access Window) return WebAPI.DOM_Double is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "pageYOffset"; -- void scroll(optional ScrollToOptions options); -- void scroll(unrestricted double x, unrestricted double y); -- void scrollTo(optional ScrollToOptions options); -- void scrollTo(unrestricted double x, unrestricted double y); -- void scrollBy(optional ScrollToOptions options); -- void scrollBy(unrestricted double x, unrestricted double y); not overriding function Get_Screen_X (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "screenX"; not overriding function Get_Screen_Y (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "screenY"; not overriding function Get_Outer_Width (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "outerWidth"; not overriding function Get_Outer_Height (Self : not null access Window) return WebAPI.DOM_Long is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "outerHeight"; not overriding function Get_Device_Pixel_Ratio (Self : not null access Window) return WebAPI.DOM_Double is abstract with Import => True, Convention => JavaScript_Property_Getter, Link_Name => "devicePixelRatio"; end WebAPI.HTML.Windows;
AdaCore/spat
Ada
73,903
adb
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); with Ada.Directories; with Ada.Strings.Fixed; with SPAT.Entity_Line; with SPAT.Entity_Location; with SPAT.Field_Names; with SPAT.Flow_Item; with SPAT.Log; with SPAT.Preconditions; with SPAT.Proof_Item; with SPAT.Strings; package body SPAT.Spark_Info is use type Ada.Containers.Count_Type; use type Analyzed_Entities.Cursor; -- Make JSON type enumeration literals directly visible. use all type GNATCOLL.JSON.JSON_Value_Type; --------------------------------------------------------------------------- -- Subprogram prototypes. --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- Get_Sentinel (Flows) --------------------------------------------------------------------------- function Get_Sentinel (Node : in Analyzed_Entities.Constant_Reference_Type) return Flows_Sentinel; --------------------------------------------------------------------------- -- Get_Sentinel (Proofs) --------------------------------------------------------------------------- function Get_Sentinel (Node : in Analyzed_Entities.Constant_Reference_Type) return Proofs_Sentinel; --------------------------------------------------------------------------- -- Guess_Version -- -- Checks for presence of certain fields that are presumed version -- specific. --------------------------------------------------------------------------- function Guess_Version (Name : in String; Root : in JSON_Value) return File_Version; --------------------------------------------------------------------------- -- Map_Assumptions_Elements --------------------------------------------------------------------------- procedure Map_Assumptions_Elements (This : in out T; Root : in JSON_Array); --------------------------------------------------------------------------- -- Map_Entities --------------------------------------------------------------------------- procedure Map_Entities (This : in out T; Root : in JSON_Value; From_File : in File_Sets.Cursor) with Pre => (Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Name, Kind => JSON_String_Type) and then Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Sloc, Kind => JSON_Array_Type)); --------------------------------------------------------------------------- -- Map_Flow_Elements --------------------------------------------------------------------------- procedure Map_Flow_Elements (This : in out T; Root : in JSON_Array); --------------------------------------------------------------------------- -- Map_Proof_Elements --------------------------------------------------------------------------- procedure Map_Proof_Elements (This : in out T; Version : in File_Version; Root : in JSON_Array; Cache_Cursor : in File_Cached_Info.Cursor); --------------------------------------------------------------------------- -- Map_Sloc_Elements --------------------------------------------------------------------------- procedure Map_Sloc_Elements (This : in out T; The_Tree : in out Entity.Tree.T; Position : in Entity.Tree.Cursor; Root : in JSON_Array); --------------------------------------------------------------------------- -- Map_Spark_Elements --------------------------------------------------------------------------- procedure Map_Spark_Elements (This : in out T; Root : in JSON_Array; From_File : in File_Sets.Cursor); --------------------------------------------------------------------------- -- Map_Timings --------------------------------------------------------------------------- procedure Map_Timings (This : in out T; File : in SPARK_File_Name; Root : in JSON_Value; Version : in File_Version); --------------------------------------------------------------------------- -- Sort_Entity_By_Name -- -- Sort code entities by their name. -- Sorting: alphabetical, ascending --------------------------------------------------------------------------- procedure Sort_Entity_By_Name (This : in T; Container : in out Strings.Entity_Names); --------------------------------------------------------------------------- -- Sort_Entity_By_Proof_Steps -- -- Sort code entities by how much maximum proof steps they required. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Proof_Steps (This : in T; Container : in out Strings.Entity_Names); --------------------------------------------------------------------------- -- Sort_Entity_By_Proof_Time -- -- Sort code entities by how much total proof time they required. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Proof_Time (This : in T; Container : in out Strings.Entity_Names); --------------------------------------------------------------------------- -- Sort_Entity_By_Success_Steps -- -- Sort code entities by how many maximum steps for a successful proofs. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Success_Steps (This : in T; Container : in out Strings.Entity_Names); --------------------------------------------------------------------------- -- Sort_Entity_By_Success_Time -- -- Sort code entities by how much maximum time for a successful proofs. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Success_Time (This : in T; Container : in out Strings.Entity_Names); --------------------------------------------------------------------------- -- Sort_File_By_Basename -- -- Sort files by their base name (i.e. without containing directory or -- extension). -- Sorting: alphabetical, ascending --------------------------------------------------------------------------- procedure Sort_File_By_Basename (This : in T; Container : in out Strings.SPARK_File_Names); --------------------------------------------------------------------------- -- Sort_File_By_Proof_Time -- -- Sort files by how much total time it required to spend in flow analysis -- and proof. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_File_By_Proof_Time (This : in T; Container : in out Strings.SPARK_File_Names); --------------------------------------------------------------------------- -- Sort_File_By_Steps -- -- Sort files by how much maximum steps were done in proof. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_File_By_Steps (This : in T; Container : in out Strings.SPARK_File_Names); --------------------------------------------------------------------------- -- Sort_File_By_Max_Success_Steps -- -- Sort files by minimum steps required for successful proof. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_File_By_Max_Success_Steps (This : in T; Container : in out Strings.SPARK_File_Names); --------------------------------------------------------------------------- -- Sort_File_By_Max_Success_Time -- -- Sort files by minimum time required for successful proof. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_File_By_Max_Success_Time (This : in T; Container : in out Strings.SPARK_File_Names); --------------------------------------------------------------------------- -- Subprogram implementations --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- Flow_Time --------------------------------------------------------------------------- not overriding function Flow_Time (This : in T; File : in SPARK_File_Name) return Duration is (This.Timings (File).Flow); --------------------------------------------------------------------------- -- Get_Sentinel (Flows) --------------------------------------------------------------------------- function Get_Sentinel (Node : in Analyzed_Entities.Constant_Reference_Type) return Flows_Sentinel is (Flows_Sentinel (SPAT.Entity.Tree.Element (Position => Node.Flows))); --------------------------------------------------------------------------- -- Get_Sentinel (Proofs) --------------------------------------------------------------------------- function Get_Sentinel (Node : in Analyzed_Entities.Constant_Reference_Type) return Proofs_Sentinel is (Proofs_Sentinel (SPAT.Entity.Tree.Element (Position => Node.Proofs))); --------------------------------------------------------------------------- -- Guess_Version --------------------------------------------------------------------------- function Guess_Version (Name : in String; Root : in JSON_Value) return File_Version is Result : File_Version := GNAT_CE_2019; begin if Root.Has_Field (Field => Field_Names.Session_Map) then -- "session_map" seems new in CE 2020. Result := GNAT_CE_2020; elsif Root.Has_Field (Field => Field_Names.Timings) then declare Timings : constant GNATCOLL.JSON.JSON_Value := Root.Get (Field => Field_Names.Timings); begin if Timings.Has_Field (Field => Field_Names.Translation_Of_Compilation_Unit) then -- This field seems to have disappeared in GNAT CE 2020, so if -- it is present, we assume GNAT CE 2019. Result := GNAT_CE_2019; else Result := GNAT_CE_2020; end if; end; end if; Log.Debug (Message => "Detected file version of """ & Ada.Directories.Simple_Name (Name => Name) & """ is " & Result'Image & "."); return Result; end Guess_Version; --------------------------------------------------------------------------- -- Has_Failed_Attempts --------------------------------------------------------------------------- not overriding function Has_Failed_Attempts (This : in T; Entity : in Entity_Name) return Boolean is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Has_Failed_Attempts; end Has_Failed_Attempts; --------------------------------------------------------------------------- -- Has_Unjustified_Attempts --------------------------------------------------------------------------- not overriding function Has_Unjustified_Attempts (This : in T; Entity : in Entity_Name) return Boolean is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Has_Unjustified_Attempts; end Has_Unjustified_Attempts; --------------------------------------------------------------------------- -- Has_Unproved_Attempts --------------------------------------------------------------------------- not overriding function Has_Unproved_Attempts (This : in T; Entity : in Entity_Name) return Boolean is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Has_Unproved_Attempts; end Has_Unproved_Attempts; --------------------------------------------------------------------------- -- Iterate_Children --------------------------------------------------------------------------- not overriding function Iterate_Children (This : in T; Entity : in Entity_Name; Position : in SPAT.Entity.Tree.Cursor) return SPAT.Entity.Tree.Forward_Iterator'Class is begin return This.Entities (Entity).The_Tree.Iterate_Children (Parent => Position); end Iterate_Children; --------------------------------------------------------------------------- -- List_All_Entities --------------------------------------------------------------------------- not overriding function List_All_Entities (This : in T; Sort_By : in Sorting_Criterion := Name) return Strings.Entity_Names is begin return Result : Strings.Entity_Names (Capacity => This.Entities.Length) do for Position in This.Entities.Iterate loop Result.Append (New_Item => Analyzed_Entities.Key (Position => Position)); end loop; case Sort_By is when None => null; when Name => This.Sort_Entity_By_Name (Container => Result); when Max_Success_Time => This.Sort_Entity_By_Success_Time (Container => Result); when Max_Time => This.Sort_Entity_By_Proof_Time (Container => Result); when Max_Success_Steps => This.Sort_Entity_By_Success_Steps (Container => Result); when Max_Steps => This.Sort_Entity_By_Proof_Steps (Container => Result); end case; end return; end List_All_Entities; --------------------------------------------------------------------------- -- List_All_Files --------------------------------------------------------------------------- not overriding function List_All_Files (This : in T; Sort_By : in Sorting_Criterion := None) return Strings.SPARK_File_Names is begin return Result : Strings.SPARK_File_Names (Capacity => This.Files.Length) do for File of This.Files loop Result.Append (New_Item => File); end loop; case Sort_By is when None => null; when Name => This.Sort_File_By_Basename (Container => Result); when Max_Success_Time => This.Sort_File_By_Max_Success_Time (Container => Result); when Max_Time => This.Sort_File_By_Proof_Time (Container => Result); when Max_Success_Steps => This.Sort_File_By_Max_Success_Steps (Container => Result); when Max_Steps => This.Sort_File_By_Steps (Container => Result); end case; end return; end List_All_Files; --------------------------------------------------------------------------- -- Map_Assumptions_Elements --------------------------------------------------------------------------- procedure Map_Assumptions_Elements (This : in out T; Root : in JSON_Array) is begin -- TODO: Add all elements from the "assumptions" array. null; end Map_Assumptions_Elements; --------------------------------------------------------------------------- -- Map_Entities --------------------------------------------------------------------------- procedure Map_Entities (This : in out T; Root : in JSON_Value; From_File : in File_Sets.Cursor) is Obj_Name : constant Entity_Name := Entity_Name (Subject_Name'(Root.Get (Field => Field_Names.Name))); Slocs : constant JSON_Array := Root.Get (Field => Field_Names.Sloc); Index : Analyzed_Entities.Cursor := This.Entities.Find (Key => Obj_Name); begin if Index = Analyzed_Entities.No_Element then declare Element : Analyzed_Entity; Dummy_Inserted : Boolean; begin Element.SPARK_File := From_File; This.Entities.Insert (Key => Obj_Name, New_Item => Element, Position => Index, Inserted => Dummy_Inserted); end; end if; declare Reference : constant Analyzed_Entities.Reference_Type := This.Entities.Reference (Position => Index); use type Entity.Tree.Cursor; begin -- Add sentinel(s) if not yet present. if Reference.Source_Lines = Entity.Tree.No_Element then Reference.The_Tree.Insert_Child (Parent => Reference.The_Tree.Root, Before => Entity.Tree.No_Element, New_Item => Source_Lines_Sentinel'(Entity.T with null record), Position => Reference.Source_Lines); end if; if Reference.Flows = Entity.Tree.No_Element then Reference.The_Tree.Insert_Child (Parent => Reference.The_Tree.Root, Before => Entity.Tree.No_Element, New_Item => Empty_Flows_Sentinel, Position => Reference.Flows); end if; if Reference.Proofs = Entity.Tree.No_Element then Reference.The_Tree.Insert_Child (Parent => Reference.The_Tree.Root, Before => Entity.Tree.No_Element, New_Item => Empty_Proofs_Sentinel, Position => Reference.Proofs); end if; This.Map_Sloc_Elements (Root => Slocs, The_Tree => Reference.The_Tree, Position => Reference.Source_Lines); end; end Map_Entities; --------------------------------------------------------------------------- -- Map_Flow_Elements --------------------------------------------------------------------------- procedure Map_Flow_Elements (This : in out T; Root : in JSON_Array) is begin for I in 1 .. GNATCOLL.JSON.Length (Arr => Root) loop declare Element : constant JSON_Value := GNATCOLL.JSON.Get (Arr => Root, Index => I); begin if Preconditions.Ensure_Field (Object => Element, Field => Field_Names.Entity, Kind => JSON_Object_Type) then declare Source_Entity : constant JSON_Value := Element.Get (Field => Field_Names.Entity); begin -- The name referenced here should match a name we already -- have in the hash table. if Preconditions.Ensure_Field (Object => Source_Entity, Field => Field_Names.Name, Kind => JSON_String_Type) then declare The_Key : constant Entity_Name := Entity_Name (Subject_Name' (Source_Entity.Get (Field => Field_Names.Name))); Update_At : constant Analyzed_Entities.Cursor := This.Entities.Find (Key => The_Key); begin if Update_At /= Analyzed_Entities.No_Element then if Flow_Item.Has_Required_Fields (Object => Element) then declare Reference : constant Analyzed_Entities.Reference_Type := This.Entities.Reference (Position => Update_At); begin Reference.The_Tree.Append_Child (Parent => Reference.Flows, New_Item => Flow_Item.Create (Object => Element)); end; end if; else Log.Warning (Message => "flow: """ & To_String (Source => The_Key) & """ not found in index."); end if; end; end if; end; end if; end; end loop; -- Sort flows by file name:line:column. for E of This.Entities loop SPAT.Flow_Item.Sort_By_Location (This => E.The_Tree, Parent => E.Flows); end loop; end Map_Flow_Elements; --------------------------------------------------------------------------- -- Map_Proof_Elements --------------------------------------------------------------------------- procedure Map_Proof_Elements (This : in out T; Version : in File_Version; Root : in JSON_Array; Cache_Cursor : in File_Cached_Info.Cursor) is ------------------------------------------------------------------------ -- Update_Caches ------------------------------------------------------------------------ procedure Update_Caches (Reference : in Analyzed_Entities.Reference_Type); ------------------------------------------------------------------------ -- Update_Caches ------------------------------------------------------------------------ procedure Update_Caches (Reference : in Analyzed_Entities.Reference_Type) is N : constant Proof_Item.T := Proof_Item.T (Entity.T'Class' (Reference.The_Tree (Entity.Tree.Last_Child (Position => Reference.Proofs)))); begin Update_Sentinel : declare ------------------------------------------------------------------ -- Local_Update ------------------------------------------------------------------ procedure Local_Update (Element : in out Entity.T'Class); ------------------------------------------------------------------ -- Local_Update ------------------------------------------------------------------ procedure Local_Update (Element : in out Entity.T'Class) is S : Proofs_Sentinel renames Proofs_Sentinel (Element); begin -- Update sentinel (proof list specific). S.Cache := Proof_Cache'(Max_Proof_Time => Duration'Max (S.Cache.Max_Proof_Time, N.Max_Time), Max_Proof_Steps => Prover_Steps'Max (S.Cache.Max_Proof_Steps, N.Max_Steps), Max_Success_Proof_Time => Duration'Max (S.Cache.Max_Success_Proof_Time, N.Max_Success_Time), Max_Success_Proof_Steps => Prover_Steps'Max (S.Cache.Max_Success_Proof_Steps, N.Max_Success_Steps), Total_Proof_Time => S.Cache.Total_Proof_Time + N.Total_Time, Has_Failed_Attempts => S.Cache.Has_Failed_Attempts or else N.Has_Failed_Attempts, Has_Unproved_Attempts => S.Cache.Has_Unproved_Attempts or else N.Has_Unproved_Attempts, Has_Unjustified_Attempts => S.Cache.Has_Unjustified_Attempts or else N.Is_Unjustified); end Local_Update; begin Reference.The_Tree.Update_Element (Position => Reference.Proofs, Process => Local_Update'Access); end Update_Sentinel; Update_File_Cache : declare ------------------------------------------------------------------ -- Local_Update ------------------------------------------------------------------ procedure Local_Update (Key : in SPARK_File_Name; Element : in out Cache_Info); ------------------------------------------------------------------ -- Local_Update ------------------------------------------------------------------ procedure Local_Update (Key : in SPARK_File_Name; Element : in out Cache_Info) is pragma Unreferenced (Key); begin if N.Has_Unproved_Attempts then null; -- VC is not fully proven, so don't update the max -- time for successful proofs else Element.Max_Success_Proof_Time := Duration'Max (Element.Max_Success_Proof_Time, N.Max_Success_Time); Element.Max_Success_Proof_Steps := Prover_Steps'Max (Element.Max_Success_Proof_Steps, N.Max_Success_Steps); end if; Element.Max_Proof_Time := Duration'Max (Element.Max_Proof_Time, N.Max_Time); Element.Max_Proof_Steps := Prover_Steps'Max (Element.Max_Proof_Steps, N.Max_Steps); end Local_Update; begin This.Cached.Update_Element (Position => Cache_Cursor, Process => Local_Update'Access); end Update_File_Cache; end Update_Caches; begin for I in 1 .. GNATCOLL.JSON.Length (Arr => Root) loop declare Element : constant JSON_Value := GNATCOLL.JSON.Get (Arr => Root, Index => I); begin if Preconditions.Ensure_Field (Object => Element, Field => Field_Names.Entity, Kind => JSON_Object_Type) then declare Source_Entity : constant JSON_Value := Element.Get (Field => Field_Names.Entity); begin -- The name referenced here should match a name we already -- have in the hash table. if Preconditions.Ensure_Field (Object => Source_Entity, Field => Field_Names.Name, Kind => JSON_String_Type) then declare The_Key : constant Entity_Name := Entity_Name (Subject_Name' (Source_Entity.Get (Field => Field_Names.Name))); Update_At : constant Analyzed_Entities.Cursor := This.Entities.Find (Key => The_Key); begin if Update_At /= Analyzed_Entities.No_Element then if Proof_Item.Has_Required_Fields (Object => Element, Version => Version) then declare Reference : constant Analyzed_Entities.Reference_Type := This.Entities.Reference (Position => Update_At); begin Proof_Item.Add_To_Tree (Object => Element, Version => Version, Tree => Reference.The_Tree, Parent => Reference.Proofs); -- Update parent sentinel and file info with -- new proof times. Update_Caches (Reference => Reference); end; end if; else Log.Warning (Message => "proof: """ & To_String (Source => The_Key) & """ not found in index."); end if; end; end if; end; end if; end; end loop; -- Sort proofs by time to proof them. for E of This.Entities loop SPAT.Proof_Item.Sort_By_Duration (Tree => E.The_Tree, Parent => E.Proofs); end loop; end Map_Proof_Elements; --------------------------------------------------------------------------- -- Map_Sloc_Elements --------------------------------------------------------------------------- procedure Map_Sloc_Elements (This : in out T; The_Tree : in out Entity.Tree.T; Position : in Entity.Tree.Cursor; Root : in JSON_Array) is pragma Unreferenced (This); begin for I in 1 .. GNATCOLL.JSON.Length (Arr => Root) loop declare Sloc : constant JSON_Value := GNATCOLL.JSON.Get (Arr => Root, Index => I); begin if Entity_Line.Has_Required_Fields (Object => Sloc) then The_Tree.Append_Child (Parent => Position, New_Item => Entity_Line.Create (Object => Sloc)); end if; end; end loop; end Map_Sloc_Elements; --------------------------------------------------------------------------- -- Map_Spark_Elements --------------------------------------------------------------------------- procedure Map_Spark_Elements (This : in out T; Root : in JSON_Array; From_File : in File_Sets.Cursor) is Length : constant Natural := GNATCOLL.JSON.Length (Arr => Root); begin This.Entities.Reserve_Capacity (Capacity => Ada.Containers.Count_Type (Length)); for I in 1 .. Length loop declare Element : constant JSON_Value := GNATCOLL.JSON.Get (Arr => Root, Index => I); begin if Preconditions.Ensure_Field (Object => Element, Field => Field_Names.Name, Kind => JSON_String_Type) and then Preconditions.Ensure_Field (Object => Element, Field => Field_Names.Sloc, Kind => JSON_Array_Type) then This.Map_Entities (Root => Element, From_File => From_File); end if; end; end loop; end Map_Spark_Elements; --------------------------------------------------------------------------- -- Map_Spark_File --------------------------------------------------------------------------- not overriding procedure Map_Spark_File (This : in out T; File : in SPARK_File_Name; Root : in JSON_Value) is Version : constant File_Version := Guess_Version (Name => To_String (File), Root => Root); Cache_Cursor : File_Cached_Info.Cursor; File_Cursor : File_Sets.Cursor; begin -- Clear cache data. This.Flow_Count := -1; This.Proof_Count := -1; -- Establish reference to file. May add it to the Files list if it was -- not known yet. declare Dummy_Inserted : Boolean; begin This.Files.Insert (New_Item => File, Position => File_Cursor, Inserted => Dummy_Inserted); -- Same for the cached information (which may get updated). This.Cached.Insert (Key => File, New_Item => Cache_Info'(Max_Success_Proof_Time => 0.0, Max_Success_Proof_Steps => 0, Max_Proof_Time => 0.0, Max_Proof_Steps => 0), Position => Cache_Cursor, Inserted => Dummy_Inserted); end; -- If I understand the .spark file format correctly, this should -- establish the table of all known analysis elements. if Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Spark, Kind => JSON_Array_Type) then This.Map_Spark_Elements (Root => Root.Get (Field => Field_Names.Spark), From_File => File_Cursor); end if; if Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Flow, Kind => JSON_Array_Type) then This.Map_Flow_Elements (Root => Root.Get (Field => Field_Names.Flow)); end if; if Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Proof, Kind => JSON_Array_Type) then This.Map_Proof_Elements (Root => Root.Get (Field => Field_Names.Proof), Version => Version, Cache_Cursor => Cache_Cursor); end if; if Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Assumptions, Kind => JSON_Array_Type) then This.Map_Assumptions_Elements (Root => Root.Get (Field => Field_Names.Assumptions)); end if; if Preconditions.Ensure_Field (Object => Root, Field => Field_Names.Timings, Kind => JSON_Object_Type) then -- The "timings" object is version dependent. This.Map_Timings (File => File, Root => Root.Get (Field => Field_Names.Timings), Version => Version); end if; exception when E : others => Log.Dump_Exception (E => E, Message => "Internal problem encountered while mapping JSON objects.", File => To_String (Source => File)); Log.Warning (Message => "Internal error encountered, results will be inaccurate."); end Map_Spark_File; --------------------------------------------------------------------------- -- Map_Timings --------------------------------------------------------------------------- procedure Map_Timings (This : in out T; File : in SPARK_File_Name; Root : in JSON_Value; Version : in File_Version) is begin if Timing_Item.Has_Required_Fields (Object => Root, Version => Version) then This.Timings.Insert (Key => File, New_Item => Timing_Item.Create (Object => Root, Version => Version)); else This.Timings.Insert (Key => File, New_Item => Timing_Item.None); end if; end Map_Timings; --------------------------------------------------------------------------- -- Max_Proof_Steps --------------------------------------------------------------------------- not overriding function Max_Proof_Steps (This : in T; Entity : in Entity_Name) return Prover_Steps is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Max_Proof_Steps; end Max_Proof_Steps; --------------------------------------------------------------------------- -- Max_Proof_Time --------------------------------------------------------------------------- not overriding function Max_Proof_Time (This : in T; Entity : in Entity_Name) return Duration is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Max_Proof_Time; end Max_Proof_Time; --------------------------------------------------------------------------- -- Max_Proof_Time --------------------------------------------------------------------------- not overriding function Max_Proof_Time (This : in T; File : in SPARK_File_Name) return Duration is (This.Cached (File).Max_Proof_Time); --------------------------------------------------------------------------- -- Max_Proof_Steps --------------------------------------------------------------------------- not overriding function Max_Proof_Steps (This : in T; File : in SPARK_File_Name) return Prover_Steps is (This.Cached (File).Max_Proof_Steps); --------------------------------------------------------------------------- -- Max_Success_Proof_Steps --------------------------------------------------------------------------- not overriding function Max_Success_Proof_Steps (This : in T; Entity : in Entity_Name) return Prover_Steps is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Max_Success_Proof_Steps; end Max_Success_Proof_Steps; --------------------------------------------------------------------------- -- Max_Success_Proof_Time --------------------------------------------------------------------------- not overriding function Max_Success_Proof_Time (This : in T; Entity : in Entity_Name) return Duration is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Max_Success_Proof_Time; end Max_Success_Proof_Time; --------------------------------------------------------------------------- -- Max_Success_Proof_Steps --------------------------------------------------------------------------- not overriding function Max_Success_Proof_Steps (This : in T; File : in SPARK_File_Name) return Prover_Steps is (This.Cached (File).Max_Success_Proof_Steps); --------------------------------------------------------------------------- -- Max_Success_Proof_Time --------------------------------------------------------------------------- not overriding function Max_Success_Proof_Time (This : in T; File : in SPARK_File_Name) return Duration is (This.Cached (File).Max_Success_Proof_Time); --------------------------------------------------------------------------- -- Num_Flows --------------------------------------------------------------------------- not overriding function Num_Flows (This : not null access T) return Ada.Containers.Count_Type is begin -- Data not yet cached? if This.Flow_Count = -1 then declare Result : Ada.Containers.Count_Type := 0; begin for E of This.Entities loop Result := Result + Entity.Tree.Child_Count (Parent => E.Flows); end loop; -- Update cache. This.Flow_Count := Result; end; end if; return This.Flow_Count; end Num_Flows; --------------------------------------------------------------------------- -- Num_Proofs --------------------------------------------------------------------------- not overriding function Num_Proofs (This : not null access T) return Ada.Containers.Count_Type is begin -- Data not yet cached? if This.Proof_Count = -1 then declare Result : Ada.Containers.Count_Type := 0; begin for E of This.Entities loop Result := Result + Entity.Tree.Child_Count (Parent => E.Proofs); end loop; -- Update cache. This.Proof_Count := Result; end; end if; return This.Proof_Count; end Num_Proofs; --------------------------------------------------------------------------- -- Print_Trees --------------------------------------------------------------------------- not overriding procedure Print_Trees (This : in T) is begin if SPAT.Log.Debug_Enabled then for Position in This.Entities.Iterate loop declare Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Position => Position); begin for C in SPAT.Entity.Tree.Iterate_Subtree (Position => Reference.Proofs) loop declare E : constant Entity.T'Class := Entity.Tree.Element (C); use Ada.Strings.Fixed; begin SPAT.Log.Debug (Natural (SPAT.Entity.Tree.Child_Depth (Reference.Proofs, C)) * ' ' & "[]: " & E.Image); end; end loop; end; end loop; end if; end Print_Trees; --------------------------------------------------------------------------- -- Proof_Time --------------------------------------------------------------------------- not overriding function Proof_Time (This : in T; File : in SPARK_File_Name) return Duration is Timings : constant Timing_Item.T := This.Timings (File); begin case Timings.Version is when GNAT_CE_2019 => -- In this version we have a "proof" timing field, report it -- directly. return Timings.Proof; when GNAT_CE_2020 => declare File_Cursor : constant File_Sets.Cursor := This.Files.Find (Item => File); -- No need to compare filenames, just check the cursor to the -- expected file. use type File_Sets.Cursor; Summed_Proof_Time : Duration := Timings.Proof; begin -- In this version there's no proof timing field anymore, so we -- need to sum the proof times of the entities, too. for Position in This.Entities.Iterate loop declare Name : constant Entity_Name := Analyzed_Entities.Key (Position); begin if Analyzed_Entities.Element (Position).SPARK_File = File_Cursor then Summed_Proof_Time := Summed_Proof_Time + This.Total_Proof_Time (Name); end if; end; end loop; return Summed_Proof_Time; end; end case; end Proof_Time; --------------------------------------------------------------------------- -- Proof_Tree --------------------------------------------------------------------------- not overriding function Proof_Tree (This : in T; Entity : in Entity_Name) return SPAT.Entity.Tree.Forward_Iterator'Class is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); begin return Reference.The_Tree.Iterate_Children (Parent => Reference.Proofs); end Proof_Tree; --------------------------------------------------------------------------- -- Sort_Entity_By_Name --------------------------------------------------------------------------- procedure Sort_Entity_By_Name (This : in T; Container : in out Strings.Entity_Names) is pragma Unreferenced (This); package Sorting is new Strings.Implementation.Entities.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.Entities.Base_Vectors.Vector (Container)); end Sort_Entity_By_Name; --------------------------------------------------------------------------- -- Sort_Entity_By_Proof_Steps --------------------------------------------------------------------------- procedure Sort_Entity_By_Proof_Steps (This : in T; Container : in out Strings.Entity_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean is Left_Steps : constant Prover_Steps := This.Max_Proof_Steps (Entity => Left); Right_Steps : constant Prover_Steps := This.Max_Proof_Steps (Entity => Right); Left_Total_Time : constant Duration := This.Total_Proof_Time (Entity => Left); Right_Total_Time : constant Duration := This.Total_Proof_Time (Entity => Right); Left_Max_Time : constant Duration := This.Max_Proof_Time (Entity => Left); Right_Max_Time : constant Duration := This.Max_Proof_Time (Entity => Right); Left_Success_Time : constant Duration := This.Max_Success_Proof_Time (Entity => Left); Right_Success_Time : constant Duration := This.Max_Success_Proof_Time (Entity => Right); begin if Left_Steps /= Right_Steps then return Left_Steps > Right_Steps; end if; -- Steps are equal, try by total proof time. if Left_Total_Time /= Right_Total_Time then return Left_Total_Time > Right_Total_Time; end if; -- Total time is the same, try to sort by max time. if Left_Max_Time /= Right_Max_Time then return Left_Max_Time > Right_Max_Time; end if; -- Try sorting by max time for successful proof. if Left_Success_Time /= Right_Success_Time then return Left_Success_Time > Right_Success_Time; end if; -- Resort to alphabetical order. return SPAT."<" (Left, Right); -- Trap! "Left < Right" is recursive. end "<"; package Sorting is new Strings.Implementation.Entities.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.Entities.Base_Vectors.Vector (Container)); end Sort_Entity_By_Proof_Steps; --------------------------------------------------------------------------- -- Sort_Entity_By_Proof_Time --------------------------------------------------------------------------- procedure Sort_Entity_By_Proof_Time (This : in T; Container : in out Strings.Entity_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean is Left_Total : constant Duration := This.Total_Proof_Time (Entity => Left); Right_Total : constant Duration := This.Total_Proof_Time (Entity => Right); Left_Max : constant Duration := This.Max_Proof_Time (Entity => Left); Right_Max : constant Duration := This.Max_Proof_Time (Entity => Right); Left_Success : constant Duration := This.Max_Success_Proof_Time (Entity => Left); Right_Success : constant Duration := This.Max_Success_Proof_Time (Entity => Right); begin -- First by total time. if Left_Total /= Right_Total then return Left_Total > Right_Total; end if; -- Total time is the same, try to sort by max time. if Left_Max /= Right_Max then return Left_Max > Right_Max; end if; -- Try sorting by max time for successful proof. if Left_Success /= Right_Success then return Left_Success > Right_Success; end if; -- Resort to alphabetical order. return SPAT."<" (Left, Right); -- Trap! "Left < Right" is recursive. end "<"; package Sorting is new Strings.Implementation.Entities.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.Entities.Base_Vectors.Vector (Container)); end Sort_Entity_By_Proof_Time; --------------------------------------------------------------------------- -- Sort_Entity_By_Success_Steps -- -- Sort code entities by how many maximum steps for a successful proofs. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Success_Steps (This : in T; Container : in out Strings.Entity_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean is Left_Success_Steps : constant Prover_Steps := (if This.Has_Unproved_Attempts (Entity => Left) then 0 else This.Max_Success_Proof_Steps (Entity => Left)); Right_Success_Steps : constant Prover_Steps := (if This.Has_Unproved_Attempts (Entity => Right) then 0 else This.Max_Success_Proof_Steps (Entity => Right)); Left_Success_Time : constant Duration := (if This.Has_Unproved_Attempts (Entity => Left) then Duration'First else This.Max_Success_Proof_Time (Entity => Left)); Right_Success_Time : constant Duration := (if This.Has_Unproved_Attempts (Entity => Right) then Duration'First else This.Max_Success_Proof_Time (Entity => Right)); Left_Max_Steps : constant Prover_Steps := This.Max_Proof_Steps (Entity => Left); Right_Max_Steps : constant Prover_Steps := This.Max_Proof_Steps (Entity => Right); Left_Total_Time : constant Duration := This.Total_Proof_Time (Entity => Left); Right_Total_Time : constant Duration := This.Total_Proof_Time (Entity => Right); Left_Max_Time : constant Duration := This.Max_Proof_Time (Entity => Left); Right_Max_Time : constant Duration := This.Max_Proof_Time (Entity => Right); begin -- First by steps to successful proof if Left_Success_Steps /= Right_Success_Steps then return Left_Success_Steps > Right_Success_Steps; end if; -- Steps are equal, try time. if Left_Success_Time /= Right_Success_Time then return Left_Success_Time > Right_Success_Time; end if; -- Success times are equal, try max steps. if Left_Max_Steps /= Right_Max_Steps then return Left_Max_Steps > Right_Max_Steps; end if; -- Max steps are equal too, try total time. if Left_Total_Time /= Right_Total_Time then return Left_Total_Time > Right_Total_Time; end if; -- Total time is the same, try to sort by max time. if Left_Max_Time /= Right_Max_Time then return Left_Max_Time > Right_Max_Time; end if; -- Resort to alphabetical order. return SPAT."<" (Left, Right); -- Trap! "Left < Right" is recursive. end "<"; package Sorting is new Strings.Implementation.Entities.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.Entities.Base_Vectors.Vector (Container)); end Sort_Entity_By_Success_Steps; --------------------------------------------------------------------------- -- Sort_Entity_By_Success_Time -- -- Sort code entities by how much maximum time for a successful proofs. -- Sorting: numerical, descending --------------------------------------------------------------------------- procedure Sort_Entity_By_Success_Time (This : in T; Container : in out Strings.Entity_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in Entity_Name; Right : in Entity_Name) return Boolean is Left_Success : constant Duration := (if This.Has_Unproved_Attempts (Entity => Left) then Duration'First else This.Max_Success_Proof_Time (Entity => Left)); Right_Success : constant Duration := (if This.Has_Unproved_Attempts (Entity => Right) then Duration'First else This.Max_Success_Proof_Time (Entity => Right)); Left_Total : constant Duration := This.Total_Proof_Time (Entity => Left); Right_Total : constant Duration := This.Total_Proof_Time (Entity => Right); Left_Max : constant Duration := This.Max_Proof_Time (Entity => Left); Right_Max : constant Duration := This.Max_Proof_Time (Entity => Right); begin -- First by success time. if Left_Success /= Right_Success then return Left_Success > Right_Success; end if; -- Total time. if Left_Total /= Right_Total then return Left_Total > Right_Total; end if; -- Total time is the same, try to sort by max time. if Left_Max /= Right_Max then return Left_Max > Right_Max; end if; -- Resort to alphabetical order. return SPAT."<" (Left, Right); -- Trap! "Left < Right" is recursive. end "<"; package Sorting is new Strings.Implementation.Entities.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.Entities.Base_Vectors.Vector (Container)); end Sort_Entity_By_Success_Time; --------------------------------------------------------------------------- -- By_Basename --------------------------------------------------------------------------- function By_Basename (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean is (Ada.Directories.Base_Name (Name => To_String (Source => Left)) < Ada.Directories.Base_Name (Name => To_String (Source => Right))); package File_Name_Sorting is new Strings.Implementation.SPARK_File_Names.Base_Vectors.Generic_Sorting ("<" => By_Basename); --------------------------------------------------------------------------- -- Sort_File_By_Basename --------------------------------------------------------------------------- procedure Sort_File_By_Basename (This : in T; Container : in out Strings.SPARK_File_Names) is pragma Unreferenced (This); -- Only provided for consistency. begin File_Name_Sorting.Sort (Container => Strings.Implementation.SPARK_File_Names.Base_Vectors.Vector (Container)); end Sort_File_By_Basename; --------------------------------------------------------------------------- -- Sort_File_By_Max_Success_Steps --------------------------------------------------------------------------- procedure Sort_File_By_Max_Success_Steps (This : in T; Container : in out Strings.SPARK_File_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean is Left_Success_Steps : constant Prover_Steps := This.Max_Success_Proof_Steps (File => Left); Right_Success_Steps : constant Prover_Steps := This.Max_Success_Proof_Steps (File => Right); Left_Steps : constant Prover_Steps := This.Max_Proof_Steps (File => Left); Right_Steps : constant Prover_Steps := This.Max_Proof_Steps (File => Right); Left_Success_Time : constant Duration := This.Max_Success_Proof_Time (File => Left); Right_Success_Time : constant Duration := This.Max_Success_Proof_Time (File => Right); Left_Proof_Time : constant Duration := This.Proof_Time (File => Left); Right_Proof_Time : constant Duration := This.Proof_Time (File => Right); Left_Flow_Time : constant Duration := This.Flow_Time (File => Left); Right_Flow_Time : constant Duration := This.Flow_Time (File => Right); Left_Total_Time : constant Duration := Left_Proof_Time + Left_Flow_Time; Right_Total_Time : constant Duration := Right_Proof_Time + Right_Flow_Time; begin -- Sort by success steps. if Left_Success_Steps /= Right_Success_Steps then return Left_Success_Steps > Right_Success_Steps; end if; -- Success steps is equal, sort by max steps. if Left_Steps /= Right_Steps then return Left_Steps > Right_Steps; end if; -- If steps were equal, sort by time. if Left_Success_Time /= Right_Success_Time then return Left_Success_Time > Right_Success_Time; end if; -- If success times do not differ, prioritize proof time. if Left_Proof_Time /= Right_Proof_Time then return Left_Proof_Time > Right_Proof_Time; end if; -- If proof times are equal, try total time. if Left_Total_Time /= Right_Total_Time then return Left_Total_Time > Right_Total_Time; end if; -- Total and proof times were equal, so flow times must be equal, too. pragma Assert (Left_Flow_Time = Right_Flow_Time); -- Last resort, sort by name. return By_Basename (Left => Left, Right => Right); end "<"; package Sorting is new Strings.Implementation.SPARK_File_Names.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.SPARK_File_Names.Base_Vectors.Vector (Container)); end Sort_File_By_Max_Success_Steps; --------------------------------------------------------------------------- -- Sort_File_By_Max_Success_Time --------------------------------------------------------------------------- procedure Sort_File_By_Max_Success_Time (This : in T; Container : in out Strings.SPARK_File_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean is Left_Success : constant Duration := This.Max_Success_Proof_Time (File => Left); Right_Success : constant Duration := This.Max_Success_Proof_Time (File => Right); Left_Proof : constant Duration := This.Proof_Time (File => Left); Right_Proof : constant Duration := This.Proof_Time (File => Right); Left_Flow : constant Duration := This.Flow_Time (File => Left); Right_Flow : constant Duration := This.Flow_Time (File => Right); Left_Total : constant Duration := Left_Proof + Left_Flow; Right_Total : constant Duration := Right_Proof + Right_Flow; begin -- First by success time. if Left_Success /= Right_Success then return Left_Success > Right_Success; end if; -- If success times do not differ, prioritize proof time. if Left_Proof /= Right_Proof then return Left_Proof > Right_Proof; end if; -- If proof times are equal, try total time. if Left_Total /= Right_Total then return Left_Total > Right_Total; end if; -- Total and proof times were equal, so flow times must be equal, too. pragma Assert (Left_Flow = Right_Flow); -- Last resort, sort by name. return By_Basename (Left => Left, Right => Right); end "<"; package Sorting is new Strings.Implementation.SPARK_File_Names.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.SPARK_File_Names.Base_Vectors.Vector (Container)); end Sort_File_By_Max_Success_Time; --------------------------------------------------------------------------- -- Sort_File_By_Proof_Time --------------------------------------------------------------------------- procedure Sort_File_By_Proof_Time (This : in T; Container : in out Strings.SPARK_File_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean is Left_Proof : constant Duration := This.Proof_Time (File => Left); Right_Proof : constant Duration := This.Proof_Time (File => Right); Left_Flow : constant Duration := This.Flow_Time (File => Left); Right_Flow : constant Duration := This.Flow_Time (File => Right); Left_Total : constant Duration := Left_Proof + Left_Flow; Right_Total : constant Duration := Right_Proof + Right_Flow; begin -- First by total time. if Left_Total /= Right_Total then return Left_Total > Right_Total; end if; -- If totals do not differ, prioritize proof time. if Left_Proof /= Right_Proof then return Left_Proof > Right_Proof; end if; -- Total and proof times were equal, so flow times must be equal, too. pragma Assert (Left_Flow = Right_Flow); -- Last resort, sort by name. return By_Basename (Left => Left, Right => Right); end "<"; package Sorting is new Strings.Implementation.SPARK_File_Names.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.SPARK_File_Names.Base_Vectors.Vector (Container)); end Sort_File_By_Proof_Time; --------------------------------------------------------------------------- -- Sort_File_By_Steps --------------------------------------------------------------------------- procedure Sort_File_By_Steps (This : in T; Container : in out Strings.SPARK_File_Names) is ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean; ------------------------------------------------------------------------ -- "<" ------------------------------------------------------------------------ function "<" (Left : in SPARK_File_Name; Right : in SPARK_File_Name) return Boolean is Left_Steps : constant Prover_Steps := This.Max_Proof_Steps (File => Left); Right_Steps : constant Prover_Steps := This.Max_Proof_Steps (File => Right); Left_Success_Time : constant Duration := This.Max_Success_Proof_Time (File => Left); Right_Success_Time : constant Duration := This.Max_Success_Proof_Time (File => Right); Left_Proof_Time : constant Duration := This.Proof_Time (File => Left); Right_Proof_Time : constant Duration := This.Proof_Time (File => Right); Left_Flow_Time : constant Duration := This.Flow_Time (File => Left); Right_Flow_Time : constant Duration := This.Flow_Time (File => Right); Left_Total_Time : constant Duration := Left_Proof_Time + Left_Flow_Time; Right_Total_Time : constant Duration := Right_Proof_Time + Right_Flow_Time; begin -- Sort by max steps. if Left_Steps /= Right_Steps then return Left_Steps > Right_Steps; end if; -- If steps were equal, sort by time. if Left_Success_Time /= Right_Success_Time then return Left_Success_Time > Right_Success_Time; end if; -- If success times do not differ, prioritize proof time. if Left_Proof_Time /= Right_Proof_Time then return Left_Proof_Time > Right_Proof_Time; end if; -- If proof times are equal, try total time. if Left_Total_Time /= Right_Total_Time then return Left_Total_Time > Right_Total_Time; end if; -- Total and proof times were equal, so flow times must be equal, too. pragma Assert (Left_Flow_Time = Right_Flow_Time); -- Last resort, sort by name. return By_Basename (Left => Left, Right => Right); end "<"; package Sorting is new Strings.Implementation.SPARK_File_Names.Base_Vectors.Generic_Sorting ("<" => "<"); begin Sorting.Sort (Container => Strings.Implementation.SPARK_File_Names.Base_Vectors.Vector (Container)); end Sort_File_By_Steps; --------------------------------------------------------------------------- -- Total_Proof_Time --------------------------------------------------------------------------- not overriding function Total_Proof_Time (This : in T; Entity : in Entity_Name) return Duration is Reference : constant Analyzed_Entities.Constant_Reference_Type := This.Entities.Constant_Reference (Key => Entity); Sentinel : constant Proofs_Sentinel := Get_Sentinel (Node => Reference); begin return Sentinel.Cache.Total_Proof_Time; end Total_Proof_Time; end SPAT.Spark_Info;
stcarrez/ada-util
Ada
3,720
adb
----------------------------------------------------------------------- -- util-commands-parsers.gnat_parser -- GNAT command line parser for command drivers -- Copyright (C) 2018, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with GNAT.OS_Lib; package body Util.Commands.Parsers.GNAT_Parser is function To_OS_Lib_Argument_List (Args : in Argument_List'Class) return GNAT.OS_Lib.Argument_List_Access; function To_OS_Lib_Argument_List (Args : in Argument_List'Class) return GNAT.OS_Lib.Argument_List_Access is Count : constant Natural := Args.Get_Count; New_Arg : GNAT.OS_Lib.Argument_List (1 .. Count); begin for I in 1 .. Count loop New_Arg (I) := new String '(Args.Get_Argument (I)); end loop; return new GNAT.OS_Lib.Argument_List '(New_Arg); end To_OS_Lib_Argument_List; -- ------------------------------ -- Get all the remaining arguments from the GNAT command line parse. -- ------------------------------ procedure Get_Arguments (List : in out Dynamic_Argument_List; Command : in String; Parser : in GC.Opt_Parser := GC.Command_Line_Parser) is begin List.Name := Ada.Strings.Unbounded.To_Unbounded_String (Command); loop declare S : constant String := GC.Get_Argument (Parser => Parser); begin exit when S'Length = 0; List.List.Append (S); end; end loop; end Get_Arguments; procedure Execute (Config : in out Config_Type; Args : in Util.Commands.Argument_List'Class; Process : not null access procedure (Cmd_Args : in Commands.Argument_List'Class)) is use type GC.Command_Line_Configuration; Empty : Config_Type; begin if Config /= Empty then declare Parser : GC.Opt_Parser; Cmd_Args : Dynamic_Argument_List; Params : GNAT.OS_Lib.Argument_List_Access := To_OS_Lib_Argument_List (Args); begin GC.Initialize_Option_Scan (Parser, Params); GC.Getopt (Config => Config, Parser => Parser); Get_Arguments (Cmd_Args, Args.Get_Command_Name, Parser); Process (Cmd_Args); GC.Free (Config); GNAT.OS_Lib.Free (Params); exception when others => GNAT.OS_Lib.Free (Params); GC.Free (Config); raise; end; else Process (Args); end if; end Execute; procedure Usage (Name : in String; Config : in out Config_Type) is Opts : constant String := GC.Get_Switches (Config); begin if Opts'Length > 0 then GC.Set_Usage (Config, Usage => Name & " [switches] [arguments]"); GC.Display_Help (Config); end if; end Usage; end Util.Commands.Parsers.GNAT_Parser;
reznikmm/matreshka
Ada
3,789
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Style.Punctuation_Wrap is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Punctuation_Wrap_Node) return League.Strings.Universal_String is begin return ODF.Constants.Punctuation_Wrap_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Punctuation_Wrap;
1Crazymoney/LearnAda
Ada
450
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Szummazas is type Index is new Integer; type Elem is new Integer; type Tomb is array (Index range <>) of Elem; function Szumma ( T: Tomb ) return Elem is S: Elem := 0; begin for I in T'Range loop S := S + T(I); end loop; return S; end Szumma; begin Put_Line( Elem'Image( Szumma((3,2,5,7,1)) ) ); end Szummazas;
rogermc2/GA_Ada
Ada
2,523
adb
with Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with GL.Types; with Maths; with Blade; with Blade_Types; with GA_Maths; with GA_Utilities; with Multivectors; use Multivectors; with Multivector_Type; with Multivector_Utilities; procedure Test_MV_Factor is use GL.Types; use Blade; -- use Blade.Names_Package; no_bv : Multivector := Basis_Vector (Blade_Types.C3_no); e1_bv : Multivector := Basis_Vector (Blade_Types.C3_e1); e2_bv : Multivector := Basis_Vector (Blade_Types.C3_e2); e3_bv : Multivector := Basis_Vector (Blade_Types.C3_e3); ni_bv : Multivector := Basis_Vector (Blade_Types.C3_ni); BV_Names : Blade.Basis_Vector_Names; Dim : constant Integer := 8; Scale : Float; BL : Blade.Blade_List; B_MV : Multivector; R_MV : Multivector; NP : Normalized_Point := New_Normalized_Point (-0.391495, -0.430912, 0.218277); Factors : Multivector_List; begin Set_Geometry (C3_Geometry); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("no")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e1")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e2")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("e3")); BV_Names.Append (Ada.Strings.Unbounded.To_Unbounded_String ("ni")); B_MV := Get_Random_Blade (Dim, Integer (Maths.Random_Float * (Single (Dim) + 0.49)), 1.0); BL.Add_Blade (New_Basis_Blade (30, -0.662244)); BL.Add_Blade (New_Basis_Blade (29, -0.391495)); BL.Add_Blade (New_Basis_Blade (27, -0.430912)); BL.Add_Blade (New_Basis_Blade (23, 0.218277)); BL.Add_Blade (New_Basis_Blade (15, -0.213881)); B_MV := New_Multivector (BL); GA_Utilities.Print_Multivector ("B_MV", B_MV); Factors := Multivector_Utilities.Factorize_Blades (B_MV, Scale); GA_Utilities.Print_Multivector_List("Factors", Factors); -- Reconstruct original R_MV := New_Multivector (Scale); for index in 1 .. List_Length (Factors) loop R_MV := Outer_Product (R_MV, MV_Item (Factors, index)); end loop; GA_Utilities.Print_Multivector ("R_MV", R_MV); GA_Utilities.Print_Multivector ("NP", NP); Factors := Multivector_Utilities.Factorize_Blades (NP, Scale); GA_Utilities.Print_Multivector_List("Factors", Factors); exception when anError : others => Put_Line ("An exception occurred in Test_MV_Factor."); raise; end Test_MV_Factor;
jwarwick/aoc_2020
Ada
1,187
adb
with AUnit.Assertions; use AUnit.Assertions; package body Day.Test is procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); f : constant Forest := load_map("test1.txt"); slope : constant Natural := 3; hit : constant Natural := trees_hit(f, slope); begin Assert(hit = 7, "Expected to hit 7 trees, actually hit " & Natural'Image(hit)); end Test_Part1; procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); f : constant Forest := load_map("test1.txt"); hit : constant Natural := many_trees_hit(f); begin Assert(hit = 336, "Expected to hit 336 trees, actually hit " & Natural'Image(hit)); null; end Test_Part2; function Name (T : Test) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Test Day package"); end Name; procedure Register_Tests (T : in out Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Part1'Access, "Test Part 1"); Register_Routine (T, Test_Part2'Access, "Test Part 2"); end Register_Tests; end Day.Test;
zhmu/ananas
Ada
435
ads
with Ada.Containers.Doubly_Linked_Lists; with Equal11_Interface; package Equal11_Record is use Equal11_Interface; type My_Record_Type is new My_Interface_Type with record F : Integer; end record; overriding procedure Put (R : in My_Record_Type); Put_Result : Integer; package My_Record_Type_List_Pck is new Ada.Containers.Doubly_Linked_Lists (Element_Type => My_Record_Type); end Equal11_Record;
Salvatore-tech/Sistemas-de-Tiempo-Real
Ada
3,335
adb
with Ada.Text_IO, Ada.Real_Time; use Ada.Text_IO, Ada.Real_Time; package body Pck_tareas is C_S: Time_Span := Milliseconds(24); C_CS1: Time_Span := Milliseconds(6); C_CS2: Time_Span := Milliseconds(2); C_CS3: Time_Span := Milliseconds(10); C_CS4: Time_Span := Milliseconds(6); C_CS5: Time_Span := Milliseconds(6); C_MD1: Time_Span := Milliseconds(6); C_MD2: Time_Span := Milliseconds(2); C_MD3: Time_Span := Milliseconds(10); C_MD4: Time_Span := Milliseconds(6); C_MD5: Time_Span := Milliseconds(6); T_retraso: Time; task body Control_cs is begin loop select accept CS1 do T_retraso := Clock; Put_Line("Tarea CS1: lectura tarjeta A/D"); delay until (C_CS1 + T_retraso); end CS1; or accept CS2 do T_retraso := Clock; Put_Line("Tarea CS2: calculo acción de control"); delay until (C_CS2 + T_retraso); end CS2; or accept CS3 do T_retraso := Clock; Put_Line("Tarea CS3: tarea de escritura tarjeta A/D"); delay until(C_CS3 + T_retraso); end CS3; or accept CS4 do T_retraso := Clock; Put_Line("Tarea CS4: tarea de almacenamiento de datos"); delay until (C_CS4 + T_retraso); end CS4; or accept CS5 do T_retraso := Clock; Put_Line("Tarea CS5: tarea de visualizacion por pantalla"); delay until (C_CS5 + T_retraso); end CS5; or terminate; end select; end loop; end Control_cs; task body Modulo_MD is begin loop select accept MD1 do T_retraso := Clock; Put_Line("Tarea MD1: lectura tarjeta A/D"); delay until (C_MD1 + T_retraso); end MD1; or accept MD2 do T_retraso := Clock; Put_Line("Tarea MD2: calculo acción de control"); delay until (C_MD2 + T_retraso); end MD2; or accept MD3 do T_retraso := Clock; Put_Line("Tarea MD3: tarea de escritura tarjeta A/D"); delay until (C_MD3 + T_retraso); end MD3; or accept MD4 do T_retraso := Clock; Put_Line("Tarea MD4: tarea de almacenamiento de datos"); delay until (C_MD4 + T_retraso); end MD4; or accept MD5 do T_retraso := Clock; Put_Line("Tarea MD5: tarea de visualizacion por pantalla"); delay until (C_MD5 + T_retraso); end MD5; or terminate; end select; end loop; end Modulo_MD; task body Seguridad is begin loop accept S do T_retraso := Clock; Put_Line("Tarea S: tarea de seguridad"); delay until (C_S + T_retraso); end S; end loop; end Seguridad; end Pck_tareas;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
885
adb
with STM32_SVD; use STM32_SVD; with STM32_SVD.RCC; use STM32_SVD.RCC; package body STM32GD.Clock.Tree is function Frequency (Clock : Clock_Type) return Integer is begin case Clock is when STM32GD.Clock.RTCCLK => return RTCCLK; when STM32GD.Clock.SYSCLK => return SYSCLK; when STM32GD.Clock.PCLK => return PCLK; when STM32GD.Clock.HSI => return HSI_Value; when STM32GD.Clock.LSI => return LSI_Value; when STM32GD.Clock.LSE => return LSE_Value; when STM32GD.Clock.PLLCLK => return PLL_Output_Value; when STM32GD.Clock.HCLK => return HCLK; end case; end Frequency; procedure Init is begin if LSI_Enabled then RCC_Periph.CSR.LSION := 1; while RCC_Periph.CSR.LSIRDY = 0 loop null; end loop; end if; end Init; end STM32GD.Clock.Tree;
AdaCore/Ada-IntelliJ
Ada
388
ads
with AWS.Status; with AWS.Templates; with AWS.Services.Web_Block.Context; package @[email protected]_Blocks is use AWS; use AWS.Services; procedure Widget_Counter (Request : in Status.Data; Context : not null access Web_Block.Context.Object; Translations : in out Templates.Translate_Set); end @[email protected]_Blocks;
fnarenji/BezierToSTL
Ada
828
adb
with Ada.Unchecked_Deallocation; with Courbes.Visiteurs; use Courbes.Visiteurs; package body Courbes is use Liste_Points; procedure Liberer_Courbe (Self : in out Courbe_Ptr) is procedure Liberer_Delivrer is new Ada.Unchecked_Deallocation (Courbe'Class, Courbe_Ptr); begin -- Libération de la memoire allouée par le Ctor -- Note: cela fonctionne aussi sur les types dérivés Liberer_Delivrer (Self); end; function Obtenir_Debut (Self : Courbe) return Point2D is begin return Self.Debut; end; function Obtenir_Fin (Self : Courbe) return Point2D is begin return Self.Fin; end; procedure Accepter (Self : Courbe; Visiteur : Courbes.Visiteurs.Visiteur_Courbe'Class) is begin Visiteur.Visiter(Self); end; end Courbes;
reznikmm/matreshka
Ada
7,018
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.Table_Representation_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Db_Table_Representation_Element_Node is begin return Self : Db_Table_Representation_Element_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Db_Table_Representation_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_Db_Table_Representation (ODF.DOM.Db_Table_Representation_Elements.ODF_Db_Table_Representation_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 Db_Table_Representation_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Table_Representation_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Db_Table_Representation_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_Db_Table_Representation (ODF.DOM.Db_Table_Representation_Elements.ODF_Db_Table_Representation_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 Db_Table_Representation_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_Db_Table_Representation (Visitor, ODF.DOM.Db_Table_Representation_Elements.ODF_Db_Table_Representation_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.Db_URI, Matreshka.ODF_String_Constants.Table_Representation_Element, Db_Table_Representation_Element_Node'Tag); end Matreshka.ODF_Db.Table_Representation_Elements;
reznikmm/gela
Ada
4,255
adb
with Ada.Text_IO; with League.String_Vectors; with AG_Tools.Input; with AG_Tools.Contexts; with AG_Tools.Writers; use AG_Tools.Writers; package body AG_Tools.Prop_Setter is -------------- -- Generate -- -------------- procedure Generate (G : Anagram.Grammars.Grammar_Access) is use type League.Strings.Universal_String; use type Anagram.Grammars.Attribute_Declaration_Index; Context : aliased AG_Tools.Contexts.Context; Done : League.String_Vectors.Universal_String_Vector; Name : League.Strings.Universal_String; Spec : Writer renames Context.Spec; Impl : Writer renames Context.Impl; begin Context.Add_With ("Gela.Element_Visiters", AG_Tools.Contexts.Spec_Unit); Spec.P; Spec.P ("package Gela.Property_Setters is"); Spec.P (" pragma Preelaborate;"); Spec.P; Spec.P (" type Property_Setter is limited interface;"); Spec.P; for J of G.Declaration loop Name := J.Name & "#" & J.Type_Name; if Done.Index (Name) = 0 then Context.Add_With (Package_Name (J.Type_Name), AG_Tools.Contexts.Spec_Unit); Spec.N (" not overriding procedure On_"); Spec.P (To_Ada (J.Name)); Spec.P (" (Self : in out Property_Setter;"); Spec.P (" Element : Gela.Elements.Element_Access;"); Spec.N (" Value : out "); Spec.N (J.Type_Name); Spec.P (") is abstract;"); Spec.P; Done.Append (Name); end if; end loop; Spec.P (" type Visiter (V : not null access Property_Setter'Class) is"); Spec.P (" new Gela.Element_Visiters.Visiter with null record;"); Spec.P; Spec.P ("private"); Impl.P ("package body Gela.Property_Setters is"); for NT of G.Non_Terminal loop for Prod of G.Production (NT.First .. NT.Last) loop if AG_Tools.Input.Is_Concrete (NT.Index) and not NT.Is_List then Name := To_Ada (NT.Name); Context.Add_With ("Gela.Elements." & Plural (Name), AG_Tools.Contexts.Spec_Unit); Spec.N (" overriding procedure ", Impl); Spec.P (To_Ada (Name), Impl); Spec.P (" (Self : in out Visiter;", Impl); Spec.N (" Node : not null Gela.Elements.", Impl); Spec.N (Plural (Name), Impl); Spec.N (".", Impl); Spec.N (To_Ada (Name), Impl); Spec.N ("_Access)", Impl); Spec.P (";"); Impl.P (" is"); for Decl of G.Declaration (NT.First_Attribute .. NT.Last_Attribute) loop Impl.N (" "); Impl.N (To_Ada (Decl.Name)); Impl.N (" : "); Impl.N (Decl.Type_Name); Impl.P (";"); end loop; Impl.P (" begin"); for Decl of G.Declaration (NT.First_Attribute .. NT.Last_Attribute) loop Impl.N (" Self.V.On_"); Impl.N (To_Ada (Decl.Name)); Impl.N (" (Gela.Elements.Element_Access (Node), "); Impl.N (To_Ada (Decl.Name)); Impl.P (");"); Impl.N (" Node.Set_"); Impl.N (To_Ada (Decl.Name)); Impl.N (" ("); Impl.N (To_Ada (Decl.Name)); Impl.P (");"); end loop; if NT.First_Attribute > NT.Last_Attribute then Impl.P (" null;"); end if; Impl.N (" end "); Impl.N (To_Ada (Name)); Impl.P (";"); Impl.P; Spec.P; end if; end loop; end loop; Spec.P; Spec.P ("end Gela.Property_Setters;", Impl); Context.Print_Withes (AG_Tools.Contexts.Spec_Unit); Ada.Text_IO.Put_Line (Spec.Text.To_UTF_8_String); Ada.Text_IO.Put_Line (Impl.Text.To_UTF_8_String); end Generate; end AG_Tools.Prop_Setter;
reznikmm/matreshka
Ada
3,729
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Script_Asian_Attributes is pragma Preelaborate; type ODF_Style_Script_Asian_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Script_Asian_Attribute_Access is access all ODF_Style_Script_Asian_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Script_Asian_Attributes;
Riishabh/HelloWorld
Ada
100
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line("Hello, World!"); end Hello;
riccardo-bernardini/eugen
Ada
482
adb
pragma Ada_2012; package body Tokenize.Private_Token_Lists with SPARK_Mode => On is ------------ -- Append -- ------------ procedure Append (List : in out Token_List; What : String) is begin if List.First_Free > List.Tokens'Last then raise Constraint_Error; end if; List.Tokens (List.First_Free) := To_Unbounded_String (What); List.First_Free := List.First_Free + 1; end Append; end Tokenize.Private_Token_Lists;
zhmu/ananas
Ada
1,051
adb
-- { dg-do run } -- { dg-options "-O -gnatp" } with Volatile11_Pkg; use Volatile11_Pkg; procedure Volatile11 is Value : Integer := 1; Bit1 : Boolean := false; pragma Volatile (Bit1); Bit2 : Boolean := false; pragma Volatile (Bit2); Bit3 : Boolean := false; pragma Volatile (Bit3); Bit4 : Boolean := false; pragma Volatile (Bit4); Bit5 : Boolean := false; pragma Volatile (Bit5); Bit6 : Boolean := false; pragma Volatile (Bit6); Bit7 : Boolean := false; pragma Volatile (Bit7); Bit8 : Boolean := false; pragma Volatile (Bit8); begin Bit_Test(Input => Value, Output1 => Bit1, Output2 => Bit2, Output3 => Bit3, Output4 => Bit4, Output5 => Bit5, Output6 => Bit6, Output7 => Bit7, Output8 => F.all); -- Check that F is invoked before Bit_Test if B /= True then raise Program_Error; end if; end;
clay-siefken/pe1
Ada
251
adb
with Ada.Text_IO; procedure PE1 is S : Integer; begin S := 0; for i in 1 .. 999 loop if (i mod 3) = 0 or (i mod 5) = 0 then S := S + i; end if; end loop; Ada.Text_IO.Put_Line(Item => Integer'Image(S)); end PE1;
reznikmm/matreshka
Ada
3,674
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Null_Date_Elements is pragma Preelaborate; type ODF_Table_Null_Date is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Null_Date_Access is access all ODF_Table_Null_Date'Class with Storage_Size => 0; end ODF.DOM.Table_Null_Date_Elements;
reznikmm/gela
Ada
3,780
adb
with Ada.Wide_Wide_Text_IO; with League.Application; with League.Strings; with League.String_Vectors; with Gela.Compilation_Unit_Sets; with Gela.Compilation_Units; with Gela.Context_Factories; with Gela.Contexts; with Gela.Elements; with Element_Printers; procedure API_Dump_Tree is procedure Process_Unit_Set (Unit_Set : Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access); procedure Process_Unit (Unit : Gela.Compilation_Units.Compilation_Unit_Access); procedure Process_Element (Element : access Gela.Elements.Element'Class; Indent : Natural); Context : Gela.Contexts.Context_Access; ------------------- -- For_Each_Unit -- ------------------- procedure Process_Unit_Set (Unit_Set : Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access) is Cursor : Gela.Compilation_Unit_Sets.Compilation_Unit_Cursor'Class := Unit_Set.First; begin while Cursor.Has_Element loop Process_Unit (Unit => Cursor.Element); Cursor.Next; end loop; end Process_Unit_Set; ------------------ -- Process_Unit -- ------------------ procedure Process_Unit (Unit : Gela.Compilation_Units.Compilation_Unit_Access) is Unit_Name : League.Strings.Universal_String := Context.Symbols.Image (Unit.Name); begin Ada.Wide_Wide_Text_IO.Put_Line ("UNIT NAME: " & Unit_Name.To_Wide_Wide_String); Process_Element (Unit.Tree, Indent => 0); end Process_Unit; --------------------- -- Process_Element -- --------------------- procedure Process_Element (Element : access Gela.Elements.Element'Class; Indent : Natural) is Space : constant Wide_Wide_String := " " & " " & " "; Printer : Element_Printers.Element_Printer; begin if not Element.Assigned then Ada.Wide_Wide_Text_IO.Put_Line (Space (1 .. Indent) & "null"); return; end if; Element.Visit (Printer); Ada.Wide_Wide_Text_IO.Put_Line (Space (1 .. Indent) & Printer.Image.To_Wide_Wide_String); for Item of Element.Nested_Items loop case Item.Kind is when Gela.Elements.Nested_Token => null; when Gela.Elements.Nested_Element => Process_Element (Item.Nested_Element, Indent + 2); when Gela.Elements.Nested_Sequence => declare Cursor : Gela.Elements.Element_Sequence_Cursor'Class := Item.Nested_Sequence.First; begin Ada.Wide_Wide_Text_IO.Put_Line (Space (1 .. Indent) & "["); while Cursor.Has_Element loop Process_Element (Cursor.Element, Indent + 2); Cursor.Next; end loop; Ada.Wide_Wide_Text_IO.Put_Line (Space (1 .. Indent) & "]"); end; end case; end loop; end Process_Element; Env : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("GELA_INCLUDE_PATH"); Args : constant League.String_Vectors.Universal_String_Vector := League.Application.Arguments; begin Context := Gela.Context_Factories.Create_Context (Args, League.Application.Environment.Value (Env)); Process_Unit_Set (Context.Library_Unit_Declarations); Process_Unit_Set (Context.Compilation_Unit_Bodies); end API_Dump_Tree;
houey/Amass
Ada
751
ads
-- Copyright 2017-2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local url = require("url") local json = require("json") name = "Baidu" type = "scrape" function start() setratelimit(1) end function vertical(ctx, domain) for i=0,100,10 do checkratelimit() local ok = scrape(ctx, {['url']=buildurl(domain, i)}) if not ok then break end end end function buildurl(domain, pagenum) local query = "site:" .. domain .. " -site:www." .. domain local params = { wd=query, oq=query, pn=pagenum, } return "https://www.baidu.com/s?" .. url.build_query_string(params) end
MinimSecure/unum-sdk
Ada
1,387
adb
-- Copyright 2015-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. procedure Foo is type New_Integer is new Integer; type Integer_Access is access Integer; function F (I : Integer; A : Integer_Access) return Boolean is begin return True; end F; function F (I : New_Integer; A : Integer_Access) return Boolean is begin return False; end F; procedure P (I : Integer; A : Integer_Access) is begin null; end P; procedure P (I : New_Integer; A : Integer_Access) is begin null; end P; B1 : constant Boolean := F (Integer'(1), null); -- BREAK B2 : constant Boolean := F (New_Integer'(2), null); begin P (Integer'(3), null); P (New_Integer'(4), null); end Foo;
annexi-strayline/AURA
Ada
4,940
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Core -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Containers; with Ada.Strings.Unbounded; with Registrar.Registry; package body Registrar.Executive.Subsystems_Request is ----------- -- Image -- ----------- function Image (Order: Subsystems_Request_Order) return String is use Ada.Strings.Unbounded; use type Ada.Containers.Count_Type; Image_String: Unbounded_String; begin Set_Unbounded_String (Target => Image_String, Source => "[Subsystems_Request_Order]" & New_Line & "Requested Subsystems:"); if Order.Requested_Subsystems.Length = 0 then Append (Source => Image_String, New_Item => " NONE"); else for SS of Order.Requested_Subsystems loop Append (Source => Image_String, New_Item => New_Line & "- " & SS.Name.To_UTF8_String); end loop; end if; return To_String (Image_String); end Image; ------------- -- Execute -- ------------- procedure Execute (Order: in out Subsystems_Request_Order) is package All_Subsystems renames Registrar.Registry.All_Subsystems; begin pragma Assert (for all SS of Order.Requested_Subsystems => SS.AURA and then SS.State = Requested); All_Subsystems.Union (Order.Requested_Subsystems); end Execute; end Registrar.Executive.Subsystems_Request;
persan/advent-of-code-2020
Ada
3,891
ads
with Ada.Containers.Indefinite_Vectors; -- https://adventofcode.com/2020/day/3 -- --- Day 3: Toboggan Trajectory --- -- -- With the toboggan login problems resolved, you set off toward the airport. -- While travel by toboggan might be easy, it's certainly not safe: -- there's very minimal steering and the area is covered in trees. -- You'll need to see which angles will take you near the fewest trees. -- -- Due to the local geology, trees in this area only grow on exact integer coordinates in a grid. -- You make a map (your puzzle input) of the open squares (.) and trees (#) you can see. For example: -- -- ..##....... -- #...#...#.. -- .#....#..#. -- ..#.#...#.# -- .#...##..#. -- ..#.##..... -- .#.#.#....# -- .#........# -- #.##...#... -- #...##....# -- .#..#...#.# -- -- These aren't the only trees, though; due to something you read about once involving arboreal genetics and biome stability, -- the same pattern repeats to the right many times: -- -- ..##.........##.........##.........##.........##.........##....... ---> -- #...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#.. -- .#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#. -- ..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.# -- .#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#. -- ..#.##.......#.##.......#.##.......#.##.......#.##.......#.##..... ---> -- .#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....# -- .#........#.#........#.#........#.#........#.#........#.#........# -- #.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#... -- #...##....##...##....##...##....##...##....##...##....##...##....# -- .#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.# ---> -- -- You start on the open square (.) -- in the top-left corner and need to reach the bottom (below the bottom-most row on your map). -- -- The toboggan can only follow a few specific slopes -- (you opted for a cheaper model that prefers rational numbers); -- start by counting all the trees you would encounter for the slope right 3, down 1: -- -- From your starting position at the top-left, check the position that is right 3 and down 1. -- Then, check the position that is right 3 and down 1 from there, and so on until you go past the bottom of the map. -- -- The locations you'd check in the above example are marked here with -- O where there was an open square and X where there was a tree: -- -- ..##.........##.........##.........##.........##.........##....... ---> -- #..O#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#.. -- .#....X..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#. -- ..#.#...#O#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.# -- .#...##..#..X...##..#..#...##..#..#...##..#..#...##..#..#...##..#. -- ..#.##.......#.X#.......#.##.......#.##.......#.##.......#.##..... ---> -- .#.#.#....#.#.#.#.O..#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....# -- .#........#.#........X.#........#.#........#.#........#.#........# -- #.##...#...#.##...#...#.X#...#...#.##...#...#.##...#...#.##...#... -- #...##....##...##....##...#X....##...##....##...##....##...##....# -- .#..#...#.#.#..#...#.#.#..#...X.#.#..#...#.#.#..#...#.#.#..#...#.# ---> -- -- In this example, traversing the map using this slope would cause you to encounter 7 trees. -- -- Starting at the top-left corner of your map and following a slope of -- right 3 and down 1, how many trees would you encounter? package Adventofcode.Day_3 is package Slopes is new Ada.Containers.Indefinite_Vectors (Natural, String); type Slope_Type is new Slopes.Vector with null record; function Race (Slope : Slope_Type; Right : Natural := 3; Down : Natural := 1) return Long_Long_Integer; procedure Read (Into_Slope : in out Slope_Type; Path : String); end Adventofcode.Day_3;
mgrojo/bingada
Ada
2,332
adb
--***************************************************************************** --* --* PROJECT: BingAda --* --* FILE: q_sound.sfml.adb --* --* AUTHOR: Manuel <mgrojo at github> --* --***************************************************************************** -- External sound library -- with Snd4ada_Hpp; with Ada.Directories; with Ada.Strings.Fixed; with Interfaces.C.Strings; with Gtkada.Intl; with Q_Bingo; package body Q_Sound is use type Interfaces.C.int; type T_Sound_Array is array (Q_Bingo.T_Number) of Interfaces.C.Int; V_Sounds : T_Sound_Array := (others => -1); --================================================================== function F_Filename (V_Number : Positive) return String is C_Number_Image : constant String := Ada.Strings.Fixed.Trim (V_Number'Image, Ada.Strings.Left); C_Path : constant String := "media/"; C_Extension : constant String := ".ogg"; C_Lang_Code_Last : constant := 2; C_Locale : constant String := Gtkada.Intl.Getlocale; C_Default_Lang : constant String := "en"; V_Lang : String (1 .. C_Lang_Code_Last) := C_Default_Lang; begin if C_Locale'Length >= C_Lang_Code_Last then V_Lang := C_Locale (C_Locale'First .. C_Locale'First + C_Lang_Code_Last - 1); end if; if not Ada.Directories.Exists (C_Path & V_Lang & '/' & C_Number_Image & C_Extension) then V_Lang := C_Default_Lang; end if; return C_Path & V_Lang & '/' & C_Number_Image & C_Extension; end F_Filename; --================================================================== procedure P_Initialize is begin snd4ada_hpp.initSnds; for V_Number in V_Sounds'Range loop V_Sounds (V_Number) := snd4ada_hpp.initSnd (Pc => Interfaces.C.Strings.New_String (F_Filename (V_Number)), Vol => 99); end loop; end P_Initialize; --================================================================== procedure P_Play_Number (V_Number : Positive) is begin snd4ada_hpp.playSnd (V_Sounds (V_number)); end P_Play_Number; --================================================================== procedure P_Clean_Up is begin snd4ada_hpp.termSnds; end P_Clean_Up; end Q_Sound;
AdaCore/libadalang
Ada
73
adb
with Pkg_1; procedure Foo is begin pragma Test (Pkg_1.Bar); end Foo;
optikos/oasis
Ada
6,000
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Constrained_Array_Types is function Create (Array_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Index_Subtypes : not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Of_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Component_Definition : not null Program.Elements.Component_Definitions .Component_Definition_Access) return Constrained_Array_Type is begin return Result : Constrained_Array_Type := (Array_Token => Array_Token, Left_Bracket_Token => Left_Bracket_Token, Index_Subtypes => Index_Subtypes, Right_Bracket_Token => Right_Bracket_Token, Of_Token => Of_Token, Component_Definition => Component_Definition, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Index_Subtypes : not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access; Component_Definition : not null Program.Elements.Component_Definitions .Component_Definition_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Constrained_Array_Type is begin return Result : Implicit_Constrained_Array_Type := (Index_Subtypes => Index_Subtypes, Component_Definition => Component_Definition, 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 Index_Subtypes (Self : Base_Constrained_Array_Type) return not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access is begin return Self.Index_Subtypes; end Index_Subtypes; overriding function Component_Definition (Self : Base_Constrained_Array_Type) return not null Program.Elements.Component_Definitions .Component_Definition_Access is begin return Self.Component_Definition; end Component_Definition; overriding function Array_Token (Self : Constrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Array_Token; end Array_Token; overriding function Left_Bracket_Token (Self : Constrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Left_Bracket_Token; end Left_Bracket_Token; overriding function Right_Bracket_Token (Self : Constrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Right_Bracket_Token; end Right_Bracket_Token; overriding function Of_Token (Self : Constrained_Array_Type) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Of_Token; end Of_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Constrained_Array_Type) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Constrained_Array_Type) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Constrained_Array_Type) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Constrained_Array_Type'Class) is begin for Item in Self.Index_Subtypes.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; Set_Enclosing_Element (Self.Component_Definition, Self'Unchecked_Access); null; end Initialize; overriding function Is_Constrained_Array_Type_Element (Self : Base_Constrained_Array_Type) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Constrained_Array_Type_Element; overriding function Is_Type_Definition_Element (Self : Base_Constrained_Array_Type) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Type_Definition_Element; overriding function Is_Definition_Element (Self : Base_Constrained_Array_Type) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Definition_Element; overriding procedure Visit (Self : not null access Base_Constrained_Array_Type; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Constrained_Array_Type (Self); end Visit; overriding function To_Constrained_Array_Type_Text (Self : aliased in out Constrained_Array_Type) return Program.Elements.Constrained_Array_Types .Constrained_Array_Type_Text_Access is begin return Self'Unchecked_Access; end To_Constrained_Array_Type_Text; overriding function To_Constrained_Array_Type_Text (Self : aliased in out Implicit_Constrained_Array_Type) return Program.Elements.Constrained_Array_Types .Constrained_Array_Type_Text_Access is pragma Unreferenced (Self); begin return null; end To_Constrained_Array_Type_Text; end Program.Nodes.Constrained_Array_Types;
gspu/synth
Ada
10,438
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Text_IO; with JohnnyText; with Definitions; use Definitions; private with Ada.Characters.Latin_1; private with Ada.Directories; private with Parameters; private with Unix; package Replicant is package JT renames JohnnyText; package TIO renames Ada.Text_IO; scenario_unexpected : exception; type slave_options is record need_procfs : Boolean := False; need_linprocfs : Boolean := False; skip_cwrappers : Boolean := False; end record; type package_abi is record calculated_abi : JT.Text; calculated_alt_abi : JT.Text; calc_abi_noarch : JT.Text; calc_alt_abi_noarch : JT.Text; end record; -- For every single port to be built, the build need to first be created -- and then destroyed when the build is complete. procedure launch_slave (id : builders; opts : slave_options); procedure destroy_slave (id : builders; opts : slave_options); -- This needs to be run as soon as the configuration profile is loaded, -- env before the "initialize" function procedure set_platform; -- This procedure needs to be run once. -- It basically sets the operating system "flavor" which affects the -- mount command spawning. It also creates the password database procedure initialize (testmode : Boolean; num_cores : cpu_range); -- This removes the password database procedure finalize; -- Returns True if any mounts are detected (used by pilot) function synth_mounts_exist return Boolean; -- Returns True if any _work/_localbase dirs are detected (used by pilot) function disk_workareas_exist return Boolean; -- Returns True if the attempt to clear mounts is successful. function clear_existing_mounts return Boolean; -- Returns True if the attempt to remove the disk work areas is successful function clear_existing_workareas return Boolean; -- The actual command to build a local repository (Returns True on success) function build_repository (id : builders; sign_command : String := "") return Boolean; -- Returns all the UNAME_x environment variables -- They will be passed to the buildcycle package function jail_environment return JT.Text; -- On FreeBSD, if "/boot" exists but "/boot/modules" does not, return True -- This is a pre-run validity check function boot_modules_directory_missing return Boolean; root_localbase : constant String := "/usr/local"; private package PM renames Parameters; package AD renames Ada.Directories; package LAT renames Ada.Characters.Latin_1; type mount_mode is (readonly, readwrite); type flavors is (unknown, freebsd, dragonfly, netbsd, linux, solaris); type folder_operation is (lock, unlock); type folder is (bin, sbin, lib, libexec, usr_bin, usr_include, usr_lib, usr_libdata, usr_libexec, usr_sbin, usr_share, usr_lib32, xports, options, packages, distfiles, dev, etc, etc_default, etc_mtree, etc_rcd, home, linux, proc, root, tmp, var, wrkdirs, usr_local, usr_src, ccache, boot, usr_x11r7, usr_games); subtype subfolder is folder range bin .. usr_share; subtype filearch is String (1 .. 11); -- home and root need to be set readonly reference_base : constant String := "Base"; root_bin : constant String := "/bin"; root_sbin : constant String := "/sbin"; root_X11R7 : constant String := "/usr/X11R7"; root_usr_bin : constant String := "/usr/bin"; root_usr_games : constant String := "/usr/games"; root_usr_include : constant String := "/usr/include"; root_usr_lib : constant String := "/usr/lib"; root_usr_lib32 : constant String := "/usr/lib32"; root_usr_libdata : constant String := "/usr/libdata"; root_usr_libexec : constant String := "/usr/libexec"; root_usr_sbin : constant String := "/usr/sbin"; root_usr_share : constant String := "/usr/share"; root_usr_src : constant String := "/usr/src"; root_dev : constant String := "/dev"; root_etc : constant String := "/etc"; root_etc_default : constant String := "/etc/defaults"; root_etc_mtree : constant String := "/etc/mtree"; root_etc_rcd : constant String := "/etc/rc.d"; root_lib : constant String := "/lib"; root_tmp : constant String := "/tmp"; root_var : constant String := "/var"; root_home : constant String := "/home"; root_boot : constant String := "/boot"; root_boot_fw : constant String := "/boot/firmware"; root_kmodules : constant String := "/boot/modules"; root_lmodules : constant String := "/boot/modules.local"; root_root : constant String := "/root"; root_proc : constant String := "/proc"; root_linux : constant String := "/compat/linux"; root_linproc : constant String := "/compat/linux/proc"; root_xports : constant String := "/xports"; root_options : constant String := "/options"; root_libexec : constant String := "/libexec"; root_wrkdirs : constant String := "/construction"; root_packages : constant String := "/packages"; root_distfiles : constant String := "/distfiles"; root_ccache : constant String := "/ccache"; chroot : constant String := "/usr/sbin/chroot "; platform_type : flavors := unknown; smp_cores : cpu_range := cpu_range'First; support_locks : Boolean; developer_mode : Boolean; abn_log_ready : Boolean; builder_env : JT.Text; abnormal_log : TIO.File_Type; abnormal_cmd_logname : constant String := "05_abnormal_command_output.log"; -- Throws exception if mount attempt was unsuccessful procedure mount_nullfs (target, mount_point : String; mode : mount_mode := readonly); -- Throws exception if mount attempt was unsuccessful procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0); -- Throws exception if unmount attempt was unsuccessful procedure unmount (device_or_node : String); -- Throws exception if directory was not successfully created procedure forge_directory (target : String); -- Return the full path of the mount point function location (mount_base : String; point : folder) return String; function mount_target (point : folder) return String; -- Query configuration to determine the master mount function get_master_mount return String; function get_slave_mount (id : builders) return String; -- returns "SLXX" where XX is a zero-padded integer (01 .. 32) function slave_name (id : builders) return String; -- locks and unlocks folders, even from root procedure folder_access (path : String; operation : folder_operation); -- self explanatory procedure create_symlink (destination, symbolic_link : String); -- generic command, throws exception if exit code is not 0 procedure execute (command : String); procedure silent_exec (command : String); function internal_system_command (command : String) return JT.Text; -- create slave's /var directory tree. Path should be an empty directory. procedure populate_var_folder (path : String); -- create /etc/make.conf in slave procedure create_make_conf (path_to_etc : String; skip_cwrappers : Boolean); -- create /etc/passwd (and databases) to define system users procedure create_passwd (path_to_etc : String); procedure create_base_passwd (path_to_mm : String); -- create /etc/group to define root user procedure create_group (path_to_etc : String); procedure create_base_group (path_to_mm : String); -- copy host's /etc/resolv.conf to slave procedure copy_resolv_conf (path_to_etc : String); -- copy host's /etc/mtree files to slave procedure copy_mtree_files (path_to_mtree : String); -- copy host's conf defaults procedure copy_rc_default (path_to_etc : String); procedure copy_etc_rcsubr (path_to_etc : String); procedure copy_ldconfig (path_to_etc : String); -- create minimal /etc/services procedure create_etc_services (path_to_etc : String); -- create a dummy fstab for linux packages (looks for linprocfs) procedure create_etc_fstab (path_to_etc : String); -- create /etc/shells, required by install scripts of some packages procedure create_etc_shells (path_to_etc : String); -- mount the devices procedure mount_devices (path_to_dev : String); procedure unmount_devices (path_to_dev : String); -- execute ldconfig as last action of slave creation procedure execute_ldconfig (id : builders); -- Used for per-profile make.conf fragments (if they exist) procedure concatenate_makeconf (makeconf_handle : TIO.File_Type; target_name : String); -- Wrapper for rm -rf <directory> procedure annihilate_directory_tree (tree : String); -- This is only done for FreeBSD. For DragonFly, it's a null-op procedure mount_linprocfs (mount_point : String); -- It turns out at least one major port uses procfs (gnustep) procedure mount_procfs (path_to_proc : String); procedure unmount_procfs (path_to_proc : String); -- Change mount mode to read-only procedure set_mount_as_read_only (mount_point : String); -- Used to generic mtree exclusion files procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type); procedure write_preinstall_section (mtreefile : TIO.File_Type); procedure create_mtree_exc_preconfig (path_to_mm : String); procedure create_mtree_exc_preinst (path_to_mm : String); -- capture unexpected output while setting up builders (e.g. mount) procedure start_abnormal_logging; procedure stop_abnormal_logging; -- Generic directory copy utility (ordinary files only) function copy_directory_contents (src_directory : String; tgt_directory : String; pattern : String) return Boolean; end Replicant;
reznikmm/matreshka
Ada
4,197
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Properties.Declarations.Function_Declarations; package body Properties.Declarations.Procedure_Declaration is --------------------- -- Call_Convention -- --------------------- function Call_Convention (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Convention_Property) return Engines.Convention_Kind renames Properties.Declarations.Function_Declarations.Call_Convention; -------------------- -- Intrinsic_Name -- -------------------- function Intrinsic_Name (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String renames Properties.Declarations.Function_Declarations.Intrinsic_Name; end Properties.Declarations.Procedure_Declaration;
reznikmm/matreshka
Ada
4,123
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Table_Label_Cell_Range_Address_Attributes; package Matreshka.ODF_Table.Label_Cell_Range_Address_Attributes is type Table_Label_Cell_Range_Address_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Label_Cell_Range_Address_Attributes.ODF_Table_Label_Cell_Range_Address_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Label_Cell_Range_Address_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Label_Cell_Range_Address_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Label_Cell_Range_Address_Attributes;
optikos/oasis
Ada
6,364
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Defining_Identifiers; with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Return_Object_Specifications; with Program.Element_Visitors; package Program.Nodes.Return_Object_Specifications is pragma Preelaborate; type Return_Object_Specification is new Program.Nodes.Node and Program.Elements.Return_Object_Specifications .Return_Object_Specification and Program.Elements.Return_Object_Specifications .Return_Object_Specification_Text with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Colon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Aliased_Token : Program.Lexical_Elements.Lexical_Element_Access; Constant_Token : Program.Lexical_Elements.Lexical_Element_Access; Object_Subtype : not null Program.Elements.Element_Access; Assignment_Token : Program.Lexical_Elements.Lexical_Element_Access; Expression : Program.Elements.Expressions.Expression_Access) return Return_Object_Specification; type Implicit_Return_Object_Specification is new Program.Nodes.Node and Program.Elements.Return_Object_Specifications .Return_Object_Specification with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Object_Subtype : not null Program.Elements.Element_Access; Expression : Program.Elements.Expressions.Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Aliased : Boolean := False; Has_Constant : Boolean := False) return Implicit_Return_Object_Specification with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Return_Object_Specification is abstract new Program.Nodes.Node and Program.Elements.Return_Object_Specifications .Return_Object_Specification with record Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Object_Subtype : not null Program.Elements.Element_Access; Expression : Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Return_Object_Specification'Class); overriding procedure Visit (Self : not null access Base_Return_Object_Specification; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Return_Object_Specification) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Object_Subtype (Self : Base_Return_Object_Specification) return not null Program.Elements.Element_Access; overriding function Expression (Self : Base_Return_Object_Specification) return Program.Elements.Expressions.Expression_Access; overriding function Is_Return_Object_Specification_Element (Self : Base_Return_Object_Specification) return Boolean; overriding function Is_Declaration_Element (Self : Base_Return_Object_Specification) return Boolean; type Return_Object_Specification is new Base_Return_Object_Specification and Program.Elements.Return_Object_Specifications .Return_Object_Specification_Text with record Colon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Aliased_Token : Program.Lexical_Elements.Lexical_Element_Access; Constant_Token : Program.Lexical_Elements.Lexical_Element_Access; Assignment_Token : Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Return_Object_Specification_Text (Self : aliased in out Return_Object_Specification) return Program.Elements.Return_Object_Specifications .Return_Object_Specification_Text_Access; overriding function Colon_Token (Self : Return_Object_Specification) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Aliased_Token (Self : Return_Object_Specification) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Constant_Token (Self : Return_Object_Specification) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Assignment_Token (Self : Return_Object_Specification) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Aliased (Self : Return_Object_Specification) return Boolean; overriding function Has_Constant (Self : Return_Object_Specification) return Boolean; type Implicit_Return_Object_Specification is new Base_Return_Object_Specification with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Aliased : Boolean; Has_Constant : Boolean; end record; overriding function To_Return_Object_Specification_Text (Self : aliased in out Implicit_Return_Object_Specification) return Program.Elements.Return_Object_Specifications .Return_Object_Specification_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Return_Object_Specification) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Return_Object_Specification) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Return_Object_Specification) return Boolean; overriding function Has_Aliased (Self : Implicit_Return_Object_Specification) return Boolean; overriding function Has_Constant (Self : Implicit_Return_Object_Specification) return Boolean; end Program.Nodes.Return_Object_Specifications;
reznikmm/matreshka
Ada
5,079
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.Internals.UML_Elements; with AMF.Standard_Profile_L3.System_Models; with AMF.UML.Models; with AMF.Visitors; package AMF.Internals.Standard_Profile_L3_System_Models is type Standard_Profile_L3_System_Model_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Base and AMF.Standard_Profile_L3.System_Models.Standard_Profile_L3_System_Model with null record; overriding function Get_Base_Model (Self : not null access constant Standard_Profile_L3_System_Model_Proxy) return AMF.UML.Models.UML_Model_Access; -- Getter of SystemModel::base_Model. -- overriding procedure Set_Base_Model (Self : not null access Standard_Profile_L3_System_Model_Proxy; To : AMF.UML.Models.UML_Model_Access); -- Setter of SystemModel::base_Model. -- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L3_System_Model_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L3_System_Model_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L3_System_Model_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.Standard_Profile_L3_System_Models;
reznikmm/matreshka
Ada
6,860
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_Meta.Printed_By_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Meta_Printed_By_Element_Node is begin return Self : Meta_Printed_By_Element_Node do Matreshka.ODF_Meta.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Meta_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Meta_Printed_By_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_Meta_Printed_By (ODF.DOM.Meta_Printed_By_Elements.ODF_Meta_Printed_By_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 Meta_Printed_By_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Printed_By_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Meta_Printed_By_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_Meta_Printed_By (ODF.DOM.Meta_Printed_By_Elements.ODF_Meta_Printed_By_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 Meta_Printed_By_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_Meta_Printed_By (Visitor, ODF.DOM.Meta_Printed_By_Elements.ODF_Meta_Printed_By_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.Meta_URI, Matreshka.ODF_String_Constants.Printed_By_Element, Meta_Printed_By_Element_Node'Tag); end Matreshka.ODF_Meta.Printed_By_Elements;
stcarrez/ada-el
Ada
3,687
adb
----------------------------------------------------------------------- -- el-methods-func_1 -- Function Bindings with 1 argument -- Copyright (C) 2010, 2011, 2012, 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 Util.Beans.Objects; package body EL.Methods.Func_1 is use EL.Expressions; -- ------------------------------ -- Returns True if the method is a valid method which accepts the arguments -- defined by the package instantiation. -- ------------------------------ function Is_Valid (Method : in EL.Expressions.Method_Info) return Boolean is begin if Method.Binding = null then return False; else return Method.Binding.all in Binding'Class; end if; end Is_Valid; -- ------------------------------ -- Execute the method describe by the method expression -- and with the given context. The method signature is: -- -- function F (Obj : <Bean>; Param : Param1_Type) return Return_Type; -- -- where <Bean> inherits from <b>Readonly_Bean</b> -- (See <b>Bind</b> package) -- -- Raises <b>Invalid_Method</b> if the method referenced by -- the method expression does not exist or does not match -- the signature. -- ------------------------------ function Execute (Method : in EL.Expressions.Method_Expression'Class; Param : in Param1_Type; Context : in EL.Contexts.ELContext'Class) return Return_Type is Info : constant Method_Info := Method.Get_Method_Info (Context); begin if Info.Binding = null then raise EL.Expressions.Invalid_Method with "Method not found"; end if; -- If the binding has the wrong type, we are trying to invoke -- a method with a different signature. if not (Info.Binding.all in Binding'Class) then raise EL.Expressions.Invalid_Method with "Invalid signature for method '" & Info.Binding.Name.all & "'"; end if; declare use Util.Beans.Objects; Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Info.Object); Proxy : constant Binding_Access := Binding (Info.Binding.all)'Access; begin return Proxy.Method (Bean.all, Param); end; end Execute; -- ------------------------------ -- Proxy for the binding. -- The proxy declares the binding definition that links -- the name to the function and it implements the necessary -- object conversion to translate the <b>Readonly_Bean</b> -- object to the target object type. -- ------------------------------ package body Bind is function Method_Access (O : Util.Beans.Basic.Readonly_Bean'Class; P1 : Param1_Type) return Return_Type is Object : constant Bean := Bean (O); Result : constant Return_Type := Method (Object, P1); begin return Result; end Method_Access; end Bind; end EL.Methods.Func_1;
reznikmm/matreshka
Ada
6,740
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Time_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Time_Element_Node is begin return Self : Text_Time_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Time_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Time (ODF.DOM.Text_Time_Elements.ODF_Text_Time_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Time_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Time_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Time_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Time (ODF.DOM.Text_Time_Elements.ODF_Text_Time_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Time_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Time (Visitor, ODF.DOM.Text_Time_Elements.ODF_Text_Time_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Time_Element, Text_Time_Element_Node'Tag); end Matreshka.ODF_Text.Time_Elements;
sungyeon/drake
Ada
2,663
ads
pragma License (Unrestricted); -- implementation unit specialized for Linux with C.bits.dirent; with C.dirent; package System.Native_Directories.Searching is pragma Preelaborate; subtype Directory_Entry_Access is C.bits.dirent.struct_dirent_ptr; function New_Directory_Entry (Source : not null Directory_Entry_Access) return not null Directory_Entry_Access; procedure Free (X : in out Directory_Entry_Access); type Directory_Entry_Additional_Type is record Filled : Boolean; Information : aliased C.sys.stat.struct_stat; end record; pragma Suppress_Initialization (Directory_Entry_Additional_Type); -- same as Ada.Directories.Filter_Type type Filter_Type is array (File_Kind) of Boolean; pragma Pack (Filter_Type); pragma Suppress_Initialization (Filter_Type); subtype Handle_Type is C.dirent.DIR_ptr; Null_Handle : constant Handle_Type := null; type Search_Type is record Handle : C.dirent.DIR_ptr; Pattern : C.char_ptr; Filter : Filter_Type; end record; pragma Suppress_Initialization (Search_Type); procedure Start_Search ( Search : aliased in out Search_Type; Directory : String; Pattern : String; Filter : Filter_Type; Directory_Entry : out Directory_Entry_Access; Has_Next_Entry : out Boolean); procedure End_Search ( Search : aliased in out Search_Type; Raise_On_Error : Boolean); procedure Get_Next_Entry ( Search : aliased in out Search_Type; Directory_Entry : out Directory_Entry_Access; Has_Next_Entry : out Boolean); procedure Get_Entry ( Directory : String; Name : String; Directory_Entry : aliased out Directory_Entry_Access; -- allocated Additional : aliased in out Directory_Entry_Additional_Type); function Simple_Name (Directory_Entry : not null Directory_Entry_Access) return String; function Kind (Directory_Entry : not null Directory_Entry_Access) return File_Kind; function Size ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Additional : aliased in out Directory_Entry_Additional_Type) return Ada.Streams.Stream_Element_Count; function Modification_Time ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Additional : aliased in out Directory_Entry_Additional_Type) return Native_Calendar.Native_Time; procedure Get_Information ( Directory : String; Directory_Entry : not null Directory_Entry_Access; Information : aliased out C.sys.stat.struct_stat); end System.Native_Directories.Searching;
apple-oss-distributions/old_ncurses
Ada
5,230
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.Enumeration -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Interfaces.C.Strings; package Terminal_Interface.Curses.Forms.Field_Types.Enumeration is pragma Preelaborate (Terminal_Interface.Curses.Forms.Field_Types.Enumeration); type String_Access is access String; -- Type_Set is used by the child package Ada type Type_Set is (Lower_Case, Upper_Case, Mixed_Case); type Enum_Array is array (Positive range <>) of String_Access; type Enumeration_Info (C : Positive) is record Names : Enum_Array (1 .. C); Case_Sensitive : Boolean := False; Match_Must_Be_Unique : Boolean := False; end record; type Enumeration_Field is new Field_Type with private; function Create (Info : Enumeration_Info; Auto_Release_Names : Boolean := False) return Enumeration_Field; -- Make an fieldtype from the info. Enumerations are special, because -- they normally don't copy the enum values into a private store, so -- we have to care for the lifetime of the info we provide. -- The Auto_Release_Names flag may be used to automatically releases -- the strings in the Names array of the Enumeration_Info. function Make_Enumeration_Type (Info : Enumeration_Info; Auto_Release_Names : Boolean := False) return Enumeration_Field renames Create; procedure Release (Enum : in out Enumeration_Field); -- But we may want to release the field to release the memory allocated -- by it internally. After that the Enumeration field is no longer usable. -- The next type defintions are all ncurses extensions. They are typically -- not available in other curses implementations. procedure Set_Field_Type (Fld : in Field; Typ : in Enumeration_Field); pragma Inline (Set_Field_Type); private type CPA_Access is access Interfaces.C.Strings.chars_ptr_array; type Enumeration_Field is new Field_Type with record Case_Sensitive : Boolean := False; Match_Must_Be_Unique : Boolean := False; Arr : CPA_Access := null; end record; end Terminal_Interface.Curses.Forms.Field_Types.Enumeration;
reinertk/cpros
Ada
70
ads
package cpros_exceptions is cfe0 : exception; end cpros_exceptions;
fnarenji/BoiteMaker
Ada
2,794
adb
with logger; use logger; package body petit_poucet is -- Instancie un petit poucet function get_petit_poucet(start_pos : point_t) return petit_poucet_t is start_node : constant node_ptr := create(start_pos); begin debug("Naissance d'un petit poucet à la position " & to_string(start_pos)); return (start_pos => start_pos, curr_pos => start_pos, start_node => start_node, curr_node => start_node); end; -- Obtient les points laissés par le petit poucet function get_points(poucet : petit_poucet_t) return node_ptr is begin return poucet.start_node; end; -- Cette fonction générique permet d'éviter d'écrire de multiple fois les fonctions mv_* qui sont essentiellement les mêmes, exceptées qu'elles fonctions sur des axes différents (x ou y) et avec des multiplicateurs différents (delta * -1 pour aller à gauche/en haut, delta * 1 sinon) -- en passant une fonction de mv (mv_x ou mv_y du package point) et un mult en tant que paramètre de généricité generic debug_string : string; mv : mv_point_ptr; mult : integer; procedure mv_poucet(poucet : in out petit_poucet_t; delta_axis : float); -- corps de la fonction générique à part car Ada n'autorise pas -- déclaration + impl. en même temps quand il s'agit de blocs génériques procedure mv_poucet(poucet : in out petit_poucet_t; delta_axis : float) is begin debug("Le poucet se déplace vers " & debug_string & " de " & float'image(delta_axis)); mv(poucet.curr_pos, delta_axis * float(mult)); poucet.curr_node := add_after(poucet.curr_node, poucet.curr_pos); end; -- Instanciations des fonctions de mouvement avec pour nom internal_* -- On ne peut les instancier directement en tant que mv_* -- car Ada ne l'autorise pas (message: instanciation cannot provide for body) procedure internal_mv_l is new mv_poucet ("l", mv_x_ptr, -1); procedure internal_mv_r is new mv_poucet ("r", mv_x_ptr, 1); procedure internal_mv_u is new mv_poucet ("u", mv_y_ptr, -1); procedure internal_mv_d is new mv_poucet ("d", mv_y_ptr, 1); -- Un renommage est par contre une manière valide -- de fournir un corps à une fonction déclarée dans le package -- (contrairement à une instanciation de fonction générique) procedure mv_l(poucet : in out petit_poucet_t; delta_x : float) renames internal_mv_l; procedure mv_r(poucet : in out petit_poucet_t; delta_x : float) renames internal_mv_r; procedure mv_u(poucet : in out petit_poucet_t; delta_y : float) renames internal_mv_u; procedure mv_d(poucet : in out petit_poucet_t; delta_y : float) renames internal_mv_d; end;
AdaCore/libadalang
Ada
587
adb
procedure Test is function Foo (A : Integer) return Float; A : Float := Foo --% node.p_failsafe_referenced_def_name(True) (12); B : Integer := Foo --% node.p_failsafe_referenced_def_name(True) (12); C : Integer := Barz --% node.p_failsafe_referenced_def_name(True) (12); D : Integer; --% node.p_defining_name.p_failsafe_referenced_def_name() E : Integer := F --% node.p_failsafe_referenced_def_name() ; G : Integer := D 'Size --% node.p_failsafe_referenced_def_name() ; begin null; end Test;
optikos/oasis
Ada
8,138
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Known_Discriminant_Parts; with Program.Elements.Aspect_Specifications; with Program.Elements.Expressions; with Program.Elements.Protected_Definitions; with Program.Elements.Protected_Type_Declarations; with Program.Element_Visitors; package Program.Nodes.Protected_Type_Declarations is pragma Preelaborate; type Protected_Type_Declaration is new Program.Nodes.Node and Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration and Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration_Text with private; function Create (Protected_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Type_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Discriminant_Part : Program.Elements.Known_Discriminant_Parts .Known_Discriminant_Part_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; New_Token : Program.Lexical_Elements.Lexical_Element_Access; Progenitors : Program.Elements.Expressions.Expression_Vector_Access; With_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Definition : not null Program.Elements.Protected_Definitions .Protected_Definition_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Protected_Type_Declaration; type Implicit_Protected_Type_Declaration is new Program.Nodes.Node and Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration with private; function Create (Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Discriminant_Part : Program.Elements.Known_Discriminant_Parts .Known_Discriminant_Part_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Progenitors : Program.Elements.Expressions .Expression_Vector_Access; Definition : not null Program.Elements.Protected_Definitions .Protected_Definition_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Protected_Type_Declaration with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Protected_Type_Declaration is abstract new Program.Nodes.Node and Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration with record Name : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Discriminant_Part : Program.Elements.Known_Discriminant_Parts .Known_Discriminant_Part_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Progenitors : Program.Elements.Expressions .Expression_Vector_Access; Definition : not null Program.Elements.Protected_Definitions .Protected_Definition_Access; end record; procedure Initialize (Self : aliased in out Base_Protected_Type_Declaration'Class); overriding procedure Visit (Self : not null access Base_Protected_Type_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Protected_Type_Declaration) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; overriding function Discriminant_Part (Self : Base_Protected_Type_Declaration) return Program.Elements.Known_Discriminant_Parts .Known_Discriminant_Part_Access; overriding function Aspects (Self : Base_Protected_Type_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; overriding function Progenitors (Self : Base_Protected_Type_Declaration) return Program.Elements.Expressions.Expression_Vector_Access; overriding function Definition (Self : Base_Protected_Type_Declaration) return not null Program.Elements.Protected_Definitions .Protected_Definition_Access; overriding function Is_Protected_Type_Declaration_Element (Self : Base_Protected_Type_Declaration) return Boolean; overriding function Is_Declaration_Element (Self : Base_Protected_Type_Declaration) return Boolean; type Protected_Type_Declaration is new Base_Protected_Type_Declaration and Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration_Text with record Protected_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Type_Token : not null Program.Lexical_Elements .Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; New_Token : Program.Lexical_Elements.Lexical_Element_Access; With_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Protected_Type_Declaration_Text (Self : aliased in out Protected_Type_Declaration) return Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration_Text_Access; overriding function Protected_Token (Self : Protected_Type_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Type_Token (Self : Protected_Type_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Protected_Type_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Protected_Type_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function New_Token (Self : Protected_Type_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token_2 (Self : Protected_Type_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Protected_Type_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Protected_Type_Declaration is new Base_Protected_Type_Declaration with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Protected_Type_Declaration_Text (Self : aliased in out Implicit_Protected_Type_Declaration) return Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Protected_Type_Declaration) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Protected_Type_Declaration) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Protected_Type_Declaration) return Boolean; end Program.Nodes.Protected_Type_Declarations;
stcarrez/ada-util
Ada
945
ads
----------------------------------------------------------------------- -- util-concurrent -- Concurrent Tools -- Copyright (C) 2001, 2002, 2003, 2009, 2010, 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. ----------------------------------------------------------------------- package Util.Concurrent is pragma Pure; end Util.Concurrent;
charlie5/aIDE
Ada
5,525
adb
with Ada.Exceptions; with Ada.Wide_Text_IO; with Ada.Characters.Handling; with Asis; with Asis.Ada_Environments; with Asis.Implementation; with Asis.Exceptions; with Asis.Errors; with AdaM.Assist.Query.find_All.context_Processing; procedure AdaM.Assist.Query.find_All.Driver is My_Context : Asis.Context; My_Context_Name : constant Wide_String := Asis.Ada_Environments.Default_Name; -- The default name in case of the GNAT ASIS implementation is empty. -- If you would like to have some non-null name for your ASIS Context, -- change the initialization expression in this declaration. Note, that -- in the GNAT ASIS implementation the name of a Context does not have any -- special meaning or semantics associated with particular names. My_Context_Parameters : constant Wide_String := Asis.Ada_Environments.Default_Parameters; -- The default COntext parameters in case of the GNAT ASIS implementation -- are an empty string. This corresponds to the following Context -- definition: "-CA -FT -SA", and has the following meaning: -- -CA - a Context is made up by all the tree files in the tree search -- path; the tree search path is not set, so the default is used, -- and the default is the current directory; -- -FT - only pre-created trees are used, no tree file can be created by -- ASIS; -- -SA - source files for all the Compilation Units belonging to the -- Context (except the predefined Standard package) are considered -- in the consistency check when opening the Context; -- -- If you would like to use some other Context definition, you have to -- replace the initialization expression in this declaration by -- the corresponding Parameters string. See the ASIS Reference Manual for -- the full details of the Context definition for the GNAT ASIS -- implementation. Initialization_Parameters : constant Wide_String := ""; Finalization_Parameters : constant Wide_String := ""; -- If you would like to use some specific initialization or finalization -- parameters, you may set them here as initialization expressions in -- the declarations above. begin -- The code below corresponds to the basic sequencing of calls to ASIS -- queries which is mandatory for any ASIS application. -- First, the ASIS implementation should be initialized -- (Asis.Implementation.Initialize), then an application should define -- an ASIS Context to process by associating the Context with an external -- environment (Asis.Ada_Environments.Associate), then the Context should -- be opened (sis.Ada_Environments.Open ). After that all the ASIS queries -- may be used (the ASIS processing is encapsulated in -- Context_Processing.Process_Context. When the ASIS analysis is over, the -- application should release the system resources by closing the ASIS -- Context (Asis.Ada_Environments.Close), breaking the association of the -- Context with the external world (Asis.Ada_Environments.Dissociate) and -- finalizing the ASIS implementation (Asis.Implementation.Finalize). Asis.Implementation.Initialize (Initialization_Parameters); Asis.Ada_Environments.Associate (The_Context => My_Context, Name => My_Context_Name, Parameters => My_Context_Parameters); Asis.Ada_Environments.Open (My_Context); AdaM.Assist.Query.find_All.context_Processing.Process_Context (The_Context => My_Context, Trace => False); Asis.Ada_Environments.Close (My_Context); Asis.Ada_Environments.Dissociate (My_Context); Asis.Implementation.Finalize (Finalization_Parameters); exception -- The exception handling in this driver is somewhat redundant and may -- need some reconsidering when using this driver in real ASIS tools when Ex : Asis.Exceptions.ASIS_Inappropriate_Context | Asis.Exceptions.ASIS_Inappropriate_Container | Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit | Asis.Exceptions.ASIS_Inappropriate_Element | Asis.Exceptions.ASIS_Inappropriate_Line | Asis.Exceptions.ASIS_Inappropriate_Line_Number | Asis.Exceptions.ASIS_Failed => Ada.Wide_Text_IO.Put ("ASIS exception ("); Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String ( Ada.Exceptions.Exception_Name (Ex))); Ada.Wide_Text_IO.Put (") is raised"); Ada.Wide_Text_IO.New_Line; Ada.Wide_Text_IO.Put ("ASIS Error Status is "); Ada.Wide_Text_IO.Put (Asis.Errors.Error_Kinds'Wide_Image (Asis.Implementation.Status)); Ada.Wide_Text_IO.New_Line; Ada.Wide_Text_IO.Put ("ASIS Diagnosis is "); Ada.Wide_Text_IO.New_Line; Ada.Wide_Text_IO.Put (Asis.Implementation.Diagnosis); Ada.Wide_Text_IO.New_Line; Asis.Implementation.Set_Status; when Ex : others => Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String ( Ada.Exceptions.Exception_Name (Ex))); Ada.Wide_Text_IO.Put (" is raised ("); Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String ( Ada.Exceptions.Exception_Information (Ex))); Ada.Wide_Text_IO.Put (")"); Ada.Wide_Text_IO.New_Line; end AdaM.Assist.Query.find_All.Driver;
bannzai/openapi-generator
Ada
13,938
adb
-- Swagger Petstore -- This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special_key` to test the authorization filters. -- -- OpenAPI spec version: 1.0.0 -- Contact: [email protected] -- -- NOTE: This package is auto generated by the swagger code generator 2.4.0-SNAPSHOT. -- https://github.com/swagger-api/swagger-codegen.git -- Do not edit the class manually. with Swagger.Streams; package body Samples.Petstore.Clients is -- Add a new pet to the store procedure Add_Pet (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICATION_XML)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/pet"); Client.Call (Swagger.Clients.POST, URI, Req); end Add_Pet; -- Deletes a pet procedure Delete_Pet (Client : in out Client_Type; Pet_Id : in Swagger.Long; Api_Key : in Swagger.Nullable_UString) is URI : Swagger.Clients.URI_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.DELETE, URI); end Delete_Pet; -- Finds Pets by status -- Multiple status values can be provided with comma separated strings procedure Find_Pets_By_Status (Client : in out Client_Type; Status : in Swagger.Nullable_UString_Vectors.Vector; Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Add_Param ("status", Status); URI.Set_Path ("/pet/findByStatus"); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Find_Pets_By_Status; -- Finds Pets by tags -- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. procedure Find_Pets_By_Tags (Client : in out Client_Type; Tags : in Swagger.Nullable_UString_Vectors.Vector; Result : out Samples.Petstore.Models.Pet_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Add_Param ("tags", Tags); URI.Set_Path ("/pet/findByTags"); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Find_Pets_By_Tags; -- Find pet by ID -- Returns a single pet procedure Get_Pet_By_Id (Client : in out Client_Type; Pet_Id : in Swagger.Long; Result : out Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_Pet_By_Id; -- Update an existing pet procedure Update_Pet (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.Pet_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (Swagger.Clients.APPLICATION_JSON, Swagger.Clients.APPLICATION_XML)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/pet"); Client.Call (Swagger.Clients.PUT, URI, Req); end Update_Pet; -- Updates a pet in the store with form data procedure Update_Pet_With_Form (Client : in out Client_Type; Pet_Id : in Swagger.Long; Name : in Swagger.Nullable_UString; Status : in Swagger.Nullable_UString) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_FORM)); Req.Stream.Write_Entity ("name", Name); Req.Stream.Write_Entity ("status", Status); URI.Set_Path ("/pet/{petId}"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.POST, URI, Req); end Update_Pet_With_Form; -- uploads an image procedure Upload_File (Client : in out Client_Type; Pet_Id : in Swagger.Long; Additional_Metadata : in Swagger.Nullable_UString; File : in Swagger.File_Part_Type; Result : out Samples.Petstore.Models.ApiResponse_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_FORM)); Req.Stream.Write_Entity ("additionalMetadata", Additional_Metadata); Req.Stream.Write_Entity ("file", File); URI.Set_Path ("/pet/{petId}/uploadImage"); URI.Set_Path_Param ("petId", Swagger.To_String (Pet_Id)); Client.Call (Swagger.Clients.POST, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Upload_File; -- Delete purchase order by ID -- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors procedure Delete_Order (Client : in out Client_Type; Order_Id : in Swagger.UString) is URI : Swagger.Clients.URI_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/store/order/{orderId}"); URI.Set_Path_Param ("orderId", Order_Id); Client.Call (Swagger.Clients.DELETE, URI); end Delete_Order; -- Returns pet inventories by status -- Returns a map of status codes to quantities procedure Get_Inventory (Client : in out Client_Type; Result : out Swagger.Nullable_Integer_Map) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/store/inventory"); Client.Call (Swagger.Clients.GET, URI, Reply); Swagger.Streams.Deserialize (Reply, "", Result); end Get_Inventory; -- Find purchase order by ID -- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions procedure Get_Order_By_Id (Client : in out Client_Type; Order_Id : in Swagger.Long; Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/store/order/{orderId}"); URI.Set_Path_Param ("orderId", Swagger.To_String (Order_Id)); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_Order_By_Id; -- Place an order for a pet procedure Place_Order (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.Order_Type; Result : out Samples.Petstore.Models.Order_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/store/order"); Client.Call (Swagger.Clients.POST, URI, Req, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Place_Order; -- Create user -- This can only be done by the logged in user. procedure Create_User (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/user"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_User; -- Creates list of users with given input array procedure Create_Users_With_Array_Input (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/user/createWithArray"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_Users_With_Array_Input; -- Creates list of users with given input array procedure Create_Users_With_List_Input (Client : in out Client_Type; P_Body : in Samples.Petstore.Models.User_Type_Vectors.Vector) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/user/createWithList"); Client.Call (Swagger.Clients.POST, URI, Req); end Create_Users_With_List_Input; -- Delete user -- This can only be done by the logged in user. procedure Delete_User (Client : in out Client_Type; Username : in Swagger.UString) is URI : Swagger.Clients.URI_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.DELETE, URI); end Delete_User; -- Get user by user name procedure Get_User_By_Name (Client : in out Client_Type; Username : in Swagger.UString; Result : out Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.GET, URI, Reply); Samples.Petstore.Models.Deserialize (Reply, "", Result); end Get_User_By_Name; -- Logs user into the system procedure Login_User (Client : in out Client_Type; Username : in Swagger.UString; Password : in Swagger.UString; Result : out Swagger.UString) is URI : Swagger.Clients.URI_Type; Reply : Swagger.Value_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Add_Param ("username", Username); URI.Add_Param ("password", Password); URI.Set_Path ("/user/login"); Client.Call (Swagger.Clients.GET, URI, Reply); Swagger.Streams.Deserialize (Reply, "", Result); end Login_User; -- Logs out current logged in user session procedure Logout_User (Client : in out Client_Type) is URI : Swagger.Clients.URI_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); URI.Set_Path ("/user/logout"); Client.Call (Swagger.Clients.GET, URI); end Logout_User; -- Updated user -- This can only be done by the logged in user. procedure Update_User (Client : in out Client_Type; Username : in Swagger.UString; P_Body : in Samples.Petstore.Models.User_Type) is URI : Swagger.Clients.URI_Type; Req : Swagger.Clients.Request_Type; begin Client.Set_Accept ((Swagger.Clients.APPLICATION_XML, Swagger.Clients.APPLICATION_JSON)); Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON)); Samples.Petstore.Models.Serialize (Req.Stream, "", P_Body); URI.Set_Path ("/user/{username}"); URI.Set_Path_Param ("username", Username); Client.Call (Swagger.Clients.PUT, URI, Req); end Update_User; end Samples.Petstore.Clients;
stcarrez/dynamo
Ada
15,252
ads
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . S I N P U T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1995-2008, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ -- This package adds to the GNAT Sinput package some utility routines -- used for obtaining and/or analyzing the pieces of the compilation -- unit's source code from the source buffer. -- -- Note, that up to the version 3.09, the Tree_Read procedure in the GNAT -- Sinput package contains a bug - it does not reset to the initial values -- the global variables used to implement caching for searching for -- a source file index. The ASIS implementation includes the corrected -- version of Sinput package -- -- The routines defined in this package are intended to be used in the -- implementation of the Asis.Text package and for implementing queries -- from other ASIS packages having String or Asis_String as the returned -- (sub)type. -- -- All the routines defined in this package rely on the fact that all -- the source buffers being accessed correspond to the compilable units, -- so they do not care about error finding and recovery. with Asis.Text; use Asis.Text; with Types; use Types; package A4G.A_Sinput is function A_Get_Column_Number (P : Source_Ptr) return Source_Ptr; -- This function differs from the Sinput.Get_Column_Number function in two -- aspects. First, it does not make any transformations of Tab characters -- into equivalent sequences of blanks to represent the standard 1,9,17.. -- spacing pattern, it returns the column number of the specified -- Source_Ptr value as the "distance" from the beginning of the -- corresponding line in the source text. Second, this function considers a -- content of the source buffer as a possible encoding of wide character -- string and counts the column number in wide characters that make up -- the source code. function Wide_String_Image (Node : Node_Id) return Wide_String; -- for Node of N_String_Literal, N_Defining_Operator_Symbol or -- N_Operator_Symbol kind returns the string image of the corresponding -- represented string literal, including string quoters, as it is -- required by the ASIS queries Value_Image, Name_Image and -- Defining_Name_Image. It is an error to call this function for -- a node of some other node kind. This function transformes the internal -- representation of the argument construct taking into account the -- encoding method. function Operator_Image (Node : Node_Id) return String; -- this function returns the string imege of an operator_symbol -- from infix calls to operator functions. It works on nodes of -- N_Identifier and N_Op_Xxx kind. The result includes string quotes -- as for the prefix call to operator function. function Get_Character (P : Source_Ptr) return Character; -- Returns the character pointed by P. -- This function is not "tree-swapping-safe" -- FROM S_B_Serv and from Subservises function Get_Wide_Word (P_Start : Source_Ptr; P_End : Source_Ptr) return Wide_String; -- Returns a part of the source text corresponding to the part of ints -- internal representation bounded by P_Start .. P_End. Takes into account -- the encoding of wide characters and makes the corresponding conversions. -- This function does not check, that P_Start and P_End both point into the -- same source. -- This function is not "tree-swapping-safe" function Source_Locations_To_Span (Span_Beg : Source_Ptr; Span_End : Source_Ptr) return Span; -- Transforms the pair of locations in the source buffer into an -- ASIS Span. Note, that ASIS Span counts the source positions in wide -- characters, whereas Span_Beg and Span_End are pointers to the internal -- string (but not wide string!) representation of the source text! -- This function is not "tree-swapping-safe" function Get_Location (E : Asis.Element) return Source_Ptr; -- Returns the value of the Sloc field of the (original) node -- on which E is based -- This function is "tree-swapping-safe" -- FROM Subservises function Number_Of_Lines (E : Asis.Element) return Integer; -- Returns the number of the last line in the source file accessable -- through this Element, taking into account Source_Reference pragma if -- it presents in the source file. -- -- This function is "tree-swapping-safe" -- FROM Subservises function Identifier_Image (Ident : Node_Id) return String; -- For a node, which is of N_Identifier or N_Defining_Identifier kind, -- this function returns the string image of the corresponding -- (defining) identifier -- Note, that this function does not take into account the possible -- encoding of upper half wide characters. The results of this function are -- used in internal Compilation Unit table only, so this function does not -- make any problem for proper encoding processing in Asis.Text. But anyway -- this should be revised to completely conform to the source -- representation required by the Ada standard. function Exp_Name_Image (Name : Node_Id) return String; -- For a node, which is of N_Defining_Program_Unit_Name, -- N_Defining_Identifier, N_Expanded_Name or N_Identifier kind, -- this function returns the string image of the corresponding name function Comment_Beginning (Line_Image : Text_Buffer) return Source_Ptr; -- Returns position of the first _comment_ hyphen in the argument string. -- If there is no comment, then returns No_Location. -- The string has to correspond to a legal Ada program fragment, -- otherwise a constraint error may be raised. -- -- Note, that this function can be used for detecting the comment beginning -- in the line buffer of the Standard String type, because the index range -- of Text_Buffer (and the range of Source_Ptr) includes the low bound of -- Positive. ------------------------------------------------------------------------ -- Staring from this point, some mess exists, which originates from -- -- collecting all the text processing/source buffer-processing -- -- routines from Subservices and S_B_Serv -- ------------------------------------------------------------------------ function Next_Identifier (P : Source_Ptr) return Source_Ptr; -- Returns the location of the first charaster of the identifier which -- should follow the position indicated by P. Initially this -- function was intended to find the beginning of the pragma identifier, -- so two requirements should be met for its correct use: P points to -- some separator (as defined by RM 95 2.2 (3-6), and the next lexem -- should be either comment or identifier. -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function Get_String_End (P : Source_Ptr) return Source_Ptr; -- Supposing that P points to the leading quotation of the string -- literal, this function defines the location of the quotation -- ending the string constant. -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function Get_Num_Literal_End (P : Source_Ptr) return Source_Ptr; -- Supposing that P points to the first character of a numeric -- literal, this function defines the location of the last character -- of the literal. -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function Search_Rightmost_Symbol (P : Source_Ptr; Char : Character := ';') return Source_Ptr; -- The function returns the location of the rightmost symbol equial -- to Char for the position indicated by P (including P itself). -- Comments are skipped during the search -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function Rightmost_Non_Blank (P : Source_Ptr) return Source_Ptr; -- returns the first non-blank symbol (excluding format effectors) -- following P (if P itself is a non-blank symbol, P is returned). -- Comments are skipped type In_Word_Condition is access function (P : Source_Ptr) return Boolean; -- I wish I had time to get rid of this awkward approach based on -- In_Word_Condition! :(( function Get_Word_End (P : Source_Ptr; In_Word : In_Word_Condition) return Source_Ptr; -- The function returns the location of the firs/last character of the -- lexical element which contains character pointed by P. It is supposed -- that P does not point inside comment, separator or delimiter (RM95 2.2) -- -- The first version of these function (with the second parameters of -- In_Word_Char_Condition type is used when it is enough to test only one -- character to get the answer. But if it is necessary to examine some -- characters before/after the given character, the second form should be -- used with the corresponding test function. -- -- The initial idea is to use these functions to get the start/end of -- identifiers, numeric literals and string literals. -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function In_Identifier (P : Source_Ptr) return Boolean; -- Returns true if P points somewhere inside an identifier, and False -- otherwise -- This function is not "tree-swapping-safe" -- FROM S_B_Serv function Search_Prev_Word (S : Source_Ptr) return Source_Ptr; -- Returns the location of the previous word end. -- The comments are skipped. -- This function is not "tree-swapping-safe" -- FROM Subservises function Search_Beginning_Of_Word (S : Source_Ptr) return Source_Ptr; -- Returns the location of the beginning of the word to which S points. -- This function is not "tree-swapping-safe" -- FROM Subservises function Search_Prev_Word_Start (S : Source_Ptr) return Source_Ptr; -- Equivalent to Search_Beginning_Of_Word (Search_Prev_Word (S)) function Search_End_Of_Word (S : Source_Ptr) return Source_Ptr; -- Returns the location of the end of the word to which S points. -- This function is not "tree-swapping-safe" -- FROM Subservises -- It's crazy to have it along with Get_Word_End!!! function Search_Next_Word (S : Source_Ptr) return Source_Ptr; -- Returns the location of the next word beginning. The comments -- are skipped. -- This function is not "tree-swapping-safe" -- FROM Subservises function Search_Left_Parenthesis (S : Source_Ptr) return Source_Ptr; -- Returns the location of the first inclusion of left parenthesis before -- the location in source file to which S points. -- This function is not "tree-swapping-safe" -- FROM Subservises function Is_EOL_Char (Ch : Character) return Boolean; -- Checks if Ch is a character defining an end of line. According to RM05 -- 2.2(2/2), "a sequence of one or more format_effectors other than the -- character whose code position is 16#09# (CHARACTER TABULATION) signifies -- at least one end of line." function Get_Wide_Ch (S : Source_Ptr) return Wide_Character; -- Provided that S points to the first character of the internal -- representation of some character from the original source, returns -- this riginal source character, taking into account the encoding method function Is_Start_Of_Wide_Char_For_ASIS (S : Source_Buffer_Ptr; P : Source_Ptr; C : Source_Ptr := No_Location) return Boolean; -- Determines if S (P) is the start of a wide character sequence. This -- function differs from Widechar in two aspects: first, it assumes that -- the bracket encoding can not be used in a comment text, and if set, the -- actual for C should point to the beginning of the comment that in the -- source buffer, and second, in any non-comment text it assumes that a -- bracket encoding is always set ON (see the description of -gnatW option -- in GNAT UGN). procedure Skip_Wide_For_ASIS (S : Source_Buffer_Ptr; P : in out Source_Ptr); -- Similar to Widechar.Skip_Wide, but always skips bracked encoding -- sequense. Before calling this function, the caller should check thar -- Is_Start_Of_Wide_Char_For_ASIS (S, P) is True end A4G.A_Sinput;
sungyeon/drake
Ada
46,417
adb
-- reference: -- http://www.unicode.org/reports/tr15/ with Ada.Characters.Conversions; with Ada.Strings.Canonical_Composites; with Ada.UCD; package body Ada.Strings.Normalization is use type UCD.UCS_4; function Standard_Equal (Left, Right : Wide_Wide_String) return Boolean; function Standard_Equal (Left, Right : Wide_Wide_String) return Boolean is begin return Left = Right; end Standard_Equal; function Standard_Less (Left, Right : Wide_Wide_String) return Boolean; function Standard_Less (Left, Right : Wide_Wide_String) return Boolean is begin return Left < Right; end Standard_Less; -- NFD procedure D_Buff ( Item : in out Wide_Wide_String; Last : in out Natural; Decomposed : out Boolean); procedure D_Buff ( Item : in out Wide_Wide_String; Last : in out Natural; Decomposed : out Boolean) is begin Decomposed := False; for I in reverse Item'First .. Last loop declare D : constant Natural := Canonical_Composites.D_Find (Item (I)); To : Canonical_Composites.Decomposed_Wide_Wide_String; To_Length : Natural; begin if D > 0 then To := Canonical_Composites.D_Map (D).To; To_Length := Canonical_Composites.Decomposed_Length (To); elsif Wide_Wide_Character'Pos (Item (I)) in UCD.Hangul.SBase .. UCD.Hangul.SBase + UCD.Hangul.SCount - 1 then -- S to LV[T] declare SIndex : constant UCD.UCS_4 := Wide_Wide_Character'Pos (Item (I)) - UCD.Hangul.SBase; L : constant UCD.UCS_4 := UCD.Hangul.LBase + SIndex / UCD.Hangul.NCount; V : constant UCD.UCS_4 := UCD.Hangul.VBase + SIndex rem UCD.Hangul.NCount / UCD.Hangul.TCount; T : constant UCD.UCS_4 := UCD.Hangul.TBase + SIndex rem UCD.Hangul.TCount; begin To (1) := Wide_Wide_Character'Val (L); To (2) := Wide_Wide_Character'Val (V); To_Length := 2; if T /= UCD.Hangul.TBase then To (3) := Wide_Wide_Character'Val (T); To_Length := 3; end if; end; else goto Continue; end if; -- replacing Decomposed := True; Item (I + To_Length .. Last + To_Length - 1) := Item (I + 1 .. Last); Item (I .. I + To_Length - 1) := To (1 .. To_Length); Last := Last + To_Length - 1; end; <<Continue>> null; end loop; end D_Buff; -- NFC procedure C_Buff ( Item : in out Wide_Wide_String; Last : in out Natural; Composed : out Boolean); procedure C_Buff ( Item : in out Wide_Wide_String; Last : in out Natural; Composed : out Boolean) is begin Composed := False; for I in reverse Item'First .. Last - 1 loop Process_After_Index : loop declare From : constant Canonical_Composites.Composing_Wide_Wide_String := (Item (I), Item (I + 1)); C : constant Natural := Canonical_Composites.C_Find (From); To : Wide_Wide_Character; begin if C > 0 then To := Canonical_Composites.C_Map (C).To; elsif Wide_Wide_Character'Pos (From (1)) in UCD.Hangul.LBase .. UCD.Hangul.LBase + UCD.Hangul.LCount - 1 and then Wide_Wide_Character'Pos (From (2)) in UCD.Hangul.VBase .. UCD.Hangul.VBase + UCD.Hangul.VCount - 1 then -- LV to S declare LIndex : constant UCD.UCS_4 := Wide_Wide_Character'Pos (From (1)) - UCD.Hangul.LBase; VIndex : constant UCD.UCS_4 := Wide_Wide_Character'Pos (From (2)) - UCD.Hangul.VBase; begin To := Wide_Wide_Character'Val ( UCD.Hangul.SBase + (LIndex * UCD.Hangul.VCount + VIndex) * UCD.Hangul.TCount); end; elsif Wide_Wide_Character'Pos (From (1)) in UCD.Hangul.SBase .. UCD.Hangul.SBase + UCD.Hangul.SCount - 1 and then Wide_Wide_Character'Pos (From (2)) in UCD.Hangul.TBase .. UCD.Hangul.TBase + UCD.Hangul.TCount - 1 then -- ST to T declare ch : constant UCD.UCS_4 := Wide_Wide_Character'Pos (From (1)); TIndex : constant UCD.UCS_4 := Wide_Wide_Character'Pos (From (2)) - UCD.Hangul.TBase; begin To := Wide_Wide_Character'Val (ch + TIndex); end; else exit Process_After_Index; end if; -- replacing Composed := True; Item (I) := To; Last := Last - 1; exit Process_After_Index when Last <= I; Item (I + 1 .. Last) := Item (I + 2 .. Last + 1); end; end loop Process_After_Index; end loop; end C_Buff; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; Max_Length : Positive; with procedure Get ( Data : String_Type; Last : out Natural; Result : out Wide_Wide_Character; Is_Illegal_Sequence : out Boolean); with procedure Put ( Code : Wide_Wide_Character; Result : out String_Type; Last : out Natural); with procedure Get_Combined ( State : in out Composites.State; Item : String_Type; Last : out Natural; Is_Illegal_Sequence : out Boolean); package Generic_Normalization is procedure Decode ( Item : String_Type; Buffer : out Wide_Wide_String; Buffer_Last : out Natural); procedure Encode ( Item : Wide_Wide_String; Buffer : out String_Type; Buffer_Last : out Natural); procedure Decompose_No_Length_Check ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); procedure Compose_No_Length_Check ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); end Generic_Normalization; package body Generic_Normalization is procedure Decode ( Item : String_Type; Buffer : out Wide_Wide_String; Buffer_Last : out Natural) is Last : Natural := Item'First - 1; Code : Wide_Wide_Character; Is_Illegal_Sequence : Boolean; -- ignore begin Buffer_Last := Buffer'First - 1; while Last < Item'Last loop Get ( Item (Last + 1 .. Item'Last), Last, Code, Is_Illegal_Sequence); Buffer_Last := Buffer_Last + 1; Buffer (Buffer_Last) := Code; end loop; end Decode; procedure Encode ( Item : Wide_Wide_String; Buffer : out String_Type; Buffer_Last : out Natural) is begin Buffer_Last := Buffer'First - 1; for I in Item'Range loop Put ( Item (I), Buffer (Buffer_Last + 1 .. Buffer'Last), Buffer_Last); end loop; end Encode; procedure Decompose_No_Length_Check ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is Is_Illegal_Sequence : Boolean; begin -- get one combining character sequence Get_Combined (State, Item, Last, Is_Illegal_Sequence); if not Is_Illegal_Sequence then -- normalization declare Decomposed : Boolean; Buffer : Wide_Wide_String ( 1 .. Expanding * Max_Length * (Last - Item'First + 1)); Buffer_Last : Natural; begin -- decoding Decode ( Item (Item'First .. Last), Buffer, Buffer_Last); -- decomposing D_Buff (Buffer, Buffer_Last, Decomposed); -- encoding if Decomposed then Encode (Buffer (1 .. Buffer_Last), Out_Item, Out_Last); return; end if; end; end if; Out_Last := Out_Item'First + (Last - Item'First); Out_Item (Out_Item'First .. Out_Last) := Item (Item'First .. Last); end Decompose_No_Length_Check; procedure Compose_No_Length_Check ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is Is_Illegal_Sequence : Boolean; begin -- get one combining character sequence Get_Combined (State, Item, Last, Is_Illegal_Sequence); if not Is_Illegal_Sequence then -- normalization declare Decomposed : Boolean; Composed : Boolean; Buffer : Wide_Wide_String ( 1 .. Expanding * Max_Length * (Last - Item'First + 1)); Buffer_Last : Natural; begin -- decoding Decode ( Item (Item'First .. Last), Buffer, Buffer_Last); -- first, decomposing D_Buff (Buffer, Buffer_Last, Decomposed); -- next, composing C_Buff (Buffer, Buffer_Last, Composed); -- encoding if Decomposed or else Composed then Encode (Buffer (1 .. Buffer_Last), Out_Item, Out_Last); return; end if; end; end if; Out_Last := Out_Item'First + (Last - Item'First); Out_Item (Out_Item'First .. Out_Last) := Item (Item'First .. Last); end Compose_No_Length_Check; end Generic_Normalization; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); procedure Generic_Decompose ( Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Decompose ( Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is begin if Item'Length = 0 then Last := Item'First - 1; Out_Last := Out_Item'First - 1; else Canonical_Composites.Initialize_D; declare St : Composites.State; begin Start (Item, St); N.Decompose_No_Length_Check (St, Item, Last, Out_Item, Out_Last); end; end if; end Generic_Decompose; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); procedure Generic_Decompose_With_State ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Decompose_With_State ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is begin if Item'Length = 0 then -- finished Last := Item'Last; State.Next_Character := Wide_Wide_Character'Val (0); State.Next_Combining_Class := 0; State.Next_Is_Illegal_Sequence := False; State.Next_Last := Last; Out_Last := Out_Item'First - 1; else Canonical_Composites.Initialize_D; N.Decompose_No_Length_Check (State, Item, Last, Out_Item, Out_Last); end if; end Generic_Decompose_With_State; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); procedure Generic_Decompose_All ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Decompose_All ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural) is begin Out_Last := Out_Item'First - 1; if Item'Length > 0 then Canonical_Composites.Initialize_D; declare St : Composites.State; Last : Natural := Item'First - 1; begin Start (Item, St); while Last < Item'Last loop N.Decompose_No_Length_Check ( St, Item (Last + 1 .. Item'Last), Last, Out_Item (Out_Last + 1 .. Out_Item'Last), Out_Last); end loop; end; end if; end Generic_Decompose_All; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Decompose ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural); function Generic_Decompose_All_Func (Item : String_Type) return String_Type; function Generic_Decompose_All_Func (Item : String_Type) return String_Type is Result : String_Type (1 .. Expanding * N.Max_Length * Item'Length); Result_Last : Natural := Result'First - 1; begin Decompose (Item, Result, Result_Last); return Result (Result'First .. Result_Last); end Generic_Decompose_All_Func; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); procedure Generic_Compose ( Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Compose ( Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is begin if Item'Length = 0 then Last := Item'First - 1; Out_Last := Out_Item'First - 1; else Canonical_Composites.Initialize_C; declare St : Composites.State; begin Start (Item, St); N.Compose_No_Length_Check (St, Item, Last, Out_Item, Out_Last); end; end if; end Generic_Compose; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); procedure Generic_Compose_With_State ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Compose_With_State ( State : in out Composites.State; Item : String_Type; Last : out Natural; Out_Item : out String_Type; Out_Last : out Natural) is begin if Item'Length = 0 then -- finished Last := Item'Last; State.Next_Character := Wide_Wide_Character'Val (0); State.Next_Combining_Class := 0; State.Next_Is_Illegal_Sequence := False; State.Next_Last := Last; Out_Last := Out_Item'First - 1; else Canonical_Composites.Initialize_C; N.Compose_No_Length_Check (State, Item, Last, Out_Item, Out_Last); end if; end Generic_Compose_With_State; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); procedure Generic_Compose_All ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural); procedure Generic_Compose_All ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural) is begin Out_Last := Out_Item'First - 1; if Item'Length > 0 then Canonical_Composites.Initialize_C; declare St : Composites.State; Last : Natural := Item'First - 1; begin Start (Item, St); while Last < Item'Last loop N.Compose_No_Length_Check ( St, Item (Last + 1 .. Item'Last), Last, Out_Item (Out_Last + 1 .. Out_Item'Last), Out_Last); end loop; end; end if; end Generic_Compose_All; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Compose ( Item : String_Type; Out_Item : out String_Type; Out_Last : out Natural); function Generic_Compose_All_Func (Item : String_Type) return String_Type; function Generic_Compose_All_Func (Item : String_Type) return String_Type is Result : String_Type (1 .. Expanding * N.Max_Length * Item'Length); Result_Last : Natural := Result'First - 1; begin Compose (Item, Result, Result_Last); return Result (Result'First .. Result_Last); end Generic_Compose_All_Func; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with function Equal ( Left, Right : String_Type; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean; function Generic_Equal (Left, Right : String_Type) return Boolean; function Generic_Equal (Left, Right : String_Type) return Boolean is begin return Equal (Left, Right, Standard_Equal'Access); end Generic_Equal; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); function Generic_Equal_With_Comparator ( Left, Right : String_Type; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean; function Generic_Equal_With_Comparator ( Left, Right : String_Type; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is begin if Left'Length = 0 then return Right'Length = 0; elsif Right'Length = 0 then return False; end if; Canonical_Composites.Initialize_D; declare Left_State : Composites.State; Left_Last : Natural := Left'First - 1; Right_State : Composites.State; Right_Last : Natural := Right'First - 1; begin Start (Left, Left_State); Start (Right, Right_State); loop -- get one combining character sequence declare Left_First : constant Positive := Left_Last + 1; Right_First : constant Positive := Right_Last + 1; Left_Is_Illegal_Sequence : Boolean; Right_Is_Illegal_Sequence : Boolean; begin N.Get_Combined ( Left_State, Left (Left_First .. Left'Last), Left_Last, Left_Is_Illegal_Sequence); N.Get_Combined ( Right_State, Right (Right_First .. Right'Last), Right_Last, Right_Is_Illegal_Sequence); if not Left_Is_Illegal_Sequence then if not Right_Is_Illegal_Sequence then -- left and right are legal declare Left_Buffer : Wide_Wide_String ( 1 .. Expanding * N.Max_Length * (Left_Last - Left_First + 1)); Left_Buffer_Last : Natural; Left_Decomposed : Boolean; -- ignore Right_Buffer : Wide_Wide_String ( 1 .. Expanding * N.Max_Length * (Right_Last - Right_First + 1)); Right_Buffer_Last : Natural; Right_Decomposed : Boolean; -- ignore begin N.Decode ( Left (Left_First .. Left_Last), Left_Buffer, Left_Buffer_Last); D_Buff ( Left_Buffer, Left_Buffer_Last, Left_Decomposed); N.Decode ( Right (Right_First .. Right_Last), Right_Buffer, Right_Buffer_Last); D_Buff ( Right_Buffer, Right_Buffer_Last, Right_Decomposed); if not Equal_Combined ( Left_Buffer (1 .. Left_Buffer_Last), Right_Buffer (1 .. Right_Buffer_Last)) then return False; end if; end; else -- left is legal, right is illegal return False; end if; else if not Right_Is_Illegal_Sequence then -- left is illegal, right is legal return False; else -- left and right are illegal if Left (Left_First .. Left_Last) /= Right (Right_First .. Right_Last) then return False; end if; end if; end if; end; -- detect ends if Left_Last >= Left'Last then return Right_Last >= Right'Last; elsif Right_Last >= Right'Last then return False; end if; end loop; end; end Generic_Equal_With_Comparator; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with function Less ( Left, Right : String_Type; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean; function Generic_Less (Left, Right : String_Type) return Boolean; function Generic_Less (Left, Right : String_Type) return Boolean is begin return Less (Left, Right, Standard_Less'Access); end Generic_Less; generic type Character_Type is (<>); type String_Type is array (Positive range <>) of Character_Type; with package N is new Generic_Normalization (Character_Type, String_Type, others => <>); with procedure Start (Item : String_Type; State : out Composites.State); function Generic_Less_With_Comparator ( Left, Right : String_Type; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean; function Generic_Less_With_Comparator ( Left, Right : String_Type; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is begin if Left'Length = 0 then return Right'Length > 0; elsif Right'Length = 0 then return False; end if; Canonical_Composites.Initialize_D; declare Left_State : Composites.State; Left_Last : Natural := Left'First - 1; Right_State : Composites.State; Right_Last : Natural := Right'First - 1; begin Start (Left, Left_State); Start (Right, Right_State); loop -- get one combining character sequence declare Left_First : constant Positive := Left_Last + 1; Right_First : constant Positive := Right_Last + 1; Left_Is_Illegal_Sequence : Boolean; Right_Is_Illegal_Sequence : Boolean; begin N.Get_Combined ( Left_State, Left (Left_First .. Left'Last), Left_Last, Left_Is_Illegal_Sequence); N.Get_Combined ( Right_State, Right (Right_First .. Right'Last), Right_Last, Right_Is_Illegal_Sequence); if not Left_Is_Illegal_Sequence then if not Right_Is_Illegal_Sequence then -- left and right are legal declare Left_Buffer : Wide_Wide_String ( 1 .. Expanding * N.Max_Length * (Left_Last - Left_First + 1)); Left_Buffer_Last : Natural; Left_Decomposed : Boolean; -- ignore Right_Buffer : Wide_Wide_String ( 1 .. Expanding * N.Max_Length * (Right_Last - Right_First + 1)); Right_Buffer_Last : Natural; Right_Decomposed : Boolean; -- ignore begin N.Decode ( Left (Left_First .. Left_Last), Left_Buffer, Left_Buffer_Last); D_Buff ( Left_Buffer, Left_Buffer_Last, Left_Decomposed); N.Decode ( Right (Right_First .. Right_Last), Right_Buffer, Right_Buffer_Last); D_Buff ( Right_Buffer, Right_Buffer_Last, Right_Decomposed); if Less_Combined ( Left_Buffer (1 .. Left_Buffer_Last), Right_Buffer (1 .. Right_Buffer_Last)) then return True; elsif Less_Combined ( Right_Buffer (1 .. Right_Buffer_Last), Left_Buffer (1 .. Left_Buffer_Last)) then return False; end if; end; else -- left is legal, right is illegal return True; end if; else if not Right_Is_Illegal_Sequence then -- left is illegal, right is legal return False; else -- left and right are illegal if Left (Left_First .. Left_Last) < Right (Right_First .. Right_Last) then return True; elsif Left (Left_First .. Left_Last) < Right (Right_First .. Right_Last) then return False; end if; end if; end if; end; -- detect ends if Left_Last >= Left'Last then return Right_Last < Right'Last; elsif Right_Last >= Right'Last then return False; end if; end loop; end; end Generic_Less_With_Comparator; package Strings is new Generic_Normalization ( Character, String, Characters.Conversions.Max_Length_In_String, Characters.Conversions.Get, Characters.Conversions.Put, Composites.Get_Combined); package Wide_Strings is new Generic_Normalization ( Wide_Character, Wide_String, Characters.Conversions.Max_Length_In_Wide_String, Characters.Conversions.Get, Characters.Conversions.Put, Composites.Get_Combined); package Wide_Wide_Strings is new Generic_Normalization ( Wide_Wide_Character, Wide_Wide_String, Characters.Conversions.Max_Length_In_Wide_Wide_String, -- 1 Characters.Conversions.Get, Characters.Conversions.Put, Composites.Get_Combined); -- implementation procedure Iterate ( Expanded : Boolean; Process : not null access procedure ( Precomposed : Wide_Wide_Character; Decomposed : Wide_Wide_String)) is procedure Do_Iterate ( Map : Canonical_Composites.D_Map_Array; Process : not null access procedure ( Precomposed : Wide_Wide_Character; Decomposed : Wide_Wide_String)); procedure Do_Iterate ( Map : Canonical_Composites.D_Map_Array; Process : not null access procedure ( Precomposed : Wide_Wide_Character; Decomposed : Wide_Wide_String)) is begin for I in Map'Range loop declare E : Canonical_Composites.D_Map_Element renames Map (I); Decomposed_Length : constant Natural := Canonical_Composites.Decomposed_Length (E.To); begin Process (E.From, E.To (1 .. Decomposed_Length)); end; end loop; end Do_Iterate; begin if Expanded then Canonical_Composites.Initialize_D; Do_Iterate (Canonical_Composites.D_Map.all, Process); else Canonical_Composites.Initialize_Unexpanded_D; Do_Iterate (Canonical_Composites.Unexpanded_D_Map.all, Process); end if; end Iterate; procedure Decompose ( Item : String; Last : out Natural; Out_Item : out String; Out_Last : out Natural) is procedure Decompose_String is new Generic_Decompose (Character, String, Strings, Composites.Start); begin Decompose_String (Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( State : in out Composites.State; Item : String; Last : out Natural; Out_Item : out String; Out_Last : out Natural) is procedure Decompose_String is new Generic_Decompose_With_State (Character, String, Strings); begin Decompose_String (State, Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( Item : Wide_String; Last : out Natural; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_String is new Generic_Decompose ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); begin Decompose_Wide_String (Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( State : in out Composites.State; Item : Wide_String; Last : out Natural; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_String is new Generic_Decompose_With_State ( Wide_Character, Wide_String, Wide_Strings); begin Decompose_Wide_String (State, Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( Item : Wide_Wide_String; Last : out Natural; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_Wide_String is new Generic_Decompose ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); begin Decompose_Wide_Wide_String (Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( State : in out Composites.State; Item : Wide_Wide_String; Last : out Natural; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_Wide_String is new Generic_Decompose_With_State ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings); begin Decompose_Wide_Wide_String (State, Item, Last, Out_Item, Out_Last); end Decompose; procedure Decompose ( Item : String; Out_Item : out String; Out_Last : out Natural) is procedure Decompose_String is new Generic_Decompose_All ( Character, String, Strings, Composites.Start); pragma Inline_Always (Decompose_String); begin Decompose_String (Item, Out_Item, Out_Last); end Decompose; function Decompose (Item : String) return String is function Decompose_String is new Generic_Decompose_All_Func ( Character, String, Strings, Decompose); begin return Decompose_String (Item); end Decompose; procedure Decompose ( Item : Wide_String; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_String is new Generic_Decompose_All ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); pragma Inline_Always (Decompose_Wide_String); begin Decompose_Wide_String (Item, Out_Item, Out_Last); end Decompose; function Decompose (Item : Wide_String) return Wide_String is function Decompose_Wide_String is new Generic_Decompose_All_Func ( Wide_Character, Wide_String, Wide_Strings, Decompose); begin return Decompose_Wide_String (Item); end Decompose; procedure Decompose ( Item : Wide_Wide_String; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Decompose_Wide_Wide_String is new Generic_Decompose_All ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); pragma Inline_Always (Decompose_Wide_Wide_String); begin Decompose_Wide_Wide_String (Item, Out_Item, Out_Last); end Decompose; function Decompose (Item : Wide_Wide_String) return Wide_Wide_String is function Decompose_Wide_Wide_String is new Generic_Decompose_All_Func ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Decompose); begin return Decompose_Wide_Wide_String (Item); end Decompose; procedure Compose ( Item : String; Last : out Natural; Out_Item : out String; Out_Last : out Natural) is procedure Compose_String is new Generic_Compose (Character, String, Strings, Composites.Start); begin Compose_String (Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( State : in out Composites.State; Item : String; Last : out Natural; Out_Item : out String; Out_Last : out Natural) is procedure Compose_String is new Generic_Compose_With_State (Character, String, Strings); begin Compose_String (State, Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( Item : Wide_String; Last : out Natural; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Compose_Wide_String is new Generic_Compose ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); begin Compose_Wide_String (Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( State : in out Composites.State; Item : Wide_String; Last : out Natural; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Compose_Wide_String is new Generic_Compose_With_State ( Wide_Character, Wide_String, Wide_Strings); begin Compose_Wide_String (State, Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( Item : Wide_Wide_String; Last : out Natural; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Compose_Wide_Wide_String is new Generic_Compose ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); begin Compose_Wide_Wide_String (Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( State : in out Composites.State; Item : Wide_Wide_String; Last : out Natural; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Compose_Wide_Wide_String is new Generic_Compose_With_State ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings); begin Compose_Wide_Wide_String (State, Item, Last, Out_Item, Out_Last); end Compose; procedure Compose ( Item : String; Out_Item : out String; Out_Last : out Natural) is procedure Compose_String is new Generic_Compose_All ( Character, String, Strings, Composites.Start); pragma Inline_Always (Compose_String); begin Compose_String (Item, Out_Item, Out_Last); end Compose; function Compose (Item : String) return String is function Compose_String is new Generic_Compose_All_Func (Character, String, Strings, Compose); begin return Compose_String (Item); end Compose; procedure Compose ( Item : Wide_String; Out_Item : out Wide_String; Out_Last : out Natural) is procedure Compose_Wide_String is new Generic_Compose_All ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); pragma Inline_Always (Compose_Wide_String); begin Compose_Wide_String (Item, Out_Item, Out_Last); end Compose; function Compose (Item : Wide_String) return Wide_String is function Compose_Wide_String is new Generic_Compose_All_Func ( Wide_Character, Wide_String, Wide_Strings, Compose); begin return Compose_Wide_String (Item); end Compose; procedure Compose ( Item : Wide_Wide_String; Out_Item : out Wide_Wide_String; Out_Last : out Natural) is procedure Compose_Wide_Wide_String is new Generic_Compose_All ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); pragma Inline_Always (Compose_Wide_Wide_String); begin Compose_Wide_Wide_String (Item, Out_Item, Out_Last); end Compose; function Compose (Item : Wide_Wide_String) return Wide_Wide_String is function Compose_Wide_Wide_String is new Generic_Compose_All_Func ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Compose); begin return Compose_Wide_Wide_String (Item); end Compose; function Equal (Left, Right : String) return Boolean is function Equal_String is new Generic_Equal (Character, String, Equal); begin return Equal_String (Left, Right); end Equal; function Equal ( Left, Right : String; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Equal_String is new Generic_Equal_With_Comparator ( Character, String, Strings, Composites.Start); pragma Inline_Always (Equal_String); begin return Equal_String (Left, Right, Equal_Combined); end Equal; function Equal (Left, Right : Wide_String) return Boolean is function Equal_Wide_String is new Generic_Equal (Wide_Character, Wide_String, Equal); begin return Equal_Wide_String (Left, Right); end Equal; function Equal ( Left, Right : Wide_String; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Equal_Wide_String is new Generic_Equal_With_Comparator ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); pragma Inline_Always (Equal_Wide_String); begin return Equal_Wide_String (Left, Right, Equal_Combined); end Equal; function Equal (Left, Right : Wide_Wide_String) return Boolean is function Equal_Wide_Wide_String is new Generic_Equal (Wide_Wide_Character, Wide_Wide_String, Equal); begin return Equal_Wide_Wide_String (Left, Right); end Equal; function Equal ( Left, Right : Wide_Wide_String; Equal_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Equal_Wide_Wide_String is new Generic_Equal_With_Comparator ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); pragma Inline_Always (Equal_Wide_Wide_String); begin return Equal_Wide_Wide_String (Left, Right, Equal_Combined); end Equal; function Less (Left, Right : String) return Boolean is function Less_String is new Generic_Less (Character, String, Less); begin return Less_String (Left, Right); end Less; function Less ( Left, Right : String; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Less_String is new Generic_Less_With_Comparator ( Character, String, Strings, Composites.Start); pragma Inline_Always (Less_String); begin return Less_String (Left, Right, Less_Combined); end Less; function Less (Left, Right : Wide_String) return Boolean is function Less_Wide_String is new Generic_Less (Wide_Character, Wide_String, Less); begin return Less_Wide_String (Left, Right); end Less; function Less ( Left, Right : Wide_String; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Less_Wide_String is new Generic_Less_With_Comparator ( Wide_Character, Wide_String, Wide_Strings, Composites.Start); pragma Inline_Always (Less_Wide_String); begin return Less_Wide_String (Left, Right, Less_Combined); end Less; function Less (Left, Right : Wide_Wide_String) return Boolean is function Less_Wide_Wide_String is new Generic_Less (Wide_Wide_Character, Wide_Wide_String, Less); begin return Less_Wide_Wide_String (Left, Right); end Less; function Less ( Left, Right : Wide_Wide_String; Less_Combined : not null access function ( Left, Right : Wide_Wide_String) return Boolean) return Boolean is function Less_Wide_Wide_String is new Generic_Less_With_Comparator ( Wide_Wide_Character, Wide_Wide_String, Wide_Wide_Strings, Composites.Start); pragma Inline_Always (Less_Wide_Wide_String); begin return Less_Wide_Wide_String (Left, Right, Less_Combined); end Less; end Ada.Strings.Normalization;
charlie5/lace
Ada
703
ads
with ada.Numerics.generic_elementary_Functions; generic type Float_type is digits <>; type Matrix_2x2_type is private; with package float_elementary_Functions is new ada.Numerics.generic_elementary_Functions (Float_type); with function to_Matrix_2x2 (m11, m12, m21, m22 : Float_type) return Matrix_2x2_type; slot_Count : Standard.Positive; package cached_Rotation -- -- Caches 2x2 rotation matrices of angles for speed at the cost of precision. -- is pragma Optimize (Time); function to_Rotation (Angle : in Float_type) return access constant Matrix_2x2_type; private pragma Inline_Always (to_Rotation); end cached_Rotation;
reznikmm/matreshka
Ada
6,820
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Checkbox_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Form_Checkbox_Element_Node is begin return Self : Form_Checkbox_Element_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Form_Checkbox_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_Form_Checkbox (ODF.DOM.Form_Checkbox_Elements.ODF_Form_Checkbox_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 Form_Checkbox_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Checkbox_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Form_Checkbox_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_Form_Checkbox (ODF.DOM.Form_Checkbox_Elements.ODF_Form_Checkbox_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 Form_Checkbox_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_Form_Checkbox (Visitor, ODF.DOM.Form_Checkbox_Elements.ODF_Form_Checkbox_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.Form_URI, Matreshka.ODF_String_Constants.Checkbox_Element, Form_Checkbox_Element_Node'Tag); end Matreshka.ODF_Form.Checkbox_Elements;
reznikmm/matreshka
Ada
6,386
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- 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 version is for POSIX operating systems. Note, it depends from GNAT -- runtime also. ------------------------------------------------------------------------------ with Ada.Streams; with Ada.Strings.Fixed; with Interfaces.C.Pointers; with Interfaces.C.Strings; with System.Address_To_Access_Conversions; with League.Text_Codecs; separate (League.Application) procedure Initialize_Arguments_Environment is use type Interfaces.C.size_t; package chars_ptr_Pointers is new Interfaces.C.Pointers (Interfaces.C.size_t, Interfaces.C.Strings.chars_ptr, Interfaces.C.Strings.chars_ptr_array, Interfaces.C.Strings.Null_Ptr); package chars_ptr_Conversions is new System.Address_To_Access_Conversions (Interfaces.C.Strings.chars_ptr); function To_Stream_Element_Array (Item : String) return Ada.Streams.Stream_Element_Array; -- Converts string into Stream_Element_Array. GNAT_Argc : constant Integer; pragma Import (C, GNAT_Argc); GNAT_Argv : constant System.Address; pragma Import (C, GNAT_Argv); GNAT_Envp : constant System.Address; pragma Import (C, GNAT_Envp); ----------------------------- -- To_Stream_Element_Array -- ----------------------------- function To_Stream_Element_Array (Item : String) return Ada.Streams.Stream_Element_Array is use type Ada.Streams.Stream_Element_Offset; Aux : constant Ada.Streams.Stream_Element_Array (0 .. Item'Length - 1); for Aux'Address use Item'Address; pragma Import (Ada, Aux); begin return Aux; end To_Stream_Element_Array; begin -- Convert arguments. declare Argv : constant Interfaces.C.Strings.chars_ptr_array := chars_ptr_Pointers.Value (chars_ptr_Pointers.Pointer (chars_ptr_Conversions.To_Pointer (GNAT_Argv)), Interfaces.C.ptrdiff_t (GNAT_Argc)); begin for J in Argv'First + 1 .. Argv'Last loop Args.Append (League.Text_Codecs.Codec_For_Application_Locale.Decode (To_Stream_Element_Array (Interfaces.C.Strings.Value (Argv (J))))); end loop; end; -- Convert process environment. declare Envp : constant Interfaces.C.Strings.chars_ptr_array := chars_ptr_Pointers.Value (chars_ptr_Pointers.Pointer (chars_ptr_Conversions.To_Pointer (GNAT_Envp))); begin for J in Envp'First .. Envp'Last - 1 loop declare Pair : constant String := Interfaces.C.Strings.Value (Envp (J)); Index : constant Natural := Ada.Strings.Fixed.Index (Pair, "="); begin Env.Insert (League.Text_Codecs.Codec_For_Application_Locale.Decode (To_Stream_Element_Array (Pair (Pair'First .. Index - 1))), League.Text_Codecs.Codec_For_Application_Locale.Decode (To_Stream_Element_Array (Pair (Index + 1 .. Pair'Last)))); end; end loop; end; end Initialize_Arguments_Environment;
onox/orka
Ada
854
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Jobs.System is procedure Execute_GPU_Jobs is begin Executors.Execute_Jobs ("Renderer", Queues.GPU, Queue'Access); end Execute_GPU_Jobs; end Orka.Jobs.System;