content stringlengths 23 1.05M |
|---|
-- Time-stamp: <01 oct 2012 15:37 queinnec@enseeiht.fr>
-- Tâches clients : lecteurs, rédacteurs
package LR.Tasks is
MAXPROCS : constant Integer := 30;
subtype Proc_Id is Positive range 1..MAXPROCS;
task type Lecteur is
entry Init(MonId: Proc_Id);
end Lecteur;
task type Redacteur is
entry Init(MonId: Proc_Id);
end Redacteur;
type Lecteur_Access is access Lecteur;
type Redacteur_Access is access Redacteur;
end LR.Tasks;
|
with Converters;
-- @summary
-- Units used in aviation, operations among them and conversion
-- factors.
--
-- @description
-- Measure_Units provides all you can need to play with
-- units used in aviation, except that this is a lie because
-- this is a test, so you won't find anything really useful
-- here.
--
package Measure_Units is
Meters_per_Nautical_Mile : constant := 1852.0;
Meters_per_Foot : constant := 0.3048;
Mps_per_Knot : constant := Meters_per_Nautical_Mile/3600.0;
type Kn is new Float;
-- Knot (NM/h)
subtype Kt is Kn;
-- kt is used in aviation in place of kn
type NM is new Float;
-- Nautical Mile (1832 m by definition; it was 1/60 of a degree of
-- latitude)
type Ft is new Float;
-- Foot (0.3048 m)
type Climb_Rate is new Float;
-- Climb rate is misured in ft/min; negative values are for sink
-- rate.
type Meter is new Float;
-- Standard meter
type Mps is new Float;
-- m/s
function To_Mps (V : Kn) return Mps;
-- Convert kn to m/s.
function To_Meters (V : NM) return Meter;
-- Convert NM to meters.
function To_Meters (V : Ft) return Meter;
-- Convert ft to meters.
function "*"
(Speed : Kn;
T : Duration) return NM;
-- Speed in kn * t gives a distance.
-- @param Speed Speed expressed in knots.
-- @param T Time in seconds.
-- @return NM done in the given time.
function "*"
(CR : Climb_Rate;
T : Duration) return Ft;
-- Climb rate (ft/min) * t gives an altitude (distance).
-- @param CR Climb rate.
-- @param T Time in seconds.
-- @return the feet climbed after that time.
function "/"
(D : Ft;
T : Duration) return Climb_Rate;
-- Distance in feet / time is a Climb rate
-- @param D Diff of altitude in feet.
-- @param T Time in seconds.
-- @return the climb rate.
function To_String is new Converters.To_String (Kn);
function To_String is new Converters.To_String (Ft);
function To_String is new Converters.To_String (NM);
function To_String is new Converters.To_String (Mps);
function To_String is new Converters.To_String (Meter);
function To_String is new Converters.To_String (Climb_Rate);
function "&" is new Converters.Concat (Kn, To_String);
function "&" is new Converters.Concat (Ft, To_String);
function "&" is new Converters.Concat (NM, To_String);
function "&" is new Converters.Concat (Mps, To_String);
function "&" is new Converters.Concat (Meter, To_String);
function "&" is new Converters.Concat (Climb_Rate, To_String);
end Measure_Units;
|
package body Complejos is
function "+" (C1,C2 : Complejo) return Complejo is
begin
return (C1.Re+C2.Re,C1.Im+C2.Im);
end "+";
function Haz_Complejo (Re,Im : Float) return Complejo is
begin
return (Re,Im);
end Haz_Complejo;
function Imag (C : Complejo) return Float is
begin
return C.Im;
end Imag;
function Image (C : Complejo) return String is
begin
if C.Im>=0.0 then
return Float'Image(C.Re)&" + "&Float'Image(C.Im)&" J";
else
return Float'Image(C.Re)&" - "&Float'Image(abs C.Im)&" J";
end if;
end Image;
function Real (C : Complejo) return Float is
begin
return C.Re;
end Real;
end Complejos;
|
with Ada.Text_IO; use Ada.Text_IO;
with USB.Utils; use USB.Utils;
with System.Storage_Elements; use System.Storage_Elements;
with HAL; use HAL;
procedure Main is
Alloc : USB.Utils.Basic_RAM_Allocator (256);
procedure Test (Alignment : UInt8; Len : UInt11) is
Addr : constant Integer_Address :=
To_Integer (Allocate (Alloc, Alignment, Len));
begin
if Addr = 0 then
Put ("Allocation failed");
elsif (Addr mod Integer_Address (Alignment)) /= 0 then
Put ("Bad alignment");
else
Put ("OK");
end if;
Put_Line (" - Align:" & Alignment'Img & " Len:" & Len'Img);
end Test;
begin
Test (1, 1);
Test (2, 1);
Test (4, 1);
Test (8, 1);
Test (16, 1);
Test (32, 1);
Test (4, 512);
end Main;
|
with Standard_Natural_Numbers; use Standard_Natural_Numbers;
with Standard_Floating_Matrices;
with Standard_Complex_Matrices;
with Double_Double_Matrices;
with Quad_Double_Matrices;
with Multprec_Floating_Matrices;
with DoblDobl_Complex_Matrices;
with QuadDobl_Complex_Matrices;
with Multprec_Complex_Matrices;
package VarbPrec_Matrix_Conversions is
-- DESCRIPTION :
-- Often we want to convert matrices of various precisions.
-- This package collects routines to convert between matrices of
-- different types of precision for use in variable precision solvers,
-- for real and complex numbers.
function d2dd ( mtx : Standard_Floating_Matrices.Matrix )
return Double_Double_Matrices.Matrix;
function d2dd ( mtx : Standard_Complex_Matrices.Matrix )
return DoblDobl_Complex_Matrices.Matrix;
function d2qd ( mtx : Standard_Floating_Matrices.Matrix )
return Quad_Double_Matrices.Matrix;
function d2qd ( mtx : Standard_Complex_Matrices.Matrix )
return QuadDobl_Complex_Matrices.Matrix;
function d2mp ( mtx : Standard_Floating_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function d2mp ( mtx : Standard_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a floating-point matrix in standard double precision
-- to a matrix in double double (dd), quad double (qd) precision,
-- or arbitrary multiprecision (mp).
function dd2d ( mtx : Double_Double_Matrices.Matrix )
return Standard_Floating_Matrices.Matrix;
function dd2d ( mtx : DoblDobl_Complex_Matrices.Matrix )
return Standard_Complex_Matrices.Matrix;
function dd2qd ( mtx : Double_Double_Matrices.Matrix )
return Quad_Double_Matrices.Matrix;
function dd2qd ( mtx : DoblDobl_Complex_Matrices.Matrix )
return QuadDobl_Complex_Matrices.Matrix;
function dd2mp ( mtx : Double_Double_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function dd2mp ( mtx : DoblDobl_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a matrix in double double precision to a matrix
-- in standard double (d), quad double (qd) precision,
-- or arbitrary multiprecision (mp).
function qd2d ( mtx : Quad_Double_Matrices.Matrix )
return Standard_Floating_Matrices.Matrix;
function qd2d ( mtx : QuadDobl_Complex_Matrices.Matrix )
return Standard_Complex_Matrices.Matrix;
function qd2dd ( mtx : Quad_Double_Matrices.Matrix )
return Double_Double_Matrices.Matrix;
function qd2dd ( mtx : QuadDobl_Complex_Matrices.Matrix )
return DoblDobl_Complex_Matrices.Matrix;
function qd2mp ( mtx : Quad_Double_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function qd2mp ( mtx : QuadDobl_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a matrix in quad double precision to a matrix
-- in standard double (d) or double double (dd) precision,
-- or arbitrary multiprecision (mp).
procedure Set_Size ( mtx : in out Multprec_Floating_Matrices.Matrix;
size : in natural32 );
procedure Set_Size ( mtx : in out Multprec_Complex_Matrices.Matrix;
size : in natural32 );
-- DESCRIPTION :
-- Sets the size of the matrix mtx to the given value of size.
end VarbPrec_Matrix_Conversions;
|
with
Interfaces.C.Strings,
System;
use type
Interfaces.C.int,
Interfaces.C.Strings.chars_ptr,
System.Address;
package body FLTK.Environment is
function new_fl_preferences
(P, V, A : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_preferences, "new_fl_preferences");
pragma Inline (new_fl_preferences);
procedure free_fl_preferences
(E : in System.Address);
pragma Import (C, free_fl_preferences, "free_fl_preferences");
pragma Inline (free_fl_preferences);
function fl_preferences_entries
(E : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_preferences_entries, "fl_preferences_entries");
pragma Inline (fl_preferences_entries);
function fl_preferences_entry
(E : in System.Address;
I : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, fl_preferences_entry, "fl_preferences_entry");
pragma Inline (fl_preferences_entry);
function fl_preferences_entryexists
(E : in System.Address;
K : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_preferences_entryexists, "fl_preferences_entryexists");
pragma Inline (fl_preferences_entryexists);
function fl_preferences_size
(E : in System.Address;
K : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_preferences_size, "fl_preferences_size");
pragma Inline (fl_preferences_size);
function fl_preferences_get_int
(E : in System.Address;
K : in Interfaces.C.char_array;
V : out Interfaces.C.int;
D : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_preferences_get_int, "fl_preferences_get_int");
pragma Inline (fl_preferences_get_int);
function fl_preferences_get_float
(E : in System.Address;
K : in Interfaces.C.char_array;
V : out Interfaces.C.C_float;
D : in Interfaces.C.C_float)
return Interfaces.C.int;
pragma Import (C, fl_preferences_get_float, "fl_preferences_get_float");
pragma Inline (fl_preferences_get_float);
function fl_preferences_get_double
(E : in System.Address;
K : in Interfaces.C.char_array;
V : out Interfaces.C.double;
D : in Interfaces.C.double)
return Interfaces.C.int;
pragma Import (C, fl_preferences_get_double, "fl_preferences_get_double");
pragma Inline (fl_preferences_get_double);
function fl_preferences_get_str
(E : in System.Address;
K : in Interfaces.C.char_array;
V : out Interfaces.C.Strings.chars_ptr;
D : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_preferences_get_str, "fl_preferences_get_str");
pragma Inline (fl_preferences_get_str);
function fl_preferences_set_int
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_int, "fl_preferences_set_int");
pragma Inline (fl_preferences_set_int);
function fl_preferences_set_float
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.C_float)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_float, "fl_preferences_set_float");
pragma Inline (fl_preferences_set_float);
function fl_preferences_set_float_prec
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.C_float;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_float_prec, "fl_preferences_set_float_prec");
pragma Inline (fl_preferences_set_float_prec);
function fl_preferences_set_double
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.double)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_double, "fl_preferences_set_double");
pragma Inline (fl_preferences_set_double);
function fl_preferences_set_double_prec
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.double;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_double_prec, "fl_preferences_set_double_prec");
pragma Inline (fl_preferences_set_double_prec);
function fl_preferences_set_str
(E : in System.Address;
K : in Interfaces.C.char_array;
V : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_preferences_set_str, "fl_preferences_set_str");
pragma Inline (fl_preferences_set_str);
function fl_preferences_deleteentry
(E : in System.Address;
K : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, fl_preferences_deleteentry, "fl_preferences_deleteentry");
pragma Inline (fl_preferences_deleteentry);
function fl_preferences_deleteallentries
(E : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_preferences_deleteallentries, "fl_preferences_deleteallentries");
pragma Inline (fl_preferences_deleteallentries);
function fl_preferences_clear
(E : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_preferences_clear, "fl_preferences_clear");
pragma Inline (fl_preferences_clear);
procedure fl_preferences_flush
(E : in System.Address);
pragma Import (C, fl_preferences_flush, "fl_preferences_flush");
pragma Inline (fl_preferences_flush);
procedure Finalize
(This : in out Preferences) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Preferences'Class
then
free_fl_preferences (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
end Finalize;
package body Forge is
function From_Filesystem
(Path, Vendor, Application : in String)
return Preferences is
begin
return This : Preferences do
This.Void_Ptr := new_fl_preferences
(Interfaces.C.To_C (Path),
Interfaces.C.To_C (Vendor),
Interfaces.C.To_C (Application));
end return;
end From_Filesystem;
end Forge;
function Number_Of_Entries
(This : in Preferences)
return Natural is
begin
return Natural (fl_preferences_entries (This.Void_Ptr));
end Number_Of_Entries;
function Get_Key
(This : in Preferences;
Index : in Natural)
return String
is
Key : Interfaces.C.Strings.chars_ptr :=
fl_preferences_entry (This.Void_Ptr, Interfaces.C.int (Index));
begin
-- no need for dealloc?
if Key = Interfaces.C.Strings.Null_Ptr then
raise Constraint_Error;
else
return Interfaces.C.Strings.Value (Key);
end if;
end Get_Key;
function Entry_Exists
(This : in Preferences;
Key : in String)
return Boolean is
begin
return fl_preferences_entryexists (This.Void_Ptr, Interfaces.C.To_C (Key)) /= 0;
end Entry_Exists;
function Entry_Size
(This : in Preferences;
Key : in String)
return Natural is
begin
return Natural (fl_preferences_size (This.Void_Ptr, Interfaces.C.To_C (Key)));
end Entry_Size;
function Get
(This : in Preferences;
Key : in String)
return Integer
is
Value : Interfaces.C.int;
begin
if fl_preferences_get_int
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value, 0) = 0
then
raise Preference_Error;
end if;
return Integer (Value);
end Get;
function Get
(This : in Preferences;
Key : in String)
return Float
is
Value : Interfaces.C.C_float;
begin
if fl_preferences_get_float
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value, 0.0) = 0
then
raise Preference_Error;
end if;
return Float (Value);
end Get;
function Get
(This : in Preferences;
Key : in String)
return Long_Float
is
Value : Interfaces.C.double;
begin
if fl_preferences_get_double
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value, 0.0) = 0
then
raise Preference_Error;
end if;
return Long_Float (Value);
end Get;
function Get
(This : in Preferences;
Key : in String)
return String
is
Value : Interfaces.C.Strings.chars_ptr;
Check : Interfaces.C.int := fl_preferences_get_str
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value,
Interfaces.C.To_C ("default"));
begin
if Check = 0 then
raise Preference_Error;
end if;
if Value = Interfaces.C.Strings.Null_Ptr then
return "";
else
declare
Str : String := Interfaces.C.Strings.Value (Value);
begin
Interfaces.C.Strings.Free (Value);
return Str;
end;
end if;
end Get;
function Get
(This : in Preferences;
Key : in String;
Default : in Integer)
return Integer
is
Value, X : Interfaces.C.int;
begin
X := fl_preferences_get_int
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value,
Interfaces.C.int (Default));
return Integer (Value);
end Get;
function Get
(This : in Preferences;
Key : in String;
Default : in Float)
return Float
is
Value : Interfaces.C.C_float;
X : Interfaces.C.int;
begin
X := fl_preferences_get_float
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value,
Interfaces.C.C_float (Default));
return Float (Value);
end Get;
function Get
(This : in Preferences;
Key : in String;
Default : in Long_Float)
return Long_Float
is
Value : Interfaces.C.double;
X : Interfaces.C.int;
begin
X := fl_preferences_get_double
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value,
Interfaces.C.double (Default));
return Long_Float (Value);
end Get;
function Get
(This : in Preferences;
Key : in String;
Default : in String)
return String
is
Value : Interfaces.C.Strings.chars_ptr;
X : Interfaces.C.int := fl_preferences_get_str
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Value,
Interfaces.C.To_C (Default));
begin
if Value = Interfaces.C.Strings.Null_Ptr then
return "";
else
declare
Str : String := Interfaces.C.Strings.Value (Value);
begin
Interfaces.C.Strings.Free (Value);
return Str;
end;
end if;
end Get;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Integer) is
begin
if fl_preferences_set_int
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.int (Value)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Float) is
begin
if fl_preferences_set_float
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.C_float (Value)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Float;
Precision : in Natural) is
begin
if fl_preferences_set_float_prec
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.C_float (Value),
Interfaces.C.int (Precision)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Long_Float) is
begin
if fl_preferences_set_double
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.double (Value)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in Long_Float;
Precision : in Natural) is
begin
if fl_preferences_set_double_prec
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.double (Value),
Interfaces.C.int (Precision)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Set
(This : in out Preferences;
Key : in String;
Value : in String) is
begin
if fl_preferences_set_str
(This.Void_Ptr,
Interfaces.C.To_C (Key),
Interfaces.C.To_C (Value)) = 0
then
raise Preference_Error;
end if;
end Set;
procedure Delete_Entry
(This : in out Preferences;
Key : in String) is
begin
if fl_preferences_deleteentry (This.Void_Ptr, Interfaces.C.To_C (Key)) = 0 then
raise Preference_Error;
end if;
end Delete_Entry;
procedure Delete_All_Entries
(This : in out Preferences) is
begin
if fl_preferences_deleteallentries (This.Void_Ptr) = 0 then
raise Preference_Error;
end if;
end Delete_All_Entries;
procedure Clear
(This : in out Preferences) is
begin
if fl_preferences_clear (This.Void_Ptr) = 0 then
raise Preference_Error;
end if;
end Clear;
procedure Flush
(This : in Preferences) is
begin
fl_preferences_flush (This.Void_Ptr);
end Flush;
end FLTK.Environment;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Finalization;
package Yaml.Destination is
type Instance is abstract new Ada.Finalization.Limited_Controlled with
null record;
type Pointer is access all Instance'Class;
procedure Write_Data (D : in out Instance; Buffer : String) is abstract;
end Yaml.Destination;
|
pragma Eliminate (p, d);
package elim1 is
type t is tagged null record;
procedure d (a : t);
end;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Catalan is
function Catalan (N : Natural) return Natural is
Result : Positive := 1;
begin
for I in 1..N loop
Result := Result * 2 * (2 * I - 1) / (I + 1);
end loop;
return Result;
end Catalan;
begin
for N in 0..15 loop
Put_Line (Integer'Image (N) & " =" & Integer'Image (Catalan (N)));
end loop;
end Test_Catalan;
|
-----------------------------------------------------------------------
-- are-generator -- Advanced Resource Embedder Generator
-- Copyright (C) 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with GNAT.Command_Line;
-- = Generator =
-- The code generators are invoked when the installer has scanned the directories,
-- selected the files and applied the installation rules to produce the content
-- that must be embedded.
--
-- @include are-generator-ada2012.ads
-- @include are-generator-c.ads
-- @include are-generator-go.ads
package Are.Generator is
package GC renames GNAT.Command_Line;
-- Main entry point to parse command line arguments.
procedure Main;
procedure Usage;
private
type Generator_Type is limited interface;
-- Generate the code for the resources that have been collected.
procedure Generate (Generator : in out Generator_Type;
Resources : in Resource_List;
Context : in out Are.Context_Type'Class) is abstract;
-- Setup the command line configuration to accept specific generation options.
procedure Setup (Generator : in out Generator_Type;
Config : in out GC.Command_Line_Configuration) is abstract;
-- Return a string that identifies the program.
function Get_Title return String;
procedure Add_Option (Switch, Value : in String);
-- Portability hack to support old GNAT.Command_Line before gcc 7.3
procedure Specific_Options (Config : in out GC.Command_Line_Configuration;
Context : in out Are.Context_Type'Class);
end Are.Generator;
|
-- String_To_Storage_Array
-- This is a simple conversion routine to help implement test vectors
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with System.Storage_Elements;
function String_To_Storage_Array(X : String)
return System.Storage_Elements.Storage_Array is
use System.Storage_Elements;
begin
-- This compile-time check is useful for GNAT, but in GNATprove it currently
-- just generates a warning that it can not yet be proved correct.
pragma Warnings (GNATprove, Off, "Compile_Time_Error");
pragma Compile_Time_Error ((Character'Size /= Storage_Element'Size),
"Character and Storage_Element types are different sizes!");
pragma Warnings (GNATprove, On, "Compile_Time_Error");
return R : Storage_Array(Storage_Offset(X'First) .. Storage_Offset(X'Last)) do
for I in X'Range loop
R(Storage_Offset(I)) := Character'Pos(X(I)) - Character'Pos(Character'First);
end loop;
end return;
end String_To_Storage_Array;
|
with AUnit.Reporter.Text;
with AUnit.Run;
with AUnit.Test_Suites;
with Test_SIMD_SSE_Arithmetic;
with Test_SIMD_SSE_Compare;
with Test_SIMD_SSE_Logical;
with Test_SIMD_SSE_Math;
with Test_SIMD_SSE_Swizzle;
with Test_SIMD_SSE4_1_Math;
with Test_SIMD_AVX_Arithmetic;
with Test_SIMD_AVX_Compare;
with Test_SIMD_AVX_Math;
with Test_SIMD_AVX_Swizzle;
with Test_SIMD_AVX2_Swizzle;
with Test_SIMD_FMA_Singles_Arithmetic;
with Test_SIMD_FMA_Doubles_Arithmetic;
with Test_Transforms_Singles_Matrices;
with Test_Transforms_Singles_Quaternions;
with Test_Transforms_Singles_Vectors;
with Test_Transforms_Doubles_Matrices;
with Test_Transforms_Doubles_Vectors;
with Test_Scene_Trees;
procedure Orka_Tests is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Result : constant AUnit.Test_Suites.Access_Test_Suite :=
AUnit.Test_Suites.New_Suite;
begin
-- SIMD > SSE (Single)
Result.Add_Test (Test_SIMD_SSE_Arithmetic.Suite);
Result.Add_Test (Test_SIMD_SSE_Compare.Suite);
Result.Add_Test (Test_SIMD_SSE_Logical.Suite);
Result.Add_Test (Test_SIMD_SSE_Math.Suite);
Result.Add_Test (Test_SIMD_SSE_Swizzle.Suite);
-- SIMD > SSE4.1 (Singles)
Result.Add_Test (Test_SIMD_SSE4_1_Math.Suite);
-- SIMD > AVX (Doubles)
Result.Add_Test (Test_SIMD_AVX_Arithmetic.Suite);
Result.Add_Test (Test_SIMD_AVX_Compare.Suite);
Result.Add_Test (Test_SIMD_AVX_Math.Suite);
Result.Add_Test (Test_SIMD_AVX_Swizzle.Suite);
-- SIMD > AVX2 (Doubles)
Result.Add_Test (Test_SIMD_AVX2_Swizzle.Suite);
-- SIMD > FMA (Singles)
Result.Add_Test (Test_SIMD_FMA_Singles_Arithmetic.Suite);
-- SIMD > FMA (Doubles)
Result.Add_Test (Test_SIMD_FMA_Doubles_Arithmetic.Suite);
-- Transforms (Singles)
Result.Add_Test (Test_Transforms_Singles_Matrices.Suite);
Result.Add_Test (Test_Transforms_Singles_Vectors.Suite);
Result.Add_Test (Test_Transforms_Singles_Quaternions.Suite);
-- Transforms (Doubles)
Result.Add_Test (Test_Transforms_Doubles_Matrices.Suite);
Result.Add_Test (Test_Transforms_Doubles_Vectors.Suite);
-- Trees
Result.Add_Test (Test_Scene_Trees.Suite);
return Result;
end Suite;
procedure Runner is new AUnit.Run.Test_Runner (Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Reporter.Set_Use_ANSI_Colors (True);
Runner (Reporter);
end Orka_Tests;
|
procedure RangeV2 is
type BitsFake is range -53 .. 191;
type Bits30 is range 0 .. 1073741823;
for Bits30'Size use 30;
type Signed_Bits26 is range -33554432 .. 33554431;
for Signed_Bits26'Size use 26;
begin
null;
end RangeV2;
|
with Ada.Text_IO; use Ada.Text_IO;
with Adventofcode.File_Line_Readers;
procedure Adventofcode.Day_6.Main is
procedure Part1 (Input_Path : String) is
Group_Reply : Reply_Type;
Totals : Natural := 0;
begin
for Line of Adventofcode.File_Line_Readers.Read_Lines (Input_Path) loop
if Line'Length > 0 then
Group_Reply := Group_Reply + Value (Line);
else
Totals := Totals + Count (Group_Reply);
Group_Reply := No_Replies;
end if;
end loop;
Totals := Totals + Count (Group_Reply);
Put_Line (Totals'Img);
end;
procedure Part2 (Input_Path : String) is
Group_Reply : Group_Replie;
Totals : Natural := 0;
begin
for Line of Adventofcode.File_Line_Readers.Read_Lines (Input_Path) loop
if Line'Length > 0 then
Group_Reply := Group_Reply + Value (Line);
else
Totals := Totals + Count (Group_Reply);
Group_Reply := No_Replies;
end if;
end loop;
Totals := Totals + Count (Group_Reply);
Put_Line (Totals'Img);
end;
begin
Part1 ("src/day-6/input.test");
Part1 ("src/day-6/input");
Part2 ("src/day-6/input.test");
Part2 ("src/day-6/input");
end Adventofcode.Day_6.Main;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.HASH_TABLES.GENERIC_BOUNDED_OPERATIONS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2016, 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/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with System; use type System.Address;
package body Ada.Containers.Hash_Tables.Generic_Bounded_Operations is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-------------------
-- Checked_Index --
-------------------
function Checked_Index
(Hash_Table : aliased in out Hash_Table_Type'Class;
Node : Count_Type) return Hash_Type
is
Lock : With_Lock (Hash_Table.TC'Unrestricted_Access);
begin
return Index (Hash_Table, Hash_Table.Nodes (Node));
end Checked_Index;
-----------
-- Clear --
-----------
procedure Clear (HT : in out Hash_Table_Type'Class) is
begin
TC_Check (HT.TC);
HT.Length := 0;
-- HT.Busy := 0;
-- HT.Lock := 0;
HT.Free := -1;
HT.Buckets := (others => 0); -- optimize this somehow ???
end Clear;
--------------------------
-- Delete_Node_At_Index --
--------------------------
procedure Delete_Node_At_Index
(HT : in out Hash_Table_Type'Class;
Indx : Hash_Type;
X : Count_Type)
is
Prev : Count_Type;
Curr : Count_Type;
begin
Prev := HT.Buckets (Indx);
if Checks and then Prev = 0 then
raise Program_Error with
"attempt to delete node from empty hash bucket";
end if;
if Prev = X then
HT.Buckets (Indx) := Next (HT.Nodes (Prev));
HT.Length := HT.Length - 1;
return;
end if;
if Checks and then HT.Length = 1 then
raise Program_Error with
"attempt to delete node not in its proper hash bucket";
end if;
loop
Curr := Next (HT.Nodes (Prev));
if Checks and then Curr = 0 then
raise Program_Error with
"attempt to delete node not in its proper hash bucket";
end if;
Prev := Curr;
end loop;
end Delete_Node_At_Index;
---------------------------
-- Delete_Node_Sans_Free --
---------------------------
procedure Delete_Node_Sans_Free
(HT : in out Hash_Table_Type'Class;
X : Count_Type)
is
pragma Assert (X /= 0);
Indx : Hash_Type;
Prev : Count_Type;
Curr : Count_Type;
begin
if Checks and then HT.Length = 0 then
raise Program_Error with
"attempt to delete node from empty hashed container";
end if;
Indx := Checked_Index (HT, X);
Prev := HT.Buckets (Indx);
if Checks and then Prev = 0 then
raise Program_Error with
"attempt to delete node from empty hash bucket";
end if;
if Prev = X then
HT.Buckets (Indx) := Next (HT.Nodes (Prev));
HT.Length := HT.Length - 1;
return;
end if;
if Checks and then HT.Length = 1 then
raise Program_Error with
"attempt to delete node not in its proper hash bucket";
end if;
loop
Curr := Next (HT.Nodes (Prev));
if Checks and then Curr = 0 then
raise Program_Error with
"attempt to delete node not in its proper hash bucket";
end if;
if Curr = X then
Set_Next (HT.Nodes (Prev), Next => Next (HT.Nodes (Curr)));
HT.Length := HT.Length - 1;
return;
end if;
Prev := Curr;
end loop;
end Delete_Node_Sans_Free;
-----------
-- First --
-----------
function First (HT : Hash_Table_Type'Class) return Count_Type is
Indx : Hash_Type;
begin
if HT.Length = 0 then
return 0;
end if;
Indx := HT.Buckets'First;
loop
if HT.Buckets (Indx) /= 0 then
return HT.Buckets (Indx);
end if;
Indx := Indx + 1;
end loop;
end First;
----------
-- Free --
----------
procedure Free
(HT : in out Hash_Table_Type'Class;
X : Count_Type)
is
N : Nodes_Type renames HT.Nodes;
begin
-- This subprogram "deallocates" a node by relinking the node off of the
-- active list and onto the free list. Previously it would flag index
-- value 0 as an error. The precondition was weakened, so that index
-- value 0 is now allowed, and this value is interpreted to mean "do
-- nothing". This makes its behavior analogous to the behavior of
-- Ada.Unchecked_Deallocation, and allows callers to avoid having to add
-- special-case checks at the point of call.
if X = 0 then
return;
end if;
pragma Assert (X <= HT.Capacity);
-- pragma Assert (N (X).Prev >= 0); -- node is active
-- Find a way to mark a node as active vs. inactive; we could
-- use a special value in Color_Type for this. ???
-- The hash table actually contains two data structures: a list for
-- the "active" nodes that contain elements that have been inserted
-- onto the container, and another for the "inactive" nodes of the free
-- store.
--
-- We desire that merely declaring an object should have only minimal
-- cost; specially, we want to avoid having to initialize the free
-- store (to fill in the links), especially if the capacity is large.
--
-- The head of the free list is indicated by Container.Free. If its
-- value is non-negative, then the free store has been initialized
-- in the "normal" way: Container.Free points to the head of the list
-- of free (inactive) nodes, and the value 0 means the free list is
-- empty. Each node on the free list has been initialized to point
-- to the next free node (via its Parent component), and the value 0
-- means that this is the last free node.
--
-- If Container.Free is negative, then the links on the free store
-- have not been initialized. In this case the link values are
-- implied: the free store comprises the components of the node array
-- started with the absolute value of Container.Free, and continuing
-- until the end of the array (Nodes'Last).
--
-- ???
-- It might be possible to perform an optimization here. Suppose that
-- the free store can be represented as having two parts: one
-- comprising the non-contiguous inactive nodes linked together
-- in the normal way, and the other comprising the contiguous
-- inactive nodes (that are not linked together, at the end of the
-- nodes array). This would allow us to never have to initialize
-- the free store, except in a lazy way as nodes become inactive.
-- When an element is deleted from the list container, its node
-- becomes inactive, and so we set its Next component to value of
-- the node's index (in the nodes array), to indicate that it is
-- now inactive. This provides a useful way to detect a dangling
-- cursor reference. ???
Set_Next (N (X), Next => X); -- Node is deallocated (not on active list)
if HT.Free >= 0 then
-- The free store has previously been initialized. All we need to
-- do here is link the newly-free'd node onto the free list.
Set_Next (N (X), HT.Free);
HT.Free := X;
elsif X + 1 = abs HT.Free then
-- The free store has not been initialized, and the node becoming
-- inactive immediately precedes the start of the free store. All
-- we need to do is move the start of the free store back by one.
HT.Free := HT.Free + 1;
else
-- The free store has not been initialized, and the node becoming
-- inactive does not immediately precede the free store. Here we
-- first initialize the free store (meaning the links are given
-- values in the traditional way), and then link the newly-free'd
-- node onto the head of the free store.
-- ???
-- See the comments above for an optimization opportunity. If
-- the next link for a node on the free store is negative, then
-- this means the remaining nodes on the free store are
-- physically contiguous, starting as the absolute value of
-- that index value.
HT.Free := abs HT.Free;
if HT.Free > HT.Capacity then
HT.Free := 0;
else
for I in HT.Free .. HT.Capacity - 1 loop
Set_Next (Node => N (I), Next => I + 1);
end loop;
Set_Next (Node => N (HT.Capacity), Next => 0);
end if;
Set_Next (Node => N (X), Next => HT.Free);
HT.Free := X;
end if;
end Free;
----------------------
-- Generic_Allocate --
----------------------
procedure Generic_Allocate
(HT : in out Hash_Table_Type'Class;
Node : out Count_Type)
is
N : Nodes_Type renames HT.Nodes;
begin
if HT.Free >= 0 then
Node := HT.Free;
-- We always perform the assignment first, before we
-- change container state, in order to defend against
-- exceptions duration assignment.
Set_Element (N (Node));
HT.Free := Next (N (Node));
else
-- A negative free store value means that the links of the nodes
-- in the free store have not been initialized. In this case, the
-- nodes are physically contiguous in the array, starting at the
-- index that is the absolute value of the Container.Free, and
-- continuing until the end of the array (Nodes'Last).
Node := abs HT.Free;
-- As above, we perform this assignment first, before modifying
-- any container state.
Set_Element (N (Node));
HT.Free := HT.Free - 1;
end if;
end Generic_Allocate;
-------------------
-- Generic_Equal --
-------------------
function Generic_Equal
(L, R : Hash_Table_Type'Class) return Boolean
is
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
Lock_L : With_Lock (L.TC'Unrestricted_Access);
Lock_R : With_Lock (R.TC'Unrestricted_Access);
L_Index : Hash_Type;
L_Node : Count_Type;
N : Count_Type;
begin
if L'Address = R'Address then
return True;
end if;
if L.Length /= R.Length then
return False;
end if;
if L.Length = 0 then
return True;
end if;
-- Find the first node of hash table L
L_Index := L.Buckets'First;
loop
L_Node := L.Buckets (L_Index);
exit when L_Node /= 0;
L_Index := L_Index + 1;
end loop;
-- For each node of hash table L, search for an equivalent node in hash
-- table R.
N := L.Length;
loop
if not Find (HT => R, Key => L.Nodes (L_Node)) then
return False;
end if;
N := N - 1;
L_Node := Next (L.Nodes (L_Node));
if L_Node = 0 then
-- We have exhausted the nodes in this bucket
if N = 0 then
return True;
end if;
-- Find the next bucket
loop
L_Index := L_Index + 1;
L_Node := L.Buckets (L_Index);
exit when L_Node /= 0;
end loop;
end if;
end loop;
end Generic_Equal;
-----------------------
-- Generic_Iteration --
-----------------------
procedure Generic_Iteration (HT : Hash_Table_Type'Class) is
Node : Count_Type;
begin
if HT.Length = 0 then
return;
end if;
for Indx in HT.Buckets'Range loop
Node := HT.Buckets (Indx);
while Node /= 0 loop
Process (Node);
Node := Next (HT.Nodes (Node));
end loop;
end loop;
end Generic_Iteration;
------------------
-- Generic_Read --
------------------
procedure Generic_Read
(Stream : not null access Root_Stream_Type'Class;
HT : out Hash_Table_Type'Class)
is
N : Count_Type'Base;
begin
Clear (HT);
Count_Type'Base'Read (Stream, N);
if Checks and then N < 0 then
raise Program_Error with "stream appears to be corrupt";
end if;
if N = 0 then
return;
end if;
if Checks and then N > HT.Capacity then
raise Capacity_Error with "too many elements in stream";
end if;
for J in 1 .. N loop
declare
Node : constant Count_Type := New_Node (Stream);
Indx : constant Hash_Type := Checked_Index (HT, Node);
B : Count_Type renames HT.Buckets (Indx);
begin
Set_Next (HT.Nodes (Node), Next => B);
B := Node;
end;
HT.Length := HT.Length + 1;
end loop;
end Generic_Read;
-------------------
-- Generic_Write --
-------------------
procedure Generic_Write
(Stream : not null access Root_Stream_Type'Class;
HT : Hash_Table_Type'Class)
is
procedure Write (Node : Count_Type);
pragma Inline (Write);
procedure Write is new Generic_Iteration (Write);
-----------
-- Write --
-----------
procedure Write (Node : Count_Type) is
begin
Write (Stream, HT.Nodes (Node));
end Write;
begin
Count_Type'Base'Write (Stream, HT.Length);
Write (HT);
end Generic_Write;
-----------
-- Index --
-----------
function Index
(Buckets : Buckets_Type;
Node : Node_Type) return Hash_Type is
begin
return Buckets'First + Hash_Node (Node) mod Buckets'Length;
end Index;
function Index
(HT : Hash_Table_Type'Class;
Node : Node_Type) return Hash_Type is
begin
return Index (HT.Buckets, Node);
end Index;
----------
-- Next --
----------
function Next
(HT : Hash_Table_Type'Class;
Node : Count_Type) return Count_Type
is
Result : Count_Type;
First : Hash_Type;
begin
Result := Next (HT.Nodes (Node));
if Result /= 0 then -- another node in same bucket
return Result;
end if;
-- This was the last node in the bucket, so move to the next
-- bucket, and start searching for next node from there.
First := Checked_Index (HT'Unrestricted_Access.all, Node) + 1;
for Indx in First .. HT.Buckets'Last loop
Result := HT.Buckets (Indx);
if Result /= 0 then -- bucket is not empty
return Result;
end if;
end loop;
return 0;
end Next;
end Ada.Containers.Hash_Tables.Generic_Bounded_Operations;
|
package body System.Mantissa is
pragma Suppress (All_Checks);
type Unsigned is mod 2 ** Integer'Size;
function clz (X : Unsigned) return Unsigned
with Import, Convention => Intrinsic, External_Name => "__builtin_clz";
-- implementation
function Mantissa_Value (First, Last : Integer) return Natural is
Max : Integer;
begin
if First < 0 then
declare
Actual_First : constant Integer := -(First + 1); -- bitwise not
begin
if Last <= 0 then
Max := Actual_First; -- First <= Last <= 0
else
Max := Integer'Max (Actual_First, Last);
end if;
end;
else
Max := Last; -- 0 <= First <= Last
end if;
if Max = 0 then
return 0;
else
return Natural (
(clz (Unsigned'Mod (Max)) xor (Integer'Size - 1)) + 1);
end if;
end Mantissa_Value;
end System.Mantissa;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 2016, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Describe I2C Master registers
with Interfaces; use Interfaces;
with System; use System;
package I2cm is
type Reserved_2 is mod 2**2;
type Reserved_3 is mod 2**3;
type Reserved_6 is mod 2**6;
type Reserved_24 is mod 2**24;
pragma Warnings (Off, "reverse bit order in machine scalar*");
type I2cm_Clock_Prescale_Register is record
Prescale : Unsigned_16;
Reserved : Unsigned_16;
end record;
for I2cm_Clock_Prescale_Register'Bit_Order use Low_Order_First;
for I2cm_Clock_Prescale_Register use record
Reserved at 0 range 16 .. 31;
Prescale at 0 range 0 .. 15;
end record;
type I2cm_Control_Register is record
Res_0 : Reserved_6;
Ien : Boolean;
En : Boolean;
Res_1 : Reserved_24;
end record;
for I2cm_Control_Register'Bit_Order use Low_Order_First;
for I2cm_Control_Register use record
Res_0 at 0 range 0 .. 5;
Ien at 0 range 6 .. 6;
En at 0 range 7 .. 7;
Res_1 at 0 range 8 .. 31;
end record;
type I2cm_Data_Register is record
Data : Unsigned_8;
Res : Reserved_24;
end record;
for I2cm_Data_Register'Bit_Order use Low_Order_First;
for I2cm_Data_Register use record
Data at 0 range 0 .. 7;
Res at 0 range 8 .. 31;
end record;
type I2cm_Command_Register is record
Iack : Boolean;
Res_0 : Reserved_2;
Ack : Boolean;
Wr : Boolean;
Rd : Boolean;
Sto : Boolean;
Sta : Boolean;
Res_1 : Reserved_24;
end record;
for I2cm_Command_Register'Bit_Order use Low_Order_First;
for I2cm_Command_Register use record
Iack at 0 range 0 .. 0;
Res_0 at 0 range 1 .. 2;
Ack at 0 range 3 .. 3;
Wr at 0 range 4 .. 4;
Rd at 0 range 5 .. 5;
Sto at 0 range 6 .. 6;
Sta at 0 range 7 .. 7;
Res_1 at 0 range 8 .. 31;
end record;
type I2cm_Status_Register is record
Iflg : Boolean;
Tip : Boolean;
Res_0 : Reserved_3;
Al : Boolean;
Busy : Boolean;
Rxack : Boolean;
Res_1 : Reserved_24;
end record;
for I2cm_Status_Register'Bit_Order use Low_Order_First;
for I2cm_Status_Register use record
Iflg at 0 range 0 .. 0;
Tip at 0 range 1 .. 1;
Res_0 at 0 range 2 .. 4;
Al at 0 range 5 .. 5;
Busy at 0 range 6 .. 6;
Rxack at 0 range 7 .. 7;
Res_1 at 0 range 8 .. 31;
end record;
pragma Warnings (On, "reverse bit order in machine scalar*");
end I2cm;
|
-----------------------------------------------------------------------
-- GtkAda - Ada95 binding for Gtk+/Gnome --
-- --
-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet --
-- Copyright (C) 2000-2008, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-----------------------------------------------------------------------
with System;
with Glib.Type_Conversion_Hooks;
package body Gtk.Event_Box is
package Type_Conversion is new Glib.Type_Conversion_Hooks.Hook_Registrator
(Get_Type'Access, Gtk_Event_Box_Record);
pragma Warnings (Off, Type_Conversion);
-------------
-- Gtk_New --
-------------
procedure Gtk_New (Event_Box : out Gtk_Event_Box) is
begin
Event_Box := new Gtk_Event_Box_Record;
Gtk.Event_Box.Initialize (Event_Box);
end Gtk_New;
----------------
-- Initialize --
----------------
procedure Initialize (Event_Box : access Gtk_Event_Box_Record'Class) is
function Internal return System.Address;
pragma Import (C, Internal, "gtk_event_box_new");
begin
Set_Object (Event_Box, Internal);
end Initialize;
------------------------
-- Set_Visible_Window --
------------------------
procedure Set_Visible_Window
(Event_Box : access Gtk_Event_Box_Record;
Visible_Window : Boolean)
is
procedure Internal (Event_Box : System.Address; Visible : Integer);
pragma Import (C, Internal, "gtk_event_box_set_visible_window");
begin
Internal (Get_Object (Event_Box), Boolean'Pos (Visible_Window));
end Set_Visible_Window;
------------------------
-- Get_Visible_Window --
------------------------
function Get_Visible_Window
(Event_Box : access Gtk_Event_Box_Record) return Boolean
is
function Internal (Box : System.Address) return Integer;
pragma Import (C, Internal, "gtk_event_box_get_visible_window");
begin
return Internal (Get_Object (Event_Box)) /= 0;
end Get_Visible_Window;
---------------------
-- Set_Above_Child --
---------------------
procedure Set_Above_Child
(Event_Box : access Gtk_Event_Box_Record;
Above_Child : Boolean)
is
procedure Internal (Box : System.Address; Above : Integer);
pragma Import (C, Internal, "gtk_event_box_set_above_child");
begin
Internal (Get_Object (Event_Box), Boolean'Pos (Above_Child));
end Set_Above_Child;
---------------------
-- Get_Above_Child --
---------------------
function Get_Above_Child
(Event_Box : access Gtk_Event_Box_Record) return Boolean
is
function Internal (Box : System.Address) return Integer;
pragma Import (C, Internal, "gtk_event_box_get_above_child");
begin
return Internal (Get_Object (Event_Box)) /= 0;
end Get_Above_Child;
end Gtk.Event_Box;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . P A R A M E T E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2021, AdaCore --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- This package defines basic parameters used by the low level tasking system
-- This is the x86-64 version of this package
pragma Restrictions (No_Elaboration_Code);
package System.BB.Parameters is
pragma Pure;
--------------------
-- Hardware clock --
--------------------
Ticks_Per_Second : constant := 1_000_000_000;
-- On x86-64 we read the TSC frequency from the CPU and convert that time
-- to nanoseconds.
TSC_Frequency : constant := 0;
-- The frequency of the Time Stamp Clock (TSC) in Hertz. When set to zero
-- the runtime will attempt to determine its value from the processor's
-- internal registers following the guidelines provided by the Intel 64 and
-- IA-32 Architectures Software Developer's Manual, Volume 3B, Section
-- 18.7.3. Since the TSC clock source is implemented differently across
-- the different Intel chip families, on some certain processors the
-- runtime may fail to either determine the TSC frequency or will set it
-- incorrectly. In the former case the runtime will raise a Program_Error
-- on boot, while for the latter always check to ensure the timing
-- behaviour is as expected. In both cases you will need to manual set the
-- TSC_Frequency constant above.
APIC_Timer_Divider : constant := 16;
-- Since the timer frequency is typically in GHz, clock the timer down as
-- we do not need such a fine grain timer capable of firing every
-- nanosecond (which also means the longest delay we can have before
-- having to reset the 32-bit timer is ~ 1 second). Instead we aim for
-- microsecond granularity.
----------------
-- Interrupts --
----------------
-- These definitions are in this package in order to isolate target
-- dependencies.
subtype Interrupt_Range is Natural range 0 .. 255;
-- Number of interrupts supported by the Local APIC
------------
-- Stacks --
------------
Interrupt_Stack_Frame_Size : constant := 8 * 1024; -- bytes
-- Size of the interrupt stack used for handling an interrupt.
Interrupt_Stack_Size : constant :=
Interrupt_Stack_Frame_Size *
(Interrupt_Priority'Last - Interrupt_Priority'First + 1);
-- Total size of the interrupt stack per processor. Each processor
-- allocates an individual interrupt stack frame for each priority level.
Interrupt_Sec_Stack_Size : constant := 128;
-- Size of the secondary stack for interrupt handlers
Exception_Stack_Size : constant := 4096; -- bytes
-- Size for each processor exception stack.
----------
-- CPUS --
----------
Max_Number_Of_CPUs : constant := 1;
-- Maximum number of CPUs
Multiprocessor : constant Boolean := Max_Number_Of_CPUs /= 1;
-- Are we on a multiprocessor board?
end System.BB.Parameters;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
-- ユーザーログ表示ツールです、CGIとして公開しないでください
with Tabula.Users.Lists.Dump;
with Vampire.Configurations;
procedure Vampire.Dump_Users_Log is
begin
Tabula.Users.Lists.Dump (
Users_Directory => Configurations.Users_Directory'Access,
Users_Log_File_Name => Configurations.Users_Log_File_Name'Access);
end Vampire.Dump_Users_Log;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.Simulation_Jobs is
type Fixed_Update_Job is new Jobs.Abstract_Parallel_Job with record
Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
Count : Natural;
end record;
type Update_Job is new Jobs.Abstract_Parallel_Job with record
Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
end record;
type After_Update_Job is new Jobs.Abstract_Parallel_Job with record
Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
View_Position : Behaviors.Vector4;
end record;
type Finished_Fixed_Update_Job is new Jobs.Abstract_Job with record
Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
View_Position : Behaviors.Vector4;
Batch_Length : Positive;
end record;
overriding
procedure Execute
(Object : Fixed_Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive);
overriding
procedure Execute
(Object : Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive);
overriding
procedure Execute
(Object : After_Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive);
overriding
procedure Execute
(Object : Finished_Fixed_Update_Job;
Context : Jobs.Execution_Context'Class);
-----------------------------------------------------------------------------
type Start_Render_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record
Fence : not null access Fences.Buffer_Fence;
end record;
type Scene_Render_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record
Render : Simulation.Render_Ptr;
Scene : Behaviors.Behavior_Array_Access;
Camera : Cameras.Camera_Ptr;
end record;
type Finish_Render_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record
Fence : not null access Fences.Buffer_Fence;
end record;
overriding
procedure Execute
(Object : Start_Render_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : Scene_Render_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : Finish_Render_Job;
Context : Jobs.Execution_Context'Class);
-----------------------------------------------------------------------------
-- CONSTRUCTORS --
-----------------------------------------------------------------------------
function Create_Fixed_Update_Job
(Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
Count : Natural) return Jobs.Parallel_Job_Ptr
is (new Fixed_Update_Job'
(Jobs.Abstract_Parallel_Job with
Scene => Scene, Time_Step => Time_Step, Count => Count));
function Create_Update_Job
(Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span) return Jobs.Parallel_Job_Ptr
is (new Update_Job'
(Jobs.Abstract_Parallel_Job with Scene => Scene, Time_Step => Time_Step));
function Create_After_Update_Job
(Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
Position : Behaviors.Vector4) return Jobs.Parallel_Job_Ptr
is (new After_Update_Job'
(Jobs.Abstract_Parallel_Job with
Scene => Scene, Time_Step => Time_Step, View_Position => Position));
function Create_Finished_Job
(Scene : not null Behaviors.Behavior_Array_Access;
Time_Step : Time_Span;
Position : Behaviors.Vector4;
Batch_Length : Positive) return Jobs.Job_Ptr
is (new Finished_Fixed_Update_Job'
(Jobs.Abstract_Job with
Scene => Scene, Time_Step => Time_Step, View_Position => Position,
Batch_Length => Batch_Length));
-----------------------------------------------------------------------------
-- CONSTRUCTORS --
-----------------------------------------------------------------------------
function Create_Start_Render_Job
(Fence : not null access Fences.Buffer_Fence) return Jobs.Job_Ptr
is (new Start_Render_Job'(Jobs.Abstract_Job with Fence => Fence));
function Create_Scene_Render_Job
(Render : Simulation.Render_Ptr;
Scene : not null Behaviors.Behavior_Array_Access;
Camera : Cameras.Camera_Ptr) return Jobs.Job_Ptr
is (new Scene_Render_Job'(Jobs.Abstract_Job with
Render => Render, Scene => Scene, Camera => Camera));
function Create_Finish_Render_Job
(Fence : not null access Fences.Buffer_Fence) return Jobs.Job_Ptr
is (new Finish_Render_Job'(Jobs.Abstract_Job with Fence => Fence));
-----------------------------------------------------------------------------
-- EXECUTE PROCEDURES --
-----------------------------------------------------------------------------
overriding
procedure Execute
(Object : Fixed_Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive)
is
DT : constant Duration := To_Duration (Object.Time_Step);
begin
for Behavior of Object.Scene (From .. To) loop
for Iteration in 1 .. Object.Count loop
Behavior.Fixed_Update (DT);
end loop;
end loop;
end Execute;
overriding
procedure Execute
(Object : Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive)
is
DT : constant Duration := To_Duration (Object.Time_Step);
begin
for Behavior of Object.Scene (From .. To) loop
Behavior.Update (DT);
end loop;
end Execute;
overriding
procedure Execute
(Object : After_Update_Job;
Context : Jobs.Execution_Context'Class;
From, To : Positive)
is
DT : constant Duration := To_Duration (Object.Time_Step);
begin
for Behavior of Object.Scene (From .. To) loop
Behavior.After_Update (DT, Object.View_Position);
end loop;
end Execute;
function Clone_Update_Job
(Job : Jobs.Parallel_Job_Ptr;
Length : Positive) return Jobs.Dependency_Array
is
Object : constant Update_Job := Update_Job (Job.all);
begin
return Result : constant Jobs.Dependency_Array (1 .. Length)
:= (others => new Update_Job'(Object));
end Clone_Update_Job;
function Clone_After_Update_Job
(Job : Jobs.Parallel_Job_Ptr;
Length : Positive) return Jobs.Dependency_Array
is
Object : constant After_Update_Job := After_Update_Job (Job.all);
begin
return Result : constant Jobs.Dependency_Array (1 .. Length)
:= (others => new After_Update_Job'(Object));
end Clone_After_Update_Job;
function Clone_Fixed_Update_Job
(Job : Jobs.Parallel_Job_Ptr;
Length : Positive) return Jobs.Dependency_Array
is
Object : constant Fixed_Update_Job := Fixed_Update_Job (Job.all);
begin
return Result : constant Jobs.Dependency_Array (1 .. Length)
:= (others => new Fixed_Update_Job'(Object));
end Clone_Fixed_Update_Job;
overriding
procedure Execute
(Object : Finished_Fixed_Update_Job;
Context : Jobs.Execution_Context'Class)
is
Update_Job : constant Jobs.Job_Ptr :=
Jobs.Parallelize (Create_Update_Job (Object.Scene, Object.Time_Step),
Clone_Update_Job'Access, Object.Scene'Length, Object.Batch_Length);
After_Update_Job : constant Jobs.Job_Ptr :=
Jobs.Parallelize (Create_After_Update_Job
(Object.Scene, Object.Time_Step, Object.View_Position),
Clone_After_Update_Job'Access, Object.Scene'Length, Object.Batch_Length);
begin
After_Update_Job.Set_Dependency (Update_Job);
Context.Enqueue (Update_Job);
end Execute;
-----------------------------------------------------------------------------
-- EXECUTE PROCEDURES --
-----------------------------------------------------------------------------
overriding
procedure Execute
(Object : Start_Render_Job;
Context : Jobs.Execution_Context'Class)
is
Status : Fences.Fence_Status;
begin
Object.Fence.Prepare_Index (Status);
end Execute;
overriding
procedure Execute
(Object : Scene_Render_Job;
Context : Jobs.Execution_Context'Class) is
begin
Object.Render (Object.Scene, Object.Camera);
end Execute;
overriding
procedure Execute
(Object : Finish_Render_Job;
Context : Jobs.Execution_Context'Class) is
begin
Object.Fence.Advance_Index;
end Execute;
end Orka.Simulation_Jobs;
|
-- This spec has been automatically generated from STM32WL5x_CM0P.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.PKA is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_MODE_Field is HAL.UInt6;
-- control register
type CR_Register is record
-- PKA enable.
EN : Boolean := False;
-- start the operation
START : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- PKA operation code
MODE : CR_MODE_Field := 16#0#;
-- unspecified
Reserved_14_16 : HAL.UInt3 := 16#0#;
-- PROCENDIE
PROCENDIE : Boolean := False;
-- unspecified
Reserved_18_18 : HAL.Bit := 16#0#;
-- RAM error interrupt enable
RAMERRIE : Boolean := False;
-- Address error interrupt enable
ADDRERRIE : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
EN at 0 range 0 .. 0;
START at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
MODE at 0 range 8 .. 13;
Reserved_14_16 at 0 range 14 .. 16;
PROCENDIE at 0 range 17 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
RAMERRIE at 0 range 19 .. 19;
ADDRERRIE at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- status register
type SR_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16;
-- Read-only. PKA operation is in progressThis bit is set to 1 whenever
-- START bit in the PKA_CR is set. It is automatically cleared when the
-- computation is complete, meaning that PKA RAM can be safely accessed
-- and a new operation can be started.
BUSY : Boolean;
-- Read-only. PKA End of Operation flag
PROCENDF : Boolean;
-- unspecified
Reserved_18_18 : HAL.Bit;
-- Read-only. PKA RAM error flag
RAMERRF : Boolean;
-- Read-only. Address error flag
ADDRERRF : Boolean;
-- unspecified
Reserved_21_31 : HAL.UInt11;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
Reserved_0_15 at 0 range 0 .. 15;
BUSY at 0 range 16 .. 16;
PROCENDF at 0 range 17 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
RAMERRF at 0 range 19 .. 19;
ADDRERRF at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- clear flag register
type CLRFR_Register is record
-- unspecified
Reserved_0_16 : HAL.UInt17 := 16#0#;
-- Write-only. Clear PKA End of Operation flag
PROCENDFC : Boolean := False;
-- unspecified
Reserved_18_18 : HAL.Bit := 16#0#;
-- Write-only. Clear PKA RAM error flag
RAMERRFC : Boolean := False;
-- Write-only. Clear Address error flag
ADDRERRFC : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CLRFR_Register use record
Reserved_0_16 at 0 range 0 .. 16;
PROCENDFC at 0 range 17 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
RAMERRFC at 0 range 19 .. 19;
ADDRERRFC at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Public key accelerator
type PKA_Peripheral is record
-- control register
CR : aliased CR_Register;
-- status register
SR : aliased SR_Register;
-- clear flag register
CLRFR : aliased CLRFR_Register;
end record
with Volatile;
for PKA_Peripheral use record
CR at 16#0# range 0 .. 31;
SR at 16#4# range 0 .. 31;
CLRFR at 16#8# range 0 .. 31;
end record;
-- Public key accelerator
PKA_Periph : aliased PKA_Peripheral
with Import, Address => PKA_Base;
end STM32_SVD.PKA;
|
package Base with SPARK_Mode is
type Number is array (Positive range <>) of Character;
function Encode (S : String) return Number
-- length of result will be longer than input, so need to guard against
-- too large input. Selecting some very restricted value, we could
-- probably bound this much better
with Pre => S'Length < Integer'Last / 200;
function Decode (N : Number) return String;
end Base;
|
-- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with Gnattest_Generated;
package DG_Types.Test_Data.Tests is
type Test is new GNATtest_Generated.GNATtest_Standard.DG_Types.Test_Data.Test
with null record;
procedure Test_Boolean_To_YN_3d5779 (Gnattest_T : in out Test);
-- dg_types.ads:111:5:Boolean_To_YN
procedure Test_Clear_W_Bit_3be3ae (Gnattest_T : in out Test);
-- dg_types.ads:114:5:Clear_W_Bit
procedure Test_Flip_W_Bit_d2d2b6 (Gnattest_T : in out Test);
-- dg_types.ads:115:5:Flip_W_Bit
procedure Test_Set_W_Bit_f63f6c (Gnattest_T : in out Test);
-- dg_types.ads:116:5:Set_W_Bit
procedure Test_Test_W_Bit_7a11db (Gnattest_T : in out Test);
-- dg_types.ads:117:5:Test_W_Bit
procedure Test_Get_W_Bits_ea9a74 (Gnattest_T : in out Test);
-- dg_types.ads:118:5:Get_W_Bits
procedure Test_Get_DW_Bits_a2bf67 (Gnattest_T : in out Test);
-- dg_types.ads:119:5:Get_DW_Bits
procedure Test_Test_DW_Bit_799079 (Gnattest_T : in out Test);
-- dg_types.ads:120:5:Test_DW_Bit
procedure Test_Clear_QW_Bit_f212ea (Gnattest_T : in out Test);
-- dg_types.ads:121:5:Clear_QW_Bit
procedure Test_Set_QW_Bit_1b4331 (Gnattest_T : in out Test);
-- dg_types.ads:122:5:Set_QW_Bit
procedure Test_Test_QW_Bit_2ec078 (Gnattest_T : in out Test);
-- dg_types.ads:123:5:Test_QW_Bit
procedure Test_Get_Lower_Byte_2c7e4b (Gnattest_T : in out Test);
-- dg_types.ads:126:5:Get_Lower_Byte
procedure Test_Get_Upper_Byte_d89a4b (Gnattest_T : in out Test);
-- dg_types.ads:127:5:Get_Upper_Byte
procedure Test_Swap_Bytes_7d46a7 (Gnattest_T : in out Test);
-- dg_types.ads:128:5:Swap_Bytes
procedure Test_Get_Bytes_From_Word_075975 (Gnattest_T : in out Test);
-- dg_types.ads:129:5:Get_Bytes_From_Word
procedure Test_Word_From_Bytes_ea4510 (Gnattest_T : in out Test);
-- dg_types.ads:130:5:Word_From_Bytes
procedure Test_Byte_To_String_d93915 (Gnattest_T : in out Test);
-- dg_types.ads:131:5:Byte_To_String
procedure Test_Low_Byte_To_Char_00e4b2 (Gnattest_T : in out Test);
-- dg_types.ads:137:5:Low_Byte_To_Char
procedure Test_Byte_Arr_To_Unbounded_8c1bb0 (Gnattest_T : in out Test);
-- dg_types.ads:138:5:Byte_Arr_To_Unbounded
procedure Test_Get_Data_Sensitive_Portion_2234ef (Gnattest_T : in out Test);
-- dg_types.ads:139:5:Get_Data_Sensitive_Portion
procedure Test_Word_To_String_8605e3 (Gnattest_T : in out Test);
-- dg_types.ads:142:5:Word_To_String
procedure Test_Lower_Word_3da74d (Gnattest_T : in out Test);
-- dg_types.ads:149:5:Lower_Word
procedure Test_Upper_Word_05c493 (Gnattest_T : in out Test);
-- dg_types.ads:150:5:Upper_Word
procedure Test_Dword_From_Two_Words_3c389f (Gnattest_T : in out Test);
-- dg_types.ads:151:5:Dword_From_Two_Words
procedure Test_Dword_To_String_55061d (Gnattest_T : in out Test);
-- dg_types.ads:152:5:Dword_To_String
procedure Test_String_To_Dword_3c5214 (Gnattest_T : in out Test);
-- dg_types.ads:158:5:String_To_Dword
procedure Test_Sext_Word_To_Dword_45b429 (Gnattest_T : in out Test);
-- dg_types.ads:159:5:Sext_Word_To_Dword
procedure Test_Lower_Dword_d008b0 (Gnattest_T : in out Test);
-- dg_types.ads:162:5:Lower_Dword
procedure Test_Upper_Dword_1042da (Gnattest_T : in out Test);
-- dg_types.ads:163:5:Upper_Dword
procedure Test_Qword_From_Two_Dwords_e0cb2c (Gnattest_T : in out Test);
-- dg_types.ads:164:5:Qword_From_Two_Dwords
procedure Test_Int_To_String_506364 (Gnattest_T : in out Test);
-- dg_types.ads:168:5:Int_To_String
procedure Test_String_To_Integer_fdacf8 (Gnattest_T : in out Test);
-- dg_types.ads:175:5:String_To_Integer
procedure Test_Decode_Dec_Data_Type_056a82 (Gnattest_T : in out Test);
-- dg_types.ads:178:5:Decode_Dec_Data_Type
procedure Test_Read_Decimal_385668 (Gnattest_T : in out Test);
-- dg_types.ads:182:5:Read_Decimal
procedure Test_DG_Double_To_Long_Float_2d8c8f (Gnattest_T : in out Test);
-- dg_types.ads:185:5:DG_Double_To_Long_Float
procedure Test_DG_Single_To_Long_Float_aba5b2 (Gnattest_T : in out Test);
-- dg_types.ads:186:5:DG_Single_To_Long_Float
procedure Test_Long_Float_To_DG_Double_8175dc (Gnattest_T : in out Test);
-- dg_types.ads:187:5:Long_Float_To_DG_Double
procedure Test_Long_Float_To_DG_Single_d6dcc8 (Gnattest_T : in out Test);
-- dg_types.ads:188:5:Long_Float_To_DG_Single
procedure Test_Byte_To_Integer_8_6ac9f0 (Gnattest_T : in out Test);
-- dg_types.ads:191:5:Byte_To_Integer_8
procedure Test_Char_To_Byte_11390e (Gnattest_T : in out Test);
-- dg_types.ads:192:5:Char_To_Byte
procedure Test_Byte_To_Char_7742da (Gnattest_T : in out Test);
-- dg_types.ads:193:5:Byte_To_Char
procedure Test_Dword_To_Integer_32_e9169d (Gnattest_T : in out Test);
-- dg_types.ads:194:5:Dword_To_Integer_32
procedure Test_Dword_To_Integer_bb8284 (Gnattest_T : in out Test);
-- dg_types.ads:195:5:Dword_To_Integer
procedure Test_Integer_32_To_Dword_67c35b (Gnattest_T : in out Test);
-- dg_types.ads:196:5:Integer_32_To_Dword
procedure Test_Integer_32_To_Phys_0e179b (Gnattest_T : in out Test);
-- dg_types.ads:197:5:Integer_32_To_Phys
procedure Test_Word_To_Integer_16_a3a65b (Gnattest_T : in out Test);
-- dg_types.ads:198:5:Word_To_Integer_16
procedure Test_Integer_16_To_Word_40bf8b (Gnattest_T : in out Test);
-- dg_types.ads:199:5:Integer_16_To_Word
procedure Test_Word_To_Unsigned_16_d3e005 (Gnattest_T : in out Test);
-- dg_types.ads:200:5:Word_To_Unsigned_16
procedure Test_Integer_64_To_Unsigned_64_f5c627 (Gnattest_T : in out Test);
-- dg_types.ads:201:5:Integer_64_To_Unsigned_64
procedure Test_Unsigned_32_To_Integer_5e891f (Gnattest_T : in out Test);
-- dg_types.ads:202:5:Unsigned_32_To_Integer
procedure Test_Integer_To_Unsigned_64_d5b49e (Gnattest_T : in out Test);
-- dg_types.ads:203:5:Integer_To_Unsigned_64
end DG_Types.Test_Data.Tests;
-- end read only
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with GNAT.OS_Lib;
with Ada.Command_Line; use Ada.Command_Line;
with System;
with Ada.Unchecked_Conversion;
with Build_Options;
procedure Getr is
type Long is mod 2**64;
type TimeVal is record
sec : Long;
usec : Long;
end record;
-- type Reserved is array(Integer range <>) of U64;
-- use to pad RUsage if C lib's getrusage() has a 'reserved' member
type RUsage is record
User_Time : TimeVal;
System_Time : TimeVal;
Max_RSS : Long;
Shared_RSS : Long;
Unshared_RSS : Long;
Unshared_Stack : Long;
Minor_Faults : Long;
Major_Faults : Long;
Swaps : Long;
In_Blocks : Long;
Out_Blocks : Long;
Msg_Send : Long;
Msg_Recv : Long;
Signal_Recv : Long;
Vol_Context : Long;
Invol_Context : Long;
-- Reserved_Padding : Reserved(1 .. 10);
end record;
function getrusage (Who : Integer; Report : access RUsage) return Integer;
pragma Import (C, getrusage, "getrusage");
RUSAGE_CHILDREN : constant Integer := -1;
function posix_spawn
(Pid : access Integer;
Path : Interfaces.C.Strings.chars_ptr;
File_Actions : System.Address;
Attrp : System.Address;
Argv : System.Address;
Envp : System.Address)
return Integer;
pragma Import (C, posix_spawn, "posix_spawn");
function waitpid
(Pid : Integer;
Wstatus : System.Address;
Options : Integer)
return Integer;
pragma Import (C, waitpid, "waitpid");
Usage : aliased RUsage;
SpawnN : Integer;
function Image (J : in Long) return String is
Str : constant String := Long'Image (J);
begin
return Str (2 .. Str'Length);
end Image;
procedure Put_Times (Key : String; Tv : TimeVal) is
begin
Put_Line
(Standard_Error,
Key & Image (Tv.sec) & " s, " & Image (Tv.usec) & " us");
end Put_Times;
procedure Put_Time (Key : String; MS : Long) is
begin
Put (Standard_Error, Key & Image (MS) & " ms (");
Put
(Standard_Error,
Float (MS) / Float (SpawnN),
Fore => 0,
Aft => 3,
Exp => 0);
Put_Line (Standard_Error, " ms/per)");
end Put_Time;
procedure Put_Unit (Key : String; Val : Long; Unit : String) is
begin
Put_Line (Standard_Error, Key & Image (Val) & " " & Unit);
end Put_Unit;
procedure Put_Val (Key : String; Val : Long) is
begin
Put_Line (Standard_Error, Key & Image (Val));
end Put_Val;
procedure Report_Usage is
sec : Long;
usec : Long;
Time_MS : Long;
begin
if 0 /= getrusage (RUSAGE_CHILDREN, Usage'Access) then
Put_Line ("Error: getrusage() failed");
else
sec := Usage.User_Time.sec + Usage.System_Time.sec;
usec := Usage.User_Time.usec + Usage.System_Time.usec;
Time_MS := (sec * 1000) + (usec / 1000);
Put_Times ("User time : ", Usage.User_Time);
Put_Times ("System time : ", Usage.System_Time);
Put_Time ("Time : ", Time_MS);
if Build_Options.macOS then
Put_Unit ("Max RSS : ", Usage.Max_RSS / 1024, "kB");
else
Put_Unit ("Max RSS : ", Usage.Max_RSS, "kB");
end if;
Put_Val ("Page reclaims : ", Usage.Minor_Faults);
Put_Val ("Page faults : ", Usage.Major_Faults);
Put_Val ("Block inputs : ", Usage.In_Blocks);
Put_Val ("Block outputs : ", Usage.Out_Blocks);
Put_Val ("vol ctx switches : ", Usage.Vol_Context);
Put_Val ("invol ctx switches : ", Usage.Invol_Context);
end if;
end Report_Usage;
procedure Spawns is
Environ : constant System.Address;
pragma Import (C, Environ, "environ");
function Get_Null is new Ada.Unchecked_Conversion (System.Address,
chars_ptr);
Nullstr : constant chars_ptr := Get_Null (System.Null_Address);
Child : aliased Integer;
Command : chars_ptr := New_String (Argument (2));
Args : array (1 .. Argument_Count) of chars_ptr :=
(1 => Command, others => Nullstr);
begin
for J in 2 .. Argument_Count loop
Args (J - 1) := New_String (Argument (J));
end loop;
for J in 1 .. SpawnN loop
if 0 /=
posix_spawn
(Child'Access, Command, System.Null_Address, System.Null_Address,
Args'Address, Environ)
then
Put_Line (Standard_Error, "Error: posix_spawn() failed");
GNAT.OS_Lib.OS_Exit (1);
end if;
if -1 = waitpid (Child, System.Null_Address, 0) then
Put_Line (Standard_Error, "Error: waitpid failed");
GNAT.OS_Lib.OS_Exit (1);
end if;
end loop;
Free (Command);
for J in Args'Range loop
Free (Args (J));
end loop;
end Spawns;
begin
if Argument_Count > 1 then
SpawnN := Positive'Value (Argument (1));
Spawns;
Report_Usage;
else
Put_Line
(Standard_Error,
"usage: " & Command_Name & " <n> <command> [<args> ...]");
GNAT.OS_Lib.OS_Exit (1);
end if;
end Getr;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT INTERFACE COMPONENTS --
-- --
-- A S I S . T E X T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) for use with GNAT. The copyright --
-- notice above, and the license provisions that follow apply solely to the --
-- contents of the part following the private keyword. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 20 package Asis.Text
------------------------------------------------------------------------------
------------------------------------------------------------------------------
package Asis.Text is
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Asis.Text
--
-- This package encapsulates a set of operations to access the text of ASIS
-- Elements. It assumes no knowledge of the existence, location, or form of
-- the program text.
--
-- The text of a program consists of the texts of one or more compilations.
-- The text of each compilation is a sequence of separate lexical elements.
-- Each lexical element is either a delimiter, an identifier (which can be a
-- reserved word), a numeric literal, a character literal, a string literal,
-- blank space, or a comment.
--
-- Each ASIS Element has a text image whose value is the series of characters
-- contained by the text span of the Element. The text span covers all the
-- characters from the first character of the Element through the last
-- character of the Element over some range of lines.
--
-- General Usage Rules:
--
-- Line lists can be indexed to obtain individual lines. The bounds of each
-- list correspond to the lines with those same numbers from the compilation
-- text.
--
-- Any Asis.Text query may raise ASIS_Failed with a Status of Text_Error if
-- the program text cannot be located or retrieved for any reason such as
-- renaming, deletion, corruption, or moving of the text.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 20.1 type Line
------------------------------------------------------------------------------
-- An Ada text line abstraction (a private type).
--
-- Used to represent text fragments from a compilation.
-- ASIS Lines are representations of the compilation text.
-- This shall be supported by all ASIS implementations.
------------------------------------------------------------------------------
type Line is private;
Nil_Line : constant Line;
function "=" (Left : Line; Right : Line) return Boolean is abstract;
-- Nil_Line is the value of an uninitialized Line object.
--
------------------------------------------------------------------------------
-- 20.2 type Line_Number
------------------------------------------------------------------------------
-- Line_Number
--
-- A numeric subtype that allows each ASIS implementation to place constraints
-- on the upper bound for Line_List elements and compilation unit size.
--
-- The upper bound of Line_Number (Maximum_Line_Number) is the only
-- allowed variation for these declarations.
--
-- Line_Number = 0 is reserved to act as an "invalid" Line_Number value. No
-- unit text line will ever have a Line_Number of zero.
------------------------------------------------------------------------------
-- Line shall be an undiscriminated private type, or, shall be derived from an
-- undiscriminated private type. It can be declared as a new type or as a
-- subtype of an existing type.
------------------------------------------------------------------------------
Maximum_Line_Number : constant ASIS_Natural :=
Implementation_Defined_Integer_Constant;
subtype Line_Number is ASIS_Natural range 0 .. Maximum_Line_Number;
------------------------------------------------------------------------------
-- 20.3 type Line_Number_Positive
------------------------------------------------------------------------------
subtype Line_Number_Positive is Line_Number range 1 .. Maximum_Line_Number;
------------------------------------------------------------------------------
-- 20.4 type Line_List
------------------------------------------------------------------------------
type Line_List is array (Line_Number_Positive range <>) of Line;
Nil_Line_List : constant Line_List;
------------------------------------------------------------------------------
-- 20.5 type Character_Position
------------------------------------------------------------------------------
-- Character_Position
--
-- A numeric subtype that allows each ASIS implementation to place constraints
-- on the upper bound for Character_Position and for compilation unit line
-- lengths.
--
-- The upper bound of Character_Position (Maximum_Line_Length) is the
-- only allowed variation for these declarations.
--
-- Character_Position = 0 is reserved to act as an "invalid"
-- Character_Position value. No unit text line will ever have a character in
-- position zero.
------------------------------------------------------------------------------
Maximum_Line_Length : constant ASIS_Natural :=
Implementation_Defined_Integer_Constant;
subtype Character_Position is ASIS_Natural range 0 .. Maximum_Line_Length;
------------------------------------------------------------------------------
-- 20.6 type Character_Position_Positive
------------------------------------------------------------------------------
subtype Character_Position_Positive is
Character_Position range 1 .. Maximum_Line_Length;
------------------------------------------------------------------------------
-- 20.7 type Span
------------------------------------------------------------------------------
-- Span
--
-- A single text position is identified by a line number and a column number,
-- that represent the text's position within the compilation unit.
--
-- The text of an element can span one or more lines. The textual Span of an
-- element identifies the lower and upper bound of a span of text positions.
--
-- Spans and positions give client tools the option of accessing compilation
-- unit text through the queries provided by this package, or, to access
-- the text directly through the original compilation unit text file. Type
-- span
-- facilitates the capture of comments before or after an element.
--
-- Note: The original compilation unit text may or may not have existed in a
-- "file", and any such file may or may not still exist. Reference Manual 10.1
-- specifies that the text of a compilation unit is submitted to a compiler.
-- It does not specify that the text is stored in a "file", nor does it
-- specify that the text of a compilation unit has any particular lifetime.
------------------------------------------------------------------------------
type Span is -- Default is Nil_Span
record
First_Line : Line_Number_Positive := 1; -- 1..0 - empty
First_Column : Character_Position_Positive := 1; -- 1..0 - empty
Last_Line : Line_Number := 0;
Last_Column : Character_Position := 0;
end record;
Nil_Span : constant Span := (First_Line => 1,
First_Column => 1,
Last_Line => 0,
Last_Column => 0);
------------------------------------------------------------------------------
-- 20.8 function First_Line_Number
------------------------------------------------------------------------------
function First_Line_Number (Element : Asis.Element) return Line_Number;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the first line number on which the text of the element resides.
--
-- Returns 0 if not Is_Text_Available(Element).
--
-- --|AN Application Note:
-- --|AN
-- --|AN The line number recorded for a particular element may or may not
-- --|AN match the "true" line number of the program text for that element if
-- --|AN the Ada environment and the local text editors do not agree on the
-- --|AN definition of "line". For example, the Reference Manual states that
-- --|AN any occurrence of an ASCII.Cr character is to be treated as one or
-- --|AN more end-of-line occurrences. On most Unix systems, the editors do
-- --|AN not treat a carriage return as being an end-of-line character.
-- --|AN
-- --|AN Ada treats all of the following as end-of-line characters: ASCII.Cr,
-- --|AN ASCII.Lf, ASCII.Ff, ASCII.Vt. It is up to the compilation system to
-- --|AN determine whether sequences of these characters causes one, or more,
-- --|AN end-of-line occurrences. Be warned, if the Ada environment and the
-- --|AN system editor (or any other line-counting program) do not use the
-- --|AN same end-of-line conventions, then the line numbers reported by ASIS
-- --|AN may not match those reported by those other programs.
--
------------------------------------------------------------------------------
-- 20.9 function Last_Line_Number
------------------------------------------------------------------------------
function Last_Line_Number (Element : Asis.Element) return Line_Number;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the last line number on which the text of the element resides.
--
-- Returns 0 if not Is_Text_Available(Element).
--
------------------------------------------------------------------------------
-- 20.10 function Element_Span
------------------------------------------------------------------------------
function Element_Span (Element : Asis.Element) return Span;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the span of the given element.
--
-- Returns a Nil_Span if the text of a Compilation_Unit (Compilation) cannot
-- be located for any reason.
-- --|AN
-- --|AN For this query, Element is only a means to access the
-- --|AN Compilation_Unit (Compilation), the availability of the text of this
-- --|AN Element itself is irrelevant to the result of the query.
--
------------------------------------------------------------------------------
-- 20.11 function Compilation_Unit_Span
------------------------------------------------------------------------------
function Compilation_Unit_Span (Element : Asis.Element) return Span;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the span of the text comprising the enclosing compilation unit of
-- the given element.
--
-- Returns a Nil_Span if the text of a Compilation_Unit (Compilation) cannot
-- be located for any reason.
-- --|AN
-- --|AN For this query, Element is only a means to access the
-- --|AN Compilation_Unit (Compilation), the availability of the text of this
-- --|AN Element itself is irrelevant to the result of the query.
--
------------------------------------------------------------------------------
-- 20.12 function Compilation_Span
------------------------------------------------------------------------------
function Compilation_Span (Element : Asis.Element) return Span;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns the span of the text comprising the compilation to which the
-- element belongs. The text span may include one or more compilation units.
--
-- Returns a Nil_Span if not Is_Text_Available(Element).
--
------------------------------------------------------------------------------
-- 20.13 function Is_Nil
------------------------------------------------------------------------------
function Is_Nil (Right : Line) return Boolean;
------------------------------------------------------------------------------
-- Right - Specifies the line to check
--
-- Returns True if the argument is the Nil_Line.
--
-- A Line from a Line_List obtained from any of the Lines functions
-- will not be Is_Nil even if it has a length of zero.
--
------------------------------------------------------------------------------
-- 20.14 function Is_Nil
------------------------------------------------------------------------------
function Is_Nil (Right : Line_List) return Boolean;
------------------------------------------------------------------------------
-- Right - Specifies the line list to check
--
-- Returns True if the argument has a 'Length of zero.
--
------------------------------------------------------------------------------
-- 20.15 function Is_Nil
------------------------------------------------------------------------------
function Is_Nil (Right : Span) return Boolean;
------------------------------------------------------------------------------
-- Right - Specifies the Span to check
--
-- Returns True if the argument has a Nil_Span.
--
------------------------------------------------------------------------------
-- 20.16 function Is_Equal
------------------------------------------------------------------------------
function Is_Equal (Left : Line; Right : Line) return Boolean;
------------------------------------------------------------------------------
-- Left - Specifies the first of the two lines
-- Right - Specifies the second of the two lines
--
-- Returns True if the two lines encompass the same text (have the same Span
-- and are from the same compilation).
--
------------------------------------------------------------------------------
-- 20.17 function Is_Identical
------------------------------------------------------------------------------
function Is_Identical (Left : Line; Right : Line) return Boolean;
------------------------------------------------------------------------------
-- Left - Specifies the first of the two lines
-- Right - Specifies the second of the two lines
--
-- Returns True if the two lines encompass the same text (have the same Span
-- and are from the same compilation) and are from the same Context.
--
------------------------------------------------------------------------------
-- 20.18 function Length
------------------------------------------------------------------------------
function Length (The_Line : Line) return Character_Position;
------------------------------------------------------------------------------
-- The_Line - Specifies the line to query
--
-- Returns the length of the line.
--
-- Raises ASIS_Inappropriate_Line if Is_Nil (The_Line).
--
------------------------------------------------------------------------------
-- 20.19 function Lines
------------------------------------------------------------------------------
function Lines (Element : Asis.Element) return Line_List;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns a list of lines covering the span of the given program element.
--
-- Returns a Nil_Span if the text of a Compilation containing a given
-- Element cannot be located for any reason.
--
-- Line lists can be indexed to obtain individual lines. The bounds of each
-- list correspond to the lines with those same numbers in the compilation
-- text.
--
-- The first Line of the result contains text from the compilation starting at
-- the First_Line/First_Column of Element's Span. The last Line of the result
-- contains text from the compilation ending at the Last_Line/Last_Column of
-- the Element's Span. Text before or after those limits is not reflected
-- in the returned list.
-- --|AN
-- --|AN For this query, Element is only a means to access the
-- --|AN Compilation_Unit (Compilation), the availability of the text of this
-- --|AN Element itself is irrelevant to the result of the query.
--
------------------------------------------------------------------------------
-- 20.20 function Lines
------------------------------------------------------------------------------
function Lines
(Element : Asis.Element;
The_Span : Span)
return Line_List;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
-- The_Span - Specifies the textual span to return
--
-- Returns a list of lines covering the given span from the compilation
-- containing the given program element.
--
-- Returns a Nil_Span if the text of a Compilation containing a given
-- Element cannot be located for any reason.
--
-- This operation can be used to access lines from text outside the span of an
-- element, but still within the compilation. For example, lines containing
-- preceding comments or lines between two elements.
--
-- Line lists can be indexed to obtain individual lines. The bounds of each
-- list correspond to the lines with those same numbers in the compilation
-- text.
--
-- The first Line of the result contains text from the compilation starting at
-- line Span.First_Line and column Span.First_Column. The last Line of the
-- result contains text from the compilation ending at line Span.Last_Line and
-- column Span.Last_Column. Text before or after those limits is not
-- reflected in the returned list.
--
-- Raises ASIS_Inappropriate_Line_Number if Is_Nil (The_Span). If
-- The_Span defines a line whose number is outside the range of text lines
-- that can be accessed through the Element, the implementation is encouraged,
-- but not required to raise ASIS_Inappropriate_Line_Number.
-- --|AN
-- --|AN For this query, Element is only a means to access the
-- --|AN Compilation_Unit (Compilation), the availability of the text of this
-- --|AN Element itself is irrelevant to the result of the query.
--
------------------------------------------------------------------------------
-- 20.21 function Lines
------------------------------------------------------------------------------
function Lines
(Element : Asis.Element;
First_Line : Line_Number_Positive;
Last_Line : Line_Number)
return Line_List;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
-- First_Line - Specifies the first line to return
-- Last_Line - Specifies the last line to return
--
-- Returns a list of Lines covering the full text for each of the indicated
-- lines from the compilation containing the given element. This operation
-- can be used to access lines from text outside the span of an element, but
-- still within the compilation.
--
-- Returns a Nil_Span if the text of a Compilation containing a given
-- Element cannot be located for any reason.
--
-- Line lists can be indexed to obtain individual lines. The bounds of each
-- list correspond to the lines with those same numbers in the compilation
-- text.
--
-- Raises ASIS_Inappropriate_Line_Number if the span is nil. If the span
-- defines a line whose number is outside the range of text lines that can be
-- accessed through the Element, the implementation is encouraged, but not
-- required to raise ASIS_Inappropriate_Line_Number.
-- --|AN
-- --|AN For this query, Element is only a means to access the
-- --|AN Compilation_Unit (Compilation), the availability of the text of this
-- --|AN Element itself is irrelevant to the result of the query.
--
------------------------------------------------------------------------------
-- 20.22 function Delimiter_Image
------------------------------------------------------------------------------
function Delimiter_Image return Wide_String;
------------------------------------------------------------------------------
-- Returns the string used as the delimiter separating individual lines of
-- text within the program text image of an element. It is also used as the
-- delimiter separating individual lines of strings returned by Debug_Image.
--
------------------------------------------------------------------------------
-- 20.23 function Element_Image
------------------------------------------------------------------------------
function Element_Image (Element : Asis.Element) return Program_Text;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns a program text image of the element. The image of an element can
-- span more than one line, in which case the program text returned by the
-- function Delimiter_Image separates the individual lines. The bounds on
-- the returned program text value are 1..N, N is as large as necessary.
--
-- Returns a null string if not Is_Text_Available(Element).
--
-- If an Element's Span begins at column position P, the returned program text
-- will be padded at the beginning with P-1 white space characters (ASCII.' '
-- or ASCII.Ht). The first character of the Element's image will thus begin
-- at character P of the returned program text. Due to the possible presence
-- of ASCII.Ht characters, the "column" position of characters within the
-- image might not be the same as their print-column positions when the image
-- is displayed on a screen or printed.
--
-- NOTE: The image of a large element can exceed the range of Program_Text.
-- In this case, the exception ASIS_Failed is raised with a Status of
-- Capacity_Error. Use the Lines function to operate on the image of large
-- elements.
--
------------------------------------------------------------------------------
-- 20.24 function Line_Image
------------------------------------------------------------------------------
function Line_Image (The_Line : Line) return Program_Text;
------------------------------------------------------------------------------
-- The_Line - Specifies the line to query
--
-- Returns a program text image of the line. The image of a single lexical
-- element can be sliced from the returned value using the first and last
-- column character positions from the Span of the Element. The bounds on the
-- returned program text are 1 .. Length(Line).
--
-- If the Line is the first line from the Lines result for an Element, it can
-- represent only a portion of a line from the original compilation. If the
-- span began at character position P, the first Line of it's Lines
-- result is padded at the beginning with P-1 white space characters
-- (ASCII.' ' or ASCII.Ht). The first character of the image will
-- thus begin at character P of the program text for the first Line. Due to
-- the possible presence of ASCII.Ht characters, the "column" position of
-- characters within the image may not be the same as their print-column
-- positions when the image is displayed or printed.
--
-- Similarly, if the Line is the last line from the Lines result for an
-- Element, it may represent only a portion of a line from the original
-- compilation. The program text image of such a Line is shorter than the
-- line from compilation and will contain only the initial portion of
-- that line.
--
-- Raises ASIS_Inappropriate_Line if Is_Nil (The_Line).
--
------------------------------------------------------------------------------
-- 20.25 function Non_Comment_Image
------------------------------------------------------------------------------
function Non_Comment_Image (The_Line : Line) return Program_Text;
------------------------------------------------------------------------------
-- The_Line - Specifies the line to query
--
-- Returns a program text image of a Line up to, but excluding, any comment
-- appearing in that Line.
--
-- The value returned is the same as that returned by the Image function,
-- except that any hyphens ("--") that start a comment, and any characters
-- that follow those hyphens, are dropped.
--
-- The bounds on the returned program text are 1..N, where N is one less than
-- the column of any hyphens ("--") that start a comment on the line.
--
-- Raises ASIS_Inappropriate_Line if Is_Nil (The_Line).
--
------------------------------------------------------------------------------
-- 20.26 function Comment_Image
------------------------------------------------------------------------------
function Comment_Image (The_Line : Line) return Program_Text;
------------------------------------------------------------------------------
-- The_Line - Specifies the line to query
--
-- Returns a program text image of any comment on that line, excluding any
-- lexical elements preceding the comment.
--
-- The value returned is the same as that returned by the Image function,
-- except that any program text prior to the two adjacent hyphens ("--") which
-- start a comment is replaced by an equal number of spaces. If the hyphens
-- began in column P of the Line, they will also begin in character position
-- P of the returned program text.
--
-- A null string is returned if the line has no comment.
--
-- The bounds of the program text are 1..N, where N is as large as necessary.
--
-- Raises ASIS_Inappropriate_Line if Is_Nil (The_Line).
--
------------------------------------------------------------------------------
-- 20.27 function Is_Text_Available
------------------------------------------------------------------------------
function Is_Text_Available (Element : Asis.Element) return Boolean;
------------------------------------------------------------------------------
-- Element - Specifies the element to query
--
-- Returns True if the implementation can return a valid text image for the
-- given element.
--
-- Returns False for any Element that Is_Nil, Is_Part_Of_Implicit, or
-- Is_Part_Of_Instance.
--
-- Returns False if the text of the element cannot be located for any reason
-- such as renaming, deletion, or moving of text.
--
-- --|IR Implementation Requirements:
-- --|IR
-- --|IR An implementation shall make text available for all explicit
-- --|IR elements.
--
------------------------------------------------------------------------------
-- 20.28 function Debug_Image
------------------------------------------------------------------------------
function Debug_Image (The_Line : Line) return Wide_String;
------------------------------------------------------------------------------
-- The_Line - Specifies the line to convert
--
-- Returns a string value containing implementation-defined debug
-- information associated with the line.
--
-- The return value uses Asis.Text.Delimiter_Image to separate the lines
-- of multi-line results. The return value does not end with
-- Asis.Text.Delimiter_Image.
--
-- These values are intended for two purposes. They are suitable for
-- inclusion in problem reports sent to the ASIS implementor. They can
-- be presumed to contain information useful when debugging the
-- implementation itself. They are also suitable for use by the ASIS
-- application when printing simple application debugging messages during
-- application development. They are intended to be, to some worthwhile
-- degree, intelligible to the user.
--
------------------------------------------------------------------------------
private
-- The content of this private part is specific for the ASIS
-- implementation for GNAT
------------------------------------------------------------------------------
type Line is
record
Sloc : Source_Ptr := No_Location;
Comment_Sloc : Source_Ptr := No_Location;
Length : Character_Position := 0;
Rel_Sloc : Source_Ptr := No_Location;
Enclosing_Unit : Unit_Id := Nil_Unit;
Enclosing_Context : Context_Id := Non_Associated;
Enclosing_Tree : Tree_Id := Nil_Tree;
Obtained : ASIS_OS_Time := Nil_ASIS_OS_Time;
end record;
Nil_Line : constant Line := (Sloc => No_Location,
Comment_Sloc => No_Location,
Length => 0,
Rel_Sloc => No_Location,
Enclosing_Unit => Nil_Unit,
Enclosing_Context => Non_Associated,
Enclosing_Tree => Nil_Tree,
Obtained => Nil_ASIS_OS_Time);
-- Note, that Line does not have the predefined "=" operation (it is
-- overridden by an abstract "=". The predefined "=" is explicitly
-- simulated in the implementation of Is_Nil query, so, if the full
-- declaration for Line is changed, the body of Is_Nil should be revised.
-----------------------------
-- Fields in the Line type --
-----------------------------
-- Sloc : Source_Ptr := No_Location;
-- indicates the beginning of the corresponding line in the Source
-- Buffer. If a given Line is the first line covering the Image of
-- some Element, the position in the Source Buffer pointed by Sloc
-- may or may not correspond to the beginning of the source text
-- line
--
-- Comment_Sloc - represents the starting Sloc position of a comment
-- that is a part of the line. Set to 0 if the line does not contain a
-- a comment. Note, that we assume that in the comment text the bracket
-- encoding can not be used for wide characters
--
-- Length : Character_Position := 0;
-- represents the length of the Line, excluding any character
-- signifying end of line (RM95, 2.2(2))
-- Note, that in the compiler lines of the source code are represented
-- using the String type, and if the line contains a wide character that
-- requires more than one one-byte character for its representation, the
-- length of one-byte character string used to represent wide-character
-- string from the source code may be bigger then the length of the
-- original source line (length here is the number of characters). In the
-- Line type we keep the lenth of the source line counted in source
-- characters, but not the length of the internal representation in
-- one-byte characters. Note that this length does not depend on the
-- encoding method.
--
-- Rel_Sloc : Source_Ptr := No_Location;
-- needed to compare string representing elements of the same
-- compilation units, but probably obtained from different trees
-- containing this unit. Obtained in the same way as for Elements -
-- by subtracting from Sloc field the source location of the
-- N_Compilation_Unit node
--
-- Enclosing_Unit : Unit_Id := Nil_Unit;
-- Enclosing_Context : Context_Id := Non_Associated;
-- These fields represent the Context in which and the Compilation
-- Unit from which the given line was obtained, they are needed
-- for comparing Lines and for tree swapping when obtaining
-- Line_Image
--
-- Enclosing_Tree : Tree_Id := Nil_Tree;
-- Sloc field may be used for obtaining the image of a Line only in
-- the tree from which it was obtained. So the Line has to keep
-- the reference to the tree for tree swapping
--
-- Obtained : ASIS_OS_Time := Nil_ASIS_OS_Time;
-- Lines, as well as Elements, cannot be used after closing the
-- Context from which they were obtained. We use time comparing
-- to check the validity of a Line
-- In the current implementation, ASIS Lines are mapped onto logical
-- GNAT lines, as defined in the Sinput package.
-- The child package Asis.Text.Set_Get defines operations for
-- accessing and updating fields of Lines, for checking the validity
-- of a Line and for creating the new value of the Line type.
-- (This package is similar to the Asis.Set_Get package, which
-- defines similar things for other ASIS abstractions - Element,
-- Context, Compilation_Unit.)
Nil_Line_List : constant Line_List (1 .. 0) := (1 .. 0 => Nil_Line);
------------------------------------------------------------------------------
end Asis.Text;
|
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets;
procedure Demo is
begin
Put_Line (GNAT.Sockets.Host_Name);
end Demo;
|
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Bounded string list and table support (for output formatting).
--
------------------------------------------------------------------------------
with SPAT.String_Vectors;
package SPAT.Strings is
package Implementation is
-- Provide instantiations of the bounded vectors for our different string
-- types.
package Subjects is new String_Vectors (Element_Type => Subject_Name,
"=" => "=",
Length => Length);
package Entities is new String_Vectors (Element_Type => Entity_Name,
"=" => "=",
Length => Length);
package SPARK_File_Names is new
String_Vectors (Element_Type => SPARK_File_Name,
"=" => "=",
Length => Length);
end Implementation;
-- A one dimensional list of strings.
type Subject_Names is new Implementation.Subjects.List with private;
type Entity_Names is new Implementation.Entities.List with private;
type SPARK_File_Names is new
Implementation.SPARK_File_Names.List with private;
Empty_Subjects : constant Subject_Names;
Empty_Names : constant Entity_Names;
Empty_Files : constant SPARK_File_Names;
private
type Subject_Names is new Implementation.Subjects.List with null record;
type Entity_Names is new Implementation.Entities.List with null record;
type SPARK_File_Names is new
Implementation.SPARK_File_Names.List with null record;
Empty_Subjects : constant Subject_Names :=
(Implementation.Subjects.Empty with null record);
Empty_Names : constant Entity_Names :=
(Implementation.Entities.Empty with null record);
Empty_Files : constant SPARK_File_Names :=
(Implementation.SPARK_File_Names.Empty with null record);
end SPAT.Strings;
|
with Ada.Text_IO;
with Ada.Directories;
with Ada.Command_Line;
with Templates_Parser;
with CLIC.TTY;
with Filesystem;
with Commands;
with Blueprint; use Blueprint;
package body Init_Project is
package IO renames Ada.Text_IO;
package TT renames CLIC.TTY;
use Ada.Directories;
Errors : Boolean := false;
Filter : constant Filter_Type :=
(Ordinary_File => True, Special_File => False, Directory => True);
procedure Init (Path : String; ToDo: Action) is
Blueprint_Folder : String := Get_Blueprint_Folder;
App_Blueprint_Folder : String := Compose (Blueprint_Folder, "app");
Blueprint : String := "standard";
Blueprint_Path : String := Compose (App_Blueprint_Folder, Blueprint);
Name : String := Simple_Name (Path);
begin
Templates_Parser.Insert
(Commands.Translations, Templates_Parser.Assoc ("APPNAME", Name));
if Exists (Blueprint_Path) then
IO.Put_Line
(TT.Italic ("Creating a new project") & " " & TT.Bold (Path) & ":");
Iterate (Blueprint_Path, Path, ToDo);
IO.New_Line;
if Errors then
IO.Put_Line
(TT.Warn ("Created project") & " " & TT.Bold (Name) & " " & "with errors.");
else
IO.Put_Line (TT.Success( "Successfully created project") & " " & TT.Warn (TT.Bold (Name)));
end if;
IO.New_Line;
IO.Put_Line
(TT.Info
(TT.Description ("Build your project using") & " " &
TT.Terminal ("/scripts/build.sh")));
IO.Put_Line
(TT.Info
(TT.Description ("Add components and other items using") & " " &
TT.Terminal ("glad generate")));
else
IO.Put_Line (TT.Error("Blueprint not found: " & Blueprint_Path));
end if;
-- TODO: Move text out into xml file
end Init;
end Init_Project; |
-----------------------------------------------------------------------
-- util-http-clients-mockups -- HTTP Clients mockups
-- Copyright (C) 2011, 2012, 2017, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Http.Clients;
with Ada.Strings.Unbounded;
package Util.Http.Clients.Mockups is
-- Register the Http manager.
procedure Register;
-- Set the path of the file that contains the response for the next
-- <b>Do_Get</b> and <b>Do_Post</b> calls.
procedure Set_File (Path : in String);
private
type File_Http_Manager is new Http_Manager with record
File : Ada.Strings.Unbounded.Unbounded_String;
end record;
type File_Http_Manager_Access is access all File_Http_Manager'Class;
procedure Create (Manager : in File_Http_Manager;
Http : in out Client'Class);
overriding
procedure Do_Get (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Head (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Post (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Put (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Patch (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Data : in String;
Reply : out Response'Class);
overriding
procedure Do_Delete (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
overriding
procedure Do_Options (Manager : in File_Http_Manager;
Http : in Client'Class;
URI : in String;
Reply : out Response'Class);
-- Set the timeout for the connection.
overriding
procedure Set_Timeout (Manager : in File_Http_Manager;
Http : in Client'Class;
Timeout : in Duration);
end Util.Http.Clients.Mockups;
|
-- Test_Input_Lengths
-- Ensure that associated data of different length are accepted and messages
-- of different lengths correctly encrypt and decrypt. This is largely aimed
-- at checking the implementation of padding.
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
with Ascon;
with System.Storage_Elements;
use System.Storage_Elements;
generic
with package Ascon_Package is new Ascon(<>);
Max_Size : System.Storage_Elements.Storage_Offset := 2000;
Other_Size : System.Storage_Elements.Storage_Offset := 73;
procedure Test_Input_Lengths;
|
------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This package handles all actions related to the AURA repositories registered
-- in a given AURA project, including checking-out subsystems, and verifying
-- previously checked-out subsystems
with Ada.Assertions;
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
with Progress;
package Repositories is
type Repository_Count is new Natural;
subtype Repository_Index is Repository_Count
range 1 .. Repository_Count'Last;
Root_Repository: constant Repository_Index := Repository_Index'First;
-- This repository automatically exists in all AURA projects, and is used to
-- detach subsystems from any upstream repository, or to handle locally
-- created subsystems
type Repository_Format is
(System,
-- System repositories are special kinds of "local" repositories that
-- have been precompiled into a set of per-subsystem shared libraries.
--
-- The central repository location (which may not be the current
-- directory) is expected to contain .ali files for all units within
-- each subsystem, and a shared library file corresponding to each
-- subsystem in a directory named "aura_lib".
--
-- Central repositories are always cached (checked for changes). Any
-- changes must be explicitly accepted by the user for any build process
-- to succeed.
--
-- Checked-out subsystems from System repositories are formed as
-- symbolic links, and are never compiled.
--
-- Subsystems checked-out from a System repository shall not have any
-- dependencies on subsystems from any other repository. This is checked
-- after all subsystems are checked-out, so it is up to the user to
-- ensure that requisite subsystems are checkedout out from the same
-- repository, or the process will fail.
Local,
-- Local repositories are simply a directory containing some set of
-- AURA Subsystems (in their respective sub-directories).
--
-- Snapshot is a recursive SHA1 hash of all files (except "dot files") in
-- the repository path, in lexicographical order
Git);
-- A git repository. Snapshot is the full commit hash.
type Repository_Cache_State is
(Standby,
-- The repository has been loaded but has not yet been needed, hence the
-- cache state has not yet been evaluated
Requested,
-- The repository is needed to aquire some subsystems
Available);
-- Repository is cached (git), or exists and has been verified (local)
package UBS renames Ada.Strings.Unbounded;
type Repository (Format: Repository_Format := Local) is
record
Location : UBS.Unbounded_String;
Snapshot : UBS.Unbounded_String;
Cache_State : Repository_Cache_State := Standby;
Cache_Path : UBS.Unbounded_String;
-- Full path to the directory containing the repository
case Format is
when Local | System =>
null;
when Git =>
Tracking_Branch: UBS.Unbounded_String;
end case;
end record;
package Repository_Vectors is new Ada.Containers.Vectors
(Index_Type => Repository_Index,
Element_Type => Repository);
---------------------------
-- Repository Operations --
---------------------------
procedure Initialize_Repositories;
Initialize_Repositories_Tracker: aliased Progress.Progress_Tracker;
-- Shall be called after the Registrar has completed entery of the project
-- root directory
--
-- Initialize_Repositories takes the following actions:
--
-- 1. Clears the existing repository vector.
--
-- 2. Checks for the existence of the root AURA package (aura.ads).
-- - If it exists, it is checked for compatibility with this
-- implementation
-- - If it does not exist, it is generated, and then entered to the
-- Registrar.
-- * Note, the package will be inserted into the "Current Directory"
--
-- 3. Checks for all AURA.Respository_X packages, processes them,
-- and loads them into the internal list
--
-- 4. Verifies the "local" repository (Index 1), and generates the spec
-- if it does not already exist
--
-- Initialize_Repositories is a sequential operation (and generally very
-- quick), and so does not submit work orders or have a tracker.
--
-- After calling Initialize_Repositories, any invalid specifications can
-- be queried through the Repo's Valid component, and the error message
-- can be extracted from the Parse_Errors component.
--
-- The procedure Check_Repositories and it's associated tracker can be
-- used to verify
--
-- Initialize_Repositories may enter new units with the registrar.
------------------------
-- Repository Queries --
------------------------
-- The following operations are all task-safe
function Total_Repositories return Repository_Count;
function Extract_Repository (Index: Repository_Index)
return Repository;
function Extract_All return Repository_Vectors.Vector;
function Cache_State (Index: Repository_Index)
return Repository_Cache_State;
procedure Add_Repository (New_Repo : in Repository;
New_Index: out Repository_Index);
-- This also generates the associated spec file
procedure Update_Repository (Index : in Repository_Index;
Updated: in Repository);
-- The repository at index Index is replaced by Updated. And the
-- actual spec file is regenerated
procedure Request_Cache (Index: in Repository_Index);
-- Iff the current Cache is "Standby", it is set to "Requested"
private
procedure Update_Cache_State (Index : in Repository_Index;
New_State: in Repository_Cache_State);
-- Does not regenerate the spec file
procedure Generate_Repo_Spec (Index: Repository_Index);
-- Generates the corresponding Spec file for the repository at Index
-- of the All_Repositories vector. If a file already exists, it is replaced.
end Repositories;
|
with RASCAL.Toolbox; use RASCAL.Toolbox;
package Controller_Error is
type TEL_Toolbox_Error is new ATEL_Toolbox_Error with null record;
--
-- A Toolbox Error has occurred.
--
procedure Handle (The : in TEL_Toolbox_Error);
end Controller_Error; |
with Resources5;
with Ada.Command_Line;
with Ada.Text_IO;
procedure Test5 is
use Resources5;
begin
if Id_main_html'Length /= 356 then
Ada.Text_IO.Put_Line ("FAIL: Invalid length for 'main.html'");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
if Id_Jsmain_js'Length /= 87 then
Ada.Text_IO.Put_Line ("FAIL: Invalid length for 'js/main.js'");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
if Id_Cssmain_css'Length /= 60 then
Ada.Text_IO.Put_Line ("FAIL: Invalid length for 'css/main.css'");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
Ada.Text_IO.Put ("PASS: ");
for Val of Id_Cssmain_css loop
if Character'Val (Val) /= ASCII.LF then
Ada.Text_IO.Put (Character'Val (Val));
end if;
end loop;
Ada.Text_IO.New_Line;
end Test5;
|
--******************************************************************************
--
-- package SYSTEM
--
--******************************************************************************
package SYSTEM is
type NAME is (VAX_VMS);
SYSTEM_NAME : constant NAME := VAX_VMS;
STORAGE_UNIT : constant := 8;
MEMORY_SIZE : constant := 2**31-1;
MAX_INT : constant := 2**31-1;
MIN_INT : constant := -(2**31);
MAX_DIGITS : constant := 33;
MAX_MANTISSA : constant := 31;
FINE_DELTA : constant := 2.0**(-30);
TICK : constant := 1.0**(-2);
subtype PRIORITY is INTEGER range 0 .. 15;
-- Address type
--
type ADDRESS is private;
type interrupt_vector is array(1..100) of address;
function "+" (LEFT : ADDRESS; RIGHT : INTEGER) return ADDRESS;
function "+" (LEFT : INTEGER; RIGHT : ADDRESS) return ADDRESS;
function "-" (LEFT : ADDRESS; RIGHT : ADDRESS) return INTEGER;
function "-" (LEFT : ADDRESS; RIGHT : INTEGER) return ADDRESS;
function "<" (LEFT, RIGHT : ADDRESS) return BOOLEAN;
function "<=" (LEFT, RIGHT : ADDRESS) return BOOLEAN;
function ">=" (LEFT, RIGHT : ADDRESS) return BOOLEAN;
ADDRESS_ZERO : constant ADDRESS;
generic
type TARGET is private;
function FETCH_FROM_ADDRESS (A : ADDRESS) return TARGET;
generic
type TARGET is private;
procedure ASSIGN_TO_ADDRESS (A : ADDRESS; T : TARGET);
type TYPE_CLASS is (TYPE_CLASS_ENUMERATION,
TYPE_CLASS_INTEGER,
TYPE_CLASS_FIXED_POINT,
TYPE_CLASS_FLOATING_POINT,
TYPE_CLASS_ARRAY,
TYPE_CLASS_RECORD,
TYPE_CLASS_ACCESS,
TYPE_CLASS_TASK,
TYPE_CLASS_ADDRESS);
-- VAX Ada floating point type declarations for the VAX
-- hardware floating point data types
type D_FLOAT is digits 14 range -1.7014118346047E+38 .. 1.7014118346047E+38;
type F_FLOAT is digits 6 range -1.70141E+38 .. 1.70141E+38;
type G_FLOAT is digits 13 range -8.988465674312E+307 .. 8.988465674312E+307;
type H_FLOAT is digits 31 range -5.948657467861588254287966331400E+4931 .. 5.948657467861588254287966331400E+4931;
-- AST handler type
type AST_HANDLER is limited private;
NO_AST_HANDLER : constant AST_HANDLER;
-- Non-Ada exception
NON_ADA_ERROR : exception;
-- VAX hardware-oriented types and functions
type BIT_ARRAY is array (INTEGER range <>) of BOOLEAN;
pragma PACK(BIT_ARRAY);
subtype BIT_ARRAY_8 is BIT_ARRAY (0 .. 7);
subtype BIT_ARRAY_16 is BIT_ARRAY (0 .. 15);
subtype BIT_ARRAY_32 is BIT_ARRAY (0 .. 31);
subtype BIT_ARRAY_64 is BIT_ARRAY (0 .. 63);
type UNSIGNED_BYTE is range 0 .. 255;
for UNSIGNED_BYTE'SIZE use 8;
function "not" (LEFT : UNSIGNED_BYTE) return UNSIGNED_BYTE;
function "and" (LEFT, RIGHT : UNSIGNED_BYTE) return UNSIGNED_BYTE;
function "or" (LEFT, RIGHT : UNSIGNED_BYTE) return UNSIGNED_BYTE;
function "xor" (LEFT, RIGHT : UNSIGNED_BYTE) return UNSIGNED_BYTE;
function TO_UNSIGNED_BYTE (LEFT : BIT_ARRAY_8) return UNSIGNED_BYTE;
function TO_BIT_ARRAY_8 (LEFT : UNSIGNED_BYTE) return BIT_ARRAY_8;
type UNSIGNED_BYTE_ARRAY is array (INTEGER range <>) of UNSIGNED_BYTE;
type UNSIGNED_WORD is range 0 .. 65535;
for UNSIGNED_WORD'SIZE use 16;
function "not" (LEFT : UNSIGNED_WORD) return UNSIGNED_WORD;
function "and" (LEFT, RIGHT : UNSIGNED_WORD) return UNSIGNED_WORD;
function "or" (LEFT, RIGHT : UNSIGNED_WORD) return UNSIGNED_WORD;
function "xor" (LEFT, RIGHT : UNSIGNED_WORD) return UNSIGNED_WORD;
function TO_UNSIGNED_WORD (LEFT : BIT_ARRAY_16) return UNSIGNED_WORD;
function TO_BIT_ARRAY_16 (LEFT : UNSIGNED_WORD) return BIT_ARRAY_16;
type UNSIGNED_WORD_ARRAY is array (INTEGER range <>) of UNSIGNED_WORD;
type UNSIGNED_LONGWORD is range MIN_INT .. MAX_INT;
function "not" (LEFT : UNSIGNED_LONGWORD) return UNSIGNED_LONGWORD;
function "and" (LEFT, RIGHT : UNSIGNED_LONGWORD) return UNSIGNED_LONGWORD;
function "or" (LEFT, RIGHT : UNSIGNED_LONGWORD) return UNSIGNED_LONGWORD;
function "xor" (LEFT, RIGHT : UNSIGNED_LONGWORD) return UNSIGNED_LONGWORD;
function TO_UNSIGNED_LONGWORD (LEFT : BIT_ARRAY_32)
return UNSIGNED_LONGWORD;
function TO_BIT_ARRAY_32 (LEFT : UNSIGNED_LONGWORD) return BIT_ARRAY_32;
type UNSIGNED_LONGWORD_ARRAY is
array (INTEGER range <>) of UNSIGNED_LONGWORD;
type UNSIGNED_QUADWORD is
record
L0 : UNSIGNED_LONGWORD;
L1 : UNSIGNED_LONGWORD;
end record;
function "not" (LEFT : UNSIGNED_QUADWORD) return UNSIGNED_QUADWORD;
function "and" (LEFT, RIGHT : UNSIGNED_QUADWORD) return UNSIGNED_QUADWORD;
function "or" (LEFT, RIGHT : UNSIGNED_QUADWORD) return UNSIGNED_QUADWORD;
function "xor" (LEFT, RIGHT : UNSIGNED_QUADWORD) return UNSIGNED_QUADWORD;
function TO_UNSIGNED_QUADWORD (LEFT : BIT_ARRAY_64)
return UNSIGNED_QUADWORD;
function TO_BIT_ARRAY_64 (LEFT : UNSIGNED_QUADWORD) return BIT_ARRAY_64;
type UNSIGNED_QUADWORD_ARRAY is
array (INTEGER range <>) of UNSIGNED_QUADWORD;
function TO_ADDRESS (X : INTEGER) return ADDRESS;
function TO_ADDRESS (X : UNSIGNED_LONGWORD) return ADDRESS;
function TO_INTEGER (X : ADDRESS) return INTEGER;
function TO_UNSIGNED_LONGWORD (X : ADDRESS) return UNSIGNED_LONGWORD;
-- Conventional names for static subtypes of type UNSIGNED_LONGWORD
subtype UNSIGNED_1 is UNSIGNED_LONGWORD range 0 .. 2** 1-1;
subtype UNSIGNED_2 is UNSIGNED_LONGWORD range 0 .. 2** 2-1;
subtype UNSIGNED_3 is UNSIGNED_LONGWORD range 0 .. 2** 3-1;
subtype UNSIGNED_4 is UNSIGNED_LONGWORD range 0 .. 2** 4-1;
subtype UNSIGNED_5 is UNSIGNED_LONGWORD range 0 .. 2** 5-1;
subtype UNSIGNED_6 is UNSIGNED_LONGWORD range 0 .. 2** 6-1;
subtype UNSIGNED_7 is UNSIGNED_LONGWORD range 0 .. 2** 7-1;
subtype UNSIGNED_8 is UNSIGNED_LONGWORD range 0 .. 2** 8-1;
subtype UNSIGNED_9 is UNSIGNED_LONGWORD range 0 .. 2** 9-1;
subtype UNSIGNED_10 is UNSIGNED_LONGWORD range 0 .. 2**10-1;
subtype UNSIGNED_11 is UNSIGNED_LONGWORD range 0 .. 2**11-1;
subtype UNSIGNED_12 is UNSIGNED_LONGWORD range 0 .. 2**12-1;
subtype UNSIGNED_13 is UNSIGNED_LONGWORD range 0 .. 2**13-1;
subtype UNSIGNED_14 is UNSIGNED_LONGWORD range 0 .. 2**14-1;
subtype UNSIGNED_15 is UNSIGNED_LONGWORD range 0 .. 2**15-1;
subtype UNSIGNED_16 is UNSIGNED_LONGWORD range 0 .. 2**16-1;
subtype UNSIGNED_17 is UNSIGNED_LONGWORD range 0 .. 2**17-1;
subtype UNSIGNED_18 is UNSIGNED_LONGWORD range 0 .. 2**18-1;
subtype UNSIGNED_19 is UNSIGNED_LONGWORD range 0 .. 2**19-1;
subtype UNSIGNED_20 is UNSIGNED_LONGWORD range 0 .. 2**20-1;
subtype UNSIGNED_21 is UNSIGNED_LONGWORD range 0 .. 2**21-1;
subtype UNSIGNED_22 is UNSIGNED_LONGWORD range 0 .. 2**22-1;
subtype UNSIGNED_23 is UNSIGNED_LONGWORD range 0 .. 2**23-1;
subtype UNSIGNED_24 is UNSIGNED_LONGWORD range 0 .. 2**24-1;
subtype UNSIGNED_25 is UNSIGNED_LONGWORD range 0 .. 2**25-1;
subtype UNSIGNED_26 is UNSIGNED_LONGWORD range 0 .. 2**26-1;
subtype UNSIGNED_27 is UNSIGNED_LONGWORD range 0 .. 2**27-1;
subtype UNSIGNED_28 is UNSIGNED_LONGWORD range 0 .. 2**28-1;
subtype UNSIGNED_29 is UNSIGNED_LONGWORD range 0 .. 2**29-1;
subtype UNSIGNED_30 is UNSIGNED_LONGWORD range 0 .. 2**30-1;
subtype UNSIGNED_31 is UNSIGNED_LONGWORD range 0 .. 2**31-1;
private
-- Not shown
type AST_HANDLER is new integer;
type ADDRESS is new integer;
end SYSTEM;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . U _ C O N V --
-- --
-- B o d y --
-- --
-- Copyright (c) 1995-2006, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adaccore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Namet; use Namet;
with Fname; use Fname;
with Krunch;
with Opt; use Opt;
package body A4G.U_Conv is
---------------------------------
-- Local Types and Subprograms --
---------------------------------
-- We use the trivial finite state automata to analyse and to transform
-- strings passed as parameters to ASIS interfaces and processed by ASIS
-- itself below there are type and routines definitions for various
-- versions of this automata
type State is (Beg_Ident, Mid_Ident, Und_Line);
-- The states of the automata. Some versions may use only a part of the
-- whole set of states.
procedure Normalize_Char (In_Char : Character;
Curr_State : in out State;
Out_Char : out Character;
OK : out Boolean);
-- One step of the finite-state-automata analyzing the string which is
-- supposed to be an Ada unit name and producind the "normalized"
-- version of the name. If In_Char under in the state Curr_State may be
-- considered as belonging to the Ada unit name, the "low-case version"
-- of this character is assigned to Out_Char, and OK is ste True,
-- otherwise OK is set false
function Convert_Char (Ch : Character) return Character;
-- performs upper case -> lover case conversion in the GNAT file
-- name style (see GNAT Document INTRO and Fnames.ads - only letters
-- from the A .. Z range are folded to lower case)
------------------
-- Convert_Char --
------------------
function Convert_Char (Ch : Character) return Character is
begin
if Ch = '.' then
return '-';
else
return To_Lower (Ch);
end if;
end Convert_Char;
------------------------
-- Get_Norm_Unit_Name --
------------------------
procedure Get_Norm_Unit_Name
(U_Name : String;
N_U_Name : out String;
Spec : Boolean;
May_Be_Unit_Name : out Boolean)
is
Current_State : State := Beg_Ident;
begin
May_Be_Unit_Name := False;
for I in U_Name'Range loop
Normalize_Char (U_Name (I), Current_State,
N_U_Name (I), May_Be_Unit_Name);
exit when not May_Be_Unit_Name;
end loop;
if not May_Be_Unit_Name then
return;
elsif N_U_Name (U_Name'Last) = '_' or else
N_U_Name (U_Name'Last) = '.'
then
-- something like "Ab_" -> "ab_" or "Ab_Cd." -> "ab_cd."
May_Be_Unit_Name := False;
return;
end if;
-- here we have all the content of U_Name parced and
-- May_Be_Unit_Name is True. All we have to do is to append
-- the "%s" or "%b" suffix
N_U_Name (N_U_Name'Last - 1) := '%';
if Spec then
N_U_Name (N_U_Name'Last) := 's';
else
N_U_Name (N_U_Name'Last) := 'b';
end if;
end Get_Norm_Unit_Name;
-----------------------------
-- Is_Predefined_File_Name --
-----------------------------
function Is_Predefined_File_Name (S : String_Access) return Boolean is
begin
Namet.Name_Len := S'Length - 1;
-- "- 1" is for trailing ASCII.NUL in the file name
Namet.Name_Buffer (1 .. Namet.Name_Len) := To_String (S);
return Fname.Is_Predefined_File_Name (Namet.Name_Enter);
end Is_Predefined_File_Name;
--------------------
-- Normalize_Char --
--------------------
procedure Normalize_Char
(In_Char : Character;
Curr_State : in out State;
Out_Char : out Character;
OK : out Boolean)
is
begin
OK := True;
case Curr_State is
when Beg_Ident =>
if Is_Letter (In_Char) then
Curr_State := Mid_Ident;
else
OK := False;
end if;
when Mid_Ident =>
if Is_Letter (In_Char) or else
Is_Digit (In_Char)
then
null;
elsif In_Char = '_' then
Curr_State := Und_Line;
elsif In_Char = '.' then
Curr_State := Beg_Ident;
else
OK := False;
end if;
when Und_Line =>
if Is_Letter (In_Char) or else
Is_Digit (In_Char)
then
Curr_State := Mid_Ident;
else
OK := False;
end if;
end case;
Out_Char := To_Lower (In_Char);
end Normalize_Char;
---------------------------
-- Source_From_Unit_Name --
---------------------------
function Source_From_Unit_Name
(S : String;
Spec : Boolean)
return String_Access
is
Result_Prefix : String (1 .. S'Length);
Result_Selector : String (1 .. 4) := ".adb";
Initial_Length : constant Natural := S'Length;
Result_Length : Natural := Initial_Length;
-- this is for the name krunching
begin
for I in S'Range loop
Result_Prefix (I) := Convert_Char (S (I));
end loop;
Krunch
(Buffer => Result_Prefix,
Len => Result_Length,
Maxlen => Integer (Maximum_File_Name_Length),
No_Predef => False);
if Spec then
Result_Selector (4) := 's';
end if;
return new String'(Result_Prefix (1 .. Result_Length)
& Result_Selector
& ASCII.NUL);
end Source_From_Unit_Name;
---------------
-- To_String --
---------------
function To_String (S : String_Access) return String is
begin
return S.all (S'First .. S'Last - 1);
end To_String;
---------------------------
-- Tree_From_Source_Name --
---------------------------
function Tree_From_Source_Name (S : String_Access) return String_Access is
Return_Val : String_Access;
begin
Return_Val := new String'(S.all);
-- the content of S should be "*.ad?" & ASCII.NUL
Return_Val (Return_Val'Last - 1) := 't'; -- ".ad?" -> ".adt"
return Return_Val;
end Tree_From_Source_Name;
end A4G.U_Conv;
|
with AVR; use AVR;
with Interfaces; use Interfaces;
with Hardware.PWM; use Hardware;
package Hardware.DriveTrain is
procedure Init;
procedure Forward;
procedure Backward;
procedure Rotate_Left;
procedure Rotate_Right;
procedure Stop;
private
Motor_Right : Hardware.PWM.Servo_Index;
Motor_Left : Hardware.PWM.Servo_Index;
Pin_Right : AVR.Bit_Number := 3; -- PB5
Pin_Left : AVR.Bit_Number := 4; -- PB6
Rotate_Forward : Unsigned_16 := 1700;
Rotate_Stop : Unsigned_16 := 1500;
Rotate_Backward : Unsigned_16 := 1300;
end Hardware.DriveTrain;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Fibonacci is
function Fibonacci (N : Natural) return Natural is
This : Natural := 0;
That : Natural := 1;
Sum : Natural;
begin
for I in 1..N loop
Sum := This + That;
That := This;
This := Sum;
end loop;
return This;
end Fibonacci;
begin
for N in 0..10 loop
Put_Line (Positive'Image (Fibonacci (N)));
end loop;
end Test_Fibonacci;
|
-- Gonzalo Martin Rodriguez
-- Ivan Fernandez Samaniego
package Priorities is
Head_Priority : constant integer := 20; -- d=100, t=400
Risk_Priority : constant integer := 19; -- d=150, t=150
Sporadic_Priority : constant integer := 18; -- d=200, t=200
Distance_Priority : constant integer := 17; -- d=300, t=300
Steering_Priority : constant integer := 16; -- d=350, t=350
Display_Priority : constant integer := 15; -- d=1000, t=1000
end Priorities;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ M A P S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1996-1998 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Einfo; use Einfo;
with Namet; use Namet;
with Output; use Output;
with Sinfo; use Sinfo;
with Uintp; use Uintp;
package body Sem_Maps is
-----------------------
-- Local Subprograms --
-----------------------
function Find_Assoc (M : Map; E : Entity_Id) return Assoc_Index;
-- Standard hash table search. M is the map to be searched, E is the
-- entity to be searched for, and Assoc_Index is the resulting
-- association, or is set to No_Assoc if there is no association.
function Find_Header_Size (N : Int) return Header_Index;
-- Find largest power of two smaller than the number of entries in
-- the table. This load factor of 2 may be adjusted later if needed.
procedure Write_Map (E : Entity_Id);
pragma Warnings (Off, Write_Map);
-- For debugging purposes.
---------------------
-- Add_Association --
---------------------
procedure Add_Association
(M : in out Map;
O_Id : Entity_Id;
N_Id : Entity_Id;
Kind : Scope_Kind := S_Local)
is
Info : constant Map_Info := Maps_Table.Table (M);
Offh : constant Header_Index := Info.Header_Offset;
Offs : constant Header_Index := Info.Header_Num;
J : constant Header_Index := Header_Index (O_Id) mod Offs;
K : constant Assoc_Index := Info.Assoc_Next;
begin
Associations_Table.Table (K) := (O_Id, N_Id, Kind, No_Assoc);
Maps_Table.Table (M).Assoc_Next := K + 1;
if Headers_Table.Table (Offh + J) /= No_Assoc then
-- Place new association at head of chain.
Associations_Table.Table (K).Next := Headers_Table.Table (Offh + J);
end if;
Headers_Table.Table (Offh + J) := K;
end Add_Association;
------------------------
-- Build_Instance_Map --
------------------------
function Build_Instance_Map (M : Map) return Map is
Info : constant Map_Info := Maps_Table.Table (M);
Res : constant Map := New_Map (Int (Info.Assoc_Num));
Offh1 : constant Header_Index := Info.Header_Offset;
Offa1 : constant Assoc_Index := Info.Assoc_Offset;
Offh2 : constant Header_Index := Maps_Table.Table (Res).Header_Offset;
Offa2 : constant Assoc_Index := Maps_Table.Table (Res).Assoc_Offset;
A : Assoc;
A_Index : Assoc_Index;
begin
for J in 0 .. Info.Header_Num - 1 loop
A_Index := Headers_Table.Table (Offh1 + J);
if A_Index /= No_Assoc then
Headers_Table.Table (Offh2 + J) := A_Index + (Offa2 - Offa1);
end if;
end loop;
for J in 0 .. Info.Assoc_Num - 1 loop
A := Associations_Table.Table (Offa1 + J);
-- For local entities that come from source, create the
-- corresponding local entities in the instance. Entities that
-- do not come from source are etypes, and new ones will be
-- generated when analyzing the instance.
if No (A.New_Id)
and then A.Kind = S_Local
and then Comes_From_Source (A.Old_Id)
then
A.New_Id := New_Copy (A.Old_Id);
A.New_Id := New_Entity (Nkind (A.Old_Id), Sloc (A.Old_Id));
Set_Chars (A.New_Id, Chars (A.Old_Id));
end if;
if A.Next /= No_Assoc then
A.Next := A.Next + (Offa2 - Offa1);
end if;
Associations_Table.Table (Offa2 + J) := A;
end loop;
Maps_Table.Table (Res).Assoc_Next := Associations_Table.Last;
return Res;
end Build_Instance_Map;
-------------
-- Compose --
-------------
function Compose (Orig_Map : Map; New_Map : Map) return Map is
Res : constant Map := Copy (Orig_Map);
Off : constant Assoc_Index := Maps_Table.Table (Res).Assoc_Offset;
A : Assoc;
K : Assoc_Index;
begin
-- Iterate over the contents of Orig_Map, looking for entities
-- that are further mapped under New_Map.
for J in 0 .. Maps_Table.Table (Res).Assoc_Num - 1 loop
A := Associations_Table.Table (Off + J);
K := Find_Assoc (New_Map, A.New_Id);
if K /= No_Assoc then
Associations_Table.Table (Off + J).New_Id
:= Associations_Table.Table (K).New_Id;
end if;
end loop;
return Res;
end Compose;
----------
-- Copy --
----------
function Copy (M : Map) return Map is
Info : constant Map_Info := Maps_Table.Table (M);
Res : constant Map := New_Map (Int (Info.Assoc_Num));
Offh1 : constant Header_Index := Info.Header_Offset;
Offa1 : constant Assoc_Index := Info.Assoc_Offset;
Offh2 : constant Header_Index := Maps_Table.Table (Res).Header_Offset;
Offa2 : constant Assoc_Index := Maps_Table.Table (Res).Assoc_Offset;
A : Assoc;
A_Index : Assoc_Index;
begin
for J in 0 .. Info.Header_Num - 1 loop
A_Index := Headers_Table.Table (Offh1 + J) + (Offa2 - Offa1);
if A_Index /= No_Assoc then
Headers_Table.Table (Offh2 + J) := A_Index + (Offa2 - Offa1);
end if;
end loop;
for J in 0 .. Info.Assoc_Num - 1 loop
A := Associations_Table.Table (Offa1 + J);
A.Next := A.Next + (Offa2 - Offa1);
Associations_Table.Table (Offa2 + J) := A;
end loop;
Maps_Table.Table (Res).Assoc_Next := Associations_Table.Last;
return Res;
end Copy;
----------------
-- Find_Assoc --
----------------
function Find_Assoc (M : Map; E : Entity_Id) return Assoc_Index is
Offh : constant Header_Index := Maps_Table.Table (M).Header_Offset;
Offs : constant Header_Index := Maps_Table.Table (M).Header_Num;
J : constant Header_Index := Header_Index (E) mod Offs;
A : Assoc;
A_Index : Assoc_Index;
begin
A_Index := Headers_Table.Table (Offh + J);
if A_Index = No_Assoc then
return A_Index;
else
A := Associations_Table.Table (A_Index);
while Present (A.Old_Id) loop
if A.Old_Id = E then
return A_Index;
elsif A.Next = No_Assoc then
return No_Assoc;
else
A_Index := A.Next;
A := Associations_Table.Table (A.Next);
end if;
end loop;
return No_Assoc;
end if;
end Find_Assoc;
----------------------
-- Find_Header_Size --
----------------------
function Find_Header_Size (N : Int) return Header_Index is
Siz : Header_Index;
begin
Siz := 2;
while 2 * Siz < Header_Index (N) loop
Siz := 2 * Siz;
end loop;
return Siz;
end Find_Header_Size;
------------
-- Lookup --
------------
function Lookup (M : Map; E : Entity_Id) return Entity_Id is
Offh : constant Header_Index := Maps_Table.Table (M).Header_Offset;
Offs : constant Header_Index := Maps_Table.Table (M).Header_Num;
J : constant Header_Index := Header_Index (E) mod Offs;
A : Assoc;
begin
if Headers_Table.Table (Offh + J) = No_Assoc then
return Empty;
else
A := Associations_Table.Table (Headers_Table.Table (Offh + J));
while Present (A.Old_Id) loop
if A.Old_Id = E then
return A.New_Id;
elsif A.Next = No_Assoc then
return Empty;
else
A := Associations_Table.Table (A.Next);
end if;
end loop;
return Empty;
end if;
end Lookup;
-------------
-- New_Map --
-------------
function New_Map (Num_Assoc : Int) return Map is
Header_Size : Header_Index := Find_Header_Size (Num_Assoc);
Res : Map_Info;
begin
-- Allocate the tables for the new map at the current end of the
-- global tables.
Associations_Table.Increment_Last;
Headers_Table.Increment_Last;
Maps_Table.Increment_Last;
Res.Header_Offset := Headers_Table.Last;
Res.Header_Num := Header_Size;
Res.Assoc_Offset := Associations_Table.Last;
Res.Assoc_Next := Associations_Table.Last;
Res.Assoc_Num := Assoc_Index (Num_Assoc);
Headers_Table.Set_Last (Headers_Table.Last + Header_Size);
Associations_Table.Set_Last
(Associations_Table.Last + Assoc_Index (Num_Assoc));
Maps_Table.Table (Maps_Table.Last) := Res;
for J in 1 .. Header_Size loop
Headers_Table.Table (Headers_Table.Last - J) := No_Assoc;
end loop;
return Maps_Table.Last;
end New_Map;
------------------------
-- Update_Association --
------------------------
procedure Update_Association
(M : in out Map;
O_Id : Entity_Id;
N_Id : Entity_Id;
Kind : Scope_Kind := S_Local)
is
J : constant Assoc_Index := Find_Assoc (M, O_Id);
begin
Associations_Table.Table (J).New_Id := N_Id;
Associations_Table.Table (J).Kind := Kind;
end Update_Association;
---------------
-- Write_Map --
---------------
procedure Write_Map (E : Entity_Id) is
M : constant Map := Map (UI_To_Int (Renaming_Map (E)));
Info : constant Map_Info := Maps_Table.Table (M);
Offh : constant Header_Index := Info.Header_Offset;
Offa : constant Assoc_Index := Info.Assoc_Offset;
A : Assoc;
begin
Write_Str ("Size : ");
Write_Int (Int (Info.Assoc_Num));
Write_Eol;
Write_Str ("Headers");
Write_Eol;
for J in 0 .. Info.Header_Num - 1 loop
Write_Int (Int (Offh + J));
Write_Str (" : ");
Write_Int (Int (Headers_Table.Table (Offh + J)));
Write_Eol;
end loop;
for J in 0 .. Info.Assoc_Num - 1 loop
A := Associations_Table.Table (Offa + J);
Write_Int (Int (Offa + J));
Write_Str (" : ");
Write_Name (Chars (A.Old_Id));
Write_Str (" ");
Write_Int (Int (A.Old_Id));
Write_Str (" ==> ");
Write_Int (Int (A.New_Id));
Write_Str (" next = ");
Write_Int (Int (A.Next));
Write_Eol;
end loop;
end Write_Map;
end Sem_Maps;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package body GL.Algebra is
function To_Vector2 (Vector : Vector3) return Vector2 is
begin
return Vector2'(Vector (X), Vector (Y));
end To_Vector2;
function To_Vector2 (Vector : Vector4) return Vector2 is
begin
return Vector2'(Vector (X), Vector (Y));
end To_Vector2;
function To_Vector3 (Vector : Vector2) return Vector3 is
begin
return Vector3'(Vector (X), Vector (Y), Null_Value);
end To_Vector3;
function To_Vector3 (Vector : Vector4) return Vector3 is
begin
return Vector3'(Vector (X), Vector (Y), Vector (Z));
end To_Vector3;
function To_Vector4 (Vector : Vector2) return Vector4 is
begin
return Vector4'(Vector (X), Vector (Y), Null_Value, One_Value);
end To_Vector4;
function To_Vector4 (Vector : Vector3) return Vector4 is
begin
return Vector4'(Vector (X), Vector (Y), Vector (Z), One_Value);
end To_Vector4;
function Cross_Product (Left, Right : Vector3) return Vector3 is
begin
return (Left (Y) * Right (Z) - Left (Z) * Right (Y),
Left (Z) * Right (X) - Left (X) * Right (Z),
Left (X) * Right (Y) - Left (Y) * Right (X));
end Cross_Product;
end GL.Algebra;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
X : Integer;
begin
X := 'a';
end;
|
pragma License (Unrestricted);
-- AARM A.16(124.cc/2), specialized for POSIX (Darwin, FreeBSD, or Linux)
package Ada.Directories.Information is
-- System-specific directory information.
-- Unix and similar systems version.
function Last_Access_Time (Name : String) return Calendar.Time;
function Last_Status_Change_Time (Name : String) return Calendar.Time;
-- modified
type Permission is (
Others_Execute, Others_Write, Others_Read,
Group_Execute, Group_Write, Group_Read,
Owner_Execute, Owner_Write, Owner_Read,
Sticky, -- additional
Set_Group_ID, Set_User_ID);
type Permission_Set_Type is array (Permission) of Boolean;
pragma Pack (Permission_Set_Type);
function Permission_Set (Name : String) return Permission_Set_Type;
function Owner (Name : String) return String;
-- Returns the image of the User_Id. If a definition of User_Id
-- is available, an implementation-defined version of Owner
-- returning User_Id should also be defined.
function Group (Name : String) return String;
-- Returns the image of the Group_Id. If a definition of Group_Id
-- is available, an implementation-defined version of Group
-- returning Group_Id should also be defined.
function Is_Block_Special_File (Name : String) return Boolean;
function Is_Character_Special_File (Name : String) return Boolean;
function Is_FIFO (Name : String) return Boolean;
function Is_Symbolic_Link (Name : String) return Boolean;
function Is_Socket (Name : String) return Boolean;
function Last_Access_Time (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Calendar.Time;
function Last_Status_Change_Time (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Calendar.Time;
function Permission_Set (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Permission_Set_Type;
function Owner (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return String;
-- See Owner above.
function Group (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return String;
-- See Group above.
function Is_Block_Special_File (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Boolean;
function Is_Character_Special_File (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Boolean;
function Is_FIFO (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Boolean;
function Is_Symbolic_Link (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Boolean;
function Is_Socket (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return Boolean;
-- Additional implementation-defined subprograms allowed here.
-- extended
-- Read a target path of a symbolic link.
function Read_Symbolic_Link (Name : String) return String;
function Read_Symbolic_Link (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return String;
-- extended from here
-- The permissions of the current user.
type User_Permission is (User_Execute, User_Write, User_Read);
type User_Permission_Set_Type is array (User_Permission) of Boolean;
pragma Pack (User_Permission_Set_Type);
function User_Permission_Set (Name : String)
return User_Permission_Set_Type;
function User_Permission_Set (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return User_Permission_Set_Type;
-- to here
-- extended
-- Unique file identifier.
type File_Id is mod 2 ** 64; -- 64bit inode
function Identity (Name : String) return File_Id;
function Identity (
Directory_Entry : Directory_Entry_Type) -- Assigned_Directory_Entry_Type
return File_Id;
end Ada.Directories.Information;
|
with Ada.Calendar;
with Ada.Real_Time;
procedure delays is
use type Ada.Calendar.Time;
use type Ada.Real_Time.Time;
use type Ada.Real_Time.Time_Span;
begin
declare
Start : Ada.Calendar.Time := Ada.Calendar.Clock;
begin
delay 1.0;
delay until Ada.Calendar.Clock + 1.0;
pragma Assert (Ada.Calendar.Clock - Start >= 2.0);
pragma Assert (Ada.Calendar.Clock - Start < 3.0); -- ??
end;
declare
Start : Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
delay 1.0;
delay until Ada.Real_Time.Clock + Ada.Real_Time.To_Time_Span (1.0);
pragma Assert (Ada.Real_Time.Clock - Start >= Ada.Real_Time.To_Time_Span (2.0));
pragma Assert (Ada.Real_Time.Clock - Start < Ada.Real_Time.To_Time_Span (3.0)); -- ??
end;
pragma Debug (Ada.Debug.Put ("OK"));
end delays;
|
-----------------------------------------------------------------------
-- ADO.Model -- ADO.Model
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 166
-----------------------------------------------------------------------
-- Copyright (C) 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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 ADO.Objects;
package body ADO.Model is
-- ----------------------------------------
-- Data object: Sequence
-- ----------------------------------------
procedure Set_Name (Object : in out Sequence_Ref;
Value : in String) is
begin
Object.Id := Ada.Strings.Unbounded.To_Unbounded_String (Value);
end Set_Name;
procedure Set_Name (Object : in out Sequence_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
begin
Object.Id := Value;
end Set_Name;
function Get_Name (Object : in Sequence_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Sequence_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
begin
return Object.Id;
end Get_Name;
function Get_Version (Object : in Sequence_Ref)
return Integer is
begin
return Object.Version;
end Get_Version;
procedure Set_Value (Object : in out Sequence_Ref;
Value : in ADO.Identifier) is
begin
Object.Value := Value;
Object.Need_Save := True;
end Set_Value;
function Get_Value (Object : in Sequence_Ref)
return ADO.Identifier is
begin
return Object.Value;
end Get_Value;
procedure Set_Block_Size (Object : in out Sequence_Ref;
Value : in ADO.Identifier) is
begin
Object.Block_Size := Value;
end Set_Block_Size;
function Get_Block_Size (Object : in Sequence_Ref)
return ADO.Identifier is
begin
return Object.Block_Size;
end Get_Block_Size;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Sequence_Ref;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
pragma Unreferenced (Session);
begin
Object.Id := Stmt.Get_Unbounded_String (0);
Object.Value := Stmt.Get_Identifier (2);
Object.Block_Size := Stmt.Get_Identifier (3);
Object.Version := Stmt.Get_Integer (1);
end Load;
procedure Find (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (SEQUENCE_TABLE'Access);
begin
Stmt.Set_Parameters (Query);
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
procedure Save (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (SEQUENCE_TABLE'Access);
begin
-- if Object.Need_Save then
-- Stmt.Save_Field (Name => COL_0_1_NAME, -- name
-- Value => Object.Get_Key);
-- Object.Clear_Modified (1);
-- end if;
if Object.Need_Save then
Stmt.Save_Field (Name => COL_2_1_NAME, -- value
Value => Object.Value);
end if;
-- if Object.Is_Modified (4) then
-- Stmt.Save_Field (Name => COL_3_1_NAME, -- block_size
-- Value => Object.Block_Size);
-- Object.Clear_Modified (4);
-- end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "name = ? and version = ?");
Stmt.Add_Param (Value => Object.Id);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (SEQUENCE_TABLE'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_1_NAME, -- name
Value => Object.Id);
Query.Save_Field (Name => COL_1_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_1_NAME, -- value
Value => Object.Value);
Query.Save_Field (Name => COL_3_1_NAME, -- block_size
Value => Object.Block_Size);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
end Create;
end ADO.Model;
|
procedure scan_for_file_ghosts (
directory_path : in String;
file_ghosts : out Filename_Container.Vector;
directory_ghosts : out Filename_Container.Vector);
-- Given an existing directory path, the procedure will produce
-- both a list of deleted directories and a list of files deleted
-- (but with available version) from that directory
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Unchecked_Deallocation;
package body Apsepp.Test_Event_Class.Generic_Exception_Mixin is
----------------------------------------------------------------------------
overriding
procedure Set (Obj : in out Child_W_Exception; Data : Test_Event_Data) is
begin
Parent (Obj).Set (Data); -- Inherited procedure call.
Child_W_Exception'Class (Obj).Free_Exception;
Obj.E := Data.E;
end Set;
----------------------------------------------------------------------------
overriding
procedure Clean_Up (Obj : in out Child_W_Exception) is
begin
Parent (Obj).Clean_Up; -- Inherited procedure call.
Child_W_Exception'Class (Obj).Free_Exception;
end Clean_Up;
----------------------------------------------------------------------------
function Exception_Access
(Obj : Child_W_Exception) return Exception_Occurrence_Access
is (Obj.E);
----------------------------------------------------------------------------
procedure Free_Exception (Obj : in out Child_W_Exception) is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Exception_Occurrence,
Name => Exception_Occurrence_Access);
begin
Free (Obj.E);
end Free_Exception;
----------------------------------------------------------------------------
end Apsepp.Test_Event_Class.Generic_Exception_Mixin;
|
-----------------------------------------------------------------------
-- receiver -- Ethernet Packet Receiver
-- Copyright (C) 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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.Real_Time;
with Ada.Synchronous_Task_Control;
with Net.Buffers;
with Net.Protos.Arp;
with Net.Protos.Dispatchers;
with Net.Headers;
with Demos;
package body Receiver is
use type Net.Ip_Addr;
use type Net.Uint8;
use type Net.Uint16;
Ready : Ada.Synchronous_Task_Control.Suspension_Object;
ONE_US : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds (1);
-- ------------------------------
-- Start the receiver loop.
-- ------------------------------
procedure Start is
begin
Ada.Synchronous_Task_Control.Set_True (Ready);
end Start;
task body Controller is
use type Ada.Real_Time.Time;
use type Ada.Real_Time.Time_Span;
use type Net.Uint64;
Packet : Net.Buffers.Buffer_Type;
Ether : Net.Headers.Ether_Header_Access;
Now : Ada.Real_Time.Time;
Dt : Us_Time;
Total : Net.Uint64 := 0;
Count : Net.Uint64 := 0;
begin
-- Wait until the Ethernet driver is ready.
Ada.Synchronous_Task_Control.Suspend_Until_True (Ready);
-- Loop receiving packets and dispatching them.
Min_Receive_Time := Us_Time'Last;
Max_Receive_Time := Us_Time'First;
loop
if Packet.Is_Null then
Net.Buffers.Allocate (Packet);
end if;
if not Packet.Is_Null then
Demos.Ifnet.Receive (Packet);
Now := Ada.Real_Time.Clock;
Ether := Packet.Ethernet;
if Ether.Ether_Type = Net.Headers.To_Network (Net.Protos.ETHERTYPE_ARP) then
Net.Protos.Arp.Receive (Demos.Ifnet, Packet);
elsif Ether.Ether_Type = Net.Headers.To_Network (Net.Protos.ETHERTYPE_IP) then
Net.Protos.Dispatchers.Receive (Demos.Ifnet, Packet);
end if;
-- Compute the time taken to process the packet in microseconds.
Dt := Us_Time ((Ada.Real_Time.Clock - Now) / ONE_US);
-- Compute average, min and max values.
Count := Count + 1;
Total := Total + Net.Uint64 (Dt);
Avg_Receive_Time := Us_Time (Total / Count);
if Dt < Min_Receive_Time then
Min_Receive_Time := Dt;
end if;
if Dt > Max_Receive_Time then
Max_Receive_Time := Dt;
end if;
else
delay until Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds (100);
end if;
end loop;
end Controller;
end Receiver;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2013, Vadim Godunko <vgodunko@gmail.com> --
-- 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.Internals.Calendars.Formatting.ISO_8601;
with Matreshka.Internals.Calendars.Formatting.Times;
with Matreshka.Internals.Calendars.Gregorian;
with Matreshka.Internals.Calendars.Times;
package body League.Calendars.ISO_8601 is
Calendar : ISO_8601_Calendar;
-- This global object is used in convenient subprograms as calendar.
function Local_Time_Zone
return Matreshka.Internals.Calendars.Time_Zone_Access;
-- XXX Local time zone is not supported now. This function is used to
-- return dummy time zone to help future transition.
--------------
-- Add_Days --
--------------
function Add_Days (Stamp : Date; Days : Integer) return Date is
begin
return Calendar.Add_Days (Stamp, Days);
end Add_Days;
--------------
-- Add_Days --
--------------
procedure Add_Days (Stamp : in out Date; Days : Integer) is
begin
Calendar.Add_Days (Stamp, Days);
end Add_Days;
--------------
-- Add_Days --
--------------
function Add_Days (Stamp : Date_Time; Days : Integer) return Date_Time is
begin
return Calendar.Add_Days (Stamp, Days);
end Add_Days;
--------------
-- Add_Days --
--------------
procedure Add_Days (Stamp : in out Date_Time; Days : Integer) is
begin
Calendar.Add_Days (Stamp, Days);
end Add_Days;
--------------
-- Add_Days --
--------------
function Add_Days
(Self : ISO_8601_Calendar'Class;
Stamp : Date;
Days : Integer) return Date
is
pragma Unreferenced (Self);
begin
return Stamp + Date (Days);
end Add_Days;
--------------
-- Add_Days --
--------------
procedure Add_Days
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date;
Days : Integer)
is
pragma Unreferenced (Self);
begin
Stamp := Stamp + Date (Days);
end Add_Days;
--------------
-- Add_Days --
--------------
function Add_Days
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Days : Integer) return Date_Time
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return Stamp;
end Add_Days;
--------------
-- Add_Days --
--------------
procedure Add_Days
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date_Time;
Days : Integer)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Add_Days;
----------------
-- Add_Months --
----------------
function Add_Months (Stamp : Date; Months : Integer) return Date is
begin
return Calendar.Add_Months (Stamp, Months);
end Add_Months;
----------------
-- Add_Months --
----------------
procedure Add_Months (Stamp : in out Date; Months : Integer) is
begin
Calendar.Add_Months (Stamp, Months);
end Add_Months;
----------------
-- Add_Months --
----------------
function Add_Months
(Stamp : Date_Time; Months : Integer) return Date_Time is
begin
return Calendar.Add_Months (Stamp, Months);
end Add_Months;
----------------
-- Add_Months --
----------------
procedure Add_Months (Stamp : in out Date_Time; Months : Integer) is
begin
Calendar.Add_Months (Stamp, Months);
end Add_Months;
----------------
-- Add_Months --
----------------
function Add_Months
(Self : ISO_8601_Calendar'Class;
Stamp : Date;
Months : Integer) return Date
is
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Total : Integer;
begin
Split (Self, Stamp, Year, Month, Day);
Total := Integer (Year * 12) + Integer (Month - 1) + Months;
Year := Year_Number (Total / 12);
Month := Month_Number ((Total mod 12) + 1);
Day := Day_Number'Min (Day, Days_In_Month (Self, Year, Month));
return Create (Self, Year, Month, Day);
end Add_Months;
----------------
-- Add_Months --
----------------
procedure Add_Months
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date;
Months : Integer) is
begin
Stamp := Add_Months (Self, Stamp, Months);
end Add_Months;
----------------
-- Add_Months --
----------------
function Add_Months
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Months : Integer) return Date_Time
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return Stamp;
end Add_Months;
----------------
-- Add_Months --
----------------
procedure Add_Months
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date_Time;
Months : Integer)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Add_Months;
---------------
-- Add_Years --
---------------
function Add_Years (Stamp : Date; Years : Integer) return Date is
begin
return Calendar.Add_Years (Stamp, Years);
end Add_Years;
---------------
-- Add_Years --
---------------
procedure Add_Years (Stamp : in out Date; Years : Integer) is
begin
Calendar.Add_Years (Stamp, Years);
end Add_Years;
---------------
-- Add_Years --
---------------
function Add_Years (Stamp : Date_Time; Years : Integer) return Date_Time is
begin
return Calendar.Add_Years (Stamp, Years);
end Add_Years;
---------------
-- Add_Years --
---------------
procedure Add_Years (Stamp : in out Date_Time; Years : Integer) is
begin
Calendar.Add_Years (Stamp, Years);
end Add_Years;
---------------
-- Add_Years --
---------------
function Add_Years
(Self : ISO_8601_Calendar'Class;
Stamp : Date;
Years : Integer) return Date is
begin
return Add_Months (Self, Stamp, Years * 12);
end Add_Years;
---------------
-- Add_Years --
---------------
procedure Add_Years
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date;
Years : Integer) is
begin
Add_Months (Self, Stamp, Years * 12);
end Add_Years;
---------------
-- Add_Years --
---------------
function Add_Years
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Years : Integer) return Date_Time
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return Stamp;
end Add_Years;
---------------
-- Add_Years --
---------------
procedure Add_Years
(Self : ISO_8601_Calendar'Class;
Stamp : in out Date_Time;
Years : Integer)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Add_Years;
------------
-- Create --
------------
function Create
(Year : Year_Number;
Month : Month_Number;
Day : Day_Number) return Date is
begin
return Calendar.Create (Year, Month, Day);
end Create;
------------
-- Create --
------------
function Create
(Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Nanosecond_100 : Nanosecond_100_Number) return Date_Time is
begin
return
Calendar.Create
(Year, Month, Day, Hour, Minute, Second, Nanosecond_100);
end Create;
------------
-- Create --
------------
function Create
(Zone : Time_Zone;
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Nanosecond_100 : Nanosecond_100_Number) return Date_Time is
begin
return
Calendar.Create
(Zone, Year, Month, Day, Hour, Minute, Second, Nanosecond_100);
end Create;
------------
-- Create --
------------
function Create
(Self : ISO_8601_Calendar'Class;
Year : Year_Number;
Month : Month_Number;
Day : Day_Number) return Date
is
pragma Unreferenced (Self);
begin
return
Date
(Matreshka.Internals.Calendars.Gregorian.Julian_Day
(Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month),
Matreshka.Internals.Calendars.Gregorian.Day_Number (Day)));
end Create;
------------
-- Create --
------------
function Create
(Self : ISO_8601_Calendar'Class;
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Nanosecond_100 : Nanosecond_100_Number) return Date_Time
is
pragma Unreferenced (Self);
begin
return
Date_Time
(Matreshka.Internals.Calendars.Times.Create
(Local_Time_Zone,
Matreshka.Internals.Calendars.Gregorian.Julian_Day
(Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month),
Matreshka.Internals.Calendars.Gregorian.Day_Number (Day)),
Matreshka.Internals.Calendars.Times.Hour_Number (Hour),
Matreshka.Internals.Calendars.Times.Minute_Number (Minute),
Matreshka.Internals.Calendars.Times.Second_Number (Second),
Matreshka.Internals.Calendars.Times.Nano_Second_100_Number
(Nanosecond_100)));
end Create;
------------
-- Create --
------------
function Create
(Self : ISO_8601_Calendar'Class;
Zone : Time_Zone;
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Nanosecond_100 : Nanosecond_100_Number) return Date_Time
is
pragma Unreferenced (Self);
begin
return
Date_Time
(Matreshka.Internals.Calendars.Times.Create
(Zone.Description,
Matreshka.Internals.Calendars.Gregorian.Julian_Day
(Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month),
Matreshka.Internals.Calendars.Gregorian.Day_Number (Day)),
Matreshka.Internals.Calendars.Times.Hour_Number (Hour),
Matreshka.Internals.Calendars.Times.Minute_Number (Minute),
Matreshka.Internals.Calendars.Times.Second_Number (Second),
Matreshka.Internals.Calendars.Times.Nano_Second_100_Number
(Nanosecond_100)));
end Create;
---------
-- Day --
---------
function Day (Stamp : Date) return Day_Number is
begin
return Calendar.Day (Stamp);
end Day;
---------
-- Day --
---------
function Day (Stamp : Date_Time) return Day_Number is
begin
return Calendar.Day (Stamp);
end Day;
---------
-- Day --
---------
function Day (Stamp : Date_Time; Zone : Time_Zone) return Day_Number is
begin
return Calendar.Day (Stamp, Zone);
end Day;
---------
-- Day --
---------
function Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Day
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Day;
---------
-- Day --
---------
function Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Day
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Day;
---------
-- Day --
---------
function Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Day
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Day;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week (Stamp : Date) return Day_Of_Week_Number is
begin
return Calendar.Day_Of_Week (Stamp);
end Day_Of_Week;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week (Stamp : Date_Time) return Day_Of_Week_Number is
begin
return Calendar.Day_Of_Week (Stamp);
end Day_Of_Week;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week
(Stamp : Date_Time; Zone : Time_Zone) return Day_Of_Week_Number is
begin
return Calendar.Day_Of_Week (Stamp, Zone);
end Day_Of_Week;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Day_Of_Week_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Week_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Week
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Day_Of_Week;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Day_Of_Week_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Week_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Week
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Day_Of_Week;
-----------------
-- Day_Of_Week --
-----------------
function Day_Of_Week
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Day_Of_Week_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Week_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Week
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Day_Of_Week;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year (Stamp : Date) return Day_Of_Year_Number is
begin
return Calendar.Day_Of_Year (Stamp);
end Day_Of_Year;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year (Stamp : Date_Time) return Day_Of_Year_Number is
begin
return Calendar.Day_Of_Year (Stamp);
end Day_Of_Year;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year
(Stamp : Date_Time; Zone : Time_Zone) return Day_Of_Year_Number is
begin
return Calendar.Day_Of_Year (Stamp, Zone);
end Day_Of_Year;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Year
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Day_Of_Year;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Day_Of_Year;
-----------------
-- Day_Of_Year --
-----------------
function Day_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Day_Of_Year;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month (Stamp : Date) return Day_Number is
begin
return Calendar.Days_In_Month (Stamp);
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month (Stamp : Date_Time) return Day_Number is
begin
return Calendar.Days_In_Month (Stamp);
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Stamp : Date_Time; Zone : Time_Zone) return Day_Number is
begin
return Calendar.Days_In_Month (Stamp, Zone);
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Year : Year_Number; Month : Month_Number) return Day_Number is
begin
return Calendar.Days_In_Month (Year, Month);
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Self : ISO_8601_Calendar'Class; Stamp : Date) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Month
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Self : ISO_8601_Calendar'Class; Stamp : Date_Time) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Month
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Month
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Days_In_Month;
-------------------
-- Days_In_Month --
-------------------
function Days_In_Month
(Self : ISO_8601_Calendar'Class;
Year : Year_Number;
Month : Month_Number) return Day_Number
is
pragma Unreferenced (Self);
begin
return
Day_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Month
(Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month)));
end Days_In_Month;
------------------
-- Days_In_Year --
------------------
function Days_In_Year (Stamp : Date) return Day_Of_Year_Number is
begin
return Calendar.Days_In_Year (Stamp);
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year (Stamp : Date_Time) return Day_Of_Year_Number is
begin
return Calendar.Days_In_Year (Stamp);
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year
(Stamp : Date_Time; Zone : Time_Zone) return Day_Of_Year_Number is
begin
return Calendar.Days_In_Year (Stamp, Zone);
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year (Year : Year_Number) return Day_Of_Year_Number is
begin
return Calendar.Days_In_Year (Year);
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year
(Self : ISO_8601_Calendar'Class; Stamp : Date) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Year
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Days_In_Year;
------------------
-- Days_In_Year --
------------------
function Days_In_Year
(Self : ISO_8601_Calendar'Class;
Year : Year_Number) return Day_Of_Year_Number
is
pragma Unreferenced (Self);
begin
return
Day_Of_Year_Number
(Matreshka.Internals.Calendars.Gregorian.Days_In_Year
(Matreshka.Internals.Calendars.Gregorian.Day_Of_Year_Number
(Year)));
end Days_In_Year;
-------------
-- Days_To --
-------------
function Days_To (From : Date; To : Date) return Integer is
begin
return Calendar.Days_To (From, To);
end Days_To;
-------------
-- Days_To --
-------------
function Days_To
(Self : ISO_8601_Calendar'Class;
From : Date;
To : Date) return Integer
is
pragma Unreferenced (Self);
begin
return Integer (To - From);
end Days_To;
---------------------
-- From_Julian_Day --
---------------------
function From_Julian_Day (Day : Integer) return Date is
begin
return Calendar.From_Julian_Day (Day);
end From_Julian_Day;
---------------------
-- From_Julian_Day --
---------------------
function From_Julian_Day
(Self : ISO_8601_Calendar'Class;
Day : Integer) return Date
is
pragma Unreferenced (Self);
begin
return Date (Day);
end From_Julian_Day;
----------
-- Hour --
----------
function Hour (Stamp : Time) return Hour_Number is
begin
return Calendar.Hour (Stamp);
end Hour;
----------
-- Hour --
----------
function Hour (Stamp : Date_Time) return Hour_Number is
begin
return Calendar.Hour (Stamp);
end Hour;
----------
-- Hour --
----------
function Hour (Stamp : Date_Time; Zone : Time_Zone) return Hour_Number is
begin
return Calendar.Hour (Stamp, Zone);
end Hour;
----------
-- Hour --
----------
function Hour
(Self : ISO_8601_Calendar'Class; Stamp : Time) return Hour_Number
is
pragma Unreferenced (Self);
begin
return
Hour_Number
(Matreshka.Internals.Calendars.Times.Hour
(Matreshka.Internals.Calendars.Relative_Time (Stamp)));
end Hour;
----------
-- Hour --
----------
function Hour
(Self : ISO_8601_Calendar'Class; Stamp : Date_Time) return Hour_Number
is
pragma Unreferenced (Self);
begin
return
Hour_Number
(Matreshka.Internals.Calendars.Times.Hour
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone));
end Hour;
----------
-- Hour --
----------
function Hour
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Hour_Number
is
pragma Unreferenced (Self);
begin
return
Hour_Number
(Matreshka.Internals.Calendars.Times.Hour
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description));
end Hour;
-----------
-- Image --
-----------
function Image
(Pattern : League.Strings.Universal_String;
Stamp : Date_Time) return League.Strings.Universal_String is
begin
return Calendar.Image (Pattern, Stamp);
end Image;
-----------
-- Image --
-----------
function Image
(Pattern : League.Strings.Universal_String;
Stamp : Date_Time;
Zone : Time_Zone) return League.Strings.Universal_String is
begin
return Calendar.Image (Pattern, Stamp, Zone);
end Image;
-----------
-- Image --
-----------
function Image
(Self : ISO_8601_Calendar'Class;
Pattern : League.Strings.Universal_String;
Stamp : Date_Time) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
Printer :
Matreshka.Internals.Calendars.Formatting.ISO_8601.ISO_8601_Printer;
Time_Printer :
Matreshka.Internals.Calendars.Formatting.Times.Time_Printer;
begin
return
Matreshka.Internals.Calendars.Formatting.Image
(Pattern,
Printer,
Time_Printer,
Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone);
end Image;
-----------
-- Image --
-----------
function Image
(Self : ISO_8601_Calendar'Class;
Pattern : League.Strings.Universal_String;
Stamp : Date_Time;
Zone : Time_Zone) return League.Strings.Universal_String
is
pragma Unreferenced (Self);
Printer :
Matreshka.Internals.Calendars.Formatting.ISO_8601.ISO_8601_Printer;
Time_Printer :
Matreshka.Internals.Calendars.Formatting.Times.Time_Printer;
begin
return
Matreshka.Internals.Calendars.Formatting.Image
(Pattern,
Printer,
Time_Printer,
Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description);
end Image;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year (Year : Year_Number) return Boolean is
begin
return Calendar.Is_Leap_Year (Year);
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year (Stamp : Date) return Boolean is
begin
return Calendar.Is_Leap_Year (Stamp);
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year (Stamp : Date_Time) return Boolean is
begin
return Calendar.Is_Leap_Year (Stamp);
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year
(Stamp : Date_Time; Zone : Time_Zone) return Boolean is
begin
return Calendar.Is_Leap_Year (Stamp, Zone);
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year
(Self : ISO_8601_Calendar'Class; Stamp : Date) return Boolean
is
pragma Unreferenced (Self);
begin
return
Matreshka.Internals.Calendars.Gregorian.Is_Leap_Year
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp));
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year
(Self : ISO_8601_Calendar'Class; Stamp : Date_Time) return Boolean
is
pragma Unreferenced (Self);
begin
return
Matreshka.Internals.Calendars.Gregorian.Is_Leap_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone));
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Boolean
is
pragma Unreferenced (Self);
begin
return
Matreshka.Internals.Calendars.Gregorian.Is_Leap_Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description));
end Is_Leap_Year;
------------------
-- Is_Leap_Year --
------------------
function Is_Leap_Year
(Self : ISO_8601_Calendar'Class; Year : Year_Number) return Boolean
is
pragma Unreferenced (Self);
begin
return
Matreshka.Internals.Calendars.Gregorian.Is_Leap_Year
(Matreshka.Internals.Calendars.Gregorian.Year_Number (Year));
end Is_Leap_Year;
--------------
-- Is_Valid --
--------------
function Is_Valid
(Year : Year_Number;
Month : Month_Number;
Day : Day_Number) return Boolean is
begin
return Calendar.Is_Valid (Year, Month, Day);
end Is_Valid;
--------------
-- Is_Valid --
--------------
function Is_Valid
(Self : ISO_8601_Calendar'Class;
Year : Year_Number;
Month : Month_Number;
Day : Day_Number) return Boolean is
begin
return Day <= Days_In_Month (Self, Year, Month);
end Is_Valid;
---------------------
-- Local_Time_Zone --
---------------------
function Local_Time_Zone
return Matreshka.Internals.Calendars.Time_Zone_Access is
begin
return Matreshka.Internals.Calendars.UTC_Time_Zone'Access;
end Local_Time_Zone;
------------
-- Minute --
------------
function Minute (Stamp : Time) return Minute_Number is
begin
return Calendar.Minute (Stamp);
end Minute;
------------
-- Minute --
------------
function Minute (Stamp : Date_Time) return Minute_Number is
begin
return Calendar.Minute (Stamp);
end Minute;
------------
-- Minute --
------------
function Minute
(Stamp : Date_Time; Zone : Time_Zone) return Minute_Number is
begin
return Calendar.Minute (Stamp, Zone);
end Minute;
------------
-- Minute --
------------
function Minute
(Self : ISO_8601_Calendar'Class; Stamp : Time) return Minute_Number
is
pragma Unreferenced (Self);
begin
return
Minute_Number
(Matreshka.Internals.Calendars.Times.Minute
(Matreshka.Internals.Calendars.Relative_Time (Stamp)));
end Minute;
------------
-- Minute --
------------
function Minute
(Self : ISO_8601_Calendar'Class; Stamp : Date_Time) return Minute_Number
is
pragma Unreferenced (Self);
begin
return
Minute_Number
(Matreshka.Internals.Calendars.Times.Minute
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone));
end Minute;
------------
-- Minute --
------------
function Minute
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Minute_Number
is
pragma Unreferenced (Self);
begin
return
Minute_Number
(Matreshka.Internals.Calendars.Times.Minute
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description));
end Minute;
-----------
-- Month --
-----------
function Month (Stamp : Date) return Month_Number is
begin
return Calendar.Month (Stamp);
end Month;
-----------
-- Month --
-----------
function Month (Stamp : Date_Time) return Month_Number is
begin
return Calendar.Month (Stamp);
end Month;
-----------
-- Month --
-----------
function Month (Stamp : Date_Time; Zone : Time_Zone) return Month_Number is
begin
return Calendar.Month (Stamp, Zone);
end Month;
-----------
-- Month --
-----------
function Month
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Month_Number
is
pragma Unreferenced (Self);
begin
return
Month_Number
(Matreshka.Internals.Calendars.Gregorian.Month
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Month;
-----------
-- Month --
-----------
function Month
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Month_Number
is
pragma Unreferenced (Self);
begin
return
Month_Number
(Matreshka.Internals.Calendars.Gregorian.Month
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Month;
-----------
-- Month --
-----------
function Month
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Month_Number
is
pragma Unreferenced (Self);
begin
return
Month_Number
(Matreshka.Internals.Calendars.Gregorian.Month
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Month;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100 (Stamp : Time) return Nanosecond_100_Number is
begin
return Calendar.Nanosecond_100 (Stamp);
end Nanosecond_100;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100 (Stamp : Date_Time) return Nanosecond_100_Number is
begin
return Calendar.Nanosecond_100 (Stamp);
end Nanosecond_100;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100
(Stamp : Date_Time; Zone : Time_Zone) return Nanosecond_100_Number is
begin
return Calendar.Nanosecond_100 (Stamp, Zone);
end Nanosecond_100;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100
(Self : ISO_8601_Calendar'Class;
Stamp : Time) return Nanosecond_100_Number
is
pragma Unreferenced (Self);
begin
return
Nanosecond_100_Number
(Matreshka.Internals.Calendars.Times.Nanosecond_100
(Matreshka.Internals.Calendars.Relative_Time (Stamp), 0));
-- XXX Doesn't support leap second, should be reviewed.
end Nanosecond_100;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Nanosecond_100_Number
is
pragma Unreferenced (Self);
begin
return
Nanosecond_100_Number
(Matreshka.Internals.Calendars.Times.Nanosecond_100
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone));
end Nanosecond_100;
--------------------
-- Nanosecond_100 --
--------------------
function Nanosecond_100
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Nanosecond_100_Number
is
pragma Unreferenced (Self);
begin
return
Nanosecond_100_Number
(Matreshka.Internals.Calendars.Times.Nanosecond_100
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description));
end Nanosecond_100;
------------
-- Second --
------------
function Second (Stamp : Time) return Second_Number is
begin
return Calendar.Second (Stamp);
end Second;
------------
-- Second --
------------
function Second (Stamp : Date_Time) return Second_Number is
begin
return Calendar.Second (Stamp);
end Second;
------------
-- Second --
------------
function Second
(Stamp : Date_Time; Zone : Time_Zone) return Second_Number is
begin
return Calendar.Second (Stamp, Zone);
end Second;
------------
-- Second --
------------
function Second
(Self : ISO_8601_Calendar'Class; Stamp : Time) return Second_Number
is
pragma Unreferenced (Self);
begin
return
Second_Number
(Matreshka.Internals.Calendars.Times.Second
(Matreshka.Internals.Calendars.Relative_Time (Stamp), 0));
-- XXX Doesn't handle leap seconds, must be reviewed.
end Second;
------------
-- Second --
------------
function Second
(Self : ISO_8601_Calendar'Class; Stamp : Date_Time) return Second_Number
is
pragma Unreferenced (Self);
begin
return
Second_Number
(Matreshka.Internals.Calendars.Times.Second
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone));
end Second;
------------
-- Second --
------------
function Second
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Second_Number
is
pragma Unreferenced (Self);
begin
return
Second_Number
(Matreshka.Internals.Calendars.Times.Second
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description));
end Second;
-----------
-- Split --
-----------
procedure Split
(Stamp : Date;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number) is
begin
Calendar.Split (Stamp, Year, Month, Day);
end Split;
-----------
-- Split --
-----------
procedure Split
(Stamp : Date_Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Nanosecond_100 : out Nanosecond_100_Number) is
begin
Calendar.Split
(Stamp, Year, Month, Day, Hour, Minute, Second, Nanosecond_100);
end Split;
-----------
-- Split --
-----------
procedure Split
(Stamp : Date_Time;
Zone : Time_Zone;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Nanosecond_100 : out Nanosecond_100_Number) is
begin
Calendar.Split
(Zone, Stamp, Year, Month, Day, Hour, Minute, Second, Nanosecond_100);
end Split;
-----------
-- Split --
-----------
procedure Split
(Self : ISO_8601_Calendar'Class;
Stamp : Date;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number)
is
pragma Unreferenced (Self);
X : constant Matreshka.Internals.Calendars.Julian_Day_Number
:= Matreshka.Internals.Calendars.Julian_Day_Number (Stamp);
begin
-- XXX Can use Split from Grerorian package to retrieve components in
-- one pass.
Year := Year_Number (Matreshka.Internals.Calendars.Gregorian.Year (X));
Month := Month_Number (Matreshka.Internals.Calendars.Gregorian.Month (X));
Day := Day_Number (Matreshka.Internals.Calendars.Gregorian.Day (X));
end Split;
-----------
-- Split --
-----------
procedure Split
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Nanosecond_100 : out Nanosecond_100_Number)
is
pragma Unreferenced (Self);
-- This parameter is used for dispatching only.
Julian_Day : Matreshka.Internals.Calendars.Julian_Day_Number;
begin
Matreshka.Internals.Calendars.Times.Split
(Local_Time_Zone,
Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Julian_Day,
Matreshka.Internals.Calendars.Times.Hour_Number (Hour),
Matreshka.Internals.Calendars.Times.Minute_Number (Minute),
Matreshka.Internals.Calendars.Times.Second_Number (Second),
Matreshka.Internals.Calendars.Times.Nano_second_100_Number
(Nanosecond_100));
Matreshka.Internals.Calendars.Gregorian.Split
(Julian_Day,
Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month),
Matreshka.Internals.Calendars.Gregorian.Day_Number (Day));
end Split;
-----------
-- Split --
-----------
procedure Split
(Self : ISO_8601_Calendar'Class;
Zone : Time_Zone;
Stamp : Date_Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Hour : out Hour_Number;
Minute : out Minute_Number;
Second : out Second_Number;
Nanosecond_100 : out Nanosecond_100_Number)
is
pragma Unreferenced (Self);
-- This parameter is used for dispatching only.
Julian_Day : Matreshka.Internals.Calendars.Julian_Day_Number;
begin
Matreshka.Internals.Calendars.Times.Split
(Zone.Description,
Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Julian_Day,
Matreshka.Internals.Calendars.Times.Hour_Number (Hour),
Matreshka.Internals.Calendars.Times.Minute_Number (Minute),
Matreshka.Internals.Calendars.Times.Second_Number (Second),
Matreshka.Internals.Calendars.Times.Nano_second_100_Number
(Nanosecond_100));
Matreshka.Internals.Calendars.Gregorian.Split
(Julian_Day,
Matreshka.Internals.Calendars.Gregorian.Year_Number (Year),
Matreshka.Internals.Calendars.Gregorian.Month_Number (Month),
Matreshka.Internals.Calendars.Gregorian.Day_Number (Day));
end Split;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day (Stamp : Date) return Integer is
begin
return Calendar.To_Julian_Day (Stamp);
end To_Julian_Day;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day (Stamp : Date_Time) return Integer is
begin
return Calendar.To_Julian_Day (Stamp);
end To_Julian_Day;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day
(Stamp : Date_Time; Zone : Time_Zone) return Integer is
begin
return Calendar.To_Julian_Day (Stamp, Zone);
end To_Julian_Day;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Integer
is
pragma Unreferenced (Self);
begin
return Integer (Stamp);
end To_Julian_Day;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Integer
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return 0;
end To_Julian_Day;
-------------------
-- To_Julian_Day --
-------------------
function To_Julian_Day
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Integer
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return 0;
end To_Julian_Day;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year (Stamp : Date) return Week_Of_Year_Number is
begin
return Calendar.Week_Of_Year (Stamp);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Stamp : Date;
Week : out Week_Of_Year_Number;
Year : out Year_Number) is
begin
Calendar.Week_Of_Year (Stamp, Week, Year);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Stamp : Date_Time;
Week : out Week_Of_Year_Number;
Year : out Year_Number) is
begin
Calendar.Week_Of_Year (Stamp, Week, Year);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Stamp : Date_Time;
Zone : Time_Zone;
Week : out Week_Of_Year_Number;
Year : out Year_Number) is
begin
Calendar.Week_Of_Year (Stamp, Zone, Week, Year);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year (Stamp : Date_Time) return Week_Of_Year_Number is
begin
return Calendar.Week_Of_Year (Stamp);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year
(Stamp : Date_Time; Zone : Time_Zone) return Week_Of_Year_Number is
begin
return Calendar.Week_Of_Year (Stamp, Zone);
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Week_Of_Year_Number
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return 1;
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date;
Week : out Week_Of_Year_Number;
Year : out Year_Number)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Week_Of_Year_Number
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return 1;
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Week : out Week_Of_Year_Number;
Year : out Year_Number)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
function Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Week_Of_Year_Number
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
return 1;
end Week_Of_Year;
------------------
-- Week_Of_Year --
------------------
procedure Week_Of_Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone;
Week : out Week_Of_Year_Number;
Year : out Year_Number)
is
pragma Unreferenced (Self);
begin
-- XXX Not yet implemented.
raise Program_Error;
end Week_Of_Year;
----------
-- Year --
----------
function Year (Stamp : Date) return Year_Number is
begin
return Calendar.Year (Stamp);
end Year;
----------
-- Year --
----------
function Year (Stamp : Date_Time) return Year_Number is
begin
return Calendar.Year (Stamp);
end Year;
----------
-- Year --
----------
function Year (Stamp : Date_Time; Zone : Time_Zone) return Year_Number is
begin
return Calendar.Year (Stamp, Zone);
end Year;
----------
-- Year --
----------
function Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date) return Year_Number
is
pragma Unreferenced (Self);
begin
return
Year_Number
(Matreshka.Internals.Calendars.Gregorian.Year
(Matreshka.Internals.Calendars.Julian_Day_Number (Stamp)));
end Year;
----------
-- Year --
----------
function Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time) return Year_Number
is
pragma Unreferenced (Self);
begin
return
Year_Number
(Matreshka.Internals.Calendars.Gregorian.Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Local_Time_Zone)));
end Year;
----------
-- Year --
----------
function Year
(Self : ISO_8601_Calendar'Class;
Stamp : Date_Time;
Zone : Time_Zone) return Year_Number
is
pragma Unreferenced (Self);
begin
return
Year_Number
(Matreshka.Internals.Calendars.Gregorian.Year
(Matreshka.Internals.Calendars.Times.Julian_Day
(Matreshka.Internals.Calendars.Absolute_Time (Stamp),
Zone.Description)));
end Year;
end League.Calendars.ISO_8601;
|
-- CE3303A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT SET_LINE_LENGTH, SET_PAGE_LENGTH, LINE_LENGTH, AND
-- PAGE_LENGTH RAISE STATUS_ERROR WHEN APPLIED TO A CLOSED FILE.
-- HISTORY:
-- ABW 08/26/82
-- SPS 09/16/82
-- JLH 08/19/87 ADDED AN ATTEMPT TO CREATE AN EXTERNAL FILE;
-- ADDED CHECKS TO THE SAME FOUR CASES WHICH EXIST
-- IN TEST AGAINST ATTEMPTED CREATE.
WITH REPORT;
USE REPORT;
WITH TEXT_IO;
USE TEXT_IO;
PROCEDURE CE3303A IS
FILE : FILE_TYPE;
FIVE : COUNT := COUNT(IDENT_INT(5));
C : COUNT;
ITEM : CHARACTER := 'A';
BEGIN
TEST ("CE3303A" , "CHECK THAT SET_LINE_LENGTH, " &
"SET_PAGE_LENGTH, LINE_LENGTH, AND " &
"PAGE_LENGTH RAISE STATUS_ERROR " &
"WHEN APPLIED TO A CLOSED FILE");
-- FILE NONEXISTANT
BEGIN
SET_LINE_LENGTH (FILE, FIVE);
FAILED ("STATUS_ERROR NOT RAISED FOR SET_LINE_LENGTH - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR SET_LINE_LENGTH " &
"- 1");
END;
BEGIN
SET_PAGE_LENGTH (FILE, FIVE);
FAILED ("STATUS_ERROR NOT RAISED FOR SET_PAGE_LENGTH - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR SET_PAGE_LENGTH " &
"- 1");
END;
BEGIN
C := LINE_LENGTH (FILE);
FAILED ("STATUS_ERROR NOT RAISED FOR LINE_LENGTH - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR LINE_LENGTH - 1");
END;
BEGIN
C := PAGE_LENGTH (FILE);
FAILED ("STATUS_ERROR NOT RAISED FOR PAGE_LENGTH - 1");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR PAGE_LENGTH - 1");
END;
BEGIN
CREATE (FILE, OUT_FILE);
PUT (FILE, ITEM);
CLOSE (FILE);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
BEGIN
SET_LINE_LENGTH (FILE, FIVE);
FAILED ("STATUS_ERROR NOT RAISED FOR SET_LINE_LENGTH - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR SET_LINE_LENGTH " &
"- 2");
END;
BEGIN
SET_PAGE_LENGTH (FILE, FIVE);
FAILED ("STATUS_ERROR NOT RAISED FOR SET_PAGE_LENGTH - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR SET_PAGE_LENGTH " &
"- 2");
END;
BEGIN
C := LINE_LENGTH (FILE);
FAILED ("STATUS_ERROR NOT RAISED FOR LINE_LENGTH - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR LINE_LENGTH - 2");
END;
BEGIN
C := PAGE_LENGTH (FILE);
FAILED ("STATUS_ERROR NOT RAISED FOR PAGE_LENGTH - 2");
EXCEPTION
WHEN STATUS_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ("OTHER EXCEPTION RAISED FOR PAGE_LENGTH - 2");
END;
RESULT;
END CE3303A;
|
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Numerics.Discrete_Random;
package body Randomise is
-- '0' to '9'
subtype Numeric_Rand_Range is Integer range 48..57;
package Numeric_Rand is new Ada.Numerics.Discrete_Random(Numeric_Rand_Range);
Numeric_Gen : Numeric_Rand.Generator;
Numeric_I : Numeric_Rand_Range;
-- 'a' to 'z'
subtype Alphabetic_Rand_Range is Integer range 97..122;
package Alphabetic_Rand is new Ada.Numerics.Discrete_Random(
Alphabetic_Rand_Range);
Alphabetic_Gen : Alphabetic_Rand.Generator;
Alphabetic_I : Alphabetic_Rand_Range;
New_Char : Character;
procedure Randomise_String(S : in out R_String.Bounded_String) is
begin
for C in R_String.To_String(S)'Range loop
case R_String.Element(S, C) is
when '0'..'9' =>
Numeric_I := Numeric_Rand.Random(Numeric_Gen);
New_Char := Character'Val(Numeric_I);
R_String.Replace_Element(S, C, New_Char);
when 'a'..'z' =>
Alphabetic_I := Alphabetic_Rand.Random(Alphabetic_Gen);
New_Char := Character'Val(Alphabetic_I);
R_String.Replace_Element(S, C, New_Char);
when 'A'..'Z' =>
Alphabetic_I := Alphabetic_Rand.Random(Alphabetic_Gen);
New_Char := To_Upper(Character'Val(Alphabetic_I));
R_String.Replace_Element(S, C, New_Char);
when others =>
null;
end case;
end loop;
end Randomise_String;
begin
Numeric_Rand.Reset(Numeric_Gen);
Alphabetic_Rand.Reset(Alphabetic_Gen);
end Randomise;
|
-- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with Gnattest_Generated;
package Tk.TtkEntry.Test_Data.Tests is
type Test is new GNATtest_Generated.GNATtest_Standard.Tk.TtkEntry.Test_Data
.Test with
null record;
procedure Test_Get_Bounding_Box_3f26de_e40b4e(Gnattest_T: in out Test);
-- tk-ttkentry.ads:362:4:Get_Bounding_Box:Test_Bounding_Box
procedure Test_Get_Bounding_Box_2eefca_9bb42f(Gnattest_T: in out Test);
-- tk-ttkentry.ads:390:4:Get_Bounding_Box:Test_Bounding_Box2
procedure Test_Delete_50540f_6a08ac(Gnattest_T: in out Test);
-- tk-ttkentry.ads:424:4:Delete:Test_Delete
procedure Test_Delete_3b495c_262e03(Gnattest_T: in out Test);
-- tk-ttkentry.ads:452:4:Delete:Test_Delete2
procedure Test_Delete_f1c89f_42ab10(Gnattest_T: in out Test);
-- tk-ttkentry.ads:484:4:Delete:Test_Delete3
procedure Test_Delete_3540bf_3e9e54(Gnattest_T: in out Test);
-- tk-ttkentry.ads:515:4:Delete:Test_Delete4
procedure Test_Get_Text_85804d_23b61d(Gnattest_T: in out Test);
-- tk-ttkentry.ads:537:4:Get_Text:Test_Get_Text
procedure Test_Set_Insert_Cursor_52b496_42a5d1(Gnattest_T: in out Test);
-- tk-ttkentry.ads:563:4:Set_Insert_Cursor:Test_Set_Insert_Cursor
procedure Test_Set_Insert_Cursor_60c8aa_e28574(Gnattest_T: in out Test);
-- tk-ttkentry.ads:587:4:Set_Insert_Cursor:Test_Set_Insert_Cursor2
procedure Test_Get_Index_421652_13e4f7(Gnattest_T: in out Test);
-- tk-ttkentry.ads:613:4:Get_Index:Test_Get_Index
procedure Test_Get_Index_ad8c06_595b62(Gnattest_T: in out Test);
-- tk-ttkentry.ads:637:4:Get_Index:Test_Get_Index2
procedure Test_Insert_Text_f548e1_a4d8a8(Gnattest_T: in out Test);
-- tk-ttkentry.ads:664:4:Insert_Text:Test_Insert_Text
procedure Test_Insert_Text_a9d4de_a4d8a8(Gnattest_T: in out Test);
-- tk-ttkentry.ads:689:4:Insert_Text:Test_Insert_Text
procedure Test_Selection_Clear_7c6919_401526(Gnattest_T: in out Test);
-- tk-ttkentry.ads:708:4:Selection_Clear:Test_Selection_Clear
procedure Test_Selection_Present_43ac3d_c0789f(Gnattest_T: in out Test);
-- tk-ttkentry.ads:729:4:Selection_Present:Test_Selection_Present
procedure Test_Selection_Range_212aed_bae09d(Gnattest_T: in out Test);
-- tk-ttkentry.ads:761:4:Selection_Range:Test_Selection_Range
procedure Test_Selection_Range_b08707_09cc67(Gnattest_T: in out Test);
-- tk-ttkentry.ads:787:4:Selection_Range:Test_Selection_Range2
procedure Test_Selection_Range_4b6a3d_907ebb(Gnattest_T: in out Test);
-- tk-ttkentry.ads:816:4:Selection_Range:Test_Selection_Range3
procedure Test_Selection_Range_d3f0c4_0118df(Gnattest_T: in out Test);
-- tk-ttkentry.ads:846:4:Selection_Range:Test_Selection_Range4
procedure Test_Validate_deb16a_7d02a7(Gnattest_T: in out Test);
-- tk-ttkentry.ads:868:4:Validate:Test_Validate
procedure Test_X_View_2a360c_fac801(Gnattest_T: in out Test);
-- tk-ttkentry.ads:890:4:X_View:Test_X_View
procedure Test_X_View_Adjust_4d030c_ce5610(Gnattest_T: in out Test);
-- tk-ttkentry.ads:916:4:X_View_Adjust:Test_X_View_Adjust
procedure Test_X_View_Adjust_9b5765_53940a(Gnattest_T: in out Test);
-- tk-ttkentry.ads:939:4:X_View_Adjust:Test_X_View_Adjust2
procedure Test_X_View_Move_To_e93a2e_470a38(Gnattest_T: in out Test);
-- tk-ttkentry.ads:960:4:X_View_Move_To:Test_X_View_Move_To
procedure Test_X_View_Scroll_84331f_ff6390(Gnattest_T: in out Test);
-- tk-ttkentry.ads:981:4:X_View_Scroll:Test_X_View_Scroll
end Tk.TtkEntry.Test_Data.Tests;
-- end read only
|
with Ada.Text_IO;
with BigInteger;
package body Problem_56 is
package IO renames Ada.Text_IO;
procedure Solve is
function Digit_Sum(bi : BigInteger.BigInt) return Positive is
str : constant String := BigInteger.ToString(bi);
sum : Natural := 0;
begin
for index in str'Range loop
sum := sum + Character'Pos(str(index)) - Character'Pos('0');
end loop;
return sum;
end Digit_Sum;
max_sum : Positive := 1;
begin
for a in 2 .. 100 loop
declare
multiplier : constant BigInteger.BigInt := BigInteger.Create(Long_Long_Integer(a));
result : BigInteger.BigInt := multiplier;
function "*"(left, right : BigInteger.BigInt) return BigInteger.BigInt renames BigInteger."*";
sum : Positive := Digit_Sum(result);
begin
if sum > max_sum then
max_sum := sum;
end if;
for b in 2 .. 100 loop
result := result * multiplier;
sum := Digit_Sum(result);
if sum > max_sum then
max_sum := sum;
end if;
end loop;
end;
end loop;
IO.Put_Line(Positive'Image(max_sum));
end Solve;
end Problem_56;
|
-- { dg-do run }
-- { dg-options "-gnatws" }
procedure Biased_Subtype is
CIM_Max_AA : constant := 9_999_999;
CIM_Min_AA : constant := -999_999;
type TIM_AA is range CIM_Min_AA..CIM_Max_AA + 1;
for TIM_AA'Size use 24;
subtype STIM_AA is TIM_AA range TIM_AA(CIM_Min_AA)..TIM_AA(CIM_Max_AA);
SAA : STIM_AA := 1;
begin
if Integer(SAA) /= 1 then
raise Program_Error;
end if;
end;
|
package body Shared_Data is
protected body Sensor_Reading is
procedure Set (Meassured_Value : in Float) is
begin
Current_Value := Meassured_Value;
Updated := True;
end Set;
entry Get (Value : out Float) when Updated is
begin
Value := Current_Value;
Updated := False;
end Get;
end Sensor_Reading;
protected body Actuator_Write is
procedure Set (Calculated_Value : in RPM; Motor : in Motor_Direction) is
begin
Current_Value := Calculated_Value;
Current_Motor := Motor;
Updated := True;
end Set;
entry Get (Value : out RPM; Motor : out Motor_Direction) when Updated is
begin
Value := Current_Value;
Motor := Current_Motor;
Updated := False;
end Get;
end Actuator_Write;
end Shared_Data; |
-- smart_c_resources.ads
-- A reference counting package to wrap a C type that requires initialization
-- and finalization.
-- Copyright (c) 2016, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
pragma Profile (No_Implementation_Extensions);
with Ada.Finalization;
with Counters_Spec;
generic
type T is private;
with function Initialize return T;
with procedure Finalize (X : in T);
with package Counters is new Counters_Spec (others => <>);
package Smart_C_Resources is
type Smart_T is new Ada.Finalization.Controlled with private;
-- Smart_T wraps a type T which is anticipated to be a pointer to an opaque
-- struct provided by a library written in C. Typically it is necessary
-- to call library routines to initialize the underlying resources and to
-- release them when no longer required. Smart_T ensures this is done in a
-- reference counted manner so the resources will only be released when the
-- last Smart_T is destroyed.
function Make_Smart_T (X : in T) return Smart_T with Inline;
-- Usually a Smart_T will be default initialized with the function used
-- to instantiate the package in the formal parameter Initialize. The
-- Make_Smart_T function can be used where an explicit initialization
-- is preferred.
function Element (S : in Smart_T) return T with Inline;
-- Element returns the underlying value of the Smart_T representing the
-- resources managed by the C library.
function Use_Count (S : in Smart_T) return Natural with Inline;
-- Use_Count returns the number of Smart_T in existence for a given C
-- resource.
function Unique (S : in Smart_T) return Boolean is
(Use_Count(S) = 1);
-- Unique tests whether a Smart_T is the only one in existence for a given
-- C resource. If it is, then the resource will be freed when the Smart_T
-- is destroyed.
type Smart_T_No_Default(<>) is new Smart_T with private;
-- Smart_T_No_Default manages a C resource that requires initialization and
-- finalization just as Smart_T does, except that no default initialization
-- is felt to be appropriate so values must always be made with Make_Smart_T.
private
use Counters;
type Smart_T is new Ada.Finalization.Controlled with
record
Element : T;
Counter : Counter_Ptr;
end record
with Type_Invariant => Valid (Smart_T);
function Valid (S : Smart_T) return Boolean is
(S.Counter /= null and then Use_Count(S.Counter.all) > 0)
with Inline;
overriding procedure Initialize (Object : in out Smart_T) with Inline;
overriding procedure Adjust (Object : in out Smart_T) with Inline;
overriding procedure Finalize (Object : in out Smart_T) with Inline;
type Smart_T_No_Default is new Smart_T with null record;
end Smart_C_Resources;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Examples Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016-2020, Vadim Godunko <vgodunko@gmail.com> --
-- 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 Ada.Wide_Wide_Text_IO;
with League.Stream_Element_Vectors;
with Web_Socket.Connections;
package body Servlets.Hello is
function "+"
(Text : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Max_Count : constant := 5;
type WS_Handler_Access is access all WS_Handler'Class;
------------
-- Do_Get --
------------
overriding procedure Do_Get
(Self : in out Hello_Servlet;
Request : Servlet.HTTP_Requests.HTTP_Servlet_Request'Class;
Response : in out Servlet.HTTP_Responses.HTTP_Servlet_Response'Class)
is
H : WS_Handler_Access := new WS_Handler;
begin
H.WS.Set_Web_Socket_Listener (H.all'Access);
Request.Upgrade (H.WS'Access);
Response.Set_Status (Servlet.HTTP_Responses.Switching_Protocols);
end Do_Get;
----------------------
-- Get_Servlet_Info --
----------------------
overriding function Get_Servlet_Info
(Self : Hello_Servlet)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
Text : constant Wide_Wide_String :=
"Hello servlet provides WebSocket upgrade responses";
begin
return +Text;
end Get_Servlet_Info;
-----------------
-- Instantiate --
-----------------
overriding function Instantiate
(Parameters : not null access
Servlet.Generic_Servlets.Instantiation_Parameters'Class)
return Hello_Servlet
is
pragma Unreferenced (Parameters);
begin
return (Servlet.HTTP_Servlets.HTTP_Servlet with null record);
end Instantiate;
---------------
-- On_Binary --
---------------
overriding procedure On_Binary
(Self : in out WS_Handler;
Data : Ada.Streams.Stream_Element_Array)
is
Vector : League.Stream_Element_Vectors.Stream_Element_Vector;
begin
Ada.Wide_Wide_Text_IO.Put_Line
("On_Binary:" & Natural'Wide_Wide_Image (Data'Length));
if Self.Count < Max_Count then
Self.Count := Self.Count + 1;
Vector.Append (Data);
Web_Socket.Connections.Connection'Class (Self.WS).
Send_Binary (Vector);
-- Web_Socket.Handlers.AWS_Handlers.Send_Binary (Self.WS, Vector);
-- Self.WS.Send_Binary (Vector);
end if;
end On_Binary;
--------------
-- On_Close --
--------------
overriding procedure On_Close
(Self : in out WS_Handler;
Status : Web_Socket.Listeners.Status_Code;
Reason : League.Strings.Universal_String) is
begin
Ada.Wide_Wide_Text_IO.Put_Line
("On_Close: "
& Web_Socket.Listeners.Status_Code'Wide_Wide_Image (Status)
& Reason.To_Wide_Wide_String);
end On_Close;
----------------
-- On_Connect --
----------------
overriding procedure On_Connect (Self : in out WS_Handler) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Connect");
end On_Connect;
--------------
-- On_Error --
--------------
overriding procedure On_Error (Self : in out WS_Handler) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Error");
end On_Error;
-------------
-- On_Text --
-------------
overriding procedure On_Text
(Self : in out WS_Handler;
Text : League.Strings.Universal_String) is
begin
Ada.Wide_Wide_Text_IO.Put_Line ("On_Text: " & Text.To_Wide_Wide_String);
if Self.Count < Max_Count then
Self.Count := Self.Count + 1;
Web_Socket.Connections.Connection'Class (Self.WS).
Send_Text (Text);
end if;
end On_Text;
end Servlets.Hello;
|
with C_String;
with Interfaces.C;
with System;
package body Agar.Core.Data_Source is
package C renames Interfaces.C;
use type C.size_t;
--
-- Open.
--
procedure Open_File
(Path : in String;
Mode : in String;
Source : out Data_Source_Access_t)
is
Ch_Path : aliased C.char_array := C.To_C (Path);
Ch_Mode : aliased C.char_array := C.To_C (Mode);
begin
Source := Thin.Data_Source.Open_File
(Path => C_String.To_C_String (Ch_Path'Unchecked_Access),
Mode => C_String.To_C_String (Ch_Mode'Unchecked_Access));
end Open_File;
--
-- Close.
--
procedure Close_File
(Source : in Data_Source_Not_Null_Access_t) is
begin
Thin.Data_Source.Close_File (Source);
end Close_File;
--
-- I/O.
--
package body IO is
Element_Bytes : constant C.size_t := Element_Type'Size / System.Storage_Unit;
procedure Read
(Source : in Data_Source_Not_Null_Access_t;
Buffer : out Element_Array_Type;
Read : out Element_Count_Type;
Status : out IO_Status_t) is
begin
Status := IO_Status_t (Thin.Data_Source.Read
(Source => Source,
Buffer => Buffer (Buffer'First)'Address,
Size => Element_Bytes,
Members => Buffer'Length));
if Status = Success then
Read := Buffer'Length;
end if;
end Read;
procedure Read_At_Offset
(Source : in Data_Source_Not_Null_Access_t;
Offset : in Byte_Offset_t;
Buffer : out Element_Array_Type;
Read : out Element_Count_Type;
Status : out IO_Status_t) is
begin
Status := IO_Status_t (Thin.Data_Source.Read_At
(Source => Source,
Buffer => Buffer (Buffer'First)'Address,
Size => Element_Bytes,
Members => Buffer'Length,
Offset => C.size_t (Offset)));
if Status = Success then
Read := Buffer'Length;
end if;
end Read_At_Offset;
procedure Write
(Source : in Data_Source_Not_Null_Access_t;
Buffer : in Element_Array_Type;
Wrote : out Element_Count_Type;
Status : out IO_Status_t) is
begin
Status := IO_Status_t (Thin.Data_Source.Write
(Source => Source,
Buffer => Buffer (Buffer'First)'Address,
Size => Element_Bytes,
Members => Buffer'Length));
if Status = Success then
Wrote := Buffer'Length;
end if;
end Write;
procedure Write_At_Offset
(Source : in Data_Source_Not_Null_Access_t;
Offset : in Byte_Offset_t;
Buffer : in Element_Array_Type;
Wrote : out Element_Count_Type;
Status : out IO_Status_t) is
begin
Status := IO_Status_t (Thin.Data_Source.Write_At
(Source => Source,
Buffer => Buffer (Buffer'First)'Address,
Size => Element_Bytes,
Offset => C.size_t (Offset),
Members => Buffer'Length));
if Status = Success then
Wrote := Buffer'Length;
else
Wrote := 0;
end if;
end Write_At_Offset;
end IO;
end Agar.Core.Data_Source;
|
package Discr11_Pkg is
type DT_1 (<>) is tagged private;
function Create return DT_1;
private
type DT_1 (Size : Positive) is tagged record
Data : String (1 .. Size);
end record;
end Discr11_Pkg;
|
with Ada.Finalization;
with kv.avm.Line_Parser;
with kv.avm.Tuples;
package kv.avm.Ini is
type Settings_Type is new Ada.Finalization.Controlled and kv.avm.Line_Parser.Parse_Line_Interface with private;
overriding procedure Initialize (Self : in out Settings_Type);
overriding procedure Adjust (Self : in out Settings_Type);
overriding procedure Finalize (Self : in out Settings_Type);
overriding procedure Parse_Line
(Self : in out Settings_Type;
Line : in String);
function Has(Self : Settings_Type; Key : String) return Boolean;
function Lookup_As_String(Self : Settings_Type; Key : String; Index : Positive := 1) return String;
function Lookup_As_Integer(Self : Settings_Type; Key : String; Index : Positive := 1) return Integer;
function Lookup_As_Tuple(Self : Settings_Type; Key : String; Index : Positive := 1) return kv.avm.Tuples.Tuple_Type;
procedure Add_Value_To_Existing_Key
(Self : in out Settings_Type;
Key : in String;
Value : in String);
procedure Insert
(Self : in out Settings_Type;
Key : in String;
Value : in String);
function Value_Count_For_Key(Self : Settings_Type; Key : String) return Natural;
procedure Parse_Input_File
(Self : in out Settings_Type;
File_In : in String);
private
type Settings_Reference_Counter_Type;
type Settings_Reference_Counter_Access is access all Settings_Reference_Counter_Type;
type Settings_Type is new Ada.Finalization.Controlled and kv.avm.Line_Parser.Parse_Line_Interface with
record
Ref : Settings_Reference_Counter_Access;
end record;
end kv.avm.Ini;
|
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+flacada@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
-- FLAC/Ada
--
-- Headers
--
-- The STREAMINFO block.
------------------------------------------------------------------------------
with Ada.Streams.Stream_IO;
with SPARK_Stream_IO;
package FLAC.Headers.Stream_Info with
Preelaborate => True,
SPARK_Mode => On
is
-- METADATA_BLOCK_STREAMINFO
-- <16> The minimum block size (in samples) used in the stream.
-- <16> The maximum block size (in samples) used in the stream. (Minimum
-- blocksize == maximum blocksize) implies a fixed-blocksize stream.
-- <24> The minimum frame size (in bytes) used in the stream. May be 0 to
-- imply the value is not known.
-- <24> The maximum frame size (in bytes) used in the stream. May be 0 to
-- imply the value is not known.
-- <20> Sample rate in Hz. Though 20 bits are available, the maximum sample
-- rate is limited by the structure of frame headers to 655350 Hz.
-- Also, a value of 0 is invalid.
-- <3> (number of channels)-1. FLAC supports from 1 to 8 channels
-- <5> (bits per sample)-1. FLAC supports from 4 to 32 bits per sample.
-- Currently the reference encoder and decoders only support up to 24
-- bits per sample.
-- <36> Total samples in stream. 'Samples' means inter-channel sample, i.e.
-- one second of 44.1 kHz audio will have 44100 samples regardless of
-- the number of channels. A value of zero here means the number of
-- total samples is unknown.
-- <128> MD5 signature of the unencoded audio data. This allows the decoder
-- to determine if an error exists in the audio data even when the
-- error does not result in an invalid bitstream.
-- NOTES
-- FLAC specifies a minimum block size of 16 and a maximum block size of
-- 65535, meaning the bit patterns corresponding to the numbers 0-15 in
-- the minimum blocksize and maximum blocksize fields are invalid.
type T is
record
Min_Block_Size : Types.Block_Size; -- samples
Max_Block_Size : Types.Block_Size; -- samples
Min_Frame_Size : Types.Length_24; -- bytes
Max_Frame_Size : Types.Length_24; -- bytes
Sample_Rate : Types.Sample_Rate;
Num_Channels : Types.Channel_Count;
Bits_Per_Sample : Types.Bits_Per_Sample;
Total_Samples : Types.Sample_Count;
MD5_Signature : Types.MD5_Sum;
end record;
Stream_Info_Length : constant := 272 / Ada.Streams.Stream_Element'Size;
---------------------------------------------------------------------------
-- Read
---------------------------------------------------------------------------
procedure Read (File : in Ada.Streams.Stream_IO.File_Type;
Item : out T;
Error : out Boolean)
with
Relaxed_Initialization => Item,
Pre => SPARK_Stream_IO.Is_Open (File => File),
Post => (if not Error then Item'Initialized),
Depends => ((Error, Item) => File);
end FLAC.Headers.Stream_Info;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Unchecked_Conversion;
with GL.API;
with GL.Enums.Getter;
package body GL.Objects.Framebuffers is
------------
function Status (Target : Framebuffer_Target) return Framebuffer_Status is
begin
return API.Check_Framebuffer_Status (Target.Kind);
end Status;
procedure Attach_Renderbuffer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Renderbuffers.Renderbuffer'Class) is
begin
API.Framebuffer_Renderbuffer (Target.Kind, Attachment,
Low_Level.Enums.Renderbuffer,
Object.Raw_Id);
Raise_Exception_On_OpenGL_Error;
end Attach_Renderbuffer;
procedure Attach_Texture (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level) is
begin
API.Framebuffer_Texture (Target.Kind, Attachment, Object.Raw_Id, Level);
Raise_Exception_On_OpenGL_Error;
end Attach_Texture;
procedure Attach_Texture_Layer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level;
Layer : Int) is
begin
API.Framebuffer_Texture_Layer (Target.Kind, Attachment, Object.Raw_Id,
Level, Layer);
Raise_Exception_On_OpenGL_Error;
end Attach_Texture_Layer;
procedure Invalidate (Target : in out Framebuffer_Target;
Attachments : Attachment_List) is
begin
API.Invalidate_Framebuffer (Target.Kind, Attachments'Length, Attachments);
Raise_Exception_On_OpenGL_Error;
end Invalidate;
procedure Invalidate_Sub (Target : in out Framebuffer_Target;
Attachments : Attachment_List;
X, Y : Int;
Width, Height : Size) is
begin
API.Invalidate_Sub_Framebuffer (Target.Kind, Attachments'Length,
Attachments, X, Y, Width, Height);
Raise_Exception_On_OpenGL_Error;
end Invalidate_Sub;
procedure Blit (Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1 : Int;
Mask : Buffers.Buffer_Bits;
Filter : Textures.Magnifying_Function) is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Buffers.Buffer_Bits, Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield
:= Convert (Mask) and 2#0100010100000000#;
begin
API.Blit_Framebuffer (Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1, Raw_Bits, Filter);
Raise_Exception_On_OpenGL_Error;
end Blit;
procedure Set_Default_Width (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Width, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Width;
function Default_Width (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size
(Target.Kind, Enums.Default_Width, Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Width;
function Max_Framebuffer_Width return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Width, Ret'Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Width;
procedure Set_Default_Height (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Height,
Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Height;
function Default_Height (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Height,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Height;
function Max_Framebuffer_Height return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Height, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Height;
procedure Set_Default_Layers (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Layers, Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Layers;
function Default_Layers (Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Layers,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Layers;
function Max_Framebuffer_Layers return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Layers, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Layers;
procedure Set_Default_Samples (Target : in out Framebuffer_Target;
Value : Size) is
begin
API.Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Samples,
Value);
Raise_Exception_On_OpenGL_Error;
end Set_Default_Samples;
function Default_Samples
(Target : Framebuffer_Target) return Size is
Ret : Size;
begin
API.Get_Framebuffer_Parameter_Size (Target.Kind, Enums.Default_Samples,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Default_Samples;
function Max_Framebuffer_Samples return Size is
Ret : aliased Size;
begin
API.Get_Size (Enums.Getter.Max_Framebuffer_Samples, Ret'Unchecked_Access);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Max_Framebuffer_Samples;
procedure Set_Default_Fixed_Sample_Locactions
(Target : in out Framebuffer_Target; Value : Boolean) is
begin
API.Framebuffer_Parameter_Bool
(Target.Kind, Enums.Default_Fixed_Sample_Locations,
Low_Level.Bool (Value));
Raise_Exception_On_OpenGL_Error;
end Set_Default_Fixed_Sample_Locactions;
function Default_Fixed_Sample_Locations (Target : Framebuffer_Target)
return Boolean is
Ret : Low_Level.Bool;
begin
API.Get_Framebuffer_Parameter_Bool
(Target.Kind, Enums.Default_Fixed_Sample_Locations, Ret);
Raise_Exception_On_OpenGL_Error;
return Boolean (Ret);
end Default_Fixed_Sample_Locations;
overriding
procedure Internal_Create_Id (Object : Framebuffer; Id : out UInt) is
pragma Unreferenced (Object);
begin
API.Gen_Framebuffers (1, Id);
Raise_Exception_On_OpenGL_Error;
end Internal_Create_Id;
overriding
procedure Internal_Release_Id (Object : Framebuffer; Id : UInt) is
pragma Unreferenced (Object);
begin
API.Delete_Framebuffers (1, (1 => Id));
Raise_Exception_On_OpenGL_Error;
end Internal_Release_Id;
function Hash (Key : Low_Level.Enums.Framebuffer_Kind)
return Ada.Containers.Hash_Type is
function Value is new Ada.Unchecked_Conversion
(Source => Low_Level.Enums.Framebuffer_Kind, Target => Low_Level.Enum);
begin
return Ada.Containers.Hash_Type (Value (Key));
end Hash;
package Framebuffer_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => Low_Level.Enums.Framebuffer_Kind,
Element_Type => Framebuffer'Class,
Hash => Hash,
Equivalent_Keys => Low_Level.Enums."=");
use type Framebuffer_Maps.Cursor;
Current_Framebuffers : Framebuffer_Maps.Map;
type Framebuffer_Kind_Array is array (Positive range <>) of
Low_Level.Enums.Framebuffer_Kind;
function Backend_Framebuffer_Targets
(Kind : Low_Level.Enums.Framebuffer_Kind) return Framebuffer_Kind_Array is
begin
case Kind is
when Low_Level.Enums.Read => return (1 => Low_Level.Enums.Read);
when Low_Level.Enums.Draw => return (1 => Low_Level.Enums.Draw);
when Low_Level.Enums.Read_Draw =>
return (1 => Low_Level.Enums.Draw, 2 => Low_Level.Enums.Read);
end case;
end Backend_Framebuffer_Targets;
pragma Inline (Backend_Framebuffer_Targets);
procedure Bind (Target : Framebuffer_Target;
Object : Framebuffer'Class) is
-- Read_Draw bind to both read and draw framebuffer, we need to set
-- the current framebuffer objects accordingly.
Targets : constant Framebuffer_Kind_Array
:= Backend_Framebuffer_Targets (Target.Kind);
Cursor : Framebuffer_Maps.Cursor;
begin
API.Bind_Framebuffer (Target.Kind, Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
for Index in Targets'Range loop
Cursor := Current_Framebuffers.Find (Targets (Index));
if Cursor = Framebuffer_Maps.No_Element then
Current_Framebuffers.Insert (Targets (Index), Object);
elsif Framebuffer_Maps.Element (Cursor).Reference.GL_Id
/= Object.Reference.GL_Id then
Current_Framebuffers.Replace_Element (Cursor, Object);
end if;
end loop;
end Bind;
function Current (Target : Framebuffer_Target) return Framebuffer'Class is
Targets : constant Framebuffer_Kind_Array
:= Backend_Framebuffer_Targets (Target.Kind);
-- If target is Read_Draw, return the draw framebuffer
-- (Note: this is necessary because distinct read/draw framebuffers
-- were added later to the API and therefore might not be available
-- in the context. So everything needs to work with just Read_Draw).
Cursor : constant Framebuffer_Maps.Cursor
:= Current_Framebuffers.Find (Targets (1));
begin
if Cursor = Framebuffer_Maps.No_Element then
raise No_Object_Bound_Exception with Target.Kind'Img;
else
return Framebuffer_Maps.Element (Cursor);
end if;
end Current;
end GL.Objects.Framebuffers;
|
pragma License (Unrestricted);
-- with System;
-- with System.Multiprocessors;
package Ada.Interrupts is
type Interrupt_Id is range 0 .. 2 ** 16 - 1; -- implementation-defined
type Parameterless_Handler is access protected procedure;
function Is_Reserved (Interrupt : Interrupt_Id) return Boolean;
pragma Inline (Is_Reserved);
-- extended
-- Check the interrupt mask of current process.
function Is_Blocked (Interrupt : Interrupt_Id) return Boolean;
pragma Inline (Is_Blocked);
-- extended
-- Set the interrupt mask of current process.
procedure Block (Interrupt : Interrupt_Id);
-- extended
-- Unset the interrupt mask of current process.
procedure Unblock (Interrupt : Interrupt_Id);
pragma Inline (Block);
pragma Inline (Unblock);
function Is_Attached (Interrupt : Interrupt_Id) return Boolean;
pragma Inline (Is_Attached);
function Current_Handler (Interrupt : Interrupt_Id)
return Parameterless_Handler;
procedure Attach_Handler (
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_Id);
pragma Inline (Attach_Handler);
procedure Exchange_Handler (
Old_Handler : out Parameterless_Handler;
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_Id);
procedure Detach_Handler (Interrupt : Interrupt_Id);
pragma Inline (Detach_Handler);
-- extended
-- Unchecked version of Attach_Handler.
procedure Unchecked_Attach_Handler (
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_Id);
pragma Inline (Unchecked_Attach_Handler);
-- extended
-- Unchecked version of Exchange_Handler.
procedure Unchecked_Exchange_Handler (
Old_Handler : out Parameterless_Handler;
New_Handler : Parameterless_Handler;
Interrupt : Interrupt_Id);
pragma Inline (Unchecked_Exchange_Handler);
-- extended
-- Unchecked version of Detach_Handler.
procedure Unchecked_Detach_Handler (Interrupt : Interrupt_Id);
pragma Inline (Unchecked_Detach_Handler);
-- function Reference (Interrupt : Interrupt_Id) return System.Address;
-- function Get_CPU (Interrupt : Interrupt_Id)
-- return System.Multiprocessors.CPU_Range;
-- extended
-- Raise a interrupt from/to itself.
procedure Raise_Interrupt (Interrupt : Interrupt_Id);
pragma Inline (Raise_Interrupt);
end Ada.Interrupts;
|
with Units; use Units;
package Config is
CFG_TARGET_ALTITUDE_THRESHOLD : constant Altitude_Type := 100.0 * Meter;
CFG_TARGET_ALTITUDE_THRESHOLD_TIME : constant := 6.0 * Second;
end Config;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package body Yaml.Presenter.Analysis is
function Features (S : String) return Scalar_Features is
Pos : Positive := S'First;
Cur : Character;
Cur_Word_Length : Natural := 0;
Cur_Line_Length : Natural := 0;
-- states
procedure Read_Beginning (Ret : out Scalar_Features) is
begin
if S'Length = 0 then
Ret := (Max_Word_Length => 0, Max_Line_Length => 0,
Single_Line_Length => 0, Quoting_Needed => Single,
Unquoted_Single_Line => True, Folding_Possible => True,
Contains_Non_Printable => False,
Leading_Spaces => 0, Trailing_Linefeeds => 0);
else
Ret := (Max_Word_Length => 0,
Max_Line_Length => 0,
Single_Line_Length => 0,
Quoting_Needed => None,
Unquoted_Single_Line => True,
Folding_Possible => True,
Contains_Non_Printable => False,
Leading_Spaces => 0,
Trailing_Linefeeds => 0);
Cur := S (Pos);
if Cur = ' ' then
Ret.Quoting_Needed := Single;
loop
Ret.Leading_Spaces := Ret.Leading_Spaces + 1;
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur /= ' ';
end loop;
end if;
end if;
end Read_Beginning;
procedure Read_Word (Ret : in out Scalar_Features) is
begin
if Cur = '#' then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
end if;
loop
case Cur is
when ':' =>
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
if Pos < S'Last and then S (Pos + 1) = ' ' then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
Pos := Pos + 1;
return;
end if;
when Character'Val (7) .. Character'Val (9) =>
Ret.Quoting_Needed := Double;
Ret.Single_Line_Length := Ret.Single_Line_Length + 2;
Ret.Contains_Non_Printable := True;
when '"' =>
if Pos = S'First then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Single_Line_Length := Ret.Single_Line_Length + 2;
Ret.Unquoted_Single_Line := False;
else
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
end if;
when others =>
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
end case;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur in ' ' | Character'Val (10);
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
end loop;
end Read_Word;
procedure Read_Newlines (Ret : in out Scalar_Features) is
begin
Ret.Max_Line_Length :=
Natural'Max (Ret.Max_Line_Length, Cur_Line_Length);
Cur_Line_Length := 0;
Ret.Max_Word_Length :=
Natural'Max (Ret.Max_Word_Length, Cur_Word_Length);
Cur_Word_Length := 0;
loop
Ret.Trailing_Linefeeds := Ret.Trailing_Linefeeds + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
Cur := S (Pos);
exit when Cur /= Character'Val (10);
end loop;
if Pos <= S'Last then
Ret.Trailing_Linefeeds := 0;
end if;
end Read_Newlines;
procedure Read_Space_After_Word (Ret : in out Scalar_Features) is
begin
Cur_Line_Length := Cur_Line_Length + 1;
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
Pos := Pos + 1;
if Pos > S'Last then
Ret.Quoting_Needed :=
Necessary_Quoting'Max (Ret.Quoting_Needed, Single);
Ret.Unquoted_Single_Line := False;
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
return;
end if;
Cur := S (Pos);
if Cur in ' ' | Character'Val (10) then
Cur_Word_Length := Cur_Word_Length + 1;
while Cur = ' ' loop
Cur_Word_Length := Cur_Word_Length + 1;
Cur_Line_Length := Cur_Line_Length + 1;
Ret.Single_Line_Length := Ret.Single_Line_Length + 1;
Pos := Pos + 1;
exit when Pos > S'Last;
end loop;
else
Ret.Max_Word_Length :=
Natural'Max (Ret.Max_Word_Length, Cur_Word_Length);
Cur_Word_Length := 0;
end if;
end Read_Space_After_Word;
begin
return Ret : Scalar_Features do
Read_Beginning (Ret);
if Pos <= S'Last then
loop
Read_Word (Ret);
exit when Pos > S'Last;
loop
case Cur is
when ' ' => Read_Space_After_Word (Ret);
when Character'Val (10) => Read_Newlines (Ret);
when others => null; -- never happens
end case;
exit when Pos > S'Last or else
not (Cur in ' ' | Character'Val (10));
end loop;
exit when Pos > S'Last;
end loop;
end if;
end return;
end Features;
end Yaml.Presenter.Analysis;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Generic_Shared_Instance.Fallback_Switch;
with Apsepp.Test_Reporter_Class.Stub.Create; use Apsepp.Test_Reporter_Class;
private package Apsepp.Test_Node_Class.Private_Test_Reporter is
procedure Run_Instance_Process_Primitive;
package Shared_Instance is new Generic_Shared_Instance
(Instance_Ancestor_Type => Test_Reporter_Interfa,
Unlock_CB => Run_Instance_Process_Primitive'Access);
function Test_Reporter return Test_Reporter_Access;
private
use Test_Reporter_Class.Stub;
-- TODO: Consider removing Test_Reporter_Stub creational function.
-- <2019-06-08>
Fallback_Instance : aliased Test_Reporter_Stub := Create;
package Shared_Instance_Fallback_Switch
is new Shared_Instance.Fallback_Switch (Fallback_Instance'Access);
end Apsepp.Test_Node_Class.Private_Test_Reporter;
|
with GESTE;
with GESTE.Text;
with Ada.Text_IO;
with Console_Char_Screen;
with GESTE_Fonts.FreeMono8pt7b;
procedure Text_Dirty is
package Font_A renames GESTE_Fonts.FreeMono8pt7b;
package Console_Screen is new Console_Char_Screen
(Width => 45,
Height => 20,
Buffer_Size => 45,
Init_Char => ' ');
Text_A : aliased GESTE.Text.Instance
(Font_A.Font, 4, 1, '#', ' ');
procedure Update is
begin
GESTE.Render_Dirty
(Screen_Rect => Console_Screen.Screen_Rect,
Background => ' ',
Buffer => Console_Screen.Buffer,
Push_Pixels => Console_Screen.Push_Pixels'Unrestricted_Access,
Set_Drawing_Area => Console_Screen.Set_Drawing_Area'Unrestricted_Access);
Console_Screen.Print;
Ada.Text_IO.New_Line;
end Update;
begin
Console_Screen.Verbose;
Text_A.Put ("test");
Text_A.Move ((0, 0));
GESTE.Add (Text_A'Unrestricted_Access, 0);
GESTE.Render_Window
(Window => Console_Screen.Screen_Rect,
Background => ' ',
Buffer => Console_Screen.Buffer,
Push_Pixels => Console_Screen.Push_Pixels'Unrestricted_Access,
Set_Drawing_Area => Console_Screen.Set_Drawing_Area'Unrestricted_Access);
Console_Screen.Print;
Ada.Text_IO.New_Line;
Update;
-- Check that inverting a char triggers a re-draw
Text_A.Invert (2, 1);
Update;
-- Check that changing a char triggers a re-draw
Text_A.Cursor (3, 1);
Text_A.Put ('O');
Update;
-- Check that changing colors triggers a re-draw
Text_A.Set_Colors (4, 1, '_', ' ');
Update;
-- Check that clearing text triggers a re-draw
Text_A.Clear;
Update;
end Text_Dirty;
|
pragma Check_Policy (Trace => Ignore);
with Ada; -- assertions
with System.Formatting.Address;
with System.Storage_Map;
with System.Unwind.Occurrences;
with System.Unwind.Raising;
package body System.Unwind.Backtrace is
pragma Suppress (All_Checks);
package Separated is
-- equivalent to __gnat_backtrace (tracebak.c/tb-gcc.c)
procedure Backtrace (
Item : aliased out Tracebacks_Array;
Last : out Natural;
Exclude_Min : Address;
Exclude_Max : Address);
end Separated;
package body Separated is separate;
-- implementation
procedure Call_Chain (Current : in out Exception_Occurrence) is
function Report return Boolean;
function Report return Boolean is
begin
Occurrences.Put_Exception_Information (Current);
return True;
end Report;
begin
if Exception_Tracebacks /= 0 and then Current.Num_Tracebacks = 0 then
Separated.Backtrace (
Current.Tracebacks,
Current.Num_Tracebacks, -- Tracebacks_Array'First = 1
Raising.AAA,
Raising.ZZZ);
pragma Check (Trace, Ada.Debug.Put ("Call_Chain"));
pragma Check (Trace, Report);
end if;
end Call_Chain;
procedure Backtrace_Information (
X : Exception_Occurrence;
Params : Address;
Put : not null access procedure (S : String; Params : Address);
New_Line : not null access procedure (Params : Address))
is
S : Formatting.Address.Address_String;
begin
Put ("Load address: 0x", Params);
declare
Item : constant Address := Storage_Map.Load_Address;
begin
Formatting.Address.Image (
Item,
S,
Set => Formatting.Lower_Case);
Put (S, Params);
end;
New_Line (Params);
Put ("Call stack traceback locations:", Params);
New_Line (Params);
for I in 1 .. X.Num_Tracebacks loop
Put ("0x", Params);
declare
Item : constant Address := X.Tracebacks (I);
begin
Formatting.Address.Image (
Item,
S,
Set => Formatting.Lower_Case);
Put (S, Params);
end;
if I < X.Num_Tracebacks then
Put (" ", Params);
end if;
end loop;
New_Line (Params);
end Backtrace_Information;
end System.Unwind.Backtrace;
|
pragma License (Unrestricted);
-- generalized unit of Ada.Strings.Unbounded
with Ada.References;
with Ada.Streams;
with Ada.Unchecked_Deallocation;
private with Ada.Finalization;
private with System.Reference_Counting;
generic
type Character_Type is (<>);
type String_Type is array (Positive range <>) of Character_Type;
with procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out String_Type) is String_Type'Read;
with procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : String_Type) is String_Type'Write;
with package Slicing is
new References.Generic_Slicing (Positive, Character_Type, String_Type);
package Ada.Strings.Generic_Unbounded is
pragma Preelaborate;
-- modified
-- Unbounded_String is declared as tagged for dot notation.
-- type Unbounded_String is private;
type Unbounded_String is tagged private;
pragma Preelaborable_Initialization (Unbounded_String);
-- modified
-- Null_Unbounded_String : constant Unbounded_String;
function Null_Unbounded_String return Unbounded_String;
-- extended
function Is_Null (Source : Unbounded_String) return Boolean;
pragma Inline (Is_Null);
function Length (Source : Unbounded_String) return Natural;
pragma Inline (Length);
-- extended
procedure Set_Length (Source : in out Unbounded_String; Length : Natural);
function Capacity (Source : Unbounded_String) return Natural;
procedure Reserve_Capacity (
Source : in out Unbounded_String;
Capacity : Natural);
pragma Inline (Capacity);
type String_Access is access all String_Type;
-- procedure Free (X : in out String_Access);
procedure Free is new Unchecked_Deallocation (String_Type, String_Access);
-- extended
type String_Constant_Access is access constant String_Type;
-- Conversion, Concatenation, and Selection functions
function To_Unbounded_String (Source : String_Type)
return Unbounded_String;
-- extended
-- For shorthand.
function "+" (Source : String_Type) return Unbounded_String
renames To_Unbounded_String;
function To_Unbounded_String (Length : Natural)
return Unbounded_String;
function To_String (Source : Unbounded_String) return String_Type;
procedure Set_Unbounded_String (
Target : out Unbounded_String;
Source : String_Type);
procedure Append (
Source : in out Unbounded_String;
New_Item : Unbounded_String);
procedure Append (
Source : in out Unbounded_String;
New_Item : String_Type);
procedure Append_Element (
Source : in out Unbounded_String;
New_Item : Character_Type);
function "&" (Left, Right : Unbounded_String) return Unbounded_String;
function "&" (Left : Unbounded_String; Right : String_Type)
return Unbounded_String;
function "&" (Left : String_Type; Right : Unbounded_String)
return Unbounded_String;
function "&" (Left : Unbounded_String; Right : Character_Type)
return Unbounded_String;
function "&" (Left : Character_Type; Right : Unbounded_String)
return Unbounded_String;
function Element (Source : Unbounded_String; Index : Positive)
return Character_Type;
pragma Inline (Element);
procedure Replace_Element (
Source : in out Unbounded_String;
Index : Positive;
By : Character_Type);
function Slice (
Source : Unbounded_String;
Low : Positive;
High : Natural)
return String_Type;
function Unbounded_Slice (
Source : Unbounded_String;
Low : Positive;
High : Natural)
return Unbounded_String;
procedure Unbounded_Slice (
Source : Unbounded_String;
Target : out Unbounded_String;
Low : Positive;
High : Natural);
overriding function "=" (Left, Right : Unbounded_String) return Boolean;
function "=" (Left : Unbounded_String; Right : String_Type) return Boolean;
function "=" (Left : String_Type; Right : Unbounded_String) return Boolean;
function "<" (Left, Right : Unbounded_String) return Boolean;
function "<" (Left : Unbounded_String; Right : String_Type) return Boolean;
function "<" (Left : String_Type; Right : Unbounded_String) return Boolean;
function "<=" (Left, Right : Unbounded_String) return Boolean;
function "<=" (Left : Unbounded_String; Right : String_Type) return Boolean;
function "<=" (Left : String_Type; Right : Unbounded_String) return Boolean;
pragma Inline ("<=");
function ">" (Left, Right : Unbounded_String) return Boolean;
function ">" (Left : Unbounded_String; Right : String_Type) return Boolean;
function ">" (Left : String_Type; Right : Unbounded_String) return Boolean;
pragma Inline (">");
function ">=" (Left, Right : Unbounded_String) return Boolean;
function ">=" (Left : Unbounded_String; Right : String_Type) return Boolean;
function ">=" (Left : String_Type; Right : Unbounded_String) return Boolean;
pragma Inline (">=");
-- extended
-- Efficient copying.
procedure Assign (
Target : in out Unbounded_String;
Source : Unbounded_String);
procedure Move (
Target : in out Unbounded_String;
Source : in out Unbounded_String);
-- extended
-- Convenient way to direct access.
function Constant_Reference (
Source : aliased Unbounded_String)
return Slicing.Constant_Reference_Type;
function Reference (
Source : aliased in out Unbounded_String)
return Slicing.Reference_Type;
-- for making constant Unbounded_String without dynamic allocation
generic
S : not null String_Constant_Access;
package Generic_Constant is
function Value return Unbounded_String;
end Generic_Constant;
private
subtype Fixed_String is String_Type (Positive);
type Fixed_String_Access is access all Fixed_String;
type Data is record -- "limited" prevents No_Elaboration_Code
Reference_Count : aliased System.Reference_Counting.Counter;
Capacity : Natural;
Max_Length : aliased System.Reference_Counting.Length_Type;
Items : not null Fixed_String_Access;
-- the storage would be allocated in here
end record;
pragma Suppress_Initialization (Data);
pragma Compile_Time_Error (
Data'Size rem Wide_Wide_Character'Size > 0,
"misaligned");
type Data_Access is access all Data;
Empty_String : aliased constant String_Type (1 .. 0) :=
(others => Character_Type'Val (0));
Empty_Data : aliased constant Data := (
Reference_Count => System.Reference_Counting.Static,
Capacity => 0,
Max_Length => 0,
Items => Fixed_String'Deref (Empty_String'Address)'Unrestricted_Access);
type Unbounded_String is new Finalization.Controlled with record
Data : aliased not null Data_Access := Empty_Data'Unrestricted_Access;
Length : aliased Natural := 0;
end record;
procedure Unique (Source : in out Unbounded_String'Class);
procedure Unique_And_Set_Length (
Source : in out Unbounded_String'Class;
Length : Natural);
overriding procedure Adjust (Object : in out Unbounded_String);
overriding procedure Finalize (Object : in out Unbounded_String);
package Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Unbounded_String);
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Unbounded_String);
end Streaming;
for Unbounded_String'Read use Streaming.Read;
for Unbounded_String'Write use Streaming.Write;
end Ada.Strings.Generic_Unbounded;
|
with AAA.Processes;
with Ada.Strings.Unbounded;
with Ada.Integer_Text_IO;
with GNAT.OS_Lib;
package body Minirest is
package OS renames GNAT.OS_Lib;
------------------
-- Code_To_Kind --
------------------
function Code_To_Kind (Code : Integer) return Status_Kinds
is (case Code is
when 100 .. 199 => Informative,
when 200 .. 299 => Success,
when 300 .. 399 => Redirect,
when 400 .. 499 => Client_Error,
when 500 .. 599 => Server_Error,
when others => raise Constraint_Error);
--------------
-- Encoding --
--------------
function To_Hex (Char : Character) return String is
Hex : String (1 .. 6);
begin
Ada.Integer_Text_IO.Put (Hex, Character'Pos (Char), Base => 16);
return Hex (4 .. 5);
end To_Hex;
function Encoding (Char : Character) return String
is (case Char is
when '!' | '#' | '$' | '%' | '&' | ''' | '(' | ')' | '*' | '+' |
',' | '/' | ':' | ';' | '=' | '?' | '@' | '[' | ']' | ' '
=> "%" & To_Hex (Char),
when others => (1 => Char));
------------
-- Encode --
------------
function Encode (S : String) return String is
use Ada.Strings.Unbounded;
Result : Unbounded_String;
begin
for Char of S loop
Append (Result, Encoding (Char));
end loop;
return To_String (Result);
end Encode;
-----------
-- "and" --
-----------
function "and" (L : Parameters; R : Parameters) return Parameters is
begin
return Result : Parameters := L do
for I in R.Data.Iterate loop
Result.Data.Insert (AAA.Strings.Maps.Key (I), R.Data (I));
end loop;
end return;
end "and";
---------
-- "=" --
---------
function "=" (Key, Value : String) return Parameters is
begin
return P : Parameters do
P.Data.Insert (Key, Value);
end return;
end "=";
---------
-- Get --
---------
Curl : constant OS.String_Access := OS.Locate_Exec_On_Path ("curl");
function Get (URL : String;
Arguments : Parameters := No_Arguments;
Headers : Parameters := No_Arguments)
return Response
is
function To_URL_Args (Map : AAA.Strings.Map) return String is
use AAA.Strings.Maps;
Flat : AAA.Strings.Vector;
begin
for I in Map.Iterate loop
Flat.Append (Encode (Key (I)) & "=" & Encode (Map (I)));
end loop;
return Flat.Flatten ('&');
end To_URL_Args;
Curl_Args : AAA.Strings.Vector :=
AAA.Strings
.To_Vector ("curl")
.Append ("-s")
.Append ("-i");
begin
if Curl in null then
raise Rest_Error with "Could not find 'curl' tool in path";
end if;
-- Add request headers
for I in Headers.Data.Iterate loop
Curl_Args.Append ("-H");
Curl_Args.Append (AAA.Strings.Maps.Key (I) & ": " & Headers.Data (I));
end loop;
declare
Raw : constant AAA.Processes.Result :=
AAA.Processes.Run
(Curl_Args
.Append
(URL
& (if Arguments.Data.Is_Empty
then ""
elsif (for some C of URL => C = '?')
then "&"
else "?")
& To_URL_Args (Arguments.Data)),
Raise_On_Error => False);
begin
if Raw.Exit_Code /= 0 then
raise Rest_Error with
"curl exited with non-zero error code:" & Raw.Exit_Code'Image;
end if;
declare
Status_Line : constant String := Raw.Output.First_Element;
Code : Integer := -1;
In_Headers : Boolean := True;
Skip : Boolean := False;
begin
-- Identify code
for I in Status_Line'Range loop
if Status_Line (I) = ' ' then
Code := Integer'Value (Status_Line (I + 1 .. I + 4));
exit;
end if;
end loop;
if Code = -1 then
raise Rest_Error with "Malformed status line: " & Status_Line;
end if;
-- Fill response
return R : Response (Code_To_Kind (Code), Status_Line'Length) do
R.Status_Line := Status_Line;
R.Status_Code := Code;
for I in Raw.Output.First_Index + 1 ..
Raw.Output.Last_Index
loop
declare
Line : constant String := Raw.Output (I);
begin
if In_Headers and then Line = "" then
In_Headers := False;
Skip := True;
end if;
if In_Headers then
R.Raw_Headers.Append (Line);
R.Headers.Insert (AAA.Strings.Head (Line, ':'),
AAA.Strings.Trim
(AAA.Strings.Tail (Line, ':')));
elsif Skip then
Skip := False;
else
R.Content.Append (Line);
end if;
end;
end loop;
end return;
end;
end;
end Get;
end Minirest;
|
-- CC1207B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT AN UNCONSTRAINED FORMAL TYPE WITH DISCRIMINANTS IS
-- ALLOWED AS THE TYPE OF A SUBPROGRAM OR AN ENTRY FORMAL
-- PARAMETER, AND AS THE TYPE OF A GENERIC FORMAL OBJECT PARAMETER,
-- AS A GENERIC ACTUAL PARAMETER, AND IN A MEMBERSHIP TEST, IN A
-- SUBTYPE DECLARATION, IN AN ACCESS TYPE DEFINITION, AND IN A
-- DERIVED TYPE DEFINITION.
-- HISTORY:
-- BCB 08/04/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE CC1207B IS
GENERIC
TYPE X (L : INTEGER) IS PRIVATE;
PACKAGE PACK IS
END PACK;
BEGIN
TEST ("CC1207B", "CHECK THAT AN UNCONSTRAINED FORMAL TYPE WITH " &
"DISCRIMINANTS IS ALLOWED AS THE TYPE OF A " &
"SUBPROGRAM OR AN ENTRY FORMAL PARAMETER, AND " &
"AS THE TYPE OF A GENERIC FORMAL OBJECT " &
"PARAMETER, AS A GENERIC ACTUAL PARAMETER, AND " &
"IN A MEMBERSHIP TEST, IN A SUBTYPE " &
"DECLARATION, IN AN ACCESS TYPE DEFINITION, " &
"AND IN A DERIVED TYPE DEFINITION");
DECLARE
TYPE REC (D : INTEGER := 3) IS RECORD
NULL;
END RECORD;
GENERIC
TYPE R (D : INTEGER) IS PRIVATE;
OBJ : R;
PACKAGE P IS
PROCEDURE S (X : R);
TASK T IS
ENTRY E (Y : R);
END T;
SUBTYPE SUB_R IS R;
TYPE ACC_R IS ACCESS R;
TYPE NEW_R IS NEW R;
BOOL : BOOLEAN := (OBJ IN R);
SUB_VAR : SUB_R(5);
ACC_VAR : ACC_R := NEW R(5);
NEW_VAR : NEW_R(5);
PACKAGE NEW_PACK IS NEW PACK (R);
END P;
REC_VAR : REC(5) := (D => 5);
PACKAGE BODY P IS
PROCEDURE S (X : R) IS
BEGIN
IF NOT EQUAL(X.D,5) THEN
FAILED ("WRONG DISCRIMINANT VALUE - S");
END IF;
END S;
TASK BODY T IS
BEGIN
ACCEPT E (Y : R) DO
IF NOT EQUAL(Y.D,5) THEN
FAILED ("WRONG DISCRIMINANT VALUE - T");
END IF;
END E;
END T;
BEGIN
IF NOT EQUAL(OBJ.D,5) THEN
FAILED ("IMPROPER DISCRIMINANT VALUE");
END IF;
S (OBJ);
T.E (OBJ);
IF NOT EQUAL(SUB_VAR.D,5) THEN
FAILED ("IMPROPER DISCRIMINANT VALUE - SUBTYPE");
END IF;
IF NOT EQUAL(ACC_VAR.D,5) THEN
FAILED ("IMPROPER DISCRIMINANT VALUE - ACCESS");
END IF;
IF NOT EQUAL(NEW_VAR.D,5) THEN
FAILED ("IMPROPER DISCRIMINANT VALUE - DERIVED");
END IF;
IF NOT BOOL THEN
FAILED ("IMPROPER RESULT FROM MEMBERSHIP TEST");
END IF;
END P;
PACKAGE NEW_P IS NEW P (REC,REC_VAR);
BEGIN
NULL;
END;
RESULT;
END CC1207B;
|
with
any_Math.any_Geometry;
package float_math.Geometry is new float_Math.any_Geometry;
pragma Pure (float_math.Geometry);
|
with Ada.Text_IO.Text_Streams;
with Ada.Command_Line;
with Resources.Help;
with Resources.Man;
with System.Storage_Elements;
procedure Show_Help is
use Ada.Text_IO;
use Resources;
use System.Storage_Elements;
procedure Print (Name : in String) is
C : access constant Storage_Array := Man.Get_Content (Name);
begin
if C = null then
C := Help.Get_Content (Name);
if C = null then
Ada.Text_IO.Put_Line ("FAIL: No help for '" & Name & "'");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
end if;
Storage_Array'Write (Text_Streams.Stream (Current_Output), C.all);
end Print;
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count = 0 then
Ada.Text_IO.Put_Line ("Help names:");
for Name of Help.Names loop
Ada.Text_IO.Put_Line (" " & Name.all);
end loop;
Ada.Text_IO.Put_Line ("Man pages:");
for Name of Man.Names loop
Ada.Text_IO.Put_Line (" " & Name.all);
end loop;
return;
end if;
for I in 1 .. Count loop
Print (Ada.Command_Line.Argument (I));
end loop;
end Show_Help;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Interfaces;
with Types;
package Database.Events is
package US renames Ada.Strings.Unbounded;
type Event_Kind is (Created, Startet, Stalled, Done,
Text, Deadline, Milestone);
type Event_Id is new Interfaces.Integer_64;
procedure Add_Event (Job : in Types.Job_Id;
Stamp : in Ada.Calendar.Time;
Kind : in Event_Kind;
Id : out Event_Id);
type Event_Info is
record
Stamp : US.Unbounded_String;
Kind : US.Unbounded_String;
end record;
package Event_Lists is
new Ada.Containers.Vectors (Positive, Event_Info);
function Get_Job_Events (Job : in Types.Job_Id)
return Event_Lists.Vector;
function Is_Done (Job : in Types.Job_Id) return Boolean;
-- Is last event in events for Job a DONE.
end Database.Events;
|
-- Implantation du module Ensembles.
package body Ensembles_Tableau is
procedure Initialiser (Ensemble : out T_Ensemble) is
begin
Ensemble.Taille := 0;
end Initialiser;
procedure Detruire (Ensemble : in out T_Ensemble) is
begin
Ensemble.Taille := 0;
end Detruire;
function Est_Vide (Ensemble : in T_Ensemble) return Boolean is
begin
return Ensemble.Taille = 0;
end Est_Vide;
function Taille (Ensemble : in T_Ensemble) return Integer is
begin
return Ensemble.Taille;
end Taille;
function Est_Present (Ensemble : in T_Ensemble; Element : in T_Element) return Boolean is
present : Boolean;
begin
present := False;
for i in 1..Taille (Ensemble) loop
if (Ensemble.Tab(i) = Element) then
present := True;
end if;
end loop;
return present;
end Est_Present;
procedure Ajouter (Ensemble : in out T_Ensemble; Element : in T_Element) is
begin
Ensemble.Taille := Ensemble.Taille + 1;
Ensemble.Tab(Ensemble.Taille) := Element;
end Ajouter;
procedure Supprimer (Ensemble : in out T_Ensemble; Element : in T_Element) is
i : Integer;
begin
i := 1;
while ( i <= Taille (Ensemble)) loop
if (Ensemble.Tab(i) = Element) Then
Ensemble.Tab(i) := Ensemble.Tab(Ensemble.Taille);
Ensemble.Taille := Ensemble.Taille - 1;
end if;
i := i + 1;
end loop;
end Supprimer;
procedure Appliquer_Sur_Tous (Ensemble : in T_Ensemble) is
begin
for i in 1..Ensemble.Taille loop
Operation (Ensemble.Tab (i));
end loop;
end Appliquer_Sur_Tous;
end Ensembles_Tableau;
|
-- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA
--
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification,
-- are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form, except as embedded into a Nordic
-- Semiconductor ASA integrated circuit in a product or a software update for
-- such product, must reproduce the above copyright notice, this list of
-- conditions and the following disclaimer in the documentation and/or other
-- materials provided with the distribution.
--
-- 3. Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 4. This software, with or without modification, must only be used with a
-- Nordic Semiconductor ASA integrated circuit.
--
-- 5. Any software provided in binary form under this license must not be reverse
-- engineered, decompiled, modified and/or disassembled.
--
-- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
-- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-- OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf52.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.PDM is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Enable or disable interrupt for STARTED event
type INTEN_STARTED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for STOPPED event
type INTEN_STOPPED_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for END event
type INTEN_END_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_END_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt
type INTEN_Register is record
-- Enable or disable interrupt for STARTED event
STARTED : INTEN_STARTED_Field := NRF_SVD.PDM.Disabled;
-- Enable or disable interrupt for STOPPED event
STOPPED : INTEN_STOPPED_Field := NRF_SVD.PDM.Disabled;
-- Enable or disable interrupt for END event
END_k : INTEN_END_Field := NRF_SVD.PDM.Disabled;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTEN_Register use record
STARTED at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
END_k at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Write '1' to Enable interrupt for STARTED event
type INTENSET_STARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for STARTED event
type INTENSET_STARTED_Field_1 is
(-- Reset value for the field
Intenset_Started_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_STARTED_Field_1 use
(Intenset_Started_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for STOPPED event
type INTENSET_STOPPED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for STOPPED event
type INTENSET_STOPPED_Field_1 is
(-- Reset value for the field
Intenset_Stopped_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_STOPPED_Field_1 use
(Intenset_Stopped_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for END event
type INTENSET_END_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_END_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for END event
type INTENSET_END_Field_1 is
(-- Reset value for the field
Intenset_End_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_END_Field_1 use
(Intenset_End_Field_Reset => 0,
Set => 1);
-- Enable interrupt
type INTENSET_Register is record
-- Write '1' to Enable interrupt for STARTED event
STARTED : INTENSET_STARTED_Field_1 :=
Intenset_Started_Field_Reset;
-- Write '1' to Enable interrupt for STOPPED event
STOPPED : INTENSET_STOPPED_Field_1 :=
Intenset_Stopped_Field_Reset;
-- Write '1' to Enable interrupt for END event
END_k : INTENSET_END_Field_1 := Intenset_End_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
STARTED at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
END_k at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Write '1' to Disable interrupt for STARTED event
type INTENCLR_STARTED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_STARTED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for STARTED event
type INTENCLR_STARTED_Field_1 is
(-- Reset value for the field
Intenclr_Started_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_STARTED_Field_1 use
(Intenclr_Started_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for STOPPED event
type INTENCLR_STOPPED_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_STOPPED_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for STOPPED event
type INTENCLR_STOPPED_Field_1 is
(-- Reset value for the field
Intenclr_Stopped_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_STOPPED_Field_1 use
(Intenclr_Stopped_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for END event
type INTENCLR_END_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_END_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for END event
type INTENCLR_END_Field_1 is
(-- Reset value for the field
Intenclr_End_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_END_Field_1 use
(Intenclr_End_Field_Reset => 0,
Clear => 1);
-- Disable interrupt
type INTENCLR_Register is record
-- Write '1' to Disable interrupt for STARTED event
STARTED : INTENCLR_STARTED_Field_1 :=
Intenclr_Started_Field_Reset;
-- Write '1' to Disable interrupt for STOPPED event
STOPPED : INTENCLR_STOPPED_Field_1 :=
Intenclr_Stopped_Field_Reset;
-- Write '1' to Disable interrupt for END event
END_k : INTENCLR_END_Field_1 := Intenclr_End_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
STARTED at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
END_k at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Enable or disable PDM module
type ENABLE_ENABLE_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 1);
-- PDM module enable register
type ENABLE_Register is record
-- Enable or disable PDM module
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.PDM.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Mono or stereo operation
type MODE_OPERATION_Field is
(-- Sample and store one pair (Left + Right) of 16bit samples per RAM word
-- R=[31:16]; L=[15:0]
Stereo,
-- Sample and store two successive Left samples (16 bit each) per RAM word
-- L1=[31:16]; L0=[15:0]
Mono)
with Size => 1;
for MODE_OPERATION_Field use
(Stereo => 0,
Mono => 1);
-- Defines on which PDM_CLK edge Left (or mono) is sampled
type MODE_EDGE_Field is
(-- Left (or mono) is sampled on falling edge of PDM_CLK
Leftfalling,
-- Left (or mono) is sampled on rising edge of PDM_CLK
Leftrising)
with Size => 1;
for MODE_EDGE_Field use
(Leftfalling => 0,
Leftrising => 1);
-- Defines the routing of the connected PDM microphones' signals
type MODE_Register is record
-- Mono or stereo operation
OPERATION : MODE_OPERATION_Field := NRF_SVD.PDM.Stereo;
-- Defines on which PDM_CLK edge Left (or mono) is sampled
EDGE : MODE_EDGE_Field := NRF_SVD.PDM.Leftfalling;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MODE_Register use record
OPERATION at 0 range 0 .. 0;
EDGE at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Left output gain adjustment, in 0.5 dB steps, around the default module
-- gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01 -19.5 dB
-- gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain adjust 0x29
-- +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50 +20 dB gain
-- adjust
type GAINL_GAINL_Field is
(-- -20dB gain adjustment (minimum)
Mingain,
-- 0dB gain adjustment ('2500 RMS' requirement)
Defaultgain,
-- +20dB gain adjustment (maximum)
Maxgain)
with Size => 7;
for GAINL_GAINL_Field use
(Mingain => 0,
Defaultgain => 40,
Maxgain => 80);
-- Left output gain adjustment
type GAINL_Register is record
-- Left output gain adjustment, in 0.5 dB steps, around the default
-- module gain (see electrical parameters) 0x00 -20 dB gain adjust 0x01
-- -19.5 dB gain adjust (...) 0x27 -0.5 dB gain adjust 0x28 0 dB gain
-- adjust 0x29 +0.5 dB gain adjust (...) 0x4F +19.5 dB gain adjust 0x50
-- +20 dB gain adjust
GAINL : GAINL_GAINL_Field := NRF_SVD.PDM.Defaultgain;
-- unspecified
Reserved_7_31 : HAL.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GAINL_Register use record
GAINL at 0 range 0 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
-- Right output gain adjustment, in 0.5 dB steps, around the default module
-- gain (see electrical parameters)
type GAINR_GAINR_Field is
(-- -20dB gain adjustment (minimum)
Mingain,
-- 0dB gain adjustment ('2500 RMS' requirement)
Defaultgain,
-- +20dB gain adjustment (maximum)
Maxgain)
with Size => 8;
for GAINR_GAINR_Field use
(Mingain => 0,
Defaultgain => 40,
Maxgain => 80);
-- Right output gain adjustment
type GAINR_Register is record
-- Right output gain adjustment, in 0.5 dB steps, around the default
-- module gain (see electrical parameters)
GAINR : GAINR_GAINR_Field := NRF_SVD.PDM.Defaultgain;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GAINR_Register use record
GAINR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------------------
-- PSEL cluster's Registers --
------------------------------
subtype CLK_PSEL_PIN_Field is HAL.UInt5;
-- Connection
type CLK_CONNECT_Field is
(-- Connect
Connected,
-- Disconnect
Disconnected)
with Size => 1;
for CLK_CONNECT_Field use
(Connected => 0,
Disconnected => 1);
-- Pin number configuration for PDM CLK signal
type CLK_PSEL_Register is record
-- Pin number
PIN : CLK_PSEL_PIN_Field := 16#1F#;
-- unspecified
Reserved_5_30 : HAL.UInt26 := 16#3FFFFFF#;
-- Connection
CONNECT : CLK_CONNECT_Field := NRF_SVD.PDM.Disconnected;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CLK_PSEL_Register use record
PIN at 0 range 0 .. 4;
Reserved_5_30 at 0 range 5 .. 30;
CONNECT at 0 range 31 .. 31;
end record;
subtype DIN_PSEL_PIN_Field is HAL.UInt5;
-- Connection
type DIN_CONNECT_Field is
(-- Connect
Connected,
-- Disconnect
Disconnected)
with Size => 1;
for DIN_CONNECT_Field use
(Connected => 0,
Disconnected => 1);
-- Pin number configuration for PDM DIN signal
type DIN_PSEL_Register is record
-- Pin number
PIN : DIN_PSEL_PIN_Field := 16#1F#;
-- unspecified
Reserved_5_30 : HAL.UInt26 := 16#3FFFFFF#;
-- Connection
CONNECT : DIN_CONNECT_Field := NRF_SVD.PDM.Disconnected;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DIN_PSEL_Register use record
PIN at 0 range 0 .. 4;
Reserved_5_30 at 0 range 5 .. 30;
CONNECT at 0 range 31 .. 31;
end record;
-- Unspecified
type PSEL_Cluster is record
-- Pin number configuration for PDM CLK signal
CLK : aliased CLK_PSEL_Register;
-- Pin number configuration for PDM DIN signal
DIN : aliased DIN_PSEL_Register;
end record
with Size => 64;
for PSEL_Cluster use record
CLK at 16#0# range 0 .. 31;
DIN at 16#4# range 0 .. 31;
end record;
--------------------------------
-- SAMPLE cluster's Registers --
--------------------------------
subtype MAXCNT_SAMPLE_BUFFSIZE_Field is HAL.UInt15;
-- Number of samples to allocate memory for in EasyDMA mode
type MAXCNT_SAMPLE_Register is record
-- Length of DMA RAM allocation in number of samples
BUFFSIZE : MAXCNT_SAMPLE_BUFFSIZE_Field := 16#0#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MAXCNT_SAMPLE_Register use record
BUFFSIZE at 0 range 0 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- Unspecified
type SAMPLE_Cluster is record
-- RAM address pointer to write samples to with EasyDMA
PTR : aliased HAL.UInt32;
-- Number of samples to allocate memory for in EasyDMA mode
MAXCNT : aliased MAXCNT_SAMPLE_Register;
end record
with Size => 64;
for SAMPLE_Cluster use record
PTR at 16#0# range 0 .. 31;
MAXCNT at 16#4# range 0 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Pulse Density Modulation (Digital Microphone) Interface
type PDM_Peripheral is record
-- Starts continuous PDM transfer
TASKS_START : aliased HAL.UInt32;
-- Stops PDM transfer
TASKS_STOP : aliased HAL.UInt32;
-- PDM transfer has started
EVENTS_STARTED : aliased HAL.UInt32;
-- PDM transfer has finished
EVENTS_STOPPED : aliased HAL.UInt32;
-- The PDM has written the last sample specified by SAMPLE.MAXCNT (or
-- the last sample after a STOP task has been received) to Data RAM
EVENTS_END : aliased HAL.UInt32;
-- Enable or disable interrupt
INTEN : aliased INTEN_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- PDM module enable register
ENABLE : aliased ENABLE_Register;
-- PDM clock generator control
PDMCLKCTRL : aliased HAL.UInt32;
-- Defines the routing of the connected PDM microphones' signals
MODE : aliased MODE_Register;
-- Left output gain adjustment
GAINL : aliased GAINL_Register;
-- Right output gain adjustment
GAINR : aliased GAINR_Register;
-- Unspecified
PSEL : aliased PSEL_Cluster;
-- Unspecified
SAMPLE : aliased SAMPLE_Cluster;
end record
with Volatile;
for PDM_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#4# range 0 .. 31;
EVENTS_STARTED at 16#100# range 0 .. 31;
EVENTS_STOPPED at 16#104# range 0 .. 31;
EVENTS_END at 16#108# range 0 .. 31;
INTEN at 16#300# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
PDMCLKCTRL at 16#504# range 0 .. 31;
MODE at 16#508# range 0 .. 31;
GAINL at 16#518# range 0 .. 31;
GAINR at 16#51C# range 0 .. 31;
PSEL at 16#540# range 0 .. 63;
SAMPLE at 16#560# range 0 .. 63;
end record;
-- Pulse Density Modulation (Digital Microphone) Interface
PDM_Periph : aliased PDM_Peripheral
with Import, Address => PDM_Base;
end NRF_SVD.PDM;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
with Regions.Symbols;
package Regions.Contexts is
pragma Preelaborate;
type Context is tagged limited private;
type Entity_Name is private;
type Selected_Entity_Name is private;
type Profile_Id is private;
-----------------------
-- Profile creation --
-----------------------
function Empty_Procedure_Profile (Self : Context) return Profile_Id;
-- Return profile for a procedure without arguments
procedure Empty_Function_Profile
(Self : in out Context;
Return_Type : Selected_Entity_Name;
Result : out Profile_Id);
-- Return profile for a function without arguments returning a given type
procedure Empty_Function_Profile
(Self : in out Context;
Return_Profile : Profile_Id;
Result : out Profile_Id);
-- Return profile for a function without arguments returning an access
-- to subprogram
procedure Append_Parameter
(Self : in out Context;
Origin : Profile_Id;
Type_Name : Selected_Entity_Name;
-- Mode|Access???
Result : out Profile_Id);
procedure Append_Parameter
(Self : in out Context;
Origin : Profile_Id;
Subprogram : Profile_Id;
Result : out Profile_Id);
---------------------------
-- Entity_Name creation --
---------------------------
procedure New_Entity_Name
(Self : in out Context;
Symbol : Regions.Symbols.Symbol;
Result : out Entity_Name);
procedure New_Entity_Name
(Self : in out Context;
Symbol : Regions.Symbols.Symbol;
Profile : Profile_Id;
Result : out Entity_Name);
------------------------------------
-- Selected_Entity_Name creation --
------------------------------------
function Root_Name (Self : Context) return Selected_Entity_Name;
-- Return Name of Standard's parent region
procedure New_Selected_Name
(Self : in out Context;
Prefix : Selected_Entity_Name;
Selector : Entity_Name;
Result : out Selected_Entity_Name);
private
type Profile_Id is new Natural;
type Entity_Name is new Natural;
type Selected_Entity_Name is new Natural;
No_Profile : constant Profile_Id := 0;
-- To create an entity name without any profile
type Profile_Kind is
(Root_Data,
Root_Code,
Parameter_Data,
Parameter_Code);
type Profile_Key (Kind : Profile_Kind := Profile_Kind'First) is record
case Kind is
when Root_Data =>
Root_Data : Selected_Entity_Name;
when Root_Code =>
Root_Code : Profile_Id;
when Parameter_Data | Parameter_Code =>
Parent : Profile_Id;
case Kind is
when Regions.Contexts.Root_Data |
Regions.Contexts.Root_Code =>
null;
when Parameter_Data =>
Parameter_Data : Selected_Entity_Name;
when Parameter_Code =>
Parameter_Code : Profile_Id;
end case;
end case;
end record;
function Hash (Value : Profile_Key) return Ada.Containers.Hash_Type;
package Profile_Maps is new Ada.Containers.Hashed_Maps
(Profile_Key,
Profile_Id,
Hash,
"=");
type Entity_Name_Key is record
Symbol : Regions.Symbols.Symbol;
Profile : Profile_Id;
end record;
function Hash (Value : Entity_Name_Key) return Ada.Containers.Hash_Type;
package Entity_Name_Maps is new Ada.Containers.Hashed_Maps
(Entity_Name_Key,
Entity_Name,
Hash,
"=");
type Selected_Entity_Name_Key is record
Prefix : Selected_Entity_Name;
Selector : Entity_Name;
end record;
function Hash (Value : Selected_Entity_Name_Key)
return Ada.Containers.Hash_Type;
package Selected_Entity_Name_Maps is new Ada.Containers.Hashed_Maps
(Selected_Entity_Name_Key,
Selected_Entity_Name,
Hash,
"=");
type Change_Count is mod 2**32;
type Context is tagged limited record
Profiles : Profile_Maps.Map;
Names : Entity_Name_Maps.Map;
Selected : Selected_Entity_Name_Maps.Map;
Version : aliased Change_Count := 0;
Last_Name : Entity_Name := 0;
Last_Selected : Selected_Entity_Name := 0;
Last_Profile : Profile_Id := 1; -- Reserve Empty_Procedure_Profile
end record;
end Regions.Contexts;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S I N P U T . L --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Alloc;
with Atree; use Atree;
with Debug; use Debug;
with Einfo; use Einfo;
with Namet; use Namet;
with Opt;
with Osint; use Osint;
with Output; use Output;
with Scans; use Scans;
with Scn; use Scn;
with Sinfo; use Sinfo;
with System; use System;
with Unchecked_Conversion;
package body Sinput.L is
Dfile : Source_File_Index;
-- Index of currently active debug source file
-----------------
-- Subprograms --
-----------------
procedure Trim_Lines_Table (S : Source_File_Index);
-- Set lines table size for entry S in the source file table to
-- correspond to the current value of Num_Source_Lines, releasing
-- any unused storage.
function Load_File
(N : File_Name_Type;
T : File_Type)
return Source_File_Index;
-- Load a source file or a configuration pragma file.
-------------------------------
-- Adjust_Instantiation_Sloc --
-------------------------------
procedure Adjust_Instantiation_Sloc (N : Node_Id; A : Sloc_Adjustment) is
Loc : constant Source_Ptr := Sloc (N);
begin
-- We only do the adjustment if the value is between the appropriate
-- low and high values. It is not clear that this should ever not be
-- the case, but in practice there seem to be some nodes that get
-- copied twice, and this is a defence against that happening.
if A.Lo <= Loc and then Loc <= A.Hi then
Set_Sloc (N, Loc + A.Adjust);
end if;
end Adjust_Instantiation_Sloc;
------------------------
-- Close_Debug_Source --
------------------------
procedure Close_Debug_Source is
S : Source_File_Record renames Source_File.Table (Dfile);
Src : Source_Buffer_Ptr;
begin
Trim_Lines_Table (Dfile);
Close_Debug_File;
-- Now we need to read the file that we wrote and store it
-- in memory for subsequent access.
Read_Source_File
(S.Debug_Source_Name, S.Source_First, S.Source_Last, Src);
S.Source_Text := Src;
end Close_Debug_Source;
--------------------------------
-- Complete_Source_File_Entry --
--------------------------------
procedure Complete_Source_File_Entry is
CSF : constant Source_File_Index := Current_Source_File;
begin
Trim_Lines_Table (CSF);
Source_File.Table (CSF).Source_Checksum := Checksum;
end Complete_Source_File_Entry;
-------------------------
-- Create_Debug_Source --
-------------------------
procedure Create_Debug_Source
(Source : Source_File_Index;
Loc : out Source_Ptr)
is
begin
Loc := Source_File.Table (Source_File.Last).Source_Last + 1;
Source_File.Increment_Last;
Dfile := Source_File.Last;
declare
S : Source_File_Record renames Source_File.Table (Dfile);
begin
S := Source_File.Table (Source);
S.Debug_Source_Name := Create_Debug_File (S.File_Name);
S.Source_First := Loc;
S.Source_Last := Loc;
S.Lines_Table := null;
S.Last_Source_Line := 1;
-- Allocate lines table, guess that it needs to be three times
-- bigger than the original source (in number of lines).
Alloc_Line_Tables
(S, Int (Source_File.Table (Source).Last_Source_Line * 3));
S.Lines_Table (1) := Loc;
end;
if Debug_Flag_GG then
Write_Str ("---> Create_Debug_Source (Source => ");
Write_Int (Int (Source));
Write_Str (", Loc => ");
Write_Int (Int (Loc));
Write_Str (");");
Write_Eol;
end if;
end Create_Debug_Source;
---------------------------------
-- Create_Instantiation_Source --
---------------------------------
procedure Create_Instantiation_Source
(Inst_Node : Entity_Id;
Template_Id : Entity_Id;
A : out Sloc_Adjustment)
is
Dnod : constant Node_Id := Declaration_Node (Template_Id);
Xold : Source_File_Index;
Xnew : Source_File_Index;
begin
Xold := Get_Source_File_Index (Sloc (Template_Id));
A.Lo := Source_File.Table (Xold).Source_First;
A.Hi := Source_File.Table (Xold).Source_Last;
Source_File.Increment_Last;
Xnew := Source_File.Last;
Source_File.Table (Xnew) := Source_File.Table (Xold);
Source_File.Table (Xnew).Instantiation := Sloc (Inst_Node);
Source_File.Table (Xnew).Template := Xold;
-- Now we need to compute the new values of Source_First, Source_Last
-- and adjust the source file pointer to have the correct virtual
-- origin for the new range of values.
Source_File.Table (Xnew).Source_First :=
Source_File.Table (Xnew - 1).Source_Last + 1;
A.Adjust := Source_File.Table (Xnew).Source_First - A.Lo;
Source_File.Table (Xnew).Source_Last := A.Hi + A.Adjust;
Source_File.Table (Xnew).Sloc_Adjust :=
Source_File.Table (Xold).Sloc_Adjust - A.Adjust;
if Debug_Flag_L then
Write_Eol;
Write_Str ("*** Create instantiation source for ");
if Nkind (Dnod) in N_Proper_Body
and then Was_Originally_Stub (Dnod)
then
Write_Str ("subunit ");
elsif Ekind (Template_Id) = E_Generic_Package then
if Nkind (Dnod) = N_Package_Body then
Write_Str ("body of package ");
else
Write_Str ("spec of package ");
end if;
elsif Ekind (Template_Id) = E_Function then
Write_Str ("body of function ");
elsif Ekind (Template_Id) = E_Procedure then
Write_Str ("body of procedure ");
elsif Ekind (Template_Id) = E_Generic_Function then
Write_Str ("spec of function ");
elsif Ekind (Template_Id) = E_Generic_Procedure then
Write_Str ("spec of procedure ");
elsif Ekind (Template_Id) = E_Package_Body then
Write_Str ("body of package ");
else pragma Assert (Ekind (Template_Id) = E_Subprogram_Body);
if Nkind (Dnod) = N_Procedure_Specification then
Write_Str ("body of procedure ");
else
Write_Str ("body of function ");
end if;
end if;
Write_Name (Chars (Template_Id));
Write_Eol;
Write_Str (" new source index = ");
Write_Int (Int (Xnew));
Write_Eol;
Write_Str (" copying from file name = ");
Write_Name (File_Name (Xold));
Write_Eol;
Write_Str (" old source index = ");
Write_Int (Int (Xold));
Write_Eol;
Write_Str (" old lo = ");
Write_Int (Int (A.Lo));
Write_Eol;
Write_Str (" old hi = ");
Write_Int (Int (A.Hi));
Write_Eol;
Write_Str (" new lo = ");
Write_Int (Int (Source_File.Table (Xnew).Source_First));
Write_Eol;
Write_Str (" new hi = ");
Write_Int (Int (Source_File.Table (Xnew).Source_Last));
Write_Eol;
Write_Str (" adjustment factor = ");
Write_Int (Int (A.Adjust));
Write_Eol;
Write_Str (" instantiation location: ");
Write_Location (Sloc (Inst_Node));
Write_Eol;
end if;
-- For a given character in the source, a higher subscript will be
-- used to access the instantiation, which means that the virtual
-- origin must have a corresponding lower value. We compute this
-- new origin by taking the address of the appropriate adjusted
-- element in the old array. Since this adjusted element will be
-- at a negative subscript, we must suppress checks.
declare
pragma Suppress (All_Checks);
function To_Source_Buffer_Ptr is new
Unchecked_Conversion (Address, Source_Buffer_Ptr);
begin
Source_File.Table (Xnew).Source_Text :=
To_Source_Buffer_Ptr
(Source_File.Table (Xold).Source_Text (-A.Adjust)'Address);
end;
end Create_Instantiation_Source;
----------------------
-- Load_Config_File --
----------------------
function Load_Config_File
(N : File_Name_Type)
return Source_File_Index
is
begin
return Load_File (N, Osint.Config);
end Load_Config_File;
---------------
-- Load_File --
---------------
function Load_File
(N : File_Name_Type;
T : File_Type)
return Source_File_Index
is
Src : Source_Buffer_Ptr;
X : Source_File_Index;
Lo : Source_Ptr;
Hi : Source_Ptr;
begin
for J in 1 .. Source_File.Last loop
if Source_File.Table (J).File_Name = N then
return J;
end if;
end loop;
-- Here we must build a new entry in the file table
Source_File.Increment_Last;
X := Source_File.Last;
if X = Source_File.First then
Lo := First_Source_Ptr;
else
Lo := Source_File.Table (X - 1).Source_Last + 1;
end if;
Read_Source_File (N, Lo, Hi, Src, T);
if Src = null then
Source_File.Decrement_Last;
return No_Source_File;
else
if Debug_Flag_L then
Write_Eol;
Write_Str ("*** Build source file table entry, Index = ");
Write_Int (Int (X));
Write_Str (", file name = ");
Write_Name (N);
Write_Eol;
Write_Str (" lo = ");
Write_Int (Int (Lo));
Write_Eol;
Write_Str (" hi = ");
Write_Int (Int (Hi));
Write_Eol;
Write_Str (" first 10 chars -->");
declare
procedure Wchar (C : Character);
-- Writes character or ? for control character
procedure Wchar (C : Character) is
begin
if C < ' ' or C in ASCII.DEL .. Character'Val (16#9F#) then
Write_Char ('?');
else
Write_Char (C);
end if;
end Wchar;
begin
for J in Lo .. Lo + 9 loop
Wchar (Src (J));
end loop;
Write_Str ("<--");
Write_Eol;
Write_Str (" last 10 chars -->");
for J in Hi - 10 .. Hi - 1 loop
Wchar (Src (J));
end loop;
Write_Str ("<--");
Write_Eol;
if Src (Hi) /= EOF then
Write_Str (" error: no EOF at end");
Write_Eol;
end if;
end;
end if;
declare
S : Source_File_Record renames Source_File.Table (X);
begin
S := (Debug_Source_Name => Full_Source_Name,
File_Name => N,
First_Mapped_Line => No_Line_Number,
Full_File_Name => Full_Source_Name,
Full_Ref_Name => Full_Source_Name,
Identifier_Casing => Unknown,
Instantiation => No_Location,
Keyword_Casing => Unknown,
Last_Source_Line => 1,
License => Unknown,
Lines_Table => null,
Lines_Table_Max => 1,
Logical_Lines_Table => null,
Num_SRef_Pragmas => 0,
Reference_Name => N,
Sloc_Adjust => 0,
Source_Checksum => 0,
Source_First => Lo,
Source_Last => Hi,
Source_Text => Src,
Template => No_Source_File,
Time_Stamp => Current_Source_File_Stamp);
Alloc_Line_Tables (S, Opt.Table_Factor * Alloc.Lines_Initial);
S.Lines_Table (1) := Lo;
end;
return X;
end if;
end Load_File;
----------------------
-- Load_Source_File --
----------------------
function Load_Source_File
(N : File_Name_Type)
return Source_File_Index
is
begin
return Load_File (N, Osint.Source);
end Load_Source_File;
----------------------------
-- Source_File_Is_Subunit --
----------------------------
function Source_File_Is_Subunit (X : Source_File_Index) return Boolean is
begin
Initialize_Scanner (No_Unit, X);
-- We scan past junk to the first interesting compilation unit
-- token, to see if it is SEPARATE. We ignore WITH keywords during
-- this and also PRIVATE. The reason for ignoring PRIVATE is that
-- it handles some error situations, and also it is possible that
-- a PRIVATE WITH feature might be approved some time in the future.
while Token = Tok_With
or else Token = Tok_Private
or else (Token not in Token_Class_Cunit and then Token /= Tok_EOF)
loop
Scan;
end loop;
return Token = Tok_Separate;
end Source_File_Is_Subunit;
----------------------
-- Trim_Lines_Table --
----------------------
procedure Trim_Lines_Table (S : Source_File_Index) is
function realloc
(P : Lines_Table_Ptr;
New_Size : Int)
return Lines_Table_Ptr;
pragma Import (C, realloc);
Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line);
begin
-- Release allocated storage that is no longer needed
Source_File.Table (S).Lines_Table :=
realloc
(Source_File.Table (S).Lines_Table,
Max * (Lines_Table_Type'Component_Size / System.Storage_Unit));
Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max);
end Trim_Lines_Table;
----------------------
-- Write_Debug_Line --
----------------------
procedure Write_Debug_Line (Str : String; Loc : in out Source_Ptr) is
S : Source_File_Record renames Source_File.Table (Dfile);
begin
-- Ignore write request if null line at start of file
if Str'Length = 0 and then Loc = S.Source_First then
return;
-- Here we write the line, and update the source record entry
else
Write_Debug_Info (Str);
Add_Line_Tables_Entry (S, Loc);
Loc := Loc + Source_Ptr (Str'Length + Debug_File_Eol_Length);
S.Source_Last := Loc;
if Debug_Flag_GG then
declare
Lin : constant String := Str;
begin
Column := 1;
Write_Str ("---> Write_Debug_Line (Str => """);
Write_Str (Lin);
Write_Str (""", Loc => ");
Write_Int (Int (Loc));
Write_Str (");");
Write_Eol;
end;
end if;
end if;
end Write_Debug_Line;
end Sinput.L;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> --
-- 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.SAX.Writers;
with Web_Services.SOAP.Payloads.Faults.Encoders.Registry;
package body Web_Services.SOAP.Payloads.Faults.Simple is
type Simple_Fault_Encoder is
limited new Web_Services.SOAP.Payloads.Faults.Encoders.SOAP_Fault_Encoder
with null record;
overriding function Create
(Dummy : not null access Boolean) return Simple_Fault_Encoder;
overriding procedure Encode
(Self : Simple_Fault_Encoder;
Message : Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class;
Writer : in out XML.SAX.Writers.SAX_Writer'Class);
------------
-- Create --
------------
overriding function Create
(Dummy : not null access Boolean) return Simple_Fault_Encoder
is
pragma Unreferenced (Dummy);
begin
return Result : Simple_Fault_Encoder;
end Create;
----------------------------------
-- Create_Must_Understand_Fault --
----------------------------------
function Create_Must_Understand_Fault
(Reason_Language : League.Strings.Universal_String;
Reason_Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String)
return Web_Services.SOAP.Payloads.SOAP_Payload_Access is
begin
return Result : constant Web_Services.SOAP.Payloads.SOAP_Payload_Access
:= new Simple_Must_Understand_Fault
do
declare
Self : Simple_Must_Understand_Fault
renames Simple_Must_Understand_Fault (Result.all);
Reason : Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Map;
begin
Reason.Insert (Reason_Language, Reason_Text);
Web_Services.SOAP.Payloads.Faults.Initialize
(Self,
Web_Services.SOAP.Payloads.Faults.Code_Vectors.Empty_Vector,
Reason);
Self.Detail := Detail;
end;
end return;
end Create_Must_Understand_Fault;
-------------------------
-- Create_Sender_Fault --
-------------------------
function Create_Sender_Fault
(Subcode_Namespace_URI : League.Strings.Universal_String;
Subcode_Local_Name : League.Strings.Universal_String;
Subcode_Prexif : League.Strings.Universal_String;
Reason_Language : League.Strings.Universal_String;
Reason_Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String)
return Web_Services.SOAP.Payloads.SOAP_Payload_Access is
begin
return Result : constant Web_Services.SOAP.Payloads.SOAP_Payload_Access
:= new Simple_Sender_Fault
do
declare
Self : Simple_Sender_Fault
renames Simple_Sender_Fault (Result.all);
Codes : Web_Services.SOAP.Payloads.Faults.Code_Vectors.Vector;
Reason : Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Map;
begin
Codes.Append
((Subcode_Namespace_URI, Subcode_Local_Name, Subcode_Prexif));
Reason.Insert (Reason_Language, Reason_Text);
Web_Services.SOAP.Payloads.Faults.Initialize (Self, Codes, Reason);
Self.Detail := Detail;
end;
end return;
end Create_Sender_Fault;
-------------------------
-- Create_Sender_Fault --
-------------------------
function Create_Sender_Fault
(Reason_Language : League.Strings.Universal_String;
Reason_Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String)
return Web_Services.SOAP.Payloads.SOAP_Payload_Access is
begin
return Result : constant Web_Services.SOAP.Payloads.SOAP_Payload_Access
:= new Simple_Sender_Fault
do
declare
Self : Simple_Sender_Fault
renames Simple_Sender_Fault (Result.all);
Reason : Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Map;
begin
Reason.Insert (Reason_Language, Reason_Text);
Web_Services.SOAP.Payloads.Faults.Initialize
(Self,
Web_Services.SOAP.Payloads.Faults.Code_Vectors.Empty_Vector,
Reason);
Self.Detail := Detail;
end;
end return;
end Create_Sender_Fault;
-----------------------------------
-- Create_Version_Mismatch_Fault --
-----------------------------------
function Create_Version_Mismatch_Fault
(Reason_Language : League.Strings.Universal_String;
Reason_Text : League.Strings.Universal_String;
Detail : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String)
return Web_Services.SOAP.Payloads.SOAP_Payload_Access is
begin
return Result : constant Web_Services.SOAP.Payloads.SOAP_Payload_Access
:= new Simple_Version_Mismatch_Fault
do
declare
Self : Simple_Version_Mismatch_Fault
renames Simple_Version_Mismatch_Fault (Result.all);
Reason : Web_Services.SOAP.Payloads.Faults.Language_Text_Maps.Map;
begin
Reason.Insert (Reason_Language, Reason_Text);
Web_Services.SOAP.Payloads.Faults.Initialize
(Self,
Web_Services.SOAP.Payloads.Faults.Code_Vectors.Empty_Vector,
Reason);
Self.Detail := Detail;
end;
end return;
end Create_Version_Mismatch_Fault;
------------
-- Encode --
------------
overriding procedure Encode
(Self : Simple_Fault_Encoder;
Message : Web_Services.SOAP.Payloads.Faults.Abstract_SOAP_Fault'Class;
Writer : in out XML.SAX.Writers.SAX_Writer'Class)
is
pragma Unreferenced (Self);
Detail : League.Strings.Universal_String;
begin
if Message in Simple_Must_Understand_Fault'Class then
Detail := Simple_Must_Understand_Fault (Message).Detail;
elsif Message in Simple_Version_Mismatch_Fault'Class then
Detail := Simple_Version_Mismatch_Fault (Message).Detail;
elsif Message in Simple_Sender_Fault'Class then
Detail := Simple_Sender_Fault (Message).Detail;
else
raise Program_Error;
-- Must never be happen.
end if;
if not Detail.Is_Empty then
Writer.Characters (Detail);
end if;
end Encode;
----------------
-- Has_Detail --
----------------
overriding function Has_Detail
(Self : Simple_Must_Understand_Fault) return Boolean is
begin
return not Self.Detail.Is_Empty;
end Has_Detail;
----------------
-- Has_Detail --
----------------
overriding function Has_Detail
(Self : Simple_Version_Mismatch_Fault) return Boolean is
begin
return not Self.Detail.Is_Empty;
end Has_Detail;
----------------
-- Has_Detail --
----------------
overriding function Has_Detail
(Self : Simple_Sender_Fault) return Boolean is
begin
return not Self.Detail.Is_Empty;
end Has_Detail;
begin
Web_Services.SOAP.Payloads.Faults.Encoders.Registry.Register
(Simple_Must_Understand_Fault'Tag, Simple_Fault_Encoder'Tag);
Web_Services.SOAP.Payloads.Faults.Encoders.Registry.Register
(Simple_Version_Mismatch_Fault'Tag, Simple_Fault_Encoder'Tag);
Web_Services.SOAP.Payloads.Faults.Encoders.Registry.Register
(Simple_Sender_Fault'Tag, Simple_Fault_Encoder'Tag);
end Web_Services.SOAP.Payloads.Faults.Simple;
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Game.SaveLoad.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
-- begin read only
-- end read only
package body Game.SaveLoad.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
procedure Wrap_Test_Generate_Save_Name_3f9630_a0a8d0
(Rename_Save: Boolean := False) is
Gnattest_1_Save_Name: constant Unbounded_String := Save_Name;
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(game-saveload.ads:0):Test_GenerateSave_Name test requirement violated");
end;
GNATtest_Generated.GNATtest_Standard.Game.SaveLoad.Generate_Save_Name
(Rename_Save);
begin
pragma Assert(Save_Name /= Gnattest_1_Save_Name);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(game-saveload.ads:0:):Test_GenerateSave_Name test commitment violated");
end;
end Wrap_Test_Generate_Save_Name_3f9630_a0a8d0;
-- end read only
-- begin read only
procedure Test_Generate_Save_Name_test_generatesave_name
(Gnattest_T: in out Test);
procedure Test_Generate_Save_Name_3f9630_a0a8d0
(Gnattest_T: in out Test) renames
Test_Generate_Save_Name_test_generatesave_name;
-- id:2.2/3f9630bf78865443/Generate_Save_Name/1/0/test_generatesave_name/
procedure Test_Generate_Save_Name_test_generatesave_name
(Gnattest_T: in out Test) is
procedure Generate_Save_Name(Rename_Save: Boolean := False) renames
Wrap_Test_Generate_Save_Name_3f9630_a0a8d0;
-- end read only
pragma Unreferenced(Gnattest_T);
Old_Save_Name: constant Unbounded_String := Save_Name;
begin
Generate_Save_Name;
Assert
(Old_Save_Name /= Save_Name,
"Failed to generate new save name (Old_Save_Name = '" &
To_String(Old_Save_Name) & "', Save_Name = '" & To_String(Save_Name) &
"').");
-- begin read only
end Test_Generate_Save_Name_test_generatesave_name;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Game.SaveLoad.Test_Data.Tests;
|
---------------------------------
-- GID - Generic Image Decoder --
---------------------------------
--
-- Private child of GID, with helpers for identifying
-- image formats and reading header informations.
--
private package GID.Headers is
--
-- Crude image signature detection
--
procedure Load_signature (
image : in out Image_descriptor;
try_tga : Boolean:= False
);
--
-- Loading of various format's headers (past signature)
--
procedure Load_BMP_header (image: in out Image_descriptor);
procedure Load_FITS_header (image: in out Image_descriptor);
procedure Load_GIF_header (image: in out Image_descriptor);
procedure Load_JPEG_header (image: in out Image_descriptor);
procedure Load_PNG_header (image: in out Image_descriptor);
procedure Load_PNM_header (image: in out Image_descriptor);
procedure Load_TGA_header (image: in out Image_descriptor);
procedure Load_TIFF_header (image: in out Image_descriptor);
end GID.Headers;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ W A R N --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2020, 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 used to deal with issuing warnings
-- about uses of uninitialized variables and unused with's. It also has
-- some unrelated routines related to the generation of warnings.
with Alloc;
with Table;
with Types; use Types;
package Sem_Warn is
------------------------
-- Warnings Off Table --
------------------------
type Warnings_Off_Entry is record
N : Node_Id;
-- A pragma Warnings (Off, ent [,Reason]) node
E : Entity_Id;
-- The entity involved
R : String_Id;
-- Warning reason if present, or null if not (not currently used)
end record;
-- An entry is made in the following table for any valid Pragma Warnings
-- (Off, entity) encountered while Opt.Warn_On_Warnings_Off is True. It
-- is used to generate warnings on any of these pragmas that turn out not
-- to be needed, or that could be replaced by Unmodified/Unreferenced.
package Warnings_Off_Pragmas is new Table.Table (
Table_Component_Type => Warnings_Off_Entry,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => Alloc.Warnings_Off_Pragmas_Initial,
Table_Increment => Alloc.Warnings_Off_Pragmas_Increment,
Table_Name => "Name_Warnings_Off_Pragmas");
--------------------
-- Initialization --
--------------------
procedure Initialize;
-- Initialize this package for new compilation
------------------------------------------
-- Routines to Handle Unused References --
------------------------------------------
procedure Check_References (E : Entity_Id; Anod : Node_Id := Empty);
-- Called at the end of processing a declarative region. The entity E
-- is the entity for the scope. All entities declared in the region,
-- as indicated by First_Entity and the entity chain, are checked to
-- see if they are variables for which warnings need to be posted for
-- either no assignments, or a use before an assignment or no references
-- at all. The Anod node is present for the case of an accept statement,
-- and references the accept statement. This is used to place the warning
-- messages in the right place.
procedure Check_Unset_Reference (N : Node_Id);
-- N is the node for an expression which occurs in a reference position,
-- e.g. as the right side of an assignment. This procedure checks to see
-- if the node is a reference to a variable entity where the entity has
-- Not_Assigned set. If so, the Unset_Reference field is set if it is not
-- the first occurrence. No warning is posted, instead warnings will be
-- posted later by Check_References. The reason we do things that
-- way is that if there are no assignments anywhere, we prefer to flag
-- the entity, rather than a reference to it. Note that for the purposes
-- of this routine, a type conversion or qualified expression whose
-- expression is an entity is also processed. The reason that we do not
-- process these at the point of occurrence is that both these constructs
-- can occur in non-reference positions (e.g. as out parameters).
procedure Check_Unused_Withs (Spec_Unit : Unit_Number_Type := No_Unit);
-- This routine performs two kinds of checks. It checks that all with'ed
-- units are referenced, and that at least one entity of each with'ed
-- unit is referenced (the latter check catches units that are only
-- referenced in a use or package renaming statement). Appropriate
-- warning messages are generated if either of these situations is
-- detected.
--
-- A special case arises when a package body or a subprogram body with
-- a separate spec is being compiled. In this case, a with may appear
-- on the spec, but be needed only by the body. This still generates
-- a warning, but the text is different (the with is not redundant,
-- it is misplaced).
--
-- This special case is implemented by making an initial call to this
-- procedure with Spec_Unit set to the unit number of the separate spec.
-- This call does not generate any warning messages, but instead may
-- result in flags being set in the N_With_Clause node that record that
-- there was no use in the spec.
--
-- The main call (made after all units have been analyzed, with Spec_Unit
-- set to the default value of No_Unit) generates the required warnings
-- using the flags set by the initial call where appropriate to specialize
-- the text of the warning messages.
---------------------
-- Output Routines --
---------------------
procedure Output_Non_Modified_In_Out_Warnings;
-- Warnings about IN OUT parameters that could be IN are collected till
-- the end of the compilation process (see body of this routine for a
-- discussion of why this is done). This procedure outputs the warnings.
-- Note: this should be called before Output_Unreferenced_Messages, since
-- if we have an IN OUT warning, that's the one we want to see.
procedure Output_Obsolescent_Entity_Warnings (N : Node_Id; E : Entity_Id);
-- N is a reference to obsolescent entity E, for which appropriate warning
-- messages are to be generated (caller has already checked that warnings
-- are active and appropriate for this entity).
procedure Output_Unreferenced_Messages;
-- Warnings about unreferenced entities are collected till the end of
-- the compilation process (see Check_Unset_Reference for further
-- details). This procedure outputs waiting warnings, if any.
procedure Output_Unused_Warnings_Off_Warnings;
-- Warnings about pragma Warnings (Off, ent) statements that are unused,
-- or could be replaced by Unmodified/Unreferenced pragmas, are collected
-- till the end of the compilation process. This procedure outputs waiting
-- warnings if any.
----------------------------
-- Other Warning Routines --
----------------------------
procedure Check_Code_Statement (N : Node_Id);
-- Perform warning checks on a code statement node
procedure Check_Infinite_Loop_Warning (Loop_Statement : Node_Id);
-- N is the node for a loop statement. This procedure checks if a warning
-- for a possible infinite loop should be given for a suspicious WHILE or
-- EXIT WHEN condition.
procedure Check_Low_Bound_Tested (Expr : Node_Id);
-- Expr is the node for a comparison operation. This procedure checks if
-- the comparison is a source comparison of P'First with some other value
-- and if so, sets the Low_Bound_Tested flag on entity P to suppress
-- warnings about improper low bound assumptions (we assume that if the
-- code has a test that explicitly checks P'First, then it is not operating
-- in blind assumption mode).
procedure Warn_On_Constant_Valid_Condition (Op : Node_Id);
-- Determine the outcome of evaluating conditional or relational operator
-- Op assuming that its scalar operands are valid. Emit a warning when the
-- result of the evaluation is True or False.
procedure Warn_On_Known_Condition (C : Node_Id);
-- C is a node for a boolean expression resulting from a relational
-- or membership operation. If the expression has a compile time known
-- value, then a warning is output if all the following conditions hold:
--
-- 1. Original expression comes from source. We don't want to generate
-- warnings for internally generated conditionals.
--
-- 2. As noted above, the expression is a relational or membership
-- test, we don't want to generate warnings for boolean variables
-- since this is typical of conditional compilation in Ada.
--
-- 3. The expression appears in a statement, rather than a declaration.
-- In practice, most occurrences in declarations are legitimate
-- conditionalizations, but occurrences in statements are often
-- errors for which the warning is useful.
--
-- 4. The expression does not occur within an instantiation. A non-
-- static expression in a generic may become constant because of
-- the attributes of the actuals, and we do not want to warn on
-- these legitimate constant foldings.
--
-- If all these conditions are met, the warning is issued noting that
-- the result of the test is always false or always true as appropriate.
function Warn_On_Modified_As_Out_Parameter (E : Entity_Id) return Boolean;
-- Returns True if we should activate warnings for entity E being modified
-- as an out parameter. True if either Warn_On_Modified_Unread is set for
-- an only OUT parameter, or if Warn_On_All_Unread_Out_Parameters is set.
procedure Warn_On_Overlapping_Actuals (Subp : Entity_Id; N : Node_Id);
-- Called on a subprogram call. Checks whether an IN OUT actual that is
-- not by-copy may overlap with another actual, thus leading to aliasing
-- in the body of the called subprogram. This is indeed a warning in Ada
-- versions prior to Ada 2012, but, unless Opt.Error_To_Warning is set by
-- use of debug flag -gnatd.E, this is illegal and generates an error.
procedure Warn_On_Suspicious_Index (Name : Entity_Id; X : Node_Id);
-- This is called after resolving an indexed component or a slice. Name
-- is the entity for the name of the indexed array, and X is the subscript
-- for the indexed component case, or one of the bounds in the slice case.
-- If Name is an unconstrained parameter of a standard string type, and
-- the index is of the form of a literal or Name'Length [- literal], then
-- a warning is generated that the subscripting operation is possibly
-- incorrectly assuming a lower bound of 1.
procedure Warn_On_Suspicious_Update (N : Node_Id);
-- N is a semantically analyzed attribute reference Prefix'Update. Issue
-- a warning if Warn_On_Suspicious_Contract is set, and N is the left-hand
-- side or right-hand side of an equality or inequality of the form:
-- Prefix = Prefix'Update(...)
-- or
-- Prefix'Update(...) = Prefix
procedure Warn_On_Unassigned_Out_Parameter
(Return_Node : Node_Id;
Scope_Id : Entity_Id);
-- Called when processing a return statement given by Return_Node. Scope_Id
-- is the Entity_Id for the procedure in which the return statement lives.
-- A check is made for the case of a procedure with out parameters that
-- have not yet been assigned, and appropriate warnings are given.
procedure Warn_On_Useless_Assignment
(Ent : Entity_Id;
N : Node_Id := Empty);
-- Called to check if we have a case of a useless assignment to the given
-- entity Ent, as indicated by a non-empty Last_Assignment field. This call
-- should only be made if at least one of the flags Warn_On_Modified_Unread
-- or Warn_On_All_Unread_Out_Parameters is True, and if Ent is in the
-- extended main source unit. N is Empty for the end of block call
-- (warning message says value unreferenced), or it is the node for
-- an overwriting assignment (warning message points to this assignment).
procedure Warn_On_Useless_Assignments (E : Entity_Id);
pragma Inline (Warn_On_Useless_Assignments);
-- Called at the end of a block or subprogram. Scans the entities of the
-- block or subprogram to see if there are any variables for which useless
-- assignments were made (assignments whose values were never read).
----------------------
-- Utility Routines --
----------------------
function Has_Junk_Name (E : Entity_Id) return Boolean;
-- Return True if the entity name contains any of the following substrings:
-- discard
-- dummy
-- ignore
-- junk
-- unused
-- Used to suppress warnings on names matching these patterns. The contents
-- of Name_Buffer and Name_Len are destroyed by this call.
end Sem_Warn;
|
------------------------------------------------------------------------------
-- --
-- J E W L . W I N 3 2 _ I N T E R F A C E --
-- --
-- This is the body of a private package containing implementation --
-- details for JEWL.Windows. It contains type conversions where a --
-- bit-for-bit conversion is inadequate. It also contains some --
-- functions which provide a more tasteful Ada wrapping for a few --
-- common sequences of Win32 magic spells. --
-- --
-- Copyright (C) John English 2000. Contact address: je@brighton.ac.uk --
-- This software is released under the terms of the GNU General Public --
-- License and is intended primarily for educational use. Please contact --
-- the author to report bugs, suggestions and modifications. --
-- --
------------------------------------------------------------------------------
-- $Id: jewl-win32_interface.adb 1.7 2007/01/08 17:00:00 JE Exp $
------------------------------------------------------------------------------
--
-- $Log: jewl-win32_interface.adb $
-- Revision 1.7 2007/01/08 17:00:00 JE
-- * Fixed linker options in JEWL.Win32_Interface to accommodate changes to GNAT
-- GPL 2006 compiler (thanks to John McCormick for this)
-- * Added delay in message loop to avoid the appearance of hogging 100% of CPU
-- time
--
-- Revision 1.6 2001/11/02 16:00:00 JE
-- * Fixed canvas bug when saving an empty canvas
-- * Restore with no prior save now acts as erase
-- * Removed redundant variable declaration in Image function
--
-- Revision 1.5 2001/08/22 15:00:00 JE
-- * Minor bugfix to Get_Text for combo boxes
-- * Minor changes to documentation (including new example involving dialogs)
--
-- Revision 1.4 2001/01/25 09:00:00 je
-- Changes visible to the user:
--
-- * Added support for drawing bitmaps on canvases (Draw_Image operations
-- and new type Image_Type)
-- * Added Play_Sound
-- * Added several new operations on all windows: Get_Origin, Get_Width,
-- Get_Height, Set_Origin, Set_Size and Focus
-- * Added several functions giving screen and window dimensions: Screen_Width,
-- Screen_Height, Frame_Width, Frame_Height, Dialog_Width, Dialog_Height and
-- Menu_Height
-- * Canvases can now handle keyboard events: new constructor and Key_Code added
-- * Added procedure Play_Sound
-- * Operations "+" and "-" added for Point_Type
-- * Pens can now be zero pixels wide
-- * The absolute origin of a frame can now have be specified when the frame
-- is created
-- * Added new File_Dialog operations Add_Filter and Set_Directory
-- * Added Get_Line renames to JEWL.IO for compatibility with Ada.Text_IO
-- * Added all the Get(File,Item) operations mentioned in documentation but
-- unaccountably missing :-(
-- * Documentation updated to reflect the above changes
-- * HTML versions of public package specifications added with links from
-- main documentation pages
--
-- Other internal changes:
--
-- * Canvas fonts, pens etc. now use JEWL.Reference_Counted_Type rather than
-- reinventing this particular wheel, as do images
-- * Various minor code formatting changes: some code reordered for clarity,
-- some comments added or amended,
-- * Changes introduced in 1.2 to support GNAT 3.10 have been reversed, since
-- GNAT 3.10 still couldn't compile this code correctly... ;-(
--
-- Outstanding issues:
--
-- * Optimisation breaks the code (workaround: don't optimise)
--
-- Revision 1.3 2000/07/07 12:00:00 je
-- * JEWL.Simple_Windows added; JEWL.IO modified to use JEWL.Simple_Windows.
-- * JEWL.IO bug fix: Put_Line to file wrote newline to standard output
-- instead of to the file (thanks to Jeff Carter for pointing this out).
-- * Panels fixed so that mouse clicks are passed on correctly to subwindows.
-- * Memos fixed so that tabs are handled properly.
-- * Password feature added to editboxes.
-- * Minor typos fixed in comments within the package sources.
-- * Documentation corrected and updated following comments from Moti Ben-Ari
-- and Don Overheu.
--
-- Revision 1.2 2000/04/18 20:00:00 je
-- * Minor code changes to enable compilation by GNAT 3.10
-- * Minor documentation errors corrected
-- * Some redundant "with" clauses removed
--
-- Revision 1.1 2000/04/09 21:00:00 je
-- Initial revision
--
------------------------------------------------------------------------------
with Interfaces.C;
package body JEWL.Win32_Interface is
pragma Linker_Options ("-luser32");
pragma Linker_Options ("-lgdi32");
pragma Linker_Options ("-lcomdlg32");
pragma Linker_Options ("-lwinmm");
use type Win32_DWORD, Win32_INT, Win32_UINT, Win32_LONG, Win32_BYTE;
use type System.Address;
----------------------------------------------------------------------------
--
-- T Y P E C O N V E R S I O N S
--
----------------------------------------------------------------------------
function To_LPSTR (S : Win32_String) return Win32_LPSTR is
function UC is new Ada.Unchecked_Conversion
(System.Address, Win32_LPSTR);
begin
return UC(S(S'First)'Address);
end To_LPSTR;
function To_LPCSTR (S : Win32_String) return Win32_LPCSTR is
function UC is new Ada.Unchecked_Conversion
(System.Address, Win32_LPCSTR);
begin
return UC(S(S'First)'Address);
end To_LPCSTR;
function To_LPARAM (S : Win32_String) return Win32_LPARAM is
function UC is new Ada.Unchecked_Conversion
(System.Address, Win32_LPARAM);
begin
return UC(S(S'First)'Address);
end To_LPARAM;
function To_String (S : Win32_String) return String is
begin
return Interfaces.C.To_Ada(S);
end To_String;
function To_Array (S : String) return Win32_String is
begin
return Interfaces.C.To_C(S);
end To_Array;
function RGB (Colour : Colour_Type) return Win32_COLORREF is
use type Win32_BYTE;
begin
return Win32_COLORREF(Colour.Red + Colour.Green*2**8 + Colour.Blue*2**16);
end RGB;
function MakePoint (Value: Win32_LPARAM) return Win32_POINTS is
use type Interfaces.Unsigned_32;
function UC is new Ada.Unchecked_Conversion
(Win32_LPARAM,Interfaces.Unsigned_32);
function UC is new Ada.Unchecked_Conversion
(Win32_WORD,Win32_SHORT);
P : Win32_POINTS;
V : Interfaces.Unsigned_32 := UC(Value);
begin
P.X := UC(Win32_WORD(V and 16#FFFF#));
P.Y := UC(Win32_WORD(Interfaces.Shift_Right(V,16) and 16#FFFF#));
return P;
end MakePoint;
----------------------------------------------------------------------------
--
-- U T I L I T Y F U N C T I O N S
--
----------------------------------------------------------------------------
--
-- Message_Box: an Ada wrapper for the Win32 MessageBox function.
--
function Message_Box (Message : String;
Title : String;
Flags : Win32_UINT) return Integer is
M : Win32_String := To_Array(Message);
T : Win32_String := To_Array(Title);
begin
return Integer(MessageBox(System.Null_Address,
To_LPCSTR(M), To_LPCSTR(T),
Flags or MB_TASKMODAL or MB_SETFOREGROUND));
end Message_Box;
----------------------------------------------------------------------------
--
-- Create_Font: an Ada wrapper for the Win32 CreateFont function.
--
function Create_Font (Font : Font_Type) return Win32_HFONT is
F : Win32_HFONT;
L : aliased Win32_LOGFONT := Set_Font(Font);
begin
F := CreateFontIndirect (L'Unchecked_Access);
return F;
end Create_Font;
----------------------------------------------------------------------------
--
-- Set_Font: convert a Font_Type object to a Win32 font.
--
function Set_Font (Font : Font_Type) return Win32_LOGFONT is
F : Win32_LOGFONT;
H : Win32_HDC;
I : Win32_INT;
begin
H := GetDC(System.Null_Address);
F.lfHeight := -Win32_LONG(GetDeviceCaps(H,LOGPIXELSY) *
Win32_INT(Font.Size) / 72);
I := ReleaseDC(System.Null_Address,H);
if Font.Bold then
F.lfWeight := 700;
else
F.lfWeight := 400;
end if;
F.lfItalic := Boolean'Pos(Font.Italic);
if Font.Name'Length < F.lfFaceName'Length then
F.lfFaceName(0..Font.Name'Length) := To_Array(Font.Name);
else
F.lfFaceName := To_Array(Font.Name(1..F.lfFaceName'Length-1));
end if;
return F;
end Set_Font;
----------------------------------------------------------------------------
--
-- Get_Font: convert a Win32 font to a Font_Type object.
--
function Get_Font (Font : Win32_LOGFONT) return Font_Type is
H : Win32_HDC;
I : Win32_INT;
S : Float;
begin
H := GetDC(System.Null_Address);
S := 72.0 / Float(GetDeviceCaps(H,LOGPIXELSY));
I := ReleaseDC (System.Null_Address, H);
return JEWL.Font(To_String(Font.lfFaceName),
abs Integer(Float(Font.lfHeight)*S),
Font.lfWeight > 500, Font.lfItalic /= 0);
end Get_Font;
end JEWL.Win32_Interface;
|
-- C94010A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT IF A GENERIC UNIT HAS A FORMAL LIMITED PRIVATE TYPE AND
-- DECLARES AN OBJECT OF THAT TYPE (OR HAS A SUBCOMPONENT OF THAT TYPE),
-- AND IF THE UNIT IS INSTANTIATED WITH A TASK TYPE OR AN OBJECT HAVING
-- A SUBCOMPONENT OF A TASK TYPE, THEN THE USUAL RULES APPLY TO THE
-- INSTANTIATED UNIT, NAMELY:
-- A) IF THE GENERIC UNIT IS A SUBPROGRAM, CONTROL CANNOT LEAVE THE
-- SUBPROGRAM UNTIL THE TASK CREATED BY THE OBJECT DECLARATION IS
-- TERMINATED.
-- THIS TEST CONTAINS RACE CONDITIONS AND SHARED VARIABLES.
-- TBN 9/22/86
-- PWN 11/30/94 REMOVED PRAGMA PRIORITY INSTANCES FOR ADA 9X.
with Impdef;
WITH REPORT; USE REPORT;
WITH SYSTEM; USE SYSTEM;
PROCEDURE C94010A IS
GLOBAL_INT : INTEGER := 0;
MY_EXCEPTION : EXCEPTION;
PACKAGE P IS
TYPE LIM_PRI_TASK IS LIMITED PRIVATE;
PRIVATE
TASK TYPE LIM_PRI_TASK IS
END LIM_PRI_TASK;
END P;
USE P;
TASK TYPE TT IS
END TT;
TYPE REC IS
RECORD
A : INTEGER := 1;
B : TT;
END RECORD;
TYPE LIM_REC IS
RECORD
A : INTEGER := 1;
B : LIM_PRI_TASK;
END RECORD;
PACKAGE BODY P IS
TASK BODY LIM_PRI_TASK IS
BEGIN
DELAY 30.0 * Impdef.One_Second;
GLOBAL_INT := IDENT_INT (2);
END LIM_PRI_TASK;
END P;
TASK BODY TT IS
BEGIN
DELAY 30.0 * Impdef.One_Second;
GLOBAL_INT := IDENT_INT (1);
END TT;
GENERIC
TYPE T IS LIMITED PRIVATE;
PROCEDURE PROC (A : INTEGER);
PROCEDURE PROC (A : INTEGER) IS
OBJ_T : T;
BEGIN
IF A = IDENT_INT (1) THEN
RAISE MY_EXCEPTION;
END IF;
END PROC;
GENERIC
TYPE T IS LIMITED PRIVATE;
FUNCTION FUNC (A : INTEGER) RETURN INTEGER;
FUNCTION FUNC (A : INTEGER) RETURN INTEGER IS
OBJ_T : T;
BEGIN
IF A = IDENT_INT (1) THEN
RAISE MY_EXCEPTION;
END IF;
RETURN 1;
END FUNC;
BEGIN
TEST ("C94010A", "CHECK TERMINATION RULES FOR INSTANTIATIONS OF " &
"GENERIC SUBPROGRAM UNITS WHICH CREATE TASKS");
-------------------------------------------------------------------
DECLARE
PROCEDURE PROC1 IS NEW PROC (TT);
BEGIN
PROC1 (0);
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 1");
DELAY 35.0;
END IF;
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
PROCEDURE PROC2 IS NEW PROC (REC);
BEGIN
PROC2 (1);
FAILED ("EXCEPTION WAS NOT RAISED - 2");
EXCEPTION
WHEN MY_EXCEPTION =>
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 2");
DELAY 35.0 * Impdef.One_Second;
END IF;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 2");
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
PROCEDURE PROC3 IS NEW PROC (LIM_PRI_TASK);
BEGIN
PROC3 (1);
FAILED ("EXCEPTION WAS NOT RAISED - 3");
EXCEPTION
WHEN MY_EXCEPTION =>
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 3");
DELAY 35.0 * Impdef.One_Second;
END IF;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 3");
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
PROCEDURE PROC4 IS NEW PROC (LIM_REC);
BEGIN
PROC4 (0);
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 4");
DELAY 35.0 * Impdef.One_Second;
END IF;
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
A : INTEGER;
FUNCTION FUNC1 IS NEW FUNC (TT);
BEGIN
A := FUNC1 (1);
FAILED ("EXCEPTION NOT RAISED - 5");
EXCEPTION
WHEN MY_EXCEPTION =>
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 5");
DELAY 35.0 * Impdef.One_Second;
END IF;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 5");
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
A : INTEGER;
FUNCTION FUNC2 IS NEW FUNC (REC);
BEGIN
A := FUNC2 (0);
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 6");
DELAY 35.0 * Impdef.One_Second;
END IF;
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
A : INTEGER;
FUNCTION FUNC3 IS NEW FUNC (LIM_PRI_TASK);
BEGIN
A := FUNC3 (0);
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 7");
DELAY 35.0 * Impdef.One_Second;
END IF;
END;
-------------------------------------------------------------------
GLOBAL_INT := IDENT_INT (0);
DECLARE
A : INTEGER;
FUNCTION FUNC4 IS NEW FUNC (LIM_REC);
BEGIN
A := FUNC4 (1);
FAILED ("EXCEPTION NOT RAISED - 8");
EXCEPTION
WHEN MY_EXCEPTION =>
IF GLOBAL_INT = IDENT_INT (0) THEN
FAILED ("TASK NOT DEPENDENT ON MASTER - 8");
END IF;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED - 8");
END;
-------------------------------------------------------------------
RESULT;
END C94010A;
|
-- Abstract :
--
-- Base utilities for McKenzie_Recover
--
-- Copyright (C) 2018 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
with Ada.Exceptions;
with WisiToken.Parse.LR.Parser;
with WisiToken.Parse.LR.Parser_Lists;
private package WisiToken.Parse.LR.McKenzie_Recover.Base is
----------
-- Protected object specs.
--
-- Tasking design requirements:
--
-- 1) For each parse_state, find all solutions of the same lowest
-- cost.
--
-- 2) use as many CPUs as available as fully as possible.
--
-- 3) avoid
-- a) busy waits
-- b) race conditions
-- c) deadlocks.
--
-- For 2), we use worker_tasks to perform the check computations on
-- each configuration. We allocate N - 1 worker_tasks, where N is the
-- number of available CPUs, saving one CPU for Supervisor and the
-- foreground IDE.
--
-- For 1), worker_tasks always get the lowest cost configuration
-- available. However, some active worker_task may have a lower cost
-- configuration that it has not yet delivered to Supervisor.
-- Therefore we always wait until all current active worker_tasks
-- deliver their results before deciding we are done.
--
-- For 3a) we have one Supervisor protected object that controls
-- access to all Parse_States and configurations, and a Shared object
-- that provides appropriate access to the Shared_Parser components.
--
-- It is tempting to try to reduce contention for Supervisor by
-- having one protected object per parser, but that requires the
-- worker tasks to busy loop checking all the parsers.
--
-- There is still a race condition on Success; the solutions can be
-- delivered in different orders on different runs. This matters
-- because each solution results in a successful parse, possibly with
-- different actions (different indentation computed, for example).
-- Which solution finally succeeds depends on which are terminated
-- due to identical parser stacks, which in turn depends on the order
-- they were delivered. See ada-mode/tests/ada_mode-interactive_2.adb
-- for an example.
--
-- There is also a race condition on how many failed or higher cost
-- configurations are checked, before the final solutions are found.
type Config_Status is (Valid, All_Done);
type Recover_State is (Active, Ready, Success, Fail);
type Parser_Status is record
Recover_State : Base.Recover_State;
Parser_State : Parser_Lists.State_Access;
Fail_Mode : Recover_Status;
Active_Workers : Natural;
-- Count of Worker_Tasks that have done Get but not Put or Success.
end record;
type Parser_Status_Array is array (SAL.Peek_Type range <>) of Parser_Status;
protected type Supervisor
(Trace : not null access WisiToken.Trace'Class;
Check_Delta_Limit : Natural;
Enqueue_Limit : Natural;
Parser_Count : SAL.Peek_Type)
is
-- There is only one object of this type, declared in Recover.
procedure Initialize
(Parsers : not null access Parser_Lists.List;
Terminals : not null access constant Base_Token_Arrays.Vector);
entry Get
(Parser_Index : out SAL.Base_Peek_Type;
Config : out Configuration;
Status : out Config_Status);
-- Get a new configuration to check. Available when there is a
-- configuration to get, or when all configs have been checked.
--
-- Increments active worker count.
--
-- Status values mean:
--
-- Valid - Parser_Index, Config are valid, should be checked.
--
-- All_Done - Parser_Index, Config are not valid.
procedure Success
(Parser_Index : in SAL.Peek_Type;
Config : in Configuration;
Configs : in out Config_Heaps.Heap_Type);
-- Report that Configuration succeeds for Parser_Label, and enqueue
-- Configs.
--
-- Decrements active worker count.
procedure Put (Parser_Index : in SAL.Peek_Type; Configs : in out Config_Heaps.Heap_Type);
-- Add Configs to the McKenzie_Data Config_Heap for Parser_Label
--
-- Decrements active worker count.
procedure Config_Full (Parser_Index : in SAL.Peek_Type);
-- Report that a config.ops was full when trying to add another op.
-- This is counted towards the enqueue limit.
function Recover_Result return Recover_Status;
procedure Fatal (E : in Ada.Exceptions.Exception_Occurrence);
-- Report a fatal error; abort all processing, make Done
-- available.
entry Done (Error_ID : out Ada.Exceptions.Exception_Id; Message : out Ada.Strings.Unbounded.Unbounded_String);
-- Available when all parsers have failed or succeeded, or an error
-- occured.
--
-- If Error_ID is not Null_Id, an error occured.
function Parser_State (Parser_Index : in SAL.Peek_Type) return Parser_Lists.Constant_Reference_Type;
function Label (Parser_Index : in SAL.Peek_Type) return Natural;
private
Parsers : access Parser_Lists.List;
Terminals : access constant Base_Token_Arrays.Vector;
All_Parsers_Done : Boolean;
Success_Counter : Natural;
Min_Success_Check_Count : Natural;
Fatal_Called : Boolean;
Result : Recover_Status;
Error_ID : Ada.Exceptions.Exception_Id;
Error_Message : Ada.Strings.Unbounded.Unbounded_String;
Parser_Status : Parser_Status_Array (1 .. Parser_Count);
end Supervisor;
type Shared
(Trace : not null access WisiToken.Trace'Class;
Lexer : not null access constant WisiToken.Lexer.Instance'Class;
Table : not null access constant Parse_Table;
Language_Fixes : WisiToken.Parse.LR.Parser.Language_Fixes_Access;
Language_Matching_Begin_Tokens : WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access;
Language_String_ID_Set : WisiToken.Parse.LR.Parser.Language_String_ID_Set_Access;
Terminals : not null access constant Base_Token_Arrays.Vector;
Line_Begin_Token : not null access constant Line_Begin_Token_Vectors.Vector)
is null record;
-- There is only one object of this type, declared in Recover. It
-- provides appropriate access to Shared_Parser components.
--
-- Since all the accessible objects are read-only (except Trace),
-- there are no protected operations, and this is not a protected
-- type.
procedure Put
(Message : in String;
Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Peek_Type;
Config : in Configuration;
Task_ID : in Boolean := True);
end WisiToken.Parse.LR.McKenzie_Recover.Base;
|
-- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
with STM32.Device;
with HIL.Config;
-- @summary
-- Target-specific mapping for HIL of Clock
package body HIL.Clock with
SPARK_Mode => Off
is
procedure configure is
begin
-- GPIOs
STM32.Device.Enable_Clock(STM32.Device.GPIO_A );
STM32.Device.Enable_Clock(STM32.Device.GPIO_B);
STM32.Device.Enable_Clock(STM32.Device.GPIO_C);
STM32.Device.Enable_Clock(STM32.Device.GPIO_D);
STM32.Device.Enable_Clock(STM32.Device.GPIO_E);
-- SPI
STM32.Device.Enable_Clock(STM32.Device.SPI_1);
-- I2C
STM32.Device.Enable_Clock( STM32.Device.I2C_1 ); -- I2C
-- UART (UART3 is Ser2 is Telemtrie2)
STM32.Device.Enable_Clock( STM32.Device.USART_3 );
STM32.Device.Enable_Clock( STM32.Device.UART_4 ); -- GPS
STM32.Device.Enable_Clock( STM32.Device.USART_6 ); -- PX4IO
STM32.Device.Enable_Clock( STM32.Device.USART_7 ); -- SER 5
-- Timers
case HIL.Config.BUZZER_PORT is
when HIL.Config.BUZZER_USE_AUX5 =>
STM32.Device.Enable_Clock (STM32.Device.Timer_4); -- AUX buzzer
STM32.Device.Reset (STM32.Device.Timer_4); -- without this not reliable
when HIL.Config.BUZZER_USE_PORT =>
STM32.Device.Enable_Clock (STM32.Device.Timer_2); -- regular buzzer port
STM32.Device.Reset (STM32.Device.Timer_2); -- without this not reliable
end case;
STM32.Device.Reset( STM32.Device.GPIO_A );
STM32.Device.Reset( STM32.Device.GPIO_B );
STM32.Device.Reset( STM32.Device.GPIO_C );
STM32.Device.Reset( STM32.Device.GPIO_D );
STM32.Device.Reset( STM32.Device.GPIO_E );
STM32.Device.Reset( STM32.Device.SPI_1 );
STM32.Device.Reset( STM32.Device.USART_3 );
STM32.Device.Reset( STM32.Device.UART_4 );
STM32.Device.Reset( STM32.Device.USART_6 );
STM32.Device.Reset( STM32.Device.USART_7 );
end configure;
-- get number of systicks since POR
function getSysTick return Natural is
begin
null;
return 0;
end getSysTick;
-- get system time since POR
function getSysTime return Ada.Real_Time.Time is
begin
return Ada.Real_Time.Clock;
end getSysTime;
end HIL.Clock;
|
-- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
-- Author: Martin Becker (becker@rcs.ei.tum.de)
with HIL; use HIL;
with Ada.Unchecked_Conversion;
with Ada.Real_Time; use Ada.Real_Time;
with ULog.Conversions; use ULog.Conversions;
with Interfaces; use Interfaces;
-- @summary
-- Implements the structure andserialization of log objects
-- according to the self-describing ULOG file format used
-- in PX4.
-- The serialized byte array is returned.
package body ULog with SPARK_Mode => On is
All_Defs : Boolean := False;
Hdr_Def : Boolean := False;
Next_Def : Message_Type := Message_Type'First;
ULOG_VERSION : constant HIL.Byte_Array := (1 => 16#1#);
ULOG_MAGIC : constant HIL.Byte_Array := (16#55#, 16#4c#, 16#6f#, 16#67#,
16#01#, 16#12#, 16#35#);
ULOG_MSG_HEAD : constant HIL.Byte_Array := (16#A3#, 16#95#);
ULOG_MTYPE_FMT : constant := 16#80#;
-- each log message looks like this:
-- +------------------+---------+----------------+
-- | ULOG_MSG_HEAD(2) | Type(1) | Msg body (var) |
-- +------------------+---------+----------------+
--
-- each body can be different. The header of the log file contains
-- the definitions for the body by means of fixed-length
-- FMT (0x80) messages, i.e., something like this:
-- +------------------+------+--------------------+
-- | ULOG_MSG_HEAD(2) | 0x80 | a definition (86B) |
-- +------------------+------+--------------------+
-- whereas 'definition' is as follows:
--
-- +---------+-----------+---------+------------+------------+
-- | type[1] | length[1] | name[4] | format[16] | labels[64] |
-- +---------+-----------+---------+------------+------------+
-- ^^ full packet incl.header
--
-- Such FMT messages define the anatomy of 'msg body' for
-- all messages with Type /= 0x80.
---------------------
-- USER PROTOTYPES
---------------------
-- add one Serialize_Ulog_* for each new message
procedure Serialize_Ulog_GPS
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = GPS;
procedure Serialize_Ulog_IMU
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = IMU;
procedure Serialize_Ulog_Baro
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message; buf : out HIL.Byte_Array)
with Pre => msg.Typ = BARO;
procedure Serialize_Ulog_Mag
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = MAG;
procedure Serialize_Ulog_Controller
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = CONTROLLER;
procedure Serialize_Ulog_Nav
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = NAV;
procedure Serialize_Ulog_Text
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = TEXT;
procedure Serialize_Ulog_LogQ
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array)
with Pre => msg.Typ = LOG_QUEUE;
-------------------------
-- INTERNAL PROTOTYPES
-------------------------
function Time_To_U64 (rtime : Ada.Real_Time.Time) return Unsigned_64
with Pre => rtime >= Ada.Real_Time.Time_First;
-- SPARK: "precond. might fail". Me: no (private type).
procedure Serialize_Ulog_With_Tag
(ct : out ULog.Conversions.Conversion_Tag;
msg : in Message;
len : out Natural;
bytes : out HIL.Byte_Array)
with Post => len < 256 and -- ulog messages cannot be longer
then len <= bytes'Length;
------------------------
-- Serialize_Ulog_GPS
------------------------
procedure Serialize_Ulog_GPS (ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message; buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "GPS");
Append_Float (ct, "lat", buf, msg.lat);
Append_Float (ct, "lon", buf, msg.lon);
Append_Float (ct, "alt", buf, msg.alt);
Append_Uint8 (ct, "sat", buf, msg.nsat);
Append_Uint8 (ct, "fix", buf, msg.fix);
Append_Uint16 (ct, "yr", buf, msg.gps_year);
Append_Uint8 (ct, "mon", buf, msg.gps_month);
Append_Uint8 (ct, "day", buf, msg.gps_day);
Append_Uint8 (ct, "h", buf, msg.gps_hour);
Append_Uint8 (ct, "m", buf, msg.gps_min);
Append_Uint8 (ct, "s", buf, msg.gps_sec);
Append_Float (ct, "acc", buf, msg.pos_acc);
Append_Float (ct, "v", buf, msg.vel);
end Serialize_Ulog_GPS;
-- pragma Annotate
-- (GNATprove, Intentional, """buf"" is not initialized",
-- "done by Martin Becker");
------------------------
-- Serialize_Ulog_Nav
------------------------
procedure Serialize_Ulog_Nav (ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message; buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "NAV");
Append_Float (ct, "dist", buf, msg.home_dist);
Append_Float (ct, "crs", buf, msg.home_course);
Append_Float (ct, "altd", buf, msg.home_altdiff);
end Serialize_Ulog_Nav;
------------------------
-- Serialize_Ulog_IMU
------------------------
procedure Serialize_Ulog_IMU (ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message; buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "IMU");
Append_Float (ct, "accX", buf, msg.accX);
Append_Float (ct, "accY", buf, msg.accY);
Append_Float (ct, "accZ", buf, msg.accZ);
Append_Float (ct, "gyroX", buf, msg.gyroX);
Append_Float (ct, "gyroY", buf, msg.gyroY);
Append_Float (ct, "gyroZ", buf, msg.gyroZ);
Append_Float (ct, "roll", buf, msg.roll);
Append_Float (ct, "pitch", buf, msg.pitch);
Append_Float (ct, "yaw", buf, msg.yaw);
end Serialize_Ulog_IMU;
pragma Annotate
(GNATprove, Intentional,
"""buf"" is not initialized", "done by Martin Becker");
------------------------
-- Serialize_Ulog_BARO
------------------------
procedure Serialize_Ulog_Baro
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "Baro");
Append_Float (ct, "press", buf, msg.pressure);
Append_Float (ct, "temp", buf, msg.temp);
Append_Float (ct, "alt", buf, msg.press_alt);
end Serialize_Ulog_Baro;
pragma Annotate
(GNATprove, Intentional,
"""buf"" is not initialized", "being done here");
------------------------
-- Serialize_Ulog_MAG
------------------------
procedure Serialize_Ulog_Mag
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "MAG");
Append_Float (ct, "magX", buf, msg.magX);
Append_Float (ct, "magY", buf, msg.magY);
Append_Float (ct, "magZ", buf, msg.magZ);
end Serialize_Ulog_Mag;
pragma Annotate
(GNATprove, Intentional,
"""buf"" is not initialized", "done by Martin Becker");
-------------------------------
-- Serialize_Ulog_Controller
-------------------------------
procedure Serialize_Ulog_Controller
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "Ctrl");
Append_Uint8 (ct, "mode", buf, msg.ctrl_mode);
Append_Float (ct, "TarYaw", buf, msg.target_yaw);
Append_Float (ct, "TarRoll", buf, msg.target_roll);
Append_Float (ct, "TarPitch", buf, msg.target_pitch);
Append_Float (ct, "EleL", buf, msg.elevon_left);
Append_Float (ct, "EleR", buf, msg.elevon_right);
end Serialize_Ulog_Controller;
pragma Annotate
(GNATprove, Intentional,
"""buf"" is not initialized", "done by Martin Becker");
------------------------
-- Serialize_Ulog_LogQ
------------------------
procedure Serialize_Ulog_LogQ
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "LogQ");
Append_Uint16 (ct, "ovf", buf, msg.n_overflows);
Append_Uint8 (ct, "qd", buf, msg.n_queued);
Append_Uint8 (ct, "max", buf, msg.max_queued);
end Serialize_Ulog_LogQ;
-- pragma Annotate
-- (GNATprove, Intentional,
-- """buf"" is not initialized", "done by Martin Becker");
-------------------------
-- Serialize_Ulog_Text
-------------------------
procedure Serialize_Ulog_Text
(ct : in out ULog.Conversions.Conversion_Tag;
msg : in Message;
buf : out HIL.Byte_Array) is
begin
Set_Name (ct, "Text");
-- we allow 128B, but the longest field is 64B. split over two.
declare
txt : String renames msg.txt (msg.txt'First .. msg.txt'First + 63);
len : Natural;
begin
if msg.txt_last > txt'Last then
len := txt'Length;
elsif msg.txt_last >= txt'First and then msg.txt_last <= txt'Last then
len := (msg.txt_last - txt'First) + 1;
else
len := 0;
end if;
Append_String64 (ct, "text1", buf, txt, len);
end;
declare
txt : String renames msg.txt (msg.txt'First + 64 .. msg.txt'Last);
len : Natural;
begin
if msg.txt_last > txt'Last then
len := txt'Length;
elsif msg.txt_last >= txt'First and then msg.txt_last <= txt'Last then
len := (msg.txt_last - txt'First) + 1;
else
len := 0;
end if;
Append_String64 (ct, "text2", buf, txt, len);
end;
end Serialize_Ulog_Text;
pragma Annotate
(GNATprove, Intentional,
"""buf"" is not initialized", "done by Martin Becker");
--------------------
-- Time_To_U64
--------------------
function Time_To_U64 (rtime : Ada.Real_Time.Time) return Unsigned_64 is
tmp : Integer;
u64 : Unsigned_64;
begin
tmp := (rtime - Ada.Real_Time.Time_First) /
Ada.Real_Time.Microseconds (1);
if tmp < Integer (Unsigned_64'First) then
u64 := Unsigned_64'First;
else
u64 := Unsigned_64 (tmp);
end if;
return u64;
end Time_To_U64;
-- SPARK: "precondition might a fail".
-- Me: "no (because Time_First is private and SPARK can't know)"
--------------------
-- Serialize_Ulog
--------------------
procedure Serialize_Ulog (msg : in Message; len : out Natural;
bytes : out HIL.Byte_Array) is
ct : ULog.Conversions.Conversion_Tag;
begin
Serialize_Ulog_With_Tag
(ct => ct, msg => msg, len => len, bytes => bytes);
pragma Unreferenced (ct); -- caller doesn't want that
end Serialize_Ulog;
-----------------------------
-- Serialize_Ulog_With_Tag
-----------------------------
procedure Serialize_Ulog_With_Tag (ct : out ULog.Conversions.Conversion_Tag;
msg : in Message; len : out Natural;
bytes : out HIL.Byte_Array) is
begin
New_Conversion (ct);
-- write header
Append_Unlabeled_Bytes
(t => ct, buf => bytes, tail => ULOG_MSG_HEAD
& HIL.Byte (Message_Type'Pos (msg.Typ)));
pragma Annotate
(GNATprove, Intentional,
"""bytes"" is not initialized", "done by Martin Becker");
-- serialize the timestamp
declare
pragma Assume (msg.t >= Ada.Real_Time.Time_First); -- see a-reatim.ads
time_usec : constant Unsigned_64 := Time_To_U64 (msg.t);
begin
Append_Uint64
(t => ct, label => "t", buf => bytes, tail => time_usec);
end;
-- call the appropriate serializaton procedure for other components
case msg.Typ is
when NONE => null;
when GPS =>
Serialize_Ulog_GPS (ct, msg, bytes);
when IMU =>
Serialize_Ulog_IMU (ct, msg, bytes);
when MAG =>
Serialize_Ulog_Mag (ct, msg, bytes);
when CONTROLLER =>
Serialize_Ulog_Controller (ct, msg, bytes);
when TEXT =>
Serialize_Ulog_Text (ct, msg, bytes);
when BARO =>
Serialize_Ulog_Baro (ct, msg, bytes);
when NAV =>
Serialize_Ulog_Nav (ct, msg, bytes);
when LOG_QUEUE =>
Serialize_Ulog_LogQ (ct, msg, bytes);
end case;
-- read back the length, and drop incomplete messages
declare
SERLEN : constant Natural := Get_Size (ct);
begin
if Buffer_Overflow (ct) or SERLEN > bytes'Length or SERLEN > 255
then
len := 0;
else
len := SERLEN;
end if;
end;
-- pragma Assert (len <= bytes'Length);
end Serialize_Ulog_With_Tag;
-------------------
-- Serialize_CSV
-------------------
-- procedure Serialize_CSV
-- (msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) is
-- begin
-- null;
-- end Serialize_CSV;
---------------------
-- Get_Header_Ulog
---------------------
procedure Get_Header_Ulog
(bytes : in out HIL.Byte_Array;
len : out Natural;
valid : out Boolean) with SPARK_Mode => Off is
begin
if All_Defs then
valid := False;
elsif not Hdr_Def then
-- before everything, return following ULog header:
-- (not required by the spec, but it helps to recover the file
-- when the SD logging goes wrong):
-- +------------+---------+-----------+
-- | File magic | version | timestamp |
-- +------------+---------+-----------+
declare
timestamp : constant HIL.Byte_Array := (0, 0, 0, 0);
l : constant Integer :=
ULOG_MAGIC'Length + ULOG_VERSION'Length + timestamp'Length;
begin
if bytes'Length < l then
len := 0;
valid := False;
end if;
bytes (bytes'First .. bytes'First + l - 1) :=
ULOG_MAGIC & ULOG_VERSION & timestamp;
len := l;
end;
Hdr_Def := True;
valid := True;
else
if Next_Def = NONE then
len := 0;
else
-- now return FMT message with definition of current type.
-- Skip type=NONE
declare
-- the following decl prevents spark mode.
-- RM 4.4(2): subtype cons. cannot depend.
-- simply comment for proof.
m : Message (typ => Next_Def);
FMT_HEAD : constant HIL.Byte_Array :=
ULOG_MSG_HEAD & ULOG_MTYPE_FMT;
type FMT_Msg is record
HEAD : HIL.Byte_Array (1 .. 3);
typ : HIL.Byte; -- auto: ID of message being described
len : HIL.Byte; -- auto: length of packed message
name : ULog_Name; -- auto: short name of message
fmt : ULog_Format; -- format string
lbl : ULog_Label; -- label string
end record
with Pack;
FMT_MSGLEN : constant Natural := (FMT_Msg'Size + 7) / 8; -- ceil
subtype foo is HIL.Byte_Array (1 .. FMT_MSGLEN);
function To_Buffer is new
Ada.Unchecked_Conversion (FMT_Msg, foo);
fmsg : FMT_Msg;
begin
if FMT_MSGLEN > bytes'Length then
len := 0; -- message too long for buffer...skip it
return;
end if;
fmsg.HEAD := FMT_HEAD;
fmsg.typ := HIL.Byte (Message_Type'Pos (Next_Def));
-- actually serialize a dummy message and read back things
declare
serbuf : HIL.Byte_Array (1 .. 512);
pragma Unreferenced (serbuf);
serlen : Natural;
begin
declare
ct : ULog.Conversions.Conversion_Tag;
begin
Serialize_Ulog_With_Tag
(ct => ct, msg => m, len => serlen, bytes => serbuf);
fmsg.fmt := ULog.Conversions.Get_Format (ct);
fmsg.name := ULog.Conversions.Get_Name (ct);
fmsg.lbl := ULog.Conversions.Get_Labels (ct);
end;
fmsg.len := HIL.Byte (serlen);
end;
-- copy all over to caller
bytes (bytes'First .. bytes'First + FMT_MSGLEN - 1) :=
To_Buffer (fmsg);
len := FMT_MSGLEN;
end;
end if;
if Next_Def < Message_Type'Last then
Next_Def := Message_Type'Succ (Next_Def);
else
All_Defs := True;
end if;
valid := True;
end if;
end Get_Header_Ulog;
end ULog;
|
package Array15 is
function F (I : Integer) return Integer;
end Array15;
|
-- Copyright 2016-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky 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.
--
-- Steam Sky 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 Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with DOM.Core; use DOM.Core;
with DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Log; use Log;
with Items; use Items;
package body ShipModules is
procedure LoadShipModules(Reader: Tree_Reader) is
NodesList: Node_List;
ModulesData: Document;
TempRecord: BaseModule_Data;
Action: Data_Action;
ModuleNode: Node;
SkillIndex: Natural;
MaterialExists: Boolean;
ModuleIndex: Unbounded_String;
begin
ModulesData := Get_Tree(Reader);
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(ModulesData, "module");
Load_Modules_Loop :
for I in 0 .. Length(NodesList) - 1 loop
TempRecord :=
(Name => Null_Unbounded_String, MType => ENGINE, Weight => 0,
Value => 0, MaxValue => 0, Durability => 0,
RepairMaterial => Null_Unbounded_String, RepairSkill => 2,
Price => 0, InstallTime => 60, Unique => False, Size => 1,
Description => Null_Unbounded_String, MaxOwners => 1, Speed => 4,
Reputation => -100);
ModuleNode := Item(NodesList, I);
ModuleIndex :=
To_Unbounded_String(Get_Attribute(ModuleNode, "index"));
Action :=
(if Get_Attribute(ModuleNode, "action")'Length > 0 then
Data_Action'Value(Get_Attribute(ModuleNode, "action"))
else ADD);
if Action in UPDATE | REMOVE then
if not BaseModules_Container.Contains
(Modules_List, ModuleIndex) then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" ship module '" & To_String(ModuleIndex) &
"', there is no ship module with that index.";
end if;
elsif BaseModules_Container.Contains(Modules_List, ModuleIndex) then
raise Data_Loading_Error
with "Can't add ship module '" & To_String(ModuleIndex) &
"', there is already a ship with that index.";
end if;
if Action /= REMOVE then
if Action = UPDATE then
TempRecord := Modules_List(ModuleIndex);
end if;
if Get_Attribute(ModuleNode, "name")'Length > 0 then
TempRecord.Name :=
To_Unbounded_String(Get_Attribute(ModuleNode, "name"));
end if;
if Get_Attribute(ModuleNode, "type")'Length > 0 then
TempRecord.MType :=
ModuleType'Value(Get_Attribute(ModuleNode, "type"));
end if;
if Get_Attribute(ModuleNode, "weight")'Length > 0 then
TempRecord.Weight :=
Natural'Value(Get_Attribute(ModuleNode, "weight"));
end if;
if Get_Attribute(ModuleNode, "value")'Length > 0 then
TempRecord.Value :=
Integer'Value(Get_Attribute(ModuleNode, "value"));
end if;
if Get_Attribute(ModuleNode, "maxvalue")'Length > 0 then
TempRecord.MaxValue :=
Integer'Value(Get_Attribute(ModuleNode, "maxvalue"));
end if;
if Get_Attribute(ModuleNode, "durability")'Length > 0 then
TempRecord.Durability :=
Integer'Value(Get_Attribute(ModuleNode, "durability"));
end if;
if Get_Attribute(ModuleNode, "material")'Length > 0 then
TempRecord.RepairMaterial :=
To_Unbounded_String(Get_Attribute(ModuleNode, "material"));
MaterialExists := False;
Check_Materials_Loop :
for Material of Items_Types loop
if Material = TempRecord.RepairMaterial then
MaterialExists := True;
exit Check_Materials_Loop;
end if;
end loop Check_Materials_Loop;
if not MaterialExists then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" ship module '" & To_String(ModuleIndex) &
"', there is no item type '" &
Get_Attribute(ModuleNode, "material") & "'.";
end if;
end if;
if Get_Attribute(ModuleNode, "skill")'Length > 0 then
SkillIndex :=
Find_Skill_Index(Get_Attribute(ModuleNode, "skill"));
if SkillIndex = 0 then
raise Data_Loading_Error
with "Can't " & To_Lower(Data_Action'Image(Action)) &
" ship module '" & To_String(ModuleIndex) &
"', there is no skill named '" &
Get_Attribute(ModuleNode, "skill") & "'.";
end if;
TempRecord.RepairSkill := SkillIndex;
end if;
if Get_Attribute(ModuleNode, "price")'Length > 0 then
TempRecord.Price :=
Integer'Value(Get_Attribute(ModuleNode, "price"));
end if;
if Get_Attribute(ModuleNode, "installtime")'Length > 0 then
TempRecord.InstallTime :=
Positive'Value(Get_Attribute(ModuleNode, "installtime"));
end if;
if Get_Attribute(ModuleNode, "unique") /= "" then
TempRecord.Unique := True;
end if;
if Get_Attribute(ModuleNode, "size") /= "" then
TempRecord.Size :=
Integer'Value(Get_Attribute(ModuleNode, "size"));
end if;
if Get_Attribute(ModuleNode, "maxowners")'Length > 0 then
TempRecord.MaxOwners :=
Integer'Value(Get_Attribute(ModuleNode, "maxowners"));
end if;
if Get_Attribute(ModuleNode, "speed")'Length > 0 then
TempRecord.Speed :=
Integer'Value(Get_Attribute(ModuleNode, "speed"));
end if;
if Get_Attribute(ModuleNode, "reputation")'Length > 0 then
TempRecord.Reputation :=
Integer'Value(Get_Attribute(ModuleNode, "reputation"));
end if;
if Has_Child_Nodes(ModuleNode) then
TempRecord.Description :=
To_Unbounded_String(Node_Value(First_Child(ModuleNode)));
end if;
if Action /= UPDATE then
BaseModules_Container.Include
(Modules_List, ModuleIndex, TempRecord);
Log_Message
("Module added: " & To_String(TempRecord.Name), EVERYTHING);
else
Modules_List(ModuleIndex) := TempRecord;
Log_Message
("Module updated: " & To_String(TempRecord.Name), EVERYTHING);
end if;
else
BaseModules_Container.Exclude(Modules_List, ModuleIndex);
Log_Message
("Module removed: " & To_String(ModuleIndex), EVERYTHING);
end if;
end loop Load_Modules_Loop;
end LoadShipModules;
function GetModuleType(ModuleIndex: Unbounded_String) return String is
ModuleTypeName: Unbounded_String :=
To_Unbounded_String
(To_Lower(ModuleType'Image(Modules_List(ModuleIndex).MType)));
begin
Replace_Element
(ModuleTypeName, 1,
To_Upper(Ada.Strings.Unbounded.Element(ModuleTypeName, 1)));
Translate(ModuleTypeName, To_Mapping("_", " "));
return To_String(ModuleTypeName);
end GetModuleType;
end ShipModules;
|
with VisitFailurePackage, VisitablePackage, EnvironmentPackage;
use VisitFailurePackage, VisitablePackage, EnvironmentPackage;
package body FailStrategy is
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
overriding
function toString(f: Fail) return String is
begin
if f.message = null then
return "Fail("""")";
else
return "Fail(""" & f.message.all & """)";
end if;
end;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
overriding
function visitLight(str:access Fail; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is
begin
if str.message = null then
raise VisitFailure;
else
RaiseVisitFailure(str.message.all);
return null; --never executed
end if;
end;
overriding
function visit(str: access Fail; i: access Introspector'Class) return Integer is
begin
return EnvironmentPackage.FAILURE;
end;
----------------------------------------------------------------------------
procedure makeFail(f : in out Fail; m: access String) is
begin
initSubterm(f);
f.message := m;
end;
function newFail return StrategyPtr is
ret : StrategyPtr := new Fail;
begin
makeFail(Fail(ret.all), null);
return ret;
end;
function newFail(m: String) return StrategyPtr is
ret : StrategyPtr := new Fail;
begin
makeFail(Fail(ret.all), new String'(m));
return ret;
end;
function newFail(m: access String) return StrategyPtr is
ret : StrategyPtr := new Fail;
begin
makeFail(Fail(ret.all), m);
return ret;
end;
----------------------------------------------------------------------------
end FailStrategy;
|
package body Array25_Pkg is
procedure Get_Inner (A : out Arr1) is
begin
null;
end;
procedure Get (A : out Arr2) is
begin
for I in Arr2'Range loop
Get_Inner (A (I).Data);
end loop;
end;
end Array25_Pkg;
|
package Dsp is
subtype Normalized_Frequency is Float range 0.0 .. 1.0;
subtype Radius is Float range 0.0 .. Float'Last;
subtype Stable_Radius is Radius range 0.0 .. 1.0;
end Dsp;
|
pragma License (Unrestricted);
-- extended unit
with Ada.IO_Exceptions;
package Ada.Streams.Block_Transmission is
-- There are efficient read/write/input/output operations for stream.
pragma Pure;
generic
type Index_Type is (<>);
type Element_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
procedure Read (
Stream : not null access Root_Stream_Type'Class;
Item : out Array_Type);
generic
type Index_Type is (<>);
type Element_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
procedure Write (
Stream : not null access Root_Stream_Type'Class;
Item : Array_Type);
generic
type Index_Type is (<>);
type Element_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
with procedure Read (
Stream : not null access Root_Stream_Type'Class;
Item : out Array_Type);
function Input (
Stream : not null access Root_Stream_Type'Class)
return Array_Type;
generic
type Index_Type is (<>);
type Element_Type is (<>);
type Array_Type is array (Index_Type range <>) of Element_Type;
with procedure Write (
Stream : not null access Root_Stream_Type'Class;
Item : Array_Type);
procedure Output (
Stream : not null access Root_Stream_Type'Class;
Item : Array_Type);
-- for Stream_Element_Array
package Stream_Element_Arrays is
procedure Read (
Stream : not null access Root_Stream_Type'Class;
Item : out Stream_Element_Array);
procedure Write (
Stream : not null access Root_Stream_Type'Class;
Item : Stream_Element_Array);
end Stream_Element_Arrays;
-- exceptions
End_Error : exception
renames IO_Exceptions.End_Error;
Data_Error : exception
renames IO_Exceptions.Data_Error;
end Ada.Streams.Block_Transmission;
|
-- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
-- @summary
-- target-independent functions of HIL.
package body HIL with
SPARK_Mode => Off
is
procedure set_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) is
begin
register := register or Unsigned_16( bit_mask );
end set_Bits;
procedure clear_Bits( register : in out Unsigned_16; bit_mask : Unsigned_16_Mask) is
begin
register := register and not Unsigned_16( bit_mask );
end clear_Bits;
procedure write_Bits( register : in out Unsigned_8;
start_index : Unsigned_8_Bit_Index;
length : Positive;
value : Integer) is
bits_mask : constant Unsigned_8 := (2**length - 1) * 2**Natural(start_index);
value_mask : constant Unsigned_8 := Unsigned_8( value * 2**Natural(start_index) );
begin
register := (register and not bits_mask ) or (bits_mask or value_mask);
end write_Bits;
function read_Bits( register : in Unsigned_8;
start_index : Unsigned_8_Bit_Index;
length : Positive) return Unsigned_8 is
bits_mask : constant Unsigned_8 := (2**length - 1) * 2**Natural(start_index);
value : constant Unsigned_8 := (bits_mask and register) / 2**Natural(start_index);
begin
return value;
end read_Bits;
end HIL;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <contact@flyx.org>
--
-- 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 Interfaces.C.Pointers;
private with GL.Enums;
private with GL.Low_Level;
package GL.Objects.Buffers is
pragma Preelaborate;
function Minimum_Alignment return Types.Size
with Post => Minimum_Alignment'Result >= 64;
-- Minimum byte alignment of pointers returned by Map_Range
-- (at least 64 bytes to support SIMD CPU instructions)
type Access_Bits is record
Read : Boolean := False;
Write : Boolean := False;
Invalidate_Range : Boolean := False;
Invalidate_Buffer : Boolean := False;
Flush_Explicit : Boolean := False;
Unsynchronized : Boolean := False;
Persistent : Boolean := False;
Coherent : Boolean := False;
end record
with Dynamic_Predicate => (Access_Bits.Read or Access_Bits.Write)
and (if Access_Bits.Flush_Explicit then Access_Bits.Write)
and (if Access_Bits.Invalidate_Range or Access_Bits.Invalidate_Buffer then
not Access_Bits.Read);
type Storage_Bits is record
Read : Boolean := False;
Write : Boolean := False;
Persistent : Boolean := False;
Coherent : Boolean := False;
Dynamic_Storage : Boolean := False;
Client_Storage : Boolean := False;
end record
with Dynamic_Predicate => (if Storage_Bits.Coherent then Storage_Bits.Persistent)
and (if Storage_Bits.Persistent then Storage_Bits.Read or Storage_Bits.Write);
type Buffer_Target (<>) is tagged limited private;
type Indexed_Buffer_Target is (Atomic_Counter, Shader_Storage, Uniform);
function Kind (Target : Buffer_Target) return Indexed_Buffer_Target;
type Buffer is new GL_Object with private;
function Allocated (Object : Buffer) return Boolean;
function Mapped (Object : Buffer) return Boolean;
procedure Bind (Target : Buffer_Target; Object : Buffer'Class);
-- Bind the buffer object to the target
--
-- The target must not be one of the targets that should be used with
-- Bind_Base or Bind_Range.
procedure Bind_Base (Target : Buffer_Target; Object : Buffer'Class; Index : Natural);
-- Bind the buffer object to the index of the target as well as to
-- the target itself.
--
-- Target must be one of the following:
--
-- * Atomic_Counter_Buffer
-- * Uniform_Buffer
-- * Shader_Storage_Buffer
procedure Allocate_Storage
(Object : in out Buffer;
Length : Long;
Kind : Numeric_Type;
Flags : Storage_Bits)
with Pre => not Object.Allocated,
Post => Object.Allocated;
-- Use this instead of Allocate_And_Load_From_Data if you don't want
-- to copy any data
overriding
procedure Initialize_Id (Object : in out Buffer);
overriding
procedure Delete_Id (Object : in out Buffer);
overriding
function Identifier (Object : Buffer) return Types.Debug.Identifier is
(Types.Debug.Buffer);
procedure Unmap (Object : in out Buffer);
procedure Invalidate_Data (Object : in out Buffer);
generic
with package Pointers is new Interfaces.C.Pointers (<>);
package Buffer_Pointers is
subtype Pointer is Pointers.Pointer;
procedure Bind_Range
(Target : Buffer_Target;
Object : Buffer'Class;
Index : Natural;
Offset, Length : Types.Size);
-- Bind a part of the buffer object to the index of the target as
-- well as to the target itself
--
-- Target must be one of the following:
--
-- * Atomic_Counter_Buffer
-- * Uniform_Buffer
-- * Shader_Storage_Buffer
procedure Allocate_And_Load_From_Data
(Object : in out Buffer;
Data : Pointers.Element_Array;
Flags : Storage_Bits)
with Pre => not Object.Allocated,
Post => Object.Allocated;
procedure Map_Range
(Object : in out Buffer;
Flags : Access_Bits;
Offset, Length : Types.Size;
Pointer : out Pointers.Pointer)
with Pre => Object.Allocated and not Object.Mapped and Length > 0;
function Get_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset, Length : Types.Size) return Pointers.Element_Array
with Pre => Length > 0,
Post => Get_Mapped_Data'Result'Length = Length;
procedure Set_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset : Types.Size;
Data : Pointers.Element_Array)
with Pre => Data'Length > 0;
procedure Set_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset : Types.Size;
Value : Pointers.Element);
procedure Flush_Buffer_Range (Object : in out Buffer;
Offset, Length : Types.Size);
procedure Clear_Sub_Data
(Object : Buffer;
Kind : Numeric_Type;
Offset, Length : Types.Size;
Data : in out Pointers.Element_Array)
with Pre => Data'Length <= 4
and then Kind /= Double_Type
and then (if Data'Length = 3 then
Kind not in Byte_Type | UByte_Type | Short_Type | UShort_Type | Half_Type);
procedure Copy_Sub_Data (Object, Target_Object : Buffer;
Read_Offset, Write_Offset, Length : Types.Size);
procedure Set_Sub_Data (Object : Buffer;
Offset : Types.Size;
Data : Pointers.Element_Array);
procedure Get_Sub_Data (Object : Buffer;
Offset : Types.Size;
Data : out Pointers.Element_Array);
procedure Invalidate_Sub_Data (Object : Buffer;
Offset, Length : Types.Size);
end Buffer_Pointers;
-- Array_Buffer, Texture_Buffer,
-- Copy_Read_Buffer, and Copy_Write_Buffer are no longer needed
-- since the GL.Objects.* packages use DSA
-- Transform_Feedback_Buffer replaced by Shader_Storage_Buffer
Element_Array_Buffer : aliased constant Buffer_Target;
Pixel_Pack_Buffer : aliased constant Buffer_Target;
Pixel_Unpack_Buffer : aliased constant Buffer_Target;
Draw_Indirect_Buffer : aliased constant Buffer_Target;
Parameter_Buffer : aliased constant Buffer_Target;
Dispatch_Indirect_Buffer : aliased constant Buffer_Target;
Query_Buffer : aliased constant Buffer_Target;
-- Buffer targets that must be binded to a specific index
-- (specified in shaders)
Uniform_Buffer : aliased constant Buffer_Target;
Shader_Storage_Buffer : aliased constant Buffer_Target;
Atomic_Counter_Buffer : aliased constant Buffer_Target;
private
for Access_Bits use record
Read at 0 range 0 .. 0;
Write at 0 range 1 .. 1;
Invalidate_Range at 0 range 2 .. 2;
Invalidate_Buffer at 0 range 3 .. 3;
Flush_Explicit at 0 range 4 .. 4;
Unsynchronized at 0 range 5 .. 5;
Persistent at 0 range 6 .. 6;
Coherent at 0 range 7 .. 7;
end record;
for Access_Bits'Size use Low_Level.Bitfield'Size;
for Storage_Bits use record
Read at 0 range 0 .. 0;
Write at 0 range 1 .. 1;
Persistent at 0 range 6 .. 6;
Coherent at 0 range 7 .. 7;
Dynamic_Storage at 0 range 8 .. 8;
Client_Storage at 0 range 9 .. 9;
end record;
for Storage_Bits'Size use Low_Level.Bitfield'Size;
type Buffer_Target (Kind : Enums.Buffer_Kind) is
tagged limited null record;
type Buffer is new GL_Object with record
Allocated, Mapped : Boolean := False;
end record;
Element_Array_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Element_Array_Buffer);
Pixel_Pack_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Pixel_Pack_Buffer);
Pixel_Unpack_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Pixel_Unpack_Buffer);
Uniform_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Uniform_Buffer);
Draw_Indirect_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Draw_Indirect_Buffer);
Parameter_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Parameter_Buffer);
Shader_Storage_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Shader_Storage_Buffer);
Dispatch_Indirect_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Dispatch_Indirect_Buffer);
Query_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Query_Buffer);
Atomic_Counter_Buffer : aliased constant Buffer_Target
:= Buffer_Target'(Kind => Enums.Atomic_Counter_Buffer);
end GL.Objects.Buffers;
|
-- { dg-do compile }
-- { dg-options "-g" }
package body Import1 is
procedure Create (Bounds : Arr) is
type Bound_Array is array (Bounds'Range) of Integer;
procedure Proc (Ptr : access Bound_Array);
pragma Import (C, Proc);
Temp : aliased Bound_Array;
begin
Proc (Temp'Access);
end;
end Import1;
|
package body Memory is
function "+" (Addr : Flash_Memory_Range; Offset : Unsigned_16) return Flash_Memory_Range is
begin
return Flash_Memory_Range (Unsigned_16 (Addr) + Offset);
end "+";
end Memory;
|
--
-- Uwe R. Zimmer, Australia, 2013
--
package body Generic_Protected is
protected body Monitor is
function Read return Element is (Value);
procedure Write (E : Element) is
begin
Value := E;
Touched := True;
end Write;
entry Wait_for_Update (E : out Element) when Touched is
begin
E := Value;
Touched := Wait_for_Update'Count > 0;
end Wait_for_Update;
end Monitor;
function Allocate (Value : Element := Default_Value) return Monitor_Ptr is
New_Monitor : constant Monitor_Ptr := new Monitor;
begin
New_Monitor.all.Write (Value);
return New_Monitor;
end Allocate;
end Generic_Protected;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
package body Discr8 is
procedure Make (C : out Local_T) is
Tmp : Local_T (Tag_One);
begin
C := Tmp;
end;
package Iteration is
type Message_T is
record
S : Local_T;
end record;
type Iterator_T is
record
S : Local_T;
end record;
type Access_Iterator_T is access Iterator_T;
end Iteration;
package body Iteration is
procedure Construct (Iterator : in out Access_Iterator_T;
Message : Message_T) is
begin
Iterator.S := Message.S;
end;
end Iteration;
end Discr8;
|
-- { dg-do compile }
-- { dg-options "-gnatc" }
generic
package Iface_Eq_Test.Child is
protected type PO is new Iface with
procedure Dummy;
end;
overriding function "=" (L, R : access PO) return Boolean;
end;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.