repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
kontena/ruby-packer | Ada | 5,080 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Menu_Demo.Handler --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2004,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions : --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.16 $
-- $Date: 2009/12/26 17:38:58 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Sample.Menu_Demo.Aux;
with Sample.Manifest; use Sample.Manifest;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
package body Sample.Menu_Demo.Handler is
package Aux renames Sample.Menu_Demo.Aux;
procedure Drive_Me (M : Menu;
Title : String := "")
is
L : Line_Count;
C : Column_Count;
Y : Line_Position;
X : Column_Position;
begin
Aux.Geometry (M, L, C, Y, X);
Drive_Me (M, Y, X, Title);
end Drive_Me;
procedure Drive_Me (M : Menu;
Lin : Line_Position;
Col : Column_Position;
Title : String := "")
is
Mask : Event_Mask := No_Events;
Old : Event_Mask;
Pan : Panel := Aux.Create (M, Title, Lin, Col);
V : Cursor_Visibility := Invisible;
begin
-- We are only interested in Clicks with the left button
Register_Reportable_Events (Left, All_Clicks, Mask);
Old := Start_Mouse (Mask);
Set_Cursor_Visibility (V);
loop
declare
K : Key_Code := Aux.Get_Request (M, Pan);
R : constant Driver_Result := Driver (M, K);
begin
case R is
when Menu_Ok => null;
when Unknown_Request =>
declare
I : constant Item := Current (M);
O : Item_Option_Set;
begin
if K = Key_Mouse then
K := SELECT_ITEM;
end if;
Get_Options (I, O);
if K = SELECT_ITEM and then not O.Selectable then
Beep;
else
if My_Driver (M, K, Pan) then
exit;
end if;
end if;
end;
when others => Beep;
end case;
end;
end loop;
End_Mouse (Old);
Aux.Destroy (M, Pan);
end Drive_Me;
end Sample.Menu_Demo.Handler;
|
reznikmm/matreshka | Ada | 4,567 | 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.Dots1_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Dots1_Attribute_Node is
begin
return Self : Draw_Dots1_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_Dots1_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Dots1_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Dots1_Attribute,
Draw_Dots1_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Dots1_Attributes;
|
peterfrankjohnson/assembler | Ada | 57 | ads | package Assembler is
procedure Assembler;
end Assembler; |
MinimSecure/unum-sdk | Ada | 880 | adb | -- Copyright (C) 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/>.
with Pck; use Pck;
procedure Foo_O508_021 is
SSA : Signed_Simple_Array := (-1, 2, -3, 4);
begin
Update_Signed_Small (SSA (3)); -- STOP
end Foo_O508_021;
|
zhmu/ananas | Ada | 4,959 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . V A L U E _ F --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routines for supporting the Value attribute for
-- ordinary fixed point types whose Small is the ratio of two Int values, and
-- also for conversion operations required in Text_IO.Fixed_IO for such types.
generic
type Int is range <>;
type Uns is mod <>;
with procedure Scaled_Divide
(X, Y, Z : Int;
Q, R : out Int;
Round : Boolean);
package System.Value_F is
pragma Preelaborate;
function Scan_Fixed
(Str : String;
Ptr : not null access Integer;
Max : Integer;
Num : Int;
Den : Int) return Int;
-- This function scans the string starting at Str (Ptr.all) for a valid
-- real literal according to the syntax described in (RM 3.5(43)). The
-- substring scanned extends no further than Str (Max). There are three
-- cases for the return:
--
-- If a valid real literal is found after scanning past any initial spaces,
-- then Ptr.all is updated past the last character of the literal (but
-- trailing spaces are not scanned out). The value returned is the value
-- Int'Integer_Value (decimal-literal-value), using the given Num/Den to
-- determine this value.
--
-- If no valid real literal is found, then Ptr.all points either to an
-- initial non-digit character, or to Max + 1 if the field is all spaces
-- and the exception Constraint_Error is raised.
--
-- If a syntactically valid integer is scanned, but the value is out of
-- range, or, in the based case, the base value is out of range or there
-- is an out of range digit, then Ptr.all points past the integer, and
-- Constraint_Error is raised.
--
-- Note: these rules correspond to the requirements for leaving the
-- pointer positioned in Text_Io.Get
--
-- Note: if Str is null, i.e. if Max is less than Ptr, then this is a
-- special case of an all-blank string, and Ptr is unchanged, and hence
-- is greater than Max as required in this case.
function Value_Fixed
(Str : String;
Num : Int;
Den : Int) return Int;
-- Used in computing X'Value (Str) where X is an ordinary fixed-point type.
-- Str is the string argument of the attribute. Constraint_Error is raised
-- if the string is malformed or if the value is out of range of Int (not
-- the range of the fixed-point type, which must be done by the caller).
-- Otherwise the value returned is the value Int'Integer_Value
-- (decimal-literal-value), using Small Num/Den to determine this value.
end System.Value_F;
|
optikos/oasis | Ada | 3,310 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Identifiers;
with Program.Elements.Expressions;
with Program.Elements.Formal_Package_Associations;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Formal_Package_Declarations is
pragma Pure (Program.Elements.Formal_Package_Declarations);
type Formal_Package_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Formal_Package_Declaration_Access is
access all Formal_Package_Declaration'Class with Storage_Size => 0;
not overriding function Name
(Self : Formal_Package_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is abstract;
not overriding function Generic_Package_Name
(Self : Formal_Package_Declaration)
return not null Program.Elements.Expressions.Expression_Access
is abstract;
not overriding function Parameters
(Self : Formal_Package_Declaration)
return Program.Elements.Formal_Package_Associations
.Formal_Package_Association_Vector_Access is abstract;
not overriding function Aspects
(Self : Formal_Package_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
type Formal_Package_Declaration_Text is limited interface;
type Formal_Package_Declaration_Text_Access is
access all Formal_Package_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Formal_Package_Declaration_Text
(Self : aliased in out Formal_Package_Declaration)
return Formal_Package_Declaration_Text_Access is abstract;
not overriding function With_Token
(Self : Formal_Package_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Package_Token
(Self : Formal_Package_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Is_Token
(Self : Formal_Package_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function New_Token
(Self : Formal_Package_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Formal_Package_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Formal_Package_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function With_Token_2
(Self : Formal_Package_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Formal_Package_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Formal_Package_Declarations;
|
Rodeo-McCabe/orka | Ada | 15,624 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
package body Orka.Rendering.Programs.Uniforms is
function Texture_Kind (Sampler : LE.Resource_Type) return LE.Texture_Kind is
use LE;
begin
case Sampler is
when Sampler_1D | Int_Sampler_1D | UInt_Sampler_1D | Sampler_1D_Shadow =>
return Texture_1D;
when Sampler_2D | Int_Sampler_2D | UInt_Sampler_2D | Sampler_2D_Shadow =>
return Texture_2D;
when Sampler_3D | Int_Sampler_3D | UInt_Sampler_3D =>
return Texture_3D;
when Sampler_2D_Rect | Int_Sampler_2D_Rect | UInt_Sampler_2D_Rect |
Sampler_2D_Rect_Shadow =>
return Texture_Rectangle;
when Sampler_Cube | Int_Sampler_Cube | UInt_Sampler_Cube | Sampler_Cube_Shadow =>
return Texture_Cube_Map;
when Sampler_Cube_Array | Int_Sampler_Cube_Array | UInt_Sampler_Cube_Array |
Sampler_Cube_Array_Shadow =>
return Texture_Cube_Map_Array;
when Sampler_1D_Array | Int_Sampler_1D_Array | UInt_Sampler_1D_Array |
Sampler_1D_Array_Shadow =>
return Texture_1D_Array;
when Sampler_2D_Array | Int_Sampler_2D_Array | UInt_Sampler_2D_Array |
Sampler_2D_Array_Shadow =>
return Texture_2D_Array;
when Sampler_Buffer | Int_Sampler_Buffer | UInt_Sampler_Buffer =>
return Texture_Buffer;
when Sampler_2D_Multisample | Int_Sampler_2D_Multisample | UInt_Sampler_2D_Multisample =>
return Texture_2D_Multisample;
when Sampler_2D_Multisample_Array | Int_Sampler_2D_Multisample_Array |
UInt_Sampler_2D_Multisample_Array =>
return Texture_2D_Multisample_Array;
when others =>
raise Constraint_Error;
end case;
end Texture_Kind;
function Image_Kind (Image : LE.Resource_Type) return LE.Texture_Kind is
use LE;
begin
case Image is
when Image_1D | Int_Image_1D | UInt_Image_1D =>
return Texture_1D;
when Image_2D | Int_Image_2D | UInt_Image_2D =>
return Texture_2D;
when Image_3D | Int_Image_3D | UInt_Image_3D =>
return Texture_3D;
when Image_2D_Rect | Int_Image_2D_Rect | UInt_Image_2D_Rect =>
return Texture_Rectangle;
when Image_Cube | Int_Image_Cube | UInt_Image_Cube =>
return Texture_Cube_Map;
when Image_Cube_Map_Array | Int_Image_Cube_Map_Array | UInt_Image_Cube_Map_Array =>
return Texture_Cube_Map_Array;
when Image_Buffer | Int_Image_Buffer | UInt_Image_Buffer =>
return Texture_Buffer;
when Image_1D_Array | Int_Image_1D_Array | UInt_Image_1D_Array =>
return Texture_1D_Array;
when Image_2D_Array | Int_Image_2D_Array | UInt_Image_2D_Array =>
return Texture_2D_Array;
when Image_2D_Multisample | Int_Image_2D_Multisample | UInt_Image_2D_Multisample =>
return Texture_2D_Multisample;
when Image_2D_Multisample_Array | Int_Image_2D_Multisample_Array |
UInt_Image_2D_Multisample_Array =>
return Texture_2D_Multisample_Array;
when others =>
raise Constraint_Error;
end case;
end Image_Kind;
function Sampler_Format_Type (Sampler : LE.Resource_Type) return PE.Format_Type is
use LE;
use PE;
begin
case Sampler is
when Sampler_1D | Sampler_2D | Sampler_3D | Sampler_2D_Rect |
Sampler_Cube | Sampler_Cube_Array | Sampler_Buffer |
Sampler_1D_Array | Sampler_2D_Array |
Sampler_2D_Multisample | Sampler_2D_Multisample_Array =>
return Float_Or_Normalized_Type;
when Int_Sampler_1D | Int_Sampler_2D | Int_Sampler_3D | Int_Sampler_2D_Rect |
Int_Sampler_Cube | Int_Sampler_Cube_Array | Int_Sampler_Buffer |
Int_Sampler_1D_Array | Int_Sampler_2D_Array |
Int_Sampler_2D_Multisample | Int_Sampler_2D_Multisample_Array =>
return Int_Type;
when UInt_Sampler_1D | UInt_Sampler_2D | UInt_Sampler_3D | UInt_Sampler_2D_Rect |
UInt_Sampler_Cube | UInt_Sampler_Cube_Array | UInt_Sampler_Buffer |
UInt_Sampler_1D_Array | UInt_Sampler_2D_Array |
UInt_Sampler_2D_Multisample | UInt_Sampler_2D_Multisample_Array =>
return Unsigned_Int_Type;
when Sampler_1D_Shadow | Sampler_2D_Shadow | Sampler_2D_Rect_Shadow |
Sampler_Cube_Shadow | Sampler_Cube_Array_Shadow |
Sampler_1D_Array_Shadow | Sampler_2D_Array_Shadow =>
return Depth_Type;
when others =>
raise Constraint_Error;
end case;
end Sampler_Format_Type;
function Image_Format_Type (Image : LE.Resource_Type) return PE.Format_Type is
use LE;
use PE;
begin
case Image is
when Image_1D | Image_2D | Image_3D | Image_2D_Rect |
Image_Cube | Image_Cube_Map_Array | Image_Buffer |
Image_1D_Array | Image_2D_Array |
Image_2D_Multisample | Image_2D_Multisample_Array =>
return Float_Or_Normalized_Type;
when Int_Image_1D | Int_Image_2D | Int_Image_3D | Int_Image_2D_Rect |
Int_Image_Cube | Int_Image_Cube_Map_Array | Int_Image_Buffer |
Int_Image_1D_Array | Int_Image_2D_Array |
Int_Image_2D_Multisample | Int_Image_2D_Multisample_Array =>
return Int_Type;
when UInt_Image_1D | UInt_Image_2D | UInt_Image_3D | UInt_Image_2D_Rect |
UInt_Image_Cube | UInt_Image_Cube_Map_Array | UInt_Image_Buffer |
UInt_Image_1D_Array | UInt_Image_2D_Array |
UInt_Image_2D_Multisample | UInt_Image_2D_Multisample_Array =>
return Unsigned_Int_Type;
when others =>
raise Constraint_Error;
end case;
end Image_Format_Type;
-----------------------------------------------------------------------------
procedure Set_Matrix (Object : Uniform; Value : Types.Singles.Matrix4) is
function Convert is new Ada.Unchecked_Conversion
(Source => Types.Singles.Matrix4, Target => GL.Types.Singles.Matrix4);
begin
Object.GL_Uniform.Set_Single_Matrix (Convert (Value));
end Set_Matrix;
procedure Set_Matrix (Object : Uniform; Value : Types.Doubles.Matrix4) is
function Convert is new Ada.Unchecked_Conversion
(Source => Types.Doubles.Matrix4, Target => GL.Types.Doubles.Matrix4);
begin
Object.GL_Uniform.Set_Double_Matrix (Convert (Value));
end Set_Matrix;
procedure Set_Vector (Object : Uniform; Value : Types.Singles.Vector4) is
function Convert is new Ada.Unchecked_Conversion
(Source => Types.Singles.Vector4, Target => GL.Types.Singles.Vector4);
begin
Object.GL_Uniform.Set_Single_Vector (Convert (Value));
end Set_Vector;
procedure Set_Vector (Object : Uniform; Value : Types.Doubles.Vector4) is
function Convert is new Ada.Unchecked_Conversion
(Source => Types.Doubles.Vector4, Target => GL.Types.Doubles.Vector4);
begin
Object.GL_Uniform.Set_Double_Vector (Convert (Value));
end Set_Vector;
-----------------------------------------------------------------------------
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Int_Array)
is
use type GL.Types.Int;
begin
case Data'Length is
when 2 =>
Object.GL_Uniform.Set_Int_Vector (GL.Types.Ints.Vector2'
(Data (Data'First),
Data (Data'First + 1)));
when 3 =>
Object.GL_Uniform.Set_Int_Vector (GL.Types.Ints.Vector3'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2)));
when 4 =>
Object.GL_Uniform.Set_Int_Vector (GL.Types.Ints.Vector4'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2),
Data (Data'First + 3)));
when others => raise Constraint_Error;
end case;
end Set_Vector;
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.UInt_Array)
is
use type GL.Types.Int;
begin
case Data'Length is
when 2 =>
Object.GL_Uniform.Set_UInt_Vector (GL.Types.UInts.Vector2'
(Data (Data'First),
Data (Data'First + 1)));
when 3 =>
Object.GL_Uniform.Set_UInt_Vector (GL.Types.UInts.Vector3'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2)));
when 4 =>
Object.GL_Uniform.Set_UInt_Vector (GL.Types.UInts.Vector4'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2),
Data (Data'First + 3)));
when others => raise Constraint_Error;
end case;
end Set_Vector;
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Single_Array)
is
use type GL.Types.Int;
begin
case Data'Length is
when 2 =>
Object.GL_Uniform.Set_Single_Vector (GL.Types.Singles.Vector2'
(Data (Data'First),
Data (Data'First + 1)));
when 3 =>
Object.GL_Uniform.Set_Single_Vector (GL.Types.Singles.Vector3'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2)));
when 4 =>
Object.GL_Uniform.Set_Single_Vector (GL.Types.Singles.Vector4'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2),
Data (Data'First + 3)));
when others => raise Constraint_Error;
end case;
end Set_Vector;
procedure Set_Vector
(Object : Uniform;
Data : GL.Types.Double_Array)
is
use type GL.Types.Int;
begin
case Data'Length is
when 2 =>
Object.GL_Uniform.Set_Double_Vector (GL.Types.Doubles.Vector2'
(Data (Data'First),
Data (Data'First + 1)));
when 3 =>
Object.GL_Uniform.Set_Double_Vector (GL.Types.Doubles.Vector3'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2)));
when 4 =>
Object.GL_Uniform.Set_Double_Vector (GL.Types.Doubles.Vector4'
(Data (Data'First),
Data (Data'First + 1),
Data (Data'First + 2),
Data (Data'First + 3)));
when others => raise Constraint_Error;
end case;
end Set_Vector;
-----------------------------------------------------------------------------
procedure Set_Single (Object : Uniform; Value : GL.Types.Single) is
begin
Object.GL_Uniform.Set_Single (Value);
end Set_Single;
procedure Set_Double (Object : Uniform; Value : GL.Types.Double) is
begin
Object.GL_Uniform.Set_Double (Value);
end Set_Double;
procedure Set_Int (Object : Uniform; Value : GL.Types.Int) is
begin
Object.GL_Uniform.Set_Int (Value);
end Set_Int;
procedure Set_UInt (Object : Uniform; Value : GL.Types.UInt) is
begin
Object.GL_Uniform.Set_UInt (Value);
end Set_UInt;
procedure Set_Integer (Object : Uniform; Value : Integer) is
begin
Object.GL_Uniform.Set_Int (GL.Types.Int (Value));
end Set_Integer;
procedure Set_Boolean (Object : Uniform; Value : Boolean) is
begin
Object.GL_Uniform.Set_Int (if Value then 1 else 0);
end Set_Boolean;
-----------------------------------------------------------------------------
function Is_Compatible
(Object : Uniform_Subroutine;
Index : Subroutine_Index) return Boolean
is
use type GL.Types.UInt;
begin
return (for some Function_Index of Object.Indices.Element => Index = Function_Index);
end Is_Compatible;
procedure Set_Function
(Object : Uniform_Subroutine;
Name : String) is
begin
Object.Set_Function (Object.Index (Name));
end Set_Function;
procedure Set_Function
(Object : Uniform_Subroutine;
Index : Subroutine_Index) is
begin
Object.Program.Set_Subroutine_Function (Object.Shader, Object.Location, Index);
end Set_Function;
function Index
(Object : Uniform_Subroutine;
Name : String) return Subroutine_Index is
begin
return Object.Program.GL_Program.Subroutine_Index (Object.Shader, Name);
end Index;
-----------------------------------------------------------------------------
function Create_Uniform_Sampler
(Object : Program;
Name : String) return Uniform_Sampler
is
Sampler_Kind : constant LE.Resource_Type := Object.GL_Program.Uniform_Type (Name);
begin
return Uniform_Sampler'
(Kind => Sampler_Kind,
GL_Uniform => Object.GL_Program.Uniform_Location (Name));
exception
when Constraint_Error =>
raise Uniform_Type_Error with
"Uniform " & Name & " has unexpected sampler type " & Sampler_Kind'Image;
end Create_Uniform_Sampler;
function Create_Uniform_Image
(Object : Program;
Name : String) return Uniform_Image
is
Image_Kind : constant LE.Resource_Type := Object.GL_Program.Uniform_Type (Name);
begin
return Uniform_Image'
(Kind => Image_Kind,
GL_Uniform => Object.GL_Program.Uniform_Location (Name));
exception
when Constraint_Error =>
raise Uniform_Type_Error with
"Uniform " & Name & " has unexpected image type " & Image_Kind'Image;
end Create_Uniform_Image;
function Create_Uniform_Subroutine
(Object : in out Program;
Shader : GL.Objects.Shaders.Shader_Type;
Name : String) return Uniform_Subroutine
is
Index : constant GL.Objects.Programs.Subroutine_Index_Type
:= Object.GL_Program.Subroutine_Uniform_Index (Shader, Name);
Indices : constant GL.Objects.Programs.Subroutine_Index_Array
:= Object.GL_Program.Subroutine_Indices_Uniform (Shader, Index);
begin
return Uniform_Subroutine'
(Location => Object.GL_Program.Subroutine_Uniform_Location (Shader, Name),
Indices => Indices_Holder.To_Holder (Indices),
Program => Object'Access,
Shader => Shader);
end Create_Uniform_Subroutine;
function Create_Uniform_Variable
(Object : Program;
Name : String) return Uniform
is
Uniform_Kind : constant LE.Resource_Type := Object.GL_Program.Uniform_Type (Name);
begin
return Uniform'
(Kind => Uniform_Kind,
GL_Uniform => Object.GL_Program.Uniform_Location (Name));
end Create_Uniform_Variable;
end Orka.Rendering.Programs.Uniforms;
|
coopht/axmpp | Ada | 3,291 | adb | ------------------------------------------------------------------------------
-- --
-- AXMPP Project --
-- --
-- XMPP Library for Ada --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Alexander Basov <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Alexander Basov, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body Con_Cli is
procedure Test (X : Session) is
begin
null;
end Test;
end Con_Cli;
|
reznikmm/matreshka | Ada | 1,086 | adb | with Ada.Command_Line;
with Ada.Streams.Stream_IO;
with League.Stream_Element_Vectors;
with Matreshka.Filters.LZMA.XZ_Unpack;
procedure XZ_Cat is
Data : Ada.Streams.Stream_Element_Array (1 .. 4096);
File : Ada.Streams.Stream_IO.File_Type;
Last : Ada.Streams.Stream_Element_Offset;
Input : League.Stream_Element_Vectors.Stream_Element_Vector;
Output : League.Stream_Element_Vectors.Stream_Element_Vector;
Filter : Matreshka.Filters.LZMA.XZ_Unpack.Filter;
begin
Ada.Streams.Stream_IO.Open
(File, Ada.Streams.Stream_IO.In_File, Ada.Command_Line.Argument (1));
while not Ada.Streams.Stream_IO.End_Of_File (File) loop
Ada.Streams.Stream_IO.Read (File, Data, Last);
Input.Clear;
Input.Append (Data (1 .. Last));
Filter.Read (Input, Output);
end loop;
Ada.Streams.Stream_IO.Close (File);
Ada.Streams.Stream_IO.Create
(File, Ada.Streams.Stream_IO.Out_File, Ada.Command_Line.Argument (2));
Ada.Streams.Stream_IO.Write (File, Output.To_Stream_Element_Array);
Ada.Streams.Stream_IO.Close (File);
end XZ_Cat;
|
AdaCore/libadalang | Ada | 130 | adb | separate (T)
task body Tsk is
begin
accept B do
Ignore_String (A'Image);
pragma Test_Statement;
end B;
end Tsk;
|
AdaCore/libadalang | Ada | 698 | adb | package P1 is
type I5 is interface;
procedure Proc_1 (X : I5) is abstract;
procedure Proc_2 (X : I5) is abstract;
procedure Proc_3 (X : I5) is abstract;
function F_4 (X : I5) return Integer is abstract;
function F_5 (X : I5) return Integer is abstract;
type I7 is interface;
procedure Proc_1 (X : I7) is abstract;
procedure Proc_2 (X : I7) is abstract;
procedure Proc_3 (X : I7) is null;
procedure Proc_4 (X : I7) is abstract;
procedure Proc_5 (X : I7) is abstract;
function Fun_6 (X : I7) return Integer is abstract;
function Fun_7 (X : I7) return Integer is abstract;
type I_5_7 is interface and I5 and I7;
--% node.p_get_primitives()
end P1;
|
reznikmm/matreshka | Ada | 4,559 | 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.Date_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Date_Attribute_Node is
begin
return Self : Meta_Date_Attribute_Node do
Matreshka.ODF_Meta.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Meta_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Meta_Date_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Date_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Meta_URI,
Matreshka.ODF_String_Constants.Date_Attribute,
Meta_Date_Attribute_Node'Tag);
end Matreshka.ODF_Meta.Date_Attributes;
|
zhmu/ananas | Ada | 162 | adb | -- { dg-do compile }
with Derived_Type5_Pkg; use Derived_Type5_Pkg;
procedure Derived_Type5 is
D : Derived;
begin
Proc1 (Rec (D));
Proc2 (Rec (D));
end;
|
stcarrez/babel | Ada | 5,945 | adb | -----------------------------------------------------------------------
-- tar -- TAR file
-- Copyright (C) 2015 Stephane.Carrez
-- Written by Stephane.Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Tar is
use type Ada.Streams.Stream_Element_Offset;
use type Ada.Streams.Stream_Element;
BLOCK_SIZE : constant Ada.Streams.Stream_Element_Offset := 512;
-- ------------------------------
-- Open the tar file for reading and use the given input stream to read the tar blocks.
-- ------------------------------
procedure Open (File : in out File_Type;
Input : in Util.Streams.Input_Stream_Access) is
begin
File.Input := Input;
File.Remain := 0;
File.Has_Current := False;
File.Next;
end Open;
-- ------------------------------
-- Returns true if the tar file contains another file entry.
-- ------------------------------
function Has_Element (File : in File_Type) return Boolean is
begin
return File.Has_Current;
end Has_Element;
procedure Get_String (From : in Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Length : in Ada.Streams.Stream_Element_Count;
Into : out Ada.Strings.Unbounded.Unbounded_String) is
Item : String (1 .. Positive (Length));
Item_Pos : Natural := 0;
C : Ada.Streams.Stream_Element;
begin
for I in Pos .. Pos + Length - 1 loop
C := From (I);
exit when C = 0;
Item_Pos := Item_Pos + 1;
Item (Item_Pos) := Character'Val (C);
end loop;
Into := Ada.Strings.Unbounded.To_Unbounded_String (Item (Item'First .. Item_Pos));
end Get_String;
function Get_Number (From : in Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Length : in Ada.Streams.Stream_Element_Count) return Long_Long_Integer is
Result : Long_Long_Integer := 0;
C : Character;
begin
for I in Pos .. Pos + Length - 1 loop
exit when From (I) = 0;
Result := Result * 8;
C := Character'Val (From (I));
if C >= '0' and C <= '7' then
Result := Result + Character'Pos (C) - Character'Pos ('0');
end if;
end loop;
return Result;
end Get_Number;
function Is_Zero (Buf : in Ada.Streams.Stream_Element_Array) return Boolean is
begin
for I in Buf'Range loop
if Buf (I) /= 0 then
return False;
end if;
end loop;
return True;
end Is_Zero;
-- ------------------------------
-- Read the next file entry in the tar file.
-- ------------------------------
procedure Next (File : in out File_Type) is
use Util.Systems.Types;
Buf : Ada.Streams.Stream_Element_Array (0 .. BLOCK_SIZE - 1);
Last : Ada.Streams.Stream_Element_Offset;
begin
File.Has_Current := False;
while File.Remain > 0 loop
File.Read (Buf, Last);
exit when Last = 0;
end loop;
if File.Padding > 0 then
File.Input.Read (Buf (1 .. File.Padding), Last);
end if;
File.Input.Read (Buf, Last);
if Last = BLOCK_SIZE and (Buf (Buf'First) /= 0 or else not Is_Zero (Buf)) then
File.Has_Current := True;
Get_String (Buf, 0, 100, File.Current.Name);
File.Current.Mode := mode_t (Get_Number (Buf, 100, 8));
File.Current.Uid := uid_t (Get_Number (Buf, 108, 8));
File.Current.Gid := gid_t (Get_Number (Buf, 116, 8));
File.Current.Size := off_t (Get_Number (Buf, 124, 12));
File.Current.Mtime := Get_Number (Buf, 136, 12);
File.Current.Chksum := Natural (Get_Number (Buf, 148, 8));
-- typeflag/156
Get_String (Buf, 157, 100, File.Current.Linkname);
Get_String (Buf, 265, 32, File.Current.Uname);
Get_String (Buf, 297, 32, File.Current.Gname);
File.Current.Devmajor := Get_Number (Buf, 329, 8);
File.Current.Devminor := Get_Number (Buf, 337, 8);
Get_String (Buf, 345, 155, File.Current.Prefix);
File.Remain := Ada.Streams.Stream_Element_Count (File.Current.Size);
File.Padding := (BLOCK_SIZE - (File.Remain mod BLOCK_SIZE)) mod BLOCK_SIZE;
end if;
end Next;
-- ------------------------------
-- Get the current file entry information.
-- ------------------------------
function Element (File : in File_Type) return File_Info_Type is
begin
return File.Current;
end Element;
-- ------------------------------
-- Read the data for the current file entry.
-- ------------------------------
procedure Read (File : in out File_Type;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
if File.Remain = 0 then
Last := 0;
elsif File.Remain >= Into'Length then
File.Input.Read (Into, Last);
File.Remain := File.Remain - Last;
else
File.Input.Read (Into (Into'First .. Into'First + File.Remain - 1), Last);
File.Remain := File.Remain - Last;
end if;
end Read;
end Tar;
|
reznikmm/matreshka | Ada | 5,896 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body Core.Objects.Listeners is
---------
-- Add --
---------
procedure Add
(Self : in out Listener_Registry'Class;
Listener : not null Listener_Access) is
begin
if Listener.all not in Abstract_Object'Class then
raise Constraint_Error
with "Listener must be derived from Abstract_Object";
else
declare
Aux : Listener_Record_Access
:= new Listener_Record
(Self'Unchecked_Access,
Abstract_Object'Class (Listener.all)'Unchecked_Access,
Listener);
begin
Aux.Connect;
end;
end if;
end Add;
--------------------
-- Generic_Notify --
--------------------
procedure Generic_Notify (Self : Listener_Registry) is
Current : Listener_Record_Access := Listener_Record_Access (Self.Head);
begin
while Current /= null loop
begin
Notify (Current.Listener.all);
exception
when others =>
-- XXX For debug purposes it can be useful to report exception
-- in some way.
null;
end;
Current := Listener_Record_Access (Current.Registry_Next);
end loop;
end Generic_Notify;
----------------------
-- Generic_Notify_1 --
----------------------
procedure Generic_Notify_1
(Self : Listener_Registry; Parameter : Parameter_Type)
is
Current : Listener_Record_Access := Listener_Record_Access (Self.Head);
begin
while Current /= null loop
begin
Notify (Current.Listener.all, Parameter);
exception
when others =>
-- XXX For debug purposes it can be useful to report exception
-- in some way.
null;
end;
Current := Listener_Record_Access (Current.Registry_Next);
end loop;
end Generic_Notify_1;
------------
-- Remove --
------------
procedure Remove
(Self : in out Listener_Registry'Class;
Listener : not null Listener_Access)
is
Current : Listener_Record_Access := Listener_Record_Access (Self.Head);
begin
while Current /= null loop
exit when Current.Listener = Listener;
Current := Listener_Record_Access (Current.Registry_Next);
end loop;
if Current /= null then
Delete (Core.Objects.Listener_Record_Access (Current));
end if;
end Remove;
end Core.Objects.Listeners;
|
reznikmm/matreshka | Ada | 4,647 | 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.Min_Label_Width_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Min_Label_Width_Attribute_Node is
begin
return Self : Text_Min_Label_Width_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Min_Label_Width_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Min_Label_Width_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Min_Label_Width_Attribute,
Text_Min_Label_Width_Attribute_Node'Tag);
end Matreshka.ODF_Text.Min_Label_Width_Attributes;
|
reznikmm/matreshka | Ada | 4,639 | 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_Presentation.Speed_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Speed_Attribute_Node is
begin
return Self : Presentation_Speed_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Speed_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Speed_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Speed_Attribute,
Presentation_Speed_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Speed_Attributes;
|
MinimSecure/unum-sdk | Ada | 864 | adb | -- Copyright 2010-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/>.
with Pck; use Pck;
procedure Foo is
My_Shape : Circle := (X => 1, Y => 2, R => 3);
X : Integer;
begin
X := Position_X (My_Shape);
end Foo;
|
reznikmm/matreshka | Ada | 3,639 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Write_Variable_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Write_Variable_Action, UML_Write_Variable_Action_Access);
|
ph0sph8/amass | Ada | 1,429 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Shodan"
type = "api"
function start()
setratelimit(2)
end
function vertical(ctx, domain)
if (api == nil or api.key == "") then
return
end
local resp
local vurl = buildurl(domain)
-- Check if the response data is in the graph database
if (api.ttl ~= nil and api.ttl > 0) then
resp = obtain_response(vurl, api.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request({
url=vurl,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
if (api.ttl ~= nil and api.ttl > 0) then
cache_response(vurl, resp)
end
end
local d = json.decode(resp)
if (d == nil or #(d.subdomains) == 0) then
return
end
for i, sub in pairs(d.subdomains) do
sendnames(ctx, sub .. "." .. domain)
end
end
function buildurl(domain)
return "https://api.shodan.io/dns/domain/" .. domain .. "?key=" .. api.key
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
for i, v in pairs(names) do
newname(ctx, v)
end
end
|
Letractively/ada-el | Ada | 2,955 | ads | -----------------------------------------------------------------------
-- el-functions-namespaces -- Namespace function mapper
-- Copyright (C) 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings.Maps;
package EL.Functions.Namespaces is
-- ------------------------------
-- Namespace Function mapper
-- ------------------------------
-- The <b>NS_Function_Mapper</b> is a delegate function mapper which provides XML
-- namespace support. The XML namespaces are registered with the <b>Set_Namespace</b>
-- procedure which records a prefix and the associated URI namespace. When a function is
-- searched, the <b>Namespace</b> is searched in the prefix map to find the corresponding
-- URI namespace. Then, the delegated function mapper is invoked using that URI.
type NS_Function_Mapper is new Function_Mapper with private;
type Function_Mapper_Access is access all Function_Mapper'Class;
-- Find the function knowing its name.
overriding
function Get_Function (Mapper : in NS_Function_Mapper;
Namespace : in String;
Name : in String) return Function_Access;
-- Bind a name to a function in the given namespace.
overriding
procedure Set_Function (Mapper : in out NS_Function_Mapper;
Namespace : in String;
Name : in String;
Func : in Function_Access);
-- Associate the <b>Prefix</b> with the givien <b>URI</b> building a new namespace.
procedure Set_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String;
URI : in String);
-- Remove the namespace prefix binding.
procedure Remove_Namespace (Mapper : in out NS_Function_Mapper;
Prefix : in String);
-- Set the delegate function mapper.
procedure Set_Function_Mapper (Mapper : in out NS_Function_Mapper;
Delegate : in Function_Mapper_Access);
private
type NS_Function_Mapper is new Function_Mapper with record
Mapping : Util.Strings.Maps.Map;
Mapper : Function_Mapper_Access;
end record;
end EL.Functions.Namespaces;
|
tj800x/SPARKNaCl | Ada | 506 | adb | with Ada.Text_IO; use Ada.Text_IO;
package body SPARKNaCl.PDebug
is
On : constant Boolean := True;
package I64IO is new Ada.Text_IO.Integer_IO (Integer_64);
procedure DH (S : in String; D : in GF)
is
begin
if On then
Put_Line (S);
for I in D'Range loop
I64IO.Put (D (I), Width => 0);
Put (' ');
I64IO.Put (D (I), Width => 0, Base => 16);
New_Line;
end loop;
end if;
end DH;
end SPARKNaCl.PDebug;
|
zhmu/ananas | Ada | 227 | adb | -- { dg-do compile }
-- { dg-error "not marked 'Inline_Always'" "" { target *-*-* } 0 }
-- { dg-error "cannot be inlined" "" { target *-*-* } 0 }
with Inline3_Pkg; use Inline3_Pkg;
procedure Inline3 is
begin
Test (0);
end;
|
AdaCore/Ada_Drivers_Library | Ada | 5,457 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Serial_IO; use Serial_IO;
with Ada.Synchronous_Task_Control; use Ada.Synchronous_Task_Control;
package Message_Buffers is
pragma Elaborate_Body;
type Message (Physical_Size : Positive) is tagged limited private;
function Content (This : Message) return String with Inline;
function Length (This : Message) return Natural with Inline;
function Content_At (This : Message; Index : Positive) return Character with
Pre => Index <= Length (This),
Inline;
procedure Clear (This : in out Message) with
Post => Length (This) = 0 and Content (This) = "",
Inline;
procedure Append (This : in out Message; Value : Character) with
Pre => Length (This) < This.Physical_Size,
Post => Content_At (This, Length (This)) = Value,
Inline;
procedure Set (This : in out Message; To : String) with
Pre => To'Length <= This.Physical_Size,
Post => Length (This) = To'Length and Content (This) = To,
Inline;
procedure Set (This : in out Message; To : Character) with
Post => Length (This) = 1 and Content_At (This, 1) = To,
Inline;
procedure Set_Terminator (This : in out Message; To : Character) with
Post => Terminator (This) = To,
Inline;
-- Specify the character that signals the end of an incoming message
-- from the sender's point of view, ie the "logical" end of a message,
-- as opposed to the physical capacity.
function Terminator (This : Message) return Character with Inline;
-- The logical end of message character (eg, CR). Either the value of a
-- prior call to Set_Terminator, or the character Nul if no terminator has
-- ever been set. The terminator character, if received, is not stored in
-- the message into which characters are being received.
procedure Await_Transmission_Complete (This : in out Message) with Inline;
-- Used for non-blocking output, to wait until the last char has been sent.
procedure Await_Reception_Complete (This : in out Message) with Inline;
-- Used for non-blocking input, to wait until the last char has been
-- received.
procedure Signal_Transmission_Complete (This : in out Message) with Inline;
procedure Signal_Reception_Complete (This : in out Message) with Inline;
procedure Note_Error (This : in out Message; Condition : Error_Conditions)
with Inline;
function Errors_Detected (This : Message) return Error_Conditions with Inline;
procedure Clear_Errors (This : in out Message) with Inline;
function Has_Error (This : Message; Condition : Error_Conditions)
return Boolean with Inline;
private
type Message (Physical_Size : Positive) is tagged limited record
Content : String (1 .. Physical_Size);
Length : Natural := 0;
Reception_Complete : Suspension_Object;
Transmission_Complete : Suspension_Object;
Terminator : Character := ASCII.NUL;
Error_Status : Error_Conditions := No_Error_Detected;
end record;
end Message_Buffers;
|
jorge-real/TTS-Ravenscar | Ada | 2,050 | adb | -- with Ada.Text_IO, Ada.Real_Time;
-- use Ada.Text_IO, Ada.Real_Time;
package body Use_CPU is
-- T1, T2, T3 : Time;
-- Time_Measured : Time_Span;
-- Tolerance : Time_Span := Microseconds (50);
-- X : Float := 0.0;
-- Min : Integer := 0;
-- Max : Integer := 10_000_000;
-- NTimes : Integer := (Max - Min) / 2; -- Number of iterations to calibrate for 10 ms use of CPU
procedure Iterate (Iterations : in Integer)
with Inline
is
X : Float := 0.0;
begin
for I in 1 .. Iterations loop
X := X + 16.25;
X := X - 16.25;
X := X + 16.25;
X := X - 16.25;
X := X + 16.25;
X := X - 16.25;
end loop;
end Iterate;
procedure Work (Amount_MS : in Natural) is
-- Constant 27464 comes from several calibration runs on the STM32F4 Discovery board
Iterations : Integer := (27464 * Amount_MS) / 10; -- (NTimes * Amount_MS) / 10;
begin
Iterate (Iterations);
end Work;
-- begin
-- Put ("Calibrating nr. of iterations for 10 ms...");
-- loop
-- --Put("Trying" & Integer'Image(NTimes) & " times:");
-- --Put(" ." & Integer'Image(NTimes) );
-- Put (".");
-- T1 := Clock;
-- Iterate (NTimes);
-- T2 := Clock;
-- T3 := Clock;
-- Time_Measured := (T2 - T1 - (T3 - T2));
-- --Put(" Took" & Duration'Image(To_Duration(Time_Measured)) & " seconds.");
-- if abs (Time_Measured - Milliseconds (10)) <= Tolerance then
-- exit;
-- elsif (Time_Measured > Milliseconds (10)) then -- NTimes too large -> reduce
-- Max := NTimes;
-- else -- NTimes too short -> increase
-- Min := NTimes;
-- end if;
-- --Put_Line (" Searching now range" & Integer'Image(Min) & " .. " & Integer'Image(Max));
-- NTimes := Min + ((Max - Min) / 2);
-- end loop;
-- Put_Line (" Done!");
-- Put_Line(" Nr. of iterations for 10 ms =" & Integer'Image(NTimes));
-- New_Line;
end Use_CPU;
|
stcarrez/ada-keystore | Ada | 1,143 | ads | -----------------------------------------------------------------------
-- intl -- Small libintl binding
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Intl is
function Gettext (Message : in String) return String;
function "-" (Message : in String) return String is (Gettext (Message));
function Current_Locale return String;
procedure Initialize (Domain : in String;
Dirname : in String);
end Intl;
|
stcarrez/ada-css | Ada | 5,201 | adb | -----------------------------------------------------------------------
-- css-comments -- CSS comments recording
-- Copyright (C) 2017, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Characters.Latin_1;
package body CSS.Comments is
function Get_Line_Count (Text : in String) return Positive;
-- ------------------------------
-- Get the line number where the comment was written.
-- ------------------------------
function Get_Line_Number (Comment : in Comment_Type) return Natural is
begin
return Comment.Object.Line;
end Get_Line_Number;
-- ------------------------------
-- Get the number of lines that the comment span.
-- ------------------------------
function Get_Line_Count (Comment : in Comment_Type) return Natural is
begin
return Comment.Object.Line_Count;
end Get_Line_Count;
-- ------------------------------
-- Get the full or stripped comment text.
-- ------------------------------
function Get_Text (Comment : in Comment_Type;
Strip : in Boolean := False) return String is
pragma Unreferenced (Strip);
begin
return Comment.Object.Text;
end Get_Text;
-- ------------------------------
-- Get the given line of the comment text.
-- ------------------------------
function Get_Text (Comment : in Comment_Type;
Line : in Positive;
Strip : in Boolean := False) return String is
Start, Finish : Positive;
begin
if Line > Comment.Object.Line_Count then
return "";
else
Start := Comment.Object.Lines (Line).Start;
Finish := Comment.Object.Lines (Line).Finish;
if Strip then
while Start <= Finish loop
exit when Comment.Object.Text (Start) /= ' '
and then Comment.Object.Text (Start) /= ASCII.HT;
Start := Start + 1;
end loop;
while Start <= Finish loop
exit when Comment.Object.Text (Finish) /= ' '
and then Comment.Object.Text (Finish) /= ASCII.HT;
Finish := Finish - 1;
end loop;
end if;
return Comment.Object.Text (Start .. Finish);
end if;
end Get_Text;
function Get_Line_Count (Text : in String) return Positive is
Result : Positive := 1;
begin
for I in Text'Range loop
if Text (I) = Ada.Characters.Latin_1.LF then
Result := Result + 1;
end if;
end loop;
return Result;
end Get_Line_Count;
-- ------------------------------
-- Insert in the comment list the comment described by <tt>Text</tt>
-- and associated with source line number <tt>Line</tt>. After insertion
-- the comment reference is returned to identify the new comment.
-- ------------------------------
procedure Insert (List : in out CSSComment_List;
Text : in String;
Line : in Natural;
Index : out Comment_Type) is
N : constant Positive := Get_Line_Count (Text);
C : constant Comment_Access := new Comment '(Len => Text'Length, Line_Count => N,
Text => Text, Line => Line, Next => List.Chain,
Lines => (others => (1, 0)));
First : Natural := 1;
Last : constant Natural := Text'Length;
Pos : Positive := 1;
begin
Index.Object := C.all'Access;
List.Chain := C;
while First <= Last loop
if Text (First) = Ada.Characters.Latin_1.LF then
C.Lines (Pos).Finish := First - 1;
Pos := Pos + 1;
C.Lines (Pos).Start := First + 1;
end if;
First := First + 1;
end loop;
C.Lines (Pos).Finish := Last;
end Insert;
-- ------------------------------
-- Release the memory used by the comment list.
-- ------------------------------
overriding
procedure Finalize (List : in out CSSComment_List) is
procedure Free is
new Ada.Unchecked_Deallocation (Comment, Comment_Access);
Current : Comment_Access := List.Chain;
begin
while Current /= null loop
declare
Next : constant Comment_Access := Current.Next;
begin
Free (Current);
Current := Next;
end;
end loop;
List.Chain := null;
end Finalize;
end CSS.Comments;
|
reznikmm/matreshka | Ada | 3,749 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Use_Chart_Objects_Attributes is
pragma Preelaborate;
type ODF_Text_Use_Chart_Objects_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Use_Chart_Objects_Attribute_Access is
access all ODF_Text_Use_Chart_Objects_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Use_Chart_Objects_Attributes;
|
melwyncarlo/ProjectEuler | Ada | 7,149 | adb | with Ada.Long_Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A043 is
use Ada.Long_Integer_Text_IO;
Main_Num : String (1 .. 10) := "0123456789";
Temp_Char : String (1 .. 1);
Pandigital_Num_List : array (Integer range 1 .. 100) of Long_Integer :=
(others => 0);
Sum : Long_Integer := 0;
Count_Val : Integer := 1;
Duplicate_Found : Boolean;
begin
for I in 1 .. 10 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Main_Num (5 .. 5);
Main_Num (5 .. 5) := Main_Num (4 .. 4);
Main_Num (4 .. 4) := Main_Num (3 .. 3);
Main_Num (3 .. 3) := Main_Num (2 .. 2);
Main_Num (2 .. 2) := Main_Num (1 .. 1);
Main_Num (1 .. 1) := Temp_Char;
for J in 1 .. 9 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Main_Num (5 .. 5);
Main_Num (5 .. 5) := Main_Num (4 .. 4);
Main_Num (4 .. 4) := Main_Num (3 .. 3);
Main_Num (3 .. 3) := Main_Num (2 .. 2);
Main_Num (2 .. 2) := Temp_Char;
for K in 1 .. 8 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Main_Num (5 .. 5);
Main_Num (5 .. 5) := Main_Num (4 .. 4);
Main_Num (4 .. 4) := Main_Num (3 .. 3);
Main_Num (3 .. 3) := Temp_Char;
for L in 1 .. 7 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Main_Num (5 .. 5);
Main_Num (5 .. 5) := Main_Num (4 .. 4);
Main_Num (4 .. 4) := Temp_Char;
for M in 1 .. 6 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Main_Num (5 .. 5);
Main_Num (5 .. 5) := Temp_Char;
for N in 1 .. 5 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Main_Num (6 .. 6);
Main_Num (6 .. 6) := Temp_Char;
for O in 1 .. 4 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Main_Num (7 .. 7);
Main_Num (7 .. 7) := Temp_Char;
for P in 1 .. 3 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Main_Num (8 .. 8);
Main_Num (8 .. 8) := Temp_Char;
for Q in 1 .. 2 loop
Temp_Char := Main_Num (10 .. 10);
Main_Num (10 .. 10) := Main_Num (9 .. 9);
Main_Num (9 .. 9) := Temp_Char;
if Main_Num (6 .. 6) /= "5"
and Main_Num (6 .. 6) /= "0"
then
goto Continue;
end if;
if Integer'Value (Main_Num (4 .. 4)) mod 2 /= 0
then
goto Continue;
end if;
if (Integer'Value (Main_Num (3 .. 3))
+ Integer'Value (Main_Num (4 .. 4))
+ Integer'Value (Main_Num (5 .. 5))) mod 3 /= 0
then
goto Continue;
end if;
if Integer'Value (Main_Num (5 .. 7)) mod 7 /= 0
then
goto Continue;
end if;
if Integer'Value (Main_Num (6 .. 8)) mod 11 /= 0
then
goto Continue;
end if;
if Integer'Value (Main_Num (7 .. 9)) mod 13 /= 0
then
goto Continue;
end if;
if Integer'Value (Main_Num (8 .. 10)) mod 17 /= 0
then
goto Continue;
end if;
Duplicate_Found := False;
for R in 1 .. Count_Val loop
if Pandigital_Num_List (R)
= Long_Integer'Value (Main_Num)
then
Duplicate_Found := True;
exit;
end if;
end loop;
if not Duplicate_Found then
Pandigital_Num_List (Count_Val) :=
Long_Integer'Value (Main_Num);
Sum := Sum
+ Long_Integer'Value (Main_Num);
Count_Val := Count_Val + 1;
end if;
<<Continue>>
end loop;
end loop;
end loop;
end loop;
end loop;
end loop;
end loop;
end loop;
end loop;
Put (Sum, Width => 0);
end A043;
|
gusthoff/ada_wavefiles_gtk_app | Ada | 1,545 | adb | -------------------------------------------------------------------------------
--
-- WAVEFILES GTK APPLICATION
--
-- Main file
--
-- The MIT License (MIT)
--
-- Copyright (c) 2017 Gustavo A. Hoffmann
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and /
-- or sell copies of the Software, and to permit persons to whom the Software
-- is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-- IN THE SOFTWARE.
-------------------------------------------------------------------------------
with WaveFiles_Gtk;
procedure Wavefiles_Gtk_App is
begin
-- Creates main window
WaveFiles_Gtk.Create;
end Wavefiles_Gtk_App;
|
AdaCore/Ada_Drivers_Library | Ada | 8,813 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017-2019, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body SiFive.UART is
-------------------
-- Set_Stop_Bits --
-------------------
procedure Set_Stop_Bits (This : in out UART_Device; To : Stop_Bits) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.TXCTRL.NSTOP := (case To is
when Stopbits_1 => False,
when Stopbits_2 => True);
end Set_Stop_Bits;
-------------------
-- Set_Baud_Rate --
-------------------
procedure Set_Baud_Rate (This : in out UART_Device;
CPU_Frequency : UInt32;
To : Baud_Rates)
is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.DIV.DIV := UInt16 (CPU_Frequency / (To - 1));
end Set_Baud_Rate;
---------------
-- Enable_RX --
---------------
procedure Enable_RX (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.RXCTRL.ENABLE := True;
end Enable_RX;
---------------
-- Enable_TX --
---------------
procedure Enable_TX (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.TXCTRL.ENABLE := True;
end Enable_TX;
----------------
-- Disable_RX --
----------------
procedure Disable_RX (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.RXCTRL.ENABLE := False;
end Disable_RX;
----------------
-- Disable_TX --
----------------
procedure Disable_TX (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.TXCTRL.ENABLE := False;
end Disable_TX;
--------------------------
-- RX_Interrupt_Pending --
--------------------------
function RX_Interrupt_Pending (This : UART_Device) return Boolean
is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
return Periph.IP.RXWM;
end RX_Interrupt_Pending;
--------------------------
-- TX_Interrupt_Pending --
--------------------------
function TX_Interrupt_Pending (This : UART_Device) return Boolean
is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
return Periph.IP.TXWM;
end TX_Interrupt_Pending;
-------------------------
-- Enable_RX_Interrupt --
-------------------------
procedure Enable_RX_Interrupt (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.IE.RXWM := True;
end Enable_RX_Interrupt;
-------------------------
-- Enable_TX_Interrupt --
-------------------------
procedure Enable_TX_Interrupt (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.IE.TXWM := True;
end Enable_TX_Interrupt;
--------------------------
-- Disable_RX_Interrupt --
--------------------------
procedure Disable_RX_Interrupt (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.IE.RXWM := False;
end Disable_RX_Interrupt;
--------------------------
-- Disable_TX_Interrupt --
--------------------------
procedure Disable_TX_Interrupt (This : in out UART_Device) is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.IE.TXWM := False;
end Disable_TX_Interrupt;
------------------------------
-- Set_Interrupt_Thresholds --
------------------------------
procedure Set_Interrupt_Thresholds (This : in out UART_Device;
RX, TX : UInt3)
is
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
Periph.TXCTRL.TXCNT := TX;
Periph.RXCTRL.RXCNT := RX;
end Set_Interrupt_Thresholds;
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out UART_Device;
Data : UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Timeout);
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
begin
for Elt of Data loop
while Periph.TXDATA.FULL loop
null;
end loop;
Periph.TXDATA.DATA := Elt;
end loop;
Status := Ok;
end Transmit;
--------------
-- Transmit --
--------------
overriding
procedure Transmit
(This : in out UART_Device;
Data : UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
begin
raise Program_Error with "FE310 UART only support 8bit mode";
end Transmit;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out UART_Device;
Data : out UART_Data_8b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
pragma Unreferenced (Timeout);
Periph : aliased UART_Peripheral
with Import, Address => System'To_Address (This.Base_Address);
Data_Reg : RXDATA_Register;
begin
for Elt of Data loop
loop
Data_Reg := Periph.RXDATA;
exit when not Data_Reg.EMPTY;
end loop;
Elt := Data_Reg.DATA;
end loop;
Status := Ok;
end Receive;
-------------
-- Receive --
-------------
overriding
procedure Receive
(This : in out UART_Device;
Data : out UART_Data_9b;
Status : out UART_Status;
Timeout : Natural := 1000)
is
begin
raise Program_Error with "FE310 UART only support 8bit mode";
end Receive;
end SiFive.UART;
|
Rodeo-McCabe/orka | Ada | 4,151 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <[email protected]>
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.API;
with GL.Enums.Getter;
package body GL.Viewports is
-----------------------------------------------------------------------------
-- Viewports --
-----------------------------------------------------------------------------
function Maximum_Viewports return Size is
Result : Size := 16;
begin
API.Get_Size.Ref (Enums.Getter.Max_Viewports, Result);
return Result;
end Maximum_Viewports;
function Viewport_Subpixel_Bits return Size is
Result : Size := 0;
begin
API.Get_Size.Ref (Enums.Getter.Viewport_Subpixel_Bits, Result);
return Result;
end Viewport_Subpixel_Bits;
function Origin_Range return Singles.Vector2 is
Result : Singles.Vector2 := (0.0, 0.0);
begin
API.Get_Single_Vec2.Ref (Enums.Getter.Viewport_Bounds_Range, Result);
return Result;
end Origin_Range;
function Maximum_Extent return Singles.Vector2 is
Result : Singles.Vector2 := (0.0, 0.0);
begin
API.Get_Single_Vec2.Ref (Enums.Getter.Max_Viewport_Dims, Result);
return Result;
end Maximum_Extent;
procedure Set_Viewports (List : Viewport_List) is
begin
API.Viewport_Array.Ref (List'First, List'Length, List);
end Set_Viewports;
function Get_Viewport (Index : UInt) return Viewport is
Result : Singles.Vector4;
begin
API.Get_Single_Vec4_I.Ref (Enums.Getter.Viewport, Index, Result);
return
(X => Result (X),
Y => Result (Y),
Width => Result (Z),
Height => Result (W));
end Get_Viewport;
procedure Set_Depth_Ranges (List : Depth_Range_List) is
begin
API.Depth_Range_Array.Ref (List'First, List'Length, List);
end Set_Depth_Ranges;
function Get_Depth_Range (Index : UInt) return Depth_Range is
Result : Doubles.Vector2;
begin
API.Get_Double_Vec2_I.Ref (Enums.Getter.Depth_Range, Index, Result);
return
(Near => Result (X),
Far => Result (Y));
end Get_Depth_Range;
procedure Set_Scissor_Rectangles (List : Scissor_Rectangle_List) is
begin
API.Scissor_Array.Ref (List'First, List'Length, List);
end Set_Scissor_Rectangles;
function Get_Scissor_Rectangle (Index : UInt) return Scissor_Rectangle is
Result : Ints.Vector4;
begin
API.Get_Int_Vec4_I.Ref (Enums.Getter.Scissor_Box, Index, Result);
return
(Left => Result (X),
Bottom => Result (Y),
Width => Result (Z),
Height => Result (W));
end Get_Scissor_Rectangle;
-----------------------------------------------------------------------------
-- Clipping --
-----------------------------------------------------------------------------
procedure Set_Clipping (Origin : Viewport_Origin; Depth : Depth_Mode) is
begin
API.Clip_Control.Ref (Origin, Depth);
end Set_Clipping;
function Origin return Viewport_Origin is
Result : Viewport_Origin := Viewport_Origin'First;
begin
API.Get_Clip_Origin.Ref (Enums.Getter.Clip_Origin, Result);
return Result;
end Origin;
function Depth return Depth_Mode is
Result : Depth_Mode := Depth_Mode'First;
begin
API.Get_Clip_Depth_Mode.Ref (Enums.Getter.Clip_Depth_Mode, Result);
return Result;
end Depth;
end GL.Viewports;
|
usnistgov/rcslib | Ada | 1,024 | ads | with Nml;
with Interfaces.C;
use Interfaces.C;
with Ada.Finalization;
use Ada.Finalization;
with Unchecked_Conversion;
with Unchecked_Deallocation;
package Mynmlmsg is
type Mynmlmsg_Type is new Nml.NmlMsg with
record
AnotherInt : Int;
AnIntArray : Nml.Int_Array(1..10);
AnIntDla_Length : Int;
AnIntDla : Nml.Int_Array(1..10);
end record;
type Mynmlmsg_Type_Access is access Mynmlmsg_Type;
function NmlMsg_Access_To_Mynmlmsg_Type_Access is new
Unchecked_Conversion(Nml.NmlMsg_Access,Mynmlmsg_Type_Access);
procedure UpdateMynmlmsg_Type(Cms : in NML.Cms_Access ;
Msg : in Mynmlmsg_Type_Access );
procedure Initialize(Object : in out Mynmlmsg_Type);
function Format(Param_1 : in long;
Param_2 : in Nml.NmlMsg_Access;
Param_3 : in Nml.Cms_Access)
return int;
procedure Free is new Unchecked_Deallocation(Mynmlmsg_Type,Mynmlmsg_Type_Access);
end Mynmlmsg;
|
charlie5/lace | Ada | 6,953 | adb | with
ada.Strings.Hash,
ada.unchecked_Conversion;
package body openGL
is
------------
-- Profiles
--
function Profile return profile_Kind
is separate;
-----------
-- Vectors
--
function Scaled (Self : in Vector_3; By : in Vector_3) return Vector_3
is
begin
return [Self (1) * By (1),
Self (2) * By (2),
Self (3) * By (3)];
end Scaled;
function Scaled (Self : in Vector_3_array; By : in Vector_3) return Vector_3_array
is
Result : Vector_3_array (Self'Range);
begin
for i in Result'Range
loop
Result (i) := Scaled (Self (i), By);
end loop;
return Result;
end Scaled;
function to_Vector_3_array (Self : Vector_2_array) return Vector_3_array
is
the_Array : Vector_3_array (1 .. Self'Length);
begin
for i in Self'Range
loop
the_Array (Index_t (i)) := Vector_3 (Self (i) & 0.0);
end loop;
return the_Array;
end to_Vector_3_array;
----------
-- Colors
--
function to_color_Value (Self : in Primary) return color_Value
is
Value : constant Real := Real'Rounding (Real (Self) * 255.0);
begin
return color_Value (Value);
end to_color_Value;
function to_Primary (Self : in color_Value) return Primary
is
begin
return Primary (Real (Self) / 255.0);
end to_Primary;
function to_Color (Red, Green, Blue : in Primary) return rgb_Color
is
begin
return (to_color_Value (Red),
to_color_Value (Green),
to_color_Value (Blue));
end to_Color;
function to_lucid_Color (From : in rgba_Color) return lucid_Color
is
begin
return (Primary => (to_Primary (From.Primary.Red),
to_Primary (From.Primary.Green),
to_Primary (From.Primary.Blue)),
Opacity => Opaqueness (to_Primary (From.Alpha)));
end to_lucid_Color;
function to_rgba_Color (From : in lucid_Color) return rgba_Color
is
begin
return (Primary => (to_color_Value (From.Primary.Red),
to_color_Value (From.Primary.Green),
to_color_Value (From.Primary.Blue)),
Alpha => to_color_Value (Primary (From.Opacity)));
end to_rgba_Color;
function to_Color (From : in rgb_Color) return Color
is
begin
return (to_Primary (From.Red),
to_Primary (From.Green),
to_Primary (From.Blue));
end to_Color;
function to_rgb_Color (From : in Color) return rgb_Color
is
begin
return (to_color_Value (From.Red),
to_color_Value (From.Green),
to_color_Value (From.Blue));
end to_rgb_Color;
-------------
-- Heightmap
--
function Scaled (Self : in height_Map; By : in Real) return height_Map
is
begin
return Result : height_Map := Self
do
scale (Result, By);
end return;
end scaled;
procedure scale (Self : in out height_Map; By : in Real)
is
begin
for Row in Self'Range (1)
loop
for Col in Self'Range (1)
loop
Self (Row, Col) := Self (Row, Col) * By;
end loop;
end loop;
end scale;
function height_Extent (Self : in height_Map) return Vector_2
is
Min : Real := Real'Last;
Max : Real := Real'First;
begin
for Row in Self'Range (1)
loop
for Col in Self'Range (2)
loop
Min := Real'Min (Min, Self (Row, Col));
Max := Real'Max (Max, Self (Row, Col));
end loop;
end loop;
return [Min, Max];
end height_Extent;
function Region (Self : in height_Map; Rows, Cols : in index_Pair) return height_Map
is
Width : constant Index_t := Index_t (Rows (2) - Rows (1));
Height : constant Index_t := Index_t (Cols (2) - Cols (1));
the_Region : openGL.height_Map (1 .. Width + 1,
1 .. Height + 1);
begin
for Row in the_Region'Range (1)
loop
for Col in the_Region'Range (2)
loop
the_Region (Row, Col) := Self (Row + Rows (1) - 1,
Col + Cols (1) - 1);
end loop;
end loop;
return the_Region;
end Region;
----------
-- Assets
--
function to_Asset (Self : in String) return asset_Name
is
the_Name : String (asset_Name'Range);
begin
the_Name (1 .. Self'Length) := Self;
the_Name (Self'Length + 1 .. the_Name'Last) := [others => ' '];
return asset_Name (the_Name);
end to_Asset;
function to_String (Self : in asset_Name) return String
is
begin
for Each in reverse Self'Range
loop
if Self (Each) /= ' '
then
return String (Self (1 .. Each));
end if;
end loop;
return "";
end to_String;
function Hash (Self : in asset_Name) return ada.Containers.Hash_type
is
begin
return ada.Strings.Hash (to_String (Self));
end Hash;
---------
-- Bounds
--
function bounding_Box_of (Self : Sites) return Bounds
is
Result : Bounds := null_Bounds;
begin
for Each in Self'Range
loop
Result.Box.Lower (1) := Real'Min (Result.Box.Lower (1), Self (Each)(1));
Result.Box.Lower (2) := Real'Min (Result.Box.Lower (2), Self (Each)(2));
Result.Box.Lower (3) := Real'Min (Result.Box.Lower (3), Self (Each)(3));
Result.Box.Upper (1) := Real'Max (Result.Box.Upper (1), Self (Each)(1));
Result.Box.Upper (2) := Real'Max (Result.Box.Upper (2), Self (Each)(2));
Result.Box.Upper (3) := Real'Max (Result.Box.Upper (3), Self (Each)(3));
Result.Ball := Real'Max (Result.Ball,
abs Self (Each));
end loop;
return Result;
end bounding_Box_of;
procedure set_Ball_from_Box (Self : in out Bounds)
is
begin
Self.Ball := Real'Max (abs Self.Box.Lower,
abs Self.Box.Upper);
end set_Ball_from_Box;
---------
-- Images
--
function to_Image (From : in lucid_Image) return Image
is
the_Image : Image (From'Range (1),
From'Range (2));
begin
for Row in From'Range (1)
loop
for Col in From'Range (2)
loop
the_Image (Row, Col) := From (Row, Col).Primary;
end loop;
end loop;
return the_Image;
end to_Image;
------------
-- safe_Real
--
protected
body safe_Real
is
procedure Value_is (Now : in Real)
is
begin
the_Value := Now;
end Value_is;
function Value return Real
is
begin
return the_Value;
end Value;
end safe_Real;
end openGL;
|
stcarrez/ada-awa | Ada | 6,116 | adb | -----------------------------------------------------------------------
-- awa-mail -- Mail module
-- Copyright (C) 2011, 2012, 2015, 2017, 2018, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with AWA.Modules.Beans;
with AWA.Modules.Get;
with AWA.Mail.Beans;
with AWA.Mail.Components.Factory;
with AWA.Applications;
with Security;
with Servlet.Core;
with Servlet.Sessions;
with ASF.Requests.Mockup;
with ASF.Responses.Mockup;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Log.Loggers;
package body AWA.Mail.Modules is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Mail.Module");
package Register is new AWA.Modules.Beans (Module => Mail_Module,
Module_Access => Mail_Module_Access);
type Mail_Principal is new Security.Principal with null record;
-- Get the principal name.
overriding
function Get_Name (From : in Mail_Principal) return String;
-- ------------------------------
-- Get the principal name.
-- ------------------------------
overriding
function Get_Name (From : in Mail_Principal) return String is
pragma Unreferenced (From);
begin
return "AWA Mailer";
end Get_Name;
-- ------------------------------
-- Initialize the mail module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Mail_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the mail module");
-- Add the Mail UI components.
App.Add_Components (AWA.Mail.Components.Factory.Definition);
-- Register here any bean class, servlet, filter.
Register.Register (Plugin => Plugin,
Name => "AWA.Mail.Beans.Mail_Bean",
Handler => AWA.Mail.Beans.Create_Mail_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
end Initialize;
-- ------------------------------
-- Configures the module after its initialization and after having read its XML configuration.
-- ------------------------------
overriding
procedure Configure (Plugin : in out Mail_Module;
Props : in ASF.Applications.Config) is
Mailer : constant String := Props.Get ("mailer", "smtp");
begin
Log.Info ("Mail plugin is using {0} mailer", Mailer);
Plugin.Mailer := AWA.Mail.Clients.Factory (Mailer, Props);
end Configure;
-- ------------------------------
-- Create a new mail message.
-- ------------------------------
function Create_Message (Plugin : in Mail_Module)
return AWA.Mail.Clients.Mail_Message_Access is
begin
return Plugin.Mailer.Create_Message;
end Create_Message;
-- ------------------------------
-- Receive an event sent by another module with <b>Send_Event</b> method.
-- Format and send an email.
-- ------------------------------
procedure Send_Mail (Plugin : in Mail_Module;
Template : in String;
Props : in Util.Beans.Objects.Maps.Map;
Params : in Util.Beans.Objects.Maps.Map;
Content : in AWA.Events.Module_Event'Class) is
Name : constant String := Content.Get_Parameter ("name");
Locale : constant String := Content.Get_Parameter ("locale");
App : constant AWA.Modules.Application_Access := Plugin.Get_Application;
begin
Log.Info ("Receive event {0} with template {1}", Name, Template);
if Template = "" then
Log.Debug ("No email template associated with event {0}", Name);
return;
end if;
declare
use Util.Beans.Objects;
Req : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
Session : Servlet.Sessions.Session;
Ptr : constant Util.Beans.Basic.Readonly_Bean_Access := Content'Unrestricted_Access;
Bean : constant Object := To_Object (Ptr, STATIC);
Dispatcher : constant Servlet.Core.Request_Dispatcher
:= App.Get_Request_Dispatcher (Template);
Iter : Maps.Cursor := Params.First;
begin
App.Create_Session (Session);
Session.Set_Principal (new Mail_Principal);
Req.Set_Session (Session);
Req.Set_Request_URI (Template);
Req.Set_Method ("GET");
Req.Set_Attribute (Name => "event", Value => Bean);
Req.Set_Attributes (Props);
if Locale'Length > 0 then
Req.Set_Header ("Accept-Language", Locale);
end if;
-- Setup the request parameters.
while Maps.Has_Element (Iter) loop
Req.Set_Parameter (Maps.Key (Iter), To_String (Maps.Element (Iter)));
Maps.Next (Iter);
end loop;
Servlet.Core.Forward (Dispatcher, Req, Reply);
App.Delete_Session (Session);
end;
end Send_Mail;
-- ------------------------------
-- Get the mail module instance associated with the current application.
-- ------------------------------
function Get_Mail_Module return Mail_Module_Access is
function Get is new AWA.Modules.Get (Mail_Module, Mail_Module_Access, NAME);
begin
return Get;
end Get_Mail_Module;
end AWA.Mail.Modules;
|
sungyeon/drake | Ada | 11,502 | adb | -- convert UCD/UnicodeData.txt, UCD/CompositionExclusions.txt
-- bin/ucd_normalization -r $UCD/UnicodeData.txt $UCD/CompositionExclusions.txt > ../source/strings/a-ucdnor.ads
-- bin/ucd_normalization -u $UCD/UnicodeData.txt $UCD/CompositionExclusions.txt > ../source/strings/a-ucnoun.ads
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Containers.Ordered_Maps;
with Ada.Containers.Ordered_Sets;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants;
with Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Wide_Wide_Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
procedure ucd_normalization is
function Value (S : String) return Wide_Wide_Character is
Img : constant String := "Hex_" & (1 .. 8 - S'Length => '0') & S;
begin
return Wide_Wide_Character'Value (Img);
end Value;
procedure Put_16 (Item : Integer) is
begin
if Item >= 16#10000# then
Put (Item, Width => 1, Base => 16);
else
declare
S : String (1 .. 8); -- "16#XXXX#"
begin
Put (S, Item, Base => 16);
S (1) := '1';
S (2) := '6';
S (3) := '#';
for I in reverse 4 .. 6 loop
if S (I) = '#' then
S (4 .. I) := (others => '0');
exit;
end if;
end loop;
Put (S);
end;
end if;
end Put_16;
function NFS_Exclusion (C : Wide_Wide_Character) return Boolean is
begin
case Wide_Wide_Character'Pos (C) is
when 16#2000# .. 16#2FFF#
| 16#F900# .. 16#FAFF#
| 16#2F800# .. 16#2FAFF# =>
return True;
when others =>
return False;
end case;
end NFS_Exclusion;
package Decomposite_Maps is new Ada.Containers.Ordered_Maps (
Wide_Wide_Character,
Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String);
use Decomposite_Maps;
package WWC_Sets is new Ada.Containers.Ordered_Sets (
Wide_Wide_Character);
use WWC_Sets;
NFD : Decomposite_Maps.Map;
Exclusions : WWC_Sets.Set;
type Kind_Type is (Decomposition, Excluded, Singleton);
type Bit is (In_16, In_32);
function Get_Bit (C : Wide_Wide_Character) return Bit is
begin
if C > Wide_Wide_Character'Val (16#FFFF#) then
return In_32;
else
return In_16;
end if;
end Get_Bit;
function Get_Bit (S : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String) return Bit is
begin
for I in 1 .. Length (S) loop
if Get_Bit (Element (S, I)) = In_32 then
return In_32;
end if;
end loop;
return In_16;
end Get_Bit;
type Normalization is (D, C);
Total_Num : array (Boolean, Normalization) of Natural;
Num : array (Boolean, Kind_Type, Bit) of Natural;
type Output_Kind is (Reversible, Unreversible);
Output : Output_Kind;
begin
if Argument (1) = "-r" then
Output := Reversible;
elsif Argument (1) = "-u" then
Output := Unreversible;
else
raise Data_Error with "-r or -u";
end if;
declare
File : Ada.Text_IO.File_Type;
begin
Open (File, In_File, Argument (2));
while not End_Of_File (File) loop
declare
Line : constant String := Get_Line (File);
type Range_Type is record
First : Positive;
Last : Natural;
end record;
Fields : array (1 .. 14) of Range_Type;
P : Positive := Line'First;
N : Natural;
Token_First : Positive;
Token_Last : Natural;
Code : Wide_Wide_Character;
Alt : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String;
begin
for I in Fields'Range loop
N := P;
while N <= Line'Last and then Line (N) /= ';' loop
N := N + 1;
end loop;
if (N <= Line'Last) /= (I < Field'Last) then
raise Data_Error with Line & " -- 2A";
end if;
Fields (I).First := P;
Fields (I).Last := N - 1;
P := N + 1; -- skip ';'
end loop;
Code := Value (Line (Fields (1).First .. Fields (1).Last));
if Fields (6).First <= Fields (6).Last then -- normalization
if Line (Fields (6).First) = '<' then
null; -- skip NFKD
else -- NFD
Alt := Null_Unbounded_Wide_Wide_String;
P := Fields (6).First;
while P <= Fields (6).Last loop
Find_Token (
Line (P .. Fields (6).Last),
Hexadecimal_Digit_Set,
Inside,
Token_First,
Token_Last);
if Token_First /= P then
raise Data_Error with Line & " -- 2B";
end if;
Append (Alt, Value (Line (Token_First .. Token_Last)));
P := Token_Last + 1;
exit when P > Fields (6).Last;
N := Index_Non_Blank (Line (P .. Fields (6).Last));
if N = 0 then
raise Data_Error with Line & " -- 2C";
end if;
P := N;
end loop;
Insert (NFD, Code, Alt);
end if;
end if;
end;
end loop;
Close (File);
end;
declare
I : Decomposite_Maps.Cursor := First (NFD);
begin
while Has_Element (I) loop
if not NFS_Exclusion (Key (I)) then
declare
J : Decomposite_Maps.Cursor := Next (I);
begin
while Has_Element (J) loop
if Element (I) = Element (J) then
raise Data_Error with "dup";
end if;
J := Next (J);
end loop;
end;
end if;
I := Next (I);
end loop;
end;
declare
File : Ada.Text_IO.File_Type;
begin
Open (File, In_File, Argument (3));
while not End_Of_File (File) loop
declare
Line : constant String := Get_Line (File);
P : Positive := Line'First;
Token_First : Positive;
Token_Last : Natural;
First : Wide_Wide_Character;
begin
if Line'Length = 0 or else Line (P) = '#' then
null; -- comment
else
Find_Token (
Line (P .. Line'Last),
Hexadecimal_Digit_Set,
Inside,
Token_First,
Token_Last);
if Token_First /= P then
raise Data_Error with Line & " -- 3A";
end if;
First := Value (Line (Token_First .. Token_Last));
P := Token_Last + 1;
if Line (P) = '.' then
raise Data_Error with Line & " -- 3B";
end if;
if not Contains (NFD, First) then
raise Data_Error with Line & " -- 3C";
end if;
Insert (Exclusions, First);
end if;
end;
end loop;
Close (File);
end;
-- # (4) Non-Starter Decompositions
-- # 0344 COMBINING GREEK DIALYTIKA TONOS
-- # 0F73 TIBETAN VOWEL SIGN II
-- # 0F75 TIBETAN VOWEL SIGN UU
-- # 0F81 TIBETAN VOWEL SIGN REVERSED II
Insert (Exclusions, Wide_Wide_Character'Val (16#0344#));
Insert (Exclusions, Wide_Wide_Character'Val (16#0F73#));
Insert (Exclusions, Wide_Wide_Character'Val (16#0F75#));
Insert (Exclusions, Wide_Wide_Character'Val (16#0F81#));
-- count
for NFSE in Boolean loop
for K in Kind_Type loop
for B in Bit loop
Num (NFSE, K, B) := 0;
end loop;
end loop;
for N in Normalization loop
Total_Num (NFSE, N) := 0;
end loop;
end loop;
declare
I : Decomposite_Maps.Cursor := First (NFD);
begin
while Has_Element (I) loop
declare
NFSE : Boolean := NFS_Exclusion (Key (I));
B : Bit := Bit'Max (Get_Bit (Key (I)), Get_Bit (Element (I)));
K : Kind_Type;
begin
if Contains (Exclusions, Key (I)) then
K := Excluded;
elsif Length (Element (I)) > 1 then
K := Decomposition;
Total_Num (NFSE, C) := Total_Num (NFSE, C) + 1;
else
K := Singleton;
end if;
Num (NFSE, K, B) := Num (NFSE, K, B) + 1;
Total_Num (NFSE, D) := Total_Num (NFSE, D) + 1;
end;
I := Next (I);
end loop;
end;
-- output the Ada spec
case Output is
when Reversible =>
Put_Line ("pragma License (Unrestricted);");
Put_Line ("-- implementation unit,");
Put_Line ("-- translated from UnicodeData.txt (6), CompositionExclusions.txt");
Put_Line ("package Ada.UCD.Normalization is");
Put_Line (" pragma Pure;");
New_Line;
Put_Line (" -- excluding U+2000..U+2FFF, U+F900..U+FAFF, and U+2F800..U+2FAFF");
New_Line;
Put (" NFD_Total : constant := ");
Put (Total_Num (False, D), Width => 1);
Put (";");
New_Line;
Put (" NFC_Total : constant := ");
Put (Total_Num (False, C), Width => 1);
Put (";");
New_Line;
New_Line;
when Unreversible =>
Put_Line ("pragma License (Unrestricted);");
Put_Line ("-- implementation unit,");
Put_Line ("-- translated from UnicodeData.txt (6), CompositionExclusions.txt");
Put_Line ("package Ada.UCD.Normalization.Unreversible is");
Put_Line (" pragma Pure;");
New_Line;
Put_Line (" -- including U+2000..U+2FFF, U+F900..U+FAFF, and U+2F800..U+2FAFF");
New_Line;
Put (" NFD_Unreversible_Total : constant := ");
Put (Total_Num (True, D), Width => 1);
Put (";");
New_Line;
Put (" NFC_Unreversible_Total : constant := ");
Put (Total_Num (True, C), Width => 1);
Put (";");
New_Line;
New_Line;
end case;
declare
NFSE : constant Boolean := Output = Unreversible;
begin
for K in Kind_Type loop
for B in Bit loop
if Num (NFSE, K, B) /= 0 then
Put (" NFD_");
if NFSE then
Put ("Unreversible_");
end if;
case K is
when Decomposition => Put ("D_");
when Excluded => Put ("E_");
when Singleton => Put ("S_");
end case;
Put ("Table_");
case B is
when In_16 => Put ("XXXX");
when In_32 => Put ("XXXXXXXX");
end case;
Put (" : constant Map_");
case B is
when In_16 => Put ("16");
when In_32 => Put ("32");
end case;
Put ("x");
case K is
when Decomposition | Excluded => Put ("2");
when Singleton => Put ("1");
end case;
Put ("_Type (1 .. ");
Put (Num (NFSE, K, B), Width => 1);
Put (") := (");
New_Line;
declare
I : Decomposite_Maps.Cursor := First (NFD);
Second : Boolean := False;
begin
while Has_Element (I) loop
declare
Item_NFSE : Boolean := NFS_Exclusion (Key (I));
Item_B : Bit := Bit'Max (Get_Bit (Key (I)), Get_Bit (Element (I)));
Item_K : Kind_Type;
begin
if Contains (Exclusions, Key (I)) then
Item_K := Excluded;
elsif Length (Element (I)) > 1 then
Item_K := Decomposition;
else
Item_K := Singleton;
end if;
if Item_NFSE = NFSE
and then Item_K = K
and then Item_B = B
then
if Second then
Put (",");
New_Line;
end if;
Put (" ");
if Num (NFSE, K, B) = 1 then
Put ("1 => ");
end if;
Put ("(");
Put_16 (Wide_Wide_Character'Pos (Key (I)));
Put (", ");
if K = Singleton then
Put_16 (
Wide_Wide_Character'Pos (
Element (Element (I), 1)));
else
declare
E : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String
renames Element (I);
begin
Put ("(");
for EI in 1 .. Length (E) loop
if EI > 1 then
Put (", ");
end if;
Put_16 (
Wide_Wide_Character'Pos (
Element (E, EI)));
end loop;
Put (")");
end;
end if;
Put (")");
Second := True;
end if;
end;
I := Next (I);
end loop;
Put (");");
New_Line;
end;
New_Line;
end if;
end loop;
end loop;
end;
case Output is
when Reversible =>
Put_Line ("end Ada.UCD.Normalization;");
when Unreversible =>
Put_Line ("end Ada.UCD.Normalization.Unreversible;");
end case;
end ucd_normalization;
|
charlie5/cBound | Ada | 1,348 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_query_pointer_cookie_t is
-- Item
--
type Item is record
sequence : aliased Interfaces.C.unsigned;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_query_pointer_cookie_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_pointer_cookie_t.Item,
Element_Array => xcb.xcb_query_pointer_cookie_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_query_pointer_cookie_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_pointer_cookie_t.Pointer,
Element_Array => xcb.xcb_query_pointer_cookie_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_query_pointer_cookie_t;
|
optikos/oasis | Ada | 1,948 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
package Program.Elements.Loop_Parameter_Specifications is
pragma Pure (Program.Elements.Loop_Parameter_Specifications);
type Loop_Parameter_Specification is
limited interface and Program.Elements.Declarations.Declaration;
type Loop_Parameter_Specification_Access is
access all Loop_Parameter_Specification'Class with Storage_Size => 0;
not overriding function Name
(Self : Loop_Parameter_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is abstract;
not overriding function Definition
(Self : Loop_Parameter_Specification)
return not null Program.Elements.Discrete_Ranges.Discrete_Range_Access
is abstract;
not overriding function Has_Reverse
(Self : Loop_Parameter_Specification)
return Boolean is abstract;
type Loop_Parameter_Specification_Text is limited interface;
type Loop_Parameter_Specification_Text_Access is
access all Loop_Parameter_Specification_Text'Class with Storage_Size => 0;
not overriding function To_Loop_Parameter_Specification_Text
(Self : aliased in out Loop_Parameter_Specification)
return Loop_Parameter_Specification_Text_Access is abstract;
not overriding function In_Token
(Self : Loop_Parameter_Specification_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Reverse_Token
(Self : Loop_Parameter_Specification_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
end Program.Elements.Loop_Parameter_Specifications;
|
AdaCore/training_material | Ada | 1,571 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Numbers; use Numbers;
with Types; use Types;
with Strings; use Strings;
package body Parser is
type Element_T is record
Line_Number : Integer;
Category : Category_T;
Description : String_T;
Quantity : Quantity_T;
Cost : Cost_T;
end record;
Database : array (1 .. 10) of Element_T;
Database_Count : Integer := 0;
procedure Load (Filename : String) is
File : File_Type;
begin
Open (File, In_File, Filename);
while not End_Of_File (File)
loop
declare
Pieces : Strings_T := Split (Get_Line (File));
Element : Element_T;
begin
Element.Line_Number := Integer (Line (File) - 1);
Element.Category := Convert (Pieces (1).all);
Element.Description := Pieces (2);
Element.Quantity := Convert (Pieces (3).all);
Element.Cost := Convert (Pieces (4).all);
Database_Count := Database_Count + 1;
Database (Database_Count) := Element;
end;
end loop;
end Load;
procedure Print is
begin
for Element of Database (1 .. Database_Count)
loop
Put (Element.Line_Number'image & ": ");
Put (Element.Description.all & " (");
Put (Convert (Element.Category) & ") ");
Put (Convert (Element.Quantity) & " at $");
Put_Line (Convert (Element.Cost));
end loop;
end Print;
end Parser;
|
stcarrez/ada-keystore | Ada | 2,949 | adb | -----------------------------------------------------------------------
-- akt-commands-genkey -- Generate simple keys to lock/unkock wallets
-- 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.
-----------------------------------------------------------------------
with Ada.Directories;
with GNAT.Command_Line;
with AKT.Configs;
with Keystore.Passwords.Files;
package body AKT.Commands.Genkey is
-- ------------------------------
-- Generate or list some simple keys.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
Dir : constant String := AKT.Configs.Get_Directory_Key_Path;
begin
if Dir'Length = 0 then
AKT.Commands.Log.Error (-("no valid directory keys can be created"));
raise Error;
end if;
for I in 1 .. Args.Get_Count loop
declare
Key_Name : constant String := Args.Get_Argument (I);
Path : constant String := Get_Named_Key_Path (Key_Name);
begin
if Ada.Directories.Exists (Path) then
if Command.Remove then
Ada.Directories.Delete_File (Path);
else
AKT.Commands.Log.Error (-("key '{0}' is already defined"), Key_Name);
raise Error;
end if;
elsif not Command.Remove then
Context.Key_Provider := Keystore.Passwords.Files.Generate (Path);
end if;
end;
end loop;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Drivers.Command_Type (Command).Setup (Config, Context);
GC.Define_Switch (Config, Command.Remove'Access,
"-r", "--remove", -("Remove the named key"));
end Setup;
end AKT.Commands.Genkey;
|
BrickBot/Bound-T-H8-300 | Ada | 9,451 | ads | -- Assertions.Opt (decl)
--
-- Command-line options for accessing and using assertions that are
-- provided by the user and describe the behaviour of the target
-- program under analysis.
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.15 $
-- $Date: 2015/10/24 19:36:46 $
--
-- $Log: assertions-opt.ads,v $
-- Revision 1.15 2015/10/24 19:36:46 niklas
-- Moved to free licence.
--
-- Revision 1.14 2011-08-31 04:23:33 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.13 2009-12-21 14:59:28 niklas
-- BT-CH-0201: Role names with blanks. Option -warn [no_]role.
--
-- Revision 1.12 2009-12-15 09:13:28 niklas
-- BT-CH-0193: Less alarms for assertions on absent subprograms.
--
-- Revision 1.11 2009-03-27 13:57:12 niklas
-- BT-CH-0167: Assertion context identified by source-code markers.
--
-- Revision 1.10 2009/03/21 13:09:17 niklas
-- BT-CH-0165: Option -file_match for matching asserted file-names.
--
-- Revision 1.9 2009/03/20 18:19:28 niklas
-- BT-CH-0164: Assertion context identified by source-line number.
--
-- Revision 1.8 2009/01/18 07:59:17 niklas
-- Removed unused context clause.
--
-- Revision 1.7 2008/11/03 07:58:11 niklas
-- BT-CH-0155: Ignore assertions on absent subprograms.
--
-- Revision 1.6 2007/08/03 19:11:20 niklas
-- Added option Trace_Sub_Options.
--
-- Revision 1.5 2007/01/25 21:25:12 niklas
-- BT-CH-0043.
--
-- Revision 1.4 2006/05/27 21:48:45 niklas
-- BT-CH-0020.
--
-- Revision 1.3 2005/06/12 07:20:29 niklas
-- Added procedure Take_File and package body.
--
-- Revision 1.2 2000/12/28 12:37:29 holsti
-- Trace_Map added.
--
-- Revision 1.1 2000/04/21 19:38:58 holsti
-- Renamed child Options to Opt
--
with Options.Bool;
with Options.File_Sets;
with Options.Nat;
package Assertions.Opt is
pragma Elaborate_Body;
--
-- To register the options.
Assertion_Files : aliased Options.File_Sets.Option_T;
--
-- The (names of) the assertion files, if given.
Mark_Files : aliased Options.File_Sets.Option_T;
--
-- The (names of) the mark-definition files, if given.
Warn_Absent_Subprogram_Opt :
aliased Options.Bool.Option_T (Default => False);
--
-- Whether to emit a warning for assertions on subprograms that
-- are not present in the target program.
--
Warn_Absent_Subprogram : Boolean renames Warn_Absent_Subprogram_Opt.Value;
Warn_Unused_Role_Opt : aliased Options.Bool.Option_T (Default => True);
--
-- Whether to emit a warning for instruction-role assertions that
-- have not been used (have not been retrieved from the role-map in
-- the program object).
--
Warn_Unused_Role : Boolean renames Warn_Unused_Role_Opt.Value;
Implicit_Features_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to use nested assertion statements / blocks to
-- imply features of the containing program part, useful
-- for matching the assertions on the containing part to
-- actual program parts.
--
Implicit_Features : Boolean renames Implicit_Features_Opt.Value;
Line_Fuzz_Opt : aliased Options.Nat.Option_T (Default => 1);
--
-- The allowable error, or mismatch, when identifying program
-- parts by source-line numbers or source-line markers.
-- The fuzz bounds the difference in the compared line numbers.
--
Line_Fuzz : Natural renames Line_Fuzz_Opt.Value;
package File_Matching_Valued is
new Options.Discrete_Valued (
Value_Type => File_Matching_T,
Value_Image => File_Matching_T'Image);
--
-- Options with a File_Matching_T value.
File_Matching_Opt :
aliased File_Matching_Valued.Option_T (Default => Base_Name);
--
-- How to compare actual file names to file names written in
-- assertions, for example the source-file names used in features
-- to identify target program parts.
--
File_Matching : File_Matching_T renames File_Matching_Opt.Value;
Warn_File_Matching_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to emit a warning when the matching of an actual file-name
-- to a file-name given in an assertion depends essentially on the
-- current File_Matching option (that is, different option values give
-- different result for the comparison).
--
Warn_File_Matching : Boolean renames Warn_File_Matching_Opt.Value;
package File_Casing_Valued is new Options.Discrete_Valued (
Value_Type => File_Casing_T,
Value_Image => File_Casing_T'Image);
--
-- Options with a File_Casing_T value.
File_Casing_Opt :
aliased File_Casing_Valued.Option_T (Default => Case_Sensitive);
--
-- Whether comparison of actual file names to file names written
-- in assertions is sensitive to letter case.
--
File_Casing : File_Casing_T renames File_Casing_Opt.Value;
Warn_File_Casing_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to emit a warning when the matching of an actual file-name
-- to a file-name given in an assertion depends essentially on the
-- current File_Casing option (that is, different option values give
-- different result for the comparison).
--
Warn_File_Casing : Boolean renames Warn_File_Casing_Opt.Value;
package Source_Relation_Valued is new Options.Discrete_Valued (
Value_Type => Source_Relation_T,
Value_Image => Source_Relation_T'Image);
--
-- Options with a Source_Relation_T value.
Marked_Relation_Opt :
aliased Source_Relation_Valued.Option_T (Default => On);
--
-- The positional relationship to be assumed for a source-code marker
-- and the marked program part, when the part is identified as being
-- 'marked' by this marker.
--
-- This assumed relationship can be overridden in an assertion by
-- writing, instead of 'marked', that the part "is on/after/before"
-- the marker.
--
Marked_Relation : Source_Relation_T renames Marked_Relation_Opt.Value;
Trace_Parsing_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the process of parsing assertion files
-- into assertion sets.
--
Trace_Parsing : Boolean renames Trace_Parsing_Opt.Value;
Trace_Marks_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the process of reading and parsing mark
-- definitions from mark files.
--
Trace_Marks : Boolean renames Trace_Marks_Opt.Value;
Trace_Sub_Options_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the process of applying asserted subprogram
-- "options" to subprograms.
--
Trace_Sub_Options : Boolean renames Trace_Sub_Options_Opt.Value;
Trace_Matching_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the process of matching assertions to
-- parts of the program to be analysed.
--
Trace_Matching : Boolean renames Trace_Matching_Opt.Value;
Trace_To_Be_Mapped_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the result of selecting assertions to
-- be mapped onto a particular subprogram and its elements
-- (loops, calls).
--
Trace_To_Be_Mapped : Boolean renames Trace_To_Be_Mapped_Opt.Value;
Trace_Map_Opt : aliased Options.Bool.Option_T (Default => False);
--
-- Whether to trace the result of mapping assertions to
-- subprogram elements (loops, calls).
--
Trace_Map : Boolean renames Trace_Map_Opt.Value;
Deallocate : Boolean := True;
--
-- Whether to use Unchecked_Deallocation to release unused
-- heap memory.
end Assertions.Opt;
|
zhmu/ananas | Ada | 2,915 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . S T R I N G S --
-- --
-- B o d y --
-- --
-- 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/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body System.Strings is
----------
-- Free --
----------
procedure Free (Arg : in out String_List_Access) is
procedure Free_Array is new Ada.Unchecked_Deallocation
(Object => String_List, Name => String_List_Access);
begin
-- First free all the String_Access components if any
if Arg /= null then
for J in Arg'Range loop
Free (Arg (J));
end loop;
end if;
-- Now free the allocated array
Free_Array (Arg);
end Free;
end System.Strings;
|
AdaCore/libadalang | Ada | 397 | adb | procedure Test is
generic
package Pkg_G is
generic
procedure Iterator_G;
end Pkg_G;
generic
package Base_G is
package Pkg_I is new Pkg_G;
end Base_G;
package body Pkg_G is
procedure Iterator_G is null;
end Pkg_G;
package Base_I is new Base_G;
procedure Foo is new Base_I.Pkg_I.Iterator_G;
begin
Foo;
pragma Test_Statement;
end Test;
|
stcarrez/ada-util | Ada | 7,123 | adb | -----------------------------------------------------------------------
-- util-properties-form -- read json files into properties
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.IO.Form;
with Util.Stacks;
with Util.Log;
with Util.Beans.Objects;
package body Util.Properties.Form is
type Natural_Access is access all Natural;
package Length_Stack is new Util.Stacks (Element_Type => Natural,
Element_Type_Access => Natural_Access);
type Parser is abstract limited new Util.Serialize.IO.Reader with record
Base_Name : Ada.Strings.Unbounded.Unbounded_String;
Lengths : Length_Stack.Stack;
Separator : Ada.Strings.Unbounded.Unbounded_String;
Separator_Length : Natural;
end record;
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
overriding
procedure Start_Object (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class);
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
overriding
procedure Finish_Object (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class);
overriding
procedure Start_Array (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class);
overriding
procedure Finish_Array (Handler : in out Parser;
Name : in String;
Count : in Natural;
Logger : in out Util.Log.Logging'Class);
-- -----------------------
-- Start a new object associated with the given name. This is called when
-- the '{' is reached. The reader must be updated so that the next
-- <b>Set_Member</b> procedure will associate the name/value pair on the
-- new object.
-- -----------------------
overriding
procedure Start_Object (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Logger);
begin
if Name'Length > 0 then
Ada.Strings.Unbounded.Append (Handler.Base_Name, Name);
Ada.Strings.Unbounded.Append (Handler.Base_Name, Handler.Separator);
Length_Stack.Push (Handler.Lengths);
Length_Stack.Current (Handler.Lengths).all := Name'Length + Handler.Separator_Length;
end if;
end Start_Object;
-- -----------------------
-- Finish an object associated with the given name. The reader must be
-- updated to be associated with the previous object.
-- -----------------------
overriding
procedure Finish_Object (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
pragma Unreferenced (Logger);
Len : constant Natural := Ada.Strings.Unbounded.Length (Handler.Base_Name);
begin
if Name'Length > 0 then
Ada.Strings.Unbounded.Delete (Handler.Base_Name,
Len - Name'Length - Handler.Separator_Length + 1, Len);
end if;
end Finish_Object;
overriding
procedure Start_Array (Handler : in out Parser;
Name : in String;
Logger : in out Util.Log.Logging'Class) is
begin
Handler.Start_Object (Name, Logger);
end Start_Array;
overriding
procedure Finish_Array (Handler : in out Parser;
Name : in String;
Count : in Natural;
Logger : in out Util.Log.Logging'Class) is
begin
Parser'Class (Handler).Set_Member ("length", Util.Beans.Objects.To_Object (Count), Logger);
Handler.Finish_Object (Name, Logger);
end Finish_Array;
-- -----------------------
-- Parse the application/form content and put the flattened content in the property manager.
-- -----------------------
procedure Parse_Form (Manager : in out Util.Properties.Manager'Class;
Content : in String;
Flatten_Separator : in String := ".") is
type Local_Parser is new Parser with record
Manager : access Util.Properties.Manager'Class;
end record;
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Logger : in out Util.Log.Logging'Class;
Attribute : in Boolean := False);
-- -----------------------
-- Set the name/value pair on the current object. For each active mapping,
-- find whether a rule matches our name and execute it.
-- -----------------------
overriding
procedure Set_Member (Handler : in out Local_Parser;
Name : in String;
Value : in Util.Beans.Objects.Object;
Logger : in out Util.Log.Logging'Class;
Attribute : in Boolean := False) is
pragma Unreferenced (Logger, Attribute);
begin
Handler.Manager.Set (Ada.Strings.Unbounded.To_String (Handler.Base_Name) & Name,
Util.Beans.Objects.To_String (Value));
end Set_Member;
P : Local_Parser;
R : Util.Serialize.IO.Form.Parser;
begin
P.Separator := Ada.Strings.Unbounded.To_Unbounded_String (Flatten_Separator);
P.Separator_Length := Flatten_Separator'Length;
P.Manager := Manager'Access;
R.Parse_String (Content, P);
if R.Has_Error then
raise Util.Serialize.IO.Parse_Error;
end if;
end Parse_Form;
end Util.Properties.Form;
|
reznikmm/matreshka | Ada | 6,283 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.DOM_Nodes.Documents is
pragma Preelaborate;
-----------------------
-- Abstract_Document --
-----------------------
type Abstract_Document is
abstract new Matreshka.DOM_Nodes.Abstract_Node with record
First_Detached : Matreshka.DOM_Nodes.Node_Access;
Last_Detached : Matreshka.DOM_Nodes.Node_Access;
-- List of nodes which is not direct or indirect children of root node
-- of document or document's document type node. All created nodes are
-- added to this list.
end record;
not overriding function Create_Attribute
(Self : not null access Abstract_Document;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null Matreshka.DOM_Nodes.Attribute_Access;
not overriding function Create_Element
(Self : not null access Abstract_Document;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null Matreshka.DOM_Nodes.Element_Access;
not overriding function Create_Text
(Self : not null access Abstract_Document;
Data : League.Strings.Universal_String)
return not null Matreshka.DOM_Nodes.Text_Access;
overriding procedure Enter_Element
(Self : not null access Abstract_Document;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access Abstract_Document;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Abstract_Document;
Iterator : in out Standard.XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out Standard.XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out Standard.XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
type Document_Type is record
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
end record;
not overriding function Create
(The_Type : not null access Document_Type)
return Abstract_Document is abstract;
-- Dispatching constructor to be used to create and initialize document
-- node.
-------------------
-- Document_Node --
-------------------
type Document_Node is
new Matreshka.DOM_Nodes.Documents.Abstract_Document with null record;
overriding function Create
(The_Type : not null access Document_Type) return Document_Node;
end Matreshka.DOM_Nodes.Documents;
|
reznikmm/matreshka | Ada | 6,780 | 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.Applet_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Applet_Element_Node is
begin
return Self : Draw_Applet_Element_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Draw_Applet_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Draw_Applet
(ODF.DOM.Draw_Applet_Elements.ODF_Draw_Applet_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Applet_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Applet_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Draw_Applet_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Draw_Applet
(ODF.DOM.Draw_Applet_Elements.ODF_Draw_Applet_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Draw_Applet_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Draw_Applet
(Visitor,
ODF.DOM.Draw_Applet_Elements.ODF_Draw_Applet_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Applet_Element,
Draw_Applet_Element_Node'Tag);
end Matreshka.ODF_Draw.Applet_Elements;
|
reznikmm/matreshka | Ada | 4,608 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Condition_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Condition_Attribute_Node is
begin
return Self : Table_Condition_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Condition_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Condition_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Condition_Attribute,
Table_Condition_Attribute_Node'Tag);
end Matreshka.ODF_Table.Condition_Attributes;
|
faelys/natools | Ada | 3,272 | 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. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
private with Ada.Finalization;
generic
type Time is private;
with function Now return Time;
with function "-" (Left, Right : Time) return Duration;
package Natools.Time_Statistics.Generic_Timers is
type Manual_Timer (Backend : access Accumulator'Class)
is tagged limited private;
-- Timer that must be manually started and stopped
not overriding function Is_Running (Timer : Manual_Timer) return Boolean;
-- Return whether Timer is currently running
not overriding procedure Start (Timer : in out Manual_Timer)
with Pre => not Is_Running (Timer) or else raise Constraint_Error;
-- Start measuring time
not overriding procedure Stop (Timer : in out Manual_Timer)
with Pre => Is_Running (Timer) or else raise Constraint_Error;
-- Stop Timer and add the measured duration to the backend
not overriding procedure Cancel (Timer : in out Manual_Timer);
-- If Timer is running, stop it without reporting to backend
type Auto_Timer (Backend : access Accumulator'Class)
is tagged limited private;
-- Measure time between object creation and finalization
not overriding procedure Cancel (Timer : in out Auto_Timer);
-- Prevent the Timer from reporting measured time on finalization
private
type Manual_Timer (Backend : access Accumulator'Class)
is tagged limited record
Start_Time : Time;
Running : Boolean := False;
end record;
not overriding function Is_Running (Timer : Manual_Timer) return Boolean
is (Timer.Running);
type Auto_Timer (Backend : access Accumulator'Class)
is new Ada.Finalization.Limited_Controlled
with record
Start_Time : Time;
Reported : Boolean := False;
end record;
overriding procedure Initialize (Object : in out Auto_Timer);
overriding procedure Finalize (Object : in out Auto_Timer);
end Natools.Time_Statistics.Generic_Timers;
|
reznikmm/matreshka | Ada | 4,609 | 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.Position_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Number_Position_Attribute_Node is
begin
return Self : Number_Position_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_Position_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Position_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Number_URI,
Matreshka.ODF_String_Constants.Position_Attribute,
Number_Position_Attribute_Node'Tag);
end Matreshka.ODF_Number.Position_Attributes;
|
luisfelipe3d/base-cod-java | Ada | 318 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure primitivos is
name: String(1 .. 10);
begin
Put_Line("Digite seu nome: ");
Get(name);
Put_line(name);
end primitivos;
|
hbarrientosg/cs-mp | Ada | 1,313 | adb | separate(Practica4)
function Tratar_Fichero(Nom_F_Ent: in Unbounded_String;
Nom_F_Let: in Unbounded_String;
Nom_F_Num: in Unbounded_String) return Natural is
Fich1,fichL,fichN:file_type;
letra,Numero:Unbounded_string;
linea:string(1..125);
nume:natural;
begin
open(fich1,in_file,name=>to_string(Nom_F_Ent));
--Abro el fichero de que se van ha leer las lineas.
create(fichL,out_file,to_string(Nom_f_let));
--creo el fichero en modo escritura , de letras.
create(fichN,out_file,to_string(Nom_f_num));
--creo el fichero en modo lectura de numeros.
loop
letra:=null_unbounded_string;
numero:=Null_unbounded_string;--vacio las ristras
get_line(fich1,linea,nume);--leo una linea en el fichero
separar(to_unbounded_string(linea(1..nume)),Letra,Numero);
--los separo con la funcion separar
put_line(fichL,to_string(Letra));--Y guardo las lineas en sus ficheros
--correspondientes
put_line(fichN,to_string(Numero));
exit when end_of_file(fich1);
end loop;
close(fich1);
close(fichL);
close(fichN);
return 0;
exception
when Name_error =>
--salta cuando el nombre del fichero que se va a leer no existe
return 1;
when Mode_error =>
-- si no puede crear los ficheros
return 2;
when others =>
-- en otros casos retorna 3
return 3;
end Tratar_fichero;
|
BrickBot/Bound-T-H8-300 | Ada | 69,346 | adb | -- Output (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.39 $
-- $Date: 2015/10/24 20:05:50 $
--
-- $Log: output.adb,v $
-- Revision 1.39 2015/10/24 20:05:50 niklas
-- Moved to free licence.
--
-- Revision 1.38 2013-11-27 11:44:42 niklas
-- Added Locus (Code_Address_T) return Statement_Locus_T.
--
-- Revision 1.37 2011-08-31 04:23:34 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.36 2009/05/21 08:08:27 niklas
-- BT-CH-0175: Limits on the number of Warnings, Errors, Faults.
--
-- Revision 1.35 2009/03/24 07:48:35 niklas
-- BT-CH-0166: String_Pool.Item_T for source-file and marker names.
--
-- Revision 1.34 2009/03/21 13:09:17 niklas
-- BT-CH-0165: Option -file_match for matching asserted file-names.
--
-- Revision 1.33 2009/03/19 13:52:02 niklas
-- Extended the "&" operators for Statement_Range_T and Locus_T to
-- add surrounding lines for the Right operand (under -lines around).
--
-- Revision 1.32 2008/11/09 21:43:03 niklas
-- BT-CH-0158: Output.Image (Time_T) replaces Programs.Execution.Image.
--
-- Revision 1.31 2008/02/15 20:27:43 niklas
-- BT-CH-0110: Better "&" for call-paths in Output loci.
--
-- Revision 1.30 2007/04/30 06:39:55 niklas
-- Made No_Mark public and the default initial value.
--
-- Revision 1.29 2006/06/16 14:51:13 niklas
-- Published the function Formed_Source with a Default value
-- for the Form parameter.
--
-- Revision 1.28 2006/05/17 20:07:13 niklas
-- Added the function Source_File_Item.
--
-- Revision 1.27 2006/02/28 08:47:15 niklas
-- Extended the option -source (Output.Opt.Source_File_Form) to
-- apply also to the name of the target program executable file.
-- Thus, the function Program_File (Locus) now takes also a
-- Form parameter and applies Formed_Source to the file-name.
--
-- Revision 1.26 2005/10/26 14:11:16 niklas
-- Using Basic_Output.
--
-- Revision 1.25 2005/10/26 12:19:46 niklas
-- Simplified EFS checks in procedure Line.
--
-- Revision 1.24 2005/10/09 08:10:22 niklas
-- BT-CH-0013.
--
-- Revision 1.23 2005/08/24 10:06:50 niklas
-- Added an "Address" parameter (Boolean option) to the Image
-- functions for Statement_Locus_T, Statement_Range_T and
-- Source_Interval_T. This lets clients force the display of
-- code addresses in warnings and errors that need it, as if
-- the option -address were in effect.
--
-- Revision 1.22 2005/08/08 17:42:04 niklas
-- Added functions First and Last to get the line-number range
-- directly from a Statement Range.
--
-- Revision 1.21 2005/06/29 09:33:45 niklas
-- Added the Heading procedure.
--
-- Revision 1.20 2005/06/28 07:02:21 niklas
-- Added function Code_Image.
--
-- Revision 1.19 2004/04/25 09:29:45 niklas
-- First Tidorum version.
-- Multiple source files per location ("See_Also" lines).
-- Options for source-file name form (full path or basename).
-- Inexact source-line matching (surrounding lines).
-- Operations for tracing output ("Trace" lines).
-- Additional control over "Result" and "Unknown" output.
-- Caching of current default locus computed from locus nest.
--
-- Revision 1.18 2003/02/17 16:17:08 holsti
-- Added option Show_Code_Addresses (-address) to include the code address
-- in all output of code loci. Earlier, this was the default; now the
-- default is to suppress the code addresses and show only source-line
-- numbers if available.
--
-- Revision 1.17 2001/12/10 14:43:11 holsti
-- Locus-nest marks have a "Defined" attribute to avoid accessing
-- undefined (uninitialized) marks.
--
-- Revision 1.16 2001/05/27 10:50:33 holsti
-- "Note" output is conditional on Opt.Show_Notes.
--
-- Revision 1.15 2001/04/06 11:08:07 ville
-- NC_054 fixed
--
-- Revision 1.14 2001/04/04 11:02:14 ville
-- Fixed invalid Code_Address_T uses
--
-- Revision 1.13 2001/03/21 20:12:43 holsti
-- Program locations given by Locus_T.
--
-- Revision 1.12 2001/03/15 20:47:37 holsti
-- Show_Notes (option -q, -quiet) added.
--
-- Revision 1.11 2000/12/28 12:35:03 holsti
-- Image for Integer added.
--
-- Revision 1.10 2000/11/24 12:06:01 sihvo
-- Added stack height analysis.
--
-- Revision 1.9 2000/11/09 14:44:31 saarinen
-- Added function Get_Subprogram.
--
-- Revision 1.8 2000/10/26 09:30:00 saarinen
-- Added procedures Wcet, Wcet_Call, Unknown and Loop_Bound.
--
-- Revision 1.7 2000/07/02 18:44:45 holsti
-- Flush standard-output before messages.
--
-- Revision 1.6 2000/06/27 20:10:03 holsti
-- Made Fault useful...
--
-- Revision 1.5 2000/06/27 20:05:27 holsti
-- Added procedure Fault.
--
-- Revision 1.4 2000/04/24 18:36:19 holsti
-- Added Subprogram field.
--
-- Revision 1.3 2000/04/24 14:28:38 holsti
-- Symbol scopes added.
--
-- Revision 1.2 2000/04/23 21:41:16 holsti
-- Added Flow package.
--
-- Revision 1.1 2000/04/22 12:08:27 holsti
-- Output package added.
--
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;
with Output.Opt;
with Symbols.Show;
package body Output is
use Ada.Text_IO;
use type String_Pool.Item_T;
use type Symbols.Line_Number_T;
use type Symbols.Source_File_Name_T;
use type Symbols.Symbol_Table_T;
--
--- Source-file form selection
--
Path_Delimiters : Ada.Strings.Maps.Character_Set :=
Ada.Strings.Maps.To_Set ("/\");
--
-- The characters that delimit directories and file-names in
-- a path-name string.
function Formed_Source (
Full_Name : String;
Form : Source_File_Form_T := Default)
return String
is
use Ada.Strings;
use Ada.Strings.Fixed;
Real_Form : Real_Source_File_Form_T;
-- The real form after expanding Default.
Last_Name : Natural;
-- The index, in Full_Name, of the last valid file-name character,
-- that is a character other than a path delimiter.
Last_Delimiter : Natural;
-- The index, in Full_Name, of the last path delimiter before
-- the Last_Name character.
First_Name : Positive;
-- The index, in Full_Name, of the first valid file-name character
-- after Last_Delimiter.
begin
if Form = Default then
Real_Form := Opt.Source_File_Form;
else
Real_Form := Form;
end if;
case Real_Form is
when Full =>
return Full_Name;
when Base =>
Last_Name := Index (
Source => Full_Name,
Set => Path_Delimiters,
Test => Outside,
Going => Backward);
Last_Delimiter := Index (
Source => Full_Name(Full_Name'First .. Last_Name),
Set => Path_Delimiters,
Test => Inside,
Going => Backward);
if Last_Delimiter = 0 then
-- There are no path delimiters before Last_Name.
First_Name := Full_Name'First;
else
-- There are some delimiters before Last_Name.
First_Name := Last_Delimiter + 1;
end if;
return Full_Name (First_Name .. Last_Name);
end case;
end Formed_Source;
--
--- Output operations
--
procedure Line (
Channel : in Ada.Text_IO.File_Type;
Key : in String;
Locus : in Locus_T;
Data : in String);
procedure Flush_Standard_Output
renames Basic_Output.Flush_Standard_Output;
function To_Item (S : String) return String_Pool.Item_T
--
-- Stores the given string in the String_Pool and returns the
-- corresponding Item_T value, or return Null_Item if the
-- given string is null.
--
is
begin
if S'Length = 0 then
return String_Pool.Null_Item;
else
return String_Pool.To_Item (S);
end if;
end To_Item;
function To_String (Item : String_Pool.Item_T)
return String
--
-- Returns the string identified by the Item in the string pool,
-- or returns the null string if Item = Null_Item.
--
is
begin
if Item = String_Pool.Null_Item then
return "";
else
return String_Pool.To_String (Item);
end if;
end To_String;
function No_Statements return Statement_Range_T
is
begin
return No_Statement_Range;
end No_Statements;
--
--- Diagnostics
--
procedure Show (
Item : in Statement_Locus_T;
File : in Ada.Text_IO.File_Type;
Indent : in Ada.Text_IO.Positive_Count)
--
-- Displays the statement locus on the given file.
-- Intended for diagnostics.
--
is
begin
Set_Col (File, Indent);
Put (File, "Source file : ");
if Item.Source_File = Symbols.Null_Name then
Put_Line (File, "null");
else
Put_Line (File, '"' & Symbols.Image (Item.Source_File) & '"');
end if;
Set_Col (File,Indent);
Put (File, "Line number : ");
if Item.Line.Known then
Put_Line (File, Image (Item.Line.Number));
else
Put_Line (File, "?");
end if;
Set_Col (File, Indent);
Put (File,"Code address: ");
if Item.Code.Known then
Put_Line (File, Processor.Image (Item.Code.Address));
else
Put_Line (File, "?");
end if;
end Show;
procedure Show (
Item : in Source_Interval_T;
File : in Ada.Text_IO.File_Type;
Indent : in Ada.Text_IO.Positive_Count)
--
-- Displays the source-line interval on the given file.
-- Intended for diagnostics.
--
is
begin
Set_Col (File, Indent);
Put (File, "Source file : ");
if Item.File = Symbols.Null_Name then
Put_Line (File, "null");
else
Put_Line (File, '"' & Symbols.Image (Item.File) & '"');
end if;
Set_Col (File, Indent);
Put (File, "First line : ");
if Item.First.Known then
Put_Line (File, Image (Item.First.Number));
else
Put_Line (File, "?");
end if;
Set_Col (File, Indent);
Put (File, "Last line : ");
if Item.Last.Known then
Put_Line (File, Image (Item.Last.Number));
else
Put_Line (File, "?");
end if;
end Show;
procedure Show (
Item : in Code_Interval_T;
File : in Ada.Text_IO.File_Type;
Indent : in Ada.Text_IO.Positive_Count)
--
-- Displays the code-address interval on the given file.
-- Intended for diagnostics.
--
is
begin
Set_Col (File, Indent);
Put (File, "First code : ");
if Item.First.Known then
Put_Line (File, Processor.Image (Item.First.Address));
else
Put_Line (File, "?");
end if;
Set_Col (File, Indent);
Put (File, "Last code : ");
if Item.Last.Known then
Put_Line (File, Processor.Image (Item.Last.Address));
else
Put_Line (File, "?");
end if;
end Show;
procedure Show (
Item : in Statement_Range_T;
File : in Ada.Text_IO.File_Type)
--
-- Displays the statement range on the given file.
-- Intended for diagnostics.
--
is
begin
Put_Line (File,
"Statement Range with"
& Natural'Image (Item.Sources)
& " source intervals:");
for S in 1 .. Item.Sources loop
Put_Line (File, " #" & Natural'Image (S) & " :");
Show (Item.Source(S), File, 6);
end loop;
Show (Item.Code, File, 3);
end Show;
procedure Show (
Item : in Locus_T;
File : in Ada.Text_IO.File_Type)
--
-- Displays the locus on the given file.
-- Intended for diagnostics.
--
is
begin
Put_Line (File, "Locus:");
Put_Line (File, " Program : " & To_String (Item.Program_File));
Put_Line (File, " Source : " & Symbols.Image (Item.Source_File));
Put_Line (File, " Call Path: " & To_String (Item.Call_Path));
Show (Item.Statements, File);
end Show;
--
--- Querying statement loci attributes
--
function Source_File (
Item : Statement_Locus_T;
Form : Source_File_Form_T := Default)
return String
is
begin
return Formed_Source (Symbols.Image (Item.Source_File), Form);
end Source_File;
function Line_Number (Item : Statement_Locus_T)
return Line_Number_T
is
begin
if Item.Line.Known then
return Item.Line.Number;
else
return No_Line_Number;
end if;
end Line_Number;
function Code_Address (Item : Statement_Locus_T)
return Processor.Code_Address_T
is
begin
if Item.Code.Known then
return Item.Code.Address;
else
raise Program_Error;
end if;
end Code_Address;
function Number_Of_Sources (Item : Statement_Range_T)
return Natural
is
begin
return Item.Sources;
end Number_Of_Sources;
procedure Wrong_Source (
Location : in String;
Source : in Source_Ordinal_T;
Sources : in Natural)
--
-- Reports a fault in a Source ordinal parameter, which is
-- larger than the number of Sources in the statement range.
--
is
begin
-- This is a Fault, but we cannot call the Fault
-- output operation because it could lead to a recursive
-- cycle.
Line (
Channel => Standard_Error,
Key => "Fault",
Locus => No_Locus,
Data =>
Location
& Field_Separator
& "Source ordinal out of range"
& Field_Separator
& Image (Source)
& Field_Separator
& Image (Sources));
end Wrong_Source;
function Source_File (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source;
Form : Source_File_Form_T := Default)
return String
is
begin
if Source <= Item.Sources then
return Formed_Source (Symbols.Image (Item.Source(Source).File), Form);
else
Wrong_Source (
Location => "Output.Source_File",
Source => Source,
Sources => Item.Sources);
return "";
end if;
end Source_File;
function Source_File (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source)
return Symbols.Source_File_Name_T
is
begin
if Source <= Item.Sources then
return Item.Source(Source).File;
else
Wrong_Source (
Location => "Output.Source_File_Item",
Source => Source,
Sources => Item.Sources);
return Symbols.Null_Name;
end if;
end Source_File;
function First (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source)
return Statement_Locus_T
is
begin
if Source <= Item.Sources then
return (
Source_File => Item.Source(Source).File,
Line => Item.Source(Source).First,
Code => Item.Code.First,
Symbol_Table => Item.Symbol_Table);
else
Wrong_Source (
Location => "Output.First",
Source => Source,
Sources => Item.Sources);
return No_Statement;
end if;
end First;
function Last (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source)
return Statement_Locus_T
is
begin
if Source <= Item.Sources then
return (
Source_File => Item.Source(Source).File,
Line => Item.Source(Source).Last,
Code => Item.Code.Last,
Symbol_Table => Item.Symbol_Table);
else
Wrong_Source (
Location => "Output.Last",
Source => Source,
Sources => Item.Sources);
return No_Statement;
end if;
end Last;
function First (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source)
return Line_Number_T
is
begin
return Line_Number (First (Item, Source));
end First;
function Last (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source)
return Line_Number_T
is
begin
return Line_Number (Last (Item, Source));
end Last;
--
--- Constructing statement loci and ranges
--
function Locus (
Source_File : String := "";
Line_Number : Line_Number_T := No_Line_Number;
Code_Address : Processor.Code_Address_T;
Symbol_Table : Symbols.Symbol_Table_T )
return Statement_Locus_T
is
Statement : Statement_Locus_T :=
Locus (Source_File, Line_Number);
--
-- The result to be, initialised with source-file
-- and line-number, unknown code-address, no symbol-table.
begin
Statement.Code := (
Known => True,
Address => Code_Address);
Statement.Symbol_Table := Symbol_Table;
return Statement;
end Locus;
function Locus (
Source_File : String := "";
Line_Number : Line_Number_T)
return Statement_Locus_T
is
Statement : Statement_Locus_T;
-- The result to be.
begin
Statement.Source_File := Symbols.To_Source_File_Name (Source_File);
if Line_Number = No_Line_Number then
Statement.Line := (Known => False);
else
Statement.Line := (
Known => True,
Number => Line_Number);
end if;
Statement.Code := (Known => False);
Statement.Symbol_Table := Symbols.No_Symbol_Table;
return Statement;
end Locus;
function Locus (Code_Address : Processor.Code_Address_T)
return Statement_Locus_T
is
begin
return (
Source_File => Symbols.Null_Name,
Line => (Known => False),
Code => (Known => True, Address => Code_Address),
Symbol_Table => Symbols.No_Symbol_Table);
end Locus;
function Min (Left, Right : Possible_Line_Number_T)
return Possible_Line_Number_T
--
-- The smaller line number, ignoring unknown values.
--
is
begin
if not Left.Known then return Right;
elsif not Right.Known then return Left;
else
return (
Known => True,
Number => Line_Number_T'Min (Left.Number, Right.Number));
end if;
end Min;
function Max (Left, Right : Possible_Line_Number_T)
return Possible_Line_Number_T
--
-- The larger line number, ignoring unknown values.
--
is
begin
if not Left.Known then return Right;
elsif not Right.Known then return Left;
else
return (
Known => True,
Number => Line_Number_T'Max (Left.Number, Right.Number));
end if;
end Max;
function Min (Left, Right : Possible_Code_Address_T)
return Possible_Code_Address_T
--
-- The smaller code address, ignoring unknown values.
--
is
use type Processor.Code_Address_T;
Smaller : Processor.Code_Address_T;
-- The smaller address, when both known.
begin
if not Left.Known then return Right;
elsif not Right.Known then return Left;
else
-- Both known.
if Left.Address < Right.Address then
Smaller := Left.Address;
elsif Right.Address < Left.Address then
Smaller := Right.Address;
else
Smaller := Left.Address;
end if;
return (
Known => True,
Address => Smaller);
end if;
end Min;
function Max (Left, Right : Possible_Code_Address_T)
return Possible_Code_Address_T
--
-- The larger code address, ignoring unknown values.
--
is
use type Processor.Code_Address_T;
Larger : Processor.Code_Address_T;
-- The larger address, when both known.
begin
if not Left.Known then return Right;
elsif not Right.Known then return Left;
else
-- Both known.
if Left.Address < Right.Address then
Larger := Right.Address;
elsif Right.Address < Left.Address then
Larger := Left.Address;
else
Larger := Left.Address;
end if;
return (
Known => True,
Address => Larger);
end if;
end Max;
function Same_Source (
Left, Right : in Statement_Locus_T;
Location : in String)
return Symbols.Source_File_Name_T
--
-- Check that the two statements are in the same source-code
-- file (if the file is known in both).
-- Return the common source-code file-name.
--
is
begin
if Left.Source_File = Symbols.Null_Name
or Left.Source_File = Right.Source_File then
return Right.Source_File;
elsif Right.Source_File = Symbols.Null_Name then
return Left.Source_File;
else
-- This is a Fault, but we cannot call the Fault
-- output operation because it could lead to a recursive
-- cycle.
Line (
Channel => Standard_Error,
Key => "Fault",
Locus => No_Locus,
Data =>
Location
& Field_Separator
& "Conflicting source-files"
& Field_Separator
& Symbols.Image (Left.Source_File)
& Field_Separator
& Symbols.Image (Right.Source_File));
return Symbols.Null_Name;
-- On the safe side, we don't know...
end if;
end Same_Source;
function Same_Symbols (
Left, Right : in Symbols.Symbol_Table_T;
Location : in String)
return Symbols.Symbol_Table_T
--
-- Check that the two symbol-tables are the same, or one or both
-- are null.
-- Return the common symbol-table.
--
is
use Symbols;
begin
if Left = No_Symbol_Table
or Left = Right then
return Right;
elsif Right = No_Symbol_Table then
return Left;
else
-- This is a Fault, but we cannot call the Fault
-- output operation because it could lead to a recursive
-- cycle.
Line (
Channel => Standard_Error,
Key => "Fault",
Locus => No_Locus,
Data =>
Location
& Field_Separator
& "Conflicting symbol tables");
return No_Symbol_Table;
-- On the safe side, we don't know...
end if;
end Same_Symbols;
function Rainge (
First : Statement_Locus_T;
Last : Statement_Locus_T)
return Statement_Range_T
is
Source : Symbols.Source_File_Name_T;
-- The common source-file name.
Table : Symbols.Symbol_Table_T;
-- The common symbol-table.
Autograph : constant String := "Output.Rainge";
Result : Statement_Range_T;
begin
Source := Same_Source (First, Last, Autograph);
Table := Same_Symbols (
First.Symbol_Table,
Last .Symbol_Table,
Autograph);
if Source = Symbols.Null_Name then
-- No source-line/source-file info.
Result.Sources := 0;
else
-- Some source-line/source-file info.
Result.Sources := 1;
Result.Source(First_Source) := (
File => Source,
First => Min (First.Line, Last.Line),
Last => Max (First.Line, Last.Line) );
end if;
Result.Code := (
First => Min (First.Code, Last.Code),
Last => Max (First.Code, Last.Code));
Result.Symbol_Table := Table;
return Result;
end Rainge;
function "+" (Item : Statement_Locus_T)
return Statement_Range_T
is
Result : Statement_Range_T;
begin
if Item.Source_File = Symbols.Null_Name then
-- No source-line/source-file info.
Result.Sources := 0;
else
-- Some source-line information given.
Result.Sources := 1;
Result.Source(First_Source) := (
File => Item.Source_File,
First => Item.Line,
Last => Item.Line);
end if;
Result.Code := (
First => Item.Code,
Last => Item.Code);
Result.Symbol_Table := Item.Symbol_Table;
return Result;
end "+";
function Same_Source (Left, Right : Source_Interval_T)
return Boolean
--
-- Whether the two source intervals lie in the same source-file.
--
is
begin
return Left.File = Right.File;
end Same_Source;
procedure Check_Same_File (Left, Right : Source_Interval_T)
--
-- Checks that the two source intervals come from the same source file.
--
is
begin
if not Same_Source (Left, Right) then
Line (
Channel => Standard_Error,
Key => "Fault",
Locus => No_Locus,
Data =>
"Output.Check_Same_File"
& Field_Separator
& "Source files different"
& Field_Separator
& Symbols.Image (Left.File)
& Field_Separator
& Symbols.Image (Right.File));
end if;
end Check_Same_File;
function "+" (Left, Right : Source_Interval_T)
return Source_Interval_T
--
-- Union of two non-null source-line intervals from
-- the same source-file.
--
is
begin
Check_Same_File (Left, Right);
return (
File => Left.File,
First => Min (Left.First, Right.First),
Last => Max (Left.Last , Right.Last ));
end "+";
function "+" (Left, Right : Code_Interval_T)
return Code_Interval_T
--
-- Union of two non-null code address intervals.
--
is
begin
return (
First => Min (Left.First, Right.First),
Last => Max (Left.Last , Right.Last ));
end "+";
function "+" (Left, Right : Statement_Range_T)
return Statement_Range_T
is
Result : Statement_Range_T;
-- The result (union) when Left and Right are non-null.
Shared_Source : Boolean;
-- Whether the current Right interval shares a common
-- source-file with an interval in Result.
S : Source_Ordinal_T;
-- The source ordinal in Result for the shared source.
Autograph : constant String := "Output.""+"" (Statement_Range_T)";
begin
-- Source line intervals:
if Left.Sources = 0 then
-- No source lines in Left: use Right.
Result.Sources := Right.Sources;
Result.Source := Right.Source;
elsif Right.Sources = 0 then
-- No source lines in Right: use Left.
Result.Sources := Left.Sources;
Result.Source := Left.Source;
else
-- Both Left and Right contain some source lines.
-- Unite their source intervals per source file:
Result.Sources := Left.Sources;
Result.Source := Left.Source;
for R in 1 .. Right.Sources loop
-- Process Right.Source(R).
-- Look for the same source-file in the Result:
S := Result.Source'First;
Finding_Source: loop
Shared_Source :=
Same_Source (
Result.Source(S),
Right .Source(R));
exit Finding_Source when
Shared_Source or S = Result.Sources;
S := S + 1;
end loop Finding_Source;
if Shared_Source then
-- This source-file already appears in the Result.
-- Unite the source intervals:
Result.Source(S) :=
Result.Source(S)
+ Right .Source(R);
elsif Result.Sources < Result.Source'Last then
-- This source does not appear in Result yet,
-- but there is room to add it:
Result.Sources := Result.Sources + 1;
Result.Source(Result.Sources) := Right.Source(R);
else
-- This source does not appear in Result, and
-- Result already has the maximum number of sources.
-- This is a Fault, but we cannot call the Fault
-- output operation because it could lead to a recursive
-- cycle.
Line (
Channel => Standard_Error,
Key => "Fault",
Locus => No_Locus,
Data =>
Autograph
& Field_Separator
& "Too many source files, ignoring"
& Field_Separator
& Symbols.Image (Right.Source(R).File));
Show (Left , Standard_Error);
Show (Right, Standard_Error);
end if;
end loop;
end if;
-- Code address interval:
Result.Code := Left.Code + Right.Code;
-- Symbol table:
Result.Symbol_Table :=
Same_Symbols (
Left .Symbol_Table,
Right.Symbol_Table,
Autograph);
-- And that is all:
return Result;
end "+";
function "+" (
Left : Statement_Range_T;
Right : Statement_Locus_T)
return Statement_Range_T
is
begin
return Left + (+ Right);
end "+";
procedure Intersect (
Left, Right : in Source_Interval_T;
Inter : out Source_Interval_T;
Empty : out Boolean)
--
-- The intersection (common statements) of two source-line intervals
-- from the same source file.
-- It is considered a Fault if the intersection is empty.
--
is
begin
Check_Same_File (Left, Right);
Inter := (
File => Left.File,
First => Max (Left.First, Right.First),
Last => Min (Left.Last , Right.Last ));
-- Check for empty intersection:
Empty := False;
if ( Inter.First.Known
and Inter.Last .Known)
and then
Inter.Last.Number < Inter.First.Number
then
Empty := True;
Fault (
Location => "Output.Intersection(Source_Interval_T)",
Text => "Line-range intersection is empty.");
end if;
end Intersect;
procedure Intersect (
Left, Right : in Code_Interval_T;
Inter : out Code_Interval_T;
Empty : out Boolean)
--
-- The intersection (common addresses) of two code address intervals.
-- It is considered a Fault if the intersection is empty.
--
is
use type Processor.Code_Address_T;
begin
Inter := (
First => Max (Left.First, Right.First),
Last => Min (Left.Last , Right.Last ));
-- Check for empty intersection:
Empty := False;
if ( Inter.First.Known
and Inter.Last .Known)
and then
Inter.Last.Address < Inter.Last.Address
then
Empty := True;
Fault (
Location => "Output.Intersection(Code_Interval_T)",
Text => "Code-range intersection is empty.");
end if;
end Intersect;
function "&" (Left, Right : Statement_Range_T)
return Statement_Range_T
is
Rext : Statement_Range_T := Right;
-- The Right range, perhaps extended with surrounding lines.
Inter : Statement_Range_T;
-- The intersection of the two ranges.
Shared_Source : Boolean;
-- Whether the Left source, currently inspected, is also
-- present in Right.
R : Source_Ordinal_T;
-- The source ordinal in Right for the source shared
-- with Left.
Interval : Source_Interval_T;
-- The intersection of the source-line intervals from Left
-- and Right, for the shared source file.
Empty : Boolean;
-- Whether the intersection Interval is empty.
Autograph : constant String := "Output.""&""(Statement_Range_T)";
begin
Add_Surrounding_Lines (Rext);
-- Source-line intervals:
if Left.Sources = 0 then
-- Left has no source-lines, use Right.
Inter.Sources := Rext.Sources;
Inter.Source := Rext.Source;
elsif Rext.Sources = 0 then
-- Right has no source-lines, use Left.
Inter.Sources := Left.Sources;
Inter.Source := Left.Source;
else
-- Both Left and Right contain source-line intervals.
-- Intersect their source-line ranges for each source file.
-- Keep only those source files where the intersection is
-- not empty.
Inter.Sources := 0;
for L in Left.Source'First .. Left.Sources loop
-- Inspect Left.Source(S).
-- See if this source is shared with Right:
Shared_Source := False;
R := Rext.Source'First;
Finding_Source: loop
Shared_Source := Same_Source (Rext.Source(R), Left.Source(L));
exit Finding_Source when
Shared_Source or R = Rext.Sources;
R := R + 1;
end loop Finding_Source;
if Shared_Source then
Intersect (
Left => Left.Source(L),
Right => Rext.Source(R),
Inter => Interval,
Empty => Empty);
if not Empty then
-- Include the intersection interval in the
-- resulting statement range:
Inter.Sources := Inter.Sources + 1;
Inter.Source(Inter.Sources) := Interval;
end if;
end if;
end loop;
end if;
-- Code address interval:
Intersect (
Left => Left.Code,
Right => Rext.Code,
Inter => Inter.Code,
Empty => Empty);
--
-- If the intersection was empty, the Intersect operation
-- has already emitted a Fault message.
if Empty then
Inter.Code := No_Code_Interval;
end if;
-- Symbol table:
Inter.Symbol_Table :=
Same_Symbols (
Left.Symbol_Table,
Rext.Symbol_Table,
Autograph);
-- And that is all:
return Inter;
end "&";
procedure Find_Line_Before (
Address : in Processor.Code_Address_T;
Within : in Symbols.Symbol_Table_T;
Found : out Boolean;
Line : out Statement_Locus_T)
--
-- Finds the source-line locus immediately before the given address,
-- if there is one.
--
is
Befores : constant Symbols.Connection_Set_T :=
Symbols.Line_Before (Address, Within);
-- The line before this locus, if any.
begin
Found := Befores'Length > 0;
if Found then
Line := Symbols.Show.Statement (
Line => Befores(Befores'First),
Source => Within);
else
Line := No_Statement;
end if;
end Find_Line_Before;
procedure Find_Line_After (
Address : in Processor.Code_Address_T;
Within : in Symbols.Symbol_Table_T;
Found : out Boolean;
Line : out Statement_Locus_T)
--
-- Finds the source-line locus immediately after the given address,
-- if there is one.
--
is
Afters : constant Symbols.Connection_Set_T :=
Symbols.Line_After (Address, Within);
-- The line after this locus, if any.
begin
Found := Afters'Length > 0;
if Found then
Line := Symbols.Show.Statement (
Line => Afters(Afters'First),
Source => Within);
else
Line := No_Statement;
end if;
end Find_Line_After;
procedure Add_Surrounding_Lines (To : in out Statement_Range_T)
is
Found_Before, Found_After : Boolean;
-- Whether we found a source-line connection before/after
-- the given range.
Line_Before, Line_After : Statement_Locus_T;
-- The locus of the source-line before/after the given range.
begin
if Opt.Show_Surrounding_Lines
and To.Sources = 0
and To.Code.First.Known
and To.Code.Last.Known
and To.Symbol_Table /= Symbols.No_Symbol_Table
then
-- We should and can find the surrounding source lines.
Find_Line_Before (
Address => To.Code.First.Address,
Within => To.Symbol_Table,
Found => Found_Before,
Line => Line_Before);
if Found_Before then
-- We are satisfied with this line, because it is likely
-- to be the source of the code in the given range.
To.Sources := 1;
To.Source(First_Source) := (
File => Line_Before.Source_File,
First => Line_Before.Line,
Last => (Known => False));
else
-- No line found before the given locus.
-- Try to find a line after it:
Find_Line_After (
Address => To.Code.Last.Address,
Within => To.Symbol_Table,
Found => Found_After,
Line => Line_After);
if Found_After then
-- We found a source-line after, but not before the
-- given locus. This is a little unexpected, but we
-- grin and bear it.
To.Sources := 1;
To.Source(First_Source) := (
File => Line_After.Source_File,
First => (Known => False),
Last => Line_After.Line);
end if;
end if;
end if;
end Add_Surrounding_Lines;
function Enclosed (
Prefix : String;
Data : String;
Suffix : String)
return String
--
-- The Data between the given Prefix and Suffix, or null if
-- the Data is null.
--
is
begin
if Data'Length = 0 then
return "";
else
return Prefix & Data & Suffix;
end if;
end Enclosed;
function Image (Item : Possible_Line_Number_T)
return String
--
-- Line-number or nothing.
--
is
begin
if Item.Known then
return Image (Integer (Item.Number));
else
return "";
end if;
end Image;
function Image (Item : Possible_Code_Address_T)
return String
--
-- Code-address or nothing.
--
is
begin
if Item.Known then
return Processor.Image (Item.Address);
else
return "";
end if;
end Image;
function Image (
Item : Statement_Locus_T;
Address : Boolean := False)
return String
is
Line : constant String := Image (Item.Line);
begin
if Address
or Opt.Show_Code_Addresses
or Line'Length = 0
then
return Line
& Enclosed (
Prefix => "[",
Data => Image (Item.Code),
Suffix => "]");
else
return Line;
end if;
end Image;
function Rainge (First, Last : String)
return String
--
-- A range from First to Last.
-- If First = Last, only one is shown (not a range).
-- However, if First and Last are both null, returns null.
--
is
begin
if First'Length = 0 and Last'Length = 0 then
return "";
elsif First = Last then
return First;
else
return First & '-' & Last;
end if;
end Rainge;
function Image (
Item : Source_Interval_T;
Code : Code_Interval_T;
Address : Boolean := False)
return String
--
-- Image of the source-line interval.
-- Code addresses are optionally included.
--
is
Lines : constant String :=
Rainge (
First => Image (Item.First),
Last => Image (Item.Last ));
begin
if Address
or Opt.Show_Code_Addresses
or Lines'Length = 0
then
return
Lines
& Enclosed (
Prefix => "[",
Data =>
Rainge (
First => Image (Code.First),
Last => Image (Code.Last )),
Suffix => "]");
else
return Lines;
end if;
end Image;
function Image (
Item : Statement_Range_T;
Source : Source_Ordinal_T := First_Source;
Address : Boolean := False)
return String
is
begin
return Image (Item.Source(Source), Item.Code, Address);
end Image;
function Code_Image (Item : Statement_Range_T)
return String
is
begin
return
Enclosed (
Prefix => "[",
Data =>
Rainge (
First => Image (Item.Code.First),
Last => Image (Item.Code.Last )),
Suffix => "]");
end Code_Image;
--
--- Locus construction and combination
--
function Begins_With (Prefix, Whole : String) return Boolean
--
-- Whether the Whole string begins with the Prefix.
--
is
begin
return Whole'Length >= Prefix'Length
and then Whole(Whole'First .. Whole'First + Prefix'Length - 1) = Prefix;
end Begins_With;
function Subpath (Part, Whole : String) return Boolean
--
-- Whether Part is a sub-call-path of Whole, delimited on the left
-- by a Call_Mark (if Part is not a prefix of Whole) and on the
-- right by a Call_Locus_Mark (if Part is not a suffix of Whole).
--
is
use Ada.Strings.Fixed;
First : Positive := Whole'First;
-- The next index in Whole where an instance of Part may lie.
Rest : Integer;
-- The length of Whole(First .. Whole'Last).
After : Positive;
-- The index in Whole after a possible instance of Part.
Mark : Natural;
-- The index in Whole of a Call_Mark.
begin
loop
-- There is no instance of Part in Whole(Whole'First .. First - 1),
-- and this prefix of Whole is empty, or is the Whole, or ends
-- with a Call_Mark. So Whole(First..) is the next possible
-- place for an instance of Part.
Rest := Whole'Last - First + 1;
exit when Rest < Part'Length;
-- If the rest of the Whole is shorter than the Part,
-- it cannot contain an instance of Part.
After := First + Part'Length;
if Whole(First .. After - 1) = Part
and then (Rest = Part'Length
or else Begins_With (Call_Locus_Mark, Whole(After .. Whole'Last)))
then
-- Here is a Part within the whole, preceded by nothing
-- or by a Call_Mark, and followed by nothing or by
-- a Call_Locus_Mark. Yes!
return True;
end if;
-- Find the next possible starting location: after
-- the next Call_Mark, if any.
Mark := Index (
Source => Whole(First .. Whole'Last),
Pattern => Call_Mark);
exit when Mark = 0;
-- If there are no more Call_Marks in the Whole, there
-- can be no valid instances of Part.
First := Mark + Call_Mark'Length;
end loop;
-- The loop found no valid instance of Part.
return False;
end Subpath;
function Locus (
Program_File : String := "";
Source_File : String := "";
Call_Path : String := "";
Statements : Statement_Range_T := No_Statements)
return Locus_T
is
Result : Locus_T;
-- You guessed it.
begin
-- Use the given attributes as such:
Result := Locus_T'(
Program_File => To_Item (Program_File),
Source_File => Symbols.To_Source_File_Name (Source_File),
Call_Path => To_Item (Call_Path),
Statements => Statements);
-- Use source-file from statements, unless given directly:
if Result.Source_File = Symbols.Null_Name then
for S in First_Source .. Statements.Sources loop
if Statements.Source(S).File /= Symbols.Null_Name then
Result.Source_File := Statements.Source(S).File;
exit;
end if;
end loop;
end if;
-- And that is it:
return Result;
end Locus;
type Order_T is (Less, Equal, Greater, Unordered);
--
-- Ordering relationship between two Possible_Line_Number_T
-- or two Possible_Code_Address_T.
function Order (Left, Right : Possible_Line_Number_T)
return Order_T
--
-- Compare the two possible source lines numbers for ordering.
--
is
begin
if not (Left.Known and Right.Known) then
return Unordered;
elsif Left.Number < Right.Number then
return Less;
elsif Left.Number > Right.Number then
return Greater;
else
return Equal;
end if;
end Order;
function Order (Left, Right : Possible_Code_Address_T)
return Order_T
--
-- Compare the two possible code addresses for ordering.
--
is
use type Processor.Code_Address_T;
begin
if not (Left.Known and Right.Known) then
return Unordered;
elsif Left.Address < Right.Address then
return Less;
elsif Right.Address < Left.Address then
return Greater;
else
return Equal;
end if;
end Order;
function "<=" (Part, Whole : Source_Interval_T) return Boolean
--
-- Whether Part is a subinterval of Whole.
--
is
First : constant Order_T := Order (Part.First, Whole.First);
Last : constant Order_T := Order (Part.Last , Whole.Last );
-- Ordering of First and Last ends.
begin
return (First = Equal or First = Greater)
and (Last = Equal or Last = Less );
end "<=";
function "<=" (Part, Whole : Code_Interval_T) return Boolean
--
-- Whether Part is a subinterval of Whole.
--
is
First : constant Order_T := Order (Part.First, Whole.First);
Last : constant Order_T := Order (Part.Last , Whole.Last );
-- Ordering of First and Last ends.
begin
return (First = Equal or First = Greater)
and (Last = Equal or Last = Less );
end "<=";
function "<=" (Part, Whole : Source_Interval_List_T) return Boolean
--
-- Whether Part is a subrange of Whole in the sense that every
-- source-line interval in Part is a subinterval of an interval
-- in Whole from the same source.
--
is
Subrange : Boolean := True;
-- Whether Part is a subrange of Whole.
-- So far we have seen no evidence to the contrary.
P : Source_Ordinal_T;
-- The ordinal of an source-file in Part.
Shared_Source : Boolean;
-- Whether the current Part interval shares the source-file
-- with a Whole interval.
W : Source_Ordinal_T;
-- The ordinal of the Whole source for the shared source-file.
begin
P := Part'First;
Scanning_Part: loop
W := Whole'First;
Finding_Whole : loop
Shared_Source := Same_Source (Part(P), Whole(W));
exit Finding_Whole when
Shared_Source or W = Whole'Last;
W := W + 1;
end loop Finding_Whole;
Subrange :=
Shared_Source
and then Part(P) <= Whole(W);
exit Scanning_Part when
(not Subrange) or P = Part'Last;
P := P + 1;
end loop Scanning_Part;
return Subrange;
end "<=";
function Sources (Item : Locus_T)
return Source_Interval_List_T
--
-- The source intervals listed in the given locus.
--
is
begin
return Item.Statements.Source(1 .. Item.Statements.Sources);
end Sources;
function "&" (Left, Right : Locus_T)
return Locus_T
is
use String_Pool;
Rext : Locus_T := Right;
-- The Right part, perhaps extende with surrounding lines.
Combo : Locus_T := Left;
-- The combination to be.
Autograph : constant String := "Output.""&""(Locus_T)";
begin
-- Perhaps extend Right with surrounding lines:
Add_Surrounding_Lines (Rext);
-- Program File:
if Rext.Program_File /= Null_Item then
Combo.Program_File := Rext.Program_File;
end if;
-- Source File:
if Rext.Source_File /= Symbols.Null_Name then
Combo.Source_File := Rext.Source_File;
end if;
-- Call Path:
if Combo.Call_Path = Null_Item then
Combo.Call_Path := Rext.Call_Path;
elsif Rext.Call_Path /= Null_Item then
-- Neither Left nor Right call-path is null.
if not Subpath (
Part => String_Pool.To_String (Rext.Call_Path),
Whole => String_Pool.To_String (Left.Call_Path))
then
-- Right call-path is not a substring of Left.
-- Thus, Right is either more precise (a superstring
-- of Left), or not comparable and overriding.
Combo.Call_Path := Rext.Call_Path;
end if;
end if;
-- Source lines:
if Combo.Statements.Sources = 0 then
-- Left does not specify statements, use Right.
Combo.Statements := Rext.Statements;
elsif Rext.Statements.Sources /= 0 then
-- Both Left and Rext specify some statements.
if not (Sources (Left) <= Sources (Rext)) then
-- The Left source-line set is not a subset of the Rext
-- source-line set, so Rext is presumably more precise.
Combo.Statements.Sources := Rext.Statements.Sources;
Combo.Statements.Source := Rext.Statements.Source;
end if;
end if;
-- Code address:
if not (Left.Statements.Code <= Rext.Statements.Code) then
-- The Left code-address interval is not a subset of the
-- Right code-address interval, so Right is presumably
-- more precise.
Combo.Statements.Code := Rext.Statements.Code;
end if;
-- Symbol table:
Combo.Statements.Symbol_Table :=
Same_Symbols (
Left.Statements.Symbol_Table,
Rext.Statements.Symbol_Table,
Autograph);
-- And that is all:
return Combo;
end "&";
procedure Add_Surrounding_Lines (To : in out Locus_T)
is
begin
if Opt.Show_Surrounding_Lines
and To.Statements.Sources = 0
then
-- We should and perhaps can find surrounding lines.
Add_Surrounding_Lines (To => To.Statements);
-- Perhaps we now know the source-code file:
if To.Source_File = Symbols.Null_Name
and To.Statements.Sources > 0
then
To.Source_File := To.Statements.Source(1).File;
end if;
end if;
end Add_Surrounding_Lines;
--
--- Default Locus Nest
--
type Marked_Locus_T is record
Mark : Nest_Mark_T;
Locus : Locus_T;
Surrounded : Boolean;
end record;
--
-- A default locus in the nest.
--
-- Mark
-- The nest mark that identifies this level and locus.
-- Locus
-- The locus at this level.
-- Surrounded
-- Whether the Locus has been improved by
-- Add_Surrounding_Lines.
Default_Locus : array (Nest_Depth_T range 1 .. Nest_Depth_T'Last)
of Marked_Locus_T;
--
-- The stack of nested default loci is Default_Locus(1 .. Nest_Depth).
Nest_Depth : Nest_Depth_T := 0;
--
-- The current depth (number) of nested default loci.
Last_Mark_Seq : Natural := 0;
--
-- The sequence number used for the last nested default locus.
Cached_Locus_Valid : Boolean := False;
--
-- Whether the current default locus has been computed by
-- combining all nested default loci, since the last Nest or
-- Unnest operation.
Cached_Current_Locus : Locus_T;
--
-- The current locus computed by combining all the nested
-- default loci. Valid only if Cached_Locus_Valid.
function Image (Item : Nest_Mark_T) return String
--
-- A readable presentation of the mark.
--
is
begin
return "(Depth ="
& Nest_Depth_T'Image (Item.Depth)
& ", Seq ="
& Natural'Image (Item.Seq)
& ')';
end Image;
procedure Show_Nest (
File : in Ada.Text_IO.File_Type;
Indent : in Ada.Text_IO.Positive_Count)
--
-- Displays the default locus nest on the given File, with
-- the given Indentation.
-- Intended for diagnostics.
--
is
begin
for N in Default_Locus'First .. Nest_Depth loop
Set_Col (File, Indent);
Put (File,
'[' & Image (Natural (N)) & "]: "
& Image (Default_Locus(N).Locus));
if Default_Locus(N).Surrounded then
Put_Line (File, ", surrounded");
else
Put_Line (File, ", not surrounded");
end if;
end loop;
end Show_Nest;
function Nest (Locus : in Locus_T) return Nest_Mark_T
is
Mark : Nest_Mark_T;
-- To be returned.
begin
if Opt.Trace_Locus_Nesting then
Put_Line (Standard_Output,
"Nest (prev depth" & Nest_Depth_T'Image (Nest_Depth) & ')');
Show (Locus, Standard_Output);
end if;
if Nest_Depth = Nest_Depth_T'Last then
Error (
Locus => Locus,
Text =>
"Default output locus too deeply nested.");
return No_Mark;
else
Nest_Depth := Nest_Depth + 1;
Last_Mark_Seq := Last_Mark_Seq + 1;
Mark := (
Defined => True,
Depth => Nest_Depth,
Seq => Last_Mark_Seq);
Default_Locus(Nest_Depth) := (
Mark => Mark,
Locus => Locus,
Surrounded => False);
if Opt.Trace_Locus_Nesting then
Show_Nest (Standard_Output, 3);
end if;
Cached_Locus_Valid := False;
return Mark;
end if;
end Nest;
procedure Unnest (Mark : in Nest_Mark_T)
is
begin
if not Mark.Defined then
-- The mark was not "nested" or the nest was full, nothing
-- to unnest.
null;
elsif Default_Locus(Mark.Depth).Mark /= Mark then
-- Mess up.
Fault (
Location => "Output.Unnest",
Text =>
"Nested mark = "
& Image (Default_Locus(Mark.Depth).Mark)
& " /= given mark = "
& Image (Mark));
else
Nest_Depth := Mark.Depth - 1;
Cached_Locus_Valid := False;
end if;
if Opt.Trace_Locus_Nesting then
Put_Line (Standard_Output,
"Output.Unnest to depth" & Nest_Depth_T'Image (Nest_Depth));
Show_Nest (Standard_Output, 3);
end if;
end Unnest;
function Current_Locus return Locus_T
is
begin
if Opt.Trace_Current_Locus then
Put_Line (Standard_Output, "Current locus nest:");
Show_Nest (Standard_Output, 3);
end if;
if not Cached_Locus_Valid then
-- We must compute a new current locus, because the
-- nest of default loci has changed since the last
-- computation.
Cached_Current_Locus := No_Locus;
for D in 1 .. Nest_Depth loop
if not Default_Locus(D).Surrounded then
-- We have not done this yet:
Add_Surrounding_Lines (To => Default_Locus(D).Locus);
Default_Locus(D).Surrounded := True;
end if;
Cached_Current_Locus :=
Cached_Current_Locus
& Default_Locus(D).Locus;
end loop;
end if;
return Cached_Current_Locus;
end Current_Locus;
--
--- Locus queries
--
function Program_File (
Item : Locus_T;
Form : Source_File_Form_T := Default)
return String
is
begin
return Formed_Source (To_String (Item.Program_File), Form);
end Program_File;
function Source_File (
Item : Locus_T;
Form : Source_File_Form_T := Default)
return String
is
begin
return Formed_Source (Symbols.Image (Item.Source_File), Form);
end Source_File;
function Call_Path (Item : Locus_T) return String
is
begin
return To_String (Item.Call_Path);
end Call_Path;
function Statements (Item : Locus_T) return Statement_Range_T
is
begin
return Item.Statements;
end Statements;
function Image (Item : Locus_T) return String
is
begin
return
Program_File (Item) & Opt.Field_Separator
& Source_File (Item) & Opt.Field_Separator
& Call_Path (Item) & Opt.Field_Separator
& Image (Statements (Item));
end Image;
--
--- Basic output operations
--
procedure Line (
Channel : in Ada.Text_IO.File_Type;
Key : in String;
Locus : in Locus_T;
Data : in String)
--
-- Emit a line in the basic format, with the location fields
-- given by a Locus. The default loci are _not_ applied.
--
is
begin
if Locus.Statements.Sources <= 1 then
-- Traditional output form for one or no source file.
Line (
Channel => Channel,
Key => Key,
Program_File => Program_File (Locus),
Source_File => Source_File (Locus),
Call_Path => Call_Path (Locus),
Statements => Image (Locus.Statements),
Data => Data);
else
-- "See also" for the second and further source files.
Line (
Channel => Channel,
Key => Key,
Program_File => Program_File (Locus),
Source_File => Source_File (Locus.Statements, Source => 1),
Call_Path => Call_Path (Locus),
Statements => Image (Locus.Statements, Source => 1),
Data => Data);
for S in 2 .. Locus.Statements.Sources loop
Line (
Channel => Channel,
Key => Basic_Output.See_Also_Key,
Program_File => Program_File (Locus),
Source_File => Source_File (Locus.Statements, Source => S),
Call_Path => Call_Path (Locus),
Statements => Image (Locus.Statements, Source => S),
Data => "");
end loop;
end if;
end Line;
-- Limits on number of problem messages
generic
Kind : in String;
Count : in out Natural;
Max : in out Natural;
procedure One_More_Problem;
--
-- Increments the Count of problem messages of this Kind.
-- Propagates Too_Many_Problems if the tally then exceeds Max.
procedure One_More_Problem
is
begin
Count := Count + 1;
if Count > Max then
Line (
Channel => Standard_Error,
Key => Basic_Output.Error_Key,
Locus => Current_Locus,
Data => "Over"
& Natural'Image (Max)
& ' '
& Kind
& "s. Analysis aborted.");
raise Too_Many_Problems;
end if;
end One_More_Problem;
-- Notes
procedure Note (
Text : in String)
is
begin
if Opt.Show_Notes then
Line (
Channel => Standard_Output,
Key => Basic_Output.Note_Key,
Locus => Current_Locus,
Data => Text);
end if;
end Note;
procedure Note (
Locus : in Locus_T;
Text : in String)
is
begin
if Opt.Show_Notes then
Line (
Channel => Standard_Output,
Key => Basic_Output.Note_Key,
Locus => Current_Locus & Locus,
Data => Text);
end if;
end Note;
-- Warnings
Number_Warnings : Natural := 0;
--
-- The number of Warnings emitted so far.
procedure One_More_Warning is new One_More_Problem (
Kind => Basic_Output.Warning_Key,
Count => Number_Warnings,
Max => Opt.Max_Warnings);
procedure Warning (
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Basic_Output.Warning_Key,
Locus => Current_Locus,
Data => Text);
One_More_Warning;
end Warning;
procedure Warning (
Locus : in Locus_T;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Basic_Output.Warning_Key,
Locus => Current_Locus & Locus,
Data => Text);
One_More_Warning;
end Warning;
-- Errors
Number_Errors : Natural := 0;
--
-- The number of Errors emitted so far.
procedure One_More_Error is new One_More_Problem (
Kind => Basic_Output.Error_Key,
Count => Number_Errors,
Max => Opt.Max_Errors);
procedure Error (
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Error_Key,
Locus => Current_Locus,
Data => Text);
One_More_Error;
end Error;
procedure Error (
Locus : in Locus_T;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Error_Key,
Locus => Current_Locus & Locus,
Data => Text);
One_More_Error;
end Error;
-- Faults
Number_Faults : Natural := 0;
--
-- The number of Faults emitted so far.
procedure One_More_Fault is new One_More_Problem (
Kind => Basic_Output.Fault_Key,
Count => Number_Faults,
Max => Opt.Max_Faults);
procedure Fault (
Location : in String;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Fault_Key,
Locus => Current_Locus,
Data => Location
& Opt.Field_Separator
& Text);
One_More_Fault;
end Fault;
procedure Fault (
Location : in String;
Locus : in Locus_T;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Fault_Key,
Locus => Current_Locus & Locus,
Data => Location
& Opt.Field_Separator
& Text);
One_More_Fault;
end Fault;
procedure Trace (
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Basic_Output.Trace_Key,
Locus => Current_Locus,
Data => Text);
end Trace;
procedure Trace (
Locus : in Locus_T;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Basic_Output.Trace_Key,
Locus => Current_Locus & Locus,
Data => Text);
end Trace;
-- Exception info
procedure Exception_Info (
Text : in String;
Occurrence : in Ada.Exceptions.Exception_Occurrence)
is
use Ada.Exceptions;
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Exception_Key,
Locus => Current_Locus,
Data => Text
& Opt.Field_Separator
& Exception_Information (Occurrence));
end Exception_Info;
procedure Exception_Info (
Locus : in Locus_T;
Text : in String;
Occurrence : in Ada.Exceptions.Exception_Occurrence)
is
use Ada.Exceptions;
begin
Flush_Standard_Output;
Line (
Channel => Standard_Error,
Key => Basic_Output.Exception_Key,
Locus => Current_Locus & Locus,
Data => Text
& Opt.Field_Separator
& Exception_Information (Occurrence));
end Exception_Info;
-- Results and Unknowns
procedure Result (
Key : in String;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Key,
Locus => Current_Locus,
Data => Text);
end Result;
procedure Result (
Key : in String;
Locus : in Locus_T;
Text : in String)
is
begin
Flush_Standard_Output;
Line (
Channel => Standard_Output,
Key => Key,
Locus => Current_Locus & Locus,
Data => Text);
end Result;
procedure Unknown (
Key : in String;
Text : in String := "")
is
begin
Flush_Standard_Output;
if Text'Length = 0 then
Line (
Channel => Standard_Output,
Key => Basic_Output.Unknown_Key,
Locus => Current_Locus,
Data => Key);
else
Line (
Channel => Standard_Output,
Key => Basic_Output.Unknown_Key,
Locus => Current_Locus,
Data => Key
& Opt.Field_Separator
& Text);
end if;
end Unknown;
procedure Unknown (
Key : in String;
Locus : in Locus_T;
Text : in String := "")
is
begin
Flush_Standard_Output;
if Text'Length = 0 then
Line (
Channel => Standard_Output,
Key => Basic_Output.Unknown_Key,
Locus => Current_Locus & Locus,
Data => Key);
else
Line (
Channel => Standard_Output,
Key => Basic_Output.Unknown_Key,
Locus => Current_Locus & Locus,
Data => Key
& Opt.Field_Separator
& Text);
end if;
end Unknown;
--
--- Supporting utility operations
--
function Image (Item : Processor.Time_T) return String
is
Img : constant String := Processor.Time_T'Image (Item);
begin
if Img (Img'First) /= ' ' then
return Img;
else
return Img (Img'First + 1 .. Img'Last);
end if;
end Image;
function Image (Item : Line_Number_T) return String
is
Img : constant String := Line_Number_T'Image (Item);
begin
if Img (Img'First) /= ' ' then
return Img;
else
return Img (Img'First + 1 .. Img'Last);
end if;
end Image;
function Either (
Cond : Boolean;
Yes : String;
No : String)
return String
is
begin
if Cond then return Yes; else return No; end if;
end Either;
procedure Flush
is
begin
Ada.Text_IO.Flush (Standard_Output);
Ada.Text_IO.Flush (Standard_Error);
end Flush;
procedure Heading (
Text : in String;
Margin : in Ada.Text_IO.Positive_Count := 4)
is
begin
Set_Col (1);
Flush;
Put_Line (Text);
Set_Col (Margin);
end Heading;
end Output;
|
sungyeon/drake | Ada | 7,169 | adb | with System.Native_Real_Time;
with System.Native_Time;
with System.Tasks;
with System.Debug; -- assertions
with C.errno;
with C.poll;
package body System.Synchronous_Objects.Abortable is
use type Native_Time.Nanosecond_Number;
use type C.signed_int;
use type C.unsigned_short;
type struct_pollfd_array is
array (C.size_t range <>) of aliased C.poll.struct_pollfd
with Convention => C;
pragma Suppress_Initialization (struct_pollfd_array);
-- queue
procedure Take (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter;
Aborted : out Boolean) is
begin
Aborted := Tasks.Is_Aborted;
Enter (Object.Mutex.all);
declare
Previous : Queue_Node_Access := null;
I : Queue_Node_Access := Object.Head;
begin
Taking : loop
Take_No_Sync (Object, Item, Params, Filter, Previous, I);
exit Taking when Item /= null;
-- not found
declare
Tail_On_Waiting : constant Queue_Node_Access := Object.Tail;
begin
Object.Params := Params;
Object.Filter := Filter;
loop
Object.Waiting := True;
Leave (Object.Mutex.all);
Wait (Object.Pipe, Aborted => Aborted);
if not Aborted then
Read_1 (Object.Pipe.Reading_Pipe);
end if;
Enter (Object.Mutex.all);
Object.Waiting := False;
exit Taking when Aborted;
exit when Object.Tail /= Tail_On_Waiting;
end loop;
if Tail_On_Waiting /= null then
Previous := Tail_On_Waiting;
I := Tail_On_Waiting.Next;
else
Previous := null;
I := Object.Head;
end if;
end;
end loop Taking;
end;
Leave (Object.Mutex.all);
end Take;
-- event
procedure Wait (
Object : in out Event;
Aborted : out Boolean)
is
Abort_Event : constant access Event := Tasks.Abort_Event;
begin
if Abort_Event /= null then
declare
Polling : aliased struct_pollfd_array (0 .. 1);
begin
Polling (0).fd := Object.Reading_Pipe;
Polling (0).events :=
C.signed_short (
C.unsigned_short'(C.poll.POLLIN or C.poll.POLLERR));
Polling (1).fd := Abort_Event.Reading_Pipe;
Polling (1).events :=
C.signed_short (
C.unsigned_short'(C.poll.POLLIN or C.poll.POLLERR));
loop
declare
R : C.signed_int;
Value : Boolean;
begin
R := C.poll.poll (
Polling (0)'Access,
2,
-1); -- waiting indefinitely
if R > 0 then
pragma Check (Debug,
Check =>
((C.unsigned_short (Polling (0).revents)
and C.poll.POLLERR) = 0
and then (C.unsigned_short (Polling (0).revents)
and C.poll.POLLERR) = 0)
or else Debug.Runtime_Error ("POLLERR"));
Value :=
(C.unsigned_short (Polling (0).revents)
and C.poll.POLLIN) /= 0;
Aborted :=
(C.unsigned_short (Polling (1).revents)
and C.poll.POLLIN) /= 0;
exit when Value or else Aborted;
end if;
pragma Check (Debug,
Check =>
not (R < 0)
or else C.errno.errno = C.errno.EINTR
or else Debug.Runtime_Error ("poll failed"));
end;
end loop;
end;
else
Wait (Object);
Aborted := Tasks.Is_Aborted;
end if;
end Wait;
procedure Wait (
Object : in out Event;
Timeout : Duration;
Value : out Boolean;
Aborted : out Boolean)
is
Abort_Event : constant access Event := Tasks.Abort_Event;
begin
if Abort_Event /= null then
declare
Deadline : constant Duration :=
Native_Real_Time.To_Duration (Native_Real_Time.Clock) + Timeout;
Span : Duration := Timeout;
Polling : aliased struct_pollfd_array (0 .. 1);
begin
Polling (0).fd := Object.Reading_Pipe;
Polling (0).events :=
C.signed_short (
C.unsigned_short'(C.poll.POLLIN or C.poll.POLLERR));
Polling (1).fd := Abort_Event.Reading_Pipe;
Polling (1).events :=
C.signed_short (
C.unsigned_short'(C.poll.POLLIN or C.poll.POLLERR));
loop
declare
Nanoseconds : constant Native_Time.Nanosecond_Number :=
Native_Time.Nanosecond_Number'Integer_Value (Span);
Milliseconds : constant C.signed_int :=
C.signed_int'Max (
C.signed_int (Nanoseconds / 1_000_000),
0);
R : C.signed_int;
begin
R := C.poll.poll (Polling (0)'Access, 2, Milliseconds);
if R > 0 then
pragma Check (Debug,
Check =>
((C.unsigned_short (Polling (0).revents)
and C.poll.POLLERR) = 0
and then (C.unsigned_short (Polling (1).revents)
and C.poll.POLLERR) = 0)
or else Debug.Runtime_Error ("POLLERR"));
Value :=
(C.unsigned_short (Polling (0).revents)
and C.poll.POLLIN) /= 0;
Aborted :=
(C.unsigned_short (Polling (1).revents)
and C.poll.POLLIN) /= 0;
exit when Value or else Aborted;
end if;
pragma Check (Debug,
Check =>
not (R < 0)
or else C.errno.errno = C.errno.EINTR
or else Debug.Runtime_Error ("poll failed"));
end;
Span :=
Deadline
- Native_Real_Time.To_Duration (Native_Real_Time.Clock);
if Span <= 0.0 then -- timeout
Value := False;
Aborted := Tasks.Is_Aborted;
exit;
end if;
end loop;
end;
else
Wait (Object, Timeout, Value);
Aborted := Tasks.Is_Aborted;
end if;
end Wait;
end System.Synchronous_Objects.Abortable;
|
AdaCore/libadalang | Ada | 150 | adb | procedure Test is
package P is
type T is new Integer;
end P;
X : P.T := P.T'First;
pragma Test_Statement;
begin
null;
end Test;
|
stcarrez/ada-util | Ada | 2,058 | adb | -----------------------------------------------------------------------
-- compress -- Compress file using Util.Streams.Buffered.LZMA
-- Copyright (C) 2019, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Streams.Stream_IO;
with Util.Streams.Files;
with Util.Streams.Lzma;
procedure Compress is
procedure Compress_File (Source : in String;
Destination : in String);
procedure Compress_File (Source : in String;
Destination : in String) is
In_Stream : aliased Util.Streams.Files.File_Stream;
Out_Stream : aliased Util.Streams.Files.File_Stream;
Compressor : aliased Util.Streams.Lzma.Compress_Stream;
begin
In_Stream.Open (Mode => Ada.Streams.Stream_IO.In_File, Name => Source);
Out_Stream.Create (Mode => Ada.Streams.Stream_IO.Out_File, Name => Destination);
Compressor.Initialize (Output => Out_Stream'Unchecked_Access, Size => 32768);
Util.Streams.Copy (From => In_Stream, Into => Compressor);
end Compress_File;
begin
if Ada.Command_Line.Argument_Count /= 2 then
Ada.Text_IO.Put_Line ("Usage: compress source destination");
return;
end if;
Compress_File (Source => Ada.Command_Line.Argument (1),
Destination => Ada.Command_Line.Argument (2));
end Compress;
|
charlie5/cBound | Ada | 1,508 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_render_query_pict_index_values_cookie_t is
-- Item
--
type Item is record
sequence : aliased Interfaces.C.unsigned;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_render_query_pict_index_values_cookie_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_pict_index_values_cookie_t.Item,
Element_Array =>
xcb.xcb_render_query_pict_index_values_cookie_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_render_query_pict_index_values_cookie_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_query_pict_index_values_cookie_t.Pointer,
Element_Array =>
xcb.xcb_render_query_pict_index_values_cookie_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_query_pict_index_values_cookie_t;
|
stcarrez/ada-util | Ada | 4,162 | adb | -----------------------------------------------------------------------
-- util-executors -- Execute work that is queued
-- Copyright (C) 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Util.Executors is
overriding
procedure Initialize (Manager : in out Executor_Manager) is
begin
Manager.Self := Manager'Unchecked_Access;
end Initialize;
-- ------------------------------
-- Execute the work through the executor.
-- ------------------------------
procedure Execute (Manager : in out Executor_Manager;
Work : in Work_Type) is
W : constant Work_Info := Work_Info '(Work => Work, Done => False);
begin
Manager.Queue.Enqueue (W);
end Execute;
-- ------------------------------
-- Start the executor tasks.
-- ------------------------------
procedure Start (Manager : in out Executor_Manager;
Autostop : in Boolean := False) is
begin
Manager.Autostop := Autostop;
for Worker of Manager.Workers loop
Worker.Start (Manager.Self);
end loop;
end Start;
-- ------------------------------
-- Stop the tasks and wait for their completion.
-- ------------------------------
procedure Stop (Manager : in out Executor_Manager) is
W : Work_Info;
begin
W.Done := True;
for Worker of Manager.Workers loop
if not Worker'Terminated then
Manager.Queue.Enqueue (W);
end if;
end loop;
end Stop;
-- ------------------------------
-- Set the work queue size.
-- ------------------------------
procedure Set_Queue_Size (Manager : in out Executor_Manager;
Capacity : in Positive) is
begin
Manager.Queue.Set_Size (Capacity);
end Set_Queue_Size;
-- ------------------------------
-- Wait for the pending work to be executed by the executor tasks.
-- ------------------------------
procedure Wait (Manager : in out Executor_Manager) is
begin
Manager.Queue.Wait_Empty;
end Wait;
-- ------------------------------
-- Get the number of elements in the queue.
-- ------------------------------
function Get_Count (Manager : in Executor_Manager) return Natural is
begin
return Manager.Queue.Get_Count;
end Get_Count;
-- ------------------------------
-- Stop and release the executor.
-- ------------------------------
overriding
procedure Finalize (Manager : in out Executor_Manager) is
begin
Manager.Stop;
end Finalize;
task body Worker_Task is
M : access Executor_Manager;
Autostop : Boolean := False;
begin
select
accept Start (Manager : in Executor_Manager_Access) do
M := Manager;
end Start;
or
terminate;
end select;
while M /= null loop
declare
Work : Work_Info;
begin
if Autostop then
M.Queue.Dequeue (Work, 0.0);
else
M.Queue.Dequeue (Work);
end if;
exit when Work.Done;
begin
Execute (Work.Work);
exception
when E : others =>
Error (Work.Work, E);
end;
Autostop := M.Autostop;
exception
when Work_Queue.Timeout =>
exit;
end;
end loop;
end Worker_Task;
end Util.Executors;
|
Tim-Tom/project-euler | Ada | 58 | ads | package Problem_10 is
procedure Solve;
end Problem_10;
|
annexi-strayline/AURA | Ada | 14,225 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- Reference Implementation --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- 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.Assertions;
with Ada.Directories;
with Ada.Unchecked_Deallocation;
with Ada.Containers.Vectors;
with Ada.Streams.Stream_IO;
with Unit_Names;
with User_Queries;
with Stream_Hashing.Collective;
with Registrar.Library_Units;
with Registrar.Queries;
separate (Repositories.Cache)
package body Validate_Local_Or_System is
type Hash_Queue_Access is
access Stream_Hashing.Collective.Hash_Queues.Queue;
--
-- Hash_File_Order
--
type Hash_File_Order is new Workers.Work_Order with
record
Path : UBS.Unbounded_String;
Hashes: Hash_Queue_Access;
-- The following is along for the ride - it will be used to
-- fill-out a Validate_Local_Or_System_Order in the Phase_Trigger
Index : Repository_Index;
end record;
overriding procedure Execute (Order: in out Hash_File_Order);
overriding procedure Phase_Trigger (Order: in out Hash_File_Order);
overriding function Image (Order: Hash_File_Order) return String;
--
-- Validate_Local_Or_System_Order
--
-- This order is actually called from the last Hash_File_Order, and
-- generates the collective hash, and then updates/validates the repo
type Validate_Local_Or_System_Order is new Workers.Work_Order with
record
Index : Repository_Index;
Hashes: Hash_Queue_Access;
end record;
overriding procedure Execute (Order: in out Validate_Local_Or_System_Order);
overriding function Image (Order: Validate_Local_Or_System_Order)
return String;
--
-- Hash_File_Order
--
-----------
-- Image --
-----------
function Image (Order: Hash_File_Order) return String
is ( "[Hash_File_Order] (Repositories.Cache.Validate_Local_Or_System)"
& New_Line
& " Path: " & UBS.To_String (Order.Path) & New_Line
& " (For validation/generation of Repository No."
& Repository_Index'Image (Order.Index) & ')');
-------------
-- Execute --
-------------
procedure Execute (Order: in out Hash_File_Order) is
use Ada.Streams.Stream_IO;
File: File_Type;
begin
Open (File => File,
Mode => In_File,
Name => UBS.To_String (Order.Path));
Order.Hashes.Enqueue
(Stream_Hashing.Digest_Stream (Stream (File)));
Close (File);
exception
when others =>
if Is_Open (File) then
Close (File);
end if;
raise;
end Execute;
-------------------
-- Phase_Trigger --
-------------------
-- This is executred one, when all Hash_Orders have been completed. We can
-- safely deallocate the dynamic tracker, and then submit a
-- Validate_Local_Or_System_Order, which handles the rest
procedure Phase_Trigger (Order: in out Hash_File_Order) is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Progress.Progress_Tracker,
Name => Progress.Progress_Tracker_Access);
Next_Phase: Validate_Local_Or_System_Order
:= (Tracker => Caching_Progress'Access,
-- Note that Total_Items was incremented on the call to
-- Dispatch that got the whole proverbial ball rolling
Index => Order.Index,
Hashes => Order.Hashes);
begin
Free (Order.Tracker);
Workers.Enqueue_Order (Next_Phase);
end Phase_Trigger;
--
-- Validate_Local_Or_System_Order
--
-----------
-- Image --
-----------
function Image (Order: Validate_Local_Or_System_Order) return String
is ( "[Validate_Local_Or_System_Order] "
& "(Repositories.Cache.Validate_Local_Or_System)"
& New_Line
& " Repository No."
& Repository_Index'Image (Order.Index));
-------------
-- Execute --
-------------
procedure Execute (Order: in out Validate_Local_Or_System_Order) is
use Stream_Hashing;
use Stream_Hashing.Collective;
procedure Free is new Ada.Unchecked_Deallocation
(Object => Hash_Queues.Queue,
Name => Hash_Queue_Access);
Repo: Repository := Extract_Repository (Order.Index);
Collect_Hash: Hash_Type;
Hash_String : UBS.Unbounded_String;
begin
pragma Assert (Repo.Format in System | Local);
pragma Assert (Repo.Cache_State = Requested);
Compute_Collective_Hash (Hash_Queue => Order.Hashes.all,
Collective_Hash => Collect_Hash);
-- Release the queue
Free (Order.Hashes);
UBS.Set_Unbounded_String (Target => Hash_String,
Source => Collect_Hash.To_String);
if UBS.Length (Repo.Snapshot) = 0 then
-- New repo
Repo.Snapshot := Hash_String;
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
Generate_Repo_Spec (Order.Index);
return;
else
-- Verify the hash
if Collect_Hash.To_String /= UBS.To_String (Repo.Snapshot) then
-- Mismatch. Ask the user if they want to proceed (use the new
-- hash), or abort
declare
use User_Queries;
Response: String (1..1);
Last: Natural;
begin
Query_Manager.Start_Query;
loop
Query_Manager.Post_Query
(Prompt => "Repository"
& Repository_Index'Image (Order.Index)
& '(' & UBS.To_String (Repo.Location) & ')'
& " has been modified. Accept changes? (Y/[N]): ",
Default => "N",
Response_Size => Response'Length);
Query_Manager.Wait_Response (Response => Response,
Last => Last);
if Last < Response'First then
-- Default (N)
Response := "N";
end if;
exit when Response in "Y" | "y" | "N" | "n";
end loop;
Query_Manager.End_Query;
if Response in "Y" | "y" then
-- Update with new hash
Repo.Snapshot := Hash_String;
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
Generate_Repo_Spec (Order.Index);
else
-- Abort
raise Ada.Assertions.Assertion_Error with
"Repository hash mismatch. User rejected changes.";
end if;
end;
else
-- Hash ok
Repo.Cache_State := Available;
Repo.Cache_Path := Repo.Location;
Update_Repository (Index => Order.Index,
Updated => Repo);
end if;
end if;
end Execute;
--------------
-- Dispatch --
--------------
procedure Dispatch (Repo: in Repository; Index: in Repository_Index) is
use Ada.Directories;
use type Ada.Containers.Count_Type;
package Path_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => UBS.Unbounded_String,
"=" => UBS."=");
Path_Vector: Path_Vectors.Vector;
Group_Tracker: Progress.Progress_Tracker_Access
:= new Progress.Progress_Tracker;
New_Order: Hash_File_Order
:= (Tracker => Group_Tracker,
Hashes => new Stream_Hashing.Collective.Hash_Queues.Queue,
Index => Index,
others => <>);
Filter: constant Filter_Type := (Directory => True,
Ordinary_File => True,
Special_File => False);
procedure Recursive_Add (E: in Directory_Entry_Type);
procedure Recursive_Add (E: in Directory_Entry_Type) is
S_Name: constant String := Simple_Name (E);
begin
-- Don't process hidden files
if S_Name(S_Name'First) = '.' then
return;
end if;
if Kind (E) = Directory then
Search (Directory => Full_Name (E),
Pattern => "*",
Filter => Filter,
Process => Recursive_Add'Access);
else
Path_Vector.Append (UBS.To_Unbounded_String (Full_Name (E)));
end if;
end Recursive_Add;
begin
-- For System repositories, we want to make sure the AURA spec matches
if Repo.Format = System then
declare
use Ada.Streams.Stream_IO;
use Stream_Hashing;
AURA_Unit: constant Registrar.Library_Units.Library_Unit
:= Registrar.Queries.Lookup_Unit
(Unit_Names.Set_Name ("aura"));
Repo_AURA_Spec: File_Type;
Repo_AURA_Hash: Hash_Type;
begin
Open (File => Repo_AURA_Spec,
Mode => In_File,
Name => UBS.To_String (Repo.Cache_Path) & "/aura.ads");
Repo_AURA_Hash := Digest_Stream (Stream (Repo_AURA_Spec));
Ada.Assertions.Assert
(Check => Repo_AURA_Hash = AURA_Unit.Spec_File.Hash,
Message => "System repository's AURA package does not match "
& "the local AURA package");
end;
end if;
-- Start with the location of the repository, which shall be a directory
Search (Directory => UBS.To_String (Repo.Location),
Pattern => "*",
Filter => Filter,
Process => Recursive_Add'Access);
Ada.Assertions.Assert (Check => Path_Vector.Length > 0,
Message => "Location path is invalid");
-- Set up the group tracker and dispatch
Group_Tracker.Set_Total_Items (Natural (Path_Vector.Length));
-- Dispatch
for Path of Path_Vector loop
New_Order.Path := Path;
Workers.Enqueue_Order (New_Order);
end loop;
end Dispatch;
end Validate_Local_Or_System;
|
stcarrez/mat | Ada | 1,125 | adb | -----------------------------------------------------------------------
-- mat-readers -- Reader
-- Copyright (C) 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body MAT.Readers is
-- ------------------------------
-- Get the buffer endian format.
-- ------------------------------
function Get_Endian (Msg : in Message_Type) return Endian_Type is
begin
return Msg.Buffer.Endian;
end Get_Endian;
end MAT.Readers;
|
reznikmm/matreshka | Ada | 3,805 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_010D is
pragma Preelaborate;
Group_010D : aliased constant Core_Second_Stage
:= (others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_010D;
|
vlstill/ttk4145 | Ada | 3,342 | adb | with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Numerics.Float_Random;
-- (Ada tabs = 3 spaces)
procedure exercise8 is
Count_Failed : exception; -- Exception to be raised when counting fails
Gen : Generator; -- Random number generator
protected type Transaction_Manager (N : Positive) is
entry Finished;
entry Wait_Until_Aborted;
procedure Signal_Abort;
private
Finished_Gate_Open : Boolean := False;
Aborted : Boolean := False;
end Transaction_Manager;
protected body Transaction_Manager is
entry Finished when Finished_Gate_Open or Finished'Count = N is
begin
Put_Line( "Manager.Finished: count =" & Integer'Image( Finished'Count )
& " aborted = " & Boolean'Image( Aborted ) );
if Finished'Count = N - 1 then
Finished_Gate_Open := True;
end if;
if Finished'Count = 0 then
Finished_Gate_Open := False;
end if;
end Finished;
entry Wait_Until_Aborted when Aborted is
begin
Put_Line( "Wait_Until_Aborted triggered, count =" & Integer'Image( Wait_Until_Aborted'Count ) );
if Wait_Until_Aborted'Count = 0 then
Aborted := False;
end if;
end Wait_Until_Aborted;
procedure Signal_Abort is
begin
Aborted := True;
end Signal_Abort;
end Transaction_Manager;
function Unreliable_Slow_Add (x : Integer) return Integer is
Error_Rate : Constant := 0.15; -- (between 0 and 1)
begin
if Random( Gen ) <= Error_Rate then
delay Duration( Random( Gen ) * 0.5 );
raise Count_Failed;
else
delay Duration( Random( Gen ) * 4.0 );
return 10 + x;
end if;
end Unreliable_Slow_Add;
task type Transaction_Worker (Initial : Integer; Manager : access Transaction_Manager);
task body Transaction_Worker is
Num : Integer := Initial;
Prev : Integer := Num;
Round_Num : Integer := 0;
begin
Put_Line ("Worker" & Integer'Image(Initial) & " started");
loop
Put_Line ("Worker" & Integer'Image(Initial) & " started round" & Integer'Image(Round_Num));
Round_Num := Round_Num + 1;
select
Manager.Wait_Until_Aborted;
Num := Prev + 5;
Put_Line( " Worker" & Integer'Image( Initial ) & ": forward recovery triggered,"
& "changing from " & Integer'Image( Prev ) & " to " & Integer'Image( Num ) );
then abort
begin
Num := Unreliable_Slow_Add( Num );
Manager.Finished;
Put_Line (" Worker" & Integer'Image(Initial) & " comitting" & Integer'Image(Num));
exception
when Count_Failed =>
begin
Put_Line( " Worker" & Integer'Image( Initial ) & " aborting" );
Manager.Signal_Abort;
end;
end;
end select;
Prev := Num;
delay 3.0;
end loop;
end Transaction_Worker;
Manager : aliased Transaction_Manager (3);
Worker_1 : Transaction_Worker (0, Manager'Access);
Worker_2 : Transaction_Worker (1, Manager'Access);
Worker_3 : Transaction_Worker (2, Manager'Access);
begin
Reset(Gen); -- Seed the random number generator
end exercise8;
|
zhmu/ananas | Ada | 19,926 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- R E P I N F O --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routines to handle back annotation of the
-- tree to fill in representation information, and also the routines used
-- by -gnatR to output this information.
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file repinfo.h
with Types; use Types;
with Uintp; use Uintp;
package Repinfo is
--------------------------------
-- Representation Information --
--------------------------------
-- The representation information of interest here is size and
-- component information for arrays and records. For primitive
-- types, the front end computes the Esize and RM_Size fields of
-- the corresponding entities as constant non-negative integers,
-- and the Uint values are stored directly in these fields.
-- For composite types, there are two cases:
-- 1. In some cases the front end knows the values statically,
-- for example in the case where representation clauses or
-- pragmas specify the values.
-- 2. The backend is responsible for layout of all types and objects
-- not laid out by the front end. This includes all dynamic values,
-- and also static values (e.g. record sizes) when not set by the
-- front end.
-----------------------------
-- Back Annotation by Gigi --
-----------------------------
-- The following interface is used by gigi
-- As part of the processing in gigi, the types are laid out and
-- appropriate values computed for the sizes and component positions
-- and sizes of records and arrays.
-- The back-annotation circuit in gigi is responsible for updating the
-- relevant fields in the tree to reflect these computations, as follows:
-- For E_Array_Type entities, the Component_Size field
-- For all record and array types and subtypes, the Esize and RM_Size
-- fields, which respectively contain the Object_Size and Value_Size
-- values for the type or subtype.
-- For E_Component and E_Discriminant entities, the Esize (size
-- of component) and Component_Bit_Offset fields. Note that gigi
-- does not generally back annotate Normalized_Position/First_Bit.
-- There are three cases to consider:
-- 1. The value is constant. In this case, the back annotation works
-- by simply storing the non-negative universal integer value in
-- the appropriate field corresponding to this constant size.
-- 2. The value depends on the discriminant values for the current
-- record. In this case, gigi back annotates the field with a
-- representation of the expression for computing the value in
-- terms of the discriminants. A negative Uint value is used to
-- represent the value of such an expression, as explained in
-- the following section.
-- 3. The value depends on variables other than discriminants of the
-- current record. In this case, gigi also back annotates the field
-- with a representation of the expression for computing the value
-- in terms of the variables represented symbolically.
-- Note: the extended back annotation for the dynamic case is needed only
-- for -gnatR3 output. Since it can be expensive to do this back annotation
-- (for discriminated records with many variable-length arrays), we only do
-- the full back annotation in -gnatR3 mode. In any other mode, the
-- back-end just sets the value to Uint_Minus_1, indicating that the value
-- of the attribute depends on discriminant information, but not giving
-- further details.
-- GCC expressions are represented with a Uint value that is negative.
-- See the body of this package for details on the representation used.
-- One other case in which gigi back annotates GCC expressions is in
-- the Present_Expr field of an N_Variant node. This expression which
-- will always depend on discriminants, and hence always be represented
-- as a negative Uint value, provides an expression which, when evaluated
-- with a given set of discriminant values, indicates whether the variant
-- is present for that set of values (result is True, i.e. non-zero) or
-- not present (result is False, i.e. zero). Again, the full annotation of
-- this field is done only in -gnatR3 mode, and in other modes, the value
-- is set to Uint_Minus_1.
subtype Node_Ref is Unegative;
-- Subtype used for negative Uint values used to represent nodes
subtype Node_Ref_Or_Val is Uint;
-- Subtype used for values that can be a Node_Ref (negative) or a value
-- (non-negative) or No_Uint.
type TCode is range 0 .. 27;
-- Type used on Ada side to represent DEFTREECODE values defined in
-- tree.def. Only a subset of these tree codes can actually appear.
-- The names are the names from tree.def in Ada casing.
-- name code description operands symbol
Cond_Expr : constant TCode := 1; -- conditional 3 ?<>
Plus_Expr : constant TCode := 2; -- addition 2 +
Minus_Expr : constant TCode := 3; -- subtraction 2 -
Mult_Expr : constant TCode := 4; -- multiplication 2 *
Trunc_Div_Expr : constant TCode := 5; -- truncating div 2 /t
Ceil_Div_Expr : constant TCode := 6; -- div rounding up 2 /c
Floor_Div_Expr : constant TCode := 7; -- div rounding down 2 /f
Trunc_Mod_Expr : constant TCode := 8; -- mod for trunc_div 2 modt
Ceil_Mod_Expr : constant TCode := 9; -- mod for ceil_div 2 modc
Floor_Mod_Expr : constant TCode := 10; -- mod for floor_div 2 modf
Exact_Div_Expr : constant TCode := 11; -- exact div 2 /e
Negate_Expr : constant TCode := 12; -- negation 1 -
Min_Expr : constant TCode := 13; -- minimum 2 min
Max_Expr : constant TCode := 14; -- maximum 2 max
Abs_Expr : constant TCode := 15; -- absolute value 1 abs
Truth_And_Expr : constant TCode := 16; -- boolean and 2 and
Truth_Or_Expr : constant TCode := 17; -- boolean or 2 or
Truth_Xor_Expr : constant TCode := 18; -- boolean xor 2 xor
Truth_Not_Expr : constant TCode := 19; -- boolean not 1 not
Lt_Expr : constant TCode := 20; -- comparison < 2 <
Le_Expr : constant TCode := 21; -- comparison <= 2 <=
Gt_Expr : constant TCode := 22; -- comparison > 2 >
Ge_Expr : constant TCode := 23; -- comparison >= 2 >=
Eq_Expr : constant TCode := 24; -- comparison = 2 ==
Ne_Expr : constant TCode := 25; -- comparison /= 2 !=
Bit_And_Expr : constant TCode := 26; -- bitwise and 2 &
-- The following entry is used to represent a discriminant value in
-- the tree. It has a special tree code that does not correspond
-- directly to a GCC node. The single operand is the index number
-- of the discriminant in the record (1 = first discriminant).
Discrim_Val : constant TCode := 0; -- discriminant value 1 #
-- The following entry is used to represent a value not known at
-- compile time in the tree, other than a discriminant value. It
-- has a special tree code that does not correspond directly to
-- a GCC node. The single operand is an arbitrary index number.
Dynamic_Val : constant TCode := 27; -- dynamic value 1 var
----------------------------
-- The JSON output format --
----------------------------
-- The representation information can be output to a file in the JSON
-- data interchange format specified by the ECMA-404 standard. In the
-- following description, the terminology is that of the JSON syntax
-- from the ECMA document and of the JSON grammar from www.json.org.
-- The output is an array of entities
-- An entity is an object whose members are pairs taken from:
-- "name" : string
-- "location" : string
-- "record" : array of components
-- "[parent_]*variant" : array of variants
-- "formal" : array of formal parameters
-- "mechanism" : string
-- "Size" : numerical expression
-- "Object_Size" : numerical expression
-- "Value_Size" : numerical expression
-- "Component_Size" : numerical expression
-- "Range" : array of numbers
-- "Small" : number
-- "Alignment" : number
-- "Convention" : string
-- "Linker_Section" : string
-- "Bit_Order" : string
-- "Scalar_Storage_Order" : string
-- "name" and "location" are present for every entity and come from the
-- declaration of the associated Ada entity. The value of "name" is the
-- fully qualified Ada name. The value of "location" is the expanded
-- chain of instantiation locations that contains the entity.
-- "record" is present for every record type and its value is the list of
-- components. "[parent_]*variant" is present only if the record type, or
-- one of its ancestors (parent, grand-parent, etc) if it's an extension,
-- has a variant part and its value is the list of variants.
-- "formal" is present for every subprogram and entry, and its value is
-- the list of formal parameters. "mechanism" is present for functions
-- only and its value is the return mechanim.
-- The other pairs may be present when the eponymous aspect/attribute is
-- defined for the Ada entity, and their value is set by the language.
-- A component is an object whose members are pairs taken from:
-- "name" : string
-- "discriminant" : number
-- "Position" : numerical expression
-- "First_Bit" : number
-- "Size" : numerical expression
-- "name" is present for every component and comes from the declaration
-- of the type; its value is the unqualified Ada name. "discriminant" is
-- present only if the component is a discriminant, and its value is the
-- ranking of the discriminant in the list of discriminants of the type,
-- i.e. an integer index ranging from 1 to the number of discriminants.
-- The other three pairs are present for every component and come from
-- the layout of the type; their value is the value of the eponymous
-- attribute set by the language.
-- A variant is an object whose members are pairs taken from:
-- "present" : numerical expression
-- "record" : array of components
-- "variant" : array of variants
-- "present" and "record" are present for every variant. The value of
-- "present" is a boolean expression that evaluates to true when the
-- components of the variant are contained in the record type and to
-- false when they are not. The value of "record" is the list of
-- components in the variant. "variant" is present only if the variant
-- itself has a variant part and its value is the list of (sub)variants.
-- A formal parameter is an object whose members are pairs taken from:
-- "name" : string
-- "mechanism" : string
-- The two pairs are present for every formal parameter. "name" comes
-- from the declaration of the parameter in the subprogram or entry
-- and its value is the unqualified Ada name. The value of "mechanism"
-- is the passing mechanism for the parameter set by the language.
-- A numerical expression is either a number or an object whose members
-- are pairs taken from:
-- "code" : string
-- "operands" : array of numerical expressions
-- The two pairs are present for every such object. The value of "code"
-- is a symbol taken from the table defining the TCode type above. The
-- number of elements of the value of "operands" is specified by the
-- operands column in the line associated with the symbol in the table.
-- As documented above, the full back annotation is only done in -gnatR3.
-- In the other cases, if the numerical expression is not a number, then
-- it is replaced with the "??" string.
------------------------
-- The gigi Interface --
------------------------
-- The following declarations are for use by gigi for back annotation
function Create_Node
(Expr : TCode;
Op1 : Node_Ref_Or_Val;
Op2 : Node_Ref_Or_Val := No_Uint;
Op3 : Node_Ref_Or_Val := No_Uint) return Node_Ref;
-- Creates a node using the tree code defined by Expr and from one to three
-- operands as required (unused operands set as shown to No_Uint) Note that
-- this call can be used to create a discriminant reference by using (Expr
-- => Discrim_Val, Op1 => discriminant_number).
function Create_Discrim_Ref (Discr : Entity_Id) return Node_Ref;
-- Creates a reference to the discriminant whose entity is Discr
--------------------------------------------------------
-- Front-End Interface for Dynamic Size/Offset Values --
--------------------------------------------------------
-- This interface is used by GNAT LLVM to deal with all dynamic size and
-- offset fields.
-- The interface here allows these created entities to be referenced
-- using negative Unit values, so that they can be stored in the
-- appropriate size and offset fields in the tree.
-- In the case of components, if the location of the component is static,
-- then all four fields (Component_Bit_Offset, Normalized_Position, Esize,
-- and Normalized_First_Bit) are set to appropriate values. In the case of
-- a nonstatic component location, Component_Bit_Offset is not used and
-- is left set to Unknown. Normalized_Position and Normalized_First_Bit
-- are set appropriately.
subtype SO_Ref is Uint;
-- Type used to represent a Uint value that represents a static or
-- dynamic size/offset value (non-negative if static, negative if
-- the size value is dynamic).
subtype Dynamic_SO_Ref is Uint;
-- Type used to represent a negative Uint value used to store
-- a dynamic size/offset value.
function Is_Dynamic_SO_Ref (U : SO_Ref) return Boolean;
pragma Inline (Is_Dynamic_SO_Ref);
-- Given a SO_Ref (Uint) value, returns True iff the SO_Ref value
-- represents a dynamic Size/Offset value (i.e. it is negative).
function Is_Static_SO_Ref (U : SO_Ref) return Boolean;
pragma Inline (Is_Static_SO_Ref);
-- Given a SO_Ref (Uint) value, returns True iff the SO_Ref value
-- represents a static Size/Offset value (i.e. it is non-negative).
function Create_Dynamic_SO_Ref (E : Entity_Id) return Dynamic_SO_Ref;
-- Given the Entity_Id for a constant (case 1), the Node_Id for an
-- expression (case 2), or the Entity_Id for a function (case 3),
-- this function returns a (negative) Uint value that can be used
-- to retrieve the entity or expression for later use.
function Get_Dynamic_SO_Entity (U : Dynamic_SO_Ref) return Entity_Id;
-- Retrieve the Node_Id or Entity_Id stored by a previous call to
-- Create_Dynamic_SO_Ref. The approach is that the front end makes
-- the necessary Create_Dynamic_SO_Ref calls to associate the node
-- and entity id values and the back end makes Get_Dynamic_SO_Ref
-- calls to retrieve them.
------------------------------
-- External tools Interface --
------------------------------
type Discrim_List is array (Pos range <>) of Uint;
-- Type used to represent list of discriminant values
function Rep_Value (Val : Node_Ref_Or_Val; D : Discrim_List) return Uint;
-- Given the contents of a First_Bit_Position or Esize field containing
-- a node reference (i.e. a negative Uint value) and D, the list of
-- discriminant values, returns the interpreted value of this field.
-- For convenience, Rep_Value will take a non-negative Uint value
-- as an argument value, and return it unmodified. A No_Uint value is
-- also returned unmodified.
------------------------
-- Compiler Interface --
------------------------
procedure List_Rep_Info (Bytes_Big_Endian : Boolean);
-- Procedure to list representation information. Bytes_Big_Endian is the
-- value from Ttypes (Repinfo cannot have a dependency on Ttypes).
--------------------------
-- Debugging Procedures --
--------------------------
procedure List_GCC_Expression (U : Node_Ref_Or_Val);
-- Prints out given expression in symbolic form. Constants are listed
-- in decimal numeric form, Discriminants are listed with a # followed
-- by the discriminant number, and operators are output in appropriate
-- symbolic form No_Uint displays as two question marks. The output is
-- on a single line but has no line return after it. This procedure is
-- useful only if operating in backend layout mode.
procedure lgx (U : Node_Ref_Or_Val);
-- In backend layout mode, this is like List_GCC_Expression, but
-- includes a line return at the end. If operating in front end
-- layout mode, then the name of the entity for the size (either
-- a function of a variable) is listed followed by a line return.
end Repinfo;
|
kqr/qweyboard | Ada | 2,903 | adb | with Unicode_Strings; use Unicode_Strings;
with Ada.Command_Line;
with Ada.Task_Termination;
with Ada.Task_Identification;
with Configuration;
with Logging;
with Qweyboard.Emulation;
with Input_Backend;
with Output_Backend;
procedure Main is
use Logging;
Settings : Configuration.Settings;
begin
Ada.Task_Termination.Set_Specific_Handler
(Ada.Task_Identification.Current_Task,
Logging.Logging_Termination_Handler.Log_Termination_Cause'Access);
Ada.Task_Termination.Set_Dependents_Fallback_Handler
(Logging.Logging_Termination_Handler.Log_Termination_Cause'Access);
Configuration.Get_Settings (Settings);
Log.Set_Verbosity (Settings.Log_Level);
Log.Chat ("[Main] Got settings and set log verbosity");
Log.Chat ("[Main] Loading language");
Configuration.Load_Language (Settings);
-- Then kick off the emulation!
--Qweyboard.Emulation.Process.Ready_Wait;
Log.Chat ("[Main] Emulation started");
-- Configure softboard
--Qweyboard.Emulation.Process.Configure (Settings);
Log.Chat ("[Main] Emulation configured");
-- First wait for the output backend to be ready
Output_Backend.Output.Ready_Wait;
Log.Chat ("[Main] Output backend ready");
-- Then wait for input backend to be ready
Input_Backend.Input.Ready_Wait;
Log.Chat ("[Main] Input backend ready");
exception
when Configuration.ARGUMENTS_ERROR =>
Log.Error ("Usage: " & W (Ada.Command_Line.Command_Name) & " [OPTION]");
Log.Error (" ");
Log.Error ("[OPTION] is any combination of the following options: ");
Log.Error (" ");
Log.Error (" -l <language file> : Modifies the standard layout with the ");
Log.Error (" key mappings indicated in the specified ");
Log.Error (" language file. ");
Log.Error (" ");
Log.Error (" -t <milliseconds> : Set the timeout for what counts as one ");
Log.Error (" stroke. If you want 0, NKRO is strongly ");
Log.Error (" recommended. Default value is 500, which ");
Log.Error (" is probably way too high. ");
Log.Error (" ");
Log.Error (" -v,-vv,-vvv : Sets the log level of the software. If you ");
Log.Error (" want to know what goes on inside, this is ");
Log.Error (" where to poke... ");
Ada.Command_Line.Set_Exit_Status (1);
end Main;
|
ohenley/ada-util | Ada | 4,835 | ads | -----------------------------------------------------------------------
-- util-streams-texts -- Text stream utilities
-- Copyright (C) 2010, 2011, 2012, 2015, 2016, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Strings.Wide_Wide_Unbounded;
with Util.Streams.Buffered;
with Ada.Calendar;
with GNAT.Calendar.Time_IO;
-- == Texts ==
-- The <tt>Util.Streams.Texts</tt> package implements text oriented input and output streams.
-- The <tt>Print_Stream</tt> type extends the <tt>Output_Buffer_Stream</tt> to allow writing
-- text content.
--
-- The <tt>Reader_Stream</tt> package extends the <tt>Input_Buffer_Stream</tt> and allows to
-- read text content.
package Util.Streams.Texts is
-- -----------------------
-- Print stream
-- -----------------------
-- The <b>Print_Stream</b> is an output stream which provides helper methods
-- for writing text streams.
type Print_Stream is new Buffered.Output_Buffer_Stream with private;
type Print_Stream_Access is access all Print_Stream'Class;
procedure Initialize (Stream : in out Print_Stream;
To : in Output_Stream_Access);
-- Write a raw character on the stream.
procedure Write (Stream : in out Print_Stream;
Char : in Character);
-- Write a wide character on the stream doing some conversion if necessary.
-- The default implementation translates the wide character to a UTF-8 sequence.
procedure Write_Wide (Stream : in out Print_Stream;
Item : in Wide_Wide_Character);
-- Write a raw string on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in String);
-- Write a raw string on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Strings.Unbounded.Unbounded_String);
-- Write a raw string on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String);
-- Write an integer on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Integer);
-- Write an integer on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Long_Long_Integer);
-- Write a date on the stream.
procedure Write (Stream : in out Print_Stream;
Item : in Ada.Calendar.Time;
Format : in GNAT.Calendar.Time_IO.Picture_String
:= GNAT.Calendar.Time_IO.ISO_Date);
-- Get the output stream content as a string.
function To_String (Stream : in Buffered.Output_Buffer_Stream'Class) return String;
-- Write a character on the stream.
procedure Write_Char (Stream : in out Print_Stream'Class;
Item : in Character);
-- Write a character on the stream.
procedure Write_Char (Stream : in out Print_Stream'Class;
Item : in Wide_Wide_Character);
-- -----------------------
-- Reader stream
-- -----------------------
-- The <b>Reader_Stream</b> is an input stream which provides helper methods
-- for reading text streams.
type Reader_Stream is new Buffered.Input_Buffer_Stream with private;
type Reader_Stream_Access is access all Reader_Stream'Class;
-- Initialize the reader to read the input from the input stream given in <b>From</b>.
procedure Initialize (Stream : in out Reader_Stream;
From : in Input_Stream_Access);
-- Read an input line from the input stream. The line is terminated by ASCII.LF.
-- When <b>Strip</b> is set, the line terminators (ASCII.CR, ASCII.LF) are removed.
procedure Read_Line (Stream : in out Reader_Stream;
Into : out Ada.Strings.Unbounded.Unbounded_String;
Strip : in Boolean := False);
private
type Print_Stream is new Buffered.Output_Buffer_Stream with null record;
type Reader_Stream is new Buffered.Input_Buffer_Stream with null record;
end Util.Streams.Texts;
|
twdroeger/ada-awa | Ada | 15,846 | ads | -----------------------------------------------------------------------
-- AWA.Audits.Models -- AWA.Audits.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Basic.Lists;
with AWA.Users.Models;
pragma Warnings (On);
package AWA.Audits.Models is
pragma Style_Checks ("-mr");
type Audit_Ref is new ADO.Objects.Object_Ref with null record;
type Audit_Field_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The Audit table records the changes made on database on behalf of a user.
-- The record indicates the database table and row, the field being updated,
-- the old and new value. The old and new values are converted to a string
-- and they truncated if necessary to 256 characters.
-- --------------------
-- Create an object key for Audit.
function Audit_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Audit from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Audit_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Audit : constant Audit_Ref;
function "=" (Left, Right : Audit_Ref'Class) return Boolean;
-- Set the audit identifier
procedure Set_Id (Object : in out Audit_Ref;
Value : in ADO.Identifier);
-- Get the audit identifier
function Get_Id (Object : in Audit_Ref)
return ADO.Identifier;
-- Set the date when the field was modified.
procedure Set_Date (Object : in out Audit_Ref;
Value : in Ada.Calendar.Time);
-- Get the date when the field was modified.
function Get_Date (Object : in Audit_Ref)
return Ada.Calendar.Time;
-- Set the old field value.
procedure Set_Old_Value (Object : in out Audit_Ref;
Value : in ADO.Nullable_String);
procedure Set_Old_Value (Object : in out Audit_Ref;
Value : in String);
-- Get the old field value.
function Get_Old_Value (Object : in Audit_Ref)
return ADO.Nullable_String;
function Get_Old_Value (Object : in Audit_Ref)
return String;
-- Set the new field value.
procedure Set_New_Value (Object : in out Audit_Ref;
Value : in ADO.Nullable_String);
procedure Set_New_Value (Object : in out Audit_Ref;
Value : in String);
-- Get the new field value.
function Get_New_Value (Object : in Audit_Ref)
return ADO.Nullable_String;
function Get_New_Value (Object : in Audit_Ref)
return String;
-- Set the database entity identifier to which the audit is associated.
procedure Set_Entity_Id (Object : in out Audit_Ref;
Value : in ADO.Identifier);
-- Get the database entity identifier to which the audit is associated.
function Get_Entity_Id (Object : in Audit_Ref)
return ADO.Identifier;
--
procedure Set_Field (Object : in out Audit_Ref;
Value : in Integer);
--
function Get_Field (Object : in Audit_Ref)
return Integer;
-- Set the user session under which the field was modified.
procedure Set_Session (Object : in out Audit_Ref;
Value : in AWA.Users.Models.Session_Ref'Class);
-- Get the user session under which the field was modified.
function Get_Session (Object : in Audit_Ref)
return AWA.Users.Models.Session_Ref'Class;
-- Set the entity type.
procedure Set_Entity_Type (Object : in out Audit_Ref;
Value : in ADO.Entity_Type);
-- Get the entity type.
function Get_Entity_Type (Object : in Audit_Ref)
return ADO.Entity_Type;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Audit_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Audit_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
AUDIT_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Audit_Ref);
-- Copy of the object.
procedure Copy (Object : in Audit_Ref;
Into : in out Audit_Ref);
package Audit_Vectors is
new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Audit_Ref,
"=" => "=");
subtype Audit_Vector is Audit_Vectors.Vector;
procedure List (Object : in out Audit_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class);
-- --------------------
-- The Audit_Field table describes
-- the database field being updated.
-- --------------------
-- Create an object key for Audit_Field.
function Audit_Field_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Audit_Field from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Audit_Field_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Audit_Field : constant Audit_Field_Ref;
function "=" (Left, Right : Audit_Field_Ref'Class) return Boolean;
-- Set the audit field identifier.
procedure Set_Id (Object : in out Audit_Field_Ref;
Value : in Integer);
-- Get the audit field identifier.
function Get_Id (Object : in Audit_Field_Ref)
return Integer;
-- Set the audit field name.
procedure Set_Name (Object : in out Audit_Field_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out Audit_Field_Ref;
Value : in String);
-- Get the audit field name.
function Get_Name (Object : in Audit_Field_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in Audit_Field_Ref)
return String;
-- Set the entity type
procedure Set_Entity_Type (Object : in out Audit_Field_Ref;
Value : in ADO.Entity_Type);
-- Get the entity type
function Get_Entity_Type (Object : in Audit_Field_Ref)
return ADO.Entity_Type;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Audit_Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in Integer);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Audit_Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in Integer;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Audit_Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Audit_Field_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Audit_Field_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Audit_Field_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
AUDIT_FIELD_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Audit_Field_Ref);
-- Copy of the object.
procedure Copy (Object : in Audit_Field_Ref;
Into : in out Audit_Field_Ref);
private
AUDIT_NAME : aliased constant String := "awa_audit";
COL_0_1_NAME : aliased constant String := "id";
COL_1_1_NAME : aliased constant String := "date";
COL_2_1_NAME : aliased constant String := "old_value";
COL_3_1_NAME : aliased constant String := "new_value";
COL_4_1_NAME : aliased constant String := "entity_id";
COL_5_1_NAME : aliased constant String := "field";
COL_6_1_NAME : aliased constant String := "session_id";
COL_7_1_NAME : aliased constant String := "entity_type";
AUDIT_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 8,
Table => AUDIT_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access,
7 => COL_6_1_NAME'Access,
8 => COL_7_1_NAME'Access)
);
AUDIT_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= AUDIT_DEF'Access;
Null_Audit : constant Audit_Ref
:= Audit_Ref'(ADO.Objects.Object_Ref with null record);
type Audit_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => AUDIT_DEF'Access)
with record
Date : Ada.Calendar.Time;
Old_Value : ADO.Nullable_String;
New_Value : ADO.Nullable_String;
Entity_Id : ADO.Identifier;
Field : Integer;
Session : AWA.Users.Models.Session_Ref;
Entity_Type : ADO.Entity_Type;
end record;
type Audit_Access is access all Audit_Impl;
overriding
procedure Destroy (Object : access Audit_Impl);
overriding
procedure Find (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Audit_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Audit_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Audit_Ref'Class;
Impl : out Audit_Access);
AUDIT_FIELD_NAME : aliased constant String := "awa_audit_field";
COL_0_2_NAME : aliased constant String := "id";
COL_1_2_NAME : aliased constant String := "name";
COL_2_2_NAME : aliased constant String := "entity_type";
AUDIT_FIELD_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 3,
Table => AUDIT_FIELD_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access)
);
AUDIT_FIELD_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= AUDIT_FIELD_DEF'Access;
Null_Audit_Field : constant Audit_Field_Ref
:= Audit_Field_Ref'(ADO.Objects.Object_Ref with null record);
type Audit_Field_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_STRING,
Of_Class => AUDIT_FIELD_DEF'Access)
with record
Name : Ada.Strings.Unbounded.Unbounded_String;
Entity_Type : ADO.Entity_Type;
end record;
type Audit_Field_Access is access all Audit_Field_Impl;
overriding
procedure Destroy (Object : access Audit_Field_Impl);
overriding
procedure Find (Object : in out Audit_Field_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Audit_Field_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Audit_Field_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Audit_Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Audit_Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Audit_Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Audit_Field_Ref'Class;
Impl : out Audit_Field_Access);
end AWA.Audits.Models;
|
zrmyers/VulkanAda | Ada | 18,972 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2020 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Interfaces.C;
with Ada.Numerics;
with Ada.Unchecked_Conversion;
with Ada.Numerics.Generic_Elementary_Functions;
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
package Vulkan.Math is
pragma Preelaborate;
pragma Pure;
----------------------------------------------------------------------------
-- Math Constants
----------------------------------------------------------------------------
--< A constant value representing PI.
PI : constant := Ada.Numerics.Pi;
--< A constant value representing Euler's number e.
E : constant := Ada.Numerics.e;
--< The constant natural logarithm of 2 value. This constant is used in the
--< implementation of Exp2().
LN2 : constant := 0.69314_71805_59945_30941_72321_21458_18;
----------------------------------------------------------------------------
-- Math Scalar Types
----------------------------------------------------------------------------
--< A value that can either be true or false. This type has the same size
--< as a boolean value in C.
type Vkm_Bool is new Boolean;
for Vkm_Bool use (False => 0,
True => 1);
for Vkm_Bool'Size use Interfaces.C.unsigned_char'Size;
--< A 32-bit unsigned integer type.
type Vkm_Uint is new Interfaces.C.unsigned;
--< A 32-bit 2's complement signed integer type.
type Vkm_Int is new Interfaces.C.int;
--< A 32-bit single precision signed floating point number.
type Vkm_Float is new Interfaces.C.C_Float;
--< A 64-bit double precision signed floating point number.
type Vkm_Double is new Interfaces.C.double;
--< The maximum dmmension for a vector or a row or column of a matrix.
type Vkm_Length is new Integer range 1 .. 4;
--< The set of indices allowed for use with any vector or matrix.
type Vkm_Indices is new Integer range 0 .. 3;
--< @private
--< Instantiation of Generic Elementary Functions for Float.
package VKM_FLT_NEF is new
Ada.Numerics.Generic_Elementary_Functions(Float_Type => Vkm_Float);
--< @private
--< Instantiation of Generic Elemantry Functions for Double.
package VKM_DBL_NEF is new
Ada.Numerics.Generic_Elementary_Functions(Float_Type => Vkm_Double);
----------------------------------------------------------------------------
-- Conversion Functions
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Indices.
--<
--< @description
--< Convert a value of type Vkm_Length to a value of type Vkm_Indices.
--<
--< @param length The length value to convert to indices.
--<
--< @return The length converted to an index.
----------------------------------------------------------------------------
function To_Vkm_Indices (length : in Vkm_Length) return Vkm_Indices is
(Vkm_Indices(Vkm_Length'Base(length) - 1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Length.
--<
--< @description
--< Convert a value of type Vkm_Indices to a value of type Vkm_Length.
--<
--< @param last_index
--< The index value to convert to a vector length.
--<
--< @return
--< The result of the conversion.
----------------------------------------------------------------------------
function To_Vkm_Length (last_index : in Vkm_Indices) return Vkm_Length is
(Vkm_Length(Vkm_Indices'Base(last_index) + 1)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Bool.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Bool type.
--
--< If the value is not equal to zero, returns true; Otherwise returns false.
--
--< @param value The value to convert to Vkm_Bool.
--
--< @return The conversion to Vkm_Bool.
----------------------------------------------------------------------------
function To_Vkm_Bool (value : in Vkm_Uint ) return Vkm_Bool is
(Vkm_Bool(value /= 0)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Bool.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Bool type.
--
--< If the value is not equal to zero, returns true; Otherwise returns false.
--
--< @param value The value to convert to Vkm_Bool.
--
--< @return The conversion to Vkm_Bool.
----------------------------------------------------------------------------
function To_Vkm_Bool (value : in Vkm_Int ) return Vkm_Bool is
(Vkm_Bool(value /= 0)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Bool.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Bool type.
--
--< If the value is not equal to zero, returns true; Otherwise returns false.
--
--< @param value The value to convert to Vkm_Bool.
--
--< @return The conversion to Vkm_Bool.
----------------------------------------------------------------------------
function To_Vkm_Bool (value : in Vkm_Float ) return Vkm_Bool is
(Vkm_Bool(value /= 0.0)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Bool.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Bool type.
--
--< If the value is not equal to zero, returns true; Otherwise returns false.
--
--< @param value The value to convert to Vkm_Bool.
--
--< @return The conversion to Vkm_Bool.
----------------------------------------------------------------------------
function To_Vkm_Bool (value : in Vkm_Double) return Vkm_Bool is
(Vkm_Bool(value /= 0.0)) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Uint.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Uint type.
--
--< If value is true returns 1; Otherwise returns 0.
--
--< @param value The value to convert
--
--< @return The conversion to Vkm_Uint.
----------------------------------------------------------------------------
function To_Vkm_Uint (value : in Vkm_Bool ) return Vkm_Uint is
(if value then 1 else 0) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Uint.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Uint type.
--
--< Conversion from Vkm_Int preserves the bit pattern of the argument, modifying
--< the value of negative arguments.
--
--< @return The conversion to Vkm_Uint.
----------------------------------------------------------------------------
function To_Vkm_Uint is new Ada.Unchecked_Conversion(Source => Vkm_Int, Target => Vkm_Uint);
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Uint.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Uint type.
--
--< @param value The value to convert to Vkm_Uint.
--
--< @return The conversion to Vkm_Uint.
----------------------------------------------------------------------------
function To_Vkm_Uint (value : in Vkm_Float ) return Vkm_Uint is
(Vkm_Uint(Vkm_Float'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Uint.
--<
--< @description
--< Convert a vulkan math type to the Vkm_Uint type.
--
--< @param value The value to convert to Vkm_Uint.
--
--< @return The conversion to Vkm_Uint.
----------------------------------------------------------------------------
function To_Vkm_Uint (value : in Vkm_Double) return Vkm_Uint is
(Vkm_Uint(Vkm_Double'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Int.
--<
--< @description
--< Convert various VKM Math types to the Vkm_Int type.
--
--< @param value The value to convert to Vkm_Int.
--
--< @return The conversion to Vkm_Int.
----------------------------------------------------------------------------
function To_Vkm_Int (value : in Vkm_Bool ) return Vkm_Int is
(if value then 1 else 0) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Int.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Int
--< math types.
--
--< Conversion from Vkm_Uint preserves the bit pattern of the argument,
--< causing the values of very large unsigned integer to change due to the
--< sign bit being set.
--
--< @return The conversion to Vkm_Int.
----------------------------------------------------------------------------
function To_Vkm_Int is new Ada.Unchecked_Conversion(Source => Vkm_Uint, Target => Vkm_Int);
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Int.
--<
--< @description
--< Convert various VKM Math types to the Vkm_Int type.
--
--< @param value The value to convert to Vkm_Int.
--
--< @return The conversion to Vkm_Int.
----------------------------------------------------------------------------
function To_Vkm_Int (value : in Vkm_Float ) return Vkm_Int is
(Vkm_Int(Vkm_Float'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Int.
--<
--< @description
--< Convert various VKM Math types to the Vkm_Int type.
--
--< @param value The value to convert to Vkm_Int.
--
--< @return The conversion to Vkm_Int.
----------------------------------------------------------------------------
function To_Vkm_Int (value : in Vkm_Double) return Vkm_Int is
(Vkm_Int(Vkm_Double'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Float.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Float
--< math types.
--
--< @param value The value to convert to Vkm_Float.
--
--< @return The conversion to Vkm_Float.
----------------------------------------------------------------------------
function To_Vkm_Float (value : in Vkm_Bool ) return Vkm_Float is
(if value then 1.0 else 0.0) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Float.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Float
--< math types.
--
--< @param value The value to convert to Vkm_Float.
--
--< @return The conversion to Vkm_Float.
----------------------------------------------------------------------------
function To_Vkm_Float (value : in Vkm_Uint ) return Vkm_Float is
(Vkm_Float(Vkm_Uint'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Float.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Float
--< math types.
--
--< @param value The value to convert to Vkm_Float.
--
--< @return The conversion to Vkm_Float.
----------------------------------------------------------------------------
function To_Vkm_Float (value : in Vkm_Int ) return Vkm_Float is
(Vkm_Float(Vkm_Int'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Float.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Float
--< math types.
--
--< @param value The value to convert to Vkm_Float.
--
--< @return The conversion to Vkm_Float.
----------------------------------------------------------------------------
function To_Vkm_Float (value : in Vkm_Double) return Vkm_Float is
(Vkm_Float(Vkm_Double'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Float.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Double
--< math types.
--
--< @param value The value to convert to Vkm_Double.
--
--< @return The conversion to Vkm_Double.
----------------------------------------------------------------------------
function To_Vkm_Double (value : in Vkm_Bool ) return Vkm_Double is
(if value then 1.0 else 0.0) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Double.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Double
--< math types.
--
--< @param value The value to convert to Vkm_Double.
--
--< @return The conversion to Vkm_Double.
----------------------------------------------------------------------------
function To_Vkm_Double (value : in Vkm_Uint ) return Vkm_Double is
(Vkm_Double(Vkm_Uint'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Double.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Double
--< math types.
--
--< @param value The value to convert to Vkm_Double.
--
--< @return The conversion to Vkm_Double.
----------------------------------------------------------------------------
function To_Vkm_Double (value : in Vkm_Int ) return Vkm_Double is
(Vkm_Double(Vkm_Int'Base(value))) with Inline;
----------------------------------------------------------------------------
--< @summary
--< Convert to Vkm_Double.
--<
--< @description
--< The following operations convert various VKM Math types to Vkm_Double
--< math types.
--
--< @param value The value to convert to Vkm_Double.
--
--< @return The conversion to Vkm_Double.
----------------------------------------------------------------------------
function To_Vkm_Double (value : in Vkm_Float) return Vkm_Double is
(Vkm_Double(Vkm_Float'Base(value))) with Inline;
----------------------------------------------------------------------------
-- Operator override definitions
----------------------------------------------------------------------------
function "-" (instance : in Vkm_Bool) return Vkm_Bool is
(not instance) with inline;
function "+" (left, right : in Vkm_Bool) return Vkm_Bool is
(left xor right) with inline;
function "-" (left, right : in Vkm_Bool) return Vkm_Bool is
(left xor right) with inline;
function "*" (left, right : in Vkm_Bool) return Vkm_Bool is
(left and right) with inline;
----------------------------------------------------------------------------
function "abs" (x : in Vkm_Float ) return Vkm_Float is
(if x >= 0.0 then x else -x) with Inline;
function Floor (x : in Vkm_Float) return Vkm_Float renames Vkm_Float'Floor;
function "mod" (x, y : in Vkm_Float) return Vkm_Float is
(x - y * Floor(x / y)) with Inline;
function Exp (x : in Vkm_Float) return Vkm_Float
renames VKM_FLT_NEF.Exp;
function "**" (x, y : in Vkm_Float) return Vkm_Float
renames VKM_FLT_NEF."**";
----------------------------------------------------------------------------
function "abs" (x : in Vkm_Double ) return Vkm_Double is
(if x >= 0.0 then x else -x) with Inline;
function Floor (x : in Vkm_Double) return Vkm_Double renames Vkm_Double'Floor;
function "mod" (x, y : in Vkm_Double) return Vkm_Double is
(x - y * Floor(x / y)) with Inline;
function Exp (x : in Vkm_Double) return Vkm_Double
renames VKM_DBL_NEF.Exp;
function "**" (x, y : in Vkm_Double) return Vkm_Double
renames VKM_DBL_NEF."**";
end Vulkan.Math;
|
sungyeon/drake | Ada | 6,396 | ads | pragma License (Unrestricted);
-- implementation unit specialized for Darwin
with Ada.IO_Exceptions;
with Ada.Streams;
with C.icucore;
package System.Native_Environment_Encoding is
-- Platform-depended text encoding.
pragma Preelaborate;
use type C.char_array;
use type C.size_t;
-- max length of one multi-byte character
Max_Substitute_Length : constant := 6; -- UTF-8
-- encoding identifier
type Encoding_Id is access constant C.char;
for Encoding_Id'Storage_Size use 0;
function Get_Image (Encoding : Encoding_Id) return String;
function Get_Default_Substitute (Encoding : Encoding_Id)
return Ada.Streams.Stream_Element_Array;
function Get_Min_Size_In_Stream_Elements (Encoding : Encoding_Id)
return Ada.Streams.Stream_Element_Offset;
UTF_8_Name : aliased constant C.char_array (0 .. 5) :=
"UTF-8" & C.char'Val (0);
UTF_8 : constant Encoding_Id := UTF_8_Name (0)'Access;
UTF_16_Names : aliased constant
array (Bit_Order) of aliased C.char_array (0 .. 8) := (
High_Order_First => "UTF-16BE" & C.char'Val (0),
Low_Order_First => "UTF-16LE" & C.char'Val (0));
UTF_16 : constant Encoding_Id := UTF_16_Names (Default_Bit_Order)(0)'Access;
UTF_16BE : constant Encoding_Id :=
UTF_16_Names (High_Order_First)(0)'Access;
UTF_16LE : constant Encoding_Id :=
UTF_16_Names (Low_Order_First)(0)'Access;
UTF_32_Names : aliased constant
array (Bit_Order) of aliased C.char_array (0 .. 8) := (
High_Order_First => "UTF-32BE" & C.char'Val (0),
Low_Order_First => "UTF-32LE" & C.char'Val (0));
UTF_32 : constant Encoding_Id := UTF_32_Names (Default_Bit_Order)(0)'Access;
UTF_32BE : constant Encoding_Id :=
UTF_32_Names (High_Order_First)(0)'Access;
UTF_32LE : constant Encoding_Id :=
UTF_32_Names (Low_Order_First)(0)'Access;
function Get_Current_Encoding return Encoding_Id;
-- Returns UTF-8. In POSIX, The system encoding is assumed as UTF-8.
pragma Inline (Get_Current_Encoding);
-- subsidiary types to converter
type Subsequence_Status_Type is (
Finished,
Success,
Overflow, -- the output buffer is not large enough
Illegal_Sequence, -- a input character could not be mapped to the output
Truncated); -- the input buffer is broken off at a multi-byte character
pragma Discard_Names (Subsequence_Status_Type);
type Continuing_Status_Type is
new Subsequence_Status_Type range
Success ..
Subsequence_Status_Type'Last;
type Finishing_Status_Type is
new Subsequence_Status_Type range
Finished ..
Overflow;
type Status_Type is
new Subsequence_Status_Type range
Finished ..
Illegal_Sequence;
type Substituting_Status_Type is
new Status_Type range
Finished ..
Overflow;
subtype True_Only is Boolean range True .. True;
-- converter
Half_Buffer_Length : constant :=
64 / (C.icucore.UChar'Size / Standard'Storage_Unit);
subtype Buffer_Type is
C.icucore.UChar_array (0 .. 2 * Half_Buffer_Length - 1);
type Converter is record
-- about "From"
From_uconv : C.icucore.UConverter_ptr := null;
-- intermediate
Buffer : Buffer_Type;
Buffer_First : aliased C.icucore.UChar_const_ptr;
Buffer_Limit : aliased C.icucore.UChar_ptr; -- Last + 1
-- about "To"
To_uconv : C.icucore.UConverter_ptr := null;
Substitute_Length : Ada.Streams.Stream_Element_Offset;
Substitute : Ada.Streams.Stream_Element_Array (
1 ..
Max_Substitute_Length);
end record;
pragma Suppress_Initialization (Converter);
Disable_Controlled : constant Boolean := False;
procedure Open (Object : in out Converter; From, To : Encoding_Id);
procedure Close (Object : in out Converter);
function Is_Open (Object : Converter) return Boolean;
pragma Inline (Is_Open);
function Min_Size_In_From_Stream_Elements_No_Check (Object : Converter)
return Ada.Streams.Stream_Element_Offset;
function Substitute_No_Check (Object : Converter)
return Ada.Streams.Stream_Element_Array;
procedure Set_Substitute_No_Check (
Object : in out Converter;
Substitute : Ada.Streams.Stream_Element_Array);
-- convert subsequence
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : Boolean;
Status : out Subsequence_Status_Type);
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Status : out Continuing_Status_Type);
procedure Convert_No_Check (
Object : Converter;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Finishing_Status_Type);
-- convert all character sequence
-- procedure Convert_No_Check (
-- Object : Converter;
-- Item : Ada.Streams.Stream_Element_Array;
-- Last : out Ada.Streams.Stream_Element_Offset;
-- Out_Item : out Ada.Streams.Stream_Element_Array;
-- Out_Last : out Ada.Streams.Stream_Element_Offset;
-- Finish : True_Only;
-- Status : out Status_Type);
-- convert all character sequence with substitute
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Substituting_Status_Type);
procedure Put_Substitute (
Object : Converter;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Is_Overflow : out Boolean);
-- exceptions
Name_Error : exception
renames Ada.IO_Exceptions.Name_Error;
Use_Error : exception
renames Ada.IO_Exceptions.Use_Error;
end System.Native_Environment_Encoding;
|
hhanff/software | Ada | 102 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line ("Hello WORLD!");
end Hello;
|
apple-oss-distributions/old_ncurses | Ada | 4,324 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_User_Data --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control:
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
-- |
-- |=====================================================================
-- | man page form_field_userptr.3x
-- |=====================================================================
-- |
package body Terminal_Interface.Curses.Forms.Field_User_Data is
-- |
-- |
-- |
use type Interfaces.C.int;
procedure Set_User_Data (Fld : in Field;
Data : in User_Access)
is
function Set_Field_Userptr (Fld : Field;
Usr : User_Access) return C_Int;
pragma Import (C, Set_Field_Userptr, "set_field_userptr");
Res : constant Eti_Error := Set_Field_Userptr (Fld, Data);
begin
if Res /= E_Ok then
Eti_Exception (Res);
end if;
end Set_User_Data;
-- |
-- |
-- |
function Get_User_Data (Fld : in Field) return User_Access
is
function Field_Userptr (Fld : Field) return User_Access;
pragma Import (C, Field_Userptr, "field_userptr");
begin
return Field_Userptr (Fld);
end Get_User_Data;
procedure Get_User_Data (Fld : in Field;
Data : out User_Access)
is
begin
Data := Get_User_Data (Fld);
end Get_User_Data;
end Terminal_Interface.Curses.Forms.Field_User_Data;
|
radekwlsk/concurrent-railroad-ada | Ada | 1,528 | ads | --
-- Radoslaw Kowalski 221454
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Calendar;
with Rails; use Rails;
package Trains is
package Calendar renames Ada.Calendar;
type Train (Route_Length: Integer) is
record
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array(1 .. Route_Length);
Index : Integer;
Att : Track_Ptr;
end record;
type Train_Ptr is access Train;
procedure Connection(Self: Train_Ptr; From, To : out Track_Ptr);
function Move_To(Self: Train_Ptr; T : Track_Ptr) return Float;
function As_String(Self: Train_Ptr) return String;
function As_Verbose_String(Self: Train_Ptr) return String;
type Trains_Array is array(Integer range<>) of Train_Ptr;
type Trains_Ptr is access Trains_Array;
function New_Train (
Id : Integer;
Name : SU.Unbounded_String;
Speed : Integer;
Capacity : Integer;
Route : Route_Array) return Train_Ptr;
task type Simulation is
entry Init(S : Calendar.Time; SPH : Integer; H : Integer; M : Integer; V : Boolean);
entry Simulate(T : in Train_Ptr; C : in Connections_Ptr);
end Simulation;
type Simulation_Ptr is access Simulation;
type Time_Component_Type is
delta 1.0 digits 2 range 0.0 .. 60.0;
end Trains;
|
igoratf/Hello-World | Ada | 96 | adb | with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello, world!");
end Hello; |
stcarrez/ada-awa | Ada | 6,406 | adb | -----------------------------------------------------------------------
-- awa-mail-components-factory -- Mail UI Component Factory
-- Copyright (C) 2012, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Views.Nodes;
with ASF.Components.Base;
with AWA.Mail.Modules;
with AWA.Mail.Components.Messages;
with AWA.Mail.Components.Recipients;
with AWA.Mail.Components.Attachments;
package body AWA.Mail.Components.Factory is
use ASF.Components.Base;
use ASF.Views.Nodes;
function Create_Bcc return UIComponent_Access;
function Create_Body return UIComponent_Access;
function Create_Cc return UIComponent_Access;
function Create_From return UIComponent_Access;
function Create_Message return UIComponent_Access;
function Create_To return UIComponent_Access;
function Create_Subject return UIComponent_Access;
function Create_Attachment return UIComponent_Access;
URI : aliased constant String := "http://code.google.com/p/ada-awa/mail";
BCC_TAG : aliased constant String := "bcc";
BODY_TAG : aliased constant String := "body";
CC_TAG : aliased constant String := "cc";
FROM_TAG : aliased constant String := "from";
MESSAGE_TAG : aliased constant String := "message";
SUBJECT_TAG : aliased constant String := "subject";
TO_TAG : aliased constant String := "to";
ATTACHMENT_TAG : aliased constant String := "attachment";
-- ------------------------------
-- Create an UIMailRecipient component
-- ------------------------------
function Create_Bcc return UIComponent_Access is
Result : constant Recipients.UIMailRecipient_Access := new Recipients.UIMailRecipient;
begin
Result.Set_Recipient (AWA.Mail.Clients.BCC);
return Result.all'Access;
end Create_Bcc;
-- ------------------------------
-- Create an UIMailBody component
-- ------------------------------
function Create_Body return UIComponent_Access is
begin
return new Messages.UIMailBody;
end Create_Body;
-- ------------------------------
-- Create an UIMailRecipient component
-- ------------------------------
function Create_Cc return UIComponent_Access is
Result : constant Recipients.UIMailRecipient_Access := new Recipients.UIMailRecipient;
begin
Result.Set_Recipient (AWA.Mail.Clients.CC);
return Result.all'Access;
end Create_Cc;
-- ------------------------------
-- Create an UISender component
-- ------------------------------
function Create_From return UIComponent_Access is
begin
return new Recipients.UISender;
end Create_From;
-- ------------------------------
-- Create an UIMailMessage component
-- ------------------------------
function Create_Message return UIComponent_Access is
use type AWA.Mail.Modules.Mail_Module_Access;
Result : constant Messages.UIMailMessage_Access := new Messages.UIMailMessage;
Module : constant AWA.Mail.Modules.Mail_Module_Access := AWA.Mail.Modules.Get_Mail_Module;
begin
if Module = null then
return null;
end if;
Result.Set_Message (Module.Create_Message);
return Result.all'Access;
end Create_Message;
-- ------------------------------
-- Create an UIMailSubject component
-- ------------------------------
function Create_Subject return UIComponent_Access is
begin
return new Messages.UIMailSubject;
end Create_Subject;
-- ------------------------------
-- Create an UIMailRecipient component
-- ------------------------------
function Create_To return UIComponent_Access is
begin
return new Recipients.UIMailRecipient;
end Create_To;
-- ------------------------------
-- Create an UIMailAttachment component
-- ------------------------------
function Create_Attachment return UIComponent_Access is
begin
return new Attachments.UIMailAttachment;
end Create_Attachment;
Bindings : aliased constant ASF.Factory.Binding_Array
:= (1 => (Name => ATTACHMENT_TAG'Access,
Component => Create_Attachment'Access,
Tag => Create_Component_Node'Access),
2 => (Name => BCC_TAG'Access,
Component => Create_Bcc'Access,
Tag => Create_Component_Node'Access),
3 => (Name => BODY_TAG'Access,
Component => Create_Body'Access,
Tag => Create_Component_Node'Access),
4 => (Name => CC_TAG'Access,
Component => Create_Cc'Access,
Tag => Create_Component_Node'Access),
5 => (Name => FROM_TAG'Access,
Component => Create_From'Access,
Tag => Create_Component_Node'Access),
6 => (Name => MESSAGE_TAG'Access,
Component => Create_Message'Access,
Tag => Create_Component_Node'Access),
7 => (Name => SUBJECT_TAG'Access,
Component => Create_Subject'Access,
Tag => Create_Component_Node'Access),
8 => (Name => TO_TAG'Access,
Component => Create_To'Access,
Tag => Create_Component_Node'Access)
);
Mail_Factory : aliased constant ASF.Factory.Factory_Bindings
:= (URI => URI'Access, Bindings => Bindings'Access);
-- ------------------------------
-- Get the AWA Mail component factory.
-- ------------------------------
function Definition return ASF.Factory.Factory_Bindings_Access is
begin
return Mail_Factory'Access;
end Definition;
end AWA.Mail.Components.Factory;
|
tum-ei-rcs/StratoX | Ada | 1,339 | ads | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Martin Becker ([email protected])
with Units; use Units;
-- @summary
-- Interface to use a buzzer/beeper.
package Buzzer_Manager with SPARK_Mode is
-- subtype T_Name is Character
-- with Static_Predicate => T_Name in 'a' .. 'g'; -- c,d,e,f,g,a,b
-- subtype T_Octave is Integer range 3 .. 8;
-- type Tone_Type is record
-- name : T_Name;
-- octave : T_Octave; -- 3=small octave
-- end record;
-- -- A4 = 440Hz
--
-- type Song_Type is array (Positive range <>) of Tone_Type;
procedure Initialize;
procedure Tick;
-- call this periodically to manage the buzzer
function Valid_Frequency (f : Frequency_Type) return Boolean is
(f > 0.0 * Hertz);
-- procedure Set_Tone (t : Tone_Type);
--
-- function Tone_To_Frequency (tone : Tone_Type) return Frequency_Type;
-- -- compute the frequency for the given tone name.
-- -- Examples:
-- -- a' => 400
procedure Beep
(f : in Frequency_Type;
Reps : Natural;
Period : Time_Type;
Length : in Time_Type);
-- beep given number of times. If reps = 0, then infinite.
private
procedure Reconfigure_Buzzer;
end Buzzer_Manager;
|
AdaCore/ada-traits-containers | Ada | 16,051 | adb | --
-- Copyright (C) 2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
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;
|
sungyeon/drake | Ada | 1,475 | adb | pragma Check_Policy (Validate => Disable);
with Ada.Strings.Naked_Maps.Canonical_Composites;
-- with Ada.Strings.Naked_Maps.Debug;
with Ada.Strings.Naked_Maps.Set_Constants;
with System.Once;
with System.Reference_Counting;
package body Ada.Strings.Naked_Maps.Basic is
-- Basic_Set
type Character_Set_Access_With_Pool is access Character_Set_Data;
Basic_Set_Data : Character_Set_Access_With_Pool;
Basic_Set_Flag : aliased System.Once.Flag := 0;
procedure Basic_Set_Init;
procedure Basic_Set_Init is
Letter_Set : constant not null Character_Set_Access :=
Set_Constants.Letter_Set;
Base_Set : constant not null Character_Set_Access :=
Canonical_Composites.Base_Set;
Ranges : Character_Ranges (1 .. Letter_Set.Length + Base_Set.Length);
Ranges_Last : Natural;
begin
Intersection (Ranges, Ranges_Last, Letter_Set.Items, Base_Set.Items);
Basic_Set_Data := new Character_Set_Data'(
Length => Ranges_Last,
Reference_Count => System.Reference_Counting.Static,
Items => Ranges (1 .. Ranges_Last));
pragma Check (Validate, Debug.Valid (Basic_Set_Data.all));
end Basic_Set_Init;
-- implementation of Basic_Set
function Basic_Set return not null Character_Set_Access is
begin
System.Once.Initialize (Basic_Set_Flag'Access, Basic_Set_Init'Access);
return Character_Set_Access (Basic_Set_Data);
end Basic_Set;
end Ada.Strings.Naked_Maps.Basic;
|
Componolit/libsparkcrypto | Ada | 3,233 | adb | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 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.Unchecked_Conversion;
package body LSC.Internal.Types
with SPARK_Mode => Off
is
function Word32_To_Byte_Array32 (Value : Word32) return Byte_Array32_Type
is
function W322W8A is new Ada.Unchecked_Conversion
(Word32, Byte_Array32_Type);
begin
return W322W8A (Value);
end Word32_To_Byte_Array32;
----------------------------------------------------------------------------
function Byte_Array32_To_Word32 (Value : Byte_Array32_Type) return Word32
is
function W8A2W32 is new Ada.Unchecked_Conversion
(Byte_Array32_Type, Word32);
begin
return W8A2W32 (Value);
end Byte_Array32_To_Word32;
----------------------------------------------------------------------------
function Word64_To_Byte_Array64 (Value : Word64) return Byte_Array64_Type
is
function W642W8A is new Ada.Unchecked_Conversion
(Word64, Byte_Array64_Type);
begin
return W642W8A (Value);
end Word64_To_Byte_Array64;
----------------------------------------------------------------------------
function Byte_Array64_To_Word64 (Value : Byte_Array64_Type) return Word64
is
function W8A2W64 is new Ada.Unchecked_Conversion
(Byte_Array64_Type, Word64);
begin
return W8A2W64 (Value);
end Byte_Array64_To_Word64;
end LSC.Internal.Types;
|
io7m/coreland-c_string | Ada | 3,101 | adb | with Ada.Strings.Unbounded;
with Ada.Text_IO;
with C_String.Arrays;
with Interfaces.C;
with Test;
procedure t_Index2 is
package c renames Interfaces.C;
package IO renames Ada.Text_IO;
package UStrings renames Ada.Strings.Unbounded;
function ccall_size return c.int;
pragma Import (c, ccall_size, "ccall_size");
function ccall return C_String.Arrays.Pointer_Array_t;
pragma Import (c, ccall, "ccall");
begin
IO.Put_Line ("-- Ada begin");
declare
Address : constant C_String.Arrays.Pointer_Array_t := ccall;
begin
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 0, Size => Natural (ccall_size))) = "abcdefgh",
Pass_Message => "Tab (0) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 0, Size => Natural (ccall_size))),
Fail_Message => "Tab (0) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 0, Size => Natural (ccall_size))));
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 1, Size => Natural (ccall_size))) = "zyxwvuts",
Pass_Message => "Tab (1) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 1, Size => Natural (ccall_size))),
Fail_Message => "Tab (1) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 1, Size => Natural (ccall_size))));
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 2, Size => Natural (ccall_size))) = "12345678",
Pass_Message => "Tab (2) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 2, Size => Natural (ccall_size))),
Fail_Message => "Tab (2) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 2, Size => Natural (ccall_size))));
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 3, Size => Natural (ccall_size))) = "klmnopqr",
Pass_Message => "Tab (3) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 3, Size => Natural (ccall_size))),
Fail_Message => "Tab (3) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 3, Size => Natural (ccall_size))));
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 4, Size => Natural (ccall_size))) = "@@@@@@@@",
Pass_Message => "Tab (4) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 4, Size => Natural (ccall_size))),
Fail_Message => "Tab (4) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 4, Size => Natural (ccall_size))));
Test.Assert
(Check => UStrings.To_String (C_String.Arrays.Index (Address, Index => 5, Size => Natural (ccall_size))) = "&&&&&&&&",
Pass_Message => "Tab (5) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 5, Size => Natural (ccall_size))),
Fail_Message => "Tab (5) = " & UStrings.To_String (C_String.Arrays.Index (Address, Index => 5, Size => Natural (ccall_size))));
end;
IO.Put_Line ("-- Ada exit");
end t_Index2;
|
DrenfongWong/tkm-rpc | Ada | 724 | adb | with Tkmrpc.Servers.Ike;
with Tkmrpc.Response.Ike.Tkm_Version.Convert;
package body Tkmrpc.Operation_Handlers.Ike.Tkm_Version is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
pragma Unreferenced (Req);
Specific_Res : Response.Ike.Tkm_Version.Response_Type;
begin
Specific_Res := Response.Ike.Tkm_Version.Null_Response;
Servers.Ike.Tkm_Version
(Result => Specific_Res.Header.Result,
Version => Specific_Res.Data.Version);
Res := Response.Ike.Tkm_Version.Convert.To_Response (S => Specific_Res);
end Handle;
end Tkmrpc.Operation_Handlers.Ike.Tkm_Version;
|
zhmu/ananas | Ada | 3,310 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . P O L L . W A I T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Wait implementation on top of native poll call
--
-- This submodule can be used on systems where poll system call is natively
-- supported. Microsoft Windows supports WSAPoll system call from Vista
-- version and this submodule can be used on such Windows versions too, the
-- System.OS_Constants.Poll_Linkname constant defines appropriate link name
-- for Windows. But we do not use WSAPoll in GNAT.Sockets.Poll implementation
-- for now because it is much slower than select system call, at least in
-- Windows version 10.0.18363.1016.
separate (GNAT.Sockets.Poll)
procedure Wait
(Fds : in out Set; Timeout : Interfaces.C.int; Result : out Integer)
is
function Poll
(Fds : Poll_Set;
Nfds : nfds_t;
Timeout : Interfaces.C.int) return Integer
with Import, Convention => Stdcall, External_Name => SOC.Poll_Linkname;
begin
Result := Poll (Fds.Fds, nfds_t (Fds.Length), Timeout);
end Wait;
|
tum-ei-rcs/StratoX | Ada | 3,273 | ads | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Martin Becker ([email protected])
with Interfaces;
with HIL;
-- @summary
-- Implements a serialization of log objects (records,
-- string messages, etc.) according to the self-describing
-- ULOG file format used in PX4.
-- The serialized byte array is returned.
--
-- We cannot make this abstract, because it would require
-- access types to use polymorphism, and that's not SPARK.
package ULog with SPARK_Mode is
-- root type/base class for polymorphism. all visible to clients.
type Message is tagged record
Timestamp : Interfaces.Unsigned_64 := 0;
Length : Interfaces.Unsigned_16 := 0;
end record;
---------------------------------------------------------------------
-- Non-Primitive operations --
-- (not inherited; available for all members of class-wide type) --
---------------------------------------------------------------------
procedure Serialize (msg : in Message'Class; bytes : out HIL.Byte_Array);
-- turn object into ULOG byte array
-- indefinite argument (class-wide type)
-- FIXME: maybe overload attribute Output?
procedure Format (msg : in Message'Class; bytes : out HIL.Byte_Array);
-- turn object's format description into ULOG byte array
procedure Get_Header (bytes : out HIL.Byte_Array);
-- every ULOG file starts with a header, which is generated here
-- for all known message types
procedure Describe (msg : in Message'Class; namestring : out String); -- is abstract
-- return a readable string identifying message type
function Describe_Func (msg : in Message'Class) return String;
-- same as above, but as function. REquired because of string.
function Size (msg : in Message'Class)
return Interfaces.Unsigned_16; -- is abstract;
-- return length of serialized object in bytes
-- Note that this has nothing to do with the size of the struct, since
-- the representation in ULOG format may be different.
------------------------------------
-- Primitive operations --
-- (inherited in Message'Class) --
------------------------------------
-- those are NOT dispatched
private
function Self (msg : in Message) return ULog.Message'Class;
-- factory function to convert to specific child view
--------------------------------------------
-- Primitive operations --
-- (inherited by types in Message'Class) --
--------------------------------------------
procedure Get_Serialization (msg : in Message; bytes : out HIL.Byte_Array);
-- the actual serialization
function Get_Size (msg : in Message) return Interfaces.Unsigned_16;
procedure Get_Format
(msg : in Message;
bytes : out HIL.Byte_Array); -- is abstract
-- for a specific message type, generate the FMT header.
--
-- FIXME: we actually don't need an instance of the message.
-- Actually we want the equivalent to a static member function
-- in C++. Maybe a type attribute?
--
-- FIXME: we want it private, but abstract does not support this.
end ULog;
|
MinimSecure/unum-sdk | Ada | 858 | adb | -- Copyright 2008-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
My_Circle : Circle := (Pos => (1, 2), Radius => 3);
begin
Do_Nothing (My_Circle); -- STOP
end Foo;
|
sparre/Command-Line-Parser-Generator | Ada | 792 | adb | -- Copyright: JSA Research & Innovation <[email protected]>
-- License: Beer Ware
pragma License (Unrestricted);
with Ada.Strings.Wide_Unbounded;
package body Command_Line_Parser_Generator.Formal_Parameter is
function Has_Default_Value (Item : in Instance) return Boolean is
use Ada.Strings.Wide_Unbounded;
begin
return Item.Default_Value /= Null_Unbounded_Wide_String;
end Has_Default_Value;
function Image (Item : in Instance) return Wide_String is
begin
if Item.Has_Default_Value then
return +Item.Name & " : in " & (+Item.Type_Name) &
" := " & (+Item.Default_Value);
else
return +Item.Name & " : in " & (+Item.Type_Name);
end if;
end Image;
end Command_Line_Parser_Generator.Formal_Parameter;
|
reznikmm/matreshka | Ada | 4,551 | 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_Dr3d.Vrp_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Dr3d_Vrp_Attribute_Node is
begin
return Self : Dr3d_Vrp_Attribute_Node do
Matreshka.ODF_Dr3d.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Dr3d_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Dr3d_Vrp_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Vrp_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Dr3d_URI,
Matreshka.ODF_String_Constants.Vrp_Attribute,
Dr3d_Vrp_Attribute_Node'Tag);
end Matreshka.ODF_Dr3d.Vrp_Attributes;
|
juergenpf/ncurses-snapshots | Ada | 9,009 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Menu_Demo.Aux --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020,2023 Thomas E. Dickey --
-- Copyright 1998-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: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.16 $
-- $Date: 2023/06/17 17:21:59 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Sample.Manifest; use Sample.Manifest;
with Sample.Helpers; use Sample.Helpers;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Explanation; use Sample.Explanation;
package body Sample.Menu_Demo.Aux is
procedure Geometry (M : Menu;
L : out Line_Count;
C : out Column_Count;
Y : out Line_Position;
X : out Column_Position;
Fy : out Line_Position;
Fx : out Column_Position);
procedure Geometry (M : Menu;
L : out Line_Count; -- Lines used for menu
C : out Column_Count; -- Columns used for menu
Y : out Line_Position; -- Proposed Line for menu
X : out Column_Position; -- Proposed Column for menu
Fy : out Line_Position; -- Vertical inner frame
Fx : out Column_Position) -- Horiz. inner frame
is
Spc_Desc : Column_Position; -- spaces between description and item
begin
Set_Mark (M, Menu_Marker);
Spacing (M, Spc_Desc, Fy, Fx);
Scale (M, L, C);
Fx := Fx + Column_Position (Fy - 1); -- looks a bit nicer
L := L + 2 * Fy; -- count for frame at top and bottom
C := C + 2 * Fx; -- "
-- Calculate horizontal coordinate at the screen center
X := (Columns - C) / 2;
Y := 1; -- always starting on line 1
end Geometry;
procedure Geometry (M : Menu;
L : out Line_Count; -- Lines used for menu
C : out Column_Count; -- Columns used for menu
Y : out Line_Position; -- Proposed Line for menu
X : out Column_Position) -- Proposed Column for menu
is
Fy : Line_Position;
Fx : Column_Position;
begin
Geometry (M, L, C, Y, X, Fy, Fx);
end Geometry;
function Create (M : Menu;
Title : String;
Lin : Line_Position;
Col : Column_Position) return Panel
is
W, S : Window;
L : Line_Count;
C : Column_Count;
Y, Fy : Line_Position;
X, Fx : Column_Position;
Pan : Panel;
begin
Geometry (M, L, C, Y, X, Fy, Fx);
W := New_Window (L, C, Lin, Col);
Set_Meta_Mode (W);
Set_KeyPad_Mode (W);
if Has_Colors then
Set_Background (Win => W,
Ch => (Ch => ' ',
Color => Menu_Back_Color,
Attr => Normal_Video));
Set_Foreground (Men => M, Color => Menu_Fore_Color);
Set_Background (Men => M, Color => Menu_Back_Color);
Set_Grey (Men => M, Color => Menu_Grey_Color);
Erase (W);
end if;
S := Derived_Window (W, L - Fy, C - Fx, Fy, Fx);
Set_Meta_Mode (S);
Set_KeyPad_Mode (S);
Box (W);
Set_Window (M, W);
Set_Sub_Window (M, S);
if Title'Length > 0 then
Window_Title (W, Title);
end if;
Pan := New_Panel (W);
Post (M);
return Pan;
end Create;
procedure Destroy (M : Menu;
P : in out Panel)
is
W, S : Window;
begin
W := Get_Window (M);
S := Get_Sub_Window (M);
Post (M, False);
Erase (W);
Delete (P);
Set_Window (M, Null_Window);
Set_Sub_Window (M, Null_Window);
Delete (S);
Delete (W);
Update_Panels;
end Destroy;
function Get_Request (M : Menu; P : Panel) return Key_Code
is
W : constant Window := Get_Window (M);
K : Real_Key_Code;
Ch : Character;
begin
Top (P);
loop
K := Get_Key (W);
if K in Special_Key_Code'Range then
case K is
when HELP_CODE => Explain_Context;
when EXPLAIN_CODE => Explain ("MENUKEYS");
when Key_Home => return REQ_FIRST_ITEM;
when QUIT_CODE => return QUIT;
when Key_Cursor_Down => return REQ_DOWN_ITEM;
when Key_Cursor_Up => return REQ_UP_ITEM;
when Key_Cursor_Left => return REQ_LEFT_ITEM;
when Key_Cursor_Right => return REQ_RIGHT_ITEM;
when Key_End => return REQ_LAST_ITEM;
when Key_Backspace => return REQ_BACK_PATTERN;
when Key_Next_Page => return REQ_SCR_DPAGE;
when Key_Previous_Page => return REQ_SCR_UPAGE;
when others => return K;
end case;
elsif K in Normal_Key_Code'Range then
Ch := Character'Val (K);
case Ch is
when CAN => return QUIT; -- CTRL-X
when SO => return REQ_NEXT_ITEM; -- CTRL-N
when DLE => return REQ_PREV_ITEM; -- CTRL-P
when NAK => return REQ_SCR_ULINE; -- CTRL-U
when EOT => return REQ_SCR_DLINE; -- CTRL-D
when ACK => return REQ_SCR_DPAGE; -- CTRL-F
when STX => return REQ_SCR_UPAGE; -- CTRL-B
when EM => return REQ_CLEAR_PATTERN; -- CTRL-Y
when BS => return REQ_BACK_PATTERN; -- CTRL-H
when SOH => return REQ_NEXT_MATCH; -- CTRL-A
when ENQ => return REQ_PREV_MATCH; -- CTRL-E
when DC4 => return REQ_TOGGLE_ITEM; -- CTRL-T
when CR | LF => return SELECT_ITEM;
when others => return K;
end case;
else
return K;
end if;
end loop;
end Get_Request;
end Sample.Menu_Demo.Aux;
|
stcarrez/ada-asf | Ada | 2,982 | ads | -----------------------------------------------------------------------
-- asf-events-faces-actions -- Actions Events
-- Copyright (C) 2010, 2011, 2012, 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 Util.Events;
with Ada.Strings.Unbounded;
with EL.Expressions;
with EL.Methods.Proc_1;
with ASF.Contexts.Faces;
with ASF.Components.Base;
package ASF.Events.Faces.Actions is
package Action_Method is
new EL.Methods.Proc_1 (Param1_Type => Ada.Strings.Unbounded.Unbounded_String);
-- ------------------------------
-- Action event
-- ------------------------------
-- The <b>Action_Event</b> is posted when a method bean action must be executed
-- as a result of a command (such as button press). The method action must return
-- an outcome string that indicates which view to return.
type Action_Event is new Faces_Event with private;
type Action_Event_Access is access all Action_Event'Class;
-- Get the method expression to invoke
function Get_Method (Event : in Action_Event) return EL.Expressions.Method_Expression;
-- Get the method binding with the Ada bean object to invoke.
function Get_Method_Info (Event : in Action_Event;
Context : in Contexts.Faces.Faces_Context'Class)
return EL.Expressions.Method_Info;
-- Post an <b>Action_Event</b> on the component.
procedure Post_Event (UI : in out Components.Base.UIComponent'Class;
Method : in EL.Expressions.Method_Expression);
-- ------------------------------
-- Action Listener
-- ------------------------------
-- The <b>Action_Listener</b> is the interface to receive the <b>Action_Event</b>.
type Action_Listener is limited interface and Util.Events.Event_Listener;
type Action_Listener_Access is access all Action_Listener'Class;
-- Process the action associated with the action event.
procedure Process_Action (Listener : in Action_Listener;
Event : in Action_Event'Class;
Context : in out Contexts.Faces.Faces_Context'Class) is abstract;
private
type Action_Event is new Faces_Event with record
Method : EL.Expressions.Method_Expression;
end record;
end ASF.Events.Faces.Actions;
|
reznikmm/matreshka | Ada | 3,704 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Comment_Attributes is
pragma Preelaborate;
type ODF_Table_Comment_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Comment_Attribute_Access is
access all ODF_Table_Comment_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Comment_Attributes;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 1,930 | ads | -- This package was generated by the Ada_Drivers_Library project wizard script
package ADL_Config is
Vendor : constant String := "STMicro"; -- From board definition
Max_Mount_Points : constant := 2; -- From default value
Max_Mount_Name_Length : constant := 128; -- From default value
Runtime_Profile : constant String := "ravenscar-full"; -- From command line
Device_Name : constant String := "STM32F405RGTx"; -- From board definition
Device_Family : constant String := "STM32F4"; -- From board definition
Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition
Runtime_Name : constant String := "ravenscar-full-stm32f4"; -- From default value
Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition
CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition
Board : constant String := "Crazyflie"; -- From command line
Has_ZFP_Runtime : constant String := "False"; -- From board definition
Number_Of_Interrupts : constant := 0; -- From default value
High_Speed_External_Clock : constant := 8000000; -- From board definition
Use_Startup_Gen : constant Boolean := False; -- From command line
Max_Path_Length : constant := 1024; -- From default value
Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition
Architecture : constant String := "ARM"; -- From board definition
end ADL_Config;
|
rguilloteau/pok | Ada | 617 | ads | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2020 POK team
pragma No_Run_Time;
with APEX;
use APEX;
with APEX.Timing;
use APEX.Timing;
with Interfaces.C;
package Activity is
procedure Thr1_Job;
end Activity;
|
reznikmm/matreshka | Ada | 4,965 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.Utp.Determ_Alts.Collections is
pragma Preelaborate;
package Utp_Determ_Alt_Collections is
new AMF.Generic_Collections
(Utp_Determ_Alt,
Utp_Determ_Alt_Access);
type Set_Of_Utp_Determ_Alt is
new Utp_Determ_Alt_Collections.Set with null record;
Empty_Set_Of_Utp_Determ_Alt : constant Set_Of_Utp_Determ_Alt;
type Ordered_Set_Of_Utp_Determ_Alt is
new Utp_Determ_Alt_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Utp_Determ_Alt : constant Ordered_Set_Of_Utp_Determ_Alt;
type Bag_Of_Utp_Determ_Alt is
new Utp_Determ_Alt_Collections.Bag with null record;
Empty_Bag_Of_Utp_Determ_Alt : constant Bag_Of_Utp_Determ_Alt;
type Sequence_Of_Utp_Determ_Alt is
new Utp_Determ_Alt_Collections.Sequence with null record;
Empty_Sequence_Of_Utp_Determ_Alt : constant Sequence_Of_Utp_Determ_Alt;
private
Empty_Set_Of_Utp_Determ_Alt : constant Set_Of_Utp_Determ_Alt
:= (Utp_Determ_Alt_Collections.Set with null record);
Empty_Ordered_Set_Of_Utp_Determ_Alt : constant Ordered_Set_Of_Utp_Determ_Alt
:= (Utp_Determ_Alt_Collections.Ordered_Set with null record);
Empty_Bag_Of_Utp_Determ_Alt : constant Bag_Of_Utp_Determ_Alt
:= (Utp_Determ_Alt_Collections.Bag with null record);
Empty_Sequence_Of_Utp_Determ_Alt : constant Sequence_Of_Utp_Determ_Alt
:= (Utp_Determ_Alt_Collections.Sequence with null record);
end AMF.Utp.Determ_Alts.Collections;
|
egustafson/sandbox | Ada | 501 | ads | with Ada.Finalization;
package Obj is
type Obj_T is new Ada.Finalization.Controlled with private;
function New_Obj( I : in Integer ) return Obj_T;
procedure Put( O : Obj_T );
private
type Obj_T is new Ada.Finalization.Controlled with
record
X : Integer := 0;
Serial : Integer := 0;
end record;
procedure Initialize( Object: in out Obj_T );
procedure Adjust( Object: in out Obj_T );
procedure Finalize( Object: in out Obj_T );
end Obj;
|
grim7reaper/SipHash | Ada | 6,532 | ads | ------------------------------------------------------------------------
-- Copyright (c) 2014 Sylvain Laperche <[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:
-- 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 author 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 HOLDERS AND CONTRIBUTORSBE 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.
------------------------------------------------------------------------
generic
-- Number of compression rounds
Nb_Compression_Rounds : Positive;
-- Number of finalization rounds.
Nb_Finalization_Rounds : Positive;
------------------------------------------------------------------------
-- SipHash.PRF
--
-- Purpose:
-- This package provides an implementation of the SipHash PRF.
------------------------------------------------------------------------
package SipHash.PRF is
type Object is limited private;
---------------------------------------------------------------------
-- Initialize
--
-- Purpose:
-- Initializes a SipHash instance with the specified 128-bit secret
-- key.
-- Parameters:
-- Key: a 128-bit secret key.
-- Return:
-- Returns an initialized SipHash instance.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Initialize(Key : in Key_Type)
return Object;
---------------------------------------------------------------------
-- Update
--
-- Purpose:
-- Add a byte to the hash.
-- Parameters:
-- Hash: a SipHash instance.
-- Byte: a byte of data.
-- Exceptions:
-- None.
---------------------------------------------------------------------
procedure Update(Hash : in out Object; Byte : in U8);
---------------------------------------------------------------------
-- Update
--
-- Purpose:
-- Add an array of bytes to the hash.
-- Parameters:
-- Hash: a SipHash instance.
-- Byte: an array of bytes.
-- Exceptions:
-- None.
---------------------------------------------------------------------
procedure Update(Hash : in out Object; Input : in Byte_Sequence);
---------------------------------------------------------------------
-- Finalize
--
-- Purpose:
-- Runs the finalization round and computes the hash value.
-- Parameters:
-- Hash: a SipHash instance.
-- Result: the hash value.
-- Exceptions:
-- None.
-- Remarks:
-- You MUST call Reset before calling Update again.
---------------------------------------------------------------------
procedure Finalize(Hash : in out Object; Result : out U64);
---------------------------------------------------------------------
-- Reset
--
-- Purpose:
-- Re-Initializes the internal state.
-- Parameters:
-- Hash: a SipHash instance.
-- Key: a 128-bit secret key.
-- Remarks:
-- The current state is lost.
---------------------------------------------------------------------
procedure Reset(Hash : in out Object; Key : in Key_Type);
---------------------------------------------------------------------
-- Hash
--
-- Purpose:
-- Computes the hash of the input using the specified 128-bit
-- secret key.
-- Parameters:
-- Input: data to hash.
-- Key: a 128-bit secret key.
-- Return:
-- Returns the hash value.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Hash(Input : in Byte_Sequence; Key : in Key_Type)
return U64;
private
-- A block of 64 bits contains 8 octets.
Block_Size : constant U8 := 8;
-- An unpacked 64-bit integer corresponds to a sequence of 8 bytes.
subtype U64_Unpacked is Byte_Sequence (U64 range 1..8);
type Object is limited
record
-- Interneal state.
V0 : U64;
V1 : U64;
V2 : U64;
V3 : U64;
-- Current block.
Block : U64;
-- Position in the current block.
Block_Index : U8;
-- Processed bytes' counter (modulo 256)
Count : U8;
end record;
---------------------------------------------------------------------
-- Pack_As_LE
--
-- Purpose:
-- Packs a 64-bit integer using the little-endian encoding.
-- Parameters:
-- Input: an unpacked 64-bit integer.
-- Return:
-- Returns a 64-bit little-endian integer.
-- Exceptions:
-- None.
---------------------------------------------------------------------
function Pack_As_LE(Input : in U64_Unpacked)
return U64
with Inline;
---------------------------------------------------------------------
-- Sip_Round
--
-- Purpose:
-- Executes the round function of SipHash.
-- Parameters:
-- V0: Internal state(0).
-- V1: Internal state(1).
-- V2: Internal state(2).
-- V3: Internal state(3).
-- Exceptions:
-- None.
---------------------------------------------------------------------
procedure Sip_Round(V0, V1, V2, V3 : in out U64)
with Inline;
end SipHash.PRF;
|
reznikmm/matreshka | Ada | 4,589 | 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_Fo.Max_Height_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Max_Height_Attribute_Node is
begin
return Self : Fo_Max_Height_Attribute_Node do
Matreshka.ODF_Fo.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Fo_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Fo_Max_Height_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Max_Height_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Fo_URI,
Matreshka.ODF_String_Constants.Max_Height_Attribute,
Fo_Max_Height_Attribute_Node'Tag);
end Matreshka.ODF_Fo.Max_Height_Attributes;
|
optikos/oasis | Ada | 3,479 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Formal_Access_Types;
with Program.Lexical_Elements;
with Program.Elements.Parameter_Specifications;
package Program.Elements.Formal_Function_Access_Types is
pragma Pure (Program.Elements.Formal_Function_Access_Types);
type Formal_Function_Access_Type is
limited interface
and Program.Elements.Formal_Access_Types.Formal_Access_Type;
type Formal_Function_Access_Type_Access is
access all Formal_Function_Access_Type'Class with Storage_Size => 0;
not overriding function Parameters
(Self : Formal_Function_Access_Type)
return Program.Elements.Parameter_Specifications
.Parameter_Specification_Vector_Access is abstract;
not overriding function Result_Subtype
(Self : Formal_Function_Access_Type)
return not null Program.Elements.Element_Access is abstract;
not overriding function Has_Not_Null
(Self : Formal_Function_Access_Type)
return Boolean is abstract;
not overriding function Has_Protected
(Self : Formal_Function_Access_Type)
return Boolean is abstract;
not overriding function Has_Not_Null_2
(Self : Formal_Function_Access_Type)
return Boolean is abstract;
type Formal_Function_Access_Type_Text is limited interface;
type Formal_Function_Access_Type_Text_Access is
access all Formal_Function_Access_Type_Text'Class with Storage_Size => 0;
not overriding function To_Formal_Function_Access_Type_Text
(Self : aliased in out Formal_Function_Access_Type)
return Formal_Function_Access_Type_Text_Access is abstract;
not overriding function Not_Token
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Null_Token
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Access_Token
(Self : Formal_Function_Access_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Protected_Token
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Function_Token
(Self : Formal_Function_Access_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Right_Bracket_Token
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Return_Token
(Self : Formal_Function_Access_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Not_Token_2
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Null_Token_2
(Self : Formal_Function_Access_Type_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
end Program.Elements.Formal_Function_Access_Types;
|
AdaCore/training_material | Ada | 4,255 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2009, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This 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, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Libm_Single; use Libm_Single;
package body Solar_System is
-- QUESTION 1
-- Declare an exception called Bodies_Collision
procedure Init_Body
(B : Bodies_Enum_T;
Bodies : in out Bodies_Array_T;
Radius : Float;
Color : RGBA_T;
Distance : Float;
Angle : Float;
Speed : Float;
Turns_Around : Bodies_Enum_T;
Visible : Boolean := True)
is
begin
Bodies (B) :=
(Distance => Distance,
Speed => Speed,
Angle => Angle,
Turns_Around => Turns_Around,
Visible => Visible,
Color => Color,
Radius => Radius,
others => <>);
end Init_Body;
-- implement a function to compute the X coordinate
-- x of the reference + distance * cos(angle)
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;
-- implement a function to compute the Y coordinate
-- y of the reference + distance * sin(angle)
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
is
begin
return Turns_Around.X + Body_To_Move.Distance * Cos (Body_To_Move.Angle);
end Compute_X;
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
is
begin
return Turns_Around.Y + Body_To_Move.Distance * Sin (Body_To_Move.Angle);
end Compute_Y;
function Colliding (A : Body_T; B : Body_T) return Boolean is
begin
return (A.X - B.X) ** 2 + (A.Y - B.Y) ** 2 <= (A.Radius + B.Radius) ** 2;
end Colliding;
procedure Move (Body_To_Move : in out Body_T; Bodies : Bodies_Array_T) is
begin
Body_To_Move.X :=
Compute_X (Body_To_Move, Bodies (Body_To_Move.Turns_Around));
Body_To_Move.Y :=
Compute_Y (Body_To_Move, Bodies (Body_To_Move.Turns_Around));
Body_To_Move.Angle := Body_To_Move.Angle + Body_To_Move.Speed;
for Body_Collision_Check of Bodies loop
if Body_To_Move /= Body_Collision_Check
and then Colliding (Body_To_Move, Body_Collision_Check) then
-- QUESTION 2
-- raise an exception in case of collision between both bodies
null;
end if;
end loop;
end Move;
procedure Move_All (Bodies : in out Bodies_Array_T) is
begin
-- loop over all bodies and call Move procedure
for B of Bodies loop
declare
begin
-- call the move procedure for each body
Move (B, Bodies);
-- QUESTION 3
-- Catch the exception around this call
-- and set B.Speed to -B.Speed
end;
end loop;
end Move_All;
end Solar_System;
|
reznikmm/matreshka | Ada | 3,660 | 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.Operation_Template_Parameters.Hash is
new AMF.Elements.Generic_Hash (UML_Operation_Template_Parameter, UML_Operation_Template_Parameter_Access);
|
zrmyers/VulkanAda | Ada | 1,851 | ads | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--< @group Vulkan Math Basic Types
--------------------------------------------------------------------------------
--< @summary
--< This package provides a single precision floating point matrix with 2 rows
--< and 2 columns.
--------------------------------------------------------------------------------
package Vulkan.Math.Dmat3x2.Test is
-- Test Harness for Mat3x2 regression tests
procedure Test_Dmat3x2;
end Vulkan.Math.Dmat3x2.Test;
|
stcarrez/etherscope | Ada | 2,617 | adb | -----------------------------------------------------------------------
-- etherscope-stats -- Ethernet Packet Statistics
-- Copyright (C) 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body EtherScope.Stats is
use type Net.Uint32;
use type Net.Uint64;
-- ------------------------------
-- Update the statistics after reception of a packet of the given length.
-- ------------------------------
procedure Add (Stats : in out Statistics;
Length : in Net.Uint32) is
begin
Stats.Packets := Stats.Packets + 1;
Stats.Bytes := Stats.Bytes + Net.Uint64 (Length);
end Add;
-- ------------------------------
-- Update the statistics after reception of a packet of the given length.
-- ------------------------------
procedure Add (Samples : in out Graph_Samples;
Kind : in Graph_Kind;
Stats : in out Statistics;
Length : in Net.Uint32) is
begin
Stats.Packets := Stats.Packets + 1;
Stats.Bytes := Stats.Bytes + Net.Uint64 (Length);
Samples (Kind) := Samples (Kind) + Net.Uint64 (Length);
end Add;
-- ------------------------------
-- Compute the bandwidth utilization in bits per second. The <tt>Dt</tt> is the
-- delta time in milliseconds that ellapsed between the two samples. After the
-- call, <tt>Previous</tt> contains the same value as <tt>Current</tt>.
-- ------------------------------
procedure Update_Rate (Current : in out Statistics;
Previous : in out Statistics;
Dt : in Positive) is
D : constant Net.Uint64 := Current.Bytes - Previous.Bytes;
begin
if D /= 0 then
Current.Bandwidth := Net.Uint32 ((8_000 * D) / Net.Uint64 (Dt));
else
Current.Bandwidth := 0;
end if;
Previous := Current;
end Update_Rate;
end EtherScope.Stats;
|
G-P-S/freetype-gopro-mac | Ada | 4,331 | ads | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: zlib-streams.ads,v 1.1 2009/10/28 06:31:01 dnewman Exp $
package ZLib.Streams is
type Stream_Mode is (In_Stream, Out_Stream, Duplex);
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
type Stream_Type is
new Ada.Streams.Root_Stream_Type with private;
procedure Read
(Stream : in out Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Type;
Item : in Ada.Streams.Stream_Element_Array);
procedure Flush
(Stream : in out Stream_Type;
Mode : in Flush_Mode := Sync_Flush);
-- Flush the written data to the back stream,
-- all data placed to the compressor is flushing to the Back stream.
-- Should not be used untill necessary, becouse it is decreasing
-- compression.
function Read_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_In);
-- Return total number of bytes read from back stream so far.
function Read_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Read_Total_Out);
-- Return total number of bytes read so far.
function Write_Total_In (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_In);
-- Return total number of bytes written so far.
function Write_Total_Out (Stream : in Stream_Type) return Count;
pragma Inline (Write_Total_Out);
-- Return total number of bytes written to the back stream.
procedure Create
(Stream : out Stream_Type;
Mode : in Stream_Mode;
Back : in Stream_Access;
Back_Compressed : in Boolean;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Header : in Header_Type := Default;
Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
-- If Back_Compressed is true then
-- Data written to the Stream is compressing to the Back stream
-- and data read from the Stream is decompressed data from the Back stream.
-- If Back_Compressed is false then
-- Data written to the Stream is decompressing to the Back stream
-- and data read from the Stream is compressed data from the Back stream.
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
function Is_Open (Stream : Stream_Type) return Boolean;
procedure Close (Stream : in out Stream_Type);
private
use Ada.Streams;
type Buffer_Access is access all Stream_Element_Array;
type Stream_Type
is new Root_Stream_Type with
record
Mode : Stream_Mode;
Buffer : Buffer_Access;
Rest_First : Stream_Element_Offset;
Rest_Last : Stream_Element_Offset;
-- Buffer for Read operation.
-- We need to have this buffer in the record
-- becouse not all read data from back stream
-- could be processed during the read operation.
Buffer_Size : Stream_Element_Offset;
-- Buffer size for write operation.
-- We do not need to have this buffer
-- in the record becouse all data could be
-- processed in the write operation.
Back : Stream_Access;
Reader : Filter_Type;
Writer : Filter_Type;
end record;
end ZLib.Streams;
|
charlie5/cBound | Ada | 1,641 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_get_keyboard_mapping_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
first_keycode : aliased xcb.xcb_keycode_t;
count : aliased Interfaces.Unsigned_8;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_keyboard_mapping_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_keyboard_mapping_request_t.Item,
Element_Array => xcb.xcb_get_keyboard_mapping_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_get_keyboard_mapping_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_get_keyboard_mapping_request_t.Pointer,
Element_Array => xcb.xcb_get_keyboard_mapping_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_get_keyboard_mapping_request_t;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.