content
stringlengths 23
1.05M
|
|---|
with Gtk.Main;
with Gtk.Handlers;
with Gtk.Label;
with Gtk.Button;
with Gtk.Window;
with Glib.Main;
procedure Animation is
Scroll_Forwards : Boolean := True;
package Button_Callbacks is new Gtk.Handlers.Callback
(Gtk.Button.Gtk_Button_Record);
package Label_Timeout is new Glib.Main.Generic_Sources
(Gtk.Label.Gtk_Label);
package Window_Callbacks is new Gtk.Handlers.Return_Callback
(Gtk.Window.Gtk_Window_Record, Boolean);
-- Callback for click event
procedure On_Button_Click
(Object : access Gtk.Button.Gtk_Button_Record'Class);
-- Callback for delete event
function On_Main_Window_Delete
(Object : access Gtk.Window.Gtk_Window_Record'Class)
return Boolean;
function Scroll_Text (Data : Gtk.Label.Gtk_Label) return Boolean;
procedure On_Button_Click
(Object : access Gtk.Button.Gtk_Button_Record'Class)
is
pragma Unreferenced (Object);
begin
Scroll_Forwards := not Scroll_Forwards;
end On_Button_Click;
function On_Main_Window_Delete
(Object : access Gtk.Window.Gtk_Window_Record'Class)
return Boolean
is
pragma Unreferenced (Object);
begin
Gtk.Main.Main_Quit;
return True;
end On_Main_Window_Delete;
function Scroll_Text (Data : Gtk.Label.Gtk_Label) return Boolean is
Text : constant String := Gtk.Label.Get_Text (Data);
begin
if Scroll_Forwards then
Gtk.Label.Set_Text
(Label => Data,
Str => Text (Text'First + 1 .. Text'Last) & Text (Text'First));
else
Gtk.Label.Set_Text
(Label => Data,
Str => Text (Text'Last) & Text (Text'First .. Text'Last - 1));
end if;
return True;
end Scroll_Text;
Main_Window : Gtk.Window.Gtk_Window;
Text_Button : Gtk.Button.Gtk_Button;
Scrolling_Text : Gtk.Label.Gtk_Label;
Timeout_ID : Glib.Main.G_Source_Id;
pragma Unreferenced (Timeout_ID);
begin
Gtk.Main.Init;
Gtk.Window.Gtk_New (Window => Main_Window);
Gtk.Label.Gtk_New (Label => Scrolling_Text, Str => "Hello World! ");
Gtk.Button.Gtk_New (Button => Text_Button);
Gtk.Button.Add (Container => Text_Button, Widget => Scrolling_Text);
Button_Callbacks.Connect
(Widget => Text_Button,
Name => "clicked",
Marsh => Button_Callbacks.To_Marshaller (On_Button_Click'Access));
Timeout_ID :=
Label_Timeout.Timeout_Add
(Interval => 125,
Func => Scroll_Text'Access,
Data => Scrolling_Text);
Gtk.Window.Add (Container => Main_Window, Widget => Text_Button);
Window_Callbacks.Connect
(Widget => Main_Window,
Name => "delete_event",
Marsh => Window_Callbacks.To_Marshaller (On_Main_Window_Delete'Access));
Gtk.Window.Show_All (Widget => Main_Window);
Gtk.Main.Main;
end Animation;
|
-- { dg-do run }
procedure not_null is
type Not_Null_Int_Ptr is not null access all Integer;
generic
F : Not_Null_Int_Ptr := null;
package GPack is
end GPack;
begin
declare
pragma Warnings (Off, "*null not allowed in null-excluding objects");
package Inst_2 is new GPack (null);
pragma Warnings (On, "*null not allowed in null-excluding objects");
begin
null;
end;
exception
when Constraint_Error =>
null;
end not_null;
|
package Longest_Common_Prefix
with SPARK_Mode => On,
Initializes => A
is
type Text is array (Positive range <>) of Integer;
A : Text (1 .. 1000) := (others => 0);
function LCP (X, Y : Positive) return Natural
with
Pre => X in A'Range and Y in A'Range,
Contract_Cases => (A (X) /= A (Y) => LCP'Result = 0,
X = Y => LCP'Result = A'Last - X + 1,
others => 0 < LCP'Result),
Post => (for all J in 0 .. LCP'Result - 1 => A (X + J) = A (Y + J)
and then
(if X + LCP'Result in A'Range and Y + LCP'Result in A'Range then
A (X + LCP'Result) /= A (Y + LCP'Result)));
end Longest_Common_Prefix;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2015, 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 League.String_Vectors.Internals;
with League.Strings.Internals;
with Matreshka.Internals.Strings.Configuration;
package body League.String_Vectors is
use Matreshka.Internals.String_Vectors;
use Matreshka.Internals.Strings;
use Matreshka.Internals.Strings.Configuration;
---------
-- "=" --
---------
function "="
(Left : Universal_String_Vector;
Right : Universal_String_Vector) return Boolean
is
LD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Left.Data;
RD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Right.Data;
begin
-- Both objects shared same shared object, they are equal.
if LD = RD then
return True;
end if;
-- Objects have different length, they are not equal.
if LD.Unused /= RD.Unused then
return False;
end if;
-- Check whether all strings are equal.
for J in 0 .. LD.Unused - 1 loop
if not String_Handler.Is_Equal (LD.Value (J), RD.Value (J)) then
return False;
end if;
end loop;
return True;
end "=";
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out Universal_String_Vector) is
begin
Matreshka.Internals.String_Vectors.Reference (Self.Data);
end Adjust;
------------
-- Append --
------------
procedure Append
(Self : in out Universal_String_Vector'Class;
Item : League.Strings.Universal_String'Class) is
begin
Append (Self.Data, League.Strings.Internals.Internal (Item));
Matreshka.Internals.Strings.Reference
(League.Strings.Internals.Internal (Item));
end Append;
------------
-- Append --
------------
procedure Append
(Self : in out Universal_String_Vector'Class;
Item : Universal_String_Vector'Class) is
begin
for J in 1 .. Item.Length loop
Self.Append (Item.Element (J));
end loop;
end Append;
-----------
-- Clear --
-----------
procedure Clear (Self : in out Universal_String_Vector'Class) is
begin
Matreshka.Internals.String_Vectors.Dereference (Self.Data);
Self.Data :=
Matreshka.Internals.String_Vectors.Empty_Shared_String_Vector'Access;
end Clear;
-------------
-- Element --
-------------
function Element
(Self : Universal_String_Vector'Class;
Index : Positive) return League.Strings.Universal_String
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position >= Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
return League.Strings.Internals.Create (Self.Data.Value (Position));
end Element;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
String : League.Strings.Universal_String'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
return
Self.Length >= 1
and then Self (Self.Length)
= League.Strings.Universal_String (String);
end Ends_With;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
Vector : Universal_String_Vector'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
if Self.Length >= Vector.Length then
for J in reverse 1 .. Vector.Length loop
if Self (Self.Length - Vector.Length + J) /= Vector (J) then
return False;
end if;
end loop;
return True;
end if;
return False;
end Ends_With;
---------------
-- Ends_With --
---------------
function Ends_With
(Self : Universal_String_Vector'Class;
String : Wide_Wide_String) return Boolean is
begin
return Self.Ends_With (League.Strings.To_Universal_String (String));
end Ends_With;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Universal_String_Vector) is
begin
-- Finalize can be called more than once (as specified by language
-- standard), thus implementation should provide protection from
-- multiple finalization.
if Self.Data /= null then
Dereference (Self.Data);
end if;
end Finalize;
-----------
-- Index --
-----------
function Index
(Self : Universal_String_Vector'Class;
Pattern : League.Strings.Universal_String'Class) return Natural
is
V_D : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Self.Data;
P_D : constant not null Shared_String_Access
:= League.Strings.Internals.Internal (Pattern);
Index : Matreshka.Internals.String_Vectors.String_Vector_Index := 0;
begin
while Index < V_D.Unused loop
if String_Handler.Is_Equal (V_D.Value (Index), P_D) then
return Positive (Index + 1);
end if;
Index := Index + 1;
end loop;
return 0;
end Index;
-----------
-- Index --
-----------
function Index
(Self : Universal_String_Vector'Class;
Pattern : Wide_Wide_String) return Natural is
begin
return Self.Index (League.Strings.To_Universal_String (Pattern));
end Index;
------------
-- Insert --
------------
procedure Insert
(Self : in out Universal_String_Vector'Class;
Index : Positive;
Item : League.Strings.Universal_String'Class)
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position > Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
Matreshka.Internals.String_Vectors.Insert
(Self.Data, Position, League.Strings.Internals.Internal (Item));
end Insert;
--------------
-- Is_Empty --
--------------
function Is_Empty (Self : Universal_String_Vector'Class) return Boolean is
begin
return Self.Data.Unused = 0;
end Is_Empty;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : League.Strings.Universal_String'Class)
return League.Strings.Universal_String is
begin
return Result : League.Strings.Universal_String do
if not Self.Is_Empty then
Result.Append (Self.Element (1));
end if;
for J in 2 .. Self.Length loop
Result.Append (Separator);
Result.Append (Self.Element (J));
end loop;
end return;
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : Wide_Wide_String)
return League.Strings.Universal_String is
begin
return Self.Join (League.Strings.To_Universal_String (Separator));
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : League.Characters.Universal_Character'Class)
return League.Strings.Universal_String is
begin
return Result : League.Strings.Universal_String do
if not Self.Is_Empty then
Result.Append (Self.Element (1));
end if;
for J in 2 .. Self.Length loop
Result.Append (Separator);
Result.Append (Self.Element (J));
end loop;
end return;
end Join;
----------
-- Join --
----------
function Join
(Self : Universal_String_Vector'Class;
Separator : Wide_Wide_Character)
return League.Strings.Universal_String is
begin
return Self.Join (League.Characters.To_Universal_Character (Separator));
end Join;
------------
-- Length --
------------
function Length (Self : Universal_String_Vector'Class) return Natural is
begin
return Natural (Self.Data.Unused);
end Length;
-------------
-- Prepend --
-------------
procedure Prepend
(Self : in out Universal_String_Vector'Class;
Item : Universal_String_Vector'Class) is
begin
Matreshka.Internals.String_Vectors.Prepend (Self.Data, Item.Data);
end Prepend;
----------
-- Read --
----------
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Universal_String_Vector)
is
Aux : League.Strings.Universal_String;
Length : Natural;
begin
Natural'Read (Stream, Length);
Item.Clear;
for J in 1 .. Length loop
League.Strings.Universal_String'Read (Stream, Aux);
Item.Append (Aux);
end loop;
end Read;
-------------
-- Replace --
-------------
procedure Replace
(Self : in out Universal_String_Vector'Class;
Index : Positive;
Item : League.Strings.Universal_String'Class)
is
Position : constant String_Vector_Index
:= String_Vector_Index (Index - 1);
begin
if Position >= Self.Data.Unused then
raise Constraint_Error with "Index is out of range";
end if;
Matreshka.Internals.String_Vectors.Replace
(Self.Data, Position, League.Strings.Internals.Internal (Item));
end Replace;
-----------
-- Slice --
-----------
function Slice
(Self : Universal_String_Vector'Class;
Low : Positive;
High : Natural) return Universal_String_Vector
is
SD : constant not null
Matreshka.Internals.String_Vectors.Shared_String_Vector_Access
:= Self.Data;
TD : Matreshka.Internals.String_Vectors.Shared_String_Vector_Access;
begin
if Low > High then
-- By Ada conventions, slice is empty when Low is greater than High.
-- Actual values of Low and High is not important here.
return Empty_Universal_String_Vector;
elsif Low > Self.Length or else High > Self.Length then
-- Otherwise, both Low and High should be less or equal to Length.
raise Constraint_Error with "Index is out of range";
end if;
TD := Allocate (String_Vector_Index (High - Low + 1));
for J in String_Vector_Index (Low - 1)
.. String_Vector_Index (High - 1)
loop
Reference (SD.Value (J));
TD.Value (TD.Unused) := SD.Value (J);
TD.Unused := TD.Unused + 1;
end loop;
return League.String_Vectors.Internals.Wrap (TD);
end Slice;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
String : League.Strings.Universal_String'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
return
Self.Length >= 1
and then Self (1) = League.Strings.Universal_String (String);
end Starts_With;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
Vector : Universal_String_Vector'Class) return Boolean
is
use type League.Strings.Universal_String;
begin
if Self.Length >= Vector.Length then
for J in 1 .. Vector.Length loop
if Self (J) /= Vector (J) then
return False;
end if;
end loop;
return True;
end if;
return False;
end Starts_With;
-----------------
-- Starts_With --
-----------------
function Starts_With
(Self : Universal_String_Vector'Class;
String : Wide_Wide_String) return Boolean is
begin
return Self.Starts_With (League.Strings.To_Universal_String (String));
end Starts_With;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Universal_String_Vector) is
begin
String_Vector_Index'Write (Stream, Item.Data.Unused);
for J in 1 .. Item.Length loop
League.Strings.Universal_String'Write (Stream, Item.Element (J));
end loop;
end Write;
end League.String_Vectors;
|
-- This spec has been automatically generated from STM32L4x3.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.FPU is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Floating-point context control register
type FPCCR_Register is record
-- LSPACT
LSPACT : Boolean := False;
-- USER
USER : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- THREAD
THREAD : Boolean := False;
-- HFRDY
HFRDY : Boolean := False;
-- MMRDY
MMRDY : Boolean := False;
-- BFRDY
BFRDY : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- MONRDY
MONRDY : Boolean := False;
-- unspecified
Reserved_9_29 : HAL.UInt21 := 16#0#;
-- LSPEN
LSPEN : Boolean := False;
-- ASPEN
ASPEN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FPCCR_Register use record
LSPACT at 0 range 0 .. 0;
USER at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
THREAD at 0 range 3 .. 3;
HFRDY at 0 range 4 .. 4;
MMRDY at 0 range 5 .. 5;
BFRDY at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MONRDY at 0 range 8 .. 8;
Reserved_9_29 at 0 range 9 .. 29;
LSPEN at 0 range 30 .. 30;
ASPEN at 0 range 31 .. 31;
end record;
subtype FPCAR_ADDRESS_Field is HAL.UInt29;
-- Floating-point context address register
type FPCAR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Location of unpopulated floating-point
ADDRESS : FPCAR_ADDRESS_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FPCAR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
ADDRESS at 0 range 3 .. 31;
end record;
subtype FPSCR_RMode_Field is HAL.UInt2;
-- Floating-point status control register
type FPSCR_Register is record
-- Invalid operation cumulative exception bit
IOC : Boolean := False;
-- Division by zero cumulative exception bit.
DZC : Boolean := False;
-- Overflow cumulative exception bit
OFC : Boolean := False;
-- Underflow cumulative exception bit
UFC : Boolean := False;
-- Inexact cumulative exception bit
IXC : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- Input denormal cumulative exception bit.
IDC : Boolean := False;
-- unspecified
Reserved_8_21 : HAL.UInt14 := 16#0#;
-- Rounding Mode control field
RMode : FPSCR_RMode_Field := 16#0#;
-- Flush-to-zero mode control bit:
FZ : Boolean := False;
-- Default NaN mode control bit
DN : Boolean := False;
-- Alternative half-precision control bit
AHP : Boolean := False;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Overflow condition code flag
V : Boolean := False;
-- Carry condition code flag
C : Boolean := False;
-- Zero condition code flag
Z : Boolean := False;
-- Negative condition code flag
N : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FPSCR_Register use record
IOC at 0 range 0 .. 0;
DZC at 0 range 1 .. 1;
OFC at 0 range 2 .. 2;
UFC at 0 range 3 .. 3;
IXC at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
IDC at 0 range 7 .. 7;
Reserved_8_21 at 0 range 8 .. 21;
RMode at 0 range 22 .. 23;
FZ at 0 range 24 .. 24;
DN at 0 range 25 .. 25;
AHP at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
V at 0 range 28 .. 28;
C at 0 range 29 .. 29;
Z at 0 range 30 .. 30;
N at 0 range 31 .. 31;
end record;
subtype CPACR_CP_Field is HAL.UInt4;
-- Coprocessor access control register
type CPACR_Register is record
-- unspecified
Reserved_0_19 : HAL.UInt20 := 16#0#;
-- CP
CP : CPACR_CP_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CPACR_Register use record
Reserved_0_19 at 0 range 0 .. 19;
CP at 0 range 20 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Floting point unit
type FPU_Peripheral is record
-- Floating-point context control register
FPCCR : aliased FPCCR_Register;
-- Floating-point context address register
FPCAR : aliased FPCAR_Register;
-- Floating-point status control register
FPSCR : aliased FPSCR_Register;
end record
with Volatile;
for FPU_Peripheral use record
FPCCR at 16#0# range 0 .. 31;
FPCAR at 16#4# range 0 .. 31;
FPSCR at 16#8# range 0 .. 31;
end record;
-- Floting point unit
FPU_Periph : aliased FPU_Peripheral
with Import, Address => FPU_Base;
-- Floating point unit CPACR
type FPU_CPACR_Peripheral is record
-- Coprocessor access control register
CPACR : aliased CPACR_Register;
end record
with Volatile;
for FPU_CPACR_Peripheral use record
CPACR at 0 range 0 .. 31;
end record;
-- Floating point unit CPACR
FPU_CPACR_Periph : aliased FPU_CPACR_Peripheral
with Import, Address => FPU_CPACR_Base;
end STM32_SVD.FPU;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
with Ada.IO_Exceptions;
with Ada.Streams;
with System.Unsigned_Types;
package System.Stream_Attributes is
pragma Preelaborate;
-- required for 'Read/'Write attributes by compiler (s-stratt.ads)
type Thin_Pointer is record
P1 : Address;
end record;
pragma Suppress_Initialization (Thin_Pointer);
type Fat_Pointer is record
P1 : Address;
P2 : Address;
end record;
pragma Suppress_Initialization (Fat_Pointer);
function I_AD (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Fat_Pointer;
function I_AS (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Thin_Pointer;
function I_B (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Boolean;
function I_C (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Character;
function I_F (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Float;
function I_I (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Integer;
function I_LF (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Long_Float;
function I_LI (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Long_Integer;
function I_LLF (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Long_Long_Float;
function I_LLI (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Long_Long_Integer;
function I_LLU (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Unsigned_Types.Long_Long_Unsigned;
function I_LU (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Unsigned_Types.Long_Unsigned;
function I_SF (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Short_Float;
function I_SI (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Short_Integer;
function I_SSI (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Short_Short_Integer;
function I_SSU (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Unsigned_Types.Short_Short_Unsigned;
function I_SU (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Unsigned_Types.Short_Unsigned;
function I_U (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Unsigned_Types.Unsigned;
function I_WC (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Wide_Character;
function I_WWC (Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Wide_Wide_Character;
pragma Inline (I_AD);
pragma Inline (I_AS);
pragma Inline (I_B);
pragma Inline (I_C);
pragma Inline (I_F);
pragma Inline (I_I);
pragma Inline (I_LF);
pragma Inline (I_LI);
pragma Inline (I_LLF);
pragma Inline (I_LLI);
pragma Inline (I_LLU);
pragma Inline (I_LU);
pragma Inline (I_SF);
pragma Inline (I_SI);
pragma Inline (I_SSI);
pragma Inline (I_SSU);
pragma Inline (I_SU);
pragma Inline (I_U);
pragma Inline (I_WC);
pragma Inline (I_WWC);
procedure W_AD (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Fat_Pointer);
procedure W_AS (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Thin_Pointer);
procedure W_B (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Boolean);
procedure W_C (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Character);
procedure W_F (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Float);
procedure W_I (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Integer);
procedure W_LF (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Long_Float);
procedure W_LI (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Long_Integer);
procedure W_LLF (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Long_Long_Float);
procedure W_LLI (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Long_Long_Integer);
procedure W_LLU (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Unsigned_Types.Long_Long_Unsigned);
procedure W_LU (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Unsigned_Types.Long_Unsigned);
procedure W_SF (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Short_Float);
procedure W_SI (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Short_Integer);
procedure W_SSI (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Short_Short_Integer);
procedure W_SSU (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Unsigned_Types.Short_Short_Unsigned);
procedure W_SU (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Unsigned_Types.Short_Unsigned);
procedure W_U (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Unsigned_Types.Unsigned);
procedure W_WC (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Character);
procedure W_WWC (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_Character);
pragma Inline (W_AD);
pragma Inline (W_AS);
pragma Inline (W_B);
pragma Inline (W_C);
pragma Inline (W_F);
pragma Inline (W_I);
pragma Inline (W_LF);
pragma Inline (W_LI);
pragma Inline (W_LLF);
pragma Inline (W_LLI);
pragma Inline (W_LLU);
pragma Inline (W_LU);
pragma Inline (W_SF);
pragma Inline (W_SI);
pragma Inline (W_SSI);
pragma Inline (W_SSU);
pragma Inline (W_SU);
pragma Inline (W_U);
pragma Inline (W_WC);
pragma Inline (W_WWC);
-- required for default 'Read/'Write attributes by compiler (s-stratt.ads)
-- in original libgnat, Block_IO_OK is a function, but constant is ok (?)
Block_IO_OK : constant Boolean := True;
-- exceptions
End_Error : exception
renames Ada.IO_Exceptions.End_Error;
end System.Stream_Attributes;
|
with Ada.Streams;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
package TF_INTERFACE_1 is
type CF_INTERFACE_1 is interface;
procedure P_PROCEDURE_1 (This : in out CF_INTERFACE_1)
is abstract;
procedure Read (Stream : not null access ada.Streams.Root_stream_Type'Class;
Item : out CF_INTERFACE_1) is null;
for CF_INTERFACE_1'Read use Read;
procedure Write (Stream : not null access ada.Streams.Root_stream_Type'Class;
Item : CF_INTERFACE_1) is null;
for CF_INTERFACE_1'Write use Write;
procedure Get_It (Handle : Stream_Access; It : out CF_Interface_1'class);
end TF_INTERFACE_1;
|
pragma License (Unrestricted); -- BSD 3-Clause
-- translated unit from dSFMT (test.c)
--
-- Copyright (c) 2007, 2008, 2009 Mutsuo Saito, Makoto Matsumoto
-- and Hiroshima University.
-- Copyright (c) 2011, 2002 Mutsuo Saito, Makoto Matsumoto, Hiroshima
-- University and The University of Tokyo.
-- All rights reserved.
--
--
-- Ada version by yt
--
with Ada.Command_Line;
with Ada.Execution_Time;
with Ada.Formatting;
with Ada.Integer_Text_IO;
with Ada.Long_Float_Text_IO;
with Ada.Numerics.dSFMT_19937;
-- with Ada.Numerics.dSFMT_216091;
with Ada.Real_Time;
with Ada.Text_IO;
with Interfaces;
procedure random_dsfmt is
use Ada.Numerics.dSFMT_19937;
-- use Ada.Numerics.dSFMT_216091;
use type Ada.Execution_Time.CPU_Time;
use type Ada.Real_Time.Time_Span;
use type Interfaces.Unsigned_64;
exit_1 : exception;
dsfmt_global_data : aliased Generator;
DSFMT_N : constant Natural := (DSFMT_MEXP - 128) / 104 + 1;
NUM_RANDS : constant := 50000;
TIC_COUNT : constant := 2000;
dummy : Long_Float_Array (
0 .. (NUM_RANDS / 2 + 1) * 2 - 1); -- w128_t to Long_Float
type genrand_t is access function return Long_Float;
type st_genrand_t is
access function (dsfmt : aliased in out Generator) return Long_Float;
type fill_array_t is access procedure (the_array : out Long_Float_Array);
type st_fill_array_t is
access procedure (
dsfmt : aliased in out Generator;
the_array : out Long_Float_Array);
procedure test_co;
procedure test_oc;
procedure test_oo;
procedure test_12;
procedure test_seq_co;
procedure test_seq_oc;
procedure test_seq_oo;
procedure test_seq_12;
pragma No_Inline (test_co);
pragma No_Inline (test_oc);
pragma No_Inline (test_oo);
pragma No_Inline (test_12);
pragma No_Inline (test_seq_co);
pragma No_Inline (test_seq_oc);
pragma No_Inline (test_seq_oo);
pragma No_Inline (test_seq_12);
procedure check (
range_str : in String; -- start_mess
genrand : in genrand_t;
fill_array : in fill_array_t;
st_genrand : in st_genrand_t;
st_fill_array : in st_fill_array_t;
seed : in Unsigned_32;
print_size : in Integer); -- n
procedure check_ar (
range_str : in String; -- start_mess
genrand : in genrand_t;
fill_array : in fill_array_t;
st_genrand : in st_genrand_t;
st_fill_array : in st_fill_array_t;
print_size : in Integer); -- n
-- not inline wrapper functions for check()
function s_genrand_close_open return Long_Float is
begin
return Random_0_To_Less_Than_1 (dsfmt_global_data);
end s_genrand_close_open;
function s_genrand_open_close return Long_Float is
begin
return Random_Greater_Than_0_To_1 (dsfmt_global_data);
end s_genrand_open_close;
function s_genrand_open_open return Long_Float is
begin
return Random_Greater_Than_0_To_Less_Than_1 (dsfmt_global_data);
end s_genrand_open_open;
function s_genrand_close1_open2 return Long_Float is
begin
return Random_1_To_Less_Than_2 (dsfmt_global_data);
end s_genrand_close1_open2;
function sst_genrand_close_open (dsfmt : aliased in out Generator)
return Long_Float is
begin
return Random_0_To_Less_Than_1 (dsfmt);
end sst_genrand_close_open;
function sst_genrand_open_close (dsfmt : aliased in out Generator)
return Long_Float is
begin
return Random_Greater_Than_0_To_1 (dsfmt);
end sst_genrand_open_close;
function sst_genrand_open_open (dsfmt : aliased in out Generator)
return Long_Float is
begin
return Random_Greater_Than_0_To_Less_Than_1 (dsfmt);
end sst_genrand_open_open;
function sst_genrand_close1_open2 (dsfmt : aliased in out Generator)
return Long_Float is
begin
return Random_1_To_Less_Than_2 (dsfmt);
end sst_genrand_close1_open2;
procedure s_fill_array_close_open (the_array : out Long_Float_Array) is
begin
Fill_Random_0_To_Less_Than_1 (dsfmt_global_data, the_array);
end s_fill_array_close_open;
procedure s_fill_array_open_close (the_array : out Long_Float_Array) is
begin
Fill_Random_Greater_Than_0_To_1 (dsfmt_global_data, the_array);
end s_fill_array_open_close;
procedure s_fill_array_open_open (the_array : out Long_Float_Array) is
begin
Fill_Random_Greater_Than_0_To_Less_Than_1 (dsfmt_global_data, the_array);
end s_fill_array_open_open;
procedure s_fill_array_close1_open2 (the_array : out Long_Float_Array) is
begin
Fill_Random_1_To_Less_Than_2 (dsfmt_global_data, the_array);
end s_fill_array_close1_open2;
procedure sst_fill_array_close_open (
dsfmt : aliased in out Generator;
the_array : out Long_Float_Array) is
begin
Fill_Random_0_To_Less_Than_1 (dsfmt, the_array);
end sst_fill_array_close_open;
procedure sst_fill_array_open_close (
dsfmt : aliased in out Generator;
the_array : out Long_Float_Array) is
begin
Fill_Random_Greater_Than_0_To_1 (dsfmt, the_array);
end sst_fill_array_open_close;
procedure sst_fill_array_open_open (
dsfmt : aliased in out Generator;
the_array : out Long_Float_Array) is
begin
Fill_Random_Greater_Than_0_To_Less_Than_1 (dsfmt, the_array);
end sst_fill_array_open_open;
procedure sst_fill_array_close1_open2 (
dsfmt : aliased in out Generator;
the_array : out Long_Float_Array) is
begin
Fill_Random_1_To_Less_Than_2 (dsfmt, the_array);
end sst_fill_array_close1_open2;
type union_W64_T_Tag is (u, d);
pragma Discard_Names (union_W64_T_Tag);
type union_W64_T (Unchecked_Tag : union_W64_T_Tag := d) is record
case Unchecked_Tag is
when u =>
u : Interfaces.Unsigned_64;
when d =>
d : Long_Float;
end case;
end record;
pragma Unchecked_Union (union_W64_T);
-- printf("%1.15f(%08"PRIx64")", d, u);
procedure Put (Item : in union_W64_T) is
function Image_08PRIx64 is
new Ada.Formatting.Modular_Image (
Interfaces.Unsigned_64,
Form => Ada.Formatting.Simple,
Signs => Ada.Formatting.Triming_Unsign_Marks,
Base => 16,
Set => Ada.Formatting.Lower_Case,
Digits_Width => 8);
begin
Ada.Long_Float_Text_IO.Put (Item.d, Aft => 15);
Ada.Text_IO.Put ("(");
Ada.Text_IO.Put (Image_08PRIx64 (Item.u));
Ada.Text_IO.Put (")");
end Put;
procedure check (
range_str : in String;
genrand : in genrand_t;
fill_array : in fill_array_t;
st_genrand : in st_genrand_t;
st_fill_array : in st_fill_array_t;
seed : in Unsigned_32;
print_size : in Integer)
is
lsize : constant Natural := DSFMT_N * 2 + 2;
the_array : Long_Float_Array renames dummy;
little : Long_Float_Array (0 .. lsize - 1); -- w128_t to Long_Float
r, r_st : union_W64_T;
dsfmt : aliased Generator;
begin
Ada.Text_IO.Put ("generated randoms ");
Ada.Text_IO.Put (range_str);
Ada.Text_IO.New_Line;
Reset (dsfmt_global_data, Integer (seed));
fill_array (little (0 .. lsize - 1));
fill_array (the_array (0 .. 5000 - 1));
Reset (dsfmt_global_data, Integer (seed));
Reset (dsfmt, Integer (seed));
for i in 0 .. lsize - 1 loop
r.d := genrand.all;
r_st.d := st_genrand (dsfmt);
if r.u /= r_st.u
or else r.u /= union_W64_T'(d, d => little (i)).u
then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i, Width => 1);
Ada.Text_IO.Put (": r = ");
Put (r);
Ada.Text_IO.Put (", st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => little (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
if i < print_size then
Ada.Long_Float_Text_IO.Put (little (i), Aft => 15);
Ada.Text_IO.Put (" ");
if i rem 4 = 3 then
Ada.Text_IO.New_Line;
end if;
end if;
end loop;
for i in 0 .. 5000 - 1 loop
r.d := genrand.all;
if r.u /= union_W64_T'(d, d => the_array (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i + lsize, Width => 1);
Ada.Text_IO.Put (": r = ");
Put (r);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => the_array (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
if i + lsize < print_size then
Ada.Long_Float_Text_IO.Put (the_array (i), Aft => 15);
Ada.Text_IO.Put (" ");
if (i + lsize) rem 4 = 3 then
Ada.Text_IO.New_Line;
end if;
end if;
end loop;
Reset (dsfmt, Integer (seed));
st_fill_array (dsfmt, little (0 .. lsize - 1));
st_fill_array (dsfmt, the_array (0 .. 5000 - 1));
Reset (dsfmt, Integer (seed));
for i in 0 .. lsize - 1 loop
r_st.d := st_genrand (dsfmt);
if r_st.u /= union_W64_T'(d, d => little (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i, Width => 1);
Ada.Text_IO.Put (": st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => little (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
end loop;
for i in 0 .. 5000 - 1 loop
r_st.d := st_genrand (dsfmt);
if r_st.u /= union_W64_T'(d, d => the_array (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i + lsize, Width => 1);
Ada.Text_IO.Put (": st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => the_array (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
end loop;
end check;
procedure check_ar (
range_str : in String;
genrand : in genrand_t;
fill_array : in fill_array_t;
st_genrand : in st_genrand_t;
st_fill_array : in st_fill_array_t;
print_size : in Integer)
is
lsize : constant Natural := DSFMT_N * 2 + 2;
the_array : Long_Float_Array renames dummy;
little : Long_Float_Array (0 .. lsize - 1); -- w128_t to Long_Float
r, r_st : union_W64_T;
dsfmt : aliased Generator;
ar : Unsigned_32_Array (0 .. 3) := (1, 2, 3, 4);
begin
Ada.Text_IO.Put ("generated randoms ");
Ada.Text_IO.Put (range_str);
Ada.Text_IO.New_Line;
Reset (dsfmt_global_data, Initialize (ar));
fill_array (little (0 .. lsize - 1));
fill_array (the_array (0 .. 5000 - 1));
Reset (dsfmt_global_data, Initialize (ar));
Reset (dsfmt, Initialize (ar));
for i in 0 .. lsize - 1 loop
r.d := genrand.all;
r_st.d := st_genrand.all (dsfmt);
if r.u /= r_st.u
or else r.u /= union_W64_T'(d, d => little (i)).u
then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i, Width => 1);
Ada.Text_IO.Put (": r = ");
Put (r);
Ada.Text_IO.Put (", st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => little (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
if i < print_size then
Ada.Long_Float_Text_IO.Put (little (i), Aft => 15);
Ada.Text_IO.Put (" ");
if i rem 4 = 3 then
Ada.Text_IO.New_Line;
end if;
end if;
end loop;
for i in 0 .. 5000 - 1 loop
r.d := genrand.all;
if r.u /= union_W64_T'(d, d => the_array (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i + lsize, Width => 1);
Ada.Text_IO.Put (": r = ");
Put (r);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => the_array (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
if i + lsize < print_size then
Ada.Long_Float_Text_IO.Put (the_array (i), Aft => 15);
Ada.Text_IO.Put (" ");
if (i + lsize) rem 4 = 3 then
Ada.Text_IO.New_Line;
end if;
end if;
end loop;
Reset (dsfmt, Initialize (ar));
st_fill_array (dsfmt, little (0 .. lsize - 1));
st_fill_array (dsfmt, the_array (0 .. 5000 - 1));
Reset (dsfmt, Initialize (ar));
for i in 0 .. lsize - 1 loop
r_st.d := st_genrand (dsfmt);
if r_st.u /= union_W64_T'(d, d => little (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i, Width => 1);
Ada.Text_IO.Put (": st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => little (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
end loop;
for i in 0 .. 5000 - 1 loop
r_st.d := st_genrand (dsfmt);
if r_st.u /= union_W64_T'(d, d => the_array (i)).u then
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (range_str);
Ada.Text_IO.Put (" mismatch i = ");
Ada.Integer_Text_IO.Put (i + lsize, Width => 1);
Ada.Text_IO.Put (": st = ");
Put (r_st);
Ada.Text_IO.Put (", array = ");
Put (union_W64_T'(d, d => the_array (i)));
Ada.Text_IO.New_Line;
raise exit_1;
end if;
end loop;
end check_ar;
procedure test_co is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- dsfmt_gv_fill_array_close_open(array, NUM_RANDS);
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- printf("GL BLOCK [0, 1) AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
Fill_Random_0_To_Less_Than_1 (
dsfmt,
the_array (0 .. NUM_RANDS - 1));
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
Ada.Text_IO.Put ("ST BLOCK [0, 1) AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
end test_co;
procedure test_oc is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- dsfmt_gv_fill_array_open_close(array, NUM_RANDS);
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- printf("GL BLOCK (0, 1] AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
Fill_Random_Greater_Than_0_To_1 (
dsfmt,
the_array (0 .. NUM_RANDS - 1));
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
Ada.Text_IO.Put ("ST BLOCK (0, 1] AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
end test_oc;
procedure test_oo is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- dsfmt_gv_fill_array_open_open(array, NUM_RANDS);
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- printf("GL BLOCK (0, 1) AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
Fill_Random_Greater_Than_0_To_Less_Than_1 (
dsfmt,
the_array (0 .. NUM_RANDS - 1));
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
Ada.Text_IO.Put ("ST BLOCK (0, 1) AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
end test_oo;
procedure test_12 is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- dsfmt_gv_fill_array_close1_open2(array, NUM_RANDS);
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- printf("GL BLOCK [1, 2) AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
Fill_Random_1_To_Less_Than_2 (
dsfmt,
the_array (0 .. NUM_RANDS - 1));
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
Ada.Text_IO.Put ("ST BLOCK [1, 2) AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
end test_12;
procedure test_seq_co is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
r : Long_Float;
total : Long_Float := 0.0;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- r = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- r += dsfmt_gv_genrand_close_open();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- total = r;
-- printf("GL SEQ [0, 1) 1 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- array[k] = dsfmt_gv_genrand_close_open();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- for (k = 0; k < NUM_RANDS; k++) {
-- total += array[k];
-- }
-- printf("GL SEQ [0, 1) 2 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
r := 0.0;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
r := r + Random_0_To_Less_Than_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
total := r;
Ada.Text_IO.Put ("ST SEQ [0, 1) 1 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 ..TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
the_array (k) := Random_0_To_Less_Than_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
for k in 0 .. NUM_RANDS - 1 loop
total := total + the_array (k);
end loop;
Ada.Text_IO.Put ("ST SEQ [0, 1) 2 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("total = ");
Ada.Long_Float_Text_IO.Put (total);
Ada.Text_IO.New_Line;
end test_seq_co;
procedure test_seq_oc is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
r : Long_Float;
total : Long_Float := 0.0;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- r = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- r += dsfmt_gv_genrand_open_close();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- total = r;
-- printf("GL SEQ (0, 1] 1 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- array[k] = dsfmt_gv_genrand_open_close();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- for (k = 0; k < NUM_RANDS; k++) {
-- total += array[k];
-- }
-- printf("GL SEQ (0, 1] 2 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
r := 0.0;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
r := r + Random_Greater_Than_0_To_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
total := r;
Ada.Text_IO.Put ("ST SEQ (0, 1] 1 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 ..TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
the_array (k) := Random_Greater_Than_0_To_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
for k in 0 .. NUM_RANDS - 1 loop
total := total + the_array (k);
end loop;
Ada.Text_IO.Put ("ST SEQ (0, 1] 2 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("total = ");
Ada.Long_Float_Text_IO.Put (total);
Ada.Text_IO.New_Line;
end test_seq_oc;
procedure test_seq_oo is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
r : Long_Float;
total : Long_Float := 0.0;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- r = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- r += dsfmt_gv_genrand_open_open();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- total = r;
-- printf("GL SEQ (0, 1) 1 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- array[k] = dsfmt_gv_genrand_open_open();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- for (k = 0; k < NUM_RANDS; k++) {
-- total += array[k];
-- }
-- printf("GL SEQ (0, 1) 2 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
r := 0.0;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
r := r + Random_Greater_Than_0_To_Less_Than_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
total := r;
Ada.Text_IO.Put ("ST SEQ (0, 1) 1 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 ..TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
the_array (k) := Random_Greater_Than_0_To_Less_Than_1 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
for k in 0 .. NUM_RANDS - 1 loop
total := total + the_array (k);
end loop;
Ada.Text_IO.Put ("ST SEQ (0, 1) 2 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("total = ");
Ada.Long_Float_Text_IO.Put (total);
Ada.Text_IO.New_Line;
end test_seq_oo;
procedure test_seq_12 is
clo : Ada.Execution_Time.CPU_Time;
sum : Ada.Real_Time.Time_Span;
the_array : Long_Float_Array renames dummy;
r : Long_Float;
total : Long_Float := 0.0;
dsfmt : aliased Generator;
begin
-- #if 0
-- dsfmt_gv_init_gen_rand(1234);
-- sum = 0;
-- r = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- r += dsfmt_gv_genrand_close1_open2();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- total = r;
-- printf("GL SEQ [1, 2) 1 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- sum = 0;
-- for (i = 0; i < 10; i++) {
-- clo = clock();
-- for (j = 0; j < TIC_COUNT; j++) {
-- for (k = 0; k < NUM_RANDS; k++) {
-- array[k] = dsfmt_gv_genrand_close1_open2();
-- }
-- }
-- clo = clock() - clo;
-- sum += clo;
-- }
-- for (k = 0; k < NUM_RANDS; k++) {
-- total += array[k];
-- }
-- printf("GL SEQ [1, 2) 2 AVE:%4"PRIu64"ms.\n",
-- (sum * 100) / CLOCKS_PER_SEC);
-- #endif
Reset (dsfmt_global_data, 1234);
sum := Ada.Real_Time.Time_Span_Zero;
r := 0.0;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 .. TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
r := r + Random_1_To_Less_Than_2 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
total := r;
Ada.Text_IO.Put ("ST SEQ [1, 2) 1 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
sum := Ada.Real_Time.Time_Span_Zero;
for i in 0 .. 10 - 1 loop
clo := Ada.Execution_Time.Clock;
for j in 0 ..TIC_COUNT - 1 loop
for k in 0 .. NUM_RANDS - 1 loop
the_array (k) := Random_1_To_Less_Than_2 (dsfmt);
end loop;
end loop;
sum := sum + (Ada.Execution_Time.Clock - clo);
end loop;
for k in 0 .. NUM_RANDS - 1 loop
total := total + the_array (k);
end loop;
Ada.Text_IO.Put ("ST SEQ [1, 2) 2 AVE:");
Ada.Integer_Text_IO.Put (Integer (Ada.Real_Time.To_Duration (sum * 100)),
Width => 4);
Ada.Text_IO.Put ("ms.");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("total = ");
Ada.Long_Float_Text_IO.Put (total);
Ada.Text_IO.New_Line;
end test_seq_12;
begin
Ada.Long_Float_Text_IO.Default_Fore := 0;
Ada.Long_Float_Text_IO.Default_Aft := 6; -- default of "%f"
Ada.Long_Float_Text_IO.Default_Exp := 0;
if Ada.Command_Line.Argument_Count >= 1
and then Ada.Command_Line.Argument (1) = "-s"
then
Ada.Text_IO.Put ("consumed time for generating ");
Ada.Integer_Text_IO.Put (NUM_RANDS * TIC_COUNT, Width => 1);
Ada.Text_IO.Put (" randoms.");
Ada.Text_IO.New_Line;
test_co;
test_oc;
test_oo;
test_12;
test_seq_co;
test_seq_oc;
test_seq_oo;
test_seq_12;
else
Ada.Text_IO.Put_Line (Id);
Ada.Text_IO.Put ("init_gen_rand(0) ");
check (
"[1, 2)",
s_genrand_close1_open2'Access,
s_fill_array_close1_open2'Access,
sst_genrand_close1_open2'Access,
sst_fill_array_close1_open2'Access,
0,
1000);
for i in 0 .. 19 loop
Ada.Text_IO.Put ("init_gen_rand(");
Ada.Integer_Text_IO.Put (i, Width => 1);
Ada.Text_IO.Put (") ");
case i rem 4 is
when 0 =>
check (
"[0, 1)",
s_genrand_close_open'Access,
s_fill_array_close_open'Access,
sst_genrand_close_open'Access,
sst_fill_array_close_open'Access,
Unsigned_32'Mod (i),
12);
when 1 =>
check (
"(0, 1]",
s_genrand_open_close'Access,
s_fill_array_open_close'Access,
sst_genrand_open_close'Access,
sst_fill_array_open_close'Access,
Unsigned_32'Mod (i),
12);
when 2 =>
check (
"(0, 1)",
s_genrand_open_open'Access,
s_fill_array_open_open'Access,
sst_genrand_open_open'Access,
sst_fill_array_open_open'Access,
Unsigned_32'Mod (i),
12);
when others =>
check (
"[1, 2)",
s_genrand_close1_open2'Access,
s_fill_array_close1_open2'Access,
sst_genrand_close1_open2'Access,
sst_fill_array_close1_open2'Access,
Unsigned_32'Mod (i),
12);
end case;
end loop;
Ada.Text_IO.Put ("init_by_array {1, 2, 3, 4} ");
check_ar (
"[1, 2)",
s_genrand_close1_open2'Access,
s_fill_array_close1_open2'Access,
sst_genrand_close1_open2'Access,
sst_fill_array_close1_open2'Access,
1000);
end if;
exception
when exit_1 =>
Ada.Command_Line.Set_Exit_Status (1);
end random_dsfmt;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with AdaBase.Connection.Base.SQLite;
with AdaBase.Bindings.SQLite;
with Ada.Containers.Vectors;
package AdaBase.Statement.Base.SQLite is
package ACS renames AdaBase.Connection.Base.SQLite;
package BND renames AdaBase.Bindings.SQLite;
package AC renames Ada.Containers;
type SQLite_statement (type_of_statement : Stmt_Type;
log_handler : ALF.LogFacility_access;
sqlite_conn : ACS.SQLite_Connection_Access;
initial_sql : SQL_Access;
con_error_mode : Error_Modes;
con_case_mode : Case_Modes;
con_max_blob : BLOB_Maximum)
is new Base_Statement and AIS.iStatement with private;
type SQLite_statement_access is access all SQLite_statement;
overriding
function column_count (Stmt : SQLite_statement) return Natural;
overriding
function last_insert_id (Stmt : SQLite_statement) return Trax_ID;
overriding
function last_sql_state (Stmt : SQLite_statement) return SQL_State;
overriding
function last_driver_code (Stmt : SQLite_statement) return Driver_Codes;
overriding
function last_driver_message (Stmt : SQLite_statement) return String;
overriding
procedure discard_rest (Stmt : out SQLite_statement);
overriding
function execute (Stmt : out SQLite_statement) return Boolean;
overriding
function execute (Stmt : out SQLite_statement; parameters : String;
delimiter : Character := '|') return Boolean;
overriding
function rows_returned (Stmt : SQLite_statement) return Affected_Rows;
overriding
function column_name (Stmt : SQLite_statement; index : Positive)
return String;
overriding
function column_table (Stmt : SQLite_statement; index : Positive)
return String;
overriding
function column_native_type (Stmt : SQLite_statement; index : Positive)
return field_types;
overriding
function fetch_next (Stmt : out SQLite_statement) return ARS.Datarow;
overriding
function fetch_all (Stmt : out SQLite_statement) return ARS.Datarow_Set;
overriding
function fetch_bound (Stmt : out SQLite_statement) return Boolean;
overriding
procedure fetch_next_set (Stmt : out SQLite_statement;
data_present : out Boolean;
data_fetched : out Boolean);
private
type column_info is record
table : CT.Text;
field_name : CT.Text;
field_type : field_types;
null_possible : Boolean;
sqlite_type : BND.enum_field_types;
end record;
type sqlite_canvas is record
buffer_binary : BND.ICS.char_array_access := null;
buffer_text : BND.ICS.chars_ptr := BND.ICS.Null_Ptr;
end record;
type step_result_type is (unset, data_pulled, progam_complete, error_seen);
package VColumns is new AC.Vectors (Index_Type => Positive,
Element_Type => column_info);
package VCanvas is new AC.Vectors (Index_Type => Positive,
Element_Type => sqlite_canvas);
type SQLite_statement (type_of_statement : Stmt_Type;
log_handler : ALF.LogFacility_access;
sqlite_conn : ACS.SQLite_Connection_Access;
initial_sql : SQL_Access;
con_error_mode : Error_Modes;
con_case_mode : Case_Modes;
con_max_blob : BLOB_Maximum)
is new Base_Statement and AIS.iStatement with
record
stmt_handle : aliased BND.sqlite3_stmt_Access := null;
step_result : step_result_type := unset;
assign_counter : Natural := 0;
num_columns : Natural := 0;
column_info : VColumns.Vector;
bind_canvas : VCanvas.Vector;
sql_final : SQL_Access;
end record;
procedure log_problem
(statement : SQLite_statement;
category : Log_Category;
message : String;
pull_codes : Boolean := False;
break : Boolean := False);
procedure initialize (Object : in out SQLite_statement);
procedure Adjust (Object : in out SQLite_statement);
procedure finalize (Object : in out SQLite_statement);
procedure scan_column_information (Stmt : out SQLite_statement);
procedure reclaim_canvas (Stmt : out SQLite_statement);
function seems_like_bit_string (candidate : CT.Text) return Boolean;
function private_execute (Stmt : out SQLite_statement) return Boolean;
function construct_bind_slot (Stmt : SQLite_statement; marker : Positive)
return sqlite_canvas;
procedure free_binary is new Ada.Unchecked_Deallocation
(BND.IC.char_array, BND.ICS.char_array_access);
end AdaBase.Statement.Base.SQLite;
|
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 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 --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser 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 --
-- --
--------------------------------------------------------------------------------
-- @brief OS events and types. Abstract task definition.
-- $Author$
-- $Date$
-- $Revision$
with Kernel; use Kernel;
with System; use System;
with System.Unsigned_Types; use System.Unsigned_Types;
with Ada.Unchecked_Conversion;
package RASCAL.OS is
type Event_Type is (Wimp,Message,Toolbox);
type Event_Listener (K : Event_Type) is abstract tagged record
Kind : Event_Type := K;
end record;
type Event_Pointer is access all Event_Listener'Class;
procedure Handle (The : in Event_Listener) is abstract;
type Byte is mod 2**8;
type Wimp_Handle_Type is new Integer;
type Icon_Handle_Type is new Integer;
type Reason_Event_Code_Type is new System.Unsigned_Types.Unsigned;
Reason_Event_NullReason : constant Reason_Event_Code_Type := 0;
Reason_Event_RedrawWindow : constant Reason_Event_Code_Type := 1;
Reason_Event_OpenWindow : constant Reason_Event_Code_Type := 2;
Reason_Event_CloseWindow : constant Reason_Event_Code_Type := 3;
Reason_Event_PointerLeavingWindow : constant Reason_Event_Code_Type := 4;
Reason_Event_PointerEnteringWindow : constant Reason_Event_Code_Type := 5;
Reason_Event_MouseClick : constant Reason_Event_Code_Type := 6;
Reason_Event_UserDrag : constant Reason_Event_Code_Type := 7;
Reason_Event_KeyPressed : constant Reason_Event_Code_Type := 8;
Reason_Event_MenuSelection : constant Reason_Event_Code_Type := 9;
Reason_Event_ScrollRequest : constant Reason_Event_Code_Type := 10;
Reason_Event_LoseCaret : constant Reason_Event_Code_Type := 11;
Reason_Event_GainCaret : constant Reason_Event_Code_Type := 12;
Reason_Event_PollWordNonZero : constant Reason_Event_Code_Type := 13;
Reason_Event_UserMessage : constant Reason_Event_Code_Type := 17;
Reason_Event_UserMessageRecorded : constant Reason_Event_Code_Type := 18;
Reason_Event_UserMessageAcknowledge : constant Reason_Event_Code_Type := 19;
Reason_Event_ToolboxEvent : constant Reason_Event_Code_Type := 16#200#;
type Wimp_EventListener (E : Reason_Event_Code_Type;
W : Wimp_Handle_Type;
I : Icon_Handle_Type) is abstract new Event_Listener(Wimp) with
record
Event_Code : Reason_Event_Code_Type := E;
Window : Wimp_Handle_Type := W;
Icon : Icon_Handle_Type := I;
end record;
type Message_Event_Code_Type is new System.Unsigned_Types.Unsigned;
Message_Event_Quit : constant Message_Event_Code_Type := 0;
Message_Event_DataSave : constant Message_Event_Code_Type := 1;
Message_Event_DataSaveAck : constant Message_Event_Code_Type := 2;
Message_Event_DataLoad : constant Message_Event_Code_Type := 3;
Message_Event_DataLoadAck : constant Message_Event_Code_Type := 4;
Message_Event_DataOpen : constant Message_Event_Code_Type := 5;
Message_Event_RAMFetch : constant Message_Event_Code_Type := 6;
Message_Event_RAMTransmit : constant Message_Event_Code_Type := 7;
Message_Event_PreQuit : constant Message_Event_Code_Type := 8;
Message_Event_PaletteChange : constant Message_Event_Code_Type := 9;
Message_Event_SaveDesktop : constant Message_Event_Code_Type := 10;
Message_Event_DeviceClaim : constant Message_Event_Code_Type := 11;
Message_Event_DeviceInUse : constant Message_Event_Code_Type := 12;
Message_Event_DataSaved : constant Message_Event_Code_Type := 13;
Message_Event_Shutdown : constant Message_Event_Code_Type := 14;
Message_Event_FilerOpenDir : constant Message_Event_Code_Type := 16#400#;
Message_Event_FilerCloseDir : constant Message_Event_Code_Type := 16#401#;
Message_Event_FilerOpenDirAt : constant Message_Event_Code_Type := 16#402#;
Message_Event_FilerSelectionDirectory: constant Message_Event_Code_Type := 16#403#;
Message_Event_FilerAddSelection : constant Message_Event_Code_Type := 16#404#;
Message_Event_FilerAction : constant Message_Event_Code_Type := 16#405#;
Message_Event_FilerControlAction : constant Message_Event_Code_Type := 16#406#;
Message_Event_FilerSelection : constant Message_Event_Code_Type := 16#407#;
Message_Event_AlarmSet : constant Message_Event_Code_Type := 16#500#;
Message_Event_AlarmGoneOff : constant Message_Event_Code_Type := 16#501#;
Message_Event_HelpEnable : constant Message_Event_Code_Type := 16#504#;
Message_Event_Notify : constant Message_Event_Code_Type := 16#40040#;
Message_Event_MenuWarning : constant Message_Event_Code_Type := 16#400c0#;
Message_Event_ModeChange : constant Message_Event_Code_Type := 16#400c1#;
Message_Event_TaskInitialise : constant Message_Event_Code_Type := 16#400c2#;
Message_Event_TaskCloseDown : constant Message_Event_Code_Type := 16#400c3#;
Message_Event_SlotSize : constant Message_Event_Code_Type := 16#400c4#;
Message_Event_SetSlot : constant Message_Event_Code_Type := 16#400c5#;
Message_Event_TaskNameRq : constant Message_Event_Code_Type := 16#400c6#;
Message_Event_TaskNameIs : constant Message_Event_Code_Type := 16#400c7#;
Message_Event_TaskStarted : constant Message_Event_Code_Type := 16#400c8#;
Message_Event_MenusDeleted : constant Message_Event_Code_Type := 16#400c9#;
Message_Event_Iconize : constant Message_Event_Code_Type := 16#40c10#;
Message_Event_IconizeAt : constant Message_Event_Code_Type := 16#400D0#;
Message_Event_WindowInfo : constant Message_Event_Code_Type := 16#40c11#;
Message_Event_WindowClosed : constant Message_Event_Code_Type := 16#40c12#;
Message_Event_FontChanged : constant Message_Event_Code_Type := 16#400CF#;
Message_Event_PrintFile : constant Message_Event_Code_Type := 16#80140#;
Message_Event_WillPrint : constant Message_Event_Code_Type := 16#80141#;
Message_Event_PrintSave : constant Message_Event_Code_Type := 16#80142#;
Message_Event_PrintInit : constant Message_Event_Code_Type := 16#80143#;
Message_Event_PrintError : constant Message_Event_Code_Type := 16#80144#;
Message_Event_PrintTypeOdd : constant Message_Event_Code_Type := 16#80145#;
Message_Event_PrintTypeKnown : constant Message_Event_Code_Type := 16#80146#;
Message_Event_SetPrinter : constant Message_Event_Code_Type := 16#80147#;
Message_Event_PSPrinterQuery : constant Message_Event_Code_Type := 16#8014c#;
Message_Event_PSPrinterAck : constant Message_Event_Code_Type := 16#8014d#;
Message_Event_PSPrinterModified : constant Message_Event_Code_Type := 16#8014e#;
Message_Event_PSPrinterDefaults : constant Message_Event_Code_Type := 16#8014f#;
Message_Event_PSPrinterDefaulted : constant Message_Event_Code_Type := 16#80150#;
Message_Event_PSPrinterNotPS : constant Message_Event_Code_Type := 16#80151#;
Message_Event_ResetPrinter : constant Message_Event_Code_Type := 16#80152#;
Message_Event_PSIsFontPrintRunning : constant Message_Event_Code_Type := 16#80153#;
Message_Event_HelpRequest : constant Message_Event_Code_Type := 16#502#;
Message_Event_HelpReply : constant Message_Event_Code_Type := 16#503#;
Message_Event_Help_Word : constant Message_Event_Code_Type := 16#43B00#;
Message_Event_TW_Input : constant Message_Event_Code_Type := 16#808C0#;
Message_Event_TW_Output : constant Message_Event_Code_Type := 16#808C1#;
Message_Event_TW_Ego : constant Message_Event_Code_Type := 16#808C2#;
Message_Event_TW_Morio : constant Message_Event_Code_Type := 16#808C3#;
Message_Event_TW_Morite : constant Message_Event_Code_Type := 16#808C4#;
Message_Event_TW_NewTask : constant Message_Event_Code_Type := 16#808C5#;
Message_Event_TW_Suspend : constant Message_Event_Code_Type := 16#808C6#;
Message_Event_TW_Resume : constant Message_Event_Code_Type := 16#808C7#;
Message_Event_PlugInQuit : constant Message_Event_Code_Type := 16#50D80#;
Message_Event_PlugInQuitContinue : constant Message_Event_Code_Type := 16#50D81#;
Message_Event_PlugInQuitAbort : constant Message_Event_Code_Type := 16#50D82#;
Message_Event_OpenConfigWindow : constant Message_Event_Code_Type := 16#50D83#;
Message_Event_Bugz_Query : constant Message_Event_Code_Type := 16#53B80#;
Message_Event_Bugz_BugzFile : constant Message_Event_Code_Type := 16#53B81#;
Message_Event_OLE_FileChanged : constant Message_Event_Code_Type := 16#80E1E#;
Message_Event_OLEOpenSession : constant Message_Event_Code_Type := 16#80E21#;
Message_Event_OLEOpenSessionAck : constant Message_Event_Code_Type := 16#80E22#;
Message_Event_OLECloseSession : constant Message_Event_Code_Type := 16#80E23#;
Message_Event_ConfiX : constant Message_Event_Code_Type := 16#40D50#;
Message_Event_StrongEDModeFileChanged : constant Message_Event_Code_Type := 16#43b06#;
Message_Event_StrongEDInsertText : constant Message_Event_Code_Type := 16#43b04#;
Message_Event_InetSuite_Open_URL : constant Message_Event_Code_Type := 16#4AF80#;
type Message_EventListener (E : Message_Event_Code_Type) is abstract new Event_Listener(Message) with
record
Event_Code : Message_Event_Code_Type := E;
end record;
type Message_Event_Header is
record
Size : System.Unsigned_Types.Unsigned;
Sender : Integer;
MyRef : System.Unsigned_Types.Unsigned;
YourRef : System.Unsigned_Types.Unsigned;
Event_Code : Message_Event_Code_Type;
end record;
pragma Convention (C, Message_Event_Header);
type ToolBox_Event_Code_Type is new System.Unsigned_Types.Unsigned;
Toolbox_Event_Error : constant ToolBox_Event_Code_Type := 16#44EC0#;
Toolbox_Event_ObjectAutoCreated : constant ToolBox_Event_Code_Type := 16#44EC1#;
Toolbox_Event_ObjectDeleted : constant ToolBox_Event_Code_Type := 16#44EC2#;
Toolbox_Event_Menu_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#828C0#;
Toolbox_Event_Menu_HasBeenHidden : constant ToolBox_Event_Code_Type := 16#828C1#;
Toolbox_Event_Menu_SubMenu : constant ToolBox_Event_Code_Type := 16#828C2#;
Toolbox_Event_Menu_Selection : constant ToolBox_Event_Code_Type := 16#828C3#;
Toolbox_Event_ColourDbox_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#829C0#;
Toolbox_Event_ColourDbox_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#829C1#;
Toolbox_Event_ColourDbox_ColourSelected : constant ToolBox_Event_Code_Type := 16#829C2#;
Toolbox_Event_ColourDbox_ColourChanged : constant ToolBox_Event_Code_Type := 16#829C3#;
Toolbox_Event_ColourMenu_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82980#;
Toolbox_Event_ColourMenu_HasBeenHidden : constant ToolBox_Event_Code_Type := 16#82981#;
Toolbox_Event_ColourMenu_Selection : constant ToolBox_Event_Code_Type := 16#82982#;
Toolbox_Event_DCS_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82A80#;
Toolbox_Event_DCS_Discard : constant ToolBox_Event_Code_Type := 16#82A81#;
Toolbox_Event_DCS_Save : constant ToolBox_Event_Code_Type := 16#82A82#;
Toolbox_Event_DCS_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82A83#;
Toolbox_Event_DCS_Cancel : constant ToolBox_Event_Code_Type := 16#82A84#;
Toolbox_Event_FileInfo_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82AC0#;
Toolbox_Event_FileInfo_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82AC1#;
Toolbox_Event_FontDbox_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82A00#;
Toolbox_Event_FontDbox_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82A01#;
Toolbox_Event_FontDbox_ApplyFont : constant ToolBox_Event_Code_Type := 16#82A02#;
Toolbox_Event_FontMenu_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82A40#;
Toolbox_Event_FontMenu_HasBeenHidden : constant ToolBox_Event_Code_Type := 16#82A41#;
Toolbox_Event_FontMenu_Selection : constant ToolBox_Event_Code_Type := 16#82A42#;
Toolbox_Event_Iconbar_Clicked : constant ToolBox_Event_Code_Type := 16#82900#;
Toolbox_Event_Iconbar_SelectAboutToBeShown : constant ToolBox_Event_Code_Type := 16#82901#;
Toolbox_Event_Iconbar_AdjustAboutToBeShown : constant ToolBox_Event_Code_Type := 16#82902#;
Toolbox_Event_PrintDbox_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82B00#;
Toolbox_Event_PrintDbox_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82B01#;
Toolbox_Event_PrintDbox_SetupAboutToBeShown : constant ToolBox_Event_Code_Type := 16#82B02#;
Toolbox_Event_PrintDbox_Save : constant ToolBox_Event_Code_Type := 16#82B03#;
Toolbox_Event_PrintDbox_SetUp : constant ToolBox_Event_Code_Type := 16#82B04#;
Toolbox_Event_PrintDbox_Print : constant ToolBox_Event_Code_Type := 16#82B05#;
Toolbox_Event_ProgInfo_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82B40#;
Toolbox_Event_ProgInfo_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82B41#;
Toolbox_Event_ProgInfo_LaunchWebPage : constant ToolBox_Event_Code_Type := 16#82B42#;
Toolbox_Event_Quit_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82A90#;
Toolbox_Event_Quit_Quit : constant ToolBox_Event_Code_Type := 16#82A91#;
Toolbox_Event_Quit_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82A92#;
Toolbox_Event_Quit_Cancel : constant ToolBox_Event_Code_Type := 16#82A93#;
Toolbox_Event_SaveAs_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82BC0#;
Toolbox_Event_SaveAs_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82BC1#;
Toolbox_Event_SaveAs_SaveToFile : constant ToolBox_Event_Code_Type := 16#82BC2#;
Toolbox_Event_SaveAs_FillBuffer : constant ToolBox_Event_Code_Type := 16#82BC3#;
Toolbox_Event_SaveAs_SaveCompleted : constant ToolBox_Event_Code_Type := 16#82BC4#;
Toolbox_Event_Scale_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82C00#;
Toolbox_Event_Scale_DialogueCompleted : constant ToolBox_Event_Code_Type := 16#82C01#;
Toolbox_Event_Scale_ApplyFactor : constant ToolBox_Event_Code_Type := 16#82C02#;
Toolbox_Event_Window_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#82880#;
Toolbox_Event_ActionButton_Selected : constant ToolBox_Event_Code_Type := 16#82881#;
Toolbox_Event_OptionButton_StateChanged : constant ToolBox_Event_Code_Type := 16#82882#;
Toolbox_Event_RadioButton_StateChanged : constant ToolBox_Event_Code_Type := 16#82883#;
Toolbox_Event_DisplayField_ValueChanged : constant ToolBox_Event_Code_Type := 16#82884#;
Toolbox_Event_WritableField_ValueChanged : constant ToolBox_Event_Code_Type := 16#82885#;
Toolbox_Event_Slider_ValueChanged : constant ToolBox_Event_Code_Type := 16#82886#;
Toolbox_Event_Draggable_DragStarted : constant ToolBox_Event_Code_Type := 16#82887#;
Toolbox_Event_Draggable_DragEnded : constant ToolBox_Event_Code_Type := 16#82888#;
Toolbox_Event_PopUp_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#8288B#;
Toolbox_Event_Adjuster_Clicked : constant ToolBox_Event_Code_Type := 16#8288C#;
Toolbox_Event_NumberRange_ValueChanged : constant ToolBox_Event_Code_Type := 16#8288D#;
Toolbox_Event_StringSet_ValueChanged : constant ToolBox_Event_Code_Type := 16#8288E#;
Toolbox_Event_StringSet_AboutToBeShown : constant ToolBox_Event_Code_Type := 16#8288F#;
Toolbox_Event_Window_HasBeenHidden : constant ToolBox_Event_Code_Type := 16#82890#;
ToolBox_Event_Quit : constant ToolBox_Event_Code_Type := 16#82A91#;
Toolbox_Event_ScrollList_Selection : constant ToolBox_Event_Code_Type := 16#140181#;
Toolbox_Event_Scrollbar_PositionChanged : constant ToolBox_Event_Code_Type := 16#140183#;
Toolbox_Event_ToolAction_ButtonClicked : constant ToolBox_Event_Code_Type := 16#140140#;
TreeView_SWIBase : constant ToolBox_Event_Code_Type := 16#140280#;
TreeView_EventBase : constant ToolBox_Event_Code_Type := TreeView_SWIBase;
Toolbox_Event_TreeViewNodeSelected : constant ToolBox_Event_Code_Type := TreeView_EventBase + 0;
Toolbox_Event_TreeViewNodeExpanded : constant ToolBox_Event_Code_Type := TreeView_EventBase + 1;
Toolbox_Event_TreeViewNodeRenamed : constant ToolBox_Event_Code_Type := TreeView_EventBase + 2;
Toolbox_Event_TreeViewNodeDataRequired : constant ToolBox_Event_Code_Type := TreeView_EventBase + 3;
Toolbox_Event_TreeViewNodeDragged : constant ToolBox_Event_Code_Type := TreeView_EventBase + 4;
type Object_ID is new Integer;
type Component_ID is new Integer;
subtype Error_Code_Type is Integer;
Error_Escape : constant Error_Code_Type := 16#11#;
Error_Bad_mode : constant Error_Code_Type := 16#19#;
Error_Is_adir : constant Error_Code_Type := 16#A8#;
Error_Types_dont_match : constant Error_Code_Type := 16#AF#;
Error_Bad_rename : constant Error_Code_Type := 16#B0#;
Error_Bad_copy : constant Error_Code_Type := 16#B1#;
Error_Outside_file : constant Error_Code_Type := 16#B7#;
Error_Access_violation : constant Error_Code_Type := 16#BD#;
Error_Too_many_open_files : constant Error_Code_Type := 16#C0#;
Error_Not_open_for_update : constant Error_Code_Type := 16#C1#;
Error_File_open : constant Error_Code_Type := 16#C2#;
Error_Object_locked : constant Error_Code_Type := 16#C3#;
Error_Already_exists : constant Error_Code_Type := 16#C4#;
Error_Bad_file_name : constant Error_Code_Type := 16#CC#;
Error_File_not_found : constant Error_Code_Type := 16#D6#;
Error_Syntax : constant Error_Code_Type := 16#DC#;
Error_Channel : constant Error_Code_Type := 16#DE#;
Error_End_of_file : constant Error_Code_Type := 16#DF#;
Error_Buffer_Overflow : constant Error_Code_Type := 16#E4#;
Error_Bad_filing_system_name : constant Error_Code_Type := 16#F8#;
Error_Bad_key : constant Error_Code_Type := 16#FB#;
Error_Bad_address : constant Error_Code_Type := 16#FC#;
Error_Bad_string : constant Error_Code_Type := 16#FD#;
Error_Bad_command : constant Error_Code_Type := 16#FE#;
Error_Bad_mac_val : constant Error_Code_Type := 16#120#;
Error_Bad_var_nam : constant Error_Code_Type := 16#121#;
Error_Bad_var_type : constant Error_Code_Type := 16#122#;
Error_Var_no_room : constant Error_Code_Type := 16#123#;
Error_Var_cant_find : constant Error_Code_Type := 16#124#;
Error_Var_too_long : constant Error_Code_Type := 16#125#;
Error_Redirect_fail : constant Error_Code_Type := 16#140#;
Error_Stack_full : constant Error_Code_Type := 16#141#;
Error_Bad_hex : constant Error_Code_Type := 16#160#;
Error_Bad_expr : constant Error_Code_Type := 16#161#;
Error_Bad_bra : constant Error_Code_Type := 16#162#;
Error_Stk_oflo : constant Error_Code_Type := 16#163#;
Error_Miss_opn : constant Error_Code_Type := 16#164#;
Error_Miss_opr : constant Error_Code_Type := 16#165#;
Error_Bad_bits : constant Error_Code_Type := 16#166#;
Error_Str_oflo : constant Error_Code_Type := 16#167#;
Error_Bad_itm : constant Error_Code_Type := 16#168#;
Error_Div_zero : constant Error_Code_Type := 16#169#;
Error_Bad_base : constant Error_Code_Type := 16#16A#;
Error_Bad_numb : constant Error_Code_Type := 16#16B#;
Error_Numb_too_big : constant Error_Code_Type := 16#16C#;
Error_Bad_claim_num : constant Error_Code_Type := 16#1A1#;
Error_Bad_release : constant Error_Code_Type := 16#1A2#;
Error_Bad_dev_no : constant Error_Code_Type := 16#1A3#;
Error_Bad_dev_vec_rel : constant Error_Code_Type := 16#1A4#;
Error_Bad_env_number : constant Error_Code_Type := 16#1B0#;
Error_Cant_cancel_quit : constant Error_Code_Type := 16#1B1#;
Error_Ch_dynam_cao : constant Error_Code_Type := 16#1C0#;
Error_Ch_dynam_not_all_moved : constant Error_Code_Type := 16#1C1#;
Error_Apl_wspace_in_use : constant Error_Code_Type := 16#1C2#;
Error_Ram_fs_unchangeable : constant Error_Code_Type := 16#1C3#;
Error_Oscli_long_line : constant Error_Code_Type := 16#1E0#;
Error_Oscli_too_hard : constant Error_Code_Type := 16#1E1#;
Error_Rc_exc : constant Error_Code_Type := 16#1E2#;
Error_Sys_heap_full : constant Error_Code_Type := 16#1E3#;
Error_Buff_overflow : constant Error_Code_Type := 16#1E4#;
Error_Bad_time : constant Error_Code_Type := 16#1E5#;
Error_No_such_swi : constant Error_Code_Type := 16#1E6#;
Error_Unimplemented : constant Error_Code_Type := 16#1E7#;
Error_Out_of_range : constant Error_Code_Type := 16#1E8#;
Error_No_oscli_specials : constant Error_Code_Type := 16#1E9#;
Error_Bad_parameters : constant Error_Code_Type := 16#1EA#;
Error_Arg_repeated : constant Error_Code_Type := 16#1EB#;
Error_Bad_read_sys_info : constant Error_Code_Type := 16#1EC#;
Error_Cdat_stack_overflow : constant Error_Code_Type := 16#2C0#;
Error_Cdat_buffer_overflow : constant Error_Code_Type := 16#2C1#;
Error_Cdat_bad_field : constant Error_Code_Type := 16#2C2#;
Error_Cant_start_application : constant Error_Code_Type := 16#600#;
-- Toolbox errors
Error_Tool_Action_Out_of_Memory : constant Error_Code_Type := 16#80E920#;
Error_Tool_Action_Cant_Create_Icon : constant Error_Code_Type := 16#80E921#;
Error_Tool_Action_Cant_Create_Object : constant Error_Code_Type := 16#80E922#;
Exception_Tool_Action_Out_of_Memory : Exception;
Exception_Tool_Action_Cant_Create_Icon : Exception;
Exception_Tool_Action_Cant_Create_Object: Exception;
Exception_Escape : Exception;
Exception_Bad_mode : Exception;
Exception_Is_adir : Exception;
Exception_Types_dont_match : Exception;
Exception_Bad_rename : Exception;
Exception_Bad_copy : Exception;
Exception_Outside_file : Exception;
Exception_Access_violation : Exception;
Exception_Too_many_open_files : Exception;
Exception_Not_open_for_update : Exception;
Exception_File_open : Exception;
Exception_Object_locked : Exception;
Exception_Already_exists : Exception;
Exception_Bad_file_name : Exception;
Exception_File_not_found : Exception;
Exception_Syntax : Exception;
Exception_Channel : Exception;
Exception_End_of_file : Exception;
Exception_Buffer_Overflow : Exception;
Exception_Bad_filing_system_name : Exception;
Exception_Bad_key : Exception;
Exception_Bad_address : Exception;
Exception_Bad_string : Exception;
Exception_Bad_command : Exception;
Exception_Bad_mac_val : Exception;
Exception_Bad_var_nam : Exception;
Exception_Bad_var_type : Exception;
Exception_Var_no_room : Exception;
Exception_Var_cant_find : Exception;
Exception_Var_too_long : Exception;
Exception_Redirect_fail : Exception;
Exception_Stack_full : Exception;
Exception_Bad_hex : Exception;
Exception_Bad_expr : Exception;
Exception_Bad_bra : Exception;
Exception_Stk_oflo : Exception;
Exception_Miss_opn : Exception;
Exception_Miss_opr : Exception;
Exception_Bad_bits : Exception;
Exception_Str_oflo : Exception;
Exception_Bad_itm : Exception;
Exception_Div_zero : Exception;
Exception_Bad_base : Exception;
Exception_Bad_numb : Exception;
Exception_Numb_too_big : Exception;
Exception_Bad_claim_num : Exception;
Exception_Bad_release : Exception;
Exception_Bad_dev_no : Exception;
Exception_Bad_dev_vec_rel : Exception;
Exception_Bad_env_number : Exception;
Exception_Cant_cancel_quit : Exception;
Exception_Ch_dynam_cao : Exception;
Exception_Ch_dynam_not_all_moved : Exception;
Exception_Apl_wspace_in_use : Exception;
Exception_Ram_fs_unchangeable : Exception;
Exception_Oscli_long_line : Exception;
Exception_Oscli_too_hard : Exception;
Exception_Rc_exc : Exception;
Exception_Sys_heap_full : Exception;
Exception_Buff_overflow : Exception;
Exception_Bad_time : Exception;
Exception_No_such_swi : Exception;
Exception_Unimplemented : Exception;
Exception_Out_of_range : Exception;
Exception_No_oscli_specials : Exception;
Exception_Bad_parameters : Exception;
Exception_Arg_repeated : Exception;
Exception_Bad_read_sys_info : Exception;
Exception_Cdat_stack_overflow : Exception;
Exception_Cdat_buffer_overflow : Exception;
Exception_Cdat_bad_field : Exception;
Exception_Cant_start_application : Exception;
Exception_Unknown_Error : Exception;
procedure Raise_Error (Error : OSError_Access);
--
-- Block filled in by the toolbox on WimpPoll
--
type ToolBox_Id_Block_Type is
record
Ancestor_Id : Object_ID;
Ancestor_Component: Component_ID;
Parent_Id : Object_ID;
Parent_Component : Component_ID;
Self_Id : Object_ID;
Self_Component : Component_ID;
end record;
pragma Convention (C, ToolBox_Id_Block_Type);
type ToolBox_Id_Block_Pointer is access ToolBox_Id_Block_Type;
type Toolbox_EventListener (E : ToolBox_Event_Code_Type;
O : Object_ID;
C : Component_ID) is abstract new Event_Listener(Toolbox) with
record
Event_Code : ToolBox_Event_Code_Type := E;
Object : Object_ID := O;
Component : Component_ID := C;
ID_Block : ToolBox_Id_Block_Pointer;
end record;
type Toolbox_UserEventListener (E : ToolBox_Event_Code_Type;
O : Object_ID;
C : Component_ID) is abstract new
Toolbox_EventListener (E,O,C) with
record
Event : Event_Pointer;
end record;
type Toolbox_Event_Header is
record
Size : System.Unsigned_Types.Unsigned;
Reference_Number : Integer;
Event_Code : System.Unsigned_Types.Unsigned;
Flags : System.Unsigned_Types.Unsigned;
end record;
pragma Convention (C, Toolbox_Event_Header);
Wimp_Block_Size : constant integer := 63;
type Wimp_Block_Type is array (0 .. Wimp_Block_Size) of integer;
type Wimp_Block_Pointer is access Wimp_Block_Type;
Number_Of_Messages : integer := 0;
Max_Number_Of_Messages : constant integer := 63;
type Messages_List_Type is array (0 .. Max_Number_Of_Messages) of integer;
type Messages_List_Pointer is access Messages_List_Type;
type System_Sprite_Pointer is new Address;
type Messages_Control_Block_Type is array (1 .. 6) of System.Unsigned_Types.Unsigned;
type Messages_Handle_Type is access Messages_Control_Block_Type;
end RASCAL.OS;
|
--
-- 3.3.2 Number Declarations
--
-- number_declaration ::=
-- defining_identifier_list : constant := static_expression;
--
-- NOTE: This module is not compilation is used only for testing purposes
--
procedure Number_Declarations is
-- Examples of number declarations:
Two_Pi : constant := 2.0*Ada.Numerics.Pi; -- a real number (see A.5)
Max : constant := 500; -- an integer number
Max_Line_Size : constant := Max/6; -- the integer 83
Power_16 : constant := 2**16; -- the integer 65_536
One, Un, Eins : constant := 1; -- three different names for 1
begin
null;
end Number_Declarations;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, 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$
------------------------------------------------------------------------------
private with Ada.Streams;
private with AWS.Resources.Streams.Memory;
with AWS.Response;
private with League.Calendars;
private with League.Holders;
private with League.IRIs;
private with League.Strings;
private with League.String_Vectors;
private with League.Text_Codecs;
with Matreshka.Servlet_HTTP_Responses;
with Matreshka.Servlet_HTTP_Requests;
private with Servlet.HTTP_Cookies;
with Servlet.HTTP_Responses;
with Servlet.Output_Streams;
private with Servlet.Write_Listeners;
package Matreshka.Servlet_AWS_Responses is
type AWS_Servlet_Response is
new Matreshka.Servlet_HTTP_Responses.Abstract_HTTP_Servlet_Response
and Servlet.Output_Streams.Servlet_Output_Stream
with private;
procedure Initialize
(Self : in out AWS_Servlet_Response'Class;
Request :
not null Matreshka.Servlet_HTTP_Requests.HTTP_Servlet_Request_Access);
function Build
(Self : in out AWS_Servlet_Response'Class) return AWS.Response.Data;
-- Build AWS response data.
private
type Stream_Access is
access all AWS.Resources.Streams.Memory.Stream_Type'Class;
type Text_Codec_Access is access all League.Text_Codecs.Text_Codec'Class;
type AWS_Servlet_Response is
new Matreshka.Servlet_HTTP_Responses.Abstract_HTTP_Servlet_Response
and Servlet.Output_Streams.Servlet_Output_Stream with
record
Data : AWS.Response.Data;
Encoding : League.Strings.Universal_String;
Content_Type : League.Strings.Universal_String;
Stream : Stream_Access;
Codec : Text_Codec_Access;
Output : access Servlet.Output_Streams.Servlet_Output_Stream'Class;
end record;
overriding procedure Add_Cookie
(Self : in out AWS_Servlet_Response;
Cookie : Servlet.HTTP_Cookies.Cookie);
-- Adds the specified cookie to the response. This method can be called
-- multiple times to set more than one cookie.
overriding procedure Add_Date_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Calendars.Date_Time);
-- Adds a response header with the given name and date-value. This method
-- allows response headers to have multiple values.
overriding procedure Add_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Strings.Universal_String);
-- Adds a response header with the given name and value. This method allows
-- response headers to have multiple values.
overriding procedure Add_Integer_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Holders.Universal_Integer);
-- Adds a response header with the given name and integer value. This
-- method allows response headers to have multiple values.
overriding function Contains_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String) return Boolean;
-- Returns a boolean indicating whether the named response header has
-- already been set.
overriding function Get_Header_Names
(Self : in out AWS_Servlet_Response)
return League.String_Vectors.Universal_String_Vector;
-- Return all the header names set for this response.
overriding function Get_Headers
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector;
-- Return all the header values associated with the specified header name.
overriding procedure Send_Redirect
(Self : in out AWS_Servlet_Response;
Location : League.IRIs.IRI);
-- Sends a temporary redirect response to the client using the specified
-- redirect location URL and clears the buffer.
overriding procedure Set_Character_Encoding
(Self : in out AWS_Servlet_Response;
Encoding : League.Strings.Universal_String);
-- Sets the character encoding (MIME charset) of the response being sent to
-- the client, for example, to UTF-8. If the character encoding has already
-- been set by setContentType(java.lang.String) or
-- setLocale(java.util.Locale), this method overrides it. Calling
-- setContentType(java.lang.String) with the String of text/html and
-- calling this method with the String of UTF-8 is equivalent with calling
-- setContentType with the String of text/html; charset=UTF-8.
overriding procedure Set_Content_Type
(Self : in out AWS_Servlet_Response;
To : League.Strings.Universal_String);
-- Sets the content type of the response being sent to the client, if the
-- response has not been committed yet. The given content type may include
-- a character encoding specification, for example,
-- text/html;charset=UTF-8. The response's character encoding is only set
-- from the given content type if this method is called before getWriter is
-- called.
overriding procedure Set_Date_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Calendars.Date_Time);
-- Sets a response header with the given name and date-value. If the header
-- had already been set, the new value overwrites the previous one. The
-- Contains_Header method can be used to test for the presence of a header
-- before setting its value.
overriding procedure Set_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Strings.Universal_String);
-- Sets a response header with the given name and value. If the header had
-- already been set, the new value overwrites the previous one. The
-- Contains_Header method can be used to test for the presence of a header
-- before setting its value.
overriding procedure Set_Integer_Header
(Self : in out AWS_Servlet_Response;
Name : League.Strings.Universal_String;
Value : League.Holders.Universal_Integer);
-- Sets a response header with the given name and integer value. If the
-- header had already been set, the new value overwrites the previous one.
-- The Contains_Header method can be used to test for the presence of a
-- header before setting its value.
overriding procedure Set_Status
(Self : in out AWS_Servlet_Response;
Status : Servlet.HTTP_Responses.Status_Code);
-- Sets the status code for this response.
overriding function Get_Output_Stream
(Self : AWS_Servlet_Response)
return
not null access Servlet.Output_Streams.Servlet_Output_Stream'Class;
-- Returns a ServletOutputStream suitable for writing binary data in the
-- response. The servlet container does not encode the binary data.
overriding function Is_Ready (Self : AWS_Servlet_Response) return Boolean;
-- This method can be used to determine if data can be written without
-- blocking.
overriding procedure Set_Write_Listener
(Self : in out AWS_Servlet_Response;
Listener : not null access Servlet.Write_Listeners.Write_Listener'Class);
-- Instructs the ServletOutputStream to invoke the provided WriteListener
-- when it is possible to write.
overriding procedure Write
(Self : in out AWS_Servlet_Response;
Item : Ada.Streams.Stream_Element_Array);
overriding procedure Write
(Self : in out AWS_Servlet_Response;
Item : League.Strings.Universal_String);
end Matreshka.Servlet_AWS_Responses;
|
--
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with types.c;
with ewok.exported.interrupts;
with ewok.exported.gpios;
package ewok.exported.devices
with spark_mode => off
is
MAX_INTERRUPTS : constant := 4;
MAX_GPIOS : constant := 16;
subtype t_device_name is types.c.c_string (1 .. 16);
type t_device_name_access is access all t_device_name;
type t_interrupt_config_array is
array (unsigned_8 range <>) of
aliased ewok.exported.interrupts.t_interrupt_config;
type t_gpio_config_array is
array (unsigned_8 range <>) of
aliased ewok.exported.gpios.t_gpio_config;
type t_dev_map_mode is
(DEV_MAP_AUTO,
DEV_MAP_VOLUNTARY);
type t_user_device is record
name : t_device_name;
base_addr : system_address := 0;
size : unsigned_32 := 0;
interrupt_num : unsigned_8 range 0 .. MAX_INTERRUPTS := 0;
gpio_num : unsigned_8 range 0 .. MAX_GPIOS := 0;
map_mode : t_dev_map_mode;
interrupts : t_interrupt_config_array (1 .. MAX_INTERRUPTS);
gpios : t_gpio_config_array (1 .. MAX_GPIOS);
end record;
type t_user_device_access is access all t_user_device;
end ewok.exported.devices;
|
With
EPL.Types,
EPL.Bracket,
Ada.Strings.Fixed;
Separate (Risi_Script.Types.Patterns)
Package Body Conversions is
Function Trimmed_Image( Input : Integer ) return String is
Use Ada.Strings.Fixed, Ada.Strings;
Begin
return Trim(Side => Left, Source => Integer'Image(Input));
End Trimmed_Image;
-------------------------
-- PATTERN TO STRING --
-------------------------
Function Convert( Pattern : Half_Pattern ) return String is
Begin
Return Result : String(Pattern'Range) do
for Index in Result'Range loop
Result(Index):= +Pattern(Index);
end loop;
End Return;
End Convert;
Function Convert( Pattern : Three_Quarter_Pattern ) return String is
Function Internal_Convert( Pattern : Three_Quarter_Pattern ) return String is
Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last;
Begin
if Pattern'Length not in Positive then
return "";
else
Declare
Head : Enumeration_Length renames Pattern(Pattern'First).All;
Sigil : constant Character := +Head.Enum;
Length : constant String :=
(if Head.Enum not in RT_String | RT_Array | RT_Hash then ""
else '(' & Trimmed_Image(Head.Length) & ')');
Begin
return Sigil & Length & String'(+Pattern(Tail));
End;
end if;
End Internal_Convert;
Result : constant String := Internal_Convert( Pattern );
Parens : constant Boolean := Ada.Strings.Fixed.Index(Result, "(") in Positive;
Begin
Return "";
-- Return (if Parens then Result else )
End Convert;
Function Convert( Pattern : Full_Pattern ) return String is ("");
Function Convert( Pattern : Extended_Pattern ) return String is ("");
Function Convert( Pattern : Square_Pattern ) return String is ("");
Function Convert( Pattern : Cubic_Pattern ) return String is ("");
Function Convert( Pattern : Power_Pattern ) return String is ("");
-------------------------
-- STRING TO PATTERN --
-------------------------
-- Function Convert( Text : String ) return Half_Pattern is ("");
-- Function Convert( Text : String ) return Three_Quarter_Pattern is ("");
-- Function Convert( Text : String ) return Full_Pattern is ("");
-- Function Convert( Text : String ) return Extended_Pattern is ("");
-- Function Convert( Text : String ) return Square_Pattern is ("");
-- Function Convert( Text : String ) return Cubic_Pattern is ("");
-- Function Convert( Text : String ) return Power_Pattern is ("");
--
-- Function "+"( Pattern : Half_Pattern ) return String is
-- Subtype Tail is Positive Range Positive'Succ(Pattern'First)..Pattern'Last;
-- begin
-- if Pattern'Length not in Positive then
-- return "";
-- else
-- Declare
-- Head : Enumeration renames Pattern(Pattern'First);
-- Sigil : constant Character := +(+Head);
-- Begin
-- return Sigil & String'(+Pattern(Tail));
-- End;
-- end if;
-- end "+";
--
--
-- Function "+"( Text : String ) return Half_Pattern is
-- Subtype Tail is Positive Range Positive'Succ(Text'First)..Text'Last;
-- begin
-- if Text'Length not in Positive then
-- return (2..1 => <>);
-- else
-- Declare
-- Element : constant Enumeration:= +(+Text(Text'First));
-- Begin
-- return Element & (+Text(Tail));
-- End;
-- end if;
-- end "+";
End Conversions;
|
-----------------------------------------------------------------------
-- el-contexts-tests - Tests the EL contexts
-- 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 Util.Test_Caller;
with Util.Properties;
with Util.Beans.Objects;
with EL.Contexts.Default;
package body EL.Utils.Tests is
use Util.Tests;
use Util.Beans.Objects;
package Caller is new Util.Test_Caller (Test, "EL.Utils");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test EL.Utils.Expand",
Test_Expand_Properties'Access);
Caller.Add_Test (Suite, "Test EL.Utils.Expand (recursion)",
Test_Expand_Recursion'Access);
Caller.Add_Test (Suite, "Test EL.Utils.Eval",
Test_Eval'Access);
end Add_Tests;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Expand_Properties (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
Props : Util.Properties.Manager;
Result : Util.Properties.Manager;
begin
Props.Set ("context", "#{homedir}/context");
Props.Set ("homedir", "#{home}/#{user}");
Props.Set ("unknown", "#{not_defined}");
Props.Set ("user", "joe");
Props.Set ("home", "/home");
EL.Utils.Expand (Source => Props,
Into => Result,
Context => Context);
Assert_Equals (T, "joe", String '(Result.Get ("user")), "Invalid expansion");
Assert_Equals (T, "/home/joe", String '(Result.Get ("homedir")), "Invalid expansion");
Assert_Equals (T, "/home/joe/context", String '(Result.Get ("context")),
"Invalid expansion");
Assert_Equals (T, "", String '(Result.Get ("unknown")), "Invalid expansion");
end Test_Expand_Properties;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Expand_Recursion (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
Props : Util.Properties.Manager;
Result : Util.Properties.Manager;
begin
Props.Set ("context", "#{homedir}/context");
Props.Set ("homedir", "#{home}/#{user}");
Props.Set ("user", "joe");
Props.Set ("home", "#{context}");
EL.Utils.Expand (Source => Props,
Into => Result,
Context => Context);
Assert_Equals (T, "joe", String '(Result.Get ("user")), "Invalid expansion");
Assert_Equals (T, "/joe/context/joe/context/joe/context/joe",
String '(Result.Get ("homedir")),
"Invalid expansion");
end Test_Expand_Recursion;
-- ------------------------------
-- Test expand list of properties
-- ------------------------------
procedure Test_Eval (T : in out Test) is
Context : EL.Contexts.Default.Default_Context;
begin
Assert_Equals (T, "1", EL.Utils.Eval (Value => "1",
Context => Context), "Invalid eval <empty string>");
Assert_Equals (T, "3", EL.Utils.Eval (Value => "#{2+1}",
Context => Context), "Invalid eval <valid expr>");
declare
Value, Result : Util.Beans.Objects.Object;
begin
Value := Util.Beans.Objects.To_Object (Integer '(123));
Result := EL.Utils.Eval (Value => Value,
Context => Context);
T.Assert (Value = Result, "Eval should return the same object");
Value := Util.Beans.Objects.To_Object (String '("345"));
Result := EL.Utils.Eval (Value => Value,
Context => Context);
T.Assert (Value = Result, "Eval should return the same object");
end;
end Test_Eval;
end EL.Utils.Tests;
|
with Protypo.Api.Engine_Values.Engine_Value_Vectors;
use Protypo.Api.Engine_Values;
package Protypo.Api.Callback_Utilities is
type Class_Array is array (Positive range <>) of Engine_Value_Class;
function Match_Signature (Parameters : Engine_Value_Vectors.Vector;
Signature : Class_Array)
return Boolean;
function Is_A (Parameters : Engine_Value_Vectors.Vector;
Index : Positive;
Class : Engine_Value_Class)
return Boolean;
function Get (Parameters : Engine_Value_Vectors.Vector;
Index : Positive)
return Engine_Value;
function Get_Parameter (Parameters : Engine_Value_Vectors.Vector;
Index : Positive)
return String
with
Pre => Is_A (Parameters => Parameters,
Index => Index,
Class => Text);
end Protypo.Api.Callback_Utilities;
|
-----------------------------------------------------------------------
-- el-methods-func_string -- Pre-defined binding
-- Copyright (C) 2010, 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 EL.Methods.Func_1;
-- This package provides the method bindings to invoke
-- methods with the following signature:
--
-- function F (Object : <Bean>;
-- Param : String)
-- return String;
--
-- Example of call:
--
-- Ctx : ELContext := ...;
-- M : Method_Expression := ...;
-- A : String := ...;
--
-- R : String := Func_Unbounded.Execute (M, A, Ctx);
--
package EL.Methods.Func_String is
new EL.Methods.Func_1 (Param1_Type => String,
Return_Type => String);
|
with Ada.Streams; use Ada.Streams;
package Endianness with
Pure,
Preelaborate,
SPARK_Mode => On
is
-- @summary
-- Convenience subprograms to convert between Big- and Little-endianness
--
-- @description
-- This package contains a few convenient subprograms that allow you to
-- simply switch between native endianness of the running system and big
-- or little endianness. Ada's byte order handling is quite sophisticated
-- and it doesn't provide such routines at all. Hopefully, there is a
-- GNAT.Byte_Swapping available in GNAT, but it only allows for simple
-- swapping of bytes.
-- This package is built on top of GNAT.Byte_Swapping, but provides much
-- simpler programming interface.
--
-- This package provides generic function interfaces, but mostly you would
-- be better off utilizing already instantiated Endiannes.Standard and
-- Endianness.Interfaces packages which initialize all of the provided
-- functions for compatible types from Standard and Interfaces packages,
-- respectively.
generic
type Source is (<>);
-- Input source type
function Swap_Endian (Value : Source) return Source with
Global => null,
Pre => Source'Size = 8 or else Source'Size = 16 or else Source'Size = 32
or else Source'Size = 64;
-- Convert from one endianness to another.
generic
type Source is (<>);
-- Input source types
function Native_To_Big_Endian
(Value : Source) return Stream_Element_Array with
Global => null,
Pre => Source'Size = 8 or else Source'Size = 16 or else Source'Size = 32
or else Source'Size = 64,
Post => Native_To_Big_Endian'Result'Length =
Source'Max_Size_In_Storage_Elements;
-- Convert Value from native endianness into an array of bytes, ordered
-- as in big endian.
generic
type Source is (<>);
function Native_To_Little_Endian
(Value : Source) return Stream_Element_Array with
Global => null,
Pre => Source'Size = 8 or else Source'Size = 16 or else Source'Size = 32
or else Source'Size = 64,
Post => Native_To_Little_Endian'Result'Length =
Source'Max_Size_In_Storage_Elements;
-- Convert Value from native endianness into an array of bytes, ordered
-- as in little endian.
generic
type Target is (<>);
function Big_Endian_To_Native
(Value : Stream_Element_Array) return Target with
Global => null,
Pre =>
(Target'Size = 8 or else Target'Size = 16 or else Target'Size = 32
or else Target'Size = 64)
and then Value'Length = Target'Max_Size_In_Storage_Elements;
-- Convert Value from an array of bytes into a native value, order
-- of input bytes is assumed to be in big endian
generic
type Target is (<>);
function Little_Endian_To_Native
(Value : Stream_Element_Array) return Target with
Global => null,
Pre =>
(Target'Size = 8 or else Target'Size = 16 or else Target'Size = 32
or else Target'Size = 64)
and then Value'Length = Target'Max_Size_In_Storage_Elements;
-- Convert Value from an array of bytes into a native value, order
-- of input bytes is assumed to be in little endian
end Endianness;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 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$
------------------------------------------------------------------------------
private with Ada.Containers.Hashed_Maps;
private with Ada.Containers.Vectors;
private with Ada.Finalization;
with League.String_Vectors;
with League.Strings;
private with League.Strings.Hash;
package XML.Utilities.Namespace_Supports is
pragma Preelaborate;
type XML_Namespace_Support is tagged private;
type Component_Kinds is (Attribute, Element);
-- Process_Name
procedure Declare_Prefix
(Self : in out XML_Namespace_Support'Class;
Prefix : League.Strings.Universal_String;
Namespace_URI : League.Strings.Universal_String);
-- This procedure declares a prefix in the future namespace context to be
-- namespace uri. The prefix is activated then context is pushed and
-- remains in force until this context is popped, unless it is shadowed in
-- a descendant context.
function Namespace_URI
(Self : XML_Namespace_Support'Class;
Prefix : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.Strings.Universal_String;
-- Looks up the prefix prefix in the current context and returns the
-- currently-mapped namespace URI. Use the empty string ("") for the
-- default namespace.
function Prefix
(Self : XML_Namespace_Support'Class;
Namespace_URI : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.Strings.Universal_String;
-- Returns one of the prefixes mapped to the namespace URI.
--
-- If more than one prefix is currently mapped to the same URI, this method
-- will make an arbitrary selection; if you want all of the prefixes, use
-- the Prefixes function instead.
--
-- This function return the empty (default) prefix only for Element
-- component.
function Prefixes
(Self : XML_Namespace_Support'Class;
Component : Component_Kinds := Element)
return League.String_Vectors.Universal_String_Vector;
-- Return an enumeration of all prefixes declared in this context. The
-- 'xml:' prefix will be included.
--
-- The empty (default) prefix will be included in this enumeration; then
-- specified component is Element.
function Prefixes
(Self : XML_Namespace_Support'Class;
Namespace_URI : League.Strings.Universal_String;
Component : Component_Kinds := Element)
return League.String_Vectors.Universal_String_Vector;
-- Return an enumeration of all prefixes for a given URI whose declarations
-- are active in the current context. This includes declarations from
-- parent contexts that have not been overridden.
--
-- The empty (default) prefix will be included in this enumeration; then
-- specified component is Element.
procedure Process_Name
(Self : XML_Namespace_Support'Class;
Qualified_Name : League.Strings.Universal_String;
Component : Component_Kinds;
Namespace_URI : out League.Strings.Universal_String;
Local_Name : out League.Strings.Universal_String);
-- Process a raw XML qualified name, after all declarations in the current
-- context.
--
-- Note that attribute names are processed differently than element names:
-- an unprefixed element name will receive the default Namespace (if any),
-- while an unprefixed attribute name will not.
procedure Pop_Context (Self : in out XML_Namespace_Support'Class);
-- Revert to the previous Namespace context.
--
-- Normally, you should pop the context at the end of each XML element.
-- After popping the context, all Namespace prefix mappings that were
-- previously in force are restored.
--
-- You must not attempt to declare additional Namespace prefixes after
-- popping a context, unless you push another context first.
procedure Push_Context (Self : in out XML_Namespace_Support'Class);
-- Starts a new namespace context.
--
-- Normally, you should push a new context at the beginning of each XML
-- element: the new context automatically inherits the declarations of its
-- parent context, and it also keeps track of which declarations were made
-- within this context.
--
-- The namespace support object always starts with a base context already
-- in force: in this context, only the "xml" prefix is declared.
procedure Reset (Self : in out XML_Namespace_Support'Class);
-- Reset this Namespace support object for reuse.
--
-- It is necessary to invoke this method before reusing the Namespace
-- support object for a new session.
private
package String_Maps is
new Ada.Containers.Hashed_Maps
(League.Strings.Universal_String,
League.Strings.Universal_String,
League.Strings.Hash,
League.Strings."=",
League.Strings."=");
type Context is record
Prefix : String_Maps.Map;
Namespace_URI : String_Maps.Map;
end record;
package Context_Vectors is
new Ada.Containers.Vectors (Positive, Context);
type XML_Namespace_Support is new Ada.Finalization.Controlled with record
Current : Context;
Future : Context;
Stack : Context_Vectors.Vector;
end record;
overriding procedure Initialize (Self : in out XML_Namespace_Support);
-- Define default prefix mapping.
end XML.Utilities.Namespace_Supports;
|
with Iterateur_Mots; use Iterateur_Mots;
with Vecteurs; use Vecteurs;
package Helper is
Erreur_Lecture : Exception;
-- Cherche dans un fichier une ligne
-- qui commence par la chaine donnée
-- Renvoie la chaine trouvée SANS MARQUEUR
-- avec un car. en moins à la fin (double quote)
function Fichier_Ligne_Commence_Par(Nom_Fichier, Marqueur : String)
return String;
-- Lit une coordonnée
function Lire_Coord(Iterateur : in out Iterateur_Mot) return Float;
-- Lit un jeu de coordonnées
procedure Lire_Point2D(
Iterateur : in out Iterateur_Mot;
Separateur_Coord : Character;
Point : out Point2D);
procedure Afficher_Debug (Afficher : Boolean);
-- Affiche la chaine si Debug activé
procedure Debug (Chaine : String);
-- Juste un new_line
procedure Debug;
private
Etat_Debug : Boolean := False;
end Helper;
|
-------------------------------------
-- Laboratory work #1
-- F1: D = (SORT(A + B) + C) *(MA*ME)
-- F2: ML = SORT(MF + MG*MH)
-- F3: T = (O + P)*(MP * MS)
-- Date 30.09.2020
-------------------------------------
with data;
with Ada.Integer_Text_IO, Ada.Text_IO;
use Ada.Integer_Text_IO, Ada.Text_IO;
with System.Multiprocessors; use System.Multiprocessors;
procedure Lab1 is
N: Integer:=4;
package Data1 is new data(N);
use Data1;
D,T: Vector;
ML: Matrix;
CPU_0: CPU_Range:= 1;
CPU_1: CPU_Range:= 2;
procedure Tasks is
task T1 is
pragma Task_Name("T1");
pragma Priority(1);
pragma Storage_Size(10000000);
pragma CPU(CPU_0);
end T1;
task T2 is
pragma Task_Name("T2");
pragma Priority(2);
pragma Storage_Size(10000000);
pragma CPU(CPU_1);
end T2;
task T3 is
pragma Task_Name("T3");
pragma Priority(3);
pragma Storage_Size(10000000);
pragma CPU(CPU_1);
end T3;
task body T1 is
A,B,C: Vector;
MA,ME: Matrix;
begin
Put_Line("Task T1 started.");
delay 1.0;
Vector_Fill_Ones(A);
Vector_Fill_Ones(B);
Vector_Fill_Ones(C);
Matrix_Fill_Ones(MA);
Matrix_Fill_Ones(ME);
D:= Func1(A=>A, B=>B, C=>C, MA=>MA, ME=>ME);
end T1;
task body T2 is
MF,MH,MG: Matrix;
begin
Put_Line("Task T2 started.");
delay 1.0;
Matrix_Fill_Ones(MF);
Matrix_Fill_Ones(MG);
Matrix_Fill_Ones(MH);
ML:= Func2(MF => MF, MG => MG, MH => MH);
end T2;
task body T3 is
O,P: Vector;
MP,MS: Matrix;
begin
Put_Line("Task T3 started.");
delay 1.0;
Vector_Fill_Ones(O);
Vector_Fill_Ones(P);
Matrix_Fill_Ones(MP);
Matrix_Fill_Ones(MS);
T:= Func3(O => O, P => P,MP => MP,MS => MS);
end T3;
begin
null;
end Tasks;
begin
Tasks;
New_Line;
Put("T1: D = ");
Vector_Output(D);
New_Line;
Put_Line("Task T1 finished.");
New_Line;
Put_Line("T2: ML = ");
Matrix_Output(A => ML);
Put_Line("Task T2 finished.");
New_Line;
Put_Line("T3: T = ");
Vector_Output(T);
Put_Line("Task T3 finished.");
end Lab1;
|
with
gel.Window.sdl;
package gel.Window.setup
renames gel.Window.sdl;
|
with Ada.Strings.Fixed;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A036 is
use Ada.Strings.Fixed;
use Ada.Integer_Text_IO;
-- Initial values denoting the numbers 0, 1, 3, 5, 7, and 9.
Sum_Val : Integer := 25;
Decimal : String (1 .. 10);
Binary : String (1 .. 30);
Is_Decimal_Palindromic, Is_Binary_Palindromic : Boolean;
J, Decimal_Len, Decimal_Len_By_2,
Binary_Len, Binary_Len_By_2,
Temp_Len, Quotient : Integer;
begin
for I in 10 .. 1_000_000 loop
if (I mod 2) = 0 then
goto Continue;
end if;
Move (Source => Trim (Integer'Image (I), Ada.Strings.Both),
Target => Decimal,
Justify => Ada.Strings.Left);
Decimal_Len := Trim (Integer'Image (I), Ada.Strings.Both)'Length;
Is_Decimal_Palindromic := True;
if Decimal_Len /= 1 then
Decimal_Len_By_2 := Integer (Float'Floor (Float (Decimal_Len) / 2.0));
for J in 1 .. Decimal_Len_By_2 loop
Temp_Len := Decimal_Len - J + 1;
if Decimal (J) /= Decimal (Temp_Len) then
Is_Decimal_Palindromic := False;
exit;
end if;
end loop;
end if;
if (not Is_Decimal_Palindromic) then
goto Continue;
end if;
Binary := 30 * " ";
J := 1;
Quotient := I;
while Quotient /= 0 loop
Binary (J) := Character'Val ((Quotient mod 2) + Character'Pos ('0'));
Quotient := Integer (Float'Floor (Float (Quotient) / 2.0));
J := J + 1;
end loop;
Is_Binary_Palindromic := True;
Binary_Len := Index (Binary, " ") - 1;
Binary_Len_By_2 := Integer (Float'Floor (Float (Binary_Len) / 2.0));
for J in 1 .. Binary_Len_By_2 loop
Temp_Len := Binary_Len - J + 1;
if Binary (J) /= Binary (Temp_Len) then
Is_Binary_Palindromic := False;
exit;
end if;
end loop;
if not Is_Binary_Palindromic then
goto Continue;
end if;
Sum_Val := Sum_Val + I;
<<Continue>>
end loop;
Put (Sum_Val, Width => 0);
end A036;
|
with Ada.Containers;
with Ada.IO_Exceptions;
with Ada.Text_IO;
with OpenAL.Context.Error;
with OpenAL.Context;
with OpenAL.List;
with OpenAL.Types;
with Test;
procedure alc_001 is
package ALC renames OpenAL.Context;
package ALC_Error renames OpenAL.Context.Error;
package List renames OpenAL.List;
Device : ALC.Device_t;
No_Device : ALC.Device_t;
Context : ALC.Context_t;
OK : Boolean;
Caught_Error : Boolean;
Handled_Capture : constant Boolean := True;
Devices : List.String_Vector_t;
TC : Test.Context_t;
use type ALC.Device_t;
use type ALC.Context_t;
use type ALC_Error.Error_t;
procedure Finish is
begin
ALC.Destroy_Context (Context);
ALC.Close_Device (Device);
end Finish;
procedure Init is
begin
Device := ALC.Open_Default_Device;
pragma Assert (Device /= ALC.Invalid_Device);
Context := ALC.Create_Context (Device);
pragma Assert (Context /= ALC.Invalid_Context);
OK := ALC.Make_Context_Current (Context);
pragma Assert (OK);
end Init;
begin
Test.Initialize
(Test_Context => TC,
Program => "alc_001",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
Init;
Ada.Text_IO.Put_Line
("DEFAULT_DEVICE_SPEC : " & ALC.Get_Default_Device_Specifier);
Ada.Text_IO.Put_Line
("DEVICE_SPEC : " & ALC.Get_Device_Specifier (Device));
begin
Caught_Error := False;
Ada.Text_IO.Put_Line (ALC.Get_Device_Specifier (No_Device));
exception
when Ada.IO_Exceptions.Device_Error => Caught_Error := True;
end;
Test.Check (TC, 20, Caught_Error, "Caught_Error");
Ada.Text_IO.Put_Line
("EXTENSIONS : " & ALC.Get_Extensions (Device));
begin
Caught_Error := False;
Ada.Text_IO.Put_Line (ALC.Get_Extensions (No_Device));
exception
when Ada.IO_Exceptions.Device_Error => Caught_Error := True;
end;
Test.Check (TC, 21, Caught_Error, "Caught_Error");
Ada.Text_IO.Put_Line
("DEFAULT_CAPTURE_DEVICE_SPECIFIER : " & ALC.Get_Default_Capture_Device_Specifier);
Devices := ALC.Get_Available_Capture_Devices;
if List.String_Vectors.Is_Empty (Devices) = False then
Ada.Text_IO.Put_Line
("DEVICE COUNT: " & Ada.Containers.Count_Type'Image (List.String_Vectors.Length (Devices)));
declare
procedure Process_Element (Device : in String) is
begin
Ada.Text_IO.Put_Line ("CAPTURE_DEVICE: " & Device);
end Process_Element;
begin
for Index in
List.String_Vectors.First_Index (Devices) ..
List.String_Vectors.Last_Index (Devices)
loop
List.String_Vectors.Query_Element (Devices, Index, Process_Element'Access);
end loop;
end;
end if;
Test.Check (TC, 22, Handled_Capture, "Handled_Capture");
Ada.Text_IO.Put_Line
("MAJOR_VERSION : " & Natural'Image (ALC.Get_Major_Version (Device)));
Ada.Text_IO.Put_Line
("MINOR_VERSION : " & Natural'Image (ALC.Get_Minor_Version (Device)));
Ada.Text_IO.Put_Line
("FREQUENCY : " & OpenAL.Types.Frequency_t'Image (ALC.Get_Frequency (Device)));
Ada.Text_IO.Put_Line
("REFRESH_RATE : " & Natural'Image (ALC.Get_Refresh (Device)));
Ada.Text_IO.Put_Line
("MONO_SOURCES : " & Natural'Image (ALC.Get_Mono_Sources (Device)));
Ada.Text_IO.Put_Line
("STEREO_SOURCES : " & Natural'Image (ALC.Get_Stereo_Sources (Device)));
Finish;
end alc_001;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A027 is
use Ada.Text_IO;
use Ada.Integer_Text_IO;
-- File Reference: http://www.naturalnumbers.org/primes.html
FT : File_Type;
Last_Index : Natural;
Prime_Num : String (1 .. 10);
File_Name : constant String :=
"problems/003/PrimeNumbers_Upto_1000000";
Primes_List : array (Integer range 1 .. 1000) of Integer;
A : Integer := -999;
B_Count : Integer := 0;
A_Max : Integer := 0;
B_Max : Integer := 0;
N_Max : Integer := 0;
I : Integer := 1;
B, N, J, Max_Prime : Integer;
begin
Open (FT, In_File, File_Name);
while not End_Of_File (FT) and I /= 1000 loop
Get_Line (FT, Prime_Num, Last_Index);
if Integer'Value (Prime_Num (1 .. Last_Index)) < 1000 then
B_Count := B_Count + 1;
end if;
Primes_List (I) := Integer'Value (Prime_Num (1 .. Last_Index));
I := I + 1;
end loop;
Close (FT);
while A < 1000 loop
B := 1;
while B < B_Count loop
N := 1;
J := 1;
Max_Prime := (N * N) + (A * N) + Primes_List (B);
while J < 1000 loop
if Primes_List (J) > Max_Prime then
exit;
end if;
if Max_Prime = Primes_List (J) then
N := N + 1;
J := 1;
Max_Prime := (N * N) + (A * N) + Primes_List (B);
goto Continue;
end if;
J := J + 1;
<<Continue>>
end loop;
if N > N_Max then
N_Max := N;
A_Max := A;
B_Max := Primes_List (B);
end if;
B := B + 1;
end loop;
A := A + 1;
end loop;
Put (A_Max * B_Max, Width => 0);
end A027;
|
with Ada.Text_IO;
with Intcode.Op;
use Intcode.Op;
package body Intcode is
protected body Port is
entry Put(I: in Memory.Value) when Status /= Full is
begin
if Status = Empty then
Value := I;
Status := Full;
end if;
end Put;
entry Get(X: out Maybe_Memory_Value) when Status /= Empty is
begin
case Status is
when Full =>
X := (Present => True, Value => Value);
Status := Empty;
when others => X := (Present => False);
end case;
end Get;
entry Close when Status /= Full is
begin
Status := Closed;
end Close;
end Port;
task body Executor is
PC: Memory.Address := 0;
Relative_Base: Memory.Value := 0;
-- physical layer of memory: Peek/Poke
function Peek(From: Memory.Address) return Memory.Value is
begin
if From in AM.Mem'Range then
return AM.Mem(From);
elsif AM.Aux_Mem.Contains(From) then
return AM.Aux_Mem.Element(From);
else
return 0;
end if;
end Peek;
procedure Poke(To: Memory.Address; Value: Memory.Value) is
begin
if To in AM.Mem'Range then
AM.Mem(To) := Value;
elsif AM.Aux_Mem.Contains(To) then
AM.Aux_Mem.Replace(To, Value);
else
AM.Aux_Mem.Insert(To, Value);
end if;
end Poke;
-- logical layer of memory: Read/Store
function Read(
From: Memory.Address;
Mode: Parameter_Mode) return Memory.Value is
V: constant Memory.Value := Peek(From);
begin
return (case Mode is
when Immediate => V,
when Position => Peek(Memory.Address(V)),
when Relative => Peek(Memory.Address(Relative_Base + V)));
end Read;
procedure Store(
To: Memory.Address; Mode: Parameter_Mode; Value: Memory.Value) is
V: constant Memory.Value := Peek(To);
M: constant Memory.Address :=
(case Mode is
when Position => Memory.Address(V),
when Relative => Memory.Address(Relative_Base + V),
when Immediate =>
raise Constraint_Error with "store to relative");
begin
Poke(M, Value);
end Store;
begin
loop
declare
Curr_Op: constant Schema := Decode(AM.Mem(PC));
Params: array (Curr_Op.Params'Range) of Memory.Value;
Dst: constant Memory.Address :=
PC + Memory.Address(Params'Last);
M: constant Parameter_Mode := Curr_Op.Params(Params'Last);
Recv: Maybe_Memory_Value;
begin
for I in Params'Range loop
Params(I) := Read(
From => PC + Memory.Address(I), Mode => Curr_Op.Params(I));
end loop;
PC := PC + Params'Length + 1;
-- Ada.Text_IO.Put_Line(Curr_Op.Instruction'Image);
case Curr_Op.Instruction is
when Halt => exit;
-- Arithmetic
when Add => Store(
To => Dst,
Mode => M,
Value => Params(1) + Params(2));
when Mul => Store(
To => Dst,
Mode => M,
Value => Params(1) * Params(2));
-- I/O
when Get =>
AM.Input.Get(Recv);
if Recv.Present then
Store(To => Dst, Mode => M, Value => Recv.Value);
end if;
when Put => AM.Output.Put(Params(1));
-- Transfer of Control
when Jz =>
if Params(1) = 0 then
PC := Memory.Address(Params(2));
end if;
when Jnz =>
if Params(1) /= 0 then
PC := Memory.Address(Params(2));
end if;
-- Modify relative base
when Mrb => Relative_Base := Relative_Base + Params(1);
-- Comparison
when Lt =>
Store(
To => Dst,
Mode => M,
Value => (if Params(1) < Params(2) then 1 else 0));
when Eq =>
Store(
To => Dst,
Mode => M,
Value => (if Params(1) = Params(2) then 1 else 0));
end case;
end;
end loop;
AM.Input.Close;
AM.Output.Close;
end Executor;
end Intcode;
|
------------------------------------------------------------------------------
-- --
-- Unicode Utilities --
-- --
-- Unicode Character Database (UCD) Facilities --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Streams;
private with Ada.Characters.Conversions;
private with Ada.Strings.Wide_Wide_Unbounded;
private with Ada.Containers.Vectors;
package Unicode.UCD is
Bad_Data: exception;
type UCD_Entry is tagged private with Preelaborable_Initialization;
function Next_Entry
(Stream: not null access Ada.Streams.Root_Stream_Type'Class)
return UCD_Entry;
-- Parse from the beginning of a line in a UCD file, returning the result.
--
-- This should never fail when used correctly with a properly formatted
-- file. Therefore a parsing error is considered fatal for a given stream.
-- Once a Bad_Data exception is raised, it should be expected that
-- subsequent calls to Next_Extry will also fail.
--
-- Next_Entry is strict in parsing and makes no assuptions.
function First_Codepoint (E: UCD_Entry) return Wide_Wide_Character;
function Last_Codepoint (E: UCD_Entry) return Wide_Wide_Character;
-- Returns the first and last codepoint values for the entry.
function Property_Count (E: UCD_Entry) return Natural;
-- Returns the number of properties contained in the entry
function Property (E: UCD_Entry; Index: Positive) return String;
function Property (E: UCD_Entry; Index: Positive) return Wide_Wide_String;
-- Returns the value of the Property at the given index.
-- Raises CONSTRAINT_ERROR if the property index does not exist, or if
-- the property cannot be represented in a String
function Comment (E: UCD_Entry) return String;
function Comment (E: UCD_Entry) return Wide_Wide_String;
-- Returns the value of the comment (if any) at the end of the entry
-- (not including the initial '#')
private
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
use type WWU.Unbounded_Wide_Wide_String;
subtype Unbounded_Wide_Wide_String is WWU.Unbounded_Wide_Wide_String;
package Property_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Unbounded_Wide_Wide_String);
use type Property_Vectors.Vector;
subtype Property_Vector is Property_Vectors.Vector;
type UCD_Entry is tagged
record
First, Last: Wide_Wide_Character;
Properties : Property_Vector;
Comment : Unbounded_Wide_Wide_String;
end record;
function First_Codepoint (E: UCD_Entry) return Wide_Wide_Character
is (E.First);
function Last_Codepoint (E: UCD_Entry) return Wide_Wide_Character
is (E.Last);
function Property_Count (E: UCD_Entry) return Natural
is (Natural (E.Properties.Length));
function Property (E: UCD_Entry; Index: Positive) return Wide_Wide_String
is (WWU.To_Wide_Wide_String (E.Properties(Index)));
function Property (E: UCD_Entry; Index: Positive) return String
is (Ada.Characters.Conversions.To_String
(Wide_Wide_String'(E.Property(Index))));
function Comment (E: UCD_Entry) return Wide_Wide_String
is (WWU.To_Wide_Wide_String (E.Comment));
function Comment (E: UCD_Entry) return String
is (Ada.Characters.Conversions.To_String
(WWU.To_Wide_Wide_String (E.Comment)));
end Unicode.UCD;
|
package body System.Native_Time is
use type C.signed_int;
pragma Warnings (Off, "is not referenced");
function To_tv_nsec (X : Nanosecond_Number) return C.signed_long
with Convention => Intrinsic;
-- Darwin, FreeBSD, or Linux (32/64bit)
function To_tv_nsec (X : Nanosecond_Number) return C.signed_long_long
with Convention => Intrinsic;
-- Linux (x32)
pragma Inline_Always (To_tv_nsec);
pragma Warnings (On, "is not referenced");
function To_tv_nsec (X : Nanosecond_Number) return C.signed_long is
begin
return C.signed_long (X);
end To_tv_nsec;
function To_tv_nsec (X : Nanosecond_Number) return C.signed_long_long is
begin
return C.signed_long_long (X);
end To_tv_nsec;
-- implementation
function To_timespec (D : C.sys.time.struct_timeval)
return C.time.struct_timespec is
begin
return (
tv_sec => D.tv_sec,
tv_nsec => To_tv_nsec (Nanosecond_Number (D.tv_usec) * 1_000));
end To_timespec;
function To_timespec (D : Duration) return C.time.struct_timespec is
Nanosecond : constant Nanosecond_Number :=
Nanosecond_Number'Integer_Value (D);
Sub_Second : constant Nanosecond_Number := Nanosecond mod 1_000_000_000;
begin
return (
tv_sec =>
C.sys.types.time_t ((Nanosecond - Sub_Second) / 1_000_000_000),
tv_nsec => To_tv_nsec (Sub_Second));
end To_timespec;
function To_Duration (D : C.time.struct_timespec) return Duration is
begin
return Duration'Fixed_Value (
Nanosecond_Number'Integer_Value (To_Duration (D.tv_sec))
+ Nanosecond_Number (D.tv_nsec));
end To_Duration;
function To_Duration (D : C.sys.types.time_t) return Duration is
begin
return Duration'Fixed_Value (
(Nanosecond_Number (D)) * 1_000_000_000);
end To_Duration;
procedure Simple_Delay_For (D : Duration) is
Req_T : aliased C.time.struct_timespec := To_timespec (D);
begin
loop
declare
Rem_T : aliased C.time.struct_timespec;
R : C.signed_int;
begin
R := C.time.nanosleep (Req_T'Access, Rem_T'Access);
exit when not (R < 0);
Req_T := Rem_T;
end;
end loop;
end Simple_Delay_For;
procedure Delay_For (D : Duration) is
begin
if D >= 0.0 then
Delay_For_Hook.all (D);
end if;
end Delay_For;
end System.Native_Time;
|
-- ASCII85
-- Various binary data to ASCII codecs known as Base85, ASCII85 etc
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
with System.Storage_Elements;
with BinToAsc, BinToAsc.Base85;
package ASCII85 is
package BToA is new BinToAsc(Bin => System.Storage_Elements.Storage_Element,
Bin_Array_Index => System.Storage_Elements.Storage_Offset,
Bin_Array => System.Storage_Elements.Storage_Array);
use type BToA.Alphabet;
subtype Codec_State is BToA.Codec_State;
function Ready return BToA.Codec_State renames BToA.Ready;
function Complete return BToA.Codec_State renames BToA.Completed;
function Failed return BToA.Codec_State renames BToA.Failed;
Z85_Alphabet : constant BToA.Alphabet_85 :=
"0123456789" &
"abcdefghij" &
"klmnopqrst" &
"uvwxyzABCD" &
"EFGHIJKLMN" &
"OPQRSTUVWX" &
"YZ.-:+=^!/" &
"*?&<>()[]{" &
"}@%$#";
package Z85 is new BToA.Base85(Alphabet => Z85_Alphabet);
end ASCII85;
|
-- Generated by gen-ada-entities.pl latin1.ent symbol.ent special.ent
private package Wiki.Parsers.Html.Entities is
pragma Preelaborate;
AELIG_NAME : aliased constant String := "AElig";
AACUTE_NAME : aliased constant String := "Aacute";
ACIRC_NAME : aliased constant String := "Acirc";
AGRAVE_NAME : aliased constant String := "Agrave";
ALPHA_NAME : aliased constant String := "Alpha";
ARING_NAME : aliased constant String := "Aring";
ATILDE_NAME : aliased constant String := "Atilde";
AUML_NAME : aliased constant String := "Auml";
BETA_NAME : aliased constant String := "Beta";
CCEDIL_NAME : aliased constant String := "Ccedil";
CHI_NAME : aliased constant String := "Chi";
DAGGER_NAME : aliased constant String := "Dagger";
DELTA_NAME : aliased constant String := "Delta";
ETH_NAME : aliased constant String := "ETH";
EACUTE_NAME : aliased constant String := "Eacute";
ECIRC_NAME : aliased constant String := "Ecirc";
EGRAVE_NAME : aliased constant String := "Egrave";
EPSILON_NAME : aliased constant String := "Epsilon";
ETA_NAME : aliased constant String := "Eta";
EUML_NAME : aliased constant String := "Euml";
GAMMA_NAME : aliased constant String := "Gamma";
IACUTE_NAME : aliased constant String := "Iacute";
ICIRC_NAME : aliased constant String := "Icirc";
IGRAVE_NAME : aliased constant String := "Igrave";
IOTA_NAME : aliased constant String := "Iota";
IUML_NAME : aliased constant String := "Iuml";
KAPPA_NAME : aliased constant String := "Kappa";
LAMBDA_NAME : aliased constant String := "Lambda";
MU_NAME : aliased constant String := "Mu";
NTILDE_NAME : aliased constant String := "Ntilde";
NU_NAME : aliased constant String := "Nu";
OELIG_NAME : aliased constant String := "OElig";
OACUTE_NAME : aliased constant String := "Oacute";
OCIRC_NAME : aliased constant String := "Ocirc";
OGRAVE_NAME : aliased constant String := "Ograve";
OMEGA_NAME : aliased constant String := "Omega";
OMICRON_NAME : aliased constant String := "Omicron";
OSLASH_NAME : aliased constant String := "Oslash";
OTILDE_NAME : aliased constant String := "Otilde";
OUML_NAME : aliased constant String := "Ouml";
PHI_NAME : aliased constant String := "Phi";
PI_NAME : aliased constant String := "Pi";
PRIME_NAME : aliased constant String := "Prime";
PSI_NAME : aliased constant String := "Psi";
RHO_NAME : aliased constant String := "Rho";
SCARON_NAME : aliased constant String := "Scaron";
SIGMA_NAME : aliased constant String := "Sigma";
THORN_NAME : aliased constant String := "THORN";
TAU_NAME : aliased constant String := "Tau";
THETA_NAME : aliased constant String := "Theta";
UACUTE_NAME : aliased constant String := "Uacute";
UCIRC_NAME : aliased constant String := "Ucirc";
UGRAVE_NAME : aliased constant String := "Ugrave";
UPSILON_NAME : aliased constant String := "Upsilon";
UUML_NAME : aliased constant String := "Uuml";
XI_NAME : aliased constant String := "Xi";
YACUTE_NAME : aliased constant String := "Yacute";
YUML_NAME : aliased constant String := "Yuml";
ZETA_NAME : aliased constant String := "Zeta";
N59_NAME : aliased constant String := "aacute";
N60_NAME : aliased constant String := "acirc";
ACUTE_NAME : aliased constant String := "acute";
N62_NAME : aliased constant String := "aelig";
N63_NAME : aliased constant String := "agrave";
ALEFSYM_NAME : aliased constant String := "alefsym";
N65_NAME : aliased constant String := "alpha";
AMP_NAME : aliased constant String := "amp";
AND_NAME : aliased constant String := "and";
ANG_NAME : aliased constant String := "ang";
APOS_NAME : aliased constant String := "apos";
N70_NAME : aliased constant String := "aring";
ASYMP_NAME : aliased constant String := "asymp";
N72_NAME : aliased constant String := "atilde";
N73_NAME : aliased constant String := "auml";
BDQUO_NAME : aliased constant String := "bdquo";
N75_NAME : aliased constant String := "beta";
BRVBAR_NAME : aliased constant String := "brvbar";
BULL_NAME : aliased constant String := "bull";
CAP_NAME : aliased constant String := "cap";
N79_NAME : aliased constant String := "ccedil";
CEDIL_NAME : aliased constant String := "cedil";
CENT_NAME : aliased constant String := "cent";
N82_NAME : aliased constant String := "chi";
CIRC_NAME : aliased constant String := "circ";
CLUBS_NAME : aliased constant String := "clubs";
CONG_NAME : aliased constant String := "cong";
COPY_NAME : aliased constant String := "copy";
CRARR_NAME : aliased constant String := "crarr";
CUP_NAME : aliased constant String := "cup";
CURREN_NAME : aliased constant String := "curren";
DARR_NAME : aliased constant String := "dArr";
N91_NAME : aliased constant String := "dagger";
N92_NAME : aliased constant String := "darr";
DEG_NAME : aliased constant String := "deg";
N94_NAME : aliased constant String := "delta";
DIAMS_NAME : aliased constant String := "diams";
DIVIDE_NAME : aliased constant String := "divide";
N97_NAME : aliased constant String := "eacute";
N98_NAME : aliased constant String := "ecirc";
N99_NAME : aliased constant String := "egrave";
EMPTY_NAME : aliased constant String := "empty";
EMSP_NAME : aliased constant String := "emsp";
ENSP_NAME : aliased constant String := "ensp";
N103_NAME : aliased constant String := "epsilon";
EQUIV_NAME : aliased constant String := "equiv";
N105_NAME : aliased constant String := "eta";
N106_NAME : aliased constant String := "eth";
N107_NAME : aliased constant String := "euml";
EURO_NAME : aliased constant String := "euro";
EXIST_NAME : aliased constant String := "exist";
FNOF_NAME : aliased constant String := "fnof";
FORALL_NAME : aliased constant String := "forall";
FRAC12_NAME : aliased constant String := "frac12";
FRAC14_NAME : aliased constant String := "frac14";
FRAC34_NAME : aliased constant String := "frac34";
FRASL_NAME : aliased constant String := "frasl";
N116_NAME : aliased constant String := "gamma";
GE_NAME : aliased constant String := "ge";
GT_NAME : aliased constant String := "gt";
HARR_NAME : aliased constant String := "hArr";
N120_NAME : aliased constant String := "harr";
HEARTS_NAME : aliased constant String := "hearts";
HELLIP_NAME : aliased constant String := "hellip";
N123_NAME : aliased constant String := "iacute";
N124_NAME : aliased constant String := "icirc";
IEXCL_NAME : aliased constant String := "iexcl";
N126_NAME : aliased constant String := "igrave";
IMAGE_NAME : aliased constant String := "image";
INFIN_NAME : aliased constant String := "infin";
INT_NAME : aliased constant String := "int";
N130_NAME : aliased constant String := "iota";
IQUEST_NAME : aliased constant String := "iquest";
ISIN_NAME : aliased constant String := "isin";
N133_NAME : aliased constant String := "iuml";
N134_NAME : aliased constant String := "kappa";
LARR_NAME : aliased constant String := "lArr";
N136_NAME : aliased constant String := "lambda";
LANG_NAME : aliased constant String := "lang";
LAQUO_NAME : aliased constant String := "laquo";
N139_NAME : aliased constant String := "larr";
LCEIL_NAME : aliased constant String := "lceil";
LDQUO_NAME : aliased constant String := "ldquo";
LE_NAME : aliased constant String := "le";
LFLOOR_NAME : aliased constant String := "lfloor";
LOWAST_NAME : aliased constant String := "lowast";
LOZ_NAME : aliased constant String := "loz";
LRM_NAME : aliased constant String := "lrm";
LSAQUO_NAME : aliased constant String := "lsaquo";
LSQUO_NAME : aliased constant String := "lsquo";
LT_NAME : aliased constant String := "lt";
MACR_NAME : aliased constant String := "macr";
MDASH_NAME : aliased constant String := "mdash";
MICRO_NAME : aliased constant String := "micro";
MIDDOT_NAME : aliased constant String := "middot";
MINUS_NAME : aliased constant String := "minus";
N155_NAME : aliased constant String := "mu";
NABLA_NAME : aliased constant String := "nabla";
NBSP_NAME : aliased constant String := "nbsp";
NDASH_NAME : aliased constant String := "ndash";
NE_NAME : aliased constant String := "ne";
NI_NAME : aliased constant String := "ni";
NOT_NAME : aliased constant String := "not";
NOTIN_NAME : aliased constant String := "notin";
NSUB_NAME : aliased constant String := "nsub";
N164_NAME : aliased constant String := "ntilde";
N165_NAME : aliased constant String := "nu";
N166_NAME : aliased constant String := "oacute";
N167_NAME : aliased constant String := "ocirc";
N168_NAME : aliased constant String := "oelig";
N169_NAME : aliased constant String := "ograve";
OLINE_NAME : aliased constant String := "oline";
N171_NAME : aliased constant String := "omega";
N172_NAME : aliased constant String := "omicron";
OPLUS_NAME : aliased constant String := "oplus";
OR_NAME : aliased constant String := "or";
ORDF_NAME : aliased constant String := "ordf";
ORDM_NAME : aliased constant String := "ordm";
N177_NAME : aliased constant String := "oslash";
N178_NAME : aliased constant String := "otilde";
OTIMES_NAME : aliased constant String := "otimes";
N180_NAME : aliased constant String := "ouml";
PARA_NAME : aliased constant String := "para";
PART_NAME : aliased constant String := "part";
PERMIL_NAME : aliased constant String := "permil";
PERP_NAME : aliased constant String := "perp";
N185_NAME : aliased constant String := "phi";
N186_NAME : aliased constant String := "pi";
PIV_NAME : aliased constant String := "piv";
PLUSMN_NAME : aliased constant String := "plusmn";
POUND_NAME : aliased constant String := "pound";
N190_NAME : aliased constant String := "prime";
PROD_NAME : aliased constant String := "prod";
PROP_NAME : aliased constant String := "prop";
N193_NAME : aliased constant String := "psi";
QUOT_NAME : aliased constant String := "quot";
RARR_NAME : aliased constant String := "rArr";
RADIC_NAME : aliased constant String := "radic";
RANG_NAME : aliased constant String := "rang";
RAQUO_NAME : aliased constant String := "raquo";
N199_NAME : aliased constant String := "rarr";
RCEIL_NAME : aliased constant String := "rceil";
RDQUO_NAME : aliased constant String := "rdquo";
REAL_NAME : aliased constant String := "real";
REG_NAME : aliased constant String := "reg";
RFLOOR_NAME : aliased constant String := "rfloor";
N205_NAME : aliased constant String := "rho";
RLM_NAME : aliased constant String := "rlm";
RSAQUO_NAME : aliased constant String := "rsaquo";
RSQUO_NAME : aliased constant String := "rsquo";
SBQUO_NAME : aliased constant String := "sbquo";
N210_NAME : aliased constant String := "scaron";
SDOT_NAME : aliased constant String := "sdot";
SECT_NAME : aliased constant String := "sect";
SHY_NAME : aliased constant String := "shy";
N214_NAME : aliased constant String := "sigma";
SIGMAF_NAME : aliased constant String := "sigmaf";
SIM_NAME : aliased constant String := "sim";
SPADES_NAME : aliased constant String := "spades";
SUB_NAME : aliased constant String := "sub";
SUBE_NAME : aliased constant String := "sube";
SUM_NAME : aliased constant String := "sum";
SUP_NAME : aliased constant String := "sup";
SUP1_NAME : aliased constant String := "sup1";
SUP2_NAME : aliased constant String := "sup2";
SUP3_NAME : aliased constant String := "sup3";
SUPE_NAME : aliased constant String := "supe";
SZLIG_NAME : aliased constant String := "szlig";
N227_NAME : aliased constant String := "tau";
THERE4_NAME : aliased constant String := "there4";
N229_NAME : aliased constant String := "theta";
THETASYM_NAME : aliased constant String := "thetasym";
THINSP_NAME : aliased constant String := "thinsp";
N232_NAME : aliased constant String := "thorn";
TILDE_NAME : aliased constant String := "tilde";
TIMES_NAME : aliased constant String := "times";
TRADE_NAME : aliased constant String := "trade";
UARR_NAME : aliased constant String := "uArr";
N237_NAME : aliased constant String := "uacute";
N238_NAME : aliased constant String := "uarr";
N239_NAME : aliased constant String := "ucirc";
N240_NAME : aliased constant String := "ugrave";
UML_NAME : aliased constant String := "uml";
UPSIH_NAME : aliased constant String := "upsih";
N243_NAME : aliased constant String := "upsilon";
N244_NAME : aliased constant String := "uuml";
WEIERP_NAME : aliased constant String := "weierp";
N246_NAME : aliased constant String := "xi";
N247_NAME : aliased constant String := "yacute";
YEN_NAME : aliased constant String := "yen";
N249_NAME : aliased constant String := "yuml";
N250_NAME : aliased constant String := "zeta";
ZWJ_NAME : aliased constant String := "zwj";
ZWNJ_NAME : aliased constant String := "zwnj";
type String_Access is access constant String;
type Keyword_Array is array (Positive range 1 .. 253) of String_Access;
type Char_Array is array (Positive range 1 .. 253) of Wide_Wide_Character;
Keywords : constant Keyword_Array := (
AELIG_NAME'Access,
AACUTE_NAME'Access,
ACIRC_NAME'Access,
AGRAVE_NAME'Access,
ALPHA_NAME'Access,
ARING_NAME'Access,
ATILDE_NAME'Access,
AUML_NAME'Access,
BETA_NAME'Access,
CCEDIL_NAME'Access,
CHI_NAME'Access,
DAGGER_NAME'Access,
DELTA_NAME'Access,
ETH_NAME'Access,
EACUTE_NAME'Access,
ECIRC_NAME'Access,
EGRAVE_NAME'Access,
EPSILON_NAME'Access,
ETA_NAME'Access,
EUML_NAME'Access,
GAMMA_NAME'Access,
IACUTE_NAME'Access,
ICIRC_NAME'Access,
IGRAVE_NAME'Access,
IOTA_NAME'Access,
IUML_NAME'Access,
KAPPA_NAME'Access,
LAMBDA_NAME'Access,
MU_NAME'Access,
NTILDE_NAME'Access,
NU_NAME'Access,
OELIG_NAME'Access,
OACUTE_NAME'Access,
OCIRC_NAME'Access,
OGRAVE_NAME'Access,
OMEGA_NAME'Access,
OMICRON_NAME'Access,
OSLASH_NAME'Access,
OTILDE_NAME'Access,
OUML_NAME'Access,
PHI_NAME'Access,
PI_NAME'Access,
PRIME_NAME'Access,
PSI_NAME'Access,
RHO_NAME'Access,
SCARON_NAME'Access,
SIGMA_NAME'Access,
THORN_NAME'Access,
TAU_NAME'Access,
THETA_NAME'Access,
UACUTE_NAME'Access,
UCIRC_NAME'Access,
UGRAVE_NAME'Access,
UPSILON_NAME'Access,
UUML_NAME'Access,
XI_NAME'Access,
YACUTE_NAME'Access,
YUML_NAME'Access,
ZETA_NAME'Access,
N59_NAME'Access,
N60_NAME'Access,
ACUTE_NAME'Access,
N62_NAME'Access,
N63_NAME'Access,
ALEFSYM_NAME'Access,
N65_NAME'Access,
AMP_NAME'Access,
AND_NAME'Access,
ANG_NAME'Access,
APOS_NAME'Access,
N70_NAME'Access,
ASYMP_NAME'Access,
N72_NAME'Access,
N73_NAME'Access,
BDQUO_NAME'Access,
N75_NAME'Access,
BRVBAR_NAME'Access,
BULL_NAME'Access,
CAP_NAME'Access,
N79_NAME'Access,
CEDIL_NAME'Access,
CENT_NAME'Access,
N82_NAME'Access,
CIRC_NAME'Access,
CLUBS_NAME'Access,
CONG_NAME'Access,
COPY_NAME'Access,
CRARR_NAME'Access,
CUP_NAME'Access,
CURREN_NAME'Access,
DARR_NAME'Access,
N91_NAME'Access,
N92_NAME'Access,
DEG_NAME'Access,
N94_NAME'Access,
DIAMS_NAME'Access,
DIVIDE_NAME'Access,
N97_NAME'Access,
N98_NAME'Access,
N99_NAME'Access,
EMPTY_NAME'Access,
EMSP_NAME'Access,
ENSP_NAME'Access,
N103_NAME'Access,
EQUIV_NAME'Access,
N105_NAME'Access,
N106_NAME'Access,
N107_NAME'Access,
EURO_NAME'Access,
EXIST_NAME'Access,
FNOF_NAME'Access,
FORALL_NAME'Access,
FRAC12_NAME'Access,
FRAC14_NAME'Access,
FRAC34_NAME'Access,
FRASL_NAME'Access,
N116_NAME'Access,
GE_NAME'Access,
GT_NAME'Access,
HARR_NAME'Access,
N120_NAME'Access,
HEARTS_NAME'Access,
HELLIP_NAME'Access,
N123_NAME'Access,
N124_NAME'Access,
IEXCL_NAME'Access,
N126_NAME'Access,
IMAGE_NAME'Access,
INFIN_NAME'Access,
INT_NAME'Access,
N130_NAME'Access,
IQUEST_NAME'Access,
ISIN_NAME'Access,
N133_NAME'Access,
N134_NAME'Access,
LARR_NAME'Access,
N136_NAME'Access,
LANG_NAME'Access,
LAQUO_NAME'Access,
N139_NAME'Access,
LCEIL_NAME'Access,
LDQUO_NAME'Access,
LE_NAME'Access,
LFLOOR_NAME'Access,
LOWAST_NAME'Access,
LOZ_NAME'Access,
LRM_NAME'Access,
LSAQUO_NAME'Access,
LSQUO_NAME'Access,
LT_NAME'Access,
MACR_NAME'Access,
MDASH_NAME'Access,
MICRO_NAME'Access,
MIDDOT_NAME'Access,
MINUS_NAME'Access,
N155_NAME'Access,
NABLA_NAME'Access,
NBSP_NAME'Access,
NDASH_NAME'Access,
NE_NAME'Access,
NI_NAME'Access,
NOT_NAME'Access,
NOTIN_NAME'Access,
NSUB_NAME'Access,
N164_NAME'Access,
N165_NAME'Access,
N166_NAME'Access,
N167_NAME'Access,
N168_NAME'Access,
N169_NAME'Access,
OLINE_NAME'Access,
N171_NAME'Access,
N172_NAME'Access,
OPLUS_NAME'Access,
OR_NAME'Access,
ORDF_NAME'Access,
ORDM_NAME'Access,
N177_NAME'Access,
N178_NAME'Access,
OTIMES_NAME'Access,
N180_NAME'Access,
PARA_NAME'Access,
PART_NAME'Access,
PERMIL_NAME'Access,
PERP_NAME'Access,
N185_NAME'Access,
N186_NAME'Access,
PIV_NAME'Access,
PLUSMN_NAME'Access,
POUND_NAME'Access,
N190_NAME'Access,
PROD_NAME'Access,
PROP_NAME'Access,
N193_NAME'Access,
QUOT_NAME'Access,
RARR_NAME'Access,
RADIC_NAME'Access,
RANG_NAME'Access,
RAQUO_NAME'Access,
N199_NAME'Access,
RCEIL_NAME'Access,
RDQUO_NAME'Access,
REAL_NAME'Access,
REG_NAME'Access,
RFLOOR_NAME'Access,
N205_NAME'Access,
RLM_NAME'Access,
RSAQUO_NAME'Access,
RSQUO_NAME'Access,
SBQUO_NAME'Access,
N210_NAME'Access,
SDOT_NAME'Access,
SECT_NAME'Access,
SHY_NAME'Access,
N214_NAME'Access,
SIGMAF_NAME'Access,
SIM_NAME'Access,
SPADES_NAME'Access,
SUB_NAME'Access,
SUBE_NAME'Access,
SUM_NAME'Access,
SUP_NAME'Access,
SUP1_NAME'Access,
SUP2_NAME'Access,
SUP3_NAME'Access,
SUPE_NAME'Access,
SZLIG_NAME'Access,
N227_NAME'Access,
THERE4_NAME'Access,
N229_NAME'Access,
THETASYM_NAME'Access,
THINSP_NAME'Access,
N232_NAME'Access,
TILDE_NAME'Access,
TIMES_NAME'Access,
TRADE_NAME'Access,
UARR_NAME'Access,
N237_NAME'Access,
N238_NAME'Access,
N239_NAME'Access,
N240_NAME'Access,
UML_NAME'Access,
UPSIH_NAME'Access,
N243_NAME'Access,
N244_NAME'Access,
WEIERP_NAME'Access,
N246_NAME'Access,
N247_NAME'Access,
YEN_NAME'Access,
N249_NAME'Access,
N250_NAME'Access,
ZWJ_NAME'Access,
ZWNJ_NAME'Access);
Mapping : constant Char_Array := (
Wide_Wide_Character'Val (198),
Wide_Wide_Character'Val (193),
Wide_Wide_Character'Val (194),
Wide_Wide_Character'Val (192),
Wide_Wide_Character'Val (913),
Wide_Wide_Character'Val (197),
Wide_Wide_Character'Val (195),
Wide_Wide_Character'Val (196),
Wide_Wide_Character'Val (914),
Wide_Wide_Character'Val (199),
Wide_Wide_Character'Val (935),
Wide_Wide_Character'Val (8225),
Wide_Wide_Character'Val (916),
Wide_Wide_Character'Val (208),
Wide_Wide_Character'Val (201),
Wide_Wide_Character'Val (202),
Wide_Wide_Character'Val (200),
Wide_Wide_Character'Val (917),
Wide_Wide_Character'Val (919),
Wide_Wide_Character'Val (203),
Wide_Wide_Character'Val (915),
Wide_Wide_Character'Val (205),
Wide_Wide_Character'Val (206),
Wide_Wide_Character'Val (204),
Wide_Wide_Character'Val (921),
Wide_Wide_Character'Val (207),
Wide_Wide_Character'Val (922),
Wide_Wide_Character'Val (923),
Wide_Wide_Character'Val (924),
Wide_Wide_Character'Val (209),
Wide_Wide_Character'Val (925),
Wide_Wide_Character'Val (338),
Wide_Wide_Character'Val (211),
Wide_Wide_Character'Val (212),
Wide_Wide_Character'Val (210),
Wide_Wide_Character'Val (937),
Wide_Wide_Character'Val (927),
Wide_Wide_Character'Val (216),
Wide_Wide_Character'Val (213),
Wide_Wide_Character'Val (214),
Wide_Wide_Character'Val (934),
Wide_Wide_Character'Val (928),
Wide_Wide_Character'Val (8243),
Wide_Wide_Character'Val (936),
Wide_Wide_Character'Val (929),
Wide_Wide_Character'Val (352),
Wide_Wide_Character'Val (931),
Wide_Wide_Character'Val (222),
Wide_Wide_Character'Val (932),
Wide_Wide_Character'Val (920),
Wide_Wide_Character'Val (218),
Wide_Wide_Character'Val (219),
Wide_Wide_Character'Val (217),
Wide_Wide_Character'Val (933),
Wide_Wide_Character'Val (220),
Wide_Wide_Character'Val (926),
Wide_Wide_Character'Val (221),
Wide_Wide_Character'Val (376),
Wide_Wide_Character'Val (918),
Wide_Wide_Character'Val (225),
Wide_Wide_Character'Val (226),
Wide_Wide_Character'Val (180),
Wide_Wide_Character'Val (230),
Wide_Wide_Character'Val (224),
Wide_Wide_Character'Val (8501),
Wide_Wide_Character'Val (945),
Wide_Wide_Character'Val (38),
Wide_Wide_Character'Val (8743),
Wide_Wide_Character'Val (8736),
Wide_Wide_Character'Val (39),
Wide_Wide_Character'Val (229),
Wide_Wide_Character'Val (8776),
Wide_Wide_Character'Val (227),
Wide_Wide_Character'Val (228),
Wide_Wide_Character'Val (8222),
Wide_Wide_Character'Val (946),
Wide_Wide_Character'Val (166),
Wide_Wide_Character'Val (8226),
Wide_Wide_Character'Val (8745),
Wide_Wide_Character'Val (231),
Wide_Wide_Character'Val (184),
Wide_Wide_Character'Val (162),
Wide_Wide_Character'Val (967),
Wide_Wide_Character'Val (710),
Wide_Wide_Character'Val (9827),
Wide_Wide_Character'Val (8773),
Wide_Wide_Character'Val (169),
Wide_Wide_Character'Val (8629),
Wide_Wide_Character'Val (8746),
Wide_Wide_Character'Val (164),
Wide_Wide_Character'Val (8659),
Wide_Wide_Character'Val (8224),
Wide_Wide_Character'Val (8595),
Wide_Wide_Character'Val (176),
Wide_Wide_Character'Val (948),
Wide_Wide_Character'Val (9830),
Wide_Wide_Character'Val (247),
Wide_Wide_Character'Val (233),
Wide_Wide_Character'Val (234),
Wide_Wide_Character'Val (232),
Wide_Wide_Character'Val (8709),
Wide_Wide_Character'Val (8195),
Wide_Wide_Character'Val (8194),
Wide_Wide_Character'Val (949),
Wide_Wide_Character'Val (8801),
Wide_Wide_Character'Val (951),
Wide_Wide_Character'Val (240),
Wide_Wide_Character'Val (235),
Wide_Wide_Character'Val (8364),
Wide_Wide_Character'Val (8707),
Wide_Wide_Character'Val (402),
Wide_Wide_Character'Val (8704),
Wide_Wide_Character'Val (189),
Wide_Wide_Character'Val (188),
Wide_Wide_Character'Val (190),
Wide_Wide_Character'Val (8260),
Wide_Wide_Character'Val (947),
Wide_Wide_Character'Val (8805),
Wide_Wide_Character'Val (62),
Wide_Wide_Character'Val (8660),
Wide_Wide_Character'Val (8596),
Wide_Wide_Character'Val (9829),
Wide_Wide_Character'Val (8230),
Wide_Wide_Character'Val (237),
Wide_Wide_Character'Val (238),
Wide_Wide_Character'Val (161),
Wide_Wide_Character'Val (236),
Wide_Wide_Character'Val (8465),
Wide_Wide_Character'Val (8734),
Wide_Wide_Character'Val (8747),
Wide_Wide_Character'Val (953),
Wide_Wide_Character'Val (191),
Wide_Wide_Character'Val (8712),
Wide_Wide_Character'Val (239),
Wide_Wide_Character'Val (954),
Wide_Wide_Character'Val (8656),
Wide_Wide_Character'Val (955),
Wide_Wide_Character'Val (9001),
Wide_Wide_Character'Val (171),
Wide_Wide_Character'Val (8592),
Wide_Wide_Character'Val (8968),
Wide_Wide_Character'Val (8220),
Wide_Wide_Character'Val (8804),
Wide_Wide_Character'Val (8970),
Wide_Wide_Character'Val (8727),
Wide_Wide_Character'Val (9674),
Wide_Wide_Character'Val (8206),
Wide_Wide_Character'Val (8249),
Wide_Wide_Character'Val (8216),
Wide_Wide_Character'Val (60),
Wide_Wide_Character'Val (175),
Wide_Wide_Character'Val (8212),
Wide_Wide_Character'Val (181),
Wide_Wide_Character'Val (183),
Wide_Wide_Character'Val (8722),
Wide_Wide_Character'Val (956),
Wide_Wide_Character'Val (8711),
Wide_Wide_Character'Val (160),
Wide_Wide_Character'Val (8211),
Wide_Wide_Character'Val (8800),
Wide_Wide_Character'Val (8715),
Wide_Wide_Character'Val (172),
Wide_Wide_Character'Val (8713),
Wide_Wide_Character'Val (8836),
Wide_Wide_Character'Val (241),
Wide_Wide_Character'Val (957),
Wide_Wide_Character'Val (243),
Wide_Wide_Character'Val (244),
Wide_Wide_Character'Val (339),
Wide_Wide_Character'Val (242),
Wide_Wide_Character'Val (8254),
Wide_Wide_Character'Val (969),
Wide_Wide_Character'Val (959),
Wide_Wide_Character'Val (8853),
Wide_Wide_Character'Val (8744),
Wide_Wide_Character'Val (170),
Wide_Wide_Character'Val (186),
Wide_Wide_Character'Val (248),
Wide_Wide_Character'Val (245),
Wide_Wide_Character'Val (8855),
Wide_Wide_Character'Val (246),
Wide_Wide_Character'Val (182),
Wide_Wide_Character'Val (8706),
Wide_Wide_Character'Val (8240),
Wide_Wide_Character'Val (8869),
Wide_Wide_Character'Val (966),
Wide_Wide_Character'Val (960),
Wide_Wide_Character'Val (982),
Wide_Wide_Character'Val (177),
Wide_Wide_Character'Val (163),
Wide_Wide_Character'Val (8242),
Wide_Wide_Character'Val (8719),
Wide_Wide_Character'Val (8733),
Wide_Wide_Character'Val (968),
Wide_Wide_Character'Val (34),
Wide_Wide_Character'Val (8658),
Wide_Wide_Character'Val (8730),
Wide_Wide_Character'Val (9002),
Wide_Wide_Character'Val (187),
Wide_Wide_Character'Val (8594),
Wide_Wide_Character'Val (8969),
Wide_Wide_Character'Val (8221),
Wide_Wide_Character'Val (8476),
Wide_Wide_Character'Val (174),
Wide_Wide_Character'Val (8971),
Wide_Wide_Character'Val (961),
Wide_Wide_Character'Val (8207),
Wide_Wide_Character'Val (8250),
Wide_Wide_Character'Val (8217),
Wide_Wide_Character'Val (8218),
Wide_Wide_Character'Val (353),
Wide_Wide_Character'Val (8901),
Wide_Wide_Character'Val (167),
Wide_Wide_Character'Val (173),
Wide_Wide_Character'Val (963),
Wide_Wide_Character'Val (962),
Wide_Wide_Character'Val (8764),
Wide_Wide_Character'Val (9824),
Wide_Wide_Character'Val (8834),
Wide_Wide_Character'Val (8838),
Wide_Wide_Character'Val (8721),
Wide_Wide_Character'Val (8835),
Wide_Wide_Character'Val (185),
Wide_Wide_Character'Val (178),
Wide_Wide_Character'Val (179),
Wide_Wide_Character'Val (8839),
Wide_Wide_Character'Val (223),
Wide_Wide_Character'Val (964),
Wide_Wide_Character'Val (8756),
Wide_Wide_Character'Val (952),
Wide_Wide_Character'Val (977),
Wide_Wide_Character'Val (8201),
Wide_Wide_Character'Val (254),
Wide_Wide_Character'Val (732),
Wide_Wide_Character'Val (215),
Wide_Wide_Character'Val (8482),
Wide_Wide_Character'Val (8657),
Wide_Wide_Character'Val (250),
Wide_Wide_Character'Val (8593),
Wide_Wide_Character'Val (251),
Wide_Wide_Character'Val (249),
Wide_Wide_Character'Val (168),
Wide_Wide_Character'Val (978),
Wide_Wide_Character'Val (965),
Wide_Wide_Character'Val (252),
Wide_Wide_Character'Val (8472),
Wide_Wide_Character'Val (958),
Wide_Wide_Character'Val (253),
Wide_Wide_Character'Val (165),
Wide_Wide_Character'Val (255),
Wide_Wide_Character'Val (950),
Wide_Wide_Character'Val (8205),
Wide_Wide_Character'Val (8204));
end Wiki.Parsers.Html.Entities;
|
pragma License (Unrestricted);
with Ada.Numerics.Generic_Complex_Arrays;
with Ada.Numerics.Short_Complex_Types;
with Ada.Numerics.Short_Real_Arrays;
package Ada.Numerics.Short_Complex_Arrays is
new Generic_Complex_Arrays (Short_Real_Arrays, Short_Complex_Types);
pragma Pure (Ada.Numerics.Short_Complex_Arrays);
|
-- Change log:
-- GdM : 2005, 2006 : Get, Project also in Ada style
-- GdM : 29 - Jan - 2004 : added GLU.Get, (glGetdoublev) for GLU's matrices
-- GdM : 11 - Apr - 2002 : * adapated to the "GL .. ." and " .. .4x" - less GL
-- * "glu .. ." and other useless C prefixes removed
-- * removing of " .. .4f" - style siffixes in progress
-- Changed by MB for Windows 95, 980529
-- C replaced by Stdcall
--
-- OpenGL 1.1 Ada binding, package GLU
--
-- W. M. Richards, NiEstu, Phoenix AZ, December 1997
--
-- Converted from Brian Paul's Mesa package glu.h header file, version 2, 5.
-- As noted below in Brian's original comments, this code is distributed
-- under the terms of the GNU Library General Public License.
--
-- Version 0.1, 21 December 1997
--
--
-- Here are the original glu.h comments:
--
-- Mesa 3 - D graphics library
-- Version : 2.4
-- Copyright (C) 1995 - 1997 Brian Paul
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Library General Public
-- License as published by the Free Software Foundation; either
-- version 2 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Library General Public License for more details.
--
-- You should have received a copy of the GNU Library General Public
-- License along with this library; if not, write to the Free
-- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--
with GL;
package GLU is
VERSION_1_1 : constant := 1;
-- The GLU boolean constants
GL_FALSE : constant := GL.GL_False;
GL_TRUE : constant := GL.GL_True;
------------------------------------------------------------------------------
type Viewport_Rec is record
X, Y : aliased GL.Int;
Width, Height : aliased GL.Int;
end record;
type Matrix_Float is array (0 .. 3, 0 .. 3) of aliased GL.C_Float;
type Matrix_Double is array (0 .. 3, 0 .. 3) of aliased GL.Double;
type Viewport_Ptr is access all Viewport_Rec;
type Matrix_Float_Ptr is access all Matrix_Float;
type Matrix_Double_Ptr is access all Matrix_Double;
type GLUquadricObj is private;
type GLUtriangulatorObj is private;
type GLUnurbsObj is private;
type GLUquadricObjPtr is access all GLUquadricObj;
type GLUtriangulatorObjPtr is access all GLUtriangulatorObj;
type GLUnurbsObjPtr is access all GLUnurbsObj;
------------------------------------------------------------------------------
-- Error string
type ErrorEnm is
(
GL_NO_ERROR,
GL_INVALID_ENUM,
GL_INVALID_VALUE,
GL_INVALID_OPERATION,
GL_STACK_OVERFLOW,
GL_STACK_UNDERFLOW,
GL_OUT_OF_MEMORY,
GLU_INVALID_ENUM,
GLU_INVALID_VALUE,
GLU_OUT_OF_MEMORY,
GLU_INCOMPATIBLE_GL_VERSION
);
for ErrorEnm use
(
GL_NO_ERROR => 16#0000#,
GL_INVALID_ENUM => 16#0500#,
GL_INVALID_VALUE => 16#0501#,
GL_INVALID_OPERATION => 16#0502#,
GL_STACK_OVERFLOW => 16#0503#,
GL_STACK_UNDERFLOW => 16#0504#,
GL_OUT_OF_MEMORY => 16#0505#,
GLU_INVALID_ENUM => 16#18A24#,
GLU_INVALID_VALUE => 16#18A25#,
GLU_OUT_OF_MEMORY => 16#18A26#,
GLU_INCOMPATIBLE_GL_VERSION => 16#18A27# -- Mesa - specific?
);
for ErrorEnm'Size use GL.enum'Size;
function ErrorString (errorCode : ErrorEnm)
return GL.ubytePtr;
function Error_String (errorCode : GL.ErrorEnm)
return GL.ubytePtr;
-- Scale image
function ScaleImage (format : GL.PixelFormatEnm;
widthin : GL.Int;
heightin : GL.Int;
typein : GL.PixelDataTypeEnm;
datain : GL.pointer;
widthout : GL.Int;
heightout : GL.Int;
typeout : GL.PixelDataTypeEnm;
dataout : GL.pointer)
return GL.Int;
-- Build mipmaps
function Build1DMipmaps (target : GL.TargetTex1DOnlyEnm;
components : GL.Int;
width : GL.Int;
format : GL.TexPixelFormatEnm;
c_type : GL.PixelDataTypeEnm;
data : GL.pointer)
return GL.Int;
function Build2DMipmaps (target : GL.TargetTex2DOnlyEnm;
components : GL.Int;
width : GL.Int;
height : GL.Int;
format : GL.TexPixelFormatEnm;
c_type : GL.PixelDataTypeEnm;
data : GL.pointer)
return GL.Int;
-- Quadric objects
type DrawStyleEnm is
(
GLU_POINT,
GLU_LINE,
GLU_FILL,
GLU_SILHOUETTE
);
for DrawStyleEnm use
(
GLU_POINT => 16#186AA#,
GLU_LINE => 16#186AB#,
GLU_FILL => 16#186AC#,
GLU_SILHOUETTE => 16#186AD#
);
for DrawStyleEnm'Size use GL.enum'Size;
type OrientationEnm is
(
GLU_OUTSIDE,
GLU_INSIDE
);
for OrientationEnm use
(
GLU_OUTSIDE => 16#186B4#,
GLU_INSIDE => 16#186B5#
);
for OrientationEnm'Size use GL.enum'Size;
type NormalsEnm is
(
GLU_SMOOTH,
GLU_FLAT,
GLU_NONE
);
for NormalsEnm use
(
GLU_SMOOTH => 16#186A0#,
GLU_FLAT => 16#186A1#,
GLU_NONE => 16#186A2#
);
for NormalsEnm'Size use GL.enum'Size;
type CallbackEnm is
(
GLU_ERROR
);
for CallbackEnm use
(
GLU_ERROR => 16#18707#
);
for CallbackEnm'Size use GL.enum'Size;
type QuadricCallbackFunction is access procedure (Error : ErrorEnm);
function NewQuadric
return GLUquadricObjPtr;
procedure DeleteQuadric (state : GLUquadricObjPtr);
procedure QuadricDrawStyle (quadObject : GLUquadricObjPtr;
drawStyle : DrawStyleEnm);
procedure QuadricOrientation (quadObject : GLUquadricObjPtr;
orientation : OrientationEnm);
procedure QuadricNormals (quadObject : GLUquadricObjPtr;
normals : NormalsEnm);
procedure QuadricTexture (quadObject : GLUquadricObjPtr;
textureCoords : GL.GL_Boolean);
procedure QuadricCallback (qobj : GLUquadricObjPtr;
which : CallbackEnm;
fn : QuadricCallbackFunction);
procedure Cylinder (qobj : GLUquadricObjPtr;
baseRadius : GL.Double;
topRadius : GL.Double;
height : GL.Double;
slices : GL.Int;
stacks : GL.Int);
procedure Sphere (qobj : GLUquadricObjPtr;
radius : GL.Double;
slices : GL.Int;
stacks : GL.Int);
procedure Disk (qobj : GLUquadricObjPtr;
innerRadius : GL.Double;
outerRadius : GL.Double;
slices : GL.Int;
loops : GL.Int);
procedure PartialDisk (qobj : GLUquadricObjPtr;
innerRadius : GL.Double;
outerRadius : GL.Double;
slices : GL.Int;
loops : GL.Int;
startAngle : GL.Double;
sweepAngle : GL.Double);
-- Non - uniform rational B - splines (NURBS)
type NurbsPropertyEnm is
(
GLU_AUTO_LOAD_MATRIX,
GLU_CULLING,
GLU_PARAMETRIC_TOLERANCE,
GLU_SAMPLING_TOLERANCE,
GLU_DISPLAY_MODE,
GLU_SAMPLING_METHOD,
GLU_U_STEP,
GLU_V_STEP
);
for NurbsPropertyEnm use
(
GLU_AUTO_LOAD_MATRIX => 16#18768#,
GLU_CULLING => 16#18769#,
GLU_PARAMETRIC_TOLERANCE => 16#1876A#,
GLU_SAMPLING_TOLERANCE => 16#1876B#,
GLU_DISPLAY_MODE => 16#1876C#,
GLU_SAMPLING_METHOD => 16#1876D#,
GLU_U_STEP => 16#1876E#,
GLU_V_STEP => 16#1876F#
);
for NurbsPropertyEnm'Size use GL.enum'Size;
type NurbsDisplayModeEnm is
(
GLU_FILL,
GLU_OUTLINE_POLYGON,
GLU_OUTLINE_PATCH
);
for NurbsDisplayModeEnm use
(
GLU_FILL => 16#186AC#,
GLU_OUTLINE_POLYGON => 16#18790#,
GLU_OUTLINE_PATCH => 16#18791#
);
for NurbsDisplayModeEnm'Size use GL.enum'Size;
-- NURBS property values
GLU_PATH_LENGTH : constant := 16#18777#;
GLU_PARAMETRIC_ERROR : constant := 16#18778#;
GLU_DOMAIN_DISTANCE : constant := 16#18779#;
type NurbsErrorEnm is
(
GLU_NURBS_ERROR1, -- spline order un - supported ,
GLU_NURBS_ERROR2, -- too few knots ,
GLU_NURBS_ERROR3, -- valid knot range is empty ,
GLU_NURBS_ERROR4, -- decreasing knot sequence ,
GLU_NURBS_ERROR5, -- knot multiplicity > spline order ,
GLU_NURBS_ERROR6, -- endcurve () must follow bgncurve () ,
GLU_NURBS_ERROR7, -- bgncurve () must precede endcurve () ,
GLU_NURBS_ERROR8, -- ctrlarray or knot vector is NULL ,
GLU_NURBS_ERROR9, -- can't draw pwlcurves ,
GLU_NURBS_ERROR10, -- missing gluNurbsCurve () ,
GLU_NURBS_ERROR11, -- missing gluNurbsSurface () ,
GLU_NURBS_ERROR12, -- endtrim () must precede endsurface () ,
GLU_NURBS_ERROR13, -- bgnsurface () must precede endsurface () ,
GLU_NURBS_ERROR14, -- curve of improper type passed as trim curve ,
GLU_NURBS_ERROR15, -- bgnsurface () must precede bgntrim () ,
GLU_NURBS_ERROR16, -- endtrim () must follow bgntrim () ,
GLU_NURBS_ERROR17, -- bgntrim () must precede endtrim (),
GLU_NURBS_ERROR18, -- invalid or missing trim curve,
GLU_NURBS_ERROR19, -- bgntrim () must precede pwlcurve () ,
GLU_NURBS_ERROR20, -- pwlcurve referenced twice,
GLU_NURBS_ERROR21, -- pwlcurve and nurbscurve mixed ,
GLU_NURBS_ERROR22, -- improper usage of trim data type ,
GLU_NURBS_ERROR23, -- nurbscurve referenced twice ,
GLU_NURBS_ERROR24, -- nurbscurve and pwlcurve mixed ,
GLU_NURBS_ERROR25, -- nurbssurface referenced twice ,
GLU_NURBS_ERROR26, -- invalid property ,
GLU_NURBS_ERROR27, -- endsurface () must follow bgnsurface () ,
GLU_NURBS_ERROR28, -- intersecting or misoriented trim curves ,
GLU_NURBS_ERROR29, -- intersecting trim curves ,
GLU_NURBS_ERROR30, -- UNUSED ,
GLU_NURBS_ERROR31, -- unconnected trim curves ,
GLU_NURBS_ERROR32, -- unknown knot error ,
GLU_NURBS_ERROR33, -- negative vertex count encountered ,
GLU_NURBS_ERROR34, -- negative byte - stride ,
GLU_NURBS_ERROR35, -- unknown type descriptor ,
GLU_NURBS_ERROR36, -- null control point reference ,
GLU_NURBS_ERROR37 -- duplicate point on pwlcurve
);
for NurbsErrorEnm use
(
GLU_NURBS_ERROR1 => 16#1879B#,
GLU_NURBS_ERROR2 => 16#1879C#,
GLU_NURBS_ERROR3 => 16#1879D#,
GLU_NURBS_ERROR4 => 16#1879E#,
GLU_NURBS_ERROR5 => 16#1879F#,
GLU_NURBS_ERROR6 => 16#187A0#,
GLU_NURBS_ERROR7 => 16#187A1#,
GLU_NURBS_ERROR8 => 16#187A2#,
GLU_NURBS_ERROR9 => 16#187A3#,
GLU_NURBS_ERROR10 => 16#187A4#,
GLU_NURBS_ERROR11 => 16#187A5#,
GLU_NURBS_ERROR12 => 16#187A6#,
GLU_NURBS_ERROR13 => 16#187A7#,
GLU_NURBS_ERROR14 => 16#187A8#,
GLU_NURBS_ERROR15 => 16#187A9#,
GLU_NURBS_ERROR16 => 16#187AA#,
GLU_NURBS_ERROR17 => 16#187AB#,
GLU_NURBS_ERROR18 => 16#187AC#,
GLU_NURBS_ERROR19 => 16#187AD#,
GLU_NURBS_ERROR20 => 16#187AE#,
GLU_NURBS_ERROR21 => 16#187AF#,
GLU_NURBS_ERROR22 => 16#187B0#,
GLU_NURBS_ERROR23 => 16#187B1#,
GLU_NURBS_ERROR24 => 16#187B2#,
GLU_NURBS_ERROR25 => 16#187B3#,
GLU_NURBS_ERROR26 => 16#187B4#,
GLU_NURBS_ERROR27 => 16#187B5#,
GLU_NURBS_ERROR28 => 16#187B6#,
GLU_NURBS_ERROR29 => 16#187B7#,
GLU_NURBS_ERROR30 => 16#187B8#,
GLU_NURBS_ERROR31 => 16#187B9#,
GLU_NURBS_ERROR32 => 16#187BA#,
GLU_NURBS_ERROR33 => 16#187BB#,
GLU_NURBS_ERROR34 => 16#187BC#,
GLU_NURBS_ERROR35 => 16#187BD#,
GLU_NURBS_ERROR36 => 16#187BE#,
GLU_NURBS_ERROR37 => 16#187BF#
);
for NurbsErrorEnm'Size use GL.enum'Size;
type PwlCurveTypeEnm is
(
GLU_MAP1_TRIM_2,
GLU_MAP1_TRIM_3
);
for PwlCurveTypeEnm use
(
GLU_MAP1_TRIM_2 => 16#18772#,
GLU_MAP1_TRIM_3 => 16#18773#
);
for PwlCurveTypeEnm'Size use GL.enum'Size;
type NurbsCallbackFunction is access procedure (Error : NurbsErrorEnm);
function NewNurbsRenderer
return GLUnurbsObjPtr;
procedure DeleteNurbsRenderer (nobj : GLUnurbsObjPtr);
procedure LoadSamplingMatrices (nobj : GLUnurbsObjPtr;
modelMatrix : Matrix_Float_Ptr;
projMatrix : Matrix_Float_Ptr;
viewport : Viewport_Ptr);
procedure NurbsProperty (nobj : GLUnurbsObjPtr;
property : NurbsPropertyEnm;
value : GL.C_Float);
procedure GetNurbsProperty (nobj : GLUnurbsObjPtr;
property : NurbsPropertyEnm;
value : GL.floatPtr);
procedure BeginCurve (nobj : GLUnurbsObjPtr);
procedure EndCurve (nobj : GLUnurbsObjPtr);
procedure NurbsCurve (nobj : GLUnurbsObjPtr;
nknots : GL.Int;
knot : GL.floatPtr;
stride : GL.Int;
ctlarray : GL.floatPtr;
order : GL.Int;
c_type : GL.Map1TargetEnm);
procedure BeginSurface (nobj : GLUnurbsObjPtr);
procedure EndSurface (nobj : GLUnurbsObjPtr);
procedure NurbsSurface (nobj : GLUnurbsObjPtr;
sknot_count : GL.Int;
sknot : GL.floatPtr;
tknot_count : GL.Int;
tknot : GL.floatPtr;
s_stride : GL.Int;
t_stride : GL.Int;
ctlarray : GL.floatPtr;
sorder : GL.Int;
torder : GL.Int;
c_type : GL.Map2TargetEnm);
procedure BeginTrim (nobj : GLUnurbsObjPtr);
procedure EndTrim (nobj : GLUnurbsObjPtr);
procedure PwlCurve (nobj : GLUnurbsObjPtr;
count : GL.Int;
c_array : GL.floatPtr;
stride : GL.Int;
c_type : PwlCurveTypeEnm);
procedure NurbsCallback (nobj : GLUnurbsObjPtr;
which : CallbackEnm;
fn : NurbsCallbackFunction);
-- Polygon tesselation
type TessCallbackEnm is
(
GLU_BEGIN,
GLU_VERTEX,
GLU_END,
GLU_ERROR,
GLU_EDGE_FLAG
);
for TessCallbackEnm use
(
GLU_BEGIN => 16#18704#, -- Note : some implementations use "GLU_TESS_ .. ."
GLU_VERTEX => 16#18705#,
GLU_END => 16#18706#,
GLU_ERROR => 16#18707#,
GLU_EDGE_FLAG => 16#18708#
);
for TessCallbackEnm'Size use GL.enum'Size;
type TessBeginEnm is
(
GL_LINE_LOOP,
GL_TRIANGLES,
GL_TRIANGLE_STRIP,
GL_TRIANGLE_FAN
);
for TessBeginEnm use
(
GL_LINE_LOOP => 16#0002#,
GL_TRIANGLES => 16#0004#,
GL_TRIANGLE_STRIP => 16#0005#,
GL_TRIANGLE_FAN => 16#0006#
);
for TessBeginEnm'Size use GL.enum'Size;
type TessBeginCallbackFunction is access procedure (ObjType : TessBeginEnm);
type TessVertexCallbackFunction is access procedure (VertexData : GL.pointer);
type TessEndCallbackFunction is access procedure;
type TessErrorEnm is
(
GLU_TESS_ERROR1, -- missing gluEndPolygon ,
GLU_TESS_ERROR2, -- missing gluBeginPolygon ,
GLU_TESS_ERROR3, -- misoriented contour ,
GLU_TESS_ERROR4, -- vertex/edge intersection ,
GLU_TESS_ERROR5, -- misoriented or self - intersecting loops ,
GLU_TESS_ERROR6, -- coincident vertices ,
GLU_TESS_ERROR7, -- all vertices collinear ,
GLU_TESS_ERROR8, -- intersecting edges ,
GLU_TESS_ERROR9 -- not coplanar contours
);
for TessErrorEnm use
(
GLU_TESS_ERROR1 => 16#18737#,
GLU_TESS_ERROR2 => 16#18738#,
GLU_TESS_ERROR3 => 16#18739#,
GLU_TESS_ERROR4 => 16#1873A#,
GLU_TESS_ERROR5 => 16#1873B#,
GLU_TESS_ERROR6 => 16#1873C#,
GLU_TESS_ERROR7 => 16#1873D#,
GLU_TESS_ERROR8 => 16#1873E#,
GLU_TESS_ERROR9 => 16#1873F#
);
for TessErrorEnm'Size use GL.enum'Size;
type TessErrorCallbackFunction is access procedure (Error : TessErrorEnm);
type TessEdgeFlagCallbackFunction is access procedure (Flag : GL.GL_Boolean);
type ContourTypeEnm is
(
GLU_CW,
GLU_CCW,
GLU_INTERIOR,
GLU_EXTERIOR,
GLU_UNKNOWN
);
for ContourTypeEnm use
(
GLU_CW => 16#18718#,
GLU_CCW => 16#18719#,
GLU_INTERIOR => 16#1871A#,
GLU_EXTERIOR => 16#1871B#,
GLU_UNKNOWN => 16#1871C#
);
for ContourTypeEnm'Size use GL.enum'Size;
function NewTess
return GLUtriangulatorObjPtr;
procedure TessCallback (tobj : GLUtriangulatorObjPtr;
which : TessCallbackEnm;
fn : TessBeginCallbackFunction);
procedure TessCallback (tobj : GLUtriangulatorObjPtr;
which : TessCallbackEnm;
fn : TessVertexCallbackFunction);
procedure TessCallback (tobj : GLUtriangulatorObjPtr;
which : TessCallbackEnm;
fn : TessEndCallbackFunction);
procedure TessCallback (tobj : GLUtriangulatorObjPtr;
which : TessCallbackEnm;
fn : TessErrorCallbackFunction);
procedure TessCallback (tobj : GLUtriangulatorObjPtr;
which : TessCallbackEnm;
fn : TessEdgeFlagCallbackFunction);
procedure DeleteTess (tobj : GLUtriangulatorObjPtr);
procedure BeginPolygon (tobj : GLUtriangulatorObjPtr);
procedure EndPolygon (tobj : GLUtriangulatorObjPtr);
procedure NextContour (tobj : GLUtriangulatorObjPtr;
c_type : ContourTypeEnm);
procedure TessVertex (tobj : GLUtriangulatorObjPtr;
v : GL.doublePtr;
data : GL.pointer);
-- GLU strings
type StringEnm is
(
GLU_VERSION,
GLU_EXTENSIONS
);
for StringEnm use
(
GLU_VERSION => 16#189C0#,
GLU_EXTENSIONS => 16#189C1#
);
for StringEnm'Size use GL.enum'Size;
function GetString (name : StringEnm)
return GL.ubytePtr;
-- Projections
procedure LookAt (eyex : GL.Double;
eyey : GL.Double;
eyez : GL.Double;
centerx : GL.Double;
centery : GL.Double;
centerz : GL.Double;
upx : GL.Double;
upy : GL.Double;
upz : GL.Double);
procedure Ortho2D (left : GL.Double;
right : GL.Double;
bottom : GL.Double;
top : GL.Double);
procedure Perspective (fovy : GL.Double;
aspect : GL.Double;
zNear : GL.Double;
zFar : GL.Double);
procedure PickMatrix (x : GL.Double;
y : GL.Double;
width : GL.Double;
height : GL.Double;
viewport : Viewport_Ptr);
function Project (objx : GL.Double;
objy : GL.Double;
objz : GL.Double;
modelMatrix : Matrix_Double_Ptr;
projMatrix : Matrix_Double_Ptr;
viewport : Viewport_Ptr;
winx : GL.doublePtr;
winy : GL.doublePtr;
winz : GL.doublePtr)
return GL.Int;
pragma Import (Stdcall, Project, "gluProject");
-- Project, Ada style
procedure Project (objx : GL.Double;
objy : GL.Double;
objz : GL.Double;
modelMatrix : Matrix_Double;
projMatrix : Matrix_Double;
viewport : Viewport_Rec;
winx : out GL.Double;
winy : out GL.Double;
winz : out GL.Double;
result : out Boolean);
function UnProject (winx : GL.Double;
winy : GL.Double;
winz : GL.Double;
modelMatrix : Matrix_Double_Ptr;
projMatrix : Matrix_Double_Ptr;
viewport : Viewport_Ptr;
objx : GL.doublePtr;
objy : GL.doublePtr;
objz : GL.doublePtr)
return GL.Int;
-- GLU.Get's
procedure Get (pname : GL.ParameterNameEnm;
params : Matrix_Double_Ptr);
procedure Get (pname : GL.ParameterNameEnm;
params : out Matrix_Double);
procedure Get (pname : GL.ParameterNameEnm;
params : Viewport_Ptr);
procedure Get (params : out Viewport_Rec);
------------------------------------------------------------------------------
private
type GLUquadricObj is record null; end record;
type GLUtriangulatorObj is record null; end record;
type GLUnurbsObj is record null; end record;
pragma Import (Stdcall, LookAt, "gluLookAt");
pragma Import (Stdcall, Ortho2D, "gluOrtho2D");
pragma Import (Stdcall, Perspective, "gluPerspective");
pragma Import (Stdcall, PickMatrix, "gluPickMatrix");
-- pragma Import (Stdcall, Project, "gluProject");
pragma Import (Stdcall, UnProject, "gluUnProject");
function ErrorString_1 (errorCode : ErrorEnm) return GL.ubytePtr;
function ErrorString (errorCode : ErrorEnm) return GL.ubytePtr renames ErrorString_1;
pragma Import (Stdcall, ErrorString_1, "gluErrorString");
function ErrorString_2 (errorCode : GL.ErrorEnm) return GL.ubytePtr;
function Error_String (errorCode : GL.ErrorEnm) return GL.ubytePtr renames ErrorString_2;
pragma Import (Stdcall, ErrorString_2, "gluErrorString");
pragma Import (Stdcall, ScaleImage, "gluScaleImage");
pragma Import (Stdcall, Build1DMipmaps, "gluBuild1DMipmaps");
pragma Import (Stdcall, Build2DMipmaps, "gluBuild2DMipmaps");
pragma Import (Stdcall, NewQuadric, "gluNewQuadric");
pragma Import (Stdcall, DeleteQuadric, "gluDeleteQuadric");
pragma Import (Stdcall, QuadricDrawStyle, "gluQuadricDrawStyle");
pragma Import (Stdcall, QuadricOrientation, "gluQuadricOrientation");
pragma Import (Stdcall, QuadricNormals, "gluQuadricNormals");
pragma Import (Stdcall, QuadricTexture, "gluQuadricTexture");
pragma Import (Stdcall, QuadricCallback, "gluQuadricCallback");
pragma Import (Stdcall, Cylinder, "gluCylinder");
pragma Import (Stdcall, Sphere, "gluSphere");
pragma Import (Stdcall, Disk, "gluDisk");
pragma Import (Stdcall, PartialDisk, "gluPartialDisk");
pragma Import (Stdcall, NewNurbsRenderer, "gluNewNurbsRenderer");
pragma Import (Stdcall, DeleteNurbsRenderer, "gluDeleteNurbsRenderer");
pragma Import (Stdcall, LoadSamplingMatrices, "gluLoadSamplingMatrices");
pragma Import (Stdcall, NurbsProperty, "gluNurbsProperty");
pragma Import (Stdcall, GetNurbsProperty, "gluGetNurbsProperty");
pragma Import (Stdcall, BeginCurve, "gluBeginCurve");
pragma Import (Stdcall, EndCurve, "gluEndCurve");
pragma Import (Stdcall, NurbsCurve, "gluNurbsCurve");
pragma Import (Stdcall, BeginSurface, "gluBeginSurface");
pragma Import (Stdcall, EndSurface, "gluEndSurface");
pragma Import (Stdcall, NurbsSurface, "gluNurbsSurface");
pragma Import (Stdcall, BeginTrim, "gluBeginTrim");
pragma Import (Stdcall, EndTrim, "gluEndTrim");
pragma Import (Stdcall, PwlCurve, "gluPwlCurve");
pragma Import (Stdcall, NurbsCallback, "gluNurbsCallback");
pragma Import (Stdcall, NewTess, "gluNewTess");
pragma Import (Stdcall, TessCallback, "gluTessCallback");
pragma Import (Stdcall, DeleteTess, "gluDeleteTess");
pragma Import (Stdcall, BeginPolygon, "gluBeginPolygon");
pragma Import (Stdcall, EndPolygon, "gluEndPolygon");
pragma Import (Stdcall, NextContour, "gluNextContour");
pragma Import (Stdcall, TessVertex, "gluTessVertex");
pragma Import (Stdcall, GetString, "gluGetString");
-- GL procedures for GLU types:
-- Wrappers for Get (doubleMatrix)
procedure GetDoublev (pname : GL.ParameterNameEnm;
params : Matrix_Double_Ptr);
procedure Get (pname : GL.ParameterNameEnm;
params : Matrix_Double_Ptr) renames GetDoublev;
pragma Import (Stdcall, GetDoublev, "glGetDoublev");
-- Wrappers for Get (viewPortRec)
procedure GetIntegerv (pname : GL.ParameterNameEnm;
params : Viewport_Ptr);
procedure Get (pname : GL.ParameterNameEnm;
params : Viewport_Ptr) renames GetIntegerv;
pragma Import (Stdcall, GetIntegerv, "glGetIntegerv");
end GLU;
|
-- $Id: SetsDrv.mi,v 1.5 1992/09/24 13:05:19 grosch rel $
-- $Log: SetsDrv.mi,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with Sets, Text_Io; use Sets, Text_Io;
procedure SetsDrv is
package Int_Io is new Integer_IO (Integer); use Int_Io;
max : constant Integer := 1000;
s, t, u : tSet;
i, n : Integer;
f : File_Type;
begin
MakeSet (s, max);
MakeSet (t, max);
MakeSet (u, max);
for i in 2 .. max loop
Include (t, i);
end loop;
AssignEmpty (s);
AssignElmt (s, 1);
Assign (u, t);
Union (s, t);
AssignEmpty (t);
i := 0;
while i <= max loop
Include (t, i);
i := i + 2;
end loop;
Difference (s, t);
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 3;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 5;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 7;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 11;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 13;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 17;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 19;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 23;
end loop;
i := 0;
while i <= max loop
Exclude (s, i);
i := i + 29;
end loop;
Create (f, Out_File, "t");
WriteSet (f, s);
New_Line (f);
Close (f);
Open (f, In_File, "t");
ReadSet (f, t);
Close (f);
WriteSet (Standard_Output, t);
New_Line (Standard_Output);
Put (Standard_Output, Size (t), 5);
Card (t, n); Put (Standard_Output, n, 5);
Minimum (t, n); Put (Standard_Output, n, 5);
Maximum (t, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
AssignEmpty (u);
i := 7;
while i <= max loop
Include (u, i);
i := i + 10;
end loop;
WriteSet (Standard_Output, u);
New_Line (Standard_Output);
Put (Standard_Output, Size (u), 5);
Card (u, n); Put (Standard_Output, n, 5);
Minimum (u, n); Put (Standard_Output, n, 5);
Maximum (u, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
Intersection (u, t);
WriteSet (Standard_Output, u);
New_Line (Standard_Output);
Put (Standard_Output, Size (u), 5);
Card (u, n); Put (Standard_Output, n, 5);
Minimum (u, n); Put (Standard_Output, n, 5);
Maximum (u, n); Put (Standard_Output, n, 5);
New_Line (Standard_Output);
ReleaseSet (s);
ReleaseSet (t);
ReleaseSet (u);
MakeSet (s, 10);
Include (s, 3);
Include (s, 7);
New_Line (Standard_Output);
Put (Standard_Output, "enter Size and Set like below! (Size=0 terminates)");
New_Line (Standard_Output);
Put (Standard_Output, "10 ");
WriteSet (Standard_Output, s);
New_Line (Standard_Output);
ReleaseSet (s);
loop
New_Line (Standard_Output);
Get (Standard_Input, i);
if i = 0 then exit; end if;
MakeSet (s, i);
ReadSet (Standard_Input, s);
WriteSet (Standard_Output, s);
Put (Standard_Output, " Card = "); Card (s, n); Put (Standard_Output, n, 0); New_Line (Standard_Output);
Complement(s);
WriteSet (Standard_Output, s);
Put (Standard_Output, " Card = "); Card (s, n); Put (Standard_Output, n, 0); New_Line (Standard_Output);
ReleaseSet(s);
end loop;
end SetsDrv;
|
-- Automatically generated, do not edit.
with OpenAL.Load;
package body OpenAL.Extension.EFX_Thin is
--
-- Load function for API pointers
--
function Load_API return API_t is
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Auxiliary_Effect_Slotf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Auxiliary_Effect_Slotfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Auxiliary_Effect_Sloti_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Auxiliary_Effect_Slotiv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Delete_Auxiliary_Effect_Slots_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Delete_Effects_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Delete_Filters_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Effectf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Effectfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Effecti_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Effectiv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Filterf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Filterfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Filteri_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Filteriv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Gen_Auxiliary_Effect_Slots_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Gen_Effects_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Gen_Filters_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Auxiliary_Effect_Slotf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Auxiliary_Effect_Slotfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Auxiliary_Effect_Sloti_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Auxiliary_Effect_Slotiv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Effectf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Effectfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Effecti_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Effectiv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Filterf_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Filterfv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Filteri_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Get_Filteriv_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Is_Auxiliary_Effect_Slot_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Is_Effect_t);
function Load_Function is new Load.Load_Subprogram
(Subprogram_Access_Type => Is_Filter_t);
begin
return API_t'
(Auxiliary_Effect_Slotf => Load_Function ("alAuxiliaryEffectSlotf"),
Auxiliary_Effect_Slotfv => Load_Function ("alAuxiliaryEffectSlotfv"),
Auxiliary_Effect_Sloti => Load_Function ("alAuxiliaryEffectSloti"),
Auxiliary_Effect_Slotiv => Load_Function ("alAuxiliaryEffectSlotiv"),
Delete_Auxiliary_Effect_Slots => Load_Function ("alDeleteAuxiliaryEffectSlots"),
Delete_Effects => Load_Function ("alDeleteEffects"),
Delete_Filters => Load_Function ("alDeleteFilters"),
Effectf => Load_Function ("alEffectf"),
Effectfv => Load_Function ("alEffectfv"),
Effecti => Load_Function ("alEffecti"),
Effectiv => Load_Function ("alEffectiv"),
Filterf => Load_Function ("alFilterf"),
Filterfv => Load_Function ("alFilterfv"),
Filteri => Load_Function ("alFilteri"),
Filteriv => Load_Function ("alFilteriv"),
Gen_Auxiliary_Effect_Slots => Load_Function ("alGenAuxiliaryEffectSlots"),
Gen_Effects => Load_Function ("alGenEffects"),
Gen_Filters => Load_Function ("alGenFilters"),
Get_Auxiliary_Effect_Slotf => Load_Function ("alGetAuxiliaryEffectSlotf"),
Get_Auxiliary_Effect_Slotfv => Load_Function ("alGetAuxiliaryEffectSlotfv"),
Get_Auxiliary_Effect_Sloti => Load_Function ("alGetAuxiliaryEffectSloti"),
Get_Auxiliary_Effect_Slotiv => Load_Function ("alGetAuxiliaryEffectSlotiv"),
Get_Effectf => Load_Function ("alGetEffectf"),
Get_Effectfv => Load_Function ("alGetEffectfv"),
Get_Effecti => Load_Function ("alGetEffecti"),
Get_Effectiv => Load_Function ("alGetEffectiv"),
Get_Filterf => Load_Function ("alGetFilterf"),
Get_Filterfv => Load_Function ("alGetFilterfv"),
Get_Filteri => Load_Function ("alGetFilteri"),
Get_Filteriv => Load_Function ("alGetFilteriv"),
Is_Auxiliary_Effect_Slot => Load_Function ("alIsAuxiliaryEffectSlot"),
Is_Effect => Load_Function ("alIsEffect"),
Is_Filter => Load_Function ("alIsFilter"));
end Load_API;
end OpenAL.Extension.EFX_Thin;
|
with Ada.Unchecked_Deallocation;
with Test_Utils.Abstract_Encoder.COBS_Simple;
with Test_Utils.Abstract_Encoder.COBS_Stream;
with Test_Utils.Abstract_Encoder.COBS_Queue;
with Testsuite.Encode.Basic_Tests;
with Testsuite.Encode.Multiframe_Tests;
package body Testsuite.Encode is
Kind : Encoder_Kind := Encoder_Kind'First;
----------------------
-- Set_Encoder_Kind --
----------------------
procedure Set_Encoder_Kind (K : Encoder_Kind) is
begin
Kind := K;
end Set_Encoder_Kind;
------------
-- Set_Up --
------------
overriding
procedure Set_Up (Test : in out Encoder_Fixture) is
begin
Test.Kind := Kind;
Test.Encoder := Create_Encoder (Kind);
end Set_Up;
---------------
-- Tear_Down --
---------------
overriding
procedure Tear_Down (Test : in out Encoder_Fixture) is
begin
Free_Encoder (Test.Encoder);
end Tear_Down;
---------------
-- Add_Tests --
---------------
procedure Add_Tests (Suite : in out AUnit.Test_Suites.Test_Suite'Class) is
begin
Testsuite.Encode.Basic_Tests.Add_Tests (Suite);
Testsuite.Encode.Multiframe_Tests.Add_Tests (Suite);
end Add_Tests;
--------------------
-- Create_Encoder --
--------------------
function Create_Encoder (K : Encoder_Kind)
return not null Test_Utils.Abstract_Encoder.Any_Acc
is
use Test_Utils.Abstract_Encoder;
begin
case K is
when Simple =>
return new COBS_Simple.Instance;
when Stream =>
return new COBS_Stream.Instance;
when Queue =>
return new COBS_Queue.Instance (2048);
end case;
end Create_Encoder;
------------------
-- Free_Encoder --
------------------
procedure Free_Encoder (Dec : in out Test_Utils.Abstract_Encoder.Any_Acc) is
use Test_Utils.Abstract_Encoder;
procedure Free is new Ada.Unchecked_Deallocation
(COBS_Simple.Instance,
COBS_Simple.Acc);
procedure Free is new Ada.Unchecked_Deallocation
(COBS_Stream.Instance,
COBS_Stream.Acc);
procedure Free is new Ada.Unchecked_Deallocation
(COBS_Queue.Instance,
COBS_Queue.Acc);
begin
if Dec.all in COBS_Simple.Instance'Class then
Free (COBS_Simple.Acc (Dec));
elsif Dec.all in COBS_Stream.Instance'Class then
Free (COBS_Stream.Acc (Dec));
elsif Dec.all in COBS_Queue.Instance'Class then
Free (COBS_Queue.Acc (Dec));
else
raise Program_Error;
end if;
end Free_Encoder;
end Testsuite.Encode;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- 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 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Interrupts.Names;
package System.SF2.GPIO is
subtype GPIO_Num is Integer range 0 .. 31;
type GPIO_Mode is
(Input_Mode,
Output_Mode,
In_Out_Mode);
type GPIO_Interrupt_Mode is
(IRQ_Level_High,
IRQ_Level_Low,
IRQ_Edge_Positive,
IRQ_Edge_Negative,
IRQ_Edge_Both);
procedure GPIO_Init;
procedure GPIO_Config
(Num : GPIO_Num;
Mode : GPIO_Mode);
procedure GPIO_Config_Interrupt
(Num : GPIO_Num;
Event : GPIO_Interrupt_Mode;
Mode : GPIO_Mode := Input_Mode);
procedure Set (Num : GPIO_Num)
with Inline_Always;
procedure Clear (Num : GPIO_Num)
with Inline_Always;
function Set (Num : GPIO_Num) return Boolean
with Inline_Always;
function Interrupt_Name
(Num : GPIO_Num) return Ada.Interrupts.Interrupt_ID;
private
function Interrupt_Name
(Num : GPIO_Num) return Ada.Interrupts.Interrupt_ID
is (case Num is
when 0 => Ada.Interrupts.Names.GPIO_INT_0_Interrupt,
when 1 => Ada.Interrupts.Names.GPIO_INT_1_Interrupt,
when 2 => Ada.Interrupts.Names.GPIO_INT_2_Interrupt,
when 3 => Ada.Interrupts.Names.GPIO_INT_3_Interrupt,
when 4 => Ada.Interrupts.Names.GPIO_INT_4_Interrupt,
when 5 => Ada.Interrupts.Names.GPIO_INT_5_Interrupt,
when 6 => Ada.Interrupts.Names.GPIO_INT_6_Interrupt,
when 7 => Ada.Interrupts.Names.GPIO_INT_7_Interrupt,
when 8 => Ada.Interrupts.Names.GPIO_INT_8_Interrupt,
when 9 => Ada.Interrupts.Names.GPIO_INT_9_Interrupt,
when 10 => Ada.Interrupts.Names.GPIO_INT_10_Interrupt,
when 11 => Ada.Interrupts.Names.GPIO_INT_11_Interrupt,
when 12 => Ada.Interrupts.Names.GPIO_INT_12_Interrupt,
when 13 => Ada.Interrupts.Names.GPIO_INT_13_Interrupt,
when 14 => Ada.Interrupts.Names.GPIO_INT_14_Interrupt,
when 15 => Ada.Interrupts.Names.GPIO_INT_15_Interrupt,
when 16 => Ada.Interrupts.Names.GPIO_INT_16_Interrupt,
when 17 => Ada.Interrupts.Names.GPIO_INT_17_Interrupt,
when 18 => Ada.Interrupts.Names.GPIO_INT_18_Interrupt,
when 19 => Ada.Interrupts.Names.GPIO_INT_19_Interrupt,
when 20 => Ada.Interrupts.Names.GPIO_INT_20_Interrupt,
when 21 => Ada.Interrupts.Names.GPIO_INT_21_Interrupt,
when 22 => Ada.Interrupts.Names.GPIO_INT_22_Interrupt,
when 23 => Ada.Interrupts.Names.GPIO_INT_23_Interrupt,
when 24 => Ada.Interrupts.Names.GPIO_INT_24_Interrupt,
when 25 => Ada.Interrupts.Names.GPIO_INT_25_Interrupt,
when 26 => Ada.Interrupts.Names.GPIO_INT_26_Interrupt,
when 27 => Ada.Interrupts.Names.GPIO_INT_27_Interrupt,
when 28 => Ada.Interrupts.Names.GPIO_INT_28_Interrupt,
when 29 => Ada.Interrupts.Names.GPIO_INT_29_Interrupt,
when 30 => Ada.Interrupts.Names.GPIO_INT_30_Interrupt,
when 31 => Ada.Interrupts.Names.GPIO_INT_31_Interrupt);
end System.SF2.GPIO;
|
pragma License (Unrestricted);
private with System.Shared_Locking; -- implementation unit
package GNAT.Task_Lock is
pragma Preelaborate;
procedure Lock;
procedure Unlock;
pragma Inline (Lock); -- renamed
pragma Inline (Unlock); -- renamed
private
procedure Lock
renames System.Shared_Locking.Enter;
procedure Unlock
renames System.Shared_Locking.Leave;
end GNAT.Task_Lock;
|
with Memory.Container; use Memory.Container;
package Memory.Wrapper is
type Wrapper_Type is abstract new Container_Type with private;
type Wrapper_Pointer is access all Wrapper_Type'Class;
procedure Forward_Read(mem : in out Wrapper_Type;
source : in Natural;
address : in Address_Type;
size : in Positive) is abstract;
procedure Forward_Write(mem : in out Wrapper_Type;
source : in Natural;
address : in Address_Type;
size : in Positive) is abstract;
procedure Forward_Idle(mem : in out Wrapper_Type;
source : in Natural;
cycles : in Time_Type) is abstract;
function Forward_Get_Time(mem : Wrapper_Type) return Time_Type is abstract;
function Get_Join_Length(mem : Wrapper_Type) return Natural is abstract;
private
type Wrapper_Type is abstract new Container_Type with null record;
end Memory.Wrapper;
|
with Radar_Internals;
procedure Main is
-- You are in charge of developping a rotating radar for the new T-1000
-- Some of the radar code is already in place, it is just missing the
-- high-level interface to handle incoming objects.
type Object_Status_T is (Out_Of_Range, Tracked, Cleared, Selected);
-- QUESTION 1 - Part A
--
-- Define a type Angle_Degrees_T that is modulo 360
-- Define a subtype Object_Distance_Km_T as a Float with values
-- between 10cm and 100km
-- Define a subtype Speed_Kph_T that is a Float between 0 and 50 km/h
John_Connor : Object_Status_T := Out_Of_Range;
-- QUESTION 1 - Part B
--
-- Set Radar_Angle to be an Angle_Degrees_T with a starting value
Radar_Angle : Integer := 0;
-- Declare an Object_Distance_Km_T named Distance_Closest_Object, set to 10km
-- Declare a Speed_Kph_T named Running_Speed, set to 25km/h
-- Assign Time_To_Arrival to
-- Distance_Closest_Object divided by Running_Speed * 3600
Time_To_Arrival : Float := 0.0;
begin
-- This line will compile if the declarations are OK
Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival,
Object_Status_T'Image (John_Connor));
-- QUESTION 2 - Part A
--
-- Some time has passed since setup, set variables as follow to reflect that.
--
-- Rotate the radar 200 degrees by incrementing its value
-- Set the status of John_Connor to Tracked
-- Set distance to closest object to 4km
-- Update Running_Time accordingly
-- This line will compile if the declarations are OK
Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival,
Object_Status_T'Image (John_Connor));
-- QUESTION 2 - Part B
--
-- Some more time has passed since setup.
--
-- Rotate the radar 180 degrees
-- Set the status of John_Connor to Selected
-- This line will compile if the declarations are OK
Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival,
Object_Status_T'Image (John_Connor));
-- QUESTION 3 - Quiz
--
-- a. What happens if we want to rotate the radar by 361 degrees?
-- b. There is a last minute change in the spec: John Connor is now in
-- the "Friend" status, make changes to the code to allow for that.
-- c. What happens to the E.T.A. if Running_Speed is 0? Try it.
-- QUESTION 4 - Advanced
--
-- Redefine Object_Distance_Km_T as a type instead of subtype.
-- Modify the two division to make it work, using explicit casting.
end Main;
-- You can use the 'Scenario' tab on the right to change the Mode from
-- problem to solution, click the checkmark button, and go to the answers
-- directory to compare your solution with the correction.
|
------------------------------------------------------------------------------
-- --
-- ASIS APPLICATION TEMPLATE COMPONENTS --
-- --
-- C O N T E X T _ P R O C E S S I N G --
-- --
-- B o d y --
-- --
-- Copyright (c) 2000, Free Software Foundation, Inc. --
-- --
-- ASIS Application Templates are 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 Application Templates are distributed in --
-- the hope that they 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 distributed with --
-- distributed with GNAT; see file COPYING. If not, write to the Free --
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, --
-- USA. --
-- --
-- ASIS Application Templates were developed and are now maintained by Ada --
-- Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
with Ada.Wide_Text_IO;
with Ada.Characters.Handling;
with Ada.Exceptions;
with Asis.Compilation_Units;
with Asis.Exceptions;
with Asis.Errors;
with Asis.Implementation;
with Unit_Processing;
package body Context_Processing is
---------------------
-- Process_Context --
---------------------
procedure Process_Context
(The_Context : Asis.Context;
Trace : Boolean := False;
Output_Path : String)
is
Units : Asis.Compilation_Unit_List :=
Asis.Compilation_Units.Compilation_Units (The_Context);
Next_Unit : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit;
Next_Unit_Origin : Asis.Unit_Origins := Asis.Not_An_Origin;
Next_Unit_Class : Asis.Unit_Classes := Asis.Not_A_Class;
begin
for J in Units'Range loop
Next_Unit := Units (J);
Next_Unit_Class := Asis.Compilation_Units.Unit_Class (Next_Unit);
Next_Unit_Origin := Asis.Compilation_Units.Unit_Origin (Next_Unit);
if Trace then
Ada.Wide_Text_IO.Put ("Processing Unit: ");
Ada.Wide_Text_IO.Put
(Asis.Compilation_Units.Unit_Full_Name (Next_Unit));
case Next_Unit_Class is
when Asis.A_Public_Declaration |
Asis.A_Private_Declaration =>
Ada.Wide_Text_IO.Put (" (spec)");
when Asis.A_Separate_Body =>
Ada.Wide_Text_IO.Put (" (subunit)");
when Asis.A_Public_Body |
Asis.A_Public_Declaration_And_Body |
Asis.A_Private_Body =>
Ada.Wide_Text_IO.Put_Line (" (body)");
when others =>
Ada.Wide_Text_IO.Put_Line (" (???)");
end case;
Ada.Wide_Text_IO.New_Line;
end if;
case Next_Unit_Origin is
when Asis.An_Application_Unit =>
Unit_Processing.Process_Unit (Next_Unit, Trace, Output_Path);
-- This is the call to the procedure which performs the
-- analysis of a particular unit
if Trace then
Ada.Wide_Text_IO.Put ("Done ...");
end if;
when Asis.A_Predefined_Unit =>
if Trace then
Ada.Wide_Text_IO.Put ("Skipped as a predefined unit");
end if;
when Asis.An_Implementation_Unit =>
if Trace then
Ada.Wide_Text_IO.Put
("Skipped as an implementation-defined unit");
end if;
when Asis.Not_An_Origin =>
if Trace then
Ada.Wide_Text_IO.Put
("Skipped as nonexistent unit");
end if;
end case;
if Trace then
Ada.Wide_Text_IO.New_Line;
Ada.Wide_Text_IO.New_Line;
end if;
end loop;
exception
-- The exception handling in this procedure is somewhat redundant and
-- may need some reconsidering when using this procedure as a template
-- for a real ASIS tool
when Ex : Asis.Exceptions.ASIS_Inappropriate_Context |
Asis.Exceptions.ASIS_Inappropriate_Container |
Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit |
Asis.Exceptions.ASIS_Inappropriate_Element |
Asis.Exceptions.ASIS_Inappropriate_Line |
Asis.Exceptions.ASIS_Inappropriate_Line_Number |
Asis.Exceptions.ASIS_Failed =>
Ada.Wide_Text_IO.Put ("Process_Context : ASIS exception (");
Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String (
Ada.Exceptions.Exception_Name (Ex)));
Ada.Wide_Text_IO.Put (") is raised when processing unit ");
Ada.Wide_Text_IO.Put
(Asis.Compilation_Units.Unit_Full_Name (Next_Unit));
Ada.Wide_Text_IO.New_Line;
Ada.Wide_Text_IO.Put ("ASIS Error Status is ");
Ada.Wide_Text_IO.Put
(Asis.Errors.Error_Kinds'Wide_Image (Asis.Implementation.Status));
Ada.Wide_Text_IO.New_Line;
Ada.Wide_Text_IO.Put ("ASIS Diagnosis is ");
Ada.Wide_Text_IO.New_Line;
Ada.Wide_Text_IO.Put (Asis.Implementation.Diagnosis);
Ada.Wide_Text_IO.New_Line;
Asis.Implementation.Set_Status;
when Ex : others =>
Ada.Wide_Text_IO.Put ("Process_Context : ");
Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String (
Ada.Exceptions.Exception_Name (Ex)));
Ada.Wide_Text_IO.Put (" is raised (");
Ada.Wide_Text_IO.Put (Ada.Characters.Handling.To_Wide_String (
Ada.Exceptions.Exception_Information (Ex)));
Ada.Wide_Text_IO.Put (")");
Ada.Wide_Text_IO.New_Line;
Ada.Wide_Text_IO.Put ("when processing unit");
Ada.Wide_Text_IO.Put
(Asis.Compilation_Units.Unit_Full_Name (Next_Unit));
Ada.Wide_Text_IO.New_Line;
end Process_Context;
end Context_Processing;
|
with display ;
package game_types is
type cell is (DEAD,ALIVE) ;
type array_of_cell is array(display.screen'range(1),display.screen'range(2)) of cell ;
type coordinates is
record
x : integer := display.screen'length(1) ;
y : integer := display.screen'length(2) ;
end record ;
end game_types ;
|
with Ada.Numerics.Distributions;
package body Ada.Numerics.Discrete_Random is
function Random (Gen : Generator) return Result_Subtype is
function Do_Random is
new Distributions.Linear_Discrete_Random (
MT19937.Unsigned_32,
Result_Subtype,
Generator,
Random_32);
begin
return Do_Random (Gen'Unrestricted_Access.all);
end Random;
function Random (Gen : Generator; First, Last : Result_Subtype)
return Result_Subtype
is
subtype R is Result_Subtype range First .. Last;
function Do_Random is
new Distributions.Linear_Discrete_Random (
MT19937.Unsigned_32,
R,
Generator,
Random_32);
begin
return Do_Random (Gen'Unrestricted_Access.all);
end Random;
end Ada.Numerics.Discrete_Random;
|
-----------------------------------------------------------------------
-- users - Gives access to the OpenID principal through an Ada bean
-- Copyright (C) 2012, 2013 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 ASF.Contexts.Faces;
with ASF.Contexts.Flash;
with ASF.Sessions;
with ASF.Principals;
with ASF.Cookies;
with ASF.Events.Faces.Actions;
with ASF.Applications.Messages.Factory;
with GNAT.MD5;
with Security.Auth;
with ASF.Security.Filters;
with Util.Strings.Transforms;
package body Users is
use Ada.Strings.Unbounded;
use Security.Auth;
use type ASF.Principals.Principal_Access;
use type ASF.Contexts.Faces.Faces_Context_Access;
procedure Remove_Cookie (Name : in String);
-- ------------------------------
-- Given an Email address, return the Gravatar link to the user image.
-- (See http://en.gravatar.com/site/implement/hash/ and
-- http://en.gravatar.com/site/implement/images/)
-- ------------------------------
function Get_Gravatar_Link (Email : in String) return String is
E : constant String := Util.Strings.Transforms.To_Lower_Case (Email);
C : constant GNAT.MD5.Message_Digest := GNAT.MD5.Digest (E);
begin
return "http://www.gravatar.com/avatar/" & C;
end Get_Gravatar_Link;
-- ------------------------------
-- Get the user information identified by the given name.
-- ------------------------------
function Get_Value (From : in User_Info;
Name : in String) return Util.Beans.Objects.Object is
pragma Unreferenced (From);
F : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current;
S : ASF.Sessions.Session;
P : ASF.Principals.Principal_Access := null;
U : Security.Auth.Principal_Access := null;
begin
if F /= null then
S := F.Get_Session;
if S.Is_Valid then
P := S.Get_Principal;
if P /= null then
U := Security.Auth.Principal'Class (P.all)'Access;
end if;
end if;
end if;
if Name = "authenticated" then
return Util.Beans.Objects.To_Object (U /= null);
end if;
if U = null then
return Util.Beans.Objects.Null_Object;
end if;
if Name = "email" then
return Util.Beans.Objects.To_Object (U.Get_Email);
end if;
if Name = "language" then
return Util.Beans.Objects.To_Object (Get_Language (U.Get_Authentication));
end if;
if Name = "first_name" then
return Util.Beans.Objects.To_Object (Get_First_Name (U.Get_Authentication));
end if;
if Name = "last_name" then
return Util.Beans.Objects.To_Object (Get_Last_Name (U.Get_Authentication));
end if;
if Name = "full_name" then
return Util.Beans.Objects.To_Object (Get_Full_Name (U.Get_Authentication));
end if;
if Name = "id" then
return Util.Beans.Objects.To_Object (Get_Claimed_Id (U.Get_Authentication));
end if;
if Name = "country" then
return Util.Beans.Objects.To_Object (Get_Country (U.Get_Authentication));
end if;
if Name = "sessionId" then
return Util.Beans.Objects.To_Object (S.Get_Id);
end if;
if Name = "gravatar" then
return Util.Beans.Objects.To_Object (Get_Gravatar_Link (U.Get_Email));
end if;
return Util.Beans.Objects.To_Object (U.Get_Name);
end Get_Value;
-- ------------------------------
-- Helper to send a remove cookie in the current response
-- ------------------------------
procedure Remove_Cookie (Name : in String) is
Ctx : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current;
C : ASF.Cookies.Cookie := ASF.Cookies.Create (Name, "");
begin
ASF.Cookies.Set_Path (C, Ctx.Get_Request.Get_Context_Path);
ASF.Cookies.Set_Max_Age (C, 0);
Ctx.Get_Response.Add_Cookie (Cookie => C);
end Remove_Cookie;
-- ------------------------------
-- Logout by dropping the user session.
-- ------------------------------
procedure Logout (From : in out User_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
pragma Unreferenced (From);
F : constant ASF.Contexts.Faces.Faces_Context_Access := ASF.Contexts.Faces.Current;
S : ASF.Sessions.Session := F.Get_Session;
P : ASF.Principals.Principal_Access := null;
U : Security.Auth.Principal_Access := null;
begin
if S.Is_Valid then
P := S.Get_Principal;
if P /= null then
U := Security.Auth.Principal'Class (P.all)'Access;
end if;
S.Invalidate;
end if;
if U /= null then
F.Get_Flash.Set_Keep_Messages (True);
ASF.Applications.Messages.Factory.Add_Message (F.all, "samples.openid_logout_message",
Get_Full_Name (U.Get_Authentication));
end if;
Remove_Cookie (ASF.Security.Filters.SID_COOKIE);
Outcome := Ada.Strings.Unbounded.To_Unbounded_String ("logout_success");
end Logout;
package Logout_Binding is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => User_Info,
Method => Logout,
Name => "logout");
Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Logout_Binding.Proxy'Unchecked_Access);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression
-- ------------------------------
overriding
function Get_Method_Bindings (From : in User_Info)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Array'Access;
end Get_Method_Bindings;
end Users;
|
#############################################################################
##
#W id1728q.ada GAP library of id's Hans Ulrich Besche
##
ID_GROUP_TREE.next[1728].next[443].next[105]:=
rec(
fp:= [ 479, 1197, 2177, 2390, 5114, 5777, 6422, 6628, 6723, 6793, 7115,
7388, 8116, 8243, 9040, 10061, 10377, 11067, 11293, 11628, 12542, 14829,
15419, 15778, 17250, 18438, 20740, 22748, 25106, 28477, 28893, 29796, 30543,
32110, 32918, 33586, 34694, 36166, 38005, 38018, 38436, 38790, 40262, 41239,
42614, 43378, 43774, 44405, 45619, 46362, 46785, 47029, 47492, 47881, 48388,
49134, 50502, 51324, 51639, 51851, 52407, 52746, 52878, 53116, 53584, 54405,
54994, 56004, 56067, 56229, 57878, 59456, 60091, 62298, 62392, 63419, 63720,
65231, 65673, 66780, 69544, 69619, 70753, 70778, 71246, 71498, 71542, 71991,
72685, 73478, 73775, 74196, 74260, 75332, 75695, 78314, 80129, 81447, 81647,
82838, 83173, 83859, 84455, 85634, 85644, 85749, 85827, 86567, 87282, 87932,
87952, 88040, 88648, 89074, 90035, 90096, 92118, 92438, 92751, 93387, 93670,
93858, 94063, 94189, 94494, 98721 ],
next:= [ 37578, 37318, 34908, 34075, 35783, 37507, 34850, 37364, 34497,
34124, 34098, 37219, 35240, 34965, 34860, 34142, 37367, rec(
desc:= [ 302026 ],
fp:= [ 8600, 24392, 56120, 97401 ],
next:= [ 37510, rec(
desc:= [ 112003 ],
fp:= [ 2, 12 ],
next:= [ 35152, 34599 ] ), rec(
desc:= [ 112003 ],
fp:= [ 2, 12 ],
next:= [ 35033, 37448 ] ), 35136 ] ), rec(
desc:= [ 110003 ],
fp:= [ 4, 14, 212 ],
next:= [ 35155, 35151, 35154 ] ), 34958, 35976, 34959, 35032, 35670,
34687, 35738, 36450, rec(
desc:= [ 125007 ],
fp:= [ 8, 612 ],
next:= [ 34125, 34146 ] ), 34983, 37416, 34910, 35140, 34152, rec(
desc:= [ 108003 ],
fp:= [ 2, 12 ],
next:= [ 35138, 34688 ] ), rec(
desc:= [ 120007 ],
fp:= [ 4, 14 ],
next:= [ 35740, 36162 ] ), 34940, 34854, 35719, 34520, rec(
desc:= [ 118007 ],
fp:= [ 2, 12 ],
next:= [ 36229, 35788 ] ), 37308, 34917, rec(
desc:= [ 113003 ],
fp:= [ 4, 14, 212 ],
next:= [ 35176, 35172, 35175 ] ), rec(
desc:= [ 119007 ],
fp:= [ 8, 612 ],
next:= [ 35751, 35766 ] ), 34156, rec(
desc:= [ 120007 ],
fp:= [ 616, 814, 1012 ],
next:= [ rec(
desc:= [ 122007 ],
fp:= [ 214, 412 ],
next:= [ 35721, 36194 ] ), 36167, 35776 ] ), 34977, 36290, 36444,
34879, rec(
desc:= [ 125007 ],
fp:= [ 10, 614 ],
next:= [ 34478, 34180 ] ), 34920, rec(
desc:= [ 111003 ],
fp:= [ 4, 212 ],
next:= [ 34503, 34946 ] ), 37324, 34969, rec(
desc:= [ 123007 ],
fp:= [ 8, 612 ],
next:= [ 34107, 34084 ] ), 37385, 35178, rec(
desc:= [ 120007 ],
fp:= [ 10, 614, 812 ],
next:= [ 35791, 36152, 36181 ] ), 34942, 34904, 35711, rec(
desc:= [ 121007 ],
fp:= [ 18, 414 ],
next:= [ 34341, 34331 ] ), 36447, rec(
desc:= [ 125007 ],
fp:= [ 8, 612 ],
next:= [ 37419, 37479 ] ), 34111, 34256, 34936, 35726, 34080, rec(
desc:= [ 110003 ],
fp:= [ 4, 14 ],
next:= [ 36221, 35181 ] ), 36170, 34100, 34141, 35011, 37563, 34282,
34560, 34154, 37481, rec(
desc:= [ 123007 ],
fp:= [ 8, 612 ],
next:= [ 34121, 34473 ] ), 37330, 34944, 34938, 34104, 34109, 37374,
35754, 34966, 34149, rec(
desc:= [ 108003 ],
fp:= [ 2, 12 ],
next:= [ 35150, 35815 ] ), 35008, rec(
desc:= [ 110003 ],
fp:= [ 4, 212 ],
next:= [ 35120, 34269 ] ), 34921, 34333, 34114, 35035, rec(
desc:= [ 125007 ],
fp:= [ 2214, 2412 ],
next:= [ 34077, 34102 ] ), 37218, 34595, 34494, 36387, 37315, 34469,
34527, 37184, 34882, 37327, 35745, 37459, 34157, rec(
desc:= [ 302028 ],
fp:= [ 723, 83541 ],
next:= [ 34213, 34181 ] ), 37167, 37567, 34120, 34155, 35812, 34502,
35221, 34876, 34935, 35037, 37566, 36317, 37347, 36230 ] );
|
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure vigenere is
type stringptr is access all char_array;
procedure PString(s : stringptr) is
begin
String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all));
end;
procedure PChar(c : in Character) is
begin
Character'Write (Text_Streams.Stream (Current_Output), c);
end;
procedure SkipSpaces is
C : Character;
Eol : Boolean;
begin
loop
Look_Ahead(C, Eol);
exit when Eol or C /= ' ';
Get(C);
end loop;
end;
function position_alphabet(c : in Character) return Integer is
i : Integer;
begin
i := Character'Pos(c);
if i <= Character'Pos('Z') and then i >= Character'Pos('A')
then
return i - Character'Pos('A');
else
if i <= Character'Pos('z') and then i >= Character'Pos('a')
then
return i - Character'Pos('a');
else
return (-1);
end if;
end if;
end;
function of_position_alphabet(c : in Integer) return Character is
begin
return Character'Val(c + Character'Pos('a'));
end;
type a is Array (Integer range <>) of Character;
type a_PTR is access a;
procedure crypte(taille_cle : in Integer; cle : in a_PTR; taille : in Integer; message : in a_PTR) is
new0 : Integer;
lettre : Integer;
addon : Integer;
begin
for i in integer range 0..taille - 1 loop
lettre := position_alphabet(message(i));
if lettre /= (-1)
then
addon := position_alphabet(cle(i rem taille_cle));
new0 := (addon + lettre) rem 26;
message(i) := of_position_alphabet(new0);
end if;
end loop;
end;
taille_cle : Integer;
taille : Integer;
out2 : Character;
out0 : Character;
message : a_PTR;
cle : a_PTR;
begin
Get(taille_cle);
SkipSpaces;
cle := new a (0..taille_cle - 1);
for index in integer range 0..taille_cle - 1 loop
Get(out0);
cle(index) := out0;
end loop;
SkipSpaces;
Get(taille);
SkipSpaces;
message := new a (0..taille - 1);
for index2 in integer range 0..taille - 1 loop
Get(out2);
message(index2) := out2;
end loop;
crypte(taille_cle, cle, taille, message);
for i in integer range 0..taille - 1 loop
PChar(message(i));
end loop;
PString(new char_array'( To_C("" & Character'Val(10))));
end;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
private with GL.Low_Level;
package GL.Enums.Queries is
pragma Preelaborate;
-- Texture_Kind is declared in GL.Low_Level.Enums to be accessible for
-- OpenCLAda
type Parameter is (Time_Elapsed, Samples_Passed, Any_Samples_Passed,
Transform_Feedback_Primitives_Written);
-- needs to be declared here because of subtypes
for Parameter use (Time_Elapsed => 16#88BF#,
Samples_Passed => 16#8914#,
Any_Samples_Passed => 16#8C2F#,
Transform_Feedback_Primitives_Written => 16#8C88#);
for Parameter'Size use Low_Level.Enum'Size;
private
end GL.Enums.Queries;
|
package Inline1_Pkg is
function Valid_Real (Number : Float) return Boolean;
pragma Inline_Always (Valid_Real);
function Invalid_Real return Float;
pragma Inline_Always (Invalid_Real);
end Inline1_Pkg;
|
-- $Id: Strings.md,v 1.3 1992/08/07 14:45:41 grosch rel $
-- $Log: Strings.md,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with Unchecked_Deallocation;
package body strings is
procedure Free is new Unchecked_Deallocation (String, tString);
function "=" (Left, Right: tString) return Boolean is
begin return Left.all = Right.all; end "=";
function "<" (Left, Right: tString) return Boolean is
begin return Left.all < Right.all; end "<";
function "<=" (Left, Right: tString) return Boolean is
begin return Left.all <= Right.all; end "<=";
function ">" (Left, Right: tString) return Boolean is
begin return Left.all > Right.all; end ">";
function ">=" (Left, Right: tString) return Boolean is
begin return Left.all >= Right.all; end ">=";
function "&" (Left, Right: tString) return tString is
L_Length : constant Integer := Left.all'Length;
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := L_Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: String) return tString is
L_Length : constant Integer := Left.all'Length;
Length : constant Integer := L_Length + Right'Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. L_Length) := Left.all;
Result.all (L_Length + 1 .. Length) := Right;
return Result;
end "&";
function "&" (Left: String; Right: tString) return tString is
R_Length : constant Integer := Right.all'Length;
Length : constant Integer := Left'Length + R_Length;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Left'Length) := Left;
Result.all (Left'Length + 1 .. Length) := Right.all;
return Result;
end "&";
function "&" (Left: tString; Right: Character) return tString is
Length : constant Integer := Left.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1 .. Length - 1) := Left.all;
Result.all (Length) := Right;
return Result;
end "&";
function "&" (Left: Character; Right: tString) return tString is
Length : constant Integer := Right.all'Length + 1;
Result : tString := new String (1 .. Length);
begin
Result.all (1) := Left;
Result.all (2 .. Length) := Right.all;
return Result;
end "&";
procedure Create (Target: in out tString; Length: Natural) is
begin
Free (Target);
Target := new String (1 .. Length);
end Create;
function Length (Source: tString) return Natural is
begin
return Source.all'Length;
end Length;
function Element (Source: tString; Index: Positive) return Character is
begin
if Index <= Source.all'Last then
return Source.all (Index);
else
null; -- raise String.Index_Error;
return '?';
end if;
end Element;
procedure Replace_Element (Source: in out tString; Index: Positive; By: Character) is
begin
if Index <= Source.all'Last then
Source.all (Index) := By;
else
null; -- raise Strings.Index_Error;
end if;
end Replace_Element;
function Replace_Slice (Source: in tString; Low: Positive; High: Natural; By: String) return tString is
begin
return Source; -- To_tString (Fixed.Replace_Slice (Source.all, Low, High, By));
end Replace_Slice;
function Slice (Source: tString; Low: Positive; High: Natural) return String is
Result : String (1 .. High - Low + 1);
begin
Result := Source.all (Low .. High);
return Result;
end Slice;
function To_String (Source: tString) return String is
begin
return Source.all;
end To_String;
procedure To_tString (Source: String; Target: in out tString) is
begin
Free (Target);
Target := new String (1 .. Source'Length);
Target.all := Source;
end To_tString;
procedure ReadS (File: File_Type; Target: in out tString) is
s : String (1 .. 1024);
n : Integer;
begin
Get_Line (File, s, n);
To_tString (s (1 .. n), Target);
end ReadS;
procedure WriteS (File: File_Type; Source: tString) is
begin
Put (File, Source.all);
end WriteS;
end strings;
|
with Ada.Calendar;
with Ada.Exceptions;
with Ada.Unchecked_Conversion;
with Ada.Command_Line;
with Ada.Environment_Variables;
with Ada.Integer_Text_IO;
with Ada.Numerics;
with Ada.Numerics.Aux;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
-- NOT IN STANDARD ADA ???
--~ with Ada.Attribute_Storage;
--~ with Ada.Interrupts.Rational.Handler;
--~ with Ada.Interrupts.Rational.Handler.Dependent;
--~ with Ada.Interrupts_Conf;
-- PROBLEMS IN ASIS
--~ with Ada.Interrupts.Names;
--~ with Ada.Real_Time;
--~ with Ada.Task_Identification;
procedure Ada_Packages is
begin
null;
end Ada_Packages;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015-2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Calendar.Formatting;
with Natools.Time_IO.RFC_3339;
package body Natools.Time_Keys.Tests is
function Image (Date : Ada.Calendar.Time) return String;
procedure Key_Test
(Test : in out NT.Test;
Time : in Ada.Calendar.Time;
Expected_Key : in String;
Max_Sub_Second_Digits : in Natural);
procedure Roundtrip_Test
(Test : in out NT.Test;
Time : in Ada.Calendar.Time;
Expected_Key : in String);
------------------------------
-- Local Helper Subprograms --
------------------------------
function Image (Date : Ada.Calendar.Time) return String is
begin
return Time_IO.RFC_3339.Image
(Date => Date,
Subsecond_Digits => Duration'Aft);
end Image;
procedure Key_Test
(Test : in out NT.Test;
Time : in Ada.Calendar.Time;
Expected_Key : in String;
Max_Sub_Second_Digits : in Natural)
is
Generated_Key : constant String := To_Key (Time, Max_Sub_Second_Digits);
begin
if Generated_Key /= Expected_Key then
Test.Fail ("Generated key """ & Generated_Key
& """, expected """ & Expected_Key & '"');
Test.Info ("Time of generated key: "
& Image (To_Time (Generated_Key)));
end if;
end Key_Test;
procedure Roundtrip_Test
(Test : in out NT.Test;
Time : in Ada.Calendar.Time;
Expected_Key : in String)
is
use type Ada.Calendar.Time;
Generated_Key : constant String := To_Key (Time, 2);
Recovered_Time : constant Ada.Calendar.Time := To_Time (Generated_Key);
begin
if Generated_Key /= Expected_Key then
Test.Fail ("Generated key """ & Generated_Key
& """, expected """ & Expected_Key & '"');
end if;
if Recovered_Time /= Time then
Test.Fail ("Roundtrip time: " & Image (Recovered_Time)
& ", original: " & Image (Time));
end if;
end Roundtrip_Test;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Leap_Second (Report);
Roundtrips (Report);
Subsecond_Rounding (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Leap_Second (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Leap second support");
begin
declare
use type Ada.Calendar.Time;
Year : constant Ada.Calendar.Year_Number := 2012;
Month : constant Ada.Calendar.Month_Number := 6;
Day : constant Ada.Calendar.Day_Number := 30;
Hour : constant Ada.Calendar.Formatting.Hour_Number := 23;
Minute : constant Ada.Calendar.Formatting.Minute_Number := 59;
Second : constant Ada.Calendar.Formatting.Second_Number := 59;
Sub_Second : constant Ada.Calendar.Formatting.Second_Duration := 0.5;
Expected_Time : constant Ada.Calendar.Time
:= Ada.Calendar.Formatting.Time_Of
(Year, Month, Day, Hour, Minute, Second, Sub_Second, True);
Expected_Key : constant String := "VS6UNwxW";
Generated_Key : constant String := To_Key
(Year, Month, Day, Hour, Minute, Second, Sub_Second, True, 1);
Recovered_Time : constant Ada.Calendar.Time
:= To_Time (Generated_Key);
begin
if Generated_Key /= Expected_Key then
Test.Fail ("Generated key """ & Generated_Key
& """, expected """ & Expected_Key & '"');
end if;
if Recovered_Time /= Expected_Time then
Test.Fail ("Roundtrip time: " & Image (Recovered_Time)
& ", expected: " & Image (Expected_Time));
end if;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Leap_Second;
procedure Roundtrips (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Conversion Roundtrips");
begin
if Duration'Small <= 1.0 / 128.0 then
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2015, 1, 14, 15, 16, 17,
0.5 + 1.0 / 128.0),
"VV1EFGHWW");
end if;
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2015, 1, 2, 3, 4, 5, 0.5),
"VV12345W");
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2047, 1, 14, 8, 44, 36),
"V~1E8h_");
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2020, 10, 9, 0, 9, 0),
"V_A909");
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2303, 9, 30, 23, 0, 0),
"Z~9UN");
Roundtrip_Test
(Test,
Ada.Calendar.Formatting.Time_Of (2304, 12, 31, 0, 0, 0),
"_0CV");
exception
when Error : others => Test.Report_Exception (Error);
end Roundtrips;
procedure Subsecond_Rounding (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Overflow in subsecond rounding");
begin
if Duration'Small > 1.0 / 256.0 then
Test.Skip ("Not enough precision in Duration");
return;
end if;
Key_Test
(Test,
To_Time ("VV121231~V"),
"VV121231~",
2);
Key_Test
(Test,
To_Time ("VV121231~X"),
"VV121232",
2);
Key_Test
(Test,
To_Time ("VV124561~~V"),
"VV124561~~",
3);
Key_Test
(Test,
To_Time ("VV124561~~X"),
"VV124562",
3);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2015, 2, 2, 1, 1, 1, 255.0 / 256.0),
"VV22112",
1);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2015, 2, 2, 1, 58, 59, 255.0 / 256.0),
"VV221w",
1);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2015, 2, 2, 22, 59, 59, 255.0 / 256.0),
"VV22N",
1);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2015, 2, 28, 23, 59, 59, 255.0 / 256.0),
"VV31",
1);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2016, 2, 28, 23, 59, 59, 255.0 / 256.0),
"VW2T",
1);
Key_Test
(Test,
Ada.Calendar.Formatting.Time_Of
(2015, 12, 31, 23, 59, 59, 255.0 / 256.0),
"VW11",
1);
exception
when Error : others => Test.Report_Exception (Error);
end Subsecond_Rounding;
end Natools.Time_Keys.Tests;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013-2014, 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$
------------------------------------------------------------------------------
package XML.DOM is
pragma Pure;
type Node_Type is
(Element_Node,
Attribute_Node,
Text_Node,
CDATA_Section_Node,
Entity_Reference_Node,
Entity_Node,
Processing_Instruction_Node,
Comment_Node,
Document_Node,
Document_Type_Node,
Document_Fragment_Node,
Notation_Node);
DOM_Exception : exception;
type Error_Code is
(NO_ERROR,
INDEX_SIZE_ERROR,
DOMSTRING_SIZE_ERROR,
HIERARCHY_REQUEST_ERROR,
WRONG_DOCUMENT_ERROR,
INVALID_CHARACTER_ERROR,
NO_DATA_ALLOWED_ERROR,
NO_MODIFICATION_ALLOWED_ERROR,
NOT_FOUND_ERROR,
NOT_SUPPORTED_ERROR,
INUSE_ATTRIBUTE_ERROR,
INVALID_STATE_ERROR,
SYNTAX_ERROR,
INVALID_MODIFICATION_ERROR,
NAMESPACE_ERROR,
INVALID_ACCESS_ERROR,
VALIDATION_ERROR,
TYPE_MISMATCH_ERROR);
end XML.DOM;
|
-- Generated at 2017-03-10 17:26:29 +0000 by Natools.Static_Hash_Maps
-- from src/natools-web-simple_pages-maps.sx
package Natools.Static_Maps.Web.Simple_Pages is
pragma Pure;
type Command is
(Unknown_Command,
Comment_List,
Date, Optional_Date, If_No_Date,
Maps,
My_Tags,
Path,
Tags);
type Component is
(Error,
Comment_List,
Dates,
Elements,
Maps,
Tags);
function To_Command (Key : String) return Command;
function To_Component (Key : String) return Component;
private
Map_1_Key_0 : aliased constant String := "comments";
Map_1_Key_1 : aliased constant String := "comment-list";
Map_1_Key_2 : aliased constant String := "date";
Map_1_Key_3 : aliased constant String := "if-no-date";
Map_1_Key_4 : aliased constant String := "maps";
Map_1_Key_5 : aliased constant String := "my-tags";
Map_1_Key_6 : aliased constant String := "my-tag-list";
Map_1_Key_7 : aliased constant String := "tag-list";
Map_1_Key_8 : aliased constant String := "optional-date";
Map_1_Key_9 : aliased constant String := "path";
Map_1_Key_10 : aliased constant String := "pagelist";
Map_1_Key_11 : aliased constant String := "page-list";
Map_1_Key_12 : aliased constant String := "tag";
Map_1_Key_13 : aliased constant String := "tags";
Map_1_Keys : constant array (0 .. 13) of access constant String
:= (Map_1_Key_0'Access,
Map_1_Key_1'Access,
Map_1_Key_2'Access,
Map_1_Key_3'Access,
Map_1_Key_4'Access,
Map_1_Key_5'Access,
Map_1_Key_6'Access,
Map_1_Key_7'Access,
Map_1_Key_8'Access,
Map_1_Key_9'Access,
Map_1_Key_10'Access,
Map_1_Key_11'Access,
Map_1_Key_12'Access,
Map_1_Key_13'Access);
Map_1_Elements : constant array (0 .. 13) of Command
:= (Comment_List,
Comment_List,
Date,
If_No_Date,
Maps,
My_Tags,
My_Tags,
My_Tags,
Optional_Date,
Path,
Tags,
Tags,
Tags,
Tags);
Map_2_Key_0 : aliased constant String := "dates";
Map_2_Key_1 : aliased constant String := "tags";
Map_2_Key_2 : aliased constant String := "comments";
Map_2_Key_3 : aliased constant String := "comment-list";
Map_2_Key_4 : aliased constant String := "maps";
Map_2_Key_5 : aliased constant String := "elements";
Map_2_Key_6 : aliased constant String := "layout";
Map_2_Keys : constant array (0 .. 6) of access constant String
:= (Map_2_Key_0'Access,
Map_2_Key_1'Access,
Map_2_Key_2'Access,
Map_2_Key_3'Access,
Map_2_Key_4'Access,
Map_2_Key_5'Access,
Map_2_Key_6'Access);
Map_2_Elements : constant array (0 .. 6) of Component
:= (Dates,
Tags,
Comment_List,
Comment_List,
Maps,
Elements,
Elements);
end Natools.Static_Maps.Web.Simple_Pages;
|
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
separate (Latin_Utils.Dictionary_Package)
package body Part_Entry_IO is
---------------------------------------------------------------------------
use type Ada.Text_IO.Positive_Count;
---------------------------------------------------------------------------
procedure Get (File : in Ada.Text_IO.File_Type; Item : out Part_Entry)
is
POFS : Part_Of_Speech_Type := X;
Starting_Col : constant Ada.Text_IO.Positive_Count :=
Ada.Text_IO.Col (File);
Spacer : Character;
pragma Unreferenced (Spacer);
--------------------------------------------------------------------------
Noun : Noun_Entry;
Pronoun : Pronoun_Entry;
Propack : Propack_Entry;
Adjective : Adjective_Entry;
Numeral : Numeral_Entry;
Adverb : Adverb_Entry;
Verb : Verb_Entry;
Preposition : Preposition_Entry;
Conjunction : Conjunction_Entry;
Interjection : Interjection_Entry;
--------------------------------------------------------------------------
begin
Part_Of_Speech_Type_IO.Get (File, POFS);
Ada.Text_IO.Get (File, Spacer);
case POFS is
when N =>
Noun_Entry_IO.Get (File, Noun);
Item := (N, Noun);
when Pron =>
Pronoun_Entry_IO.Get (File, Pronoun);
Item := (Pron, Pronoun);
when Pack =>
Propack_Entry_IO.Get (File, Propack);
Item := (Pack, Propack);
when Adj =>
Adjective_Entry_IO.Get (File, Adjective);
Item := (Adj, Adjective);
when Num =>
Numeral_Entry_IO.Get (File, Numeral);
Item := (Num, Numeral);
when Adv =>
Adverb_Entry_IO.Get (File, Adverb);
Item := (Adv, Adverb);
when V =>
Verb_Entry_IO.Get (File, Verb);
Item := (V, Verb);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
Preposition_Entry_IO.Get (File, Preposition);
Item := (Prep, Preposition);
when Conj =>
Conjunction_Entry_IO.Get (File, Conjunction);
Item := (Conj, Conjunction);
when Interj =>
Interjection_Entry_IO.Get (File, Interjection);
Item := (Interj, Interjection);
when Prefix =>
Item := (Pofs => Prefix);
when Suffix =>
Item := (Pofs => Suffix);
when Tackon =>
Item := (Pofs => Tackon);
when X =>
Item := (Pofs => X);
end case;
Ada.Text_IO.Set_Col
(File,
Ada.Text_IO.Positive_Count
(Part_Entry_IO.Default_Width) + Starting_Col
);
end Get;
---------------------------------------------------------------------------
procedure Get (Item : out Part_Entry)
is
POFS : Part_Of_Speech_Type := X;
Spacer : Character;
pragma Unreferenced (Spacer);
--------------------------------------------------------------------------
Noun : Noun_Entry;
Pronoun : Pronoun_Entry;
Propack : Propack_Entry;
Adjective : Adjective_Entry;
Numeral : Numeral_Entry;
Adverb : Adverb_Entry;
Verb : Verb_Entry;
Preposition : Preposition_Entry;
Conjunction : Conjunction_Entry;
Interjection : Interjection_Entry;
--------------------------------------------------------------------------
begin
Part_Of_Speech_Type_IO.Get (POFS);
Ada.Text_IO.Get (Spacer);
case POFS is
when N =>
Noun_Entry_IO.Get (Noun);
Item := (N, Noun);
when Pron =>
Pronoun_Entry_IO.Get (Pronoun);
Item := (Pron, Pronoun);
when Pack =>
Propack_Entry_IO.Get (Propack);
Item := (Pack, Propack);
when Adj =>
Adjective_Entry_IO.Get (Adjective);
Item := (Adj, Adjective);
when Num =>
Numeral_Entry_IO.Get (Numeral);
Item := (Num, Numeral);
when Adv =>
Adverb_Entry_IO.Get (Adverb);
Item := (Adv, Adverb);
when V =>
Verb_Entry_IO.Get (Verb);
Item := (V, Verb);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
Preposition_Entry_IO.Get (Preposition);
Item := (Prep, Preposition);
when Conj =>
Conjunction_Entry_IO.Get (Conjunction);
Item := (Conj, Conjunction);
when Interj =>
Interjection_Entry_IO.Get (Interjection);
Item := (Interj, Interjection);
when Prefix =>
Item := (Pofs => Prefix);
when Suffix =>
Item := (Pofs => Suffix);
when Tackon =>
Item := (Pofs => Tackon);
when X =>
Item := (Pofs => X);
end case;
end Get;
---------------------------------------------------------------------------
procedure Put (File : in Ada.Text_IO.File_Type; Item : in Part_Entry) is
begin
Part_Of_Speech_Type_IO.Put (File, Item.Pofs);
Ada.Text_IO.Put (File, ' ');
case Item.Pofs is
when N =>
Noun_Entry_IO.Put (File, Item.N);
when Pron =>
Pronoun_Entry_IO.Put (File, Item.Pron);
when Pack =>
Propack_Entry_IO.Put (File, Item.Pack);
when Adj =>
Adjective_Entry_IO.Put (File, Item.Adj);
when Num =>
Numeral_Entry_IO.Put (File, Item.Num);
when Adv =>
Adverb_Entry_IO.Put (File, Item.Adv);
when V =>
Verb_Entry_IO.Put (File, Item.V);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
Preposition_Entry_IO.Put (File, Item.Prep);
when Conj =>
Conjunction_Entry_IO.Put (File, Item.Conj);
when Interj =>
Interjection_Entry_IO.Put (File, Item.Interj);
when X =>
null;
when Tackon .. Suffix =>
null;
end case;
end Put;
---------------------------------------------------------------------------
procedure Put (Item : in Part_Entry) is
begin
Part_Of_Speech_Type_IO.Put (Item.Pofs);
Ada.Text_IO.Put (' ');
case Item.Pofs is
when N =>
Noun_Entry_IO.Put (Item.N);
when Pron =>
Pronoun_Entry_IO.Put (Item.Pron);
when Pack =>
Propack_Entry_IO.Put (Item.Pack);
when Adj =>
Adjective_Entry_IO.Put (Item.Adj);
when Num =>
Numeral_Entry_IO.Put (Item.Num);
when Adv =>
Adverb_Entry_IO.Put (Item.Adv);
when V =>
Verb_Entry_IO.Put (Item.V);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
Preposition_Entry_IO.Put (Item.Prep);
when Conj =>
Conjunction_Entry_IO.Put (Item.Conj);
when Interj =>
Interjection_Entry_IO.Put (Item.Interj);
when Tackon .. Suffix =>
null;
when X =>
null;
end case;
end Put;
---------------------------------------------------------------------------
procedure Get
(Source : in String;
Target : out Part_Entry;
Last : out Integer
)
is
-- Used to get lower bound of substring
Low : Integer := Source'First - 1;
-- Used to know which variant of Part_Entry shall be constructed
POFS : Part_Of_Speech_Type := X;
--------------------------------------------------------------------------
Noun : Noun_Entry;
Pronoun : Pronoun_Entry;
Propack : Propack_Entry;
Adjective : Adjective_Entry;
Numeral : Numeral_Entry;
Adverb : Adverb_Entry;
Verb : Verb_Entry;
Preposition : Preposition_Entry;
Conjunction : Conjunction_Entry;
Interjection : Interjection_Entry;
--------------------------------------------------------------------------
begin
Last := Low; -- In case it is not set later
Part_Of_Speech_Type_IO.Get (Source, POFS, Low);
Low := Low + 1;
case POFS is
when N =>
Noun_Entry_IO.Get (Source (Low + 1 .. Source'Last), Noun, Last);
Target := (N, Noun);
when Pron =>
Pronoun_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Pronoun, Last);
Target := (Pron, Pronoun);
when Pack =>
Propack_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Propack, Last);
Target := (Pack, Propack);
when Adj =>
Adjective_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Adjective, Last);
Target := (Adj, Adjective);
when Num =>
Numeral_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Numeral, Last);
Target := (Num, Numeral);
when Adv =>
Adverb_Entry_IO.Get (Source (Low + 1 .. Source'Last), Adverb, Last);
Target := (Adv, Adverb);
when V =>
Verb_Entry_IO.Get (Source (Low + 1 .. Source'Last), Verb, Last);
Target := (V, Verb);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
Preposition_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Preposition, Last);
Target := (Prep, Preposition);
when Conj =>
Conjunction_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Conjunction, Last);
Target := (Conj, Conjunction);
when Interj =>
Interjection_Entry_IO.Get
(Source (Low + 1 .. Source'Last), Interjection, Last);
Target := (Interj, Interjection);
when Prefix =>
Target := (Pofs => Prefix);
when Suffix =>
Target := (Pofs => Suffix);
when Tackon =>
Target := (Pofs => Tackon);
when X =>
Target := (Pofs => X);
end case;
end Get;
---------------------------------------------------------------------------
procedure Put (Target : out String; Item : in Part_Entry) is
-- Used to get bounds of substrings
Low : Integer := Target'First - 1;
High : Integer := 0;
begin
-- Put Part_Of_Speech_Type
High := Low + Part_Of_Speech_Type_IO.Default_Width;
Part_Of_Speech_Type_IO.Put (Target (Low + 1 .. High), Item.Pofs);
Low := High + 1;
Target (Low) := ' ';
-- Put Part_Entry
case Item.Pofs is
when N =>
High := Low + Noun_Entry_IO.Default_Width;
Noun_Entry_IO.Put (Target (Low + 1 .. High), Item.N);
when Pron =>
High := Low + Pronoun_Entry_IO.Default_Width;
Pronoun_Entry_IO.Put (Target (Low + 1 .. High), Item.Pron);
when Pack =>
High := Low + Propack_Entry_IO.Default_Width;
Propack_Entry_IO.Put (Target (Low + 1 .. High), Item.Pack);
when Adj =>
High := Low + Adjective_Entry_IO.Default_Width;
Adjective_Entry_IO.Put (Target (Low + 1 .. High), Item.Adj);
when Num =>
High := Low + Numeral_Entry_IO.Default_Width;
Numeral_Entry_IO.Put (Target (Low + 1 .. High), Item.Num);
when Adv =>
High := Low + Adverb_Entry_IO.Default_Width;
Adverb_Entry_IO.Put (Target (Low + 1 .. High), Item.Adv);
when V =>
High := Low + Verb_Entry_IO.Default_Width;
Verb_Entry_IO.Put (Target (Low + 1 .. High), Item.V);
when Vpar =>
null; -- No VAPR entry
when Supine =>
null; -- No SUPINE entry
when Prep =>
High := Low + Preposition_Entry_IO.Default_Width;
Preposition_Entry_IO.Put (Target (Low + 1 .. High), Item.Prep);
when Conj =>
High := Low + Conjunction_Entry_IO.Default_Width;
Conjunction_Entry_IO.Put (Target (Low + 1 .. High), Item.Conj);
when Interj =>
High := Low + Interjection_Entry_IO.Default_Width;
Interjection_Entry_IO.Put (Target (Low + 1 .. High), Item.Interj);
when X =>
null;
when Tackon .. Suffix =>
null;
end case;
end Put;
---------------------------------------------------------------------------
end Part_Entry_IO;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $:
with Asis.Elements;
with Asis.Expressions;
with Asis.Declarations;
with Asis.Gela.Lists;
with Asis.Gela.Elements.Decl;
with Asis.Gela.Elements.Defs;
with Asis.Gela.Elements.Expr;
with Asis.Gela.Element_Utils;
with Asis.Gela.Elements.Assoc;
package body Asis.Gela.Instances.Utils is
function New_Direct_Name
(Inst : Asis.Declaration;
Name : Asis.Defining_Name) return Asis.Expression;
function Clone_Procedure
(Item : Asis.Element;
Parent : Asis.Element) return Asis.Element;
function Clone_Function
(Item : Asis.Element;
Parent : Asis.Element) return Asis.Element;
function Clone_Package
(Item : Asis.Element;
Parent : Asis.Element) return Asis.Element;
-----------------------
-- Clone_Declaration --
-----------------------
function Clone_Declaration
(Item : Asis.Element;
Parent : Asis.Element) return Asis.Element
is
use Asis.Elements;
begin
case Declaration_Kind (Parent) is
when A_Package_Instantiation |
A_Formal_Package_Declaration |
A_Formal_Package_Declaration_With_Box =>
return Clone_Package (Item, Parent);
when A_Procedure_Instantiation =>
return Clone_Procedure (Item, Parent);
when A_Function_Instantiation =>
return Clone_Function (Item, Parent);
when others =>
raise Internal_Error;
end case;
end Clone_Declaration;
--------------------
-- Clone_Function --
--------------------
function Clone_Function
(Item : Asis.Element;
Parent : Asis.Element)
return Asis.Element
is
use Asis.Gela.Elements.Decl;
Result : Function_Declaration_Ptr := new Function_Declaration_Node;
begin
Set_Enclosing_Element (Result.all, Parent);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Parent.all));
Set_Is_Dispatching_Operation
(Result.all, Is_Dispatching_Operation (Item.all));
Set_Trait_Kind (Result.all, An_Ordinary_Trait);
Set_Instance (Asis.Element (Result), Item);
return Asis.Element (Result);
end Clone_Function;
-------------------
-- Clone_Package --
-------------------
function Clone_Package
(Item : Asis.Element;
Parent : Asis.Element)
return Asis.Element
is
use Asis.Gela.Elements.Decl;
Result : Package_Declaration_Ptr := new Package_Declaration_Node;
begin
Set_Enclosing_Element (Result.all, Parent);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Parent.all));
Set_Instance (Asis.Element (Result), Item);
return Asis.Element (Result);
end Clone_Package;
---------------------
-- Clone_Procedure --
---------------------
function Clone_Procedure
(Item : Asis.Element;
Parent : Asis.Element)
return Asis.Element
is
use Asis.Gela.Elements.Decl;
Result : Procedure_Declaration_Ptr := new Procedure_Declaration_Node;
begin
Set_Enclosing_Element (Result.all, Parent);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Parent.all));
Set_Is_Dispatching_Operation
(Result.all, Is_Dispatching_Operation (Item.all));
Set_Trait_Kind (Result.all, An_Ordinary_Trait);
Set_Instance (Asis.Element (Result), Item);
return Asis.Element (Result);
end Clone_Procedure;
---------------------
-- Set_Declaration --
---------------------
procedure Set_Declaration
(Result : access Elements.Declaration_Node'Class;
Object : in Cloner_Class;
Inst : in Asis.Declaration;
Name : in Asis.Defining_Name)
is
use Asis.Elements;
use Asis.Gela.Lists;
use Asis.Gela.Elements;
use Asis.Gela.Elements.Decl;
use Primary_Defining_Name_Lists;
Name_List : Asis.Element;
Formal : Asis.Declaration := Enclosing_Element (Name);
Node : Package_Instantiation_Node'Class
renames Package_Instantiation_Node'Class (Inst.all);
begin
Set_Enclosing_Element (Result.all, Inst);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Inst.all));
Set_Declaration_Origin (Result.all, An_Explicit_Declaration);
Name_List := Lists.Primary_Defining_Name_Lists.Deep_Copy
((1 => Name), Object, Asis.Element (Result));
Set_Names (Result.all, Name_List);
Set_Instance (Asis.Element (Result), Formal);
end Set_Declaration;
---------------------
-- New_Direct_Name --
---------------------
type Base_Identifier_Access is
access all Asis.Gela.Elements.Expr.Base_Identifier_Node'Class;
function New_Direct_Name
(Inst : Asis.Declaration;
Name : Asis.Defining_Name) return Asis.Expression
is
use Asis.Elements;
use Asis.Declarations;
use Asis.Gela.Elements.Expr;
Result : Base_Identifier_Access;
begin
case Defining_Name_Kind (Name) is
when A_Defining_Identifier =>
Result := new Identifier_Node;
when A_Defining_Operator_Symbol =>
Result := new Operator_Symbol_Node;
Set_Operator_Kind
(Operator_Symbol_Node (Result.all),
Operator_Kind (Name));
when others =>
raise Internal_Error;
end case;
Set_Name_Image (Result.all, Defining_Name_Image (Name));
Set_Enclosing_Element (Result.all, Asis.Nil_Element); -- Mark the Name
-- Set_Enclosing_Element (Result.all, Inst);
Set_Start_Position (Result.all, (1, 1));
Set_End_Position (Result.all, Nil_Text_Position);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Inst.all));
return Asis.Expression (Result);
end New_Direct_Name;
--------------------------------
-- New_Normalized_Association --
--------------------------------
procedure New_Normalized_Association
(Inst : in Asis.Declaration;
Name : in Asis.Defining_Name;
Actual : in out Asis.Expression;
With_Box : in Boolean)
is
use Asis.Elements;
use Asis.Declarations;
use Asis.Gela.Elements.Decl;
use Asis.Gela.Elements.Assoc;
Formal : Asis.Declaration := Enclosing_Element (Name);
Result : Generic_Association_Ptr := new Generic_Association_Node;
Node : Formal_Package_Declaration_With_Box_Node'Class renames
Formal_Package_Declaration_With_Box_Node'Class (Inst.all);
begin
if Assigned (Actual) then
null;
elsif With_Box then
declare
use Asis.Gela.Elements.Expr;
Node : constant Box_Expression_Ptr := new Box_Expression_Node;
begin
Set_Enclosing_Element (Node.all, Asis.Element (Result));
Actual := Asis.Element (Node);
end;
else
case Declaration_Kind (Formal) is
when A_Formal_Object_Declaration =>
Actual := Initialization_Expression (Formal);
when A_Formal_Function_Declaration
| A_Formal_Procedure_Declaration =>
case Default_Kind (Formal) is
when A_Name_Default =>
Actual := Formal_Subprogram_Default (Formal);
when A_Box_Default =>
Actual := New_Direct_Name (Inst, Name);
when others =>
null;
end case;
when others =>
null;
end case;
Set_Is_Defaulted_Association (Result.all, True);
end if;
Set_Is_Normalized (Result.all, True);
Set_Enclosing_Element (Result.all, Inst);
Set_Enclosing_Compilation_Unit
(Result.all, Enclosing_Compilation_Unit (Inst.all));
Set_Formal_Parameter (Result.all, Name);
Set_Actual_Parameter (Result.all, Actual);
Set_Start_Position (Result.all, (1, 1));
Set_End_Position (Result.all, Nil_Text_Position);
Add_To_Normalized_Generic_Actual_Part (Node, Asis.Element (Result));
end New_Normalized_Association;
----------------------------
-- Set_Corresponding_Body --
----------------------------
procedure Set_Corresponding_Body (Item, Source : Asis.Element) is
use Asis.Gela.Elements.Decl;
Node : Package_Instantiation_Node'Class renames
Package_Instantiation_Node'Class (Source.all);
begin
Set_Corresponding_Body (Node, Item);
end Set_Corresponding_Body;
-----------------------------------
-- Set_Corresponding_Declaration --
-----------------------------------
procedure Set_Corresponding_Declaration (Item, Source : Asis.Element) is
use Asis.Elements;
use Asis.Gela.Elements.Decl;
begin
if Declaration_Kind (Source) = A_Formal_Package_Declaration_With_Box then
declare
Node : Formal_Package_Declaration_With_Box_Node renames
Formal_Package_Declaration_With_Box_Node (Source.all);
begin
Set_Corresponding_Declaration (Node, Item);
end;
else
declare
Node : Package_Instantiation_Node'Class renames
Package_Instantiation_Node'Class (Source.all);
begin
Set_Corresponding_Declaration (Node, Item);
end;
end if;
end Set_Corresponding_Declaration;
------------------------
-- Set_Generic_Actual --
------------------------
procedure Set_Generic_Actual
(Cloned_Item : Asis.Declaration;
Formal_Item : Asis.Declaration;
Instance : Asis.Declaration)
is
use Asis.Elements;
use Asis.Gela.Elements.Decl;
Formal : Asis.Declaration;
Actual : Asis.Expression;
List : constant Asis.Element_List :=
Normalized_Generic_Actual_Part (Instance.all);
begin
for J in List'Range loop
Formal := Enclosing_Element (Expressions.Formal_Parameter (List (J)));
if Is_Equal (Formal, Formal_Item) then
Actual := Expressions.Actual_Parameter (List (J));
end if;
end loop;
if Assigned (Actual) then
case Declaration_Kind (Cloned_Item) is
when A_Formal_Type_Declaration =>
Set_Generic_Actual
(Formal_Type_Declaration_Node (Cloned_Item.all), Actual);
when A_Formal_Package_Declaration |
A_Formal_Package_Declaration_With_Box
=>
Set_Generic_Actual
(Formal_Package_Declaration_With_Box_Node'Class
(Cloned_Item.all), Actual);
when A_Formal_Procedure_Declaration |
A_Formal_Function_Declaration
=>
Set_Generic_Actual
(Formal_Procedure_Declaration_Node'Class (Cloned_Item.all),
Actual);
when A_Formal_Object_Declaration =>
Set_Generic_Actual
(Formal_Object_Declaration_Node (Cloned_Item.all), Actual);
when others =>
null;
end case;
end if;
end Set_Generic_Actual;
-------------------------
-- Set_Generic_Element --
-------------------------
procedure Set_Generic_Element (Item, Source : Asis.Element) is
use Asis.Gela.Elements.Expr;
Node : Base_Identifier_Node'Class renames
Base_Identifier_Node'Class (Item.all);
begin
Set_Corresponding_Generic_Element (Node, Source);
Element_Utils.Set_Resolved (Item, (1 => Source));
end Set_Generic_Element;
------------------
-- Set_Instance --
------------------
procedure Set_Instance (Item, Source : Asis.Element) is
use Asis.Gela.Elements;
Result : Base_Element_Ptr := Base_Element_Ptr (Item);
begin
Set_Is_Part_Of_Instance (Result.all, True);
Set_Start_Position (Result.all, (1, 1));
Set_End_Position (Result.all, Nil_Text_Position);
if Element_Kind (Item.all) = A_Defining_Name then
Set_Corresponding_Generic_Element
(Defining_Name_Node (Item.all), Source);
end if;
end Set_Instance;
end Asis.Gela.Instances.Utils;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- 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 Maxim Reznik, 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 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.
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package Ada.Strings.Maps.Constants is
pragma Pure (Constants);
Control_Set : constant Character_Set;
Graphic_Set : constant Character_Set;
Letter_Set : constant Character_Set;
Lower_Set : constant Character_Set;
Upper_Set : constant Character_Set;
Basic_Set : constant Character_Set;
Decimal_Digit_Set : constant Character_Set;
Hexadecimal_Digit_Set : constant Character_Set;
Alphanumeric_Set : constant Character_Set;
Special_Set : constant Character_Set;
ISO_646_Set : constant Character_Set;
Lower_Case_Map : constant Character_Mapping;
--Maps to lower case for letters, else identity
Upper_Case_Map : constant Character_Mapping;
--Maps to upper case for letters, else identity
Basic_Map : constant Character_Mapping;
--Maps to basic letter for letters, else identity
private
pragma Import (Ada, Control_Set);
pragma Import (Ada, Graphic_Set);
pragma Import (Ada, Letter_Set);
pragma Import (Ada, Lower_Set);
pragma Import (Ada, Upper_Set);
pragma Import (Ada, Basic_Set);
pragma Import (Ada, Decimal_Digit_Set);
pragma Import (Ada, Hexadecimal_Digit_Set);
pragma Import (Ada, Alphanumeric_Set);
pragma Import (Ada, Special_Set);
pragma Import (Ada, ISO_646_Set);
pragma Import (Ada, Lower_Case_Map);
pragma Import (Ada, Upper_Case_Map);
pragma Import (Ada, Basic_Map);
end Ada.Strings.Maps.Constants;
|
-- PR ada/52735
-- Reported by Per Sandberg <per.sandberg@bredband.net>
-- { dg-do compile }
with Nested_Generic1_Pkg;
procedure Nested_Generic1 is
package P is new Nested_Generic1_Pkg;
begin
null;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S C A N S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, 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, 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. --
-- --
------------------------------------------------------------------------------
with Namet; use Namet;
with Snames; use Snames;
package body Scans is
-----------------------------
-- Initialize_Ada_Keywords --
-----------------------------
procedure Initialize_Ada_Keywords is
procedure Set_Reserved (N : Name_Id; T : Token_Type);
pragma Inline (Set_Reserved);
-- Set given name as a reserved word (T is the corresponding token)
------------------
-- Set_Reserved --
------------------
procedure Set_Reserved (N : Name_Id; T : Token_Type) is
begin
-- Set up Token_Type values in Names table entries for reserved
-- words. We use the Pos value of the Token_Type value. Note that
-- Is_Keyword_Name relies on the fact that Token_Type'Val (0) is not
-- a reserved word!
Set_Name_Table_Byte (N, Token_Type'Pos (T));
end Set_Reserved;
-- Start of processing for Initialize_Ada_Keywords
begin
-- Establish reserved words
Set_Reserved (Name_Abort, Tok_Abort);
Set_Reserved (Name_Abs, Tok_Abs);
Set_Reserved (Name_Abstract, Tok_Abstract);
Set_Reserved (Name_Accept, Tok_Accept);
Set_Reserved (Name_Access, Tok_Access);
Set_Reserved (Name_And, Tok_And);
Set_Reserved (Name_Aliased, Tok_Aliased);
Set_Reserved (Name_All, Tok_All);
Set_Reserved (Name_Array, Tok_Array);
Set_Reserved (Name_At, Tok_At);
Set_Reserved (Name_Begin, Tok_Begin);
Set_Reserved (Name_Body, Tok_Body);
Set_Reserved (Name_Case, Tok_Case);
Set_Reserved (Name_Constant, Tok_Constant);
Set_Reserved (Name_Declare, Tok_Declare);
Set_Reserved (Name_Delay, Tok_Delay);
Set_Reserved (Name_Delta, Tok_Delta);
Set_Reserved (Name_Digits, Tok_Digits);
Set_Reserved (Name_Do, Tok_Do);
Set_Reserved (Name_Else, Tok_Else);
Set_Reserved (Name_Elsif, Tok_Elsif);
Set_Reserved (Name_End, Tok_End);
Set_Reserved (Name_Entry, Tok_Entry);
Set_Reserved (Name_Exception, Tok_Exception);
Set_Reserved (Name_Exit, Tok_Exit);
Set_Reserved (Name_For, Tok_For);
Set_Reserved (Name_Function, Tok_Function);
Set_Reserved (Name_Generic, Tok_Generic);
Set_Reserved (Name_Goto, Tok_Goto);
Set_Reserved (Name_If, Tok_If);
Set_Reserved (Name_In, Tok_In);
Set_Reserved (Name_Is, Tok_Is);
Set_Reserved (Name_Limited, Tok_Limited);
Set_Reserved (Name_Loop, Tok_Loop);
Set_Reserved (Name_Mod, Tok_Mod);
Set_Reserved (Name_New, Tok_New);
Set_Reserved (Name_Not, Tok_Not);
Set_Reserved (Name_Null, Tok_Null);
Set_Reserved (Name_Of, Tok_Of);
Set_Reserved (Name_Or, Tok_Or);
Set_Reserved (Name_Others, Tok_Others);
Set_Reserved (Name_Out, Tok_Out);
Set_Reserved (Name_Package, Tok_Package);
Set_Reserved (Name_Pragma, Tok_Pragma);
Set_Reserved (Name_Private, Tok_Private);
Set_Reserved (Name_Procedure, Tok_Procedure);
Set_Reserved (Name_Protected, Tok_Protected);
Set_Reserved (Name_Raise, Tok_Raise);
Set_Reserved (Name_Range, Tok_Range);
Set_Reserved (Name_Record, Tok_Record);
Set_Reserved (Name_Rem, Tok_Rem);
Set_Reserved (Name_Renames, Tok_Renames);
Set_Reserved (Name_Requeue, Tok_Requeue);
Set_Reserved (Name_Return, Tok_Return);
Set_Reserved (Name_Reverse, Tok_Reverse);
Set_Reserved (Name_Select, Tok_Select);
Set_Reserved (Name_Separate, Tok_Separate);
Set_Reserved (Name_Subtype, Tok_Subtype);
Set_Reserved (Name_Tagged, Tok_Tagged);
Set_Reserved (Name_Task, Tok_Task);
Set_Reserved (Name_Terminate, Tok_Terminate);
Set_Reserved (Name_Then, Tok_Then);
Set_Reserved (Name_Type, Tok_Type);
Set_Reserved (Name_Until, Tok_Until);
Set_Reserved (Name_Use, Tok_Use);
Set_Reserved (Name_When, Tok_When);
Set_Reserved (Name_While, Tok_While);
Set_Reserved (Name_With, Tok_With);
Set_Reserved (Name_Xor, Tok_Xor);
-- Ada 2005 reserved words
Set_Reserved (Name_Interface, Tok_Interface);
Set_Reserved (Name_Overriding, Tok_Overriding);
Set_Reserved (Name_Synchronized, Tok_Synchronized);
end Initialize_Ada_Keywords;
------------------------
-- Restore_Scan_State --
------------------------
procedure Restore_Scan_State (Saved_State : Saved_Scan_State) is
begin
Scan_Ptr := Saved_State.Save_Scan_Ptr;
Token := Saved_State.Save_Token;
Token_Ptr := Saved_State.Save_Token_Ptr;
Current_Line_Start := Saved_State.Save_Current_Line_Start;
Start_Column := Saved_State.Save_Start_Column;
Checksum := Saved_State.Save_Checksum;
First_Non_Blank_Location := Saved_State.Save_First_Non_Blank_Location;
Token_Node := Saved_State.Save_Token_Node;
Token_Name := Saved_State.Save_Token_Name;
Prev_Token := Saved_State.Save_Prev_Token;
Prev_Token_Ptr := Saved_State.Save_Prev_Token_Ptr;
end Restore_Scan_State;
---------------------
-- Save_Scan_State --
---------------------
procedure Save_Scan_State (Saved_State : out Saved_Scan_State) is
begin
Saved_State.Save_Scan_Ptr := Scan_Ptr;
Saved_State.Save_Token := Token;
Saved_State.Save_Token_Ptr := Token_Ptr;
Saved_State.Save_Current_Line_Start := Current_Line_Start;
Saved_State.Save_Start_Column := Start_Column;
Saved_State.Save_Checksum := Checksum;
Saved_State.Save_First_Non_Blank_Location := First_Non_Blank_Location;
Saved_State.Save_Token_Node := Token_Node;
Saved_State.Save_Token_Name := Token_Name;
Saved_State.Save_Prev_Token := Prev_Token;
Saved_State.Save_Prev_Token_Ptr := Prev_Token_Ptr;
end Save_Scan_State;
end Scans;
|
package -<full_series_name_dots>-.enumerations is
-<list_all_enumeration_types>-
type -<series_name>-Enum is (
-<list_all_message_enumeration_names>-
);
for -<series_name>-Enum use (
-<list_all_message_enumeration_ids>-
);
end -<full_series_name_dots>-.enumerations;
|
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
-- ****h* Tcl/Strings
-- FUNCTION
-- Provide code to manipulate the Tcl strings.
-- SOURCE
package Tcl.Strings is
-- ****
--## rule off REDUCEABLE_SCOPE
-- ****t* Strings/Strings.Tcl_String
-- FUNCTION
-- Used to store Tcl string values. Strings in Tcl can be evaluated or
-- literal.
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Tcl_String is new Unbounded_String;
-- ****
-- ****d* Strings/Strings.Null_Tcl_String
-- FUNCTION
-- Empty Tcl_String
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Null_Tcl_String: constant Tcl_String := Tcl_String(Null_Unbounded_String);
-- ****
-- ****f* Strings/Strings.To_Tcl_String
-- FUNCTION
-- Convert simple Ada String to Tcl_String and format it to evaluation
-- or as literal string
-- PARAMETERS
-- Source - Ada String which will be converted to Tcl_String
-- Evaluate - If true, Source should be formatted to be evaluated as a
-- Tcl code (variables replaced by values, etc). Otherwise
-- format Source to be a literal string
-- RESULT
-- A new Tcl_String properly formatted to be evaluated or as literal
-- string. If the resulted string will be too long, it will be truncated.
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Convert text hello world to literal Tcl string
-- My_String: constant Tcl_String := To_Tcl_String("hello world");
-- SOURCE
function To_Tcl_String
(Source: String; Evaluate: Boolean := False) return Tcl_String with
Test_Case => (Name => "Test_To_Tcl_String", Mode => Nominal);
-- ****
-- ****f* Strings/Strings.To_Ada_String
-- FUNCTION
-- Convert Tcl_String to Ada String
-- PARAMETERS
-- Source - Tcl_String which will be converted to Ada String
-- RESULT
-- A new String with removed starting and ending braces or quotes signs
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Convert Tcl_String {hello world} to Ada String
-- My_String: constant String := To_String(To_Tcl_String("hello world"));
-- SOURCE
function To_Ada_String(Source: Tcl_String) return String with
Test_Case => (Name => "Test_To_Ada_String", Mode => Robustness);
-- ****
--## rule on REDUCEABLE_SCOPE
end Tcl.Strings;
|
-- $Header: /dc/uc/self/arcadia/ayacc/src/RCS/output_file_body.a,v 1.2 1993/05/31 22:36:35 self Exp self $
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to ayacc-info@ics.uci.edu
-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : output_file_body.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:32:10
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxoutput_file_body.ada
-- $Header: /dc/uc/self/arcadia/ayacc/src/RCS/output_file_body.a,v 1.2 1993/05/31 22:36:35 self Exp self $
-- $Log: output_file_body.a,v $
-- Revision 1.2 1993/05/31 22:36:35 self
-- added exception handler when opening files
--
-- Revision 1.1 1993/05/31 22:05:03 self
-- Initial revision
--
--Revision 1.1 88/08/08 14:16:40 arcadia
--Initial revision
--
-- Revision 0.1 86/04/01 15:08:26 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:37:50 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
with Actions_File, Ayacc_File_Names, Lexical_Analyzer, Options, Parse_Table,
Parse_Template_File, Source_File, Text_IO;
use Actions_File, Ayacc_File_Names, Lexical_Analyzer, Options, Parse_Table,
Parse_Template_File, Source_File, Text_IO;
package body Output_File is
SCCS_ID : constant String := "@(#) output_file_body.ada, Version 1.2";
Outfile : File_Type;
procedure Open is
begin
Create(Outfile, Out_File, Get_Out_File_Name);
exception
when Name_Error | Use_Error =>
Put_Line("Ayacc: Error Opening """ & Get_Out_File_Name & """.");
raise;
end Open;
procedure Close is
begin
Close(Outfile);
end Close;
-- Make the parser body section by reading the source --
-- and template files and merging them appropriately --
procedure Make_Output_File is
Text : String(1..260);
Length : Natural;
I : Integer;
-- UMASS CODES :
Umass_Codes : Boolean := False;
-- Indicates whether or not current line of the template
-- is the Umass codes.
UCI_Codes_Deleted : Boolean := False;
-- Indicates whether or not current line of the template
-- is UCI codes which should be deleted in Ayacc-extension.
-- END OF UMASS CODES.
begin
Open; -- Open the output file.
-- Read the first part of the source file up to '##'
-- or to end of file.
while not Source_File.Is_End_of_File loop
Source_File.Read_Line(Text, Length);
if Length > 1 then
I := 1;
while (I < Length - 1 and then Text(I) = ' ') loop
I := I + 1;
end loop;
if Text(I..I+1) = "##" then
exit;
end if;
end if;
Put_Line(Outfile, Text(1..Length));
end loop;
Parse_Template_File.Open;
-- Copy the header from the parse template
loop
Parse_Template_File.Read(Text,Length);
if Length > 1 and then Text(1..2) = "%%" then
exit;
else
-- UMASS CODES :
-- In the template, the codes between "-- UMASS CODES : " and
-- "-- END OF UMASS CODES." are specific to be used by Ayacc-extension.
-- Also the codes between "-- UCI CODES DELETED : " and
-- "-- END OF UCI CODES DELETED." should only be generated in
-- Ayacc and should be deleted in Ayacc-extension.
-- Ayacc-extension has more power in error recovery. So we
-- generate Umass codes only when Error_Recovery_Extension is True.
-- And we delete the necessary UCI codes when Error_Recovery_
-- Extension is True.
if Length = 16 and then Text(1..16) = "-- UMASS CODES :" then
Umass_Codes := True;
end if;
if Length = 22 and then Text(1..22) = "-- UCI CODES DELETED :" then
UCI_CODES_Deleted := True;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- UCI CODES DELETED :" anyway.
elsif Length = 28 and then Text(1..28) = "-- END OF UCI CODES DELETED." then
UCI_CODES_Deleted := False;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- END OF UCI CODES DELETED :" anyway.
end if;
if Options.Error_Recovery_Extension then
-- Do not generate UCI codes which should be deleted.
if not UCI_CODES_Deleted then
PUT_LINE(Outfile,Text(1..Length));
end if;
else
-- Do not generate UMASS codes.
if not Umass_Codes then
PUT_LINE(Outfile,Text(1..Length));
end if;
end if;
if Length = 22 and then Text(1..22) = "-- END OF UMASS CODES." then
Umass_Codes := False;
end if;
-- END OF UMASS CODES.
-- UCI CODES commented out :
-- The following line is commented out because it is done in Umass codes.
-- Put_Line(Outfile, Text(1..Length));
end if;
end loop;
Put_Line (Outfile, " package yy_goto_tables renames");
Put_Line (Outfile, " " & Goto_Tables_Unit_Name & ';');
Put_Line (Outfile, " package yy_shift_reduce_tables renames");
Put_Line (Outfile, " " & Shift_Reduce_Tables_Unit_Name & ';');
Put_Line (Outfile, " package yy_tokens renames");
Put_Line (Outfile, " " & Tokens_Unit_Name & ';');
-- UMASS CODES :
if Options.Error_Recovery_Extension then
Put_Line (OutFile, " -- UMASS CODES :" );
Put_Line (Outfile, " package yy_error_report renames");
Put_Line (OutFile, " " & Error_Report_Unit_Name & ";");
Put_Line (OutFile, " -- END OF UMASS CODES." );
end if;
-- END OF UMASS CODES.
-- Copy the first half of the parse template
loop
Parse_Template_File.Read(Text,Length);
if Length > 1 and then Text(1..2) = "%%" then
exit;
else
-- UMASS CODES :
-- In the template, the codes between "-- UMASS CODES : " and
-- "-- END OF UMASS CODES." are specific to be used by Ayacc-extension.
-- Also the codes between "-- UCI CODES DELETED : " and
-- "-- END OF UCI CODES DELETED." should only be generated in
-- Ayacc and should be deleted in Ayacc-extension.
-- Ayacc-extension has more power in error recovery. So we
-- generate Umass codes only when Error_Recovery_Extension is True.
-- And we delete the necessary UCI codes when Error_Recovery_
-- Extension is True.
if Length = 16 and then Text(1..16) = "-- UMASS CODES :" then
Umass_Codes := True;
end if;
if Length = 22 and then Text(1..22) = "-- UCI CODES DELETED :" then
UCI_CODES_Deleted := True;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- UCI CODES DELETED :" anyway.
elsif Length = 28 and then Text(1..28) = "-- END OF UCI CODES DELETED." then
UCI_CODES_Deleted := False;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- END OF UCI CODES DELETED :" anyway.
end if;
if Options.Error_Recovery_Extension then
-- Do not generate UCI codes which should be deleted.
if not UCI_CODES_Deleted then
PUT_LINE(Outfile,Text(1..Length));
end if;
else
-- Do not generate UMASS codes.
if not Umass_Codes then
PUT_LINE(Outfile,Text(1..Length));
end if;
end if;
if Length = 22 and then Text(1..22) = "-- END OF UMASS CODES." then
Umass_Codes := False;
end if;
-- END OF UMASS CODES.
-- UCI CODES commented out :
-- The following line is commented out because it is done in Umass codes.
-- Put_Line(Outfile, Text(1..Length));
end if;
end loop;
-- Copy declarations and procedures needed in the parse template
Put_Line (Outfile," DEBUG : constant boolean := " &
Boolean'Image (Options.Debug) & ';');
-- Consume Template Up To User Action Routines.
loop
Parse_Template_File.Read(Text,Length);
if Length > 1 and then Text(1..2) = "%%" then
exit;
else
-- UMASS CODES :
-- In the template, the codes between "-- UMASS CODES : " and
-- "-- END OF UMASS CODES." are specific to be used by Ayacc-extension.
-- Also the codes between "-- UCI CODES DELETED : " and
-- "-- END OF UCI CODES DELETED." should only be generated in
-- Ayacc and should be deleted in Ayacc-extension.
-- Ayacc-extension has more power in error recovery. So we
-- generate Umass codes only when Error_Recovery_Extension is True.
-- And we delete the necessary UCI codes when Error_Recovery_
-- Extension is True.
if Length = 16 and then Text(1..16) = "-- UMASS CODES :" then
Umass_Codes := True;
end if;
if Length = 22 and then Text(1..22) = "-- UCI CODES DELETED :" then
UCI_CODES_Deleted := True;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- UCI CODES DELETED :" anyway.
elsif Length = 28 and then Text(1..28) = "-- END OF UCI CODES DELETED." then
UCI_CODES_Deleted := False;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- END OF UCI CODES DELETED :" anyway.
end if;
if Options.Error_Recovery_Extension then
-- Do not generate UCI codes which should be deleted.
if not UCI_CODES_Deleted then
PUT_LINE(Outfile,Text(1..Length));
end if;
else
-- Do not generate UMASS codes.
if not Umass_Codes then
PUT_LINE(Outfile,Text(1..Length));
end if;
end if;
if Length = 22 and then Text(1..22) = "-- END OF UMASS CODES." then
Umass_Codes := False;
end if;
-- END OF UMASS CODES.
-- UCI CODES commented out :
-- The following line is commented out because it is done in Umass codes.
-- Put_Line(Outfile, Text(1..Length));
end if;
end loop;
Actions_File.Open(Actions_File.Read_File);
loop
exit when Actions_File.Is_End_of_File;
Actions_File.Read_Line(Text,Length);
Put_Line(Outfile, Text(1..Length));
end loop;
Actions_File.Delete;
-- Finish writing the template file
loop
exit when Parse_Template_File.Is_End_of_File;
Parse_Template_File.Read(Text,Length);
-- UMASS CODES :
-- In the template, the codes between "-- UMASS CODES : " and
-- "-- END OF UMASS CODES." are specific to be used by Ayacc-extension.
-- Also the codes between "-- UCI CODES DELETED : " and
-- "-- END OF UCI CODES DELETED." should only be generated in
-- Ayacc and should be deleted in Ayacc-extension.
-- Ayacc-extension has more power in error recovery. So we
-- generate Umass codes only when Error_Recovery_Extension is True.
-- And we delete the necessary UCI codes when Error_Recovery_
-- Extension is True.
if Length = 16 and then Text(1..16) = "-- UMASS CODES :" then
Umass_Codes := True;
end if;
if Length = 22 and then Text(1..22) = "-- UCI CODES DELETED :" then
UCI_CODES_Deleted := True;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- UCI CODES DELETED :" anyway.
elsif Length = 28 and then Text(1..28) = "-- END OF UCI CODES DELETED." then
UCI_CODES_Deleted := False;
Parse_Template_File.Read(Text,Length);
-- We read next line because we do not want to generate
-- the comment "-- END OF UCI CODES DELETED :" anyway.
end if;
if Options.Error_Recovery_Extension then
-- Do not generate UCI codes which should be deleted.
if not UCI_CODES_Deleted then
PUT_LINE(Outfile,Text(1..Length));
end if;
else
-- Do not generate UMASS codes.
if not Umass_Codes then
PUT_LINE(Outfile,Text(1..Length));
end if;
end if;
if Length = 22 and then Text(1..22) = "-- END OF UMASS CODES." then
Umass_Codes := False;
end if;
-- END OF UMASS CODES.
-- UCI CODES commented out :
-- The following line is commented out because it is done in Umass codes.
-- Put_Line(Outfile, Text(1..Length));
end loop;
Parse_Template_File.Close;
-- Copy rest of input file after ##
while not Source_File.Is_End_of_File loop
Source_File.Read_Line(Text, Length);
-- UMASS CODES :
-- If the generated codes has the extension of
-- error recovery, there may be another section
-- for error reporting. So we return if we find "%%".
if Options.Error_Recovery_Extension then
if Length > 1 and then Text(1..2) = "%%" then
exit;
end if;
end if;
-- END OF UMASS CODES.
Put_Line(Outfile, Text(1..Length));
end loop;
Close;
end Make_Output_File;
end Output_File;
|
-- { dg-do compile }
-- { dg-options "-O" }
package body Opt29 is
procedure Proc (T : Rec) is
begin
if Derived2 (T.F2.all).Id = T.F1.Id then
raise Program_Error;
end if;
end;
end Opt29;
|
-- File: testuuid.adb
-- Description: Test suite for AdaID
-- Author: Anthony Arnold
-- License: http://www.gnu.org/licenses/gpl.txt
with AdaID; use AdaID;
with AdaID.Generate; use AdaID.Generate;
with Interfaces; use Interfaces;
with AUnit.Assertions; use AUnit.Assertions;
package body AdaID_Tests is
-- Register the tests to run
procedure Register_Tests(T : in out UUID_Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine(T, Initialization'Access, "Initialization");
Register_Routine(T, SetNil'Access, "Set to Nil");
Register_Routine(T, GetVersion'Access, "Get Version");
Register_Routine(T, GetVariant'Access, "Get Variant");
Register_Routine(T, Equals'Access, "Check Equality");
Register_Routine(T, GetHashCode'Access, "Get Hash Code");
Register_Routine(T, RandomNotNil'Access, "Random UUID is not Nil");
Register_Routine(T, RandomUnique'Access, "Random UUIDs are unique");
Register_Routine(T, FromNameNotNil'Access, "UUID from a name is not Nil");
Register_Routine(T, FromNameUnique'Access, "UUID from name is unique");
Register_Routine(T, FromNameEqual'Access, "UUIDs from same name are equal");
Register_Routine(T, ToString'Access, "Convert to String");
Register_Routine(T, FromStringNil'Access, "UUID from Nil String is Nil");
Register_Routine(T, FromStringEqual'Access, "Make same UUID from common formats");
Register_Routine(T, FromBadString'Access, "Expecting Invalid_String");
end Register_Tests;
-- Register the test name
function Name (T : UUID_Test) return Message_String is
begin
return AUnit.Format ("AdaID Tests");
end Name;
-- =================== Test routines ===================== --
-- Test that a UUID is Nil on initialize
procedure Initialization(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
begin
Assert(Is_Nil(id), "UUID not initialized to nil");
end Initialization;
-- Test that Set_Nil sets a UUID to Nil
procedure SetNil(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
begin
Nil(id);
Assert(Is_Nil(id), "UUID not set to nil");
end SetNil;
-- Test that Get_Version returns the correct version
procedure GetVersion(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
begin
Assert(Get_Version(id) = Unknown, "Wrong version returned");
end GetVersion;
-- Test that Get_Variant returns the correct variant
procedure GetVariant(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
begin
Assert(Get_Variant(id) = NCS, "Wrong variant returned");
end GetVariant;
-- Test the equals operator
procedure Equals(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
begin
Assert(id1 = id2, "UUIDs not considered equal");
end Equals;
-- Test the Get_Hash_Value function, and ensure that
-- two equal UUIDs have the same Hash code.
procedure GetHashCode(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
begin
Assert(Get_Hash_Value(id1) = Get_Hash_Value(id2),
"Equal IDs don't have equal hash codes");
end GetHashCode;
-- Ensure the Random generator does not make Nil
procedure RandomNotNil(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
begin
Random(id);
Assert(not Is_Nil(id), "Random UUID is Nil");
end RandomNotNil;
-- Ensure the random generator makes unique IDs
procedure RandomUnique(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
begin
Random(id1);
Random(id2);
Assert(id1 /= id2, "Two UUIDs are not unique");
end RandomUnique;
-- Ensure the name-based generator does not make Nils
procedure FromNameNotNil(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
begin
Random(id1);
From_Name(id1, "Test_String", id2);
Assert(not Is_Nil(id2), "UUID from name turned out Nil");
end FromNameNotNil;
procedure FromNameUnique(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
begin
Random(id1);
From_Name(id1, "Test_String", id2);
Assert(id1 /= id2, "UUIDs are not unique");
end FromNameUnique;
procedure FromNameEqual(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2, id3 : UUID;
begin
Random(id1);
From_Name(id1, "Test_String", id2);
Assert(not Is_Nil(id2), "UUID from name turned out Nil");
Assert(id1 /= id2, "UUIDs are not unique");
From_Name(id1, "Test_String", id3);
Assert(id2 = id3, "Equal named UUIDs not Equal");
end FromNameEqual;
procedure FromStringNil(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
s : constant String := "00000000-0000-0000-0000-000000000000";
begin
From_String(s, id);
Assert(Is_Nil(id), "Wrong UUID from Nil string");
end FromStringNil;
procedure FromStringEqual(T : in out AUnit.Test_Cases.Test_Case'Class) is
id1, id2 : UUID;
w : constant String := "12345678-90AB-CDEF-1234-567890ABCDEF";
x : constant String := "{12345678-90AB-CDEF-1234-567890ABCDEF}";
y : constant String := "{1234567890ABCDEF1234567890ABCDEF}";
z : constant String := "1234567890ABCDEF1234567890ABCDEF";
begin
From_String(w, id1);
From_String(x, id2);
Assert(id1 = id2, "Equal UUID strings generated distinct UUIDs");
From_String(y, id2);
Assert(id1 = id2, "Equal UUID strings generated distinct UUIDs");
From_String(z, id2);
Assert(id1 = id2, "Equal UUID strings generated distinct UUIDs");
end FromStringEqual;
procedure ToString(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
s : constant String := To_String(id);
begin
Assert(s = "00000000-0000-0000-0000-000000000000", "Incorrect UUID String");
end ToString;
procedure FromBadString(T : in out AUnit.Test_Cases.Test_Case'Class) is
id : UUID;
s : constant String := "not-a-uuid";
begin
From_String(s, id);
Assert(false, "Should have raised Invalid_String");
exception
when Invalid_String => null;
end FromBadString;
end AdaID_Tests;
|
with MSPGD.GPIO; use MSPGD.GPIO;
generic
Pin : Pin_Type;
Port : Port_Type;
Alt_Func : Alt_Func_Type := IO;
Direction : Direction_Type := Input;
Pull_Resistor : Resistor_Type := None;
package MSPGD.GPIO.Pin is
pragma Preelaborate;
procedure Init
with Inline_Always;
procedure Set
with Inline_Always;
procedure Clear
with Inline_Always;
function Is_Set return Boolean
with Inline_Always;
end MSPGD.GPIO.Pin;
|
-- Motherlode
-- Copyright (c) 2020 Fabien Chouteau
with Interfaces;
with VirtAPU; use VirtAPU;
with PyGamer.Audio; use PyGamer.Audio;
package body Sound is
C_16th : constant Command := (Wait_Ticks, 1);
C_8th : constant Command := (Wait_Ticks, C_16th.Ticks * 2);
C_Quarter : constant Command := (Wait_Ticks, C_8th.Ticks * 2);
C_Half : constant Command := (Wait_Ticks, C_Quarter.Ticks * 2);
-- C_Whole : constant Command := (Wait_Ticks, C_Half.Ticks * 2);
Coin_Seq : aliased constant Command_Array :=
((Set_Decay, 10),
(Set_Mode, Pulse),
(Set_Width, 25),
(Set_Sweep, None, 1, 0),
B4,
(Wait_Ticks, 3),
E5,
(Wait_Ticks, 5),
Off
);
Gun_Seq : aliased constant Command_Array :=
((Set_Mode, Noise_1),
(Set_Decay, 15),
(Set_Sweep, Up, 13, 0),
(Set_Mode, Noise_1),
(Note_On, 200.0),
Off
);
Kick : aliased constant Command_Array :=
((Set_Decay, 6),
(Set_Sweep, Up, 7, 0),
(Set_Mode, Noise_2),
(Note_On, 150.0),
Off
);
Snare : aliased constant Command_Array :=
((Set_Decay, 6),
(Set_Mode, Noise_1),
(Note_On, 2000.0),
Off
);
Hi_Hat : aliased constant Command_Array :=
((Set_Decay, 2),
(Set_Mode, Noise_1),
(Note_On, 10000.0),
Off
);
Beat_1 : constant Command_Array :=
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Hi_Hat & C_Half &
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Hi_Hat & C_Half;
Beat_2 : constant Command_Array :=
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Hi_Hat & C_Half &
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Snare & C_Half;
Beat_3 : constant Command_Array :=
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Hi_Hat & C_Half &
Kick & C_Half &
Hi_Hat & C_Half &
Snare & C_Half &
Snare & C_Quarter &
Snare & C_Quarter;
Drums_Seq : aliased constant Command_Array :=
Beat_1 & Beat_2 & Beat_3 & Beat_2;
Bass_1 : constant Command_Array :=
C2 & C_Half & Off &
C_Half &
C2 & C_Half & Off &
C_Half &
C2 & C_Half & Off &
Ds2 & C_Half & Off &
C_Half &
Gs2 & C_Half & Off;
Bass_2 : constant Command_Array :=
C_Half &
Ds2 & C_Half & Off &
C_Half &
Fs2 & C_Half & Off &
C_Half &
Ds2 & C_Half & Off &
Fs2 & C_Half & Off &
Ds2 & C_Half & Off;
Bass_3 : constant Command_Array :=
C_Half &
Ds2 & C_Half & Off &
C_Half &
Fs2 & C_Half & Off &
C_Half &
Gs2 & C_Half & Off &
Fs2 & C_Half & Off &
C_Half;
Bass_Seq : aliased constant Command_Array :=
Bass_1 & Bass_2 & Bass_1 & Bass_3;
Sample_Rate : constant Sample_Rate_Kind := SR_22050;
APU : VirtAPU.Instance (3, 22_050);
Player_FX : constant VirtAPU.Channel_ID := 1;
Drums : constant VirtAPU.Channel_ID := 2;
Bass : constant VirtAPU.Channel_ID := 3;
procedure Next_Samples is new VirtAPU.Next_Samples_UInt
(Interfaces.Unsigned_16, PyGamer.Audio.Data_Array);
procedure Audio_Callback (Left, Right : out PyGamer.Audio.Data_Array);
--------------------
-- Audio_Callback --
--------------------
procedure Audio_Callback (Left, Right : out PyGamer.Audio.Data_Array) is
begin
Next_Samples (APU, Left);
Right := Left;
end Audio_Callback;
----------
-- Tick --
----------
procedure Tick is
begin
APU.Tick;
end Tick;
---------------
-- Play_Coin --
---------------
procedure Play_Coin is
begin
APU.Set_Volume (Player_FX, 30);
APU.Run (Player_FX, Coin_Seq'Access);
end Play_Coin;
----------------
-- Play_Drill --
----------------
procedure Play_Drill is
begin
APU.Set_Volume (Player_FX, 60);
APU.Run (Player_FX, Gun_Seq'Access);
end Play_Drill;
----------------
-- Play_Music --
----------------
procedure Play_Music is
begin
APU.Run (Drums, Drums_Seq'Access, Looping => True);
APU.Set_Volume (Drums, 10);
APU.Set_Mode (Bass, Triangle);
APU.Set_Decay (Bass, 7);
APU.Set_Volume (Bass, 90);
APU.Run (Bass, Bass_Seq'Access, Looping => True);
end Play_Music;
----------------
-- Stop_Music --
----------------
procedure Stop_Music is
begin
APU.Run (Drums, VirtAPU.Empty_Seq);
APU.Set_Volume (Drums, 0);
APU.Note_Off (Drums);
APU.Run (Bass, VirtAPU.Empty_Seq);
APU.Set_Volume (Bass, 0);
APU.Note_Off (Bass);
end Stop_Music;
begin
PyGamer.Audio.Set_Callback (Audio_Callback'Access, Sample_Rate);
APU.Set_Rhythm (120, 30);
end Sound;
|
package Rule is
type Victory is (military, colony, economy, peace);
type Good_Type is (starship_power, station_build, more_resource, easy_colony);
type Bad_Type is (less_resource, hard_build, hard_colony);
end Rule;
|
-- { dg-do link }
-- { dg-options "-O -flto" { target lto } }
with Lto16_Pkg; use Lto16_Pkg;
with Text_IO; use Text_IO;
procedure Lto16 is
begin
if F = 0.0 then
Put_Line ("zero");
else
Put_Line ("non-zero");
end if;
exception
when others => Put_Line ("exception");
end;
|
with
Interfaces.C,
System.Address_To_Access_Conversions;
use type
Interfaces.C.int,
System.Address;
package body FLTK.Tooltips is
function fl_tooltip_get_current
return System.Address;
pragma Import (C, fl_tooltip_get_current, "fl_tooltip_get_current");
pragma Inline (fl_tooltip_get_current);
procedure fl_tooltip_set_current
(I : in System.Address);
pragma Import (C, fl_tooltip_set_current, "fl_tooltip_set_current");
pragma Inline (fl_tooltip_set_current);
function fl_tooltip_enabled
return Interfaces.C.int;
pragma Import (C, fl_tooltip_enabled, "fl_tooltip_enabled");
pragma Inline (fl_tooltip_enabled);
procedure fl_tooltip_enable
(V : in Interfaces.C.int);
pragma Import (C, fl_tooltip_enable, "fl_tooltip_enable");
pragma Inline (fl_tooltip_enable);
procedure fl_tooltip_enter_area
(I : in System.Address;
X, Y, W, H : in Interfaces.C.int;
T : in Interfaces.C.char_array);
pragma Import (C, fl_tooltip_enter_area, "fl_tooltip_enter_area");
pragma Inline (fl_tooltip_enter_area);
function fl_tooltip_get_delay
return Interfaces.C.C_float;
pragma Import (C, fl_tooltip_get_delay, "fl_tooltip_get_delay");
pragma Inline (fl_tooltip_get_delay);
procedure fl_tooltip_set_delay
(V : in Interfaces.C.C_float);
pragma Import (C, fl_tooltip_set_delay, "fl_tooltip_set_delay");
pragma Inline (fl_tooltip_set_delay);
function fl_tooltip_get_hoverdelay
return Interfaces.C.C_float;
pragma Import (C, fl_tooltip_get_hoverdelay, "fl_tooltip_get_hoverdelay");
pragma Inline (fl_tooltip_get_hoverdelay);
procedure fl_tooltip_set_hoverdelay
(V : in Interfaces.C.C_float);
pragma Import (C, fl_tooltip_set_hoverdelay, "fl_tooltip_set_hoverdelay");
pragma Inline (fl_tooltip_set_hoverdelay);
function fl_tooltip_get_color
return Interfaces.C.unsigned;
pragma Import (C, fl_tooltip_get_color, "fl_tooltip_get_color");
pragma Inline (fl_tooltip_get_color);
procedure fl_tooltip_set_color
(V : in Interfaces.C.unsigned);
pragma Import (C, fl_tooltip_set_color, "fl_tooltip_set_color");
pragma Inline (fl_tooltip_set_color);
function fl_tooltip_get_margin_height
return Interfaces.C.int;
pragma Import (C, fl_tooltip_get_margin_height, "fl_tooltip_get_margin_height");
pragma Inline (fl_tooltip_get_margin_height);
-- procedure fl_tooltip_set_margin_height
-- (V : in Interfaces.C.int);
-- pragma Import (C, fl_tooltip_set_margin_height, "fl_tooltip_set_margin_height");
-- pragma Inline (fl_tooltip_set_margin_height);
function fl_tooltip_get_margin_width
return Interfaces.C.int;
pragma Import (C, fl_tooltip_get_margin_width, "fl_tooltip_get_margin_width");
pragma Inline (fl_tooltip_get_margin_width);
-- procedure fl_tooltip_set_margin_width
-- (V : in Interfaces.C.int);
-- pragma Import (C, fl_tooltip_set_margin_width, "fl_tooltip_set_margin_width");
-- pragma Inline (fl_tooltip_set_margin_width);
function fl_tooltip_get_wrap_width
return Interfaces.C.int;
pragma Import (C, fl_tooltip_get_wrap_width, "fl_tooltip_get_wrap_width");
pragma Inline (fl_tooltip_get_wrap_width);
-- procedure fl_tooltip_set_wrap_width
-- (V : in Interfaces.C.int);
-- pragma Import (C, fl_tooltip_set_wrap_width, "fl_tooltip_set_wrap_width");
-- pragma Inline (fl_tooltip_set_wrap_width);
function fl_tooltip_get_textcolor
return Interfaces.C.unsigned;
pragma Import (C, fl_tooltip_get_textcolor, "fl_tooltip_get_textcolor");
pragma Inline (fl_tooltip_get_textcolor);
procedure fl_tooltip_set_textcolor
(V : in Interfaces.C.unsigned);
pragma Import (C, fl_tooltip_set_textcolor, "fl_tooltip_set_textcolor");
pragma Inline (fl_tooltip_set_textcolor);
function fl_tooltip_get_font
return Interfaces.C.int;
pragma Import (C, fl_tooltip_get_font, "fl_tooltip_get_font");
pragma Inline (fl_tooltip_get_font);
procedure fl_tooltip_set_font
(V : in Interfaces.C.int);
pragma Import (C, fl_tooltip_set_font, "fl_tooltip_set_font");
pragma Inline (fl_tooltip_set_font);
function fl_tooltip_get_size
return Interfaces.C.int;
pragma Import (C, fl_tooltip_get_size, "fl_tooltip_get_size");
pragma Inline (fl_tooltip_get_size);
procedure fl_tooltip_set_size
(V : in Interfaces.C.int);
pragma Import (C, fl_tooltip_set_size, "fl_tooltip_set_size");
pragma Inline (fl_tooltip_set_size);
function fl_widget_get_user_data
(W : in System.Address)
return System.Address;
pragma Import (C, fl_widget_get_user_data, "fl_widget_get_user_data");
pragma Inline (fl_widget_get_user_data);
package Widget_Convert is new
System.Address_To_Access_Conversions (FLTK.Widgets.Widget'Class);
function Get_Target
return access FLTK.Widgets.Widget'Class
is
Widget_Ptr : System.Address := fl_tooltip_get_current;
begin
if Widget_Ptr /= System.Null_Address then
return Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
else
return null;
end if;
end Get_Target;
procedure Set_Target
(To : in FLTK.Widgets.Widget'Class) is
begin
fl_tooltip_set_current (Wrapper (To).Void_Ptr);
end Set_Target;
function Is_Enabled
return Boolean is
begin
return fl_tooltip_enabled /= 0;
end Is_Enabled;
procedure Set_Enabled
(To : in Boolean) is
begin
fl_tooltip_enable (Boolean'Pos (To));
end Set_Enabled;
procedure Enter_Area
(Item : in FLTK.Widgets.Widget'Class;
X, Y, W, H : in Integer;
Tip : in String) is
begin
fl_tooltip_enter_area
(Wrapper (Item).Void_Ptr,
Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Tip));
end Enter_Area;
function Get_Delay
return Float is
begin
return Float (fl_tooltip_get_delay);
end Get_Delay;
procedure Set_Delay
(To : in Float) is
begin
fl_tooltip_set_delay (Interfaces.C.C_float (To));
end Set_Delay;
function Get_Hover_Delay
return Float is
begin
return Float (fl_tooltip_get_hoverdelay);
end Get_Hover_Delay;
procedure Set_Hover_Delay
(To : in Float) is
begin
fl_tooltip_set_hoverdelay (Interfaces.C.C_float (To));
end Set_Hover_Delay;
function Get_Background_Color
return Color is
begin
return Color (fl_tooltip_get_color);
end Get_Background_Color;
procedure Set_Background_Color
(To : in Color) is
begin
fl_tooltip_set_color (Interfaces.C.unsigned (To));
end Set_Background_Color;
function Get_Margin_Height
return Natural is
begin
return Natural (fl_tooltip_get_margin_height);
end Get_Margin_Height;
-- procedure Set_Margin_Height
-- (To : in Natural) is
-- begin
-- fl_tooltip_set_margin_height (Interfaces.C.int (To));
-- end Set_Margin_Height;
function Get_Margin_Width
return Natural is
begin
return Natural (fl_tooltip_get_margin_width);
end Get_Margin_Width;
-- procedure Set_Margin_Width
-- (To : in Natural) is
-- begin
-- fl_tooltip_set_margin_width (Interfaces.C.int (To));
-- end Set_Margin_Width;
function Get_Wrap_Width
return Natural is
begin
return Natural (fl_tooltip_get_wrap_width);
end Get_Wrap_Width;
-- procedure Set_Wrap_Width
-- (To : in Natural) is
-- begin
-- fl_tooltip_set_wrap_width (Interfaces.C.int (To));
-- end Set_Wrap_Width;
function Get_Text_Color
return Color is
begin
return Color (fl_tooltip_get_textcolor);
end Get_Text_Color;
procedure Set_Text_Color
(To : in Color) is
begin
fl_tooltip_set_textcolor (Interfaces.C.unsigned (To));
end Set_Text_Color;
function Get_Text_Font
return Font_Kind is
begin
return Font_Kind'Val (fl_tooltip_get_font);
end Get_Text_Font;
procedure Set_Text_Font
(To : in Font_Kind) is
begin
fl_tooltip_set_font (Font_Kind'Pos (To));
end Set_Text_Font;
function Get_Text_Size
return Font_Size is
begin
return Font_Size (fl_tooltip_get_size);
end Get_Text_Size;
procedure Set_Text_Size
(To : in Font_Size) is
begin
fl_tooltip_set_size (Interfaces.C.int (To));
end Set_Text_Size;
end FLTK.Tooltips;
|
package Type_Lib is
type RPM is new Natural range 1000 .. 2000;
type Motor_Direction is (Left, Right);
end Type_Lib;
|
-- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath (emanuel.regnath@tum.de)
with Units.Navigation; use Units.Navigation;
with Units;
with HIL.UART;
with Interfaces; use Interfaces;
-- @summary Driver to parse messages of the GPS Module Ublox LEA-6H
package ublox8.Driver with SPARK_Mode,
Abstract_State => State,
Initializes => State
is
type Error_Type is (SUCCESS, FAILURE);
subtype Time_Type is Units.Time_Type;
type GPS_DateTime_Type is record
year : Year_Type := Year_Type'First;
mon : Month_Type := Month_Type'First;
day : Day_Of_Month_Type := Day_Of_Month_Type'First;
hour : Hour_Type := Hour_Type'First;
min : Minute_Type := Minute_Type'First;
sec : Second_Type := Second_Type'First;
end record;
type GPS_Message_Type is record
itow : GPS_Time_Of_Week_Type := 0;
datetime : GPS_DateTime_Type;
fix : GPS_Fix_Type := NO_FIX;
sats : Unsigned_8 := 0; --*< Number of SVs used in Nav Solution
lon : Longitude_Type;
lat : Latitude_Type;
alt : Altitude_Type;
speed : Units.Linear_Velocity_Type;
vacc : Units.Length_Type; -- vertical accuracy estimate
end record;
procedure reset;
procedure init;
procedure update_val;
-- poll raw data. Should be called periodically.
function get_Position return GPS_Loacation_Type;
-- read most recent position
function get_GPS_Message return GPS_Message_Type;
function get_Fix return GPS_Fix_Type;
-- read most recent fix status
function get_Nsat return Unsigned_8;
-- read most recent number of used satellits
function get_Velo return Units.Linear_Velocity_Type;
-- read most recent velocity
function get_Time return GPS_DateTime_Type;
-- read most recent time stamp
function get_Vertical_Accuracy return Units.Length_Type;
-- read most recent accuracy estimate
procedure perform_Self_Check (Status : out Error_Type);
-- test communication with GPS (ignoring fix state)
private
subtype Data_Type is HIL.UART.Data_Type;
end ublox8.Driver;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . D Y N A M I C _ P R I O R I T I E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
-- --
-- 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. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
with System.Task_Primitives.Operations;
with System.Tasking;
with System.Parameters;
with System.Soft_Links;
with Ada.Unchecked_Conversion;
package body Ada.Dynamic_Priorities is
package STPO renames System.Task_Primitives.Operations;
package SSL renames System.Soft_Links;
use System.Parameters;
use System.Tasking;
function Convert_Ids is new
Ada.Unchecked_Conversion
(Task_Identification.Task_Id, System.Tasking.Task_Id);
------------------
-- Get_Priority --
------------------
-- Inquire base priority of a task
function Get_Priority
(T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task) return System.Any_Priority
is
Target : constant Task_Id := Convert_Ids (T);
Error_Message : constant String := "Trying to get the priority of a ";
begin
if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then
raise Program_Error with Error_Message & "null task";
end if;
if Task_Identification.Is_Terminated (T) then
raise Tasking_Error with Error_Message & "terminated task";
end if;
return Target.Common.Base_Priority;
end Get_Priority;
------------------
-- Set_Priority --
------------------
-- Change base priority of a task dynamically
procedure Set_Priority
(Priority : System.Any_Priority;
T : Ada.Task_Identification.Task_Id :=
Ada.Task_Identification.Current_Task)
is
Target : constant Task_Id := Convert_Ids (T);
Error_Message : constant String := "Trying to set the priority of a ";
Yield_Needed : Boolean;
begin
if Target = Convert_Ids (Ada.Task_Identification.Null_Task_Id) then
raise Program_Error with Error_Message & "null task";
end if;
-- Setting the priority of an already-terminated task doesn't do
-- anything (see RM-D.5.1(7)). Note that Get_Priority is different in
-- this regard.
if Task_Identification.Is_Terminated (T) then
return;
end if;
SSL.Abort_Defer.all;
if Single_Lock then
STPO.Lock_RTS;
end if;
STPO.Write_Lock (Target);
Target.Common.Base_Priority := Priority;
if Target.Common.Call /= null
and then
Target.Common.Call.Acceptor_Prev_Priority /= Priority_Not_Boosted
then
-- Target is within a rendezvous, so ensure the correct priority
-- will be reset when finishing the rendezvous, and only change the
-- priority immediately if the new priority is greater than the
-- current (inherited) priority.
Target.Common.Call.Acceptor_Prev_Priority := Priority;
if Priority >= Target.Common.Current_Priority then
Yield_Needed := True;
STPO.Set_Priority (Target, Priority);
else
Yield_Needed := False;
end if;
else
Yield_Needed := True;
STPO.Set_Priority (Target, Priority);
if Target.Common.State = Entry_Caller_Sleep then
Target.Pending_Priority_Change := True;
STPO.Wakeup (Target, Target.Common.State);
end if;
end if;
STPO.Unlock (Target);
if Single_Lock then
STPO.Unlock_RTS;
end if;
if STPO.Self = Target and then Yield_Needed then
-- Yield is needed to enforce FIFO task dispatching
-- LL Set_Priority is made while holding the RTS lock so that it is
-- inheriting high priority until it release all the RTS locks.
-- If this is used in a system where Ceiling Locking is not enforced
-- we may end up getting two Yield effects.
STPO.Yield;
end if;
SSL.Abort_Undefer.all;
end Set_Priority;
end Ada.Dynamic_Priorities;
|
package NCurses is
pragma Pure;
type Color is new Natural range 0..7;
type Color_Range is new Natural range 0..1000;
type Byte is mod 2**8 with Size=>8;
COLOR_BLACK : constant Color := 0;
COLOR_RED : constant Color := 1;
COLOR_GREEN : constant Color := 2;
COLOR_YELLOW : constant Color := 3;
COLOR_BLUE : constant Color := 4;
COLOR_MAGENTA : constant Color := 5;
COLOR_CYAN : constant Color := 6;
COLOR_WHITE : constant Color := 7;
procedure Start_Color_Init;
function Get_Input return Byte
with Import, Convention=>C, Link_Name=>"get_mouse_input";
procedure Start_Color
with Import, Convention=>C, Link_Name=>"start_color";
procedure Attribute_On (Pair : in Natural)
with Import, Convention=>C, Link_Name=>"attribute_on_c";
procedure Attribute_Off (Pair : in Natural)
with Import, Convention=>C, Link_Name=>"attribute_off_c";
procedure Attribute_On_Bold
with Import, Convention=>C, Link_Name=>"attribute_on_bold_c";
procedure Setup
with Import, Convention=>C, Link_Name=>"setup";
procedure Attribute_Off_Bold
with Import, Convention=>C, Link_Name=>"attribute_off_bold_c";
procedure Init_Color_Pair (Pair : in Natural; Color_1, Color_2 : in Color)
with Import, Convention=>C, Link_Name=>"init_pair_c";
procedure Init_Color (Color_Op : in Color; R, G, B : Color_Range)
with Import, Convention=>C, Link_Name=>"init_color";
procedure Move_Print_Window (Row, Col : in Natural; Item : in String)
with Import, Convention=>C, Link_Name=>"mvprintw";
procedure Print_Window (Item : in String)
with Import, Convention=>C, Link_Name=>"printw";
procedure Pretty_Print_Window (Item : in String) with Inline;
procedure Pretty_Print_Line_Window (Item : in String) with Inline;
procedure Init_Scr
with Import, Convention=>C, Link_Name=>"initscr";
procedure Refresh
with Import, Convention=>C, Link_Name=>"refresh";
procedure End_Win
with Import, Convention=>C, Link_Name=>"endwin";
procedure Clear
with Import, Convention=>C, Link_Name=>"clear";
pragma Linker_Options("-lncurses");
end NCurses;
|
-- C54A13B.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 IF A CASE EXPRESSION IS A GENERIC "IN" OR "IN OUT"
-- PARAMETER WITH A NON-STATIC SUBTYPE OR ONE OF THESE IN
-- PARENTHESES, THEN ANY VALUE OF THE EXPRESSION'S BASE TYPE MAY
-- APPEAR AS A CHOICE.
-- HISTORY:
-- BCB 07/13/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C54A13B IS
L : INTEGER := IDENT_INT(1);
R : INTEGER := IDENT_INT(100);
SUBTYPE INT IS INTEGER RANGE L .. R;
GENERIC
IN_PAR : IN INT;
IN_OUT_PAR : IN OUT INT;
PROCEDURE GEN_PROC (I : IN OUT INTEGER);
IN_VAR : INT := IDENT_INT (10);
IN_OUT_VAR : INT := IDENT_INT (100);
CHECK_VAR : INT := IDENT_INT (1);
PROCEDURE GEN_PROC (I : IN OUT INTEGER) IS
BEGIN
CASE IN_PAR IS
WHEN 0 => I := I + IDENT_INT (2);
WHEN 10 => I := I + IDENT_INT (1);
WHEN -3000 => I := I + IDENT_INT (3);
WHEN OTHERS => I := I + IDENT_INT (4);
END CASE;
CASE IN_OUT_PAR IS
WHEN 0 => IN_OUT_PAR := IDENT_INT (0);
WHEN 100 => IN_OUT_PAR := IDENT_INT (50);
WHEN -3000 => IN_OUT_PAR := IDENT_INT (-3000);
WHEN OTHERS => IN_OUT_PAR := IDENT_INT (5);
END CASE;
CASE (IN_PAR) IS
WHEN 0 => I := I + IDENT_INT (2);
WHEN 10 => I := I + IDENT_INT (1);
WHEN -3000 => I := I + IDENT_INT (3);
WHEN OTHERS => I := I + IDENT_INT (4);
END CASE;
CASE (IN_OUT_PAR) IS
WHEN 0 => IN_OUT_PAR := IDENT_INT (200);
WHEN 50 => IN_OUT_PAR := IDENT_INT (25);
WHEN -3000 => IN_OUT_PAR := IDENT_INT (300);
WHEN OTHERS => IN_OUT_PAR := IDENT_INT (400);
END CASE;
END GEN_PROC;
PROCEDURE P IS NEW GEN_PROC (IN_VAR, IN_OUT_VAR);
BEGIN
TEST ("C54A13B", "CHECK THAT IF A CASE EXPRESSION IS A " &
"GENERIC 'IN' OR 'IN OUT' PARAMETER WITH A " &
"NON-STATIC SUBTYPE OR ONE OF " &
"THESE IN PARENTHESES, THEN ANY VALUE OF " &
"THE EXPRESSION'S BASE TYPE MAY APPEAR AS " &
"A CHOICE");
P (CHECK_VAR);
IF NOT EQUAL (CHECK_VAR, IDENT_INT(3)) THEN
FAILED ("INCORRECT CHOICES MADE FOR IN PARAMETER IN CASE");
END IF;
IF NOT EQUAL (IN_OUT_VAR, IDENT_INT(25)) THEN
FAILED ("INCORRECT CHOICESMADE FOR IN OUT PARAMETER IN CASE");
END IF;
RESULT;
END C54A13B;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2001-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the version of this package for Ravenscar bare board targets
pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during tasking
-- operations. It causes infinite loops and other problems.
with System.OS_Interface;
package System.Task_Primitives
with SPARK_Mode => Off is -- because of access types
pragma Preelaborate;
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper
-- declared local to the GNARL).
type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task
-- basis. A component of this type is guaranteed to be included
-- in the Ada_Task_Control_Block.
subtype Task_Address is System.Address;
Task_Address_Size : constant := Standard'Address_Size;
-- Type used for task addresses and its size
Alternate_Stack_Size : constant := 0;
-- No alternate signal stack is used on this platform
private
pragma SPARK_Mode (Off);
type Private_Data is limited record
Thread_Desc : aliased System.OS_Interface.Thread_Descriptor;
-- Thread descriptor associated to the ATCB to which it belongs
Thread : aliased System.OS_Interface.Thread_Id :=
System.OS_Interface.Null_Thread_Id;
-- Thread Id associated to the ATCB to which it belongs.
-- ??? It is mostly used by GDB, so we may want to remove it at some
-- point.
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb).
-- They put the same value (thr_self value). We do not want to
-- use lock on those operations and the only thing we have to
-- make sure is that they are updated in atomic fashion.
Lwp : aliased System.Address := System.Null_Address;
-- This element duplicates the Thread element. It is read by gdb when
-- the remote protocol is used.
end record;
end System.Task_Primitives;
|
package Discr12_Pkg is
function Dummy (I : Integer) return Integer;
end Discr12_Pkg;
|
with Test_Solution; use Test_Solution;
package Problem_8 is
type Int64 is range -2**63 .. 2**63 - 1;
function Solution_1 return Int64;
procedure Test_Solution_1;
function Get_Solutions return Solution_Case;
end Problem_8;
|
pragma License (Unrestricted);
-- extended unit
with Ada.References.Wide_Strings;
with Ada.Streams.Block_Transmission.Wide_Strings;
with Ada.Strings.Generic_Bounded;
package Ada.Strings.Bounded_Wide_Strings is
new Generic_Bounded (
Wide_Character,
Wide_String,
Streams.Block_Transmission.Wide_Strings.Read,
Streams.Block_Transmission.Wide_Strings.Write,
References.Wide_Strings.Slicing);
pragma Preelaborate (Ada.Strings.Bounded_Wide_Strings);
|
generic
with function "<" (L : Item_Type; R : Item_Type) return Boolean is <>;
package ACO.Utils.DS.Generic_Collection.Sorted is
pragma Preelaborate;
type Sorted_Collection (Max_Size : Positive) is
new Collection (Max_Size) with null record;
overriding
procedure Insert
(C : in out Sorted_Collection;
Item : in Item_Type)
with Pre => not Is_Full (C);
overriding
procedure Insert
(C : in out Sorted_Collection;
Item : in Item_Type;
Before : in Positive)
with Pre => Is_Valid_Index (C, Before) and not Is_Full (C);
overriding
procedure Append
(C : in out Sorted_Collection;
Item : in Item_Type)
with Pre => not Is_Full (C);
overriding
procedure Append
(C : in out Sorted_Collection;
Item : in Item_Type;
After : in Positive)
with Pre => Is_Valid_Index (C, After) and not Is_Full (C);
overriding
procedure Replace
(C : in out Sorted_Collection;
At_Index : in Positive;
Item : in Item_Type)
with Pre => Is_Valid_Index (C, At_Index);
end ACO.Utils.DS.Generic_Collection.Sorted;
|
package body Numerics is
function modulus (X, Y : in Real) return Real is
Result : Real := X;
begin
if Result >= 0.0 then
while Result - Y >= 0.0 loop
Result := Result - Y;
end loop;
else
while Result < 0.0 loop
Result := Result + Y;
end loop;
end if;
return Result;
end modulus;
function Rand return Real is
use Ada.Numerics.Float_Random;
begin
return Real (Random (Gen));
end Rand;
function Rand (N : in Nat) return Real_Vector is
use Ada.Numerics.Float_Random;
X : Real_Vector (1 .. N) := (others => Rand);
begin
return X;
end Rand;
-- Vectorize & To_Array are needed in Triplet_To_Matrix
procedure Set (X : in out RVector;
To : in Real_Vector) is
begin
X.Reserve_Capacity (To'Length);
X.Set_Length (0);
for Y of To loop
X.Append (Y);
end loop;
end Set;
procedure Set (X : in out IVector;
To : in Int_Array) is
begin
X.Reserve_Capacity (To'Length);
X.Set_Length (0);
for Y of To loop
X.Append (Y);
end loop;
end Set;
function Vectorize (Item : in Real_Vector) return RVector is
X : RVector;
begin
X.Reserve_Capacity (Item'Length);
X.Set_Length (0);
for Y of Item loop
X.Append (Y);
end loop;
return X;
end Vectorize;
function Vectorize (Item : in Int_Array) return IVector is
X : IVector;
begin
X.Reserve_Capacity (Item'Length);
X.Set_Length (0);
for Y of Item loop
X.Append (Y);
end loop;
return X;
end Vectorize;
function Norm (X : in Real_Vector) return Real is
Y : Real := 0.0;
use Real_Functions;
begin
for Item of X loop
Y := Y + Item ** 2;
end loop;
return Sqrt (Y);
end Norm;
function Max_Norm (X : in Real_Vector) return Real is
Y : Real := 0.0;
use Real_Functions;
begin
for Item of X loop
Y := Real'Max (Y, Item);
end loop;
return Y;
end Max_Norm;
function To_Array (Item : in RVector) return Real_Vector is
Result : Real_Vector (1 .. Pos (Item.Length));
I : Nat := 1;
use Ada.Text_IO;
begin
for Y of Item loop
Result (I) := Y;
I := I + 1;
end loop;
return Result;
end To_Array;
function To_Array (Item : in IVector) return Int_Array is
Result : Int_Array (1 .. Pos (Item.Length));
I : Nat := 1;
use Ada.Text_IO;
begin
for Y of Item loop
Result (I) := Y;
I := I + 1;
end loop;
return Result;
end To_Array;
function Zero (N : in Pos) return Sparse_Vector is
X : Real_Vector (1 .. 1) := (others => 0.0);
Y : Sparse_Vector := Sparse (X);
begin
Y.NMax := N;
return Y;
end Zero;
function One (I, N : in Nat) return Sparse_Vector is
X : Real_Vector (1 .. 1) := (others => 1.0);
Y : Sparse_Vector;
begin
Y := Zero (I - 1) or Sparse (X) or Zero (N - I);
return Y;
end One;
----- Vector and Array functions
procedure Set_Length (V : in out RVector;
N : in Integer) is
begin
V.Set_Length (Ada.Containers.Count_Type (N));
end Set_Length;
function Length (X : in RVector) return Integer is (Integer (X.Length));
-------- Max and Abs_Max functions ------------------
function Max_Int_Array (Item : in Int_Array) return Integer is separate;
function Max_Real_Array (Item : in Real_Vector) return Real is separate;
function Abs_Max_IA (Item : in Int_Array) return Integer is separate;
function Abs_Max_RA (Item : in Real_Vector) return Real is separate;
function Max (X : in IVector) return Integer is
Result : Integer;
begin
case X.Length is
when 0 => return 0;
when 1 => return X (1);
when others =>
Result := X (1);
for I in 2 .. Nat (X.Length) loop
if X (I) > Result then Result := X (I); end if;
end loop;
return Result;
end case;
end Max;
function Max (X : in RVector) return Real is
Result : Real;
begin
case X.Length is
when 0 => return 0.0;
when 1 => return X (1);
when others =>
Result := X (1);
for I in 2 .. Nat (X.Length) loop
if X (I) > Result then Result := X (I); end if;
end loop;
return Result;
end case;
end Max;
-------- Binary Operators ---------------------------
function Dot_Product (Left_I, Right_J : in Int_Array;
Left_X, Right_Y : in Real_Vector) return Real is separate;
function Sparse (X : in Real_Vector;
N : in Pos := 0;
Tol : in Real := 10.0 * Real'Small)
return Sparse_Vector is
use IV_Package, RV_Package, Ada.Containers;
Y : Sparse_Vector;
Offset : constant Integer := 1 - X'First;
begin
Y.NMax := (if N < X'Length then X'Length else N);
Y.X.Reserve_Capacity (Count_Type (X'Length));
Y.I.Reserve_Capacity (Count_Type (X'Length));
for I in X'Range loop
if abs (X (I)) > Tol then
Y.X.Append (X (I));
Y.I.Append (I + Offset);
end if;
end loop;
return Y;
end Sparse;
function "+" (A, B : in Sparse_Vector) return Sparse_Vector is
use IV_Package, RV_Package, Ada.Containers;
C : Sparse_Vector;
Ax, Bx : Real;
Ai, Bi : Pos;
I, J : Pos := 1;
Al : constant Pos := Pos (A.X.Length);
Bl : constant Pos := Pos (B.X.Length);
N : constant Count_Type := Count_Type'Min (Count_Type (A.NMax),
A.X.Length + B.X.Length);
begin
pragma Assert (A.NMax = B.NMax,
"ERROR: Vectors are not of equal lengths");
C.NMax := A.NMax;
C.X.Reserve_Capacity (N);
C.I.Reserve_Capacity (N);
while I <= Al and J <= Bl loop
Ax := A.X (I); Bx := B.X (J);
Ai := A.I (I); Bi := B.I (J);
if Ai = Bi then
C.X.Append (Ax + Bx);
C.I.Append (Ai);
I := I + 1; J := J + 1;
elsif Bi < Ai then
C.X.Append (Bx);
C.I.Append (Bi);
J := J + 1;
else
C.X.Append (Ax);
C.I.Append (Ai);
I := I + 1;
end if;
end loop;
while I <= Al loop
C.X.Append (A.X (I));
C.I.Append (A.I (I));
I := I + 1;
end loop;
while J <= Bl loop
C.X.Append (B.X (J));
C.I.Append (B.I (J));
J := J + 1;
end loop;
C.X.Reserve_Capacity (C.X.Length);
C.I.Reserve_Capacity (C.X.Length);
return C;
end "+";
function "*" (A : in Real;
B : in Sparse_Vector) return Sparse_Vector is
C : Sparse_Vector := B;
begin
for X of C.X loop
X := A * X;
end loop;
return C;
end "*";
function "*" (A : in Real_Matrix;
B : in Sparse_Vector) return Sparse_Vector is
C : Real_Vector (A'Range (2)) := (others => 0.0);
J : constant Int_Array := To_Array (B.I);
X : constant Real_Vector := To_Array (B.X);
begin
for K in J'Range loop
for I in A'Range (1) loop
C (I) := C (I) + A (I, J (K)) * X (J (K));
end loop;
end loop;
return Sparse (C);
end "*";
procedure Print (X : in Sparse_Vector) is
use Int_IO, Real_IO, Ada.Text_IO;
begin
Put ("Length of vector:"); Put (X.NMax); New_Line;
for I in 1 .. Pos (X.X.Length) loop
Put (X.I (I)); Put (", "); Put (X.X (I)); New_Line;
end loop;
end Print;
function Length (X : in Sparse_Vector) return Pos is (X.NMax);
function To_Array (X : in Sparse_Vector) return Real_Vector is
Y : Real_Vector (1 .. X.NMax);
begin
if Pos (X.X.Length) = X.NMax then
Y := To_Array (X.X);
else
Y := (others => 0.0);
for K in 1 .. Pos (X.I.Length) loop
Y (X.I (K)) := X.X (K);
end loop;
end if;
return Y;
end To_Array;
function Norm (X : in Sparse_Vector) return Real is
Result : Real := 0.0;
begin
for Item of X.X loop
Result := Result + Item ** 2;
end loop;
return Real_Functions.Sqrt (Result);
end Norm;
procedure Set_Length (X : in out Sparse_Vector;
N : in Pos) is
use Ada.Containers;
begin
X.NMax := N;
X.X.Reserve_Capacity (Count_Type (N));
X.I.Reserve_Capacity (Count_Type (N));
end Set_Length;
procedure Set (Item : in out Sparse_Vector;
I : in Nat;
X : in Real) is
Length : constant Pos := Pos (Item.I.Length);
begin
if Length = Item.NMax then
Item.X (I) := X;
elsif Length = 0 then
Item.I.Append (I);
Item.X.Append (X);
else
-- look for index K >= I in Item.I
for K in 1 .. Length loop
if Item.I (K) = I then
Item.X (K) := X;
return;
elsif Item.I (K) > I then
Item.I.Insert (Before => K, New_Item => I);
Item.X.Insert (Before => K, New_Item => X);
return;
end if;
end loop;
-- if not found, then append since I is largest
Item.I.Append (I);
Item.X.Append (X);
end if;
end Set;
procedure Add (Item : in out Sparse_Vector;
I : in Nat;
X : in Real) is
Length : constant Pos := Pos (Item.I.Length);
begin
if Length = Item.NMax then
Item.X (I) := X;
elsif Length = 0 then
Item.I.Append (I);
Item.X.Append (X);
else
-- look for index K >= I in Item.I
for K in 1 .. Length loop
if Item.I (K) = I then
Item.X (K) := Item.X (K) + X;
return;
elsif Item.I (K) > I then
Item.I.Insert (Before => K, New_Item => I);
Item.X.Insert (Before => K, New_Item => X);
return;
end if;
end loop;
Item.I.Append (I);
Item.X.Append (X);
end if;
end Add;
function Remove_1st_N (X : in Sparse_Vector;
N : in Pos) return Sparse_Vector is
Y : Sparse_Vector;
begin
pragma Assert (X.NMax > N);
Y.NMax := X.NMax - N;
Y.I.Reserve_Capacity (X.X.Length);
Y.X.Reserve_Capacity (X.X.Length);
for I in 1 .. Pos (X.X.Length) loop
if X.I (I) > N then
Y.I.Append (X.I (I) - N);
Y.X.Append (X.X (I));
end if;
end loop;
Y.I.Reserve_Capacity (Y.I.Length);
Y.X.Reserve_Capacity (Y.X.Length);
return Y;
end Remove_1st_N;
function "or" (X, Y : in Sparse_Vector) return Sparse_Vector is
use Ada.Containers;
Z : Sparse_Vector;
begin
Z.NMax := X.NMax + Y.NMax;
Z.I.Reserve_Capacity (X.I.Length + Y.I.Length);
Z.X.Reserve_Capacity (X.I.Length + Y.I.Length);
for I in 1 .. Pos (X.X.Length) loop
Z.I.Append (X.I (I));
Z.X.Append (X.X (I));
end loop;
for I in 1 .. Pos (Y.X.Length) loop
Z.I.Append (Y.I (I) + X.NMax);
Z.X.Append (Y.X (I));
end loop;
return Z;
end "or";
-- function "+" (X, Y : in Pos2D) return Pos2D is
-- begin
-- return (X.X + Y.X, X.Y + Y.Y);
-- end "+";
-- function "-" (X : in Pos2D) return Pos2D is
-- begin
-- return (-X.X, -X.Y);
-- end "-";
-- function "-" (X, Y : in Pos2D) return Pos2D is
-- begin
-- return (X.X - Y.X, X.Y - Y.Y);
-- end "-";
-- function Dot (X, Y : in Pos2D) return Real is
-- begin
-- return X.X * Y.X + X.Y * Y.Y;
-- end Dot;
-- function Norm (X : in Pos2D) return Real is
-- use Real_Functions;
-- begin
-- return Sqrt (X.X**2 + X.Y**2);
-- end Norm;
-- function To_Array (Xvec : in Pos2D_Vector) return Real_Vector is
-- Result : Real_Vector (1 .. 2 * Xvec'Length);
-- K : Nat := 1;
-- begin
-- for X of Xvec loop
-- Result (K) := X.X; K := K + 1;
-- Result (K) := X.Y; K := K + 1;
-- end loop;
-- return Result;
-- end To_Array;
-- function "+" (X, Y : in Pos2D_Vector) return Pos2D_Vector is
-- Z : Pos2D_Vector := X;
-- begin
-- for I in Z'Range loop
-- Z (I) := Z (I) + Y (I);
-- end loop;
-- return Z;
-- end "+";
-- function "-" (X, Y : in Pos2D_Vector) return Pos2D_Vector is
-- Z : Pos2D_Vector := X;
-- begin
-- for I in Z'Range loop
-- Z (I) := Z (I) - Y (I);
-- end loop;
-- return Z;
-- end "-";
-- function "-" (X : in Pos2D_Vector) return Pos2D_Vector is
-- Z : Pos2D_Vector (X'Range);
-- begin
-- for I in Z'Range loop
-- Z (I) := -X (I);
-- end loop;
-- return Z;
-- end "-";
-- function "*" (X : in Real;
-- Y : in Pos2D_Vector) return Pos2D_Vector is
-- Z : Pos2D_Vector := Y;
-- begin
-- for K of Z loop
-- K := X * K;
-- end loop;
-- return Z;
-- end "*";
-------- Real array functions ----------------
function "-" (X : in Real_Vector) return Real_Vector is
Y : Real_Vector (X'Range);
begin
for I in X'Range loop
Y (I) := -X (I);
end loop;
return Y;
end "-";
function "+" (X : in Real_Vector;
Y : in Real_Vector) return Real_Vector is
Z : Real_Vector (1 .. X'Length);
Offset_Y : constant Integer := Y'First - X'First;
Offset_Z : constant Integer := 1 - X'First;
begin
for I in X'Range loop
Z (I + Offset_Z) := X (I) + Y (I + Offset_Y);
end loop;
return Z;
end "+";
function "-" (X : in Real_Vector;
Y : in Real_Vector) return Real_Vector is
Z : Real_Vector (1 .. X'Length);
Offset_Y : constant Integer := Y'First - X'First;
Offset_Z : constant Integer := 1 - X'First;
begin
for I in X'Range loop
Z (I + Offset_Z) := X (I) - Y (I + Offset_Y);
end loop;
return Z;
end "-";
function "*" (Left : in Real;
Right : in Real_Vector) return Real_Vector is
Result : Real_Vector (Right'Range);
begin
for I in Result'Range loop
Result (I) := Left * Right (I);
end loop;
return Result;
end "*";
function "/" (Left : in Real_Vector;
Right : in Real) return Real_Vector is
Result : Real_Vector (Left'Range);
begin
for I in Result'Range loop
Result (I) := Left (I) / Right;
end loop;
return Result;
end "/";
----------- Real_Vector functions ---------------------------
function "*" (A : in Real_Matrix;
X : in Real_Vector) return Real_Vector is
Y : Real_Vector (1 .. A'Length (1)) := (others => 0.0);
Offset1 : constant Integer := A'First (1) - 1;
Offset2 : constant Integer := A'First (2) - X'First;
begin
for I in Y'Range loop
for J in X'Range loop
Y (I) := Y (I) + A (I + Offset1, J + Offset2) * X (J);
end loop;
end loop;
return Y;
end "*";
function Dot (X, Y : in Real_Vector) return Real is
R : Real := 0.0;
begin
for I in X'Range loop
R := R + X (I) * Y (I + Y'First - X'First);
end loop;
return R;
end Dot;
begin
Ada.Numerics.Float_Random.Reset (Gen);
end Numerics;
|
with System;
with Other_Basic_Subprogram_Calls;
package body Generic_Subprogram_Calls is
G1_Address : System.Address := G1'Address;
generic procedure G1_Renamed renames G1;
G1_Renamed_Address : System.Address := G1_Renamed'Address;
generic package G4_Renamed renames G4;
procedure Test is
procedure G1_Instance is new G1(TP => Integer);
procedure G1_Renamed_Instance is new G1_Renamed(TP => Integer);
procedure G2_Instance_1 is new G2(PP => Other_Basic_Subprogram_Calls.Other_P1);
procedure G2_Instance_2 is new G2(G2_Instance_1);
package G3_Instance is new G3(TP => Integer);
package G4_Instance is new G4(G2_Instance_1);
package G4_Renamed_Instance is new G4_Renamed(G2_Instance_2);
P : access procedure(T : Integer);
Q : access procedure;
function G5_Instance is new G5(Integer);
I : Integer := 42;
function G6_Instance is new G6(Integer, I);
PF : access function(T : Integer) return Integer;
type AQF is access function return Integer;
subtype AQFS is AQF;
QF : AQFS;
begin
G1_Instance(42);
G1_Renamed_Instance(42);
G2_Instance_1;
G2_Instance_2;
P := G1_Instance'Access;
P := G1_Renamed_Instance'Access;
P := G3_Instance.P'Access;
P(42);
G3_Instance.P(42);
Q := G2_Instance_2'Access;
Q.all;
I := G5_Instance(42);
I := G6_Instance;
PF := G5_Instance'Access;
QF := G6_Instance'Access;
I := PF(42);
I := PF.all(42);
I := QF.all;
G4_Instance.P;
G4_Renamed_Instance.P;
end;
procedure G1(T : TP) is
P : access procedure(T : TP);
X : System.Address := Other_Basic_Subprogram_Calls.Other_P1'Address;
begin
Other_Basic_Subprogram_Calls.Other_P1;
G1(T);
P := G1'Access;
end G1;
procedure G2 is
X : System.Address;
begin
PP;
X := PP'Address;
X := G2'Address;
end G2;
package body G3 is
procedure P(T : TP) is
X : System.Address := P'Address;
begin
Other_Basic_Subprogram_Calls.Other_P1;
P(T);
end P;
end G3;
package body G4 is
procedure P is
X : System.Address := PP'Address;
begin
PP;
P;
X := P'Address;
end P;
end G4;
function G5(T : TP) return TP is
begin
return T;
end G5;
function G6 return TP is
begin
return T;
end G6;
function Equal_Generic(L, R : T) return Boolean is
begin
return L = R;
end Equal_Generic;
function Equal_Bool_1 is new Equal_Generic(Boolean, Standard."=");
function Equal_Bool_2 is new Equal_Generic(Boolean);
function Foo_Generic(L, R : T) return Boolean is
begin
return Foo(L, R);
end Foo_Generic;
function Foo(L, R : Boolean) return Boolean is
begin
return L = R;
end Foo;
function Foo_Bool_1 is new Foo_Generic(Boolean, Foo);
function Foo_Bool_2 is new Foo_Generic(Boolean);
package Equal_Bool_Package_1 is new Equal_Generic_Package(Boolean, Standard."=");
package Equal_Bool_Package_2 is new Equal_Generic_Package(Boolean);
package Foo_Bool_Package_1 is new Foo_Generic_Package(Boolean, Foo);
package Foo_Bool_Package_2 is new Foo_Generic_Package(Boolean);
end Generic_Subprogram_Calls;
|
-- CE3602B.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 GET (FOR CHARACTER AND STRINGS) PROPERLY SETS THE
-- PAGE, LINE, AND COLUMN NUMBERS AFTER EACH OPERATION.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- TEXT FILES.
-- HISTORY:
-- SPS 08/30/82
-- SPS 12/17/82
-- JBG 02/22/84 CHANGED TO .ADA TEST
-- RJW 11/04/86 REVISED TEST TO OUTPUT A NON_APPLICABLE
-- RESULT WHEN FILES ARE NOT SUPPORTED.
-- JLH 09/04/87 REMOVED DEPENDENCE ON UNBOUNDED LINE LENGTH AND
-- CORRECTED EXCEPTION HANDLING.
-- BCB 11/13/87 GAVE SET_LINE_LENGTH PROCEDURE THE FILE VARIABLE
-- AS A PARAMETER. REMOVED LINE WHICH SAVED AND
-- RESTORED THE LINE LENGTH.
WITH REPORT; USE REPORT;
WITH TEXT_IO; USE TEXT_IO;
WITH CHECK_FILE;
PROCEDURE CE3602B IS
INCOMPLETE : EXCEPTION;
BEGIN
TEST ("CE3602B", "CHECK THAT GET PROPERLY SETS PAGE, LINE, AND " &
"COLUMN NUMBERS");
DECLARE
FILE1 : FILE_TYPE;
LINE1 : CONSTANT STRING := "LINE ONE OF TEST DATA FILE";
LINE2 : CONSTANT STRING := "LINE TWO";
LINE3 : CONSTANT STRING := "LINE THREE";
CN, LN : POSITIVE_COUNT;
CH : CHARACTER;
ST: STRING (1 .. 5);
ORIGINAL_LINE_LENGTH : COUNT;
BEGIN
-- CREATE AND INITIALIZE TEST DATA FILE
BEGIN
CREATE (FILE1, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON TEXT CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED ON TEXT " &
"CREATE WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED ON " &
"TEXT CREATE");
RAISE INCOMPLETE;
END;
ORIGINAL_LINE_LENGTH := LINE_LENGTH;
SET_LINE_LENGTH (FILE1, LINE1'LENGTH);
PUT (FILE1, LINE1);
SET_LINE_LENGTH (FILE1, LINE2'LENGTH);
PUT (FILE1, LINE2);
NEW_LINE (FILE1, 2);
NEW_PAGE (FILE1);
SET_LINE_LENGTH (FILE1, LINE3'LENGTH);
PUT (FILE1, LINE3);
CLOSE (FILE1);
-- BEGIN TEST
BEGIN
OPEN (FILE1, IN_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON TEXT OPEN " &
"WITH IN_FILE MODE");
RAISE INCOMPLETE;
END;
IF COL (FILE1) /= 1 THEN
FAILED ("COLUMN NUMBER NOT INITIALLY ONE");
END IF;
IF LINE (FILE1) /= 1 THEN
FAILED ("LINE NUMBER NOT INITIALLY ONE");
END IF;
IF PAGE (FILE1) /= 1 THEN
FAILED ("PAGE NUMBER NOT INITIALLY ONE");
END IF;
-- TEST COLUMN NUMBER FOR CHARACTER
GET (FILE1, CH);
IF CH /= 'L' THEN
FAILED ("CHARACTER NOT EQUAL TO L - 1");
END IF;
CN := COL (FILE1);
IF CN /= 2 THEN
FAILED ("COLUMN NUMBER NOT SET CORRECTLY " &
"- GET CHARACTER. COL NUMBER IS" &
COUNT'IMAGE(CN));
END IF;
-- TEST COLUMN NUMBER FOR STRING
GET (FILE1, ST);
CN := COL (FILE1);
IF CN /= 7 THEN
FAILED ("COLUMN NUMBER NOT SET CORRECTLY " &
"- GET STRING. COL NUMBER IS" &
COUNT'IMAGE(CN));
END IF;
-- POSITION CURRENT INDEX TO END OF LINE
WHILE NOT END_OF_LINE (FILE1) LOOP
GET (FILE1, CH);
END LOOP;
IF CH /= 'E' THEN
FAILED ("CHARACTER NOT EQUAL TO E");
END IF;
-- TEST LINE NUMBER FOR CHARACTER
GET(FILE1, CH);
IF CH /= 'L' THEN
FAILED ("CHARACTER NOT EQUAL TO L - 2");
END IF;
LN := LINE (FILE1);
IF LN /= 2 THEN
FAILED ("LINE NUMBER NOT SET CORRECTLY " &
"- GET CHARACTER. LINE NUMBER IS" &
COUNT'IMAGE(LN));
END IF;
IF PAGE (FILE1) /= POSITIVE_COUNT(IDENT_INT(1)) THEN
FAILED ("PAGE NUMBER NOT CORRECT - 1. PAGE IS" &
COUNT'IMAGE(PAGE(FILE1)));
END IF;
-- TEST LINE NUMBER FOR STRING
WHILE NOT END_OF_LINE (FILE1) LOOP
GET (FILE1, CH);
END LOOP;
GET (FILE1, ST);
IF ST /= "LINE " THEN
FAILED ("INCORRECT VALUE READ - ST");
END IF;
LN := LINE (FILE1);
CN := COL (FILE1);
IF CN /= 6 THEN
FAILED ("COLUMN NUMBER NOT SET CORRECTLY " &
"- GET STRING. COL NUMBER IS" &
COUNT'IMAGE(CN));
END IF;
IF LN /= 1 THEN
FAILED ("LINE NUMBER NOT SET CORRECTLY " &
"- GET STRING. LINE NUMBER IS" &
COUNT'IMAGE(LN));
END IF;
IF PAGE (FILE1) /= POSITIVE_COUNT(IDENT_INT(2)) THEN
FAILED ("PAGE NUMBER NOT CORRECT - 2. PAGE IS" &
COUNT'IMAGE(PAGE(FILE1)));
END IF;
BEGIN
DELETE (FILE1);
EXCEPTION
WHEN USE_ERROR =>
NULL;
END;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE3602B;
|
package body Benchmark_Containers is
type A is abstract tagged null record;
type B is new A with null record;
type B_Access is access B;
procedure Test_Indefinite (N : Long; File_Name : String) is
package Vector is new Ada.Containers.Indefinite_Vectors (Positive, B_Access);
C : Vector.Vector;
begin
for I in 1 .. N loop
C.Append (new B);
end loop;
end Test_Indefinite;
procedure Test_Non_Indefinite (N : Long; File_Name : String) is
package Vector is new Ada.Containers.Vectors (Positive, B_Access);
C : Vector.Vector;
begin
for I in 1 .. N loop
C.Append (new B);
end loop;
end Test_Non_Indefinite;
end Benchmark_Containers;
|
with STM32_SVD; use STM32_SVD;
with STM32_SVD.SCB; use STM32_SVD.SCB;
with System.Machine_Code; use System.Machine_Code;
package body STM32GD is
procedure Wait_For_Interrupt is
begin
Asm ("WFI", Volatile => True);
end Wait_For_Interrupt;
procedure Clear_Event is
begin
Asm ("SEV", Volatile => True);
Asm ("WFE", Volatile => True);
end Clear_Event;
procedure Wait_For_Event is
begin
SCB_Periph.SCR.SEVEONPEND := 1;
Asm ("WFE", Volatile => True);
end Wait_For_Event;
procedure Reset is
begin
null;
end Reset;
function UID return UID_Type is
UID_F3 : aliased UID_Type with Import, Address => System'To_Address (16#1FFFF7E8#);
UID_Fx : aliased UID_Type with Import, Address => System'To_Address (16#1FFFF7AC#);
UID_Lx : aliased UID_Type with Import, Address => System'To_Address (16#1FF80050#);
begin
if SCB_Periph.CPUID.PartNo = 16#C23# then
return UID_F3;
elsif SCB_Periph.CPUID.PartNo = 16#C60# then
return UID_Lx;
else
return UID_Fx;
end if;
end UID;
end STM32GD;
|
-- C47009B.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:
-- WHEN THE TYPE MARK IN A QUALIFIED EXPRESSION DENOTES AN ACCESS
-- TYPE, CHECK THAT CONSTRAINT_ERROR IS NOT RAISED WHEN THE VALUE
-- OF THE OPERAND IS NULL.
-- HISTORY:
-- RJW 07/23/86 CREATED ORIGINAL TEST.
-- BCB 08/18/87 CHANGED HEADER TO STANDARD HEADER FORMAT. CHANGED
-- CONSTRAINTS OF B SUBTYPES TO VALUES WHICH ARE
-- CLOSER TO THE VALUES OF THE A SUBTYPES. INDENTED
-- THE EXCEPTION STATEMENTS IN SUBTEST 11.
WITH REPORT; USE REPORT;
PROCEDURE C47009B IS
BEGIN
TEST( "C47009B", "WHEN THE TYPE MARK IN A QUALIFIED " &
"EXPRESSION DENOTES AN ACCESS TYPE, " &
"CHECK THAT CONSTRAINT_ERROR IS NOT " &
"RAISED WHEN THE VALUE OF THE OPERAND IS NULL" );
DECLARE
TYPE ACC1 IS ACCESS BOOLEAN;
A : ACC1;
BEGIN
A := ACC1'(NULL);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR TYPE ACC1" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR TYPE ACC1" );
END;
DECLARE
TYPE ACC2 IS ACCESS INTEGER;
A : ACC2;
BEGIN
A := ACC2'(NULL);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR TYPE ACC2" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR TYPE ACC2" );
END;
DECLARE
TYPE CHAR IS ('A', 'B');
TYPE ACC3 IS ACCESS CHAR;
A : ACC3;
BEGIN
A := ACC3'(NULL);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR TYPE ACC3" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR TYPE ACC3" );
END;
DECLARE
TYPE FLOAT1 IS DIGITS 5 RANGE -1.0 .. 1.0;
TYPE ACC4 IS ACCESS FLOAT1;
A : ACC4;
BEGIN
A := ACC4'(NULL);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR TYPE ACC4" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR TYPE ACC4" );
END;
DECLARE
TYPE FIXED IS DELTA 0.5 RANGE -1.0 .. 1.0;
TYPE ACC5 IS ACCESS FIXED;
A : ACC5;
BEGIN
A := ACC5'(NULL);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR TYPE ACC5" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR TYPE ACC5" );
END;
DECLARE
TYPE ARR IS ARRAY (NATURAL RANGE <>) OF INTEGER;
TYPE ACC6 IS ACCESS ARR;
SUBTYPE ACC6A IS ACC6 (IDENT_INT (1) .. IDENT_INT (5));
SUBTYPE ACC6B IS ACC6 (IDENT_INT (2) .. IDENT_INT (10));
A : ACC6A;
B : ACC6B;
BEGIN
A := ACC6A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF " &
"TYPE ACC6" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC6" );
END;
DECLARE
TYPE ARR IS ARRAY (NATURAL RANGE <>, NATURAL RANGE <>)
OF INTEGER;
TYPE ACC7 IS ACCESS ARR;
SUBTYPE ACC7A IS ACC7 (IDENT_INT (1) .. IDENT_INT (5),
IDENT_INT (1) .. IDENT_INT (1));
SUBTYPE ACC7B IS ACC7 (IDENT_INT (1) .. IDENT_INT (15),
IDENT_INT (1) .. IDENT_INT (10));
A : ACC7A;
B : ACC7B;
BEGIN
A := ACC7A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF " &
"TYPE ACC7" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC7" );
END;
DECLARE
TYPE REC (D : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE ACC8 IS ACCESS REC;
SUBTYPE ACC8A IS ACC8 (IDENT_INT (5));
SUBTYPE ACC8B IS ACC8 (IDENT_INT (6));
A : ACC8A;
B : ACC8B;
BEGIN
A := ACC8A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF " &
"TYPE ACC8" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC8" );
END;
DECLARE
TYPE REC (D1,D2 : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE ACC9 IS ACCESS REC;
SUBTYPE ACC9A IS ACC9 (IDENT_INT (4), IDENT_INT (5));
SUBTYPE ACC9B IS ACC9 (IDENT_INT (5), IDENT_INT (4));
A : ACC9A;
B : ACC9B;
BEGIN
A := ACC9A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF " &
"TYPE ACC9" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC9" );
END;
DECLARE
PACKAGE PKG IS
TYPE REC (D : INTEGER) IS PRIVATE;
PRIVATE
TYPE REC (D : INTEGER) IS
RECORD
NULL;
END RECORD;
END PKG;
USE PKG;
TYPE ACC10 IS ACCESS REC;
SUBTYPE ACC10A IS ACC10 (IDENT_INT (10));
SUBTYPE ACC10B IS ACC10 (IDENT_INT (9));
A : ACC10A;
B : ACC10B;
BEGIN
A := ACC10A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF " &
"TYPE ACC10" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC10" );
END;
DECLARE
PACKAGE PKG1 IS
TYPE REC (D : INTEGER) IS LIMITED PRIVATE;
PRIVATE
TYPE REC (D : INTEGER) IS
RECORD
NULL;
END RECORD;
END PKG1;
PACKAGE PKG2 IS END PKG2;
PACKAGE BODY PKG2 IS
USE PKG1;
TYPE ACC11 IS ACCESS REC;
SUBTYPE ACC11A IS ACC11 (IDENT_INT (11));
SUBTYPE ACC11B IS ACC11 (IDENT_INT (12));
A : ACC11A;
B : ACC11B;
BEGIN
A := ACC11A'(B);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
FAILED ( "CONSTRAINT_ERROR RAISED FOR SUBTYPES OF" &
" TYPE ACC11" );
WHEN OTHERS =>
FAILED ( "OTHER EXCEPTION RAISED FOR SUBTYPES OF " &
"TYPE ACC11" );
END PKG2;
BEGIN
NULL;
END;
RESULT;
END C47009B;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $:
-- Purpose:
-- Trivial implementation of ASIS Ada_Environments.Containers
with Asis.Compilation_Units;
package body Asis.Ada_Environments.Containers is
package C renames Asis.Compilation_Units;
-----------------------------
-- Compilation_Unit_Bodies --
-----------------------------
function Compilation_Unit_Bodies
(The_Container : in Container)
return Asis.Compilation_Unit_List
is
begin
return C.Compilation_Unit_Bodies (The_Container.The_Context);
end Compilation_Unit_Bodies;
-----------------------
-- Compilation_Units --
-----------------------
function Compilation_Units
(The_Container : in Container)
return Asis.Compilation_Unit_List
is
begin
return C.Compilation_Units (The_Container.The_Context);
end Compilation_Units;
-------------------------
-- Defining_Containers --
-------------------------
function Defining_Containers
(The_Context : in Asis.Context)
return Container_List
is
begin
return (1 => (The_Context => The_Context));
end Defining_Containers;
-----------------------
-- Enclosing_Context --
-----------------------
function Enclosing_Context
(The_Container : in Container)
return Asis.Context
is
begin
return The_Container.The_Context;
end Enclosing_Context;
--------------
-- Is_Equal --
--------------
function Is_Equal
(Left : in Container;
Right : in Container)
return Boolean
is
begin
return Is_Identical (Left, Right);
end Is_Equal;
------------------
-- Is_Identical --
------------------
function Is_Identical
(Left : in Container;
Right : in Container)
return Boolean
is
begin
return Is_Equal (Left.The_Context, Right.The_Context);
end Is_Identical;
-------------------------------
-- Library_Unit_Declarations --
-------------------------------
function Library_Unit_Declarations
(The_Container : in Container)
return Asis.Compilation_Unit_List
is
begin
return C.Library_Unit_Declarations (The_Container.The_Context);
end Library_Unit_Declarations;
----------
-- Name --
----------
function Name (The_Container : in Container) return Wide_String is
begin
return Name (The_Container.The_Context);
end Name;
end Asis.Ada_Environments.Containers;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- 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 Maxim Reznik, 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 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.
------------------------------------------------------------------------------
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Assertions;
package body Apsepp.Test_Node_Class.Abstract_Simu_Case is
----------------------------------------------------------------------------
protected body Data_Locker is
-----------------------------------------------------
function Locked return Boolean
is (Locked_Flag);
-----------------------------------------------------
entry Set (T : Tag; D : Test_Routine_Destiny) when not Locked is
begin
T_Val := T;
D_Val := D;
Locked_Flag := True;
end Set;
-----------------------------------------------------
function T return Tag is
begin
Ada.Assertions.Assert (Locked); -- Precondition.
return T_Val;
end T;
-----------------------------------------------------
function D return Test_Routine_Destiny is
begin
Ada.Assertions.Assert (Locked); -- Precondition.
return D_Val;
end D;
-----------------------------------------------------
procedure Reset is
begin
Ada.Assertions.Assert (Locked); -- Precondition.
Locked_Flag := False;
end Reset;
-----------------------------------------------------
end Data_Locker;
----------------------------------------------------------------------------
procedure Simu_Test_Routine is
Simu_Test_Routine_Other_Error : exception;
D : constant Test_Routine_Destiny := Data_Locker.D;
T : constant Tag := Data_Locker.T;
Handled : Boolean := False;
begin
Data_Locker.Reset;
for K in 1 .. D.Successful_Test_Assert_Count loop
Assert (T, True);
end loop;
case D.Kind is
when No_Failure =>
null;
when Test_Assertion_Failure =>
Assert (T, False, "Simulated test assertion failure");
when Handled_Test_Failure =>
Handled := True;
Assert (T, False,
"Simulated test assertion failure (handled)");
when Contract_Failure =>
raise Ada.Assertions.Assertion_Error
with "Simulated contract failure";
when Other_Failure =>
raise Simu_Test_Routine_Other_Error
with "Simulated unexpected test routine failure";
when Access_Failure =>
null; -- Impossible case, has already
-- caused error and test routine
-- abortion in Routine.
when Setup_Failure =>
null; -- Impossible case, has already
-- caused error and test routine
-- abortion in Setup_Routine.
end case;
exception
when others =>
if not Handled then
raise;
end if;
end Simu_Test_Routine;
----------------------------------------------------------------------------
overriding
function Routine (Obj : Simu_Test_Case;
K : Test_Routine_Index) return Test_Routine is
Simu_Test_Routine_Access_Error : exception;
D : constant Test_Routine_Destiny
:= Simu_Test_Case'Class (Obj).Story (K);
begin
case D.Kind is
when No_Failure
| Setup_Failure
| Test_Assertion_Failure
| Handled_Test_Failure
| Contract_Failure
| Other_Failure =>
null;
when Access_Failure =>
raise Simu_Test_Routine_Access_Error
with "Simulated test routine access failure";
end case;
Data_Locker.Set (Simu_Test_Case'Class (Obj)'Tag, D);
return Simu_Test_Routine'Access;
end Routine;
----------------------------------------------------------------------------
overriding
procedure Setup_Routine (Obj : Simu_Test_Case) is
Simu_Test_Routine_Setup_Error : exception;
D : constant Test_Routine_Destiny := Data_Locker.D;
pragma Unreferenced (Obj);
begin
case D.Kind is
when No_Failure
| Test_Assertion_Failure
| Handled_Test_Failure
| Contract_Failure
| Other_Failure =>
null;
when Setup_Failure =>
Data_Locker.Reset;
raise Simu_Test_Routine_Setup_Error
with "Simulated test routine access failure";
when Access_Failure =>
null; -- Impossible case, has already caused
-- error and test routine abortion in
-- Routine.
end case;
end Setup_Routine;
----------------------------------------------------------------------------
end Apsepp.Test_Node_Class.Abstract_Simu_Case;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Atom_Ref_Constructors;
with Natools.S_Expressions.Interpreter_Loop;
with Natools.Static_Maps.Web.List_Templates;
package body Natools.Web.List_Templates is
procedure Execute_Atom
(State : in out Parameters;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom);
procedure Execute_Expression
(State : in out Parameters;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class);
procedure Set_Or_Reset
(Ref : in out S_Expressions.Atom_Refs.Immutable_Reference;
Expression : in out S_Expressions.Lockable.Descriptor'Class);
-- if Expression has an atom, copy it into Ref, otherwise reset Ref
---------------------------
-- Parameter Interpreter --
---------------------------
procedure Execute_Expression
(State : in out Parameters;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom;
Arguments : in out S_Expressions.Lockable.Descriptor'Class)
is
pragma Unreferenced (Context);
package Commands renames Natools.Static_Maps.Web.List_Templates;
use type S_Expressions.Events.Event;
begin
case Commands.To_Command (S_Expressions.To_String (Name)) is
when Commands.Unknown_Command =>
null;
when Commands.Backward =>
State.Going := Backward;
when Commands.Ellipses_Are_Items =>
State.Ellipses_Are_Items := True;
when Commands.Ellipses_Are_Not_Items =>
State.Ellipses_Are_Items := False;
when Commands.Ellipsis_Prefix =>
Set_Or_Reset (State.Ellipsis_Prefix, Arguments);
when Commands.Ellipsis_Suffix =>
Set_Or_Reset (State.Ellipsis_Suffix, Arguments);
when Commands.Forward =>
State.Going := Forward;
when Commands.If_Empty =>
Set_Or_Reset (State.If_Empty, Arguments);
when Commands.Length_Limit =>
if Arguments.Current_Event = S_Expressions.Events.Add_Atom then
begin
State.Limit := Count'Value (S_Expressions.To_String
(Arguments.Current_Atom));
exception
when Constraint_Error =>
State.Limit := 0;
end;
end if;
when Commands.Prefix =>
Set_Or_Reset (State.Prefix, Arguments);
when Commands.Show_Beginning =>
State.Shown_End := Beginning;
when Commands.Show_Ending =>
State.Shown_End := Ending;
when Commands.Suffix =>
Set_Or_Reset (State.Suffix, Arguments);
when Commands.Separator =>
Set_Or_Reset (State.Separator, Arguments);
when Commands.Template =>
State.Template := S_Expressions.Caches.Move (Arguments);
end case;
end Execute_Expression;
procedure Execute_Atom
(State : in out Parameters;
Context : in Meaningless_Type;
Name : in S_Expressions.Atom)
is
pragma Unreferenced (Context);
package Commands renames Natools.Static_Maps.Web.List_Templates;
begin
case Commands.To_Command (S_Expressions.To_String (Name)) is
when Commands.Unknown_Command =>
null;
when Commands.Backward =>
State.Going := Backward;
when Commands.Ellipses_Are_Items =>
State.Ellipses_Are_Items := True;
when Commands.Ellipses_Are_Not_Items =>
State.Ellipses_Are_Items := False;
when Commands.Ellipsis_Prefix =>
State.Ellipsis_Prefix.Reset;
when Commands.Ellipsis_Suffix =>
State.Ellipsis_Suffix.Reset;
when Commands.Forward =>
State.Going := Forward;
when Commands.If_Empty =>
State.If_Empty.Reset;
when Commands.Length_Limit =>
State.Limit := 0;
when Commands.Prefix =>
State.Prefix.Reset;
when Commands.Show_Beginning =>
State.Shown_End := Beginning;
when Commands.Show_Ending =>
State.Shown_End := Ending;
when Commands.Separator =>
State.Separator.Reset;
when Commands.Suffix =>
State.Suffix.Reset;
when Commands.Template =>
null;
end case;
end Execute_Atom;
procedure Read is new Natools.S_Expressions.Interpreter_Loop
(Parameters, Meaningless_Type, Execute_Expression, Execute_Atom);
procedure Read_Parameters
(Object : in out Parameters;
Expression : in out S_Expressions.Lockable.Descriptor'Class) is
begin
Read (Expression, Object, Meaningless_Value);
end Read_Parameters;
function Read_Parameters
(Expression : in out S_Expressions.Lockable.Descriptor'Class)
return Parameters
is
Result : Parameters;
begin
Read_Parameters (Result, Expression);
return Result;
end Read_Parameters;
procedure Set_Or_Reset
(Ref : in out S_Expressions.Atom_Refs.Immutable_Reference;
Expression : in out S_Expressions.Lockable.Descriptor'Class)
is
package Constructors renames Natools.S_Expressions.Atom_Ref_Constructors;
begin
case Expression.Current_Event is
when S_Expressions.Events.Add_Atom =>
Ref := Constructors.Create (Expression.Current_Atom);
when S_Expressions.Events.Open_List
| S_Expressions.Events.Close_List
| S_Expressions.Events.End_Of_Input
| S_Expressions.Events.Error
=>
Ref.Reset;
end case;
end Set_Or_Reset;
-----------------------
-- Generic Rendering --
-----------------------
procedure Render
(Exchange : in out Sites.Exchange;
Iterator : in Iterators.Reversible_Iterator'Class;
Param : in Parameters)
is
procedure Ending_Showing_Loop
(Position : in Cursor;
Remaining_Depth : in Count);
procedure Loop_Body
(Position : in Cursor; Exit_Loop : out Boolean);
Rendered : Count := 0;
Extra_Items : constant Count
:= (if Param.Ellipses_Are_Items
then (if Param.Ellipsis_Prefix.Is_Empty then 0 else 1)
+ (if Param.Ellipsis_Suffix.Is_Empty then 0 else 1)
else 0);
Is_First : Boolean := True;
procedure Ending_Showing_Loop
(Position : in Cursor;
Remaining_Depth : in Count) is
begin
if Remaining_Depth > 1 then
case Param.Going is
when Backward =>
Ending_Showing_Loop
(Iterator.Next (Position), Remaining_Depth - 1);
when Forward =>
Ending_Showing_Loop
(Iterator.Previous (Position), Remaining_Depth - 1);
end case;
if not Param.Separator.Is_Empty then
Exchange.Append (Param.Separator.Query);
end if;
end if;
declare
Template_Copy : S_Expressions.Caches.Cursor := Param.Template;
begin
Render (Exchange, Position, Template_Copy);
end;
end Ending_Showing_Loop;
procedure Loop_Body
(Position : in Cursor; Exit_Loop : out Boolean) is
begin
if Param.Limit > 0 and then Rendered >= Param.Limit then
if not Param.Ellipsis_Suffix.Is_Empty then
Exchange.Append (Param.Ellipsis_Suffix.Query);
end if;
Exit_Loop := True;
return;
end if;
Exit_Loop := False;
if not Is_First and then not Param.Separator.Is_Empty then
Exchange.Append (Param.Separator.Query);
end if;
declare
Template_Copy : S_Expressions.Caches.Cursor := Param.Template;
begin
Render (Exchange, Position, Template_Copy);
end;
Rendered := Rendered + 1;
Is_First := False;
end Loop_Body;
Exit_Loop : Boolean;
Seen : Count := 0;
begin
if Param.Shown_End = Ending and then Param.Limit > 0 then
if Seen = 0 then
for I in Iterator loop
Seen := Seen + 1;
exit when Seen > Param.Limit;
end loop;
if Seen = 0 then
if not Param.If_Empty.Is_Empty then
Exchange.Append (Param.If_Empty.Query);
end if;
return;
end if;
end if;
if Seen > Param.Limit then
if not Param.Prefix.Is_Empty then
Exchange.Append (Param.Prefix.Query);
end if;
if not Param.Ellipsis_Prefix.Is_Empty then
Exchange.Append (Param.Ellipsis_Prefix.Query);
end if;
case Param.Going is
when Backward =>
Ending_Showing_Loop
(Iterator.First, Param.Limit - Extra_Items);
when Forward =>
Ending_Showing_Loop
(Iterator.Last, Param.Limit - Extra_Items);
end case;
if not Param.Ellipsis_Suffix.Is_Empty then
Exchange.Append (Param.Ellipsis_Suffix.Query);
end if;
if not Param.Suffix.Is_Empty then
Exchange.Append (Param.Suffix.Query);
end if;
return;
end if;
end if;
if Param.Limit > 0
and then (not Param.Ellipsis_Prefix.Is_Empty or else Extra_Items > 0)
then
if Seen = 0 then
for I in Iterator loop
Seen := Seen + 1;
exit when Seen > Param.Limit;
end loop;
if Seen = 0 then
if not Param.If_Empty.Is_Empty then
Exchange.Append (Param.If_Empty.Query);
end if;
return;
end if;
end if;
if not Param.Prefix.Is_Empty then
Exchange.Append (Param.Prefix.Query);
end if;
if Seen > Param.Limit then
if not Param.Ellipsis_Prefix.Is_Empty then
Exchange.Append (Param.Ellipsis_Prefix.Query);
end if;
Rendered := Extra_Items;
end if;
elsif not Param.Prefix.Is_Empty then
if Seen = 0 then
for I in Iterator loop
Seen := Seen + 1;
exit;
end loop;
end if;
if Seen = 0 then
if not Param.If_Empty.Is_Empty then
Exchange.Append (Param.If_Empty.Query);
end if;
return;
else
Exchange.Append (Param.Prefix.Query);
end if;
end if;
case Param.Going is
when Forward =>
for Position in Iterator loop
Loop_Body (Position, Exit_Loop);
exit when Exit_Loop;
end loop;
when Backward =>
for Position in reverse Iterator loop
Loop_Body (Position, Exit_Loop);
exit when Exit_Loop;
end loop;
end case;
if Rendered = 0 then
if not Param.If_Empty.Is_Empty then
Exchange.Append (Param.If_Empty.Query);
end if;
else
if not Param.Suffix.Is_Empty then
Exchange.Append (Param.Suffix.Query);
end if;
end if;
end Render;
end Natools.Web.List_Templates;
|
pragma License (Unrestricted);
private with System.Finalization_Root;
package Ada.Finalization is
pragma Pure;
type Controlled is abstract tagged private;
pragma Preelaborable_Initialization (Controlled);
procedure Initialize (Object : in out Controlled) is null;
procedure Adjust (Object : in out Controlled) is null;
procedure Finalize (Object : in out Controlled) is null;
type Limited_Controlled is abstract tagged limited private;
pragma Preelaborable_Initialization (Limited_Controlled);
procedure Initialize (Object : in out Limited_Controlled) is null;
procedure Finalize (Object : in out Limited_Controlled) is null;
private
type Controlled is
abstract new System.Finalization_Root.Root_Controlled with null record;
type Limited_Controlled is
abstract new System.Finalization_Root.Root_Controlled with null record;
end Ada.Finalization;
|
pragma License (Unrestricted);
-- extended unit
with Ada.Strings.Generic_Functions;
package Ada.Strings.Wide_Wide_Functions is
new Generic_Functions (
Character_Type => Wide_Wide_Character,
String_Type => Wide_Wide_String,
Space => Wide_Wide_Space);
pragma Preelaborate (Ada.Strings.Wide_Wide_Functions);
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Interfaces.C;
package GL is
pragma Preelaborate;
package C renames Interfaces.C;
-----------------------------------------------------------------------------
-- Basics --
-----------------------------------------------------------------------------
-- this is an OpenGLAda-specific procedure that must be called once at
-- startup and loads all function pointers for post-1.1 OpenGL functionality.
-- it is idempotent (i.e. can be called multiple times without further
-- effect).
procedure Init;
procedure Flush;
procedure Finish;
-- index types for vectors and matrices
type Index_Homogeneous is (X, Y, Z, W);
subtype Index_3D is Index_Homogeneous range X .. Z;
subtype Index_2D is Index_Homogeneous range X .. Y;
-- raised when a function that is not available for the current context
-- is called.
Feature_Not_Supported_Exception : exception;
-- raised when OpenGLAda does not support a certain OpenGL feature
-- (either because it's too new and has not yet been wrapped, or because
-- it's so deprecated that you shouldn't use it anyway)
Not_Implemented_Exception : exception;
private
-----------------------------------------------------------------------------
-- Internal functions --
-----------------------------------------------------------------------------
procedure Raise_Exception_On_OpenGL_Error;
pragma Inline (Raise_Exception_On_OpenGL_Error);
end GL;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . T E X T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Asis; use Asis;
with Asis.Compilation_Units; use Asis.Compilation_Units;
with Asis.Elements; use Asis.Elements;
with Asis.Errors; use Asis.Errors;
with Asis.Exceptions; use Asis.Exceptions;
with Asis.Set_Get; use Asis.Set_Get;
with Asis.Text.Set_Get; use Asis.Text.Set_Get;
with A4G.A_Debug; use A4G.A_Debug;
with A4G.A_Sinput; use A4G.A_Sinput;
with A4G.Contt; use A4G.Contt;
with A4G.Contt.TT; use A4G.Contt.TT;
with A4G.Contt.UT; use A4G.Contt.UT;
with A4G.Span_Beginning; use A4G.Span_Beginning;
with A4G.Span_End; use A4G.Span_End;
with A4G.Vcheck; use A4G.Vcheck;
with Namet; use Namet;
with Output; use Output;
with Sinput; use Sinput;
package body Asis.Text is
-------------------
-- Comment_Image --
-------------------
function Comment_Image
(The_Line : Asis.Text.Line)
return Wide_String
is
begin
Check_Validity (The_Line, "Asis.Text.Comment_Image");
if The_Line.Length = 0 then
-- just a small optimization
return "";
end if;
declare
The_Line_Image : Wide_String := Line_Image (The_Line);
Comment_Pos : constant Source_Ptr := Comment_Beginning
(Text_Buffer (To_String (The_Line_Image)));
begin
if Comment_Pos = No_Location then
-- no comment in this string
return "";
else
-- we have to pad the beginning (that is, non-comment part)
-- of the line image by white spaces, making difference between
-- HT and other symbols:
for I in The_Line_Image'First .. Natural (Comment_Pos) - 1 loop
if To_Character (The_Line_Image (I)) /= ASCII.HT then
The_Line_Image (I) := ' ';
end if;
end loop;
return The_Line_Image;
end if;
end;
exception
when ASIS_Inappropriate_Line =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => "Asis.Text.Comment_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Comment_Image",
Arg_Line => The_Line,
Ex => Ex);
end Comment_Image;
----------------------
-- Compilation_Span --
----------------------
function Compilation_Span
(Element : Asis.Element)
return Asis.Text.Span
is
Result_Span : Asis.Text.Span := Asis.Text.Nil_Span;
S_P : Source_Ptr;
S_P_Last : Source_Ptr;
SFI : Source_File_Index;
Src : Source_Buffer_Ptr;
Last_Line : Physical_Line_Number;
begin
Check_Validity (Element, "Asis.Text.Compilation_Span");
-- In case of GNAT compilations are source files, so there is no need
-- to compute Result_Span.First_Line and Result_Span.First_Column -
-- the correct values are (1, 1) , and they come from Nil_Span
S_P := Get_Location (Element);
-- this makes all the rest "tree-swapping-safe"
if S_P > Standard_Location then
SFI := Get_Source_File_Index (S_P);
Src := Source_Text (SFI);
Last_Line := Last_Source_Line (SFI);
Result_Span.Last_Line := Line_Number (Last_Line);
S_P := Line_Start (Last_Line, SFI);
S_P_Last := S_P;
while not (S_P_Last = Source_Last (SFI) or else
Src (S_P_Last) = ASCII.LF or else
Src (S_P_Last) = ASCII.CR)
loop
S_P_Last := S_P_Last + 1;
end loop;
Result_Span.Last_Column := Character_Position (S_P_Last - S_P);
end if;
return Result_Span;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Compilation_Span",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Compilation_Span",
Arg_Element => Element,
Ex => Ex);
end Compilation_Span;
---------------------------
-- Compilation_Unit_Span --
---------------------------
function Compilation_Unit_Span
(Element : Asis.Element)
return Asis.Text.Span
is
Result_Span : Asis.Text.Span := Asis.Text.Nil_Span;
CU : Asis.Compilation_Unit;
First_El : Asis.Element;
Unit : Asis.Element;
No_Cont_Clause : Boolean := True;
Span_Start : Source_Ptr;
Span_End : Source_Ptr;
begin
Check_Validity (Element, "Asis.Text.Compilation_Unit_Span");
-- First, check that the argument Element is not from the predefined
-- Standard package.
Span_Start := Get_Location (Element);
-- this makes all the rest "tree-swapping-safe"
if Span_Start > Standard_Location then
CU := Enclosing_Compilation_Unit (Element);
Unit := Unit_Declaration (CU);
declare
Cont_Cl_Elms : constant Asis.Context_Clause_List :=
Context_Clause_Elements
(Compilation_Unit => CU,
Include_Pragmas => True);
begin
if Is_Nil (Cont_Cl_Elms) then
First_El := Unit;
else
First_El := Cont_Cl_Elms (Cont_Cl_Elms'First);
No_Cont_Clause := False;
end if;
end;
Span_Start := Set_Image_Beginning (First_El);
if No_Cont_Clause then
-- For private unit declarations and for subunits we have to take
-- into account syntax elements which are not a part of the
-- corresponding unit declaration element
case Unit_Class (CU) is
when A_Private_Declaration =>
-- Taking into account leading 'private' keyword
Span_Start := Search_Prev_Word_Start (Span_Start);
when A_Separate_Body =>
-- Taking into account 'separate (...)"
Span_Start := Search_Left_Parenthesis (Span_Start);
Span_Start := Search_Prev_Word_Start (Span_Start);
when others =>
null;
end case;
end if;
Span_End := Set_Image_End (Unit);
Result_Span := Source_Locations_To_Span (Span_Start, Span_End);
end if;
return Result_Span;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Compilation_Unit_Span",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Compilation_Unit_Span",
Arg_Element => Element,
Ex => Ex);
end Compilation_Unit_Span;
-----------------
-- Debug_Image --
-----------------
function Debug_Image
(The_Line : Asis.Text.Line)
return Wide_String
is
LT : String renames ASIS_Line_Terminator;
S : constant Source_Ptr := Line_Location (The_Line);
-- this makes the rest "tree-swapping-safe"
Sindex : constant Source_File_Index := Get_Source_File_Index (S);
F_Name : constant File_Name_Type := File_Name (Sindex);
T : constant Tree_Id := The_Line.Enclosing_Tree;
C : constant Context_Id := The_Line.Enclosing_Context;
Tree_Name : String_Ptr;
begin
Check_Validity (The_Line, "Asis.Text.Debug_Image");
if Present (T) then
Get_Name_String (C, T);
Tree_Name :=
new String'(A_Name_Buffer (1 .. A_Name_Len) &
" (Tree_Id =" & Tree_Id'Image (T) & ")");
else
Tree_Name := new String'(" <nil tree>");
end if;
Get_Name_String (F_Name);
return To_Wide_String
("Debug image for Asis.Text.Line:"
& LT
& " obtained from file " & Name_Buffer (1 .. Name_Len)
& LT
& " Absolute (relative) location in source file :"
& Source_Ptr'Image (S)
& " ("
& Source_Ptr'Image (The_Line.Rel_Sloc)
& ')'
& LT
& " Line :"
& Physical_Line_Number'Image (Get_Physical_Line_Number (S))
& LT
& " Column:"
& Source_Ptr'Image (A_Get_Column_Number (S))
& LT
& " Number of characters in line:"
& Asis.Text.Character_Position'Image (Line_Length (The_Line))
& LT
& " obtained from the tree "
& Tree_Name.all);
exception
when ASIS_Inappropriate_Line =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => "Asis.Text.Debug_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Debug_Image",
Arg_Line => The_Line,
Ex => Ex);
end Debug_Image;
---------------------
-- Delimiter_Image --
---------------------
function Delimiter_Image return Wide_String is
begin
return Asis_Wide_Line_Terminator;
end Delimiter_Image;
-------------------
-- Element_Image --
-------------------
function Element_Image
(Element : Asis.Element)
return Wide_String
is
begin
Check_Validity (Element, "Asis.Text.Element_Image");
if not Is_Text_Available (Element) then
return "";
end if;
declare
LList : constant Asis.Text.Line_List := Lines (Element);
-- We create the Element Image from Lines containing the Element
Spaces : Natural;
-- The number of characters in the first line of the Image, which
-- should be padded by white spaces
Numb : Natural;
-- Yere we collect the whole number of characters needed in the
-- string representing the result Element image. Note that we are
-- counting in wide characters
begin
Spaces := Natural (Element_Span (Element).First_Column) - 1;
Numb := Asis.ASIS_Natural (Spaces) +
Asis.ASIS_Natural (LList'Last - LList'First) *
Asis.ASIS_Natural (Asis_Wide_Line_Terminator'Length);
for I in LList'First .. LList'Last loop
Numb := Numb + Natural (Line_Length (LList (I)));
end loop;
declare
Result : Wide_String (1 .. Numb);
In_Str : Positive := 1;
begin
-- The image of the first line may contain spaces padding the part
-- of the physal line that precedes the element
Result (In_Str ..
In_Str + Spaces + Line_Length (LList (LList'First)) - 1) :=
Line_Image (LList (LList'First));
In_Str := In_Str + Spaces + Line_Length (LList (LList'First));
-- and now - filling the rest of Result_String
-- by the "proper" Element Image
for Linee in LList'First + 1 .. LList'Last loop
Result (In_Str .. In_Str + ASIS_Line_Terminator'Length - 1)
:= Asis_Wide_Line_Terminator;
In_Str := In_Str + Asis_Wide_Line_Terminator'Length;
Result (In_Str .. In_Str + Line_Length (LList (Linee)) - 1) :=
Line_Image (LList (Linee));
In_Str := In_Str + Line_Length (LList (Linee));
end loop;
return Result;
end;
end;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Element_Image",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis_Text.Element_Image",
Arg_Element => Element,
Ex => Ex);
end Element_Image;
------------------
-- Element_Span --
------------------
-- Element_Span is "tree-swapping-safe"!
function Element_Span (Element : Asis.Element) return Asis.Text.Span is
Sp : Asis.Text.Span := Asis.Text.Nil_Span;
Span_Start : Source_Ptr;
Span_End : Source_Ptr;
begin
Check_Validity (Element, "Asis.Text.Element_Span");
if Debug_Flag_X or else Debug_Mode then
Write_Str ("*** Asis.Text.Element_Span ***");
Write_Eol;
Write_Str ("Element kind is ");
Write_Str (Internal_Element_Kinds'Image (Int_Kind (Element)));
Write_Eol;
end if;
if not Is_Text_Available (Element) then
if Debug_Flag_X or else Debug_Mode then
Write_Str ("!!! Text isn't available !!!");
Write_Eol;
end if;
return Sp;
end if;
-- Set_Image_Beginning is "tree-swapping-safe"
Span_Start := Set_Image_Beginning (Element);
Span_End := Set_Image_End (Element);
Sp := Source_Locations_To_Span (Span_Start, Span_End);
if Debug_Flag_X or else Debug_Mode then
Write_Str ("Returning Asis.Text.Span parameters:");
Write_Eol;
Write_Str (Debug_Image (Sp));
Write_Eol;
end if;
return Sp;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Element_Span",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Element_Span",
Arg_Element => Element,
Ex => Ex);
end Element_Span;
-----------------------
-- First_Line_Number --
-----------------------
function First_Line_Number (Element : Asis.Element) return Line_Number is
Sp : Asis.Text.Span;
begin
Check_Validity (Element, "Asis.Text.First_Line_Number");
if Is_Text_Available (Element) then
Sp := Element_Span (Element);
return Sp.First_Line;
else
return 0;
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.First_Line_Number",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.First_Line_Number",
Arg_Element => Element,
Ex => Ex);
end First_Line_Number;
--------------
-- Is_Equal --
--------------
function Is_Equal
(Left : Asis.Text.Line;
Right : Asis.Text.Line)
return Boolean
is
C_Left : Context_Id;
C_Right : Context_Id;
U_Left : Unit_Id;
U_Right : Unit_Id;
begin
Check_Validity (Left, "Asis.Text.Is_Equal");
Check_Validity (Right, "Asis.Text.Is_Equal");
-- Two lines which are Is_Equal may be obtained from different
-- Context, and they may be based on different trees. But to
-- be Is_Equal, they have to represent the same portion of the
-- source text from the same source file
if Left.Length /= Right.Length or else
Left.Rel_Sloc /= Right.Rel_Sloc
then
return False;
else
-- we use just the same approach as for comparing Elements
C_Left := Left.Enclosing_Context;
U_Left := Left.Enclosing_Unit;
C_Right := Right.Enclosing_Context;
U_Right := Right.Enclosing_Unit;
return Time_Stamp (C_Left, U_Left) = Time_Stamp (C_Right, U_Right);
end if;
exception
when ASIS_Inappropriate_Line =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => "Asis.Text.Is_Equal");
end if;
raise;
when Ex : others =>
-- Note, that in case of failure the very primitive diagnosis will be
-- generated. If the implementation of this query become more
-- sophisticated, we'll probably need two Line parameters for
-- Report_ASIS_Bug procedure
Report_ASIS_Bug
(Query_Name => "Asis.Text.Is_Equal",
Ex => Ex);
end Is_Equal;
------------------
-- Is_Identical --
------------------
function Is_Identical
(Left : Asis.Text.Line;
Right : Asis.Text.Line)
return Boolean
is
begin
Check_Validity (Left, "Asis.Text.Is_Identical");
Check_Validity (Right, "Asis.Text.Is_Identical");
return (Left.Length = Right.Length and then
Left.Rel_Sloc = Right.Rel_Sloc and then
Left.Enclosing_Context = Right.Enclosing_Context and then
Left.Enclosing_Unit = Right.Enclosing_Unit);
end Is_Identical;
------------
-- Is_Nil --
------------
function Is_Nil (Right : Asis.Text.Line) return Boolean is
Result : Boolean;
begin
-- Here we have to simulate the predefined "=" operation for
-- Line as if it is called as 'Right + Nil_Line'
Result := Right.Sloc = No_Location and then
Right.Length = 0 and then
Right.Rel_Sloc = No_Location and then
Right.Enclosing_Unit = Nil_Unit and then
Right.Enclosing_Context = Non_Associated and then
Right.Enclosing_Tree = Nil_Tree and then
Right.Obtained = Nil_ASIS_OS_Time;
return Result;
end Is_Nil;
function Is_Nil (Right : Asis.Text.Line_List) return Boolean is
begin
return Right'Length = 0;
end Is_Nil;
function Is_Nil (Right : Asis.Text.Span) return Boolean is
begin
return (Right.Last_Line < Right.First_Line) or else
((Right.Last_Line = Right.First_Line) and then
(Right.Last_Column < Right.First_Column));
end Is_Nil;
-----------------------
-- Is_Text_Available --
-----------------------
function Is_Text_Available (Element : Asis.Element) return Boolean is
El_Kind : constant Internal_Element_Kinds := Int_Kind (Element);
Spec_Case : constant Special_Cases := Special_Case (Element);
begin
Check_Validity (Element,
"Asis.Text.Is_Text_Available");
if El_Kind = Not_An_Element or else
Is_From_Implicit (Element) or else
Is_From_Instance (Element) or else
Normalization_Case (Element) /= Is_Not_Normalized or else
Spec_Case in Explicit_From_Standard .. Stand_Char_Literal
then
return False;
else
return True;
end if;
end Is_Text_Available;
----------------------
-- Last_Line_Number --
----------------------
function Last_Line_Number
(Element : Asis.Element)
return Asis.Text.Line_Number
is
Sp : Asis.Text.Span;
begin
Check_Validity (Element, "Asis.Text.Last_Line_Number");
if Is_Text_Available (Element) then
Sp := Element_Span (Element);
return Sp.Last_Line;
else
return 0;
end if;
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Last_Line_Number",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Last_Line_Number",
Arg_Element => Element,
Ex => Ex);
end Last_Line_Number;
------------
-- Length --
------------
function Length
(The_Line : Asis.Text.Line)
return Asis.Text.Character_Position
is
begin
Check_Validity (The_Line, "Asis.Text.Length");
return Line_Length (The_Line);
end Length;
----------------
-- Line_Image --
----------------
function Line_Image (The_Line : Asis.Text.Line) return Wide_String is
begin
Check_Validity (The_Line, "Asis.Text.Line_Image");
if Line_Length (The_Line) = 0 then
return "";
end if;
declare
ASIS_Line_Start : constant Source_Ptr := Line_Location (The_Line);
S : Source_Ptr := Line_Start (ASIS_Line_Start);
Space_Len : constant Natural :=
Natural (ASIS_Line_Start - S);
Space_String : Wide_String (1 .. Space_Len);
-- We cannot have more padding white spaces then Space_Len
Space_Num : Natural := 0;
-- Counter for padding spaces
Sindex : constant Source_File_Index := Get_Source_File_Index (S);
Src : constant Source_Buffer_Ptr := Source_Text (Sindex);
Line_Wide_Img : constant Wide_String := Line_Wide_Image (The_Line);
begin
-- first, padding the beginning of the image if needed:
while S < ASIS_Line_Start loop
Space_Num := Space_Num + 1;
if Get_Character (S) = ASCII.HT then
Space_String (Space_Num) := To_Wide_Character (ASCII.HT);
S := S + 1;
elsif Is_Start_Of_Wide_Char_For_ASIS (Src, S) then
Skip_Wide_For_ASIS (Src, S);
Space_String (Space_Num) := ' ';
else
Space_String (Space_Num) := ' ';
S := S + 1;
end if;
end loop;
return Space_String (1 .. Space_Num) & Line_Wide_Img;
end;
exception
when ASIS_Inappropriate_Line =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => "Asis.Text.Line_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Line_Image",
Arg_Line => The_Line,
Ex => Ex);
end Line_Image;
---------------------
-- Lines (Element) --
---------------------
function Lines (Element : Asis.Element) return Asis.Text.Line_List is
begin
Check_Validity (Element, "Asis.Text.Lines (Element)");
if not Is_Text_Available (Element) then
return Nil_Line_List;
end if;
return Lines (Element, Element_Span (Element));
exception
when ASIS_Inappropriate_Element =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Lines (Element)",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Lines (Element)",
Arg_Element => Element,
Ex => Ex);
end Lines;
---------------------------
-- Lines (Element, Span) --
---------------------------
function Lines
(Element : Asis.Element;
The_Span : Asis.Text.Span)
return Asis.Text.Line_List
is
begin
Check_Validity (Element, "Asis.Text.Lines (Element, Span)");
if not Is_Text_Available (Element) then
return Nil_Line_List;
end if;
if Is_Nil (The_Span) or else
The_Span.Last_Line > Line_Number (Number_Of_Lines (Element))
then
Raise_ASIS_Inappropriate_Line_Number ("Lines (Element, Span)");
end if;
declare
LList : Asis.Text.Line_List :=
Lines (Element, The_Span.First_Line, The_Span.Last_Line);
-- this call to Lines is "tree-swapping-safe";
-- note also, that this call to Lines should not raise
-- any exception, because all the checks are already done
First_Line : constant Line_Number := LList'First;
Last_Line : constant Line_Number := LList'Last;
First_Line_Sloc : Source_Ptr := Line_Location (LList (First_Line));
-- Needs adjustment if The_Span does does not start from the first
-- column.
Count : Character_Position;
Sindex : constant Source_File_Index :=
Get_Source_File_Index (First_Line_Sloc);
Src : constant Source_Buffer_Ptr := Source_Text (Sindex);
begin
-- and now we have to adjust the first and the last line in LList:
-- for the first line both the line location and the line length
-- should be adjusted, for the last line - the line length only;
-- the case when there is only one line is special:
if The_Span.First_Column > 1 then
Count := The_Span.First_Column - 1;
while Count > 0 loop
if Is_Start_Of_Wide_Char_For_ASIS (Src, First_Line_Sloc) then
Skip_Wide_For_ASIS (Src, First_Line_Sloc);
else
First_Line_Sloc := First_Line_Sloc + 1;
end if;
Count := Count - 1;
end loop;
Set_Line_Location
(L => LList (First_Line),
S => First_Line_Sloc);
end if;
if First_Line = Last_Line then
-- Special case when there is only one line.
Set_Line_Length
(L => LList (First_Line),
N => The_Span.Last_Column - The_Span.First_Column + 1);
else
Set_Line_Length
(L => LList (First_Line),
N => Line_Length (LList (First_Line)) -
The_Span.First_Column + 1);
Set_Line_Length
(L => LList (Last_Line),
N => The_Span.Last_Column);
end if;
return LList;
end;
exception
when ASIS_Inappropriate_Element | ASIS_Inappropriate_Line_Number =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call => "Asis.Text.Lines (Element, Asis.Text.Span)",
Argument => Element);
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Lines (Element, Asis.Text.Span)",
Arg_Element => Element,
Arg_Span => The_Span,
Ex => Ex);
end Lines;
--------------------------------------------
-- Lines (Element, First_Line, Last_Line) --
--------------------------------------------
function Lines
(Element : Asis.Element;
First_Line : Line_Number_Positive;
Last_Line : Line_Number)
return Asis.Text.Line_List
is
Result_List : Line_List (First_Line .. Last_Line);
-- there is no harm to define result list here, because the
-- real work with it will be started when all the tests are passed.
begin
Check_Validity
(Element, "Asis.Text.Lines (Element, First_Line, Last_Line)");
if Is_Nil (Element) then
return Nil_Line_List;
end if;
if First_Line > Last_Line or else -- ???
Last_Line > Line_Number (Number_Of_Lines (Element))
then
Raise_ASIS_Inappropriate_Line_Number
("Asis.Text.Lines (Element, First_Line, Last_Line)");
end if;
-- if we are here, we have Result_List consisting of Nil_Lines,
-- and we know, that all the conditions for returning the
-- proper Line_List are met. So we have to make proper settings
-- for the fields of all the Lines from Result_List
Set_Lines (Result_List, Element);
-- this is "tree-swapping-safe"
return Result_List;
exception
when ASIS_Inappropriate_Element | ASIS_Inappropriate_Line_Number =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information
(Outer_Call =>
"Asis.Text.Lines (Asis.Element, First_Line, Last_Line)",
Argument => Element);
end if;
raise;
when Ex : others =>
-- We construct the fake Span value to pass the line numbers into
-- the diagnosis
Report_ASIS_Bug
(Query_Name =>
"Asis.Text.Lines (Asis.Element, First_Line, Last_Line)",
Arg_Element => Element,
Arg_Span => (First_Line => First_Line,
First_Column => 1,
Last_Line => Last_Line,
Last_Column => Character_Position'Last),
Ex => Ex);
end Lines;
-----------------------
-- Non_Comment_Image --
-----------------------
function Non_Comment_Image
(The_Line : Asis.Text.Line)
return Wide_String
is
begin
Check_Validity (The_Line, "Asis.Text.Non_Comment_Image");
if The_Line.Length = 0 then
-- just a small optimization
return "";
end if;
declare
The_Line_Image : constant Wide_String := Line_Image (The_Line);
Comment_Pos : constant Source_Ptr := Comment_Beginning
(Text_Buffer (To_String (The_Line_Image)));
begin
if Comment_Pos = No_Location then
-- no comment in this Line
return The_Line_Image;
else
return The_Line_Image
(The_Line_Image'First .. Natural (Comment_Pos) - 1);
end if;
end;
exception
when ASIS_Inappropriate_Line =>
raise;
when ASIS_Failed =>
if Status_Indicator = Unhandled_Exception_Error then
Add_Call_Information (Outer_Call => "Asis.Text.Non_Comment_Image");
end if;
raise;
when Ex : others =>
Report_ASIS_Bug
(Query_Name => "Asis.Text.Non_Comment_Image",
Arg_Line => The_Line,
Ex => Ex);
end Non_Comment_Image;
end Asis.Text;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- Copyright (C) 2016-2017, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.Text_IO; use System.Text_IO;
with System.Machine_Reset;
with Interfaces.AArch64; use Interfaces.AArch64;
with Ada.Unchecked_Conversion;
package body Trap_Dump is
Lock_Magic : constant Unsigned_32 := 16#0badcafe#;
Lock : aliased Unsigned_32 := 0;
procedure Put (Item : Character);
procedure Put (Item : String);
procedure New_Line;
procedure Get (C : out Character);
procedure Put_Line (Item : String);
procedure Put_Hex8 (V : Unsigned_64);
procedure Put_Hex4 (V : Unsigned_32);
procedure Put_Hex1 (V : Unsigned_8);
procedure Put_02 (N : Natural);
subtype Line_Range is Natural range 1 .. 32;
Line : String (Line_Range);
Line_Len : Natural range 0 .. Line_Range'Last;
Hex_Digits : constant array (0 .. 15) of Character := "0123456789abcdef";
subtype Hex_Digit_Type is Integer range -1 .. 255;
Bad_Hex : constant Hex_Digit_Type := -1;
function Read_Hex_Digit (Pos : Line_Range) return Hex_Digit_Type;
-- Convert Line (Pos) to its hexadecimal value. Return Bad_Hex if not
-- an hexa character.
procedure Get_Line;
-- Set Line, Line_Len from input.
function Get_Unsigned_32 return Unsigned_32;
procedure Mem_Dump32;
procedure Put (Item : Character) is
begin
while not System.Text_IO.Is_Tx_Ready loop
null;
end loop;
System.Text_IO.Put (Item);
end Put;
procedure Put (Item : String) is
begin
for J in Item'Range loop
Put (Item (J));
end loop;
end Put;
procedure New_Line is
begin
if System.Text_IO.Use_Cr_Lf_For_New_Line then
Put (ASCII.CR);
end if;
Put (ASCII.LF);
end New_Line;
procedure Put_Line (Item : String) is
begin
Put (Item);
New_Line;
end Put_Line;
procedure Put_Hex8 (V : Unsigned_64) is
Res : String (1 .. 16);
begin
for I in Res'Range loop
Res (I) :=
Hex_Digits (Natural (Shift_Right (V, 4 * (16 - I)) and 15));
end loop;
Put (Res);
end Put_Hex8;
procedure Put_Hex4 (V : Unsigned_32) is
Res : String (1 .. 8);
begin
for I in Res'Range loop
Res (I) :=
Hex_Digits (Natural (Shift_Right (V, 4 * (8 - I)) and 15));
end loop;
Put (Res);
end Put_Hex4;
procedure Put_Hex1 (V : Unsigned_8) is
Res : String (1 .. 2);
begin
for I in Res'Range loop
Res (I) := Hex_Digits (Natural (Shift_Right (V, 4 * (2 - I)) and 15));
end loop;
Put (Res);
end Put_Hex1;
procedure Put_02 (N : Natural) is
Res : String (1 .. 2);
begin
Res (1) := Character'Val (48 + N / 10);
Res (2) := Character'Val (48 + N mod 10);
Put (Res);
end Put_02;
procedure Get (C : out Character) is
begin
while not Is_Rx_Ready loop
null;
end loop;
C := System.Text_IO.Get;
end Get;
procedure Print_ESR (ESR : Unsigned_32);
procedure Print_SPSR (SPSR : Unsigned_32);
procedure Print_ESR (ESR : Unsigned_32) is
begin
Put ("ESR:");
Put_Hex4 (ESR);
Put (" (EC:");
Put_Hex1 (Unsigned_8 (Shift_Right (ESR, 26)));
Put (')');
end Print_ESR;
procedure Print_SPSR (SPSR : Unsigned_32) is
begin
Put ("SPSR:");
Put_Hex4 (SPSR);
Put (" (EL:");
Put_Hex1 (Unsigned_8 (Shift_Right (SPSR, 2) and 3));
Put (')');
end Print_SPSR;
function Read_Hex_Digit (Pos : Line_Range) return Hex_Digit_Type is
C : constant Character := Line (Pos);
begin
case C is
when '0' .. '9' =>
return Character'Pos (C) - Character'Pos ('0');
when 'a' .. 'f' =>
return Character'Pos (C) - Character'Pos ('a') + 10;
when 'A' .. 'F' =>
return Character'Pos (C) - Character'Pos ('A') + 10;
when others =>
return Bad_Hex;
end case;
end Read_Hex_Digit;
procedure Get_Line is
C : Character;
Prev_Len : Natural := Line_Len;
begin
Put ("> ");
Line_Len := 0;
loop
Get (C);
case C is
when ' ' .. Character'Val (126) =>
if Line_Len < Line_Range'Last then
Line_Len := Line_Len + 1;
Line (Line_Len) := C;
Put (C);
else
Put (ASCII.BEL);
end if;
when ASCII.CR | ASCII.LF =>
New_Line;
exit;
when Character'Val (21) => -- ^U
New_Line;
Put ("> ");
Line_Len := 0;
when Character'Val (8) -- ^H
| Character'Val (127) => -- DEL
if Line_Len = 0 then
Put (ASCII.BEL);
else
Put (ASCII.BS);
Put (' ');
Put (ASCII.BS);
Line_Len := Line_Len - 1;
Prev_Len := 0;
end if;
when Character'Val (16) => -- ^P
if Line_Len = 0 and then Prev_Len > 0 then
-- Recall previous line
for I in 1 .. Prev_Len loop
Put (Line (I));
end loop;
Line_Len := Prev_Len;
else
Put (ASCII.BEL);
end if;
when others =>
Put (ASCII.BEL);
end case;
end loop;
end Get_Line;
function Get_Unsigned_32 return Unsigned_32
is
H : Hex_Digit_Type;
C : Character;
Pos : Line_Range;
Res : Unsigned_32;
begin
<<Again>> null;
Get_Line;
Pos := Line'First;
Res := 0;
if Line_Len > Pos + 1
and then Line (Pos) = '0'
and then Line (Pos + 1) = 'x'
then
-- Parse as hex.
for I in Pos + 2 .. Line_Len loop
H := Read_Hex_Digit (I);
if H = Bad_Hex then
Put_Line ("Bad character in hex number");
goto Again;
else
Res := Res * 16 + Unsigned_32 (H);
end if;
end loop;
else
-- Parse as dec.
for I in Pos .. Line_Len loop
Res := Res * 10;
C := Line (I);
if C in '0' .. '9' then
Res := Res + Character'Pos (C) - Character'Pos ('0');
else
Put_Line ("Bad character in decimal number");
goto Again;
end if;
end loop;
end if;
return Res;
end Get_Unsigned_32;
procedure Mem_Dump32 is
Addr : Unsigned_32;
Len : Unsigned_32;
Eaddr : Unsigned_32;
begin
Put ("address");
Addr := Get_Unsigned_32;
Put ("length");
Len := Get_Unsigned_32;
-- Align address
Addr := Addr and not 3;
Eaddr := Addr + Len - 1;
loop
Put_Hex4 (Addr);
Put (": ");
for I in Unsigned_32 range 0 .. 3 loop
if Addr > Eaddr then
Put (" ");
else
declare
W : Unsigned_32;
for W'Address use System'To_Address (Addr);
pragma Import (Ada, W);
begin
Put_Hex4 (W);
end;
end if;
Put (' ');
Addr := Addr + 4;
end loop;
New_Line;
exit when Addr - 1 >= Eaddr; -- Handle wrap around 0
end loop;
end Mem_Dump32;
procedure Dump (Regs : Registers_List_Acc; Id : Natural)
is
function To_Unsigned_64 is new Ada.Unchecked_Conversion
(Registers_List_Acc, Unsigned_64);
EL : Unsigned_32;
C : Character;
begin
-- Very crude lock, but cache may not be enabled
while Lock = Lock_Magic loop
null;
end loop;
Lock := Lock_Magic;
-- Initialize console in case of very early crash
if not Initialized then
Initialize;
end if;
Put ("X registers:");
New_Line;
for I in 0 .. 30 loop
if I mod 4 /= 0 then
Put (' ');
end if;
Put_02 (I);
Put (':');
Put_Hex8 (Regs.Xr (I));
if (I mod 4 = 3) or I = 30 then
New_Line;
end if;
end loop;
Put ("id: ");
Put_Hex1 (Unsigned_8 (Id));
if (Id mod 4) = 1 then
Put (" synchronous exception");
end if;
EL := Get_Current_EL;
Put (" EL: ");
Put_Hex1 (Unsigned_8 (EL / 4));
Put (" SP: ");
Put_Hex8 (To_Unsigned_64 (Regs));
Put (" CPU: ");
Put_Hex1 (Unsigned_8 (Get_MPIDR_EL1 and 3) + 1);
New_Line;
if EL = 3 * 4 then
Put ("EL3 ELR:");
Put_Hex8 (Get_ELR_EL3);
Put (", ");
Print_SPSR (Get_SPSR_EL3);
New_Line;
Put ("EL3 ");
Print_ESR (Get_ESR_EL3);
Put (", FAR:");
Put_Hex8 (Get_FAR_EL3);
Put (", EL2 SP:");
Put_Hex8 (Get_SP_EL2);
New_Line;
end if;
if EL >= 2 * 4 then
Put ("EL2 ELR:");
Put_Hex8 (Get_ELR_EL2);
Put (", ");
Print_SPSR (Get_SPSR_EL2);
Put (", EL1 SP:");
Put_Hex8 (Get_SP_EL1);
New_Line;
Put ("EL2 ");
Print_ESR (Get_ESR_EL2);
Put (", FAR:");
Put_Hex8 (Get_FAR_EL2);
Put (", HPFAR:");
Put_Hex8 (Get_HPFAR_EL2);
New_Line;
Put ("EL2 VTCR:");
Put_Hex8 (Get_VTCR_EL2);
Put (", VTTBR:");
Put_Hex8 (Get_VTTBR_EL2);
Put (", HCR:");
Put_Hex8 (Get_HCR_EL2);
New_Line;
Put ("EL2 SCTLR:");
Put_Hex4 (Get_SCTLR_EL2);
Put (" CPTR:");
Put_Hex8 (Get_CPTR_EL2);
New_Line;
end if;
if EL >= 1 * 4 then
Put ("EL1 ELR:");
Put_Hex8 (Get_ELR_EL1);
Put (", ");
Print_SPSR (Get_SPSR_EL1);
Put (", VBAR:");
Put_Hex8 (Get_VBAR_EL1);
New_Line;
Put ("EL1 ");
Print_ESR (Get_ESR_EL1);
Put (", FAR:");
Put_Hex8 (Get_FAR_EL1);
Put (", EL0 SP:");
Put_Hex8 (Get_SP_EL0);
New_Line;
Put ("EL1 SCTLR:");
Put_Hex4 (Get_SCTLR_EL1);
Put (", TCR:");
Put_Hex8 (Get_TCR_EL1);
New_Line;
Put ("EL1 TTBR0:");
Put_Hex8 (Get_TTBR0_EL1);
Put (", TTBR1:");
Put_Hex8 (Get_TTBR1_EL1);
New_Line;
end if;
-- Interractive (!!) session.
Put ("TMON: (C)ont/(R)eset/(N)ext ?");
loop
Get (C);
Put (C);
case C is
when 'c' | 'C' =>
exit;
when 'n' | 'N' =>
case EL is
when 1 * 4 =>
Set_ELR_EL1 (Get_ELR_EL1 + 4);
when 2 * 4 =>
Set_ELR_EL2 (Get_ELR_EL2 + 4);
when 3 * 4 =>
Set_ELR_EL3 (Get_ELR_EL3 + 4);
when others =>
null;
end case;
exit;
when 'r' | 'R' =>
System.Machine_Reset.Stop;
when 'd' =>
New_Line;
Mem_Dump32;
when others =>
Put ('?');
end case;
end loop;
New_Line;
Lock := 0;
end Dump;
end Trap_Dump;
|
with Ada.Containers.Ordered_Sets,
Ada.Containers.Vectors; use Ada.Containers;
with Ada.Text_IO; use Ada.Text_IO;
with Interfaces; use Interfaces;
with Input16; use Input16, Input16.OH;
procedure Day16 is
subtype Op_String is String (1 .. 4);
package String_Sets is new Ordered_Sets (Element_Type => Op_String);
package String_Set_Vectors is new Vectors
(Index_Type => Positive,
Element_Type => String_Sets.Set,
"=" => String_Sets."=");
Opcodes : array (Natural range 0 .. 15) of String_Set_Vectors.Vector;
Opcode_Lookup : array (Natural range 0 .. 15) of Op_String :=
("addr", "addi", "mulr", "muli", "banr", "bani", "borr", "bori",
"setr", "seti", "gtir", "gtri", "gtrr", "eqir", "eqri", "eqrr");
Part1_Count : Natural := 0;
begin
-- Part 1
for I in Part1_Input'Range loop
declare
Sample : constant Sample_Record := Part1_Input (I);
A : constant Unsigned_64 := Sample.Instr (1);
B : constant Unsigned_64 := Sample.Instr (2);
C : constant Unsigned_64 := Sample.Instr (3);
Match_Count : Natural := 0;
Possible_Opcodes : String_Sets.Set;
begin
for I in Opcode_Lookup'Range loop
declare
Op : constant Op_String := Opcode_Lookup (I);
begin
if Execute_Instruction (Op, Sample.Before, A, B, C) = Sample.After
then
Match_Count := Match_Count + 1;
Possible_Opcodes.Insert (Op);
end if;
end;
end loop;
Opcodes (Natural (Sample.Instr (0))).Append (Possible_Opcodes);
if Match_Count >= 3 then
Part1_Count := Part1_Count + 1;
end if;
end;
end loop;
Put_Line ("Part 1 =" & Natural'Image (Part1_Count));
-- Part 2 Setup (find the opcode values)
declare
Opcode : array (Natural range 0 .. 15) of String_Sets.Set;
Is_Finished : Boolean := False;
begin
for Op in Opcodes'Range loop
declare
Set : String_Sets.Set := Opcodes (Op).First_Element;
begin
for I in Opcodes (Op).First_Index + 1 .. Opcodes (Op).Last_Index
loop
Set := String_Sets.Intersection (Set, Opcodes (Op) (I));
end loop;
Opcode (Op) := Set;
end;
end loop;
while not Is_Finished loop
Is_Finished := True;
for I in Opcode'Range loop
if Opcode (I).Length = 1 then
Opcode_Lookup (I) := Opcode (I).First_Element;
for J in Opcode'Range loop
if J /= I then
Opcode (J).Exclude (Opcode (I).First_Element);
end if;
end loop;
else
Is_Finished := False;
end if;
end loop;
end loop;
end;
Put_Line ("Opcodes:");
for I in Opcode_Lookup'Range loop
Put_Line (Natural'Image (I) & " " & Opcode_Lookup (I));
end loop;
-- Part 2 Solution
declare
Reg : Registers := (0, 0, 0, 0);
begin
for I in Part2_Input'Range loop
declare
Op : constant Natural := Natural (Part2_Input (I) (0));
A : constant Unsigned_64 := Part2_Input (I) (1);
B : constant Unsigned_64 := Part2_Input (I) (2);
C : constant Unsigned_64 := Part2_Input (I) (3);
begin
Reg := Execute_Instruction (Opcode_Lookup (Op), Reg, A, B, C);
end;
end loop;
Put_Line ("Part 2 =" & Unsigned_64'Image (Reg (3)));
end;
end Day16;
|
-- Synchronized subscriber
with Ada.Command_Line;
with Ada.Text_IO;
with GNAT.Formatted_String;
with ZMQ;
procedure SyncSub is
use type GNAT.Formatted_String.Formatted_String;
Subscribers_Expected : constant := 10; -- We wait for 10 subscribers
function Main return Ada.Command_Line.Exit_Status
is
begin
declare
Context : ZMQ.Context_Type := ZMQ.New_Context;
-- First, connect our subscriber socket
Subscriber : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_SUB);
-- Second, synchronize with publisher
Sync_Client : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_REQ);
begin
-- First, connect our subscriber socket
Subscriber.Connect ("tcp://localhost:5561");
Subscriber.Set_Sock_Opt (ZMQ.ZMQ_SUBSCRIBE, "");
-- 0MQ is so fast, we need to wait a while...
delay 1.0;
-- Second, synchronize with publisher
Sync_Client.Connect ("tcp://localhost:5562");
-- - send a synchronization request
Sync_Client.Send ("");
-- - wait for synchronization reply
declare
Unused_Reply : String := Sync_Client.Recv;
begin
null;
end;
-- Third, get our updates and report how many we got
declare
Update_Nbr : Natural := 0;
begin
Recv_Loop :
loop
declare
Msg : constant String := Subscriber.Recv;
begin
exit Recv_Loop when Msg = "END";
end;
Update_Nbr := Update_Nbr + 1;
end loop Recv_Loop;
Ada.Text_IO.Put_Line (-(+"Received %d updates"&Update_Nbr));
end;
Subscriber.Close;
Sync_Client.Close;
Context.Term;
end;
return 0;
end Main;
begin
Ada.Command_Line.Set_Exit_Status (Main);
end SyncSub;
|
------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
pragma Warnings (Off, "* internal GNAT unit");
with System.Text_IO; use System.Text_IO;
pragma Warnings (On, "* internal GNAT unit");
with System.Machine_Code; use System.Machine_Code;
with Ada.Unchecked_Conversion;
package body Trap_Handler is
procedure Put (Item : Character);
procedure Put (Item : String);
procedure New_Line;
procedure Get (C : out Character);
procedure Put_Hex4 (V : Unsigned_32);
procedure Put_Hex1 (V : Unsigned_8);
procedure Put_02 (N : Natural);
Hex_Digits : constant array (0 .. 15) of Character := "0123456789abcdef";
procedure Put (Item : Character) is
begin
while not System.Text_IO.Is_Tx_Ready loop
null;
end loop;
System.Text_IO.Put (Item);
end Put;
procedure Put (Item : String) is
begin
for J in Item'Range loop
Put (Item (J));
end loop;
end Put;
procedure New_Line is
begin
if System.Text_IO.Use_Cr_Lf_For_New_Line then
Put (ASCII.CR);
end if;
Put (ASCII.LF);
end New_Line;
procedure Put_Hex4 (V : Unsigned_32) is
Res : String (1 .. 8);
begin
for I in Res'Range loop
Res (I) :=
Hex_Digits (Natural (Shift_Right (V, 4 * (8 - I)) and 15));
end loop;
Put (Res);
end Put_Hex4;
procedure Put_Hex1 (V : Unsigned_8) is
Res : String (1 .. 2);
begin
for I in Res'Range loop
Res (I) := Hex_Digits (Natural (Shift_Right (V, 4 * (2 - I)) and 15));
end loop;
Put (Res);
end Put_Hex1;
procedure Put_02 (N : Natural) is
Res : String (1 .. 2);
begin
Res (1) := Character'Val (48 + N / 10);
Res (2) := Character'Val (48 + N mod 10);
Put (Res);
end Put_02;
procedure Get (C : out Character) is
begin
while not Is_Rx_Ready loop
null;
end loop;
C := System.Text_IO.Get;
end Get;
pragma Unreferenced (Put_Hex1, Get);
function Get_CPSR return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrs %0,cpsr",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_CPSR;
function Get_SPSR return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrs %0,spsr",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_SPSR;
procedure Set_TLB_Data_Read_Operation_Reg (V : Unsigned_32) is
begin
Asm ("mcr p15, #3, %0, c15, c4, #2",
Inputs => Unsigned_32'Asm_Input ("r", V),
Volatile => True);
end Set_TLB_Data_Read_Operation_Reg;
function Get_Data_Register_0 return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrc p15, #3, %0, c15, c0, #0",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_Data_Register_0;
function Get_Data_Register_1 return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrc p15, #3, %0, c15, c0, #1",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_Data_Register_1;
function Get_Data_Register_2 return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrc p15, #3, %0, c15, c0, #2",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_Data_Register_2;
function Get_Data_Register_3 return Unsigned_32
is
Res : Unsigned_32;
begin
Asm ("mrc p15, #3, %0, c15, c0, #3",
Outputs => Unsigned_32'Asm_Output ("=r", Res),
Volatile => True);
return Res;
end Get_Data_Register_3;
procedure Traps_Handler (Ctxt : Trap_Context_Acc; Num : Natural)
is
function To_Unsigned_32 is new Ada.Unchecked_Conversion
(Trap_Context_Acc, Unsigned_32);
begin
-- Initialize console in case of very early crash
if not Initialized then
Initialize;
end if;
for I in 0 .. 14 loop
if I mod 4 /= 0 then
Put (' ');
end if;
if I = 13 then
Put ("SP:");
elsif I = 14 then
Put ("LR:");
else
Put_02 (I);
Put (':');
end if;
Put_Hex4 (Ctxt.R (I));
if (I mod 4) = 3 then
New_Line;
end if;
end loop;
Put (" PC:");
Put_Hex4 (Ctxt.PC);
New_Line;
Put ("SPSR:");
Put_Hex4 (Get_SPSR);
Put (" CPSR:");
Put_Hex4 (Get_CPSR);
Put (" CurSP:");
Put_Hex4 (To_Unsigned_32 (Ctxt));
Put (" Trap #");
Put_02 (Num);
New_Line;
if (Get_CPSR and 16#1f#) = 16#16# then
Put ("TLB: PA VA");
New_Line;
for I in Unsigned_32 range 0 .. 3 loop
for J in Unsigned_32 range 0 .. 127 loop
declare
function SL (V : Unsigned_32; S : Natural) return Unsigned_32
renames Shift_Left;
function SR (V : Unsigned_32; S : Natural) return Unsigned_32
renames Shift_Right;
En : constant Unsigned_32 := I * 2**30 + J;
D0, D1, D2 : Unsigned_32;
begin
Set_TLB_Data_Read_Operation_Reg (I * 2**30 + J);
D0 := Get_Data_Register_0;
if (D0 and 1) = 1 then
D2 := Get_Data_Register_2;
D1 := Get_Data_Register_1;
Put_Hex4 (En);
Put (": ");
Put_Hex4 (Get_Data_Register_3);
Put (' ');
Put_Hex4 (D2);
Put (' ');
Put_Hex4 (D1);
Put (' ');
Put_Hex4 (D0);
Put (" ");
Put_Hex4 (SL (SR (D2 and 16#3fff_fffc#, 2), 12));
Put (' ');
Put_Hex4 (SL (SR (D0 and 16#7fff_fffc#, 2), 12));
Put (' ');
case SR (D1, 24) and 7 is
when 2#000#
| 2#001# => Put (" 4K");
when 2#010#
| 2#011# => Put ("64K");
when 2#100# => Put (" 1M");
when 2#101# => Put (" 2M");
when 2#110# => Put ("16M");
when 2#111# => Put (".5G");
when others => null;
end case;
New_Line;
end if;
end;
end loop;
end loop;
end if;
loop
null;
end loop;
end Traps_Handler;
procedure Undef_Trap_Mon;
pragma Import (C, Undef_Trap_Mon, "__gnat_undef_trap_mon");
procedure Smc_Trap_Mon;
pragma Import (C, Smc_Trap_Mon, "__gnat_smc_trap_mon");
procedure Pabt_Trap_Mon;
pragma Import (C, Pabt_Trap_Mon, "__gnat_pabt_trap_mon");
procedure Dabt_Trap_Mon;
pragma Import (C, Dabt_Trap_Mon, "__gnat_dabt_trap_mon");
procedure Irq_Trap_Mon;
pragma Import (C, Irq_Trap_Mon, "__gnat_irq_trap_mon");
procedure Fiq_Trap_Mon;
pragma Import (C, Fiq_Trap_Mon, "__gnat_fiq_trap_mon");
procedure Smc_Switch_Mon;
pragma Import (C, Smc_Switch_Mon, "__gnat_smc_switch_mon");
procedure Install_Monitor_Handlers
is
use System;
Except : array (0 .. 7) of Unsigned_32
with Import, Volatile, Address => System'To_Address (0);
Vectors : array (0 .. 7) of Address
with Import, Volatile, Address => System'To_Address (16#20#);
Ldr_Pc_Pc_20 : constant Unsigned_32 := 16#e59ff018#;
begin
Except (0 .. 7) := (others => Ldr_Pc_Pc_20);
Vectors (0 .. 7) := (Null_Address,
Undef_Trap_Mon'Address,
Smc_Trap_Mon'Address,
Pabt_Trap_Mon'Address,
Dabt_Trap_Mon'Address,
Null_Address,
Irq_Trap_Mon'Address,
Fiq_Trap_Mon'Address);
for I in 0 .. 7 loop
-- DCCIMVAC
Asm ("mcr p15, #0, %0, c7, c14, #1",
Inputs => Address'Asm_Input ("r", Except (I)'Address),
Volatile => True);
-- ICIMVAU
Asm ("mcr p15, #0, %0, c7, c5, #1",
Inputs => Address'Asm_Input ("r", Except (I)'Address),
Volatile => True);
end loop;
Asm ("dsb", Volatile => True);
Asm ("isb", Volatile => True);
if False then
-- That doesn't work if cache is enabled!
Put ("Switch to monitor from cpsr ");
Put_Hex4 (Get_CPSR);
New_Line;
declare
R : Unsigned_32;
begin
Vectors (2) := Smc_Switch_Mon'Address;
Asm ("mov %0, sp",
Outputs => Unsigned_32'Asm_Output ("=r", R),
Volatile => True);
Put ("SP=");
Put_Hex4 (R);
Asm ("dsb; isb; smc #0; mov %0, r1",
Outputs => Unsigned_32'Asm_Output ("=r", R),
Volatile => True,
Clobber => "r1, r2");
Put (" R=");
Put_Hex4 (R);
Asm ("mov %0, sp",
Outputs => Unsigned_32'Asm_Output ("=r", R),
Volatile => True);
Put (" SP=");
Put_Hex4 (R);
New_Line;
end;
Vectors (2) := Smc_Trap_Mon'Address;
end if;
end Install_Monitor_Handlers;
end Trap_Handler;
|
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure euler45 is
type stringptr is access all char_array;
procedure PString(s : stringptr) is
begin
String'Write (Text_Streams.Stream (Current_Output), To_Ada(s.all));
end;
procedure PInt(i : in Integer) is
begin
String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left));
end;
function triangle(n : in Integer) return Integer is
begin
if n rem 2 = 0
then
return (n / 2) * (n + 1);
else
return n * ((n + 1) / 2);
end if;
end;
function penta(n : in Integer) return Integer is
begin
if n rem 2 = 0
then
return (n / 2) * (3 * n - 1);
else
return ((3 * n - 1) / 2) * n;
end if;
end;
function hexa(n : in Integer) return Integer is
begin
return n * (2 * n - 1);
end;
function findPenta2(n : in Integer; a : in Integer; b : in Integer) return Boolean is
p : Integer;
c : Integer;
begin
if b = a + 1
then
return penta(a) = n or else penta(b) = n;
end if;
c := (a + b) / 2;
p := penta(c);
if p = n
then
return TRUE;
else
if p < n
then
return findPenta2(n, c, b);
else
return findPenta2(n, a, c);
end if;
end if;
end;
function findHexa2(n : in Integer; a : in Integer; b : in Integer) return Boolean is
p : Integer;
c : Integer;
begin
if b = a + 1
then
return hexa(a) = n or else hexa(b) = n;
end if;
c := (a + b) / 2;
p := hexa(c);
if p = n
then
return TRUE;
else
if p < n
then
return findHexa2(n, c, b);
else
return findHexa2(n, a, c);
end if;
end if;
end;
t : Integer;
begin
for n in integer range 285..55385 loop
t := triangle(n);
if findPenta2(t, n / 5, n) and then findHexa2(t, n / 5, n / 2 + 10)
then
PInt(n);
PString(new char_array'( To_C("" & Character'Val(10))));
PInt(t);
PString(new char_array'( To_C("" & Character'Val(10))));
end if;
end loop;
end;
|
------------------------------------------------------------------------------
-- --
-- WAVEFILES --
-- --
-- Text I/O packages for common data types for wavefile buffer I/O --
-- --
-- The MIT License (MIT) --
-- --
-- Copyright (c) 2020 Gustavo A. Hoffmann --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining --
-- a copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and / or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be --
-- included in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, --
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Text_IO;
package Audio.Wavefiles.Data_Types.Text_IO is
package Wav_Fixed_8_Text_IO is new
Ada.Text_IO.Fixed_IO (Wav_Fixed_8);
package Wav_Fixed_16_Text_IO is new
Ada.Text_IO.Fixed_IO (Wav_Fixed_16);
package Wav_Fixed_24_Text_IO is new
Ada.Text_IO.Fixed_IO (Wav_Fixed_24);
package Wav_Fixed_32_Text_IO is new
Ada.Text_IO.Fixed_IO (Wav_Fixed_32);
package Wav_Fixed_64_Text_IO is new
Ada.Text_IO.Fixed_IO (Wav_Fixed_64);
package Wav_Float_32_Text_IO is new
Ada.Text_IO.Float_IO (Wav_Float_32);
package Wav_Float_64_Text_IO is new
Ada.Text_IO.Float_IO (Wav_Float_64);
package Wav_Float_128_Text_IO is new
Ada.Text_IO.Float_IO (Wav_Float_128);
end Audio.Wavefiles.Data_Types.Text_IO;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with AcronymList; use AcronymList;
with RASCAL.WimpTask; use RASCAL.WimpTask;
with RASCAL.Utility; use RASCAL.Utility;
with RASCAL.Variable; use RASCAL.Variable;
with RASCAL.OS; use RASCAL.OS;
package Main is
--
Main_Task : ToolBox_Task_Class;
main_objectid : Object_ID := -1;
main_winid : Wimp_Handle_Type := -1;
Data_Menu_Entries : natural := 0;
x_pos : Integer := -1;
y_pos : Integer := -1;
-- Constants
Not_Found_Message : UString;
app_name : constant String := "Meaning";
Choices_Write : constant String := "<Choices$Write>." & app_name;
Choices_Read : constant String := "Choices:" & app_name & ".Choices";
scrapdir : constant String := "<Wimp$ScrapDir>." & app_name;
--
Acronym_List : AcronymList.ListPointer := new AcronymList.List;
Untitled_String : Unbounded_String;
--
procedure Main;
procedure Discard_Acronyms;
procedure Read_Acronyms;
procedure Report_Error (Token : in String;
Info : in String);
--
end Main;
|
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Events.Joysticks.Game_Controllers
--
-- Game controller specific events.
--------------------------------------------------------------------------------------------------------------------
with Interfaces;
package SDL.Events.Joysticks.Game_Controllers is
type Axes is (Invalid,
Left_X,
Left_Y,
Right_X,
Right_Y,
Trigger_Left,
Trigger_Right) with
Convention => C;
for Axes use (Invalid => -1,
Left_X => 0,
Left_Y => 1,
Right_X => 2,
Right_Y => 3,
Trigger_Left => 4,
Trigger_Right => 5);
subtype LR_Axes is Axes range Left_X .. Right_Y;
subtype Trigger_Axes is Axes range Trigger_Left .. Trigger_Right;
type LR_Axes_Values is range -32768 .. 32767 with
Convention => C,
Size => 16;
type Trigger_Axes_Values is range 0 .. 32767 with
Convention => C,
Size => 16;
type Buttons is (Invalid,
A,
B,
X,
Y,
Back,
Guide,
Start,
Left_Stick,
Right_Stick,
Left_Shoulder,
Right_Shoulder,
D_Pad_Up,
D_Pad_Down,
D_Pad_Left,
D_Pad_Right) with
Convention => C;
for Buttons use (Invalid => -1,
A => 0,
B => 1,
X => 2,
Y => 3,
Back => 4,
Guide => 5,
Start => 6,
Left_Stick => 7,
Right_Stick => 8,
Left_Shoulder => 9,
Right_Shoulder => 10,
D_Pad_Up => 11,
D_Pad_Down => 12,
D_Pad_Left => 13,
D_Pad_Right => 14);
-- Update the game controller event data. This is called by the event loop.
procedure Update with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerUpdate";
function Is_Polling_Enabled return Boolean;
procedure Enable_Polling with
Inline => True;
procedure Disable_Polling with
Inline => True;
end SDL.Events.Joysticks.Game_Controllers;
|
-----------------------------------------------------------------------
-- Search.Models -- Search.Models
-----------------------------------------------------------------------
-- 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 1095
-----------------------------------------------------------------------
-- Copyright (C) 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 Ada.Unchecked_Deallocation;
package body Search.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Index_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => INDEX_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Index_Key;
function Index_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => INDEX_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Index_Key;
function "=" (Left, Right : Index_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Index_Ref'Class;
Impl : out Index_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Index_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Index_Ref) is
Impl : Index_Access;
begin
Impl := new Index_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Index
-- ----------------------------------------
procedure Set_Id (Object : in out Index_Ref;
Value : in ADO.Identifier) is
Impl : Index_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Index_Ref)
return ADO.Identifier is
Impl : constant Index_Access
:= Index_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
-- Copy of the object.
procedure Copy (Object : in Index_Ref;
Into : in out Index_Ref) is
Result : Index_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Index_Access
:= Index_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Index_Access
:= new Index_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Index_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Index_Access := new Index_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Index_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Index_Access := new Index_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Index_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Index_Access := new Index_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Index_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Index_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Index_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Index_Impl) is
type Index_Impl_Ptr is access all Index_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Index_Impl, Index_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Index_Impl_Ptr := Index_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Index_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, INDEX_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Index_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Index_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (INDEX_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Index_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (INDEX_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Index_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (INDEX_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Index_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Index_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Index_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Index_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
pragma Unreferenced (Session);
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
ADO.Objects.Set_Created (Object);
end Load;
function Document_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => DOCUMENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Document_Key;
function Document_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => DOCUMENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Document_Key;
function "=" (Left, Right : Document_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Document_Ref'Class;
Impl : out Document_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Document_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Document_Ref) is
Impl : Document_Access;
begin
Impl := new Document_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Document
-- ----------------------------------------
procedure Set_Id (Object : in out Document_Ref;
Value : in ADO.Identifier) is
Impl : Document_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Document_Ref)
return ADO.Identifier is
Impl : constant Document_Access
:= Document_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Index (Object : in out Document_Ref;
Value : in Search.Models.Index_Ref'Class) is
Impl : Document_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 2, Impl.Index, Value);
end Set_Index;
function Get_Index (Object : in Document_Ref)
return Search.Models.Index_Ref'Class is
Impl : constant Document_Access
:= Document_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Index;
end Get_Index;
-- Copy of the object.
procedure Copy (Object : in Document_Ref;
Into : in out Document_Ref) is
Result : Document_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Document_Access
:= Document_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Document_Access
:= new Document_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Index := Impl.Index;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Document_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Document_Access := new Document_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Document_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Document_Access := new Document_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Document_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Document_Access := new Document_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Document_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Document_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Document_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Document_Impl) is
type Document_Impl_Ptr is access all Document_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Document_Impl, Document_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Document_Impl_Ptr := Document_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Document_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, DOCUMENT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Document_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Document_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (DOCUMENT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- index_id
Value => Object.Index);
Object.Clear_Modified (2);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Document_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (DOCUMENT_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- index_id
Value => Object.Index);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Document_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (DOCUMENT_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Document_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Document_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Document_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Document_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
if not Stmt.Is_Null (1) then
Object.Index.Set_Key_Value (Stmt.Get_Identifier (1), Session);
end if;
ADO.Objects.Set_Created (Object);
end Load;
function Field_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => FIELD_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Field_Key;
function Field_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => FIELD_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Field_Key;
function "=" (Left, Right : Field_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Field_Ref'Class;
Impl : out Field_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Field_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Field_Ref) is
Impl : Field_Access;
begin
Impl := new Field_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Field
-- ----------------------------------------
procedure Set_Id (Object : in out Field_Ref;
Value : in ADO.Identifier) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Field_Ref)
return ADO.Identifier is
Impl : constant Field_Access
:= Field_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Field_Ref;
Value : in String) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Field_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Field_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Field_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Field_Access
:= Field_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Value (Object : in out Field_Ref;
Value : in String) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Value, Value);
end Set_Value;
procedure Set_Value (Object : in out Field_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Value, Value);
end Set_Value;
function Get_Value (Object : in Field_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Value);
end Get_Value;
function Get_Value (Object : in Field_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Field_Access
:= Field_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Value;
end Get_Value;
procedure Set_Document (Object : in out Field_Ref;
Value : in Search.Models.Document_Ref'Class) is
Impl : Field_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Document, Value);
end Set_Document;
function Get_Document (Object : in Field_Ref)
return Search.Models.Document_Ref'Class is
Impl : constant Field_Access
:= Field_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Document;
end Get_Document;
-- Copy of the object.
procedure Copy (Object : in Field_Ref;
Into : in out Field_Ref) is
Result : Field_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Field_Access
:= Field_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Field_Access
:= new Field_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
Copy.Value := Impl.Value;
Copy.Document := Impl.Document;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Field_Access := new Field_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Field_Access := new Field_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Field_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Field_Access := new Field_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Field_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Field_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Field_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Field_Impl) is
type Field_Impl_Ptr is access all Field_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Field_Impl, Field_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Field_Impl_Ptr := Field_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Field_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, FIELD_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Field_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (FIELD_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_3_NAME, -- document_id
Value => Object.Document);
Object.Clear_Modified (4);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (FIELD_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_3_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_2_3_NAME, -- value
Value => Object.Value);
Query.Save_Field (Name => COL_3_3_NAME, -- document_id
Value => Object.Document);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Field_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (FIELD_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Field_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Field_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Field_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "value" then
return Util.Beans.Objects.To_Object (Impl.Value);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Field_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
Object.Value := Stmt.Get_Unbounded_String (2);
if not Stmt.Is_Null (3) then
Object.Document.Set_Key_Value (Stmt.Get_Identifier (3), Session);
end if;
ADO.Objects.Set_Created (Object);
end Load;
function Sequence_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SEQUENCE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Sequence_Key;
function Sequence_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SEQUENCE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Sequence_Key;
function "=" (Left, Right : Sequence_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Sequence_Ref'Class;
Impl : out Sequence_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Sequence_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Sequence_Ref) is
Impl : Sequence_Access;
begin
Impl := new Sequence_Impl;
Impl.Token := ADO.NO_IDENTIFIER;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Sequence
-- ----------------------------------------
procedure Set_Positions (Object : in out Sequence_Ref;
Value : in ADO.Blob_Ref) is
Impl : Sequence_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Blob (Impl.all, 1, Impl.Positions, Value);
end Set_Positions;
function Get_Positions (Object : in Sequence_Ref)
return ADO.Blob_Ref is
Impl : constant Sequence_Access
:= Sequence_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Positions;
end Get_Positions;
procedure Set_Token (Object : in out Sequence_Ref;
Value : in ADO.Identifier) is
Impl : Sequence_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 2, Impl.Token, Value);
end Set_Token;
function Get_Token (Object : in Sequence_Ref)
return ADO.Identifier is
Impl : constant Sequence_Access
:= Sequence_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Token;
end Get_Token;
procedure Set_Field (Object : in out Sequence_Ref;
Value : in ADO.Identifier) is
Impl : Sequence_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 3, Value);
end Set_Field;
function Get_Field (Object : in Sequence_Ref)
return ADO.Identifier is
Impl : constant Sequence_Access
:= Sequence_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Field;
-- Copy of the object.
procedure Copy (Object : in Sequence_Ref;
Into : in out Sequence_Ref) is
Result : Sequence_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Sequence_Access
:= Sequence_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Sequence_Access
:= new Sequence_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Positions := Impl.Positions;
Copy.Token := Impl.Token;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Sequence_Access := new Sequence_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Sequence_Access := new Sequence_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("field = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Sequence_Access := new Sequence_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("field = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Sequence_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Sequence_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Sequence_Impl) is
type Sequence_Impl_Ptr is access all Sequence_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Sequence_Impl, Sequence_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Sequence_Impl_Ptr := Sequence_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Sequence_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, SEQUENCE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Sequence_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("field = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Sequence_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (SEQUENCE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_4_NAME, -- positions
Value => Object.Positions);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_4_NAME, -- token
Value => Object.Token);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_4_NAME, -- field
Value => Object.Get_Key);
Object.Clear_Modified (3);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "field = ? AND token = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Token);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Sequence_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (SEQUENCE_DEF'Access);
Result : Integer;
begin
Query.Save_Field (Name => COL_0_4_NAME, -- positions
Value => Object.Positions);
Query.Save_Field (Name => COL_1_4_NAME, -- token
Value => Object.Token);
Query.Save_Field (Name => COL_2_4_NAME, -- field
Value => Object.Get_Key);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Sequence_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (SEQUENCE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "field = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Sequence_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Sequence_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Sequence_Impl (Obj.all)'Access;
if Name = "token" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Token));
elsif Name = "field" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Sequence_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Positions := Stmt.Get_Blob (0);
Object.Token := Stmt.Get_Identifier (1);
Object.Set_Key_Value (Stmt.Get_Identifier (2));
ADO.Objects.Set_Created (Object);
end Load;
function Token_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => TOKEN_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Token_Key;
function Token_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => TOKEN_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Token_Key;
function "=" (Left, Right : Token_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Token_Ref'Class;
Impl : out Token_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Token_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Token_Ref) is
Impl : Token_Access;
begin
Impl := new Token_Impl;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Token
-- ----------------------------------------
procedure Set_Id (Object : in out Token_Ref;
Value : in ADO.Identifier) is
Impl : Token_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Token_Ref)
return ADO.Identifier is
Impl : constant Token_Access
:= Token_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Token_Ref;
Value : in String) is
Impl : Token_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Token_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Token_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Token_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Token_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Token_Access
:= Token_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Index (Object : in out Token_Ref;
Value : in Search.Models.Index_Ref'Class) is
Impl : Token_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 3, Impl.Index, Value);
end Set_Index;
function Get_Index (Object : in Token_Ref)
return Search.Models.Index_Ref'Class is
Impl : constant Token_Access
:= Token_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Index;
end Get_Index;
-- Copy of the object.
procedure Copy (Object : in Token_Ref;
Into : in out Token_Ref) is
Result : Token_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Token_Access
:= Token_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Token_Access
:= new Token_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
Copy.Index := Impl.Index;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Token_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Token_Access := new Token_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Token_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Token_Access := new Token_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Token_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Token_Access := new Token_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Token_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Token_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Token_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Token_Impl) is
type Token_Impl_Ptr is access all Token_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Token_Impl, Token_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Token_Impl_Ptr := Token_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Token_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, TOKEN_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Token_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Token_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (TOKEN_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_5_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_5_NAME, -- index_id
Value => Object.Index);
Object.Clear_Modified (3);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Token_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (TOKEN_DEF'Access);
Result : Integer;
begin
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_5_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_5_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_2_5_NAME, -- index_id
Value => Object.Index);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Token_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (TOKEN_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Token_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Token_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Token_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Token_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
if not Stmt.Is_Null (2) then
Object.Index.Set_Key_Value (Stmt.Get_Identifier (2), Session);
end if;
ADO.Objects.Set_Created (Object);
end Load;
end Search.Models;
|
-- 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.PWM is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Description collection[0]: Loads the first PWM value on all enabled channels from sequence 0, and starts playing that sequence at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes PWM generation to start it was not running.
-- Description collection[0]: Loads the first PWM value on all enabled
-- channels from sequence 0, and starts playing that sequence at the rate
-- defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes PWM generation to
-- start it was not running.
type TASKS_SEQSTART_Registers is array (0 .. 1) of HAL.UInt32;
-- Description collection[0]: First PWM period started on sequence 0
-- Description collection[0]: First PWM period started on sequence 0
type EVENTS_SEQSTARTED_Registers is array (0 .. 1) of HAL.UInt32;
-- Description collection[0]: Emitted at end of every sequence 0, when last value from RAM has been applied to wave counter
-- Description collection[0]: Emitted at end of every sequence 0, when last
-- value from RAM has been applied to wave counter
type EVENTS_SEQEND_Registers is array (0 .. 1) of HAL.UInt32;
-- Shortcut between SEQEND[0] event and STOP task
type SHORTS_SEQEND0_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_SEQEND0_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between SEQEND[1] event and STOP task
type SHORTS_SEQEND1_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_SEQEND1_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between LOOPSDONE event and SEQSTART[0] task
type SHORTS_LOOPSDONE_SEQSTART0_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_LOOPSDONE_SEQSTART0_Field use
(Disabled => 0,
Enabled => 1);
-- SHORTS_LOOPSDONE_SEQSTART array
type SHORTS_LOOPSDONE_SEQSTART_Field_Array is array (0 .. 1)
of SHORTS_LOOPSDONE_SEQSTART0_Field
with Component_Size => 1, Size => 2;
-- Type definition for SHORTS_LOOPSDONE_SEQSTART
type SHORTS_LOOPSDONE_SEQSTART_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LOOPSDONE_SEQSTART as a value
Val : HAL.UInt2;
when True =>
-- LOOPSDONE_SEQSTART as an array
Arr : SHORTS_LOOPSDONE_SEQSTART_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SHORTS_LOOPSDONE_SEQSTART_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Shortcut between LOOPSDONE event and STOP task
type SHORTS_LOOPSDONE_STOP_Field is
(-- Disable shortcut
Disabled,
-- Enable shortcut
Enabled)
with Size => 1;
for SHORTS_LOOPSDONE_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut register
type SHORTS_Register is record
-- Shortcut between SEQEND[0] event and STOP task
SEQEND0_STOP : SHORTS_SEQEND0_STOP_Field := NRF_SVD.PWM.Disabled;
-- Shortcut between SEQEND[1] event and STOP task
SEQEND1_STOP : SHORTS_SEQEND1_STOP_Field := NRF_SVD.PWM.Disabled;
-- Shortcut between LOOPSDONE event and SEQSTART[0] task
LOOPSDONE_SEQSTART : SHORTS_LOOPSDONE_SEQSTART_Field :=
(As_Array => False, Val => 16#0#);
-- Shortcut between LOOPSDONE event and STOP task
LOOPSDONE_STOP : SHORTS_LOOPSDONE_STOP_Field :=
NRF_SVD.PWM.Disabled;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
SEQEND0_STOP at 0 range 0 .. 0;
SEQEND1_STOP at 0 range 1 .. 1;
LOOPSDONE_SEQSTART at 0 range 2 .. 3;
LOOPSDONE_STOP at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- 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 SEQSTARTED[0] event
type INTEN_SEQSTARTED0_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_SEQSTARTED0_Field use
(Disabled => 0,
Enabled => 1);
-- INTEN_SEQSTARTED array
type INTEN_SEQSTARTED_Field_Array is array (0 .. 1)
of INTEN_SEQSTARTED0_Field
with Component_Size => 1, Size => 2;
-- Type definition for INTEN_SEQSTARTED
type INTEN_SEQSTARTED_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQSTARTED as a value
Val : HAL.UInt2;
when True =>
-- SEQSTARTED as an array
Arr : INTEN_SEQSTARTED_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTEN_SEQSTARTED_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Enable or disable interrupt for SEQEND[0] event
type INTEN_SEQEND0_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_SEQEND0_Field use
(Disabled => 0,
Enabled => 1);
-- INTEN_SEQEND array
type INTEN_SEQEND_Field_Array is array (0 .. 1) of INTEN_SEQEND0_Field
with Component_Size => 1, Size => 2;
-- Type definition for INTEN_SEQEND
type INTEN_SEQEND_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQEND as a value
Val : HAL.UInt2;
when True =>
-- SEQEND as an array
Arr : INTEN_SEQEND_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTEN_SEQEND_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Enable or disable interrupt for PWMPERIODEND event
type INTEN_PWMPERIODEND_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_PWMPERIODEND_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt for LOOPSDONE event
type INTEN_LOOPSDONE_Field is
(-- Disable
Disabled,
-- Enable
Enabled)
with Size => 1;
for INTEN_LOOPSDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Enable or disable interrupt
type INTEN_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Enable or disable interrupt for STOPPED event
STOPPED : INTEN_STOPPED_Field := NRF_SVD.PWM.Disabled;
-- Enable or disable interrupt for SEQSTARTED[0] event
SEQSTARTED : INTEN_SEQSTARTED_Field :=
(As_Array => False, Val => 16#0#);
-- Enable or disable interrupt for SEQEND[0] event
SEQEND : INTEN_SEQEND_Field := (As_Array => False, Val => 16#0#);
-- Enable or disable interrupt for PWMPERIODEND event
PWMPERIODEND : INTEN_PWMPERIODEND_Field := NRF_SVD.PWM.Disabled;
-- Enable or disable interrupt for LOOPSDONE event
LOOPSDONE : INTEN_LOOPSDONE_Field := NRF_SVD.PWM.Disabled;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTEN_Register use record
Reserved_0_0 at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
SEQSTARTED at 0 range 2 .. 3;
SEQEND at 0 range 4 .. 5;
PWMPERIODEND at 0 range 6 .. 6;
LOOPSDONE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- 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 SEQSTARTED[0] event
type INTENSET_SEQSTARTED0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_SEQSTARTED0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for SEQSTARTED[0] event
type INTENSET_SEQSTARTED0_Field_1 is
(-- Reset value for the field
Intenset_Seqstarted0_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_SEQSTARTED0_Field_1 use
(Intenset_Seqstarted0_Field_Reset => 0,
Set => 1);
-- INTENSET_SEQSTARTED array
type INTENSET_SEQSTARTED_Field_Array is array (0 .. 1)
of INTENSET_SEQSTARTED0_Field_1
with Component_Size => 1, Size => 2;
-- Type definition for INTENSET_SEQSTARTED
type INTENSET_SEQSTARTED_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQSTARTED as a value
Val : HAL.UInt2;
when True =>
-- SEQSTARTED as an array
Arr : INTENSET_SEQSTARTED_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTENSET_SEQSTARTED_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Write '1' to Enable interrupt for SEQEND[0] event
type INTENSET_SEQEND0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_SEQEND0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for SEQEND[0] event
type INTENSET_SEQEND0_Field_1 is
(-- Reset value for the field
Intenset_Seqend0_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_SEQEND0_Field_1 use
(Intenset_Seqend0_Field_Reset => 0,
Set => 1);
-- INTENSET_SEQEND array
type INTENSET_SEQEND_Field_Array is array (0 .. 1)
of INTENSET_SEQEND0_Field_1
with Component_Size => 1, Size => 2;
-- Type definition for INTENSET_SEQEND
type INTENSET_SEQEND_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQEND as a value
Val : HAL.UInt2;
when True =>
-- SEQEND as an array
Arr : INTENSET_SEQEND_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTENSET_SEQEND_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Write '1' to Enable interrupt for PWMPERIODEND event
type INTENSET_PWMPERIODEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_PWMPERIODEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for PWMPERIODEND event
type INTENSET_PWMPERIODEND_Field_1 is
(-- Reset value for the field
Intenset_Pwmperiodend_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_PWMPERIODEND_Field_1 use
(Intenset_Pwmperiodend_Field_Reset => 0,
Set => 1);
-- Write '1' to Enable interrupt for LOOPSDONE event
type INTENSET_LOOPSDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENSET_LOOPSDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Enable interrupt for LOOPSDONE event
type INTENSET_LOOPSDONE_Field_1 is
(-- Reset value for the field
Intenset_Loopsdone_Field_Reset,
-- Enable
Set)
with Size => 1;
for INTENSET_LOOPSDONE_Field_1 use
(Intenset_Loopsdone_Field_Reset => 0,
Set => 1);
-- Enable interrupt
type INTENSET_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Write '1' to Enable interrupt for STOPPED event
STOPPED : INTENSET_STOPPED_Field_1 :=
Intenset_Stopped_Field_Reset;
-- Write '1' to Enable interrupt for SEQSTARTED[0] event
SEQSTARTED : INTENSET_SEQSTARTED_Field :=
(As_Array => False, Val => 16#0#);
-- Write '1' to Enable interrupt for SEQEND[0] event
SEQEND : INTENSET_SEQEND_Field :=
(As_Array => False, Val => 16#0#);
-- Write '1' to Enable interrupt for PWMPERIODEND event
PWMPERIODEND : INTENSET_PWMPERIODEND_Field_1 :=
Intenset_Pwmperiodend_Field_Reset;
-- Write '1' to Enable interrupt for LOOPSDONE event
LOOPSDONE : INTENSET_LOOPSDONE_Field_1 :=
Intenset_Loopsdone_Field_Reset;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
Reserved_0_0 at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
SEQSTARTED at 0 range 2 .. 3;
SEQEND at 0 range 4 .. 5;
PWMPERIODEND at 0 range 6 .. 6;
LOOPSDONE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- 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 SEQSTARTED[0] event
type INTENCLR_SEQSTARTED0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_SEQSTARTED0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for SEQSTARTED[0] event
type INTENCLR_SEQSTARTED0_Field_1 is
(-- Reset value for the field
Intenclr_Seqstarted0_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_SEQSTARTED0_Field_1 use
(Intenclr_Seqstarted0_Field_Reset => 0,
Clear => 1);
-- INTENCLR_SEQSTARTED array
type INTENCLR_SEQSTARTED_Field_Array is array (0 .. 1)
of INTENCLR_SEQSTARTED0_Field_1
with Component_Size => 1, Size => 2;
-- Type definition for INTENCLR_SEQSTARTED
type INTENCLR_SEQSTARTED_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQSTARTED as a value
Val : HAL.UInt2;
when True =>
-- SEQSTARTED as an array
Arr : INTENCLR_SEQSTARTED_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTENCLR_SEQSTARTED_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Write '1' to Disable interrupt for SEQEND[0] event
type INTENCLR_SEQEND0_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_SEQEND0_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for SEQEND[0] event
type INTENCLR_SEQEND0_Field_1 is
(-- Reset value for the field
Intenclr_Seqend0_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_SEQEND0_Field_1 use
(Intenclr_Seqend0_Field_Reset => 0,
Clear => 1);
-- INTENCLR_SEQEND array
type INTENCLR_SEQEND_Field_Array is array (0 .. 1)
of INTENCLR_SEQEND0_Field_1
with Component_Size => 1, Size => 2;
-- Type definition for INTENCLR_SEQEND
type INTENCLR_SEQEND_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SEQEND as a value
Val : HAL.UInt2;
when True =>
-- SEQEND as an array
Arr : INTENCLR_SEQEND_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for INTENCLR_SEQEND_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Write '1' to Disable interrupt for PWMPERIODEND event
type INTENCLR_PWMPERIODEND_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_PWMPERIODEND_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for PWMPERIODEND event
type INTENCLR_PWMPERIODEND_Field_1 is
(-- Reset value for the field
Intenclr_Pwmperiodend_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_PWMPERIODEND_Field_1 use
(Intenclr_Pwmperiodend_Field_Reset => 0,
Clear => 1);
-- Write '1' to Disable interrupt for LOOPSDONE event
type INTENCLR_LOOPSDONE_Field is
(-- Read: Disabled
Disabled,
-- Read: Enabled
Enabled)
with Size => 1;
for INTENCLR_LOOPSDONE_Field use
(Disabled => 0,
Enabled => 1);
-- Write '1' to Disable interrupt for LOOPSDONE event
type INTENCLR_LOOPSDONE_Field_1 is
(-- Reset value for the field
Intenclr_Loopsdone_Field_Reset,
-- Disable
Clear)
with Size => 1;
for INTENCLR_LOOPSDONE_Field_1 use
(Intenclr_Loopsdone_Field_Reset => 0,
Clear => 1);
-- Disable interrupt
type INTENCLR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Write '1' to Disable interrupt for STOPPED event
STOPPED : INTENCLR_STOPPED_Field_1 :=
Intenclr_Stopped_Field_Reset;
-- Write '1' to Disable interrupt for SEQSTARTED[0] event
SEQSTARTED : INTENCLR_SEQSTARTED_Field :=
(As_Array => False, Val => 16#0#);
-- Write '1' to Disable interrupt for SEQEND[0] event
SEQEND : INTENCLR_SEQEND_Field :=
(As_Array => False, Val => 16#0#);
-- Write '1' to Disable interrupt for PWMPERIODEND event
PWMPERIODEND : INTENCLR_PWMPERIODEND_Field_1 :=
Intenclr_Pwmperiodend_Field_Reset;
-- Write '1' to Disable interrupt for LOOPSDONE event
LOOPSDONE : INTENCLR_LOOPSDONE_Field_1 :=
Intenclr_Loopsdone_Field_Reset;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
STOPPED at 0 range 1 .. 1;
SEQSTARTED at 0 range 2 .. 3;
SEQEND at 0 range 4 .. 5;
PWMPERIODEND at 0 range 6 .. 6;
LOOPSDONE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Enable or disable PWM module
type ENABLE_ENABLE_Field is
(-- Disabled
Disabled,
-- Enable
Enabled)
with Size => 1;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 1);
-- PWM module enable register
type ENABLE_Register is record
-- Enable or disable PWM module
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.PWM.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;
-- Selects up or up and down as wave counter mode
type MODE_UPDOWN_Field is
(-- Up counter - edge aligned PWM duty-cycle
Up,
-- Up and down counter - center aligned PWM duty cycle
Upanddown)
with Size => 1;
for MODE_UPDOWN_Field use
(Up => 0,
Upanddown => 1);
-- Selects operating mode of the wave counter
type MODE_Register is record
-- Selects up or up and down as wave counter mode
UPDOWN : MODE_UPDOWN_Field := NRF_SVD.PWM.Up;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MODE_Register use record
UPDOWN at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
subtype COUNTERTOP_COUNTERTOP_Field is HAL.UInt15;
-- Value up to which the pulse generator counter counts
type COUNTERTOP_Register is record
-- Value up to which the pulse generator counter counts. This register
-- is ignored when DECODER.MODE=WaveForm and only values from RAM will
-- be used.
COUNTERTOP : COUNTERTOP_COUNTERTOP_Field := 16#3FF#;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for COUNTERTOP_Register use record
COUNTERTOP at 0 range 0 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- Pre-scaler of PWM_CLK
type PRESCALER_PRESCALER_Field is
(-- Divide by 1 (16MHz)
Div_1,
-- Divide by 2 ( 8MHz)
Div_2,
-- Divide by 4 ( 4MHz)
Div_4,
-- Divide by 8 ( 2MHz)
Div_8,
-- Divide by 16 ( 1MHz)
Div_16,
-- Divide by 32 ( 500kHz)
Div_32,
-- Divide by 64 ( 250kHz)
Div_64,
-- Divide by 128 ( 125kHz)
Div_128)
with Size => 3;
for PRESCALER_PRESCALER_Field use
(Div_1 => 0,
Div_2 => 1,
Div_4 => 2,
Div_8 => 3,
Div_16 => 4,
Div_32 => 5,
Div_64 => 6,
Div_128 => 7);
-- Configuration for PWM_CLK
type PRESCALER_Register is record
-- Pre-scaler of PWM_CLK
PRESCALER : PRESCALER_PRESCALER_Field := NRF_SVD.PWM.Div_1;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PRESCALER_Register use record
PRESCALER at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- How a sequence is read from RAM and spread to the compare register
type DECODER_LOAD_Field is
(-- 1st half word (16-bit) used in all PWM channels 0..3
Common,
-- 1st half word (16-bit) used in channel 0..1; 2nd word in channel 2..3
Grouped,
-- 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in ch.3
Individual,
-- 1st half word (16-bit) in ch.0; 2nd in ch.1; ...; 4th in COUNTERTOP
Waveform)
with Size => 2;
for DECODER_LOAD_Field use
(Common => 0,
Grouped => 1,
Individual => 2,
Waveform => 3);
-- Selects source for advancing the active sequence
type DECODER_MODE_Field is
(-- SEQ[n].REFRESH is used to determine loading internal compare registers
Refreshcount,
-- NEXTSTEP task causes a new value to be loaded to internal compare registers
Nextstep)
with Size => 1;
for DECODER_MODE_Field use
(Refreshcount => 0,
Nextstep => 1);
-- Configuration of the decoder
type DECODER_Register is record
-- How a sequence is read from RAM and spread to the compare register
LOAD : DECODER_LOAD_Field := NRF_SVD.PWM.Common;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- Selects source for advancing the active sequence
MODE : DECODER_MODE_Field := NRF_SVD.PWM.Refreshcount;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DECODER_Register use record
LOAD at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
MODE at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-- Amount of playback of pattern cycles
type LOOP_CNT_Field is
(-- Looping disabled (stop at the end of the sequence)
Disabled)
with Size => 16;
for LOOP_CNT_Field use
(Disabled => 0);
-- Amount of playback of a loop
type LOOP_Register is record
-- Amount of playback of pattern cycles
CNT : LOOP_CNT_Field := NRF_SVD.PWM.Disabled;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for LOOP_Register use record
CNT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
---------------------------------
-- PWM_SEQ cluster's Registers --
---------------------------------
-- Amount of values (duty cycles) in this sequence
type CNT_CNT_Field is
(-- Sequence is disabled, and shall not be started as it is empty
Disabled)
with Size => 15;
for CNT_CNT_Field use
(Disabled => 0);
-- Description cluster[0]: Amount of values (duty cycles) in this sequence
type CNT_SEQ_Register is record
-- Amount of values (duty cycles) in this sequence
CNT : CNT_CNT_Field := NRF_SVD.PWM.Disabled;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CNT_SEQ_Register use record
CNT at 0 range 0 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
-- Amount of additional PWM periods between samples loaded into compare
-- register (load every REFRESH.CNT+1 PWM periods)
type REFRESH_CNT_Field is
(-- Update every PWM period
Continuous,
-- Reset value for the field
Refresh_Cnt_Field_Reset)
with Size => 24;
for REFRESH_CNT_Field use
(Continuous => 0,
Refresh_Cnt_Field_Reset => 1);
-- Description cluster[0]: Amount of additional PWM periods between samples
-- loaded into compare register
type REFRESH_SEQ_Register is record
-- Amount of additional PWM periods between samples loaded into compare
-- register (load every REFRESH.CNT+1 PWM periods)
CNT : REFRESH_CNT_Field := Refresh_Cnt_Field_Reset;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for REFRESH_SEQ_Register use record
CNT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype ENDDELAY_SEQ_CNT_Field is HAL.UInt24;
-- Description cluster[0]: Time added after the sequence
type ENDDELAY_SEQ_Register is record
-- Time added after the sequence in PWM periods
CNT : ENDDELAY_SEQ_CNT_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENDDELAY_SEQ_Register use record
CNT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Unspecified
type PWM_SEQ_Cluster is record
-- Description cluster[0]: Beginning address in Data RAM of this
-- sequence
PTR : aliased HAL.UInt32;
-- Description cluster[0]: Amount of values (duty cycles) in this
-- sequence
CNT : aliased CNT_SEQ_Register;
-- Description cluster[0]: Amount of additional PWM periods between
-- samples loaded into compare register
REFRESH : aliased REFRESH_SEQ_Register;
-- Description cluster[0]: Time added after the sequence
ENDDELAY : aliased ENDDELAY_SEQ_Register;
end record
with Size => 128;
for PWM_SEQ_Cluster use record
PTR at 16#0# range 0 .. 31;
CNT at 16#4# range 0 .. 31;
REFRESH at 16#8# range 0 .. 31;
ENDDELAY at 16#C# range 0 .. 31;
end record;
-- Unspecified
type PWM_SEQ_Clusters is array (0 .. 1) of PWM_SEQ_Cluster;
----------------------------------
-- PWM_PSEL cluster's Registers --
----------------------------------
subtype OUT_PSEL_PIN_Field is HAL.UInt5;
-- Connection
type OUT_CONNECT_Field is
(-- Connect
Connected,
-- Disconnect
Disconnected)
with Size => 1;
for OUT_CONNECT_Field use
(Connected => 0,
Disconnected => 1);
-- Description collection[0]: Output pin select for PWM channel 0
type OUT_PSEL_Register is record
-- Pin number
PIN : OUT_PSEL_PIN_Field := 16#1F#;
-- unspecified
Reserved_5_30 : HAL.UInt26 := 16#3FFFFFF#;
-- Connection
CONNECT : OUT_CONNECT_Field := NRF_SVD.PWM.Disconnected;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OUT_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;
-- Description collection[0]: Output pin select for PWM channel 0
type OUT_PSEL_Registers is array (0 .. 3) of OUT_PSEL_Register;
-- Unspecified
type PWM_PSEL_Cluster is record
-- Description collection[0]: Output pin select for PWM channel 0
OUT_k : aliased OUT_PSEL_Registers;
end record
with Size => 128;
for PWM_PSEL_Cluster use record
OUT_k at 0 range 0 .. 127;
end record;
---------------------------------
-- PWM_SEQ cluster's Registers --
---------------------------------
----------------------------------
-- PWM_PSEL cluster's Registers --
----------------------------------
---------------------------------
-- PWM_SEQ cluster's Registers --
---------------------------------
----------------------------------
-- PWM_PSEL cluster's Registers --
----------------------------------
-----------------
-- Peripherals --
-----------------
-- Pulse Width Modulation Unit 0
type PWM_Peripheral is record
-- Stops PWM pulse generation on all channels at the end of current PWM
-- period, and stops sequence playback
TASKS_STOP : aliased HAL.UInt32;
-- Description collection[0]: Loads the first PWM value on all enabled
-- channels from sequence 0, and starts playing that sequence at the
-- rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes PWM
-- generation to start it was not running.
TASKS_SEQSTART : aliased TASKS_SEQSTART_Registers;
-- Steps by one value in the current sequence on all enabled channels if
-- DECODER.MODE=NextStep. Does not cause PWM generation to start it was
-- not running.
TASKS_NEXTSTEP : aliased HAL.UInt32;
-- Response to STOP task, emitted when PWM pulses are no longer
-- generated
EVENTS_STOPPED : aliased HAL.UInt32;
-- Description collection[0]: First PWM period started on sequence 0
EVENTS_SEQSTARTED : aliased EVENTS_SEQSTARTED_Registers;
-- Description collection[0]: Emitted at end of every sequence 0, when
-- last value from RAM has been applied to wave counter
EVENTS_SEQEND : aliased EVENTS_SEQEND_Registers;
-- Emitted at the end of each PWM period
EVENTS_PWMPERIODEND : aliased HAL.UInt32;
-- Concatenated sequences have been played the amount of times defined
-- in LOOP.CNT
EVENTS_LOOPSDONE : aliased HAL.UInt32;
-- Shortcut register
SHORTS : aliased SHORTS_Register;
-- Enable or disable interrupt
INTEN : aliased INTEN_Register;
-- Enable interrupt
INTENSET : aliased INTENSET_Register;
-- Disable interrupt
INTENCLR : aliased INTENCLR_Register;
-- PWM module enable register
ENABLE : aliased ENABLE_Register;
-- Selects operating mode of the wave counter
MODE : aliased MODE_Register;
-- Value up to which the pulse generator counter counts
COUNTERTOP : aliased COUNTERTOP_Register;
-- Configuration for PWM_CLK
PRESCALER : aliased PRESCALER_Register;
-- Configuration of the decoder
DECODER : aliased DECODER_Register;
-- Amount of playback of a loop
LOOP_k : aliased LOOP_Register;
-- Unspecified
SEQ : aliased PWM_SEQ_Clusters;
-- Unspecified
PSEL : aliased PWM_PSEL_Cluster;
end record
with Volatile;
for PWM_Peripheral use record
TASKS_STOP at 16#4# range 0 .. 31;
TASKS_SEQSTART at 16#8# range 0 .. 63;
TASKS_NEXTSTEP at 16#10# range 0 .. 31;
EVENTS_STOPPED at 16#104# range 0 .. 31;
EVENTS_SEQSTARTED at 16#108# range 0 .. 63;
EVENTS_SEQEND at 16#110# range 0 .. 63;
EVENTS_PWMPERIODEND at 16#118# range 0 .. 31;
EVENTS_LOOPSDONE at 16#11C# range 0 .. 31;
SHORTS at 16#200# 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;
MODE at 16#504# range 0 .. 31;
COUNTERTOP at 16#508# range 0 .. 31;
PRESCALER at 16#50C# range 0 .. 31;
DECODER at 16#510# range 0 .. 31;
LOOP_k at 16#514# range 0 .. 31;
SEQ at 16#520# range 0 .. 255;
PSEL at 16#560# range 0 .. 127;
end record;
-- Pulse Width Modulation Unit 0
PWM0_Periph : aliased PWM_Peripheral
with Import, Address => PWM0_Base;
-- Pulse Width Modulation Unit 1
PWM1_Periph : aliased PWM_Peripheral
with Import, Address => PWM1_Base;
-- Pulse Width Modulation Unit 2
PWM2_Periph : aliased PWM_Peripheral
with Import, Address => PWM2_Base;
end NRF_SVD.PWM;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.