content
stringlengths 23
1.05M
|
|---|
-----------------------------------------------------------------------
-- asf-events-phases -- Lifecycle phase event
-- Copyright (C) 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.Events;
-- The <b>ASF.Events.Phases</b> package defines the phase event which represents
-- the beginning or ending of processing for a particular phase of the request lifecycle.
--
-- This package is an Ada adaptation for the Java Server Faces Specification
-- JSR 314 - 3.4.2 Application Events.
package ASF.Events.Phases is
type Phase_Type is (ANY_PHASE,
RESTORE_VIEW,
APPLY_REQUEST_VALUES,
PROCESS_VALIDATION,
UPDATE_MODEL_VALUES,
INVOKE_APPLICATION,
RENDER_RESPONSE);
-- ------------------------------
-- Phase event
-- ------------------------------
-- The <b>Phase_Event</b> represents the phase event notifying application of the
-- current lifecycly processing.
type Phase_Event (Phase : Phase_Type) is new Util.Events.Event with null record;
-- ------------------------------
-- Phase listener
-- ------------------------------
-- The <b>Phase_Listener</b> is an interface which allows application to be called
-- and receive the <b>Phase_Event</b> during the ASF lifecycle processing.
type Phase_Listener is limited interface and Util.Events.Event_Listener;
type Phase_Listener_Access is access all Phase_Listener'Class;
-- Notifies that the lifecycle phase described by the event is about to begin.
procedure Before_Phase (Listener : in Phase_Listener;
Event : in Phase_Event'Class) is null;
-- Notifies that the lifecycle phase described by the event has finished.
procedure After_Phase (Listener : in Phase_Listener;
Event : in Phase_Event'Class) is null;
-- Return the phase that this listener is interested in processing the <b>Phase_Event</b>
-- events. If the listener is interested by several events, it should return <b>ANY_PHASE</b>.
function Get_Phase (Listener : in Phase_Listener) return Phase_Type is abstract;
end ASF.Events.Phases;
|
with Ada.Containers; use Ada.Containers;
with AUnit.Assertions; use AUnit.Assertions;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Missing.AUnit.Assertions; use Missing.AUnit.Assertions;
with Rejuvenation; use Rejuvenation;
with Rejuvenation.Node_Locations; use Rejuvenation.Node_Locations;
with Rejuvenation.Placeholders; use Rejuvenation.Placeholders;
with Rejuvenation.Simple_Factory; use Rejuvenation.Simple_Factory;
with String_Vectors; use String_Vectors;
with String_Sets; use String_Sets;
with String_Sets_Utils; use String_Sets_Utils;
with Make_Ada; use Make_Ada;
package body Test_Placeholders is
procedure Assert is new Generic_Assert (Natural);
procedure Assert is new Generic_Assert (Count_Type);
procedure Assert is new Generic_Assert (Ada_Node_Kind_Type);
-- Test Functions
procedure Test_Defining_Name_Placeholder (T : in out Test_Case'Class);
procedure Test_Defining_Name_Placeholder (T : in out Test_Case'Class) is
pragma Unreferenced (T);
Placeholder_Name : constant String := "$M____MyName12";
-- TODO make a separate test case to document that
-- two consecutive underlines not permitted
-- in normal Ada variables,
-- but allowed in placeholder names!
Fragment : constant String :=
Make_Object_Declaration_Subtype_Indication
(Defining_Identifier_List => To_Vector (Placeholder_Name, 1));
Unit : constant Analysis_Unit :=
Analyze_Fragment (Fragment, Object_Decl_Rule);
begin
Assert
(Condition => Is_Placeholder_Name (Placeholder_Name),
Message =>
"Precondition violated: "
& "Name is unexpectedly not a placeholder name");
Assert
(Actual => Unit.Root.Kind, Expected => Ada_Object_Decl,
Message => "Unexpected kind of 'Unit.Root'");
declare
O_D : constant Object_Decl := Unit.Root.As_Object_Decl;
Ids : constant Defining_Name_List := O_D.F_Ids;
begin
Assert
(Actual => Ids.Children_Count, Expected => 1,
Message => "Unexpected count of children of 'Ids'");
Assert
(Condition => not Is_Placeholder (Ids),
Message => "Unexpected 'Ids' is placeholder");
Assert
(Condition => Is_Placeholder (Ids.First_Child),
Message => "Unexpected not a placeholder");
end;
end Test_Defining_Name_Placeholder;
procedure Test_Stmt_Placeholder (T : in out Test_Case'Class);
procedure Test_Stmt_Placeholder (T : in out Test_Case'Class) is
pragma Unreferenced (T);
Placeholder_Name : constant String := "$M_Aap_Noot_Mies";
Fragment : constant String :=
Make_Procedure_Call_Statement (Procedure_Name => Placeholder_Name);
Unit : constant Analysis_Unit :=
Analyze_Fragment (Fragment, Call_Stmt_Rule);
begin
Assert
(Condition => Is_Placeholder_Name (Placeholder_Name),
Message =>
"Precondition violated: "
& "Name is unexpectedly not a placeholder name");
Assert
(Actual => Unit.Root.Kind, Expected => Ada_Call_Stmt,
Message => "Unexpected kind of 'Unit.Root'");
Assert
(Condition => Is_Placeholder (Unit.Root),
Message => "Unexpected not a placeholder");
end Test_Stmt_Placeholder;
procedure Test_Subprogram_Identifier_Placeholder
(T : in out Test_Case'Class);
procedure Test_Subprogram_Identifier_Placeholder
(T : in out Test_Case'Class)
is
pragma Unreferenced (T);
Placeholder_Name : constant String := "$M_379";
Fragment : constant String :=
Make_Procedure_Call_Statement
(Procedure_Name => Placeholder_Name,
Actual_Parameter_Part => To_Vector ("3", 1) & "True" & "max");
Unit : constant Analysis_Unit :=
Analyze_Fragment (Fragment, Call_Stmt_Rule);
begin
Assert
(Condition => Is_Placeholder_Name (Placeholder_Name),
Message =>
"Precondition violated: "
& "Name is unexpectedly not a placeholder name");
Assert
(Actual => Unit.Root.Kind, Expected => Ada_Call_Stmt,
Message => "Unexpected kind of 'Unit.Root'");
declare
C_S : constant Call_Stmt := Unit.Root.As_Call_Stmt;
Call : constant Libadalang.Analysis.Name := C_S.F_Call;
begin
Assert
(Actual => Call.Kind, Expected => Ada_Call_Expr,
Message => "Unexpected kind of Call");
Assert
(Condition => not Is_Placeholder (Call),
Message => "Unexpected 'Call' is placeholder");
declare
N : constant Libadalang.Analysis.Name := Call.As_Call_Expr.F_Name;
begin
Assert
(Condition => Is_Placeholder (N),
Message => "Unexpected not a placeholder");
end;
end;
end Test_Subprogram_Identifier_Placeholder;
procedure Test_Enum_Literal_Decl_Placeholder (T : in out Test_Case'Class);
procedure Test_Enum_Literal_Decl_Placeholder (T : in out Test_Case'Class) is
pragma Unreferenced (T);
Placeholder_Name : constant String := "$S__";
Fragment : constant String :=
Make_Enumeration_Type_Definition (To_Vector (Placeholder_Name, 1));
Unit : constant Analysis_Unit :=
Analyze_Fragment (Fragment, Enum_Type_Def_Rule);
begin
Assert
(Condition => Is_Placeholder_Name (Placeholder_Name),
Message =>
"Precondition violated: "
& "Name is unexpectedly not a placeholder name");
Assert
(Actual => Unit.Root.Kind, Expected => Ada_Enum_Type_Def,
Message => "Unexpected kind of 'Unit.Root'");
declare
E_T_D : constant Enum_Type_Def := Unit.Root.As_Enum_Type_Def;
E_L_D_L : constant Enum_Literal_Decl_List := E_T_D.F_Enum_Literals;
begin
Assert
(Condition => not Is_Placeholder (E_T_D),
Message => "Unexpected 'E_T_D' is placeholder");
Assert
(Condition => not Is_Placeholder (E_L_D_L),
Message => "Unexpected 'E_L_D_L' is placeholder");
Assert
(Actual => E_L_D_L.Children_Count, Expected => 1,
Message => "Unexpected count of children of 'E_L_D_L'");
Assert
(Condition => Is_Placeholder (E_L_D_L.First_Child),
Message => "Unexpected not a placeholder");
end;
end Test_Enum_Literal_Decl_Placeholder;
procedure Test_Param_Assoc_Placeholder (T : in out Test_Case'Class);
procedure Test_Param_Assoc_Placeholder (T : in out Test_Case'Class) is
pragma Unreferenced (T);
Placeholder_Name : constant String := "$M_S";
Fragment : constant String :=
Make_Function_Call
(Actual_Parameter_Part => To_Vector (Placeholder_Name, 1));
Unit : constant Analysis_Unit := Analyze_Fragment (Fragment, Expr_Rule);
begin
Assert
(Condition => Is_Placeholder_Name (Placeholder_Name),
Message =>
"Precondition violated: "
& "Name is unexpectedly not a placeholder name");
Assert
(Actual => Unit.Root.Kind, Expected => Ada_Call_Expr,
Message => "Unexpected kind of 'Unit.Root'");
declare
C_E : constant Call_Expr := Unit.Root.As_Call_Expr;
S : constant Ada_Node := C_E.F_Suffix;
begin
Assert
(Condition => not Is_Placeholder (S),
Message => "Unexpected 'S' is placeholder");
Assert
(Actual => S.Kind, Expected => Ada_Assoc_List,
Message => "Unexpected kind of 'S'");
declare
A_L : constant Assoc_List := S.As_Assoc_List;
begin
Assert
(Actual => A_L.Children_Count, Expected => 1,
Message => "Unexpected count of children of 'A_L'");
Assert
(Condition => Is_Placeholder (A_L.First_Child),
Message => "Unexpected not a placeholder");
end;
end;
end Test_Param_Assoc_Placeholder;
procedure Assert_Nodes_In_Order
(Nodes : Node_List.Vector; Message : String);
procedure Assert_Nodes_In_Order (Nodes : Node_List.Vector; Message : String)
is
Last_Position : Natural := 0;
begin
for Node of Nodes loop
declare
Start_Position : constant Positive := Start_Offset (Node);
begin
Assert
(Condition => Last_Position < Start_Position,
Message =>
Message & ASCII.LF & "Nodes not in order" & ASCII.LF &
"Last_Position = " & Last_Position'Image & ASCII.LF &
"Start_Position = " & Start_Position'Image);
Last_Position := End_Offset (Node);
end;
end loop;
end Assert_Nodes_In_Order;
procedure Test_Placeholder_Nodes (T : in out Test_Case'Class);
procedure Test_Placeholder_Nodes (T : in out Test_Case'Class) is
pragma Unreferenced (T);
procedure Test_Placeholder_Nodes
(Fragment : String; Rule : Grammar_Rule;
NrOf_Placeholders : Count_Type);
procedure Test_Placeholder_Nodes
(Fragment : String; Rule : Grammar_Rule;
NrOf_Placeholders : Count_Type)
is
Unit : constant Analysis_Unit := Analyze_Fragment (Fragment, Rule);
Placeholders : constant Node_List.Vector :=
Get_Placeholders (Unit.Root);
begin
Assert
(Actual => Placeholders.Length, Expected => NrOf_Placeholders,
Message => "Number of placeholder nodes differ");
Assert_Nodes_In_Order
(Placeholders, "Check placeholders in order failed.");
end Test_Placeholder_Nodes;
begin
Test_Placeholder_Nodes ("$S_Bla", Name_Rule, 1);
Test_Placeholder_Nodes
("if $S_Cond then $M_True_Stmts; else $M_False_Stmts; end if;",
If_Stmt_Rule, 3);
Test_Placeholder_Nodes
("if $S_Cond then $M_Stmts; else $M_Stmts; end if;", If_Stmt_Rule, 3);
Test_Placeholder_Nodes
("my_Str : constant String := ""$S_Cond"";", Object_Decl_Rule, 0);
end Test_Placeholder_Nodes;
procedure Test_Placeholder_Names (T : in out Test_Case'Class);
procedure Test_Placeholder_Names (T : in out Test_Case'Class) is
pragma Unreferenced (T);
procedure Test_Placeholder_Names
(Fragment : String; Rule : Grammar_Rule; Expected : Set);
procedure Test_Placeholder_Names
(Fragment : String; Rule : Grammar_Rule; Expected : Set)
is
Pattern : constant Analysis_Unit := Analyze_Fragment (Fragment, Rule);
Actual : constant String_Sets.Set :=
Get_Placeholder_Names (Pattern.Root);
begin
Assert
(Condition => Actual = Expected,
Message =>
"Placeholder names differ" & ASCII.LF & "Actual = " &
To_String (Actual) & ASCII.LF & "Expected = " &
To_String (Expected));
end Test_Placeholder_Names;
Placeholder_A : constant String := "$S_Bla";
Placeholder_C : constant String := "$S_Cond";
Placeholder_T : constant String := "$M_True_Stmts";
Placeholder_F : constant String := "$M_False_Stmts";
Placeholder_S : constant String := "$M_Stmts";
begin
Test_Placeholder_Names
("$S_Bla", Name_Rule, String_Sets.To_Set (Placeholder_A));
Test_Placeholder_Names
("if " & Placeholder_C & " then " & Placeholder_T & "; else " &
Placeholder_F & "; end if;",
If_Stmt_Rule,
From_Vector
(String_Vectors.To_Vector (Placeholder_C, 1) & Placeholder_T &
Placeholder_F));
Test_Placeholder_Names
("if " & Placeholder_C & " then " & Placeholder_S & "; else " &
Placeholder_S & "; end if;",
If_Stmt_Rule, From_Vector (Placeholder_C & Placeholder_S));
Test_Placeholder_Names
("my_Str : constant String := ""$S_Cond"";", Object_Decl_Rule,
String_Sets.Empty_Set);
end Test_Placeholder_Names;
-- Test plumbing
overriding function Name
(T : Placeholders_Test_Case) return AUnit.Message_String
is
pragma Unreferenced (T);
begin
return AUnit.Format ("Patterns Placeholders");
end Name;
overriding procedure Register_Tests (T : in out Placeholders_Test_Case) is
begin
Registration.Register_Routine
(T, Test_Defining_Name_Placeholder'Access,
"Defining Name Placeholder");
Registration.Register_Routine
(T, Test_Stmt_Placeholder'Access, "Stmt Placeholder");
Registration.Register_Routine
(T, Test_Subprogram_Identifier_Placeholder'Access,
"Subprogram Identifier Placeholder");
Registration.Register_Routine
(T, Test_Enum_Literal_Decl_Placeholder'Access,
"Enum Literal Declaration Placeholder");
Registration.Register_Routine
(T, Test_Param_Assoc_Placeholder'Access, "Param Assoc Placeholder");
-- TODO Designator Identifier (e.g. $S_X => 12) and
-- Value Identifier (e.g. param_name => $S_Value) are not Param Assocs
Registration.Register_Routine
(T, Test_Placeholder_Nodes'Access, "Placeholder nodes");
Registration.Register_Routine
(T, Test_Placeholder_Names'Access, "Placeholder names");
end Register_Tests;
end Test_Placeholders;
|
with Ada.Text_IO;use Ada.Text_IO;
with Ada.Float_Text_IO;use Ada.Float_Text_IO;
procedure newton is
Number: Float;
Accuracy: Float;
a0: Float;
ak: Float;
begin
put("Enter your number : ");
get(Number);
put("Enter the accuracy : ");
get(Accuracy);
a0 := 1.0;
ak := 1.0;
loop
a0 := ak;
ak := (a0 + Number / a0) / 2.0;
exit when ak - a0 < Accuracy or (ak ** 2) - Number < Accuracy;
end loop;
put("the square root is : " &Float'Image(ak));
end newton;
|
package body Swaps is
procedure Swap (Value_1 : in out Integer; Value_2 : in out Integer) is
Tmp : Integer;
begin
Tmp := Value_1;
Value_1 := Value_2;
Value_2 := Tmp;
end Swap;
end Swaps;
|
with Interfaces;
use Interfaces;
package STM32.F4.USART is
pragma Pure;
type Status_Register is record
PE: Boolean; -- Psrity error
FE: Boolean; -- Framing error
NF: Boolean; -- Noise detection flag
ORE: Boolean; -- Overrun error
IDLE: Boolean; -- IDLE line detected
RXNE: Boolean; -- Read data register not empty
TC: Boolean; -- Transmission complete
TXE: Boolean; -- Transmit data register empty
LBD: Boolean; -- LIN break detection flag
CTS: Boolean; -- CTS flag
Reserved: Integer range 0 .. 2**22 - 1;
end record with Size => 32;
for Status_Register use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBD at 0 range 8 .. 8;
CTS at 0 range 9 .. 9;
Reserved at 0 range 10 .. 31;
end record;
type Baud_Rate_Register is record
DIV_Fraction: Integer range 0 .. 2**4 - 1; -- Fraction of USARTDIV
DIV_Mantissa: Integer range 0 .. 2**12 - 1; -- Mantissa of USARTDIV
Reserved: Integer range 0 .. 2**16 - 1;
end record with Size => 32;
for Baud_Rate_Register use record
DIV_Fraction at 0 range 0 .. 3;
DIV_Mantissa at 0 range 4 .. 15;
Reserved at 0 range 16 .. 31;
end record;
-- Parity selection bit field
type Parity is (
Even_Parity, -- Parity bit is cleared when even number of data bits is set, set otherwise
Odd_Parity -- Parity bit is set when even number of data bits is set, cleared otherwise
);
for Parity use (
Even_Parity => 2#0#,
Odd_Parity => 2#1#
);
-- Wakeup method field
type Wakeup_Method is (
Idle_Line, -- Wakeup on IDLE line detect
Address_Mark -- Wakeup on address mark detect
);
for Wakeup_Method use (
Idle_Line => 2#0#,
Address_Mark => 2#1#
);
-- Data word length
type Word_Length is (
Word_8_Bits, -- Data word (with parity bit if enabled) consists of 8 bits
Word_9_Bits -- Data word (with parity bit if enabled) consists of 9 bits
);
for Word_Length use (
Word_8_Bits => 2#0#,
Word_9_Bits => 2#1#
);
type Control_Register_1 is record
SBK: Boolean; -- Send break
RWU: Boolean; -- Receiver wakeup
RE: Boolean; -- Receiver enable
TE: Boolean; -- Trnsmitter enable
IDLEIE: Boolean; -- IDLE interrupt enable
RXNEIE: Boolean; -- RXNE interrupt enable
TCIE: Boolean; -- Transmission complete interrupt enable
TXEIE: Boolean; -- TXE interrupt enable
PEIE: Boolean; -- PE interrupt enable
PS: Parity; -- Parity selection
PCE: Boolean; -- Parity control enable
WAKE: Wakeup_Method; -- Wakeup method
M: Word_Length; -- Word length
UE: Boolean; -- USART enable
Reserved_14: Integer range 0 .. 2**1 - 1;
OVER8: Boolean; -- Oversampling mode
Reserved: Integer range 0 .. 2**16 - 1;
end record with Size => 32;
for Control_Register_1 use record
SBK at 0 range 0 .. 0;
RWU at 0 range 1 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
IDLEIE at 0 range 4 .. 4;
RXNEIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
TXEIE at 0 range 7 .. 7;
PEIE at 0 range 8 .. 8;
PS at 0 range 9 .. 9;
PCE at 0 range 10 .. 10;
WAKE at 0 range 11 .. 11;
M at 0 range 12 .. 12;
UE at 0 range 13 .. 13;
Reserved_14 at 0 range 14 .. 14;
OVER8 at 0 range 15 .. 15;
Reserved at 0 range 16 .. 31;
end record;
-- Line break detection length
type Lin_Break_Detection_Length is (
Lin_10_Bit_Break_Detection, -- 10 bits break is detected
Lin_11_Bit_Break_Detection -- 11 bits break is detected
);
for Lin_Break_Detection_Length use (
LIN_10_Bit_Break_Detection => 2#0#,
LIN_11_Bit_Break_Detection => 2#1#
);
type Clock_Phase is (
First_Edge_Capture, -- Data captured on first clock edge
Second_Edge_Capture -- Deta set on first clock edge, captured on second edge
);
for Clock_Phase use (
First_Edge_Capture => 2#0#,
Second_Edge_Capture => 2#1#
);
type Clock_Polarity is (
Positive_Pulse, -- Steady low value on CK outside transmission window
Negative_Pulse -- Steady high value on CK outside transmission window
);
for Clock_Polarity use (
Positive_Pulse => 2#0#,
Negative_Pulse => 2#1#
);
-- Number of stop bits
type Stop_Bit_Count is(
Stop_1_Bit, -- 1 stop bit
Stop_0_5_Bits, -- 0.5 stop bits
Stop_2_Bits, -- 2 stop bits
Stop_1_5_Bits -- 1.5 stop bits
);
for Stop_Bit_Count use (
Stop_1_Bit => 2#00#,
Stop_0_5_Bits => 2#01#,
Stop_2_Bits => 2#10#,
Stop_1_5_Bits => 2#11#
);
type Control_Register_2 is record
ADD: Integer range 0 .. 2**4 - 1; -- Address of the USART node
Reserved_4: Integer range 0 .. 1;
LBDL: LIN_Break_Detection_Length; -- LIN break detection length selection
LBDIE: Boolean; -- LIN break detection interrupt enable
Reserved_7: Integer range 0 .. 1;
LBCL: Boolean; -- Last bit clock pulse output (this bit is not available for UART4 and UART5)
CPHA: Clock_Phase; -- Clock phase
CPOL: Clock_Polarity; -- Clock polarity
CLKEN: Boolean; -- Clock enable
STOP: Stop_Bit_Count; -- STOP bits
LINEN: Boolean; -- LIN mode enable
Reserved: Integer range 0 .. 2**17 - 1;
end record with Size => 32;
for Control_Register_2 use record
ADD at 0 range 0 .. 3;
Reserved_4 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7 at 0 range 7 .. 7;
LBCL at 0 range 8 .. 8;
CPHA at 0 range 9 .. 9;
CPOL at 0 range 10 .. 10;
CLKEN at 0 range 11 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
Reserved at 0 range 15 .. 31;
end record;
type Control_Register_3 is record
EIE: Boolean; -- Error interrupt enable
IREN: Boolean; -- IrDA mode enable
IRLP: Boolean; -- IrDA low power
HDSEL: Boolean; -- Half duplex selection
NACK: Boolean; -- Smartcard NACK enable
SCEN: Boolean; -- Smartcard mode enable
DMAR: Boolean; -- DMA enable receiver
DMAT: Boolean; -- DMA enable transmitter
RTSE: Boolean; -- RTS enable
CTSE: Boolean; -- CTS enable
CTSIE: Boolean; -- CTS interrupt enable
ONEBIT: Boolean; -- One bit sampling enable
Reserved: Integer range 0 .. 2 ** 20 - 1;
end record with Size => 32;
for Control_Register_3 use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
NACK at 0 range 4 .. 4;
SCEN at 0 range 5 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
RTSE at 0 range 8 .. 8;
CTSE at 0 range 9 .. 9;
CTSIE at 0 range 10 .. 10;
ONEBIT at 0 range 11 .. 11;
Reserved at 0 range 12 .. 31;
end record;
type Guard_Time_and_Prescaler_Register is record
PSC: Integer range 0 .. 2**8 - 1; -- Prescaler value
GT: Integer range 0 .. 2**8 - 1; -- Guard time value in baud clocks
Reserved: Integer range 0 .. 2**16 - 1;
end record with Size => 32;
for Guard_Time_and_Prescaler_Register use record
PSC at 0 range 0 .. 7;
GT at 0 range 8 .. 15;
Reserved at 0 range 16 .. 31;
end record;
type USART_Registers is record
SR: Status_Register; -- Status register
DR: Unsigned_32; -- Data register
BRR: Baud_Rate_Register; -- Baud rate register
CR1: Control_Register_1; -- Control register 1
CR2: Control_Register_2; -- Control register 2
CR3: Control_Register_3; -- Control register 3
GTPR: Guard_Time_and_Prescaler_Register; -- Guard time and prescaler register
end record with Volatile;
for USART_Registers use record
SR at 16#00# range 0 .. 31;
DR at 16#04# range 0 .. 31;
BRR at 16#08# range 0 .. 31;
CR1 at 16#0C# range 0 .. 31;
CR2 at 16#10# range 0 .. 31;
CR3 at 16#14# range 0 .. 31;
GTPR at 16#18# range 0 .. 31;
end record;
end STM32.F4.USART;
|
with Ada.Text_IO;
with Ada.Long_Integer_Text_IO;
package body Problem_02 is
package IO renames Ada.Text_IO;
procedure Solve is
n : Long_Integer;
n_1 : Long_Integer := 1;
n_2 : Long_Integer := 0;
sum : Long_Integer := 0;
begin
loop
n := n_1 + n_2;
exit when n > 4_000_000;
if n mod 2 = 0 then
sum := sum + n;
end if;
n_2 := n_1;
n_1 := n;
end loop;
Ada.Long_Integer_Text_IO.Put(sum);
IO.New_Line;
end Solve;
end Problem_02;
|
with RTCH.Maths.Vectors;
with RTCH.Maths.Points;
package RTCH.Maths.Tuples.Steps is
-- @given ^a ← tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Tuple_A (X, Y, Z, W : Float);
-- @then ^a.x = ([-+]?\d+\.?\d*)$
procedure Then_A_X_Is (Expected : Float);
-- @and ^a.y = ([-+]?\d+\.?\d*)$
procedure And_A_Y_Is (Expected : Float);
-- @and ^a.z = ([-+]?\d+\.?\d*)$
procedure And_A_Z_Is (Expected : Float);
-- @and ^a.w = ([-+]?\d+\.?\d*)$
procedure And_A_W_Is (Expected : Float);
-- @and ^a is a point$
procedure And_A_Is_A_Point;
-- @and ^a is not a vector$
procedure And_A_Is_Not_A_Vector;
-- @and ^a is not a point$
procedure And_A_Is_Not_A_Point;
-- @and ^a is a vector$
procedure And_A_Is_A_Vector;
-- @given ^p ← point\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Point_P (X, Y, Z : Float);
-- @then ^p = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_P_Is_A_Tuple (X, Y, Z, W : Float);
-- @given ^v ← vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Vector_V (X, Y, Z : Float);
-- @then ^v = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_V_Is_A_Tuple (X, Y, Z, W : Float);
-- @given ^a1 ← tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Tuple_A1 (X, Y, Z, W : Float);
-- @given ^a2 ← tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Tuple_A2 (X, Y, Z, W : Float);
-- @then ^a1 \+ a2 = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_A1_Plus_A2_Is (X, Y, Z, W : Float);
-- @given ^p1 ← point\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Point_P1 (X, Y, Z : Float);
-- @and ^p2 ← point\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure And_Given_Point_P2 (X, Y, Z : Float);
-- @then ^p1 - p2 = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_P1_Minus_P2_Is_Vector (X, Y, Z : Float);
-- @then ^p - v = point\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_P_Minus_V_Is_Point (X, Y, Z : Float);
-- @given ^v1 ← vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Vector_V1 (X, Y, Z : Float);
-- @and ^v2 ← vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure And_Given_Vector_V2 (X, Y, Z : Float);
-- @then ^v1 - v2 = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_V1_Minus_V2_Is_Vector (X, Y, Z : Float);
-- @given ^zero ← vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Given_Zero_Vector (X, Y, Z : Float);
-- @then ^zero - v = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_Zero_Minus_V_Is_Vector (X, Y, Z : Float);
-- @then ^-a = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_Tuple_Is_Negative_A (X, Y, Z, W : Float);
-- @then ^a \* ([-+]?\d+\.?\d*) = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_A_Times_Scalar_Is_Tuple (Scalar, X, Y, Z, W : Float);
-- @then ^a / ([-+]?\d+\.?\d*) = tuple\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_A_Divide_By_Scalar_Is_Tuple (Scalar, X, Y, Z, W : Float);
-- @then ^magnitude\(v\) = ([-+]?\d+\.?\d*)$
procedure Then_Magnitude_Of_V_Is (Result : Float);
-- @then ^magnitude\(v\) = √([-+]?\d+\.?\d*)$
procedure Then_Magnitude_Of_V_Is_Sqrt_Of (Result : Float);
-- @then ^normalize\(v\) = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_Normalise_V_Is_Vector (X, Y, Z : Float);
-- @then ^normalize\(v\) = approximately vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_Normalise_V_Is_Approximately_Vector (X, Y, Z : Float);
-- @when ^norm ← normalize\(v\)$
procedure When_Normalise_V_As_Norm;
-- @then ^magnitude\(norm\) = 1$
procedure Then_Magnitude_Norm_Is_One;
-- @then ^dot\(v1, v2\) = ([-+]?\d+\.?\d*)$
procedure Then_Dot_Of_V1_And_V2_Is (Scalar : Float);
-- @then ^cross\(v1, v2\) = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure Then_Cross_Of_V1_And_V2_Is (X, Y, Z : Float);
-- @and ^cross\(v2, v1\) = vector\(([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*), ([-+]?\d+\.?\d*)\)$
procedure And_Cross_Of_V2_And_V1_Is (X, Y, Z : Float);
private
A : Tuple;
P : Points.Point;
V : Vectors.Vector;
A1 : Tuple;
A2 : Tuple;
P1 : Points.Point;
P2 : Points.Point;
V1 : Vectors.Vector;
V2 : Vectors.Vector;
Zero : Vectors.Vector;
Norm : Vectors.Vector;
end RTCH.Maths.Tuples.Steps;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
procedure Hello is
type Hello_Integer is array (Positive range 2 .. 4) of Integer;
V : hello_integer := (3, 5, 7);
procedure Say_Hello_To (Name : String) is
begin
Put ("hello ");
Put_Line (Name);
end Say_Hello_To;
begin
if Argument_Count = 1 then
Say_Hello_To (Argument (1));
else
Put_Line ("You need a name!");
Put_Line ("./hello name");
end if;
for I in V'first .. V'Last loop
Put_Line (Integer'Image (V (I)));
end loop;
end;
|
with STM32.GPIO; use STM32.GPIO;
with mpu6000_spi; use mpu6000_spi;
with Config; use Config;
with Interfaces; use Interfaces;
--
-- Accel is MPU 6000
--
package spi_accel is
procedure init;
type accel_data is
record
X, Y, Z : Short_Integer;
GX, GY, GZ : Short_Integer;
end record;
function read return accel_data;
function id (product : out Unsigned_8) return Unsigned_8;
private
gyro : Six_Axis_Accelerometer
(Port => SPI_Accel_Port'Access,
Chip_Select => CS_ACCEL'Access);
end spi_accel;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2021 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package Orka.Integrators is
pragma Pure;
generic
type Element_Type is private;
type Duration_Type is digits <>;
with function "*" (Left : Duration_Type; Right : Element_Type) return Element_Type is <>;
with function "+" (Left, Right : Element_Type) return Element_Type is <>;
function RK4
(Y : Element_Type;
DT : Duration_Type;
F : not null access function (Y : Element_Type; DT : Duration_Type) return Element_Type)
return Element_Type;
-- Return the change to Y for the given DT time step using
-- the Runge-Kutta 4th order method
--
-- The returned value must be added to Y to perform numerical integration.
-- Do Y := Result + Y if Y is a vector and Y := Result * Y if Y is a quaternion.
--
-- If F represent a time-variant system, that is, F depends on a time T,
-- then you must compute the derivative at time T + DT. In this case you
-- must keep track of T yourself and add it to the given DT.
--
-- For example:
--
-- Q := Quaternions.Normalize (RK4 (Q, 0.1, Get_Angular_Velocity'Access) * Q);
end Orka.Integrators;
|
-----------------------------------------------------------------------
-- awa-mail -- Mail module
-- 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 AWA.Modules.Beans;
with AWA.Modules.Get;
with AWA.Mail.Beans;
with AWA.Mail.Components.Factory;
with AWA.Applications;
with ASF.Requests.Mockup;
with ASF.Responses.Mockup;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Log.Loggers;
package body AWA.Mail.Modules is
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Mail.Module");
package Register is new AWA.Modules.Beans (Module => Mail_Module,
Module_Access => Mail_Module_Access);
-- ------------------------------
-- Initialize the mail module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Mail_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the mail module");
-- Add the Mail UI components.
App.Add_Components (AWA.Mail.Components.Factory.Definition);
-- Register here any bean class, servlet, filter.
Register.Register (Plugin => Plugin,
Name => "AWA.Mail.Beans.Mail_Bean",
Handler => AWA.Mail.Beans.Create_Mail_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
end Initialize;
-- ------------------------------
-- Configures the module after its initialization and after having read its XML configuration.
-- ------------------------------
overriding
procedure Configure (Plugin : in out Mail_Module;
Props : in ASF.Applications.Config) is
Mailer : constant String := Props.Get ("mailer", "smtp");
begin
Plugin.Mailer := AWA.Mail.Clients.Factory (Mailer, Props);
end Configure;
-- ------------------------------
-- Create a new mail message.
-- ------------------------------
function Create_Message (Plugin : in Mail_Module)
return AWA.Mail.Clients.Mail_Message_Access is
begin
return Plugin.Mailer.Create_Message;
end Create_Message;
-- ------------------------------
-- Get the mail template that must be used for the given event name.
-- The mail template is configured by the property: <i>module</i>.template.<i>event</i>.
-- ------------------------------
function Get_Template (Plugin : in Mail_Module;
Name : in String) return String is
Prop_Name : constant String := Plugin.Get_Name & ".template." & Name;
begin
return Plugin.Get_Config (Prop_Name);
end Get_Template;
-- Receive an event sent by another module with <b>Send_Event</b> method.
-- Format and send an email.
procedure Send_Mail (Plugin : in Mail_Module;
Template : in String;
Props : in Util.Beans.Objects.Maps.Map;
Content : in AWA.Events.Module_Event'Class) is
Name : constant String := Content.Get_Parameter ("name");
begin
Log.Info ("Receive event {0}", Name);
if Template = "" then
Log.Debug ("No email template associated with event {0}", Name);
return;
end if;
declare
Req : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
Ptr : constant Util.Beans.Basic.Readonly_Bean_Access := Content'Unrestricted_Access;
Bean : constant Util.Beans.Objects.Object
:= Util.Beans.Objects.To_Object (Ptr, Util.Beans.Objects.STATIC);
begin
Req.Set_Path_Info (Template);
Req.Set_Method ("GET");
Req.Set_Attribute (Name => "event", Value => Bean);
Req.Set_Attributes (Props);
Plugin.Get_Application.Dispatch (Page => Template,
Request => Req,
Response => Reply);
end;
end Send_Mail;
-- ------------------------------
-- Get the mail module instance associated with the current application.
-- ------------------------------
function Get_Mail_Module return Mail_Module_Access is
function Get is new AWA.Modules.Get (Mail_Module, Mail_Module_Access, NAME);
begin
return Get;
end Get_Mail_Module;
end AWA.Mail.Modules;
|
with Ada.Command_Line;
with Ada.Text_IO;
with GNU_Multiple_Precision.Big_Integers;
with GNU_Multiple_Precision.Big_Rationals;
use GNU_Multiple_Precision;
procedure Pi_Digits is
type Int is mod 2 ** 64;
package Int_To_Big is new Big_Integers.Modular_Conversions (Int);
-- constants
Zero : constant Big_Integer := Int_To_Big.To_Big_Integer (0);
One : constant Big_Integer := Int_To_Big.To_Big_Integer (1);
Two : constant Big_Integer := Int_To_Big.To_Big_Integer (2);
Three : constant Big_Integer := Int_To_Big.To_Big_Integer (3);
Four : constant Big_Integer := Int_To_Big.To_Big_Integer (4);
Ten : constant Big_Integer := Int_To_Big.To_Big_Integer (10);
-- type LFT = (Integer, Integer, Integer, Integer
type LFT is record
Q, R, S, T : Big_Integer;
end record;
-- extr :: LFT -> Integer -> Rational
function Extr (T : LFT; X : Big_Integer) return Big_Rational is
use Big_Integers;
Result : Big_Rational;
begin
-- extr (q,r,s,t) x = ((fromInteger q) * x + (fromInteger r)) /
-- ((fromInteger s) * x + (fromInteger t))
Big_Rationals.Set_Numerator (Item => Result,
New_Value => T.Q * X + T.R,
Canonicalize => False);
Big_Rationals.Set_Denominator (Item => Result,
New_Value => T.S * X + T.T);
return Result;
end Extr;
-- unit :: LFT
function Unit return LFT is
begin
-- unit = (1,0,0,1)
return LFT'(Q => One, R => Zero, S => Zero, T => One);
end Unit;
-- comp :: LFT -> LFT -> LFT
function Comp (T1, T2 : LFT) return LFT is
use Big_Integers;
begin
-- comp (q,r,s,t) (u,v,w,x) = (q*u+r*w,q*v+r*x,s*u+t*w,s*v+t*x)
return LFT'(Q => T1.Q * T2.Q + T1.R * T2.S,
R => T1.Q * T2.R + T1.R * T2.T,
S => T1.S * T2.Q + T1.T * T2.S,
T => T1.S * T2.R + T1.T * T2.T);
end Comp;
-- lfts = [(k, 4*k+2, 0, 2*k+1) | k<-[1..]
K : Big_Integer := Zero;
function LFTS return LFT is
use Big_Integers;
begin
K := K + One;
return LFT'(Q => K,
R => Four * K + Two,
S => Zero,
T => Two * K + One);
end LFTS;
-- next z = floor (extr z 3)
function Next (T : LFT) return Big_Integer is
begin
return Big_Rationals.To_Big_Integer (Extr (T, Three));
end Next;
-- safe z n = (n == floor (extr z 4)
function Safe (T : LFT; N : Big_Integer) return Boolean is
begin
return N = Big_Rationals.To_Big_Integer (Extr (T, Four));
end Safe;
-- prod z n = comp (10, -10*n, 0, 1)
function Prod (T : LFT; N : Big_Integer) return LFT is
use Big_Integers;
begin
return Comp (LFT'(Q => Ten, R => -Ten * N, S => Zero, T => One), T);
end Prod;
procedure Print_Pi (Digit_Count : Positive) is
Z : LFT := Unit;
Y : Big_Integer;
Count : Natural := 0;
begin
loop
Y := Next (Z);
if Safe (Z, Y) then
Count := Count + 1;
Ada.Text_IO.Put (Big_Integers.Image (Y));
exit when Count >= Digit_Count;
Z := Prod (Z, Y);
else
Z := Comp (Z, LFTS);
end if;
end loop;
end Print_Pi;
N : Positive := 250;
begin
if Ada.Command_Line.Argument_Count = 1 then
N := Positive'Value (Ada.Command_Line.Argument (1));
end if;
Print_Pi (N);
end Pi_Digits;
|
procedure Extension_Aggregate is
type Parent is tagged
record
C1 : Float;
C2 : Float;
end record;
type Extension is new Parent with
record
C3 : Float;
C4 : Float;
end record;
Parent_Var : Parent := (C1 => 1.0, C2 => 2.0);
Exten_Var : Extension;
begin
-- Simple aggregate
-- (See ACES V2.0, test "a9_ob_simp_aggregate_02")
Exten_Var := (C1 => 1.0, C2 => 2.0,
C3 => 3.0, C4 => 4.0);
-- Extension aggregate
-- (See ACES V2.0, test "a9_ob_ext_aggregate_02")
Exten_Var := (Parent_Var with C3 => 3.3, C4 => 4.4);
null;
end;
|
package Lv.Strings is
function New_String (Str : String) return Lv.C_String_Ptr;
procedure Free (Ptr : in out Lv.C_String_Ptr);
end Lv.Strings;
|
-- { dg-do run }
with OCONST1, OCONST2, OCONST3, OCONST4, OCONST5;
procedure Test_Oconst is
begin
OCONST1.check (OCONST1.My_R);
OCONST2.check (OCONST2.My_R);
OCONST3.check (OCONST3.My_R);
OCONST4.check (OCONST4.My_R);
OCONST5.check (OCONST5.My_R0, 0);
OCONST5.check (OCONST5.My_R1, 1);
end;
|
with Ada.Sequential_IO;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package Lexer is
type Token_Type is (
Invalid,
Literal,
Open,
Close,
EOF
);
type Lexer_Type is limited private;
procedure Open(lexer : out Lexer_Type;
file_name : in String);
procedure Close(lexer : in out Lexer_Type);
procedure Next(lexer : in out Lexer_Type);
function Get_Type(lexer : Lexer_Type) return Token_Type;
function Get_Value(lexer : Lexer_Type) return String;
function Get_File_Name(lexer : Lexer_Type) return String;
function Get_Line(lexer : Lexer_Type) return Positive;
private
package Character_IO is new Ada.Sequential_IO(Character);
type Lexer_Type is limited record
file : Character_IO.File_Type;
line : Positive := 1;
buffer : Unbounded_String;
token : Token_Type := Invalid;
value : Unbounded_String;
end record;
end Lexer;
|
--------------------------------------------------------------------------------
-- --
-- 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 --
-- --
--------------------------------------------------------------------------------
-- $Author$
-- $Date$
-- $Revision$
with RASCAL.Utility; use RASCAL.Utility;
with RASCAL.Memory; use RASCAL.Memory;
with Reporter;
package body RASCAL.Heap is
--
procedure Set_Name (Name : in String) is
begin
if not Initialised then
if Name'Length > 32 then
Heap_Name(1..32) := Name(Name'First..Name'First+31);
else
Heap_Name(1..Name'Length) := Name;
end if;
end if;
end Set_Name;
--
procedure Set_MaxSize (Extent : in Natural :=0) is
begin
if not Initialised then
DA_Max_Size := Extent;
end if;
end Set_MaxSize;
--
procedure Set_MessagesFile (Messages : in Messages_Handle_Type) is
begin
Errors := Messages;
end Set_MessagesFile;
--
function Get_Address (The : in Heap_Block_Type) return Address is
begin
return The.Anchor;
end Get_Address;
--
function Get_Size (The : in Heap_Block_Type) return Integer is
begin
return Flex.Get_Size (The.Anchor'Address);
end Get_Size;
--
procedure Extend (The : in out Heap_Block_Type;
New_Size : in Natural) is
Result : Integer;
begin
Result := Flex.Extend (The.Anchor'Address,New_Size);
if Result = 1 then
-- 0 = failure, 1 = success.
The.Extent := New_Size;
else
raise Unable_To_Extend_Block;
end if;
end Extend;
--
procedure Mid_Extend (The : in out Heap_Block_Type;
Location : in Integer;
Extent : in Integer) is
Result : Integer;
begin
Result := Flex.Mid_Extend (The.Anchor'Address,Location,Extent);
if Result = 1 then
-- 0 == failure, 1 == success
The.Extent := Get_Size (The);
else
raise Unable_To_Extend_Block;
end if;
end Mid_Extend;
--
procedure Re_Anchor (The : in out Heap_Block_Type;
To : in out Heap_Block_Type) is
Result : Integer;
begin
Result := Flex.Re_Anchor (To.Anchor'Address,The.Anchor'Address);
The.Extent := 0;
To.Extent := Get_Size (To);
end Re_Anchor;
--
procedure Set_Budge (Budge : in Boolean) is
Result : Integer;
New_State : Integer := 0;
begin
if Budge then
New_State := 1;
end if;
Result := Flex.Set_Budge (New_State);
end Set_Budge;
--
procedure Save_HeapInfo (Filename : in String) is
begin
Flex.Save_HeapInfo (Filename);
end Save_HeapInfo;
--
function Compact return Boolean is
Result : Integer;
begin
Result := Flex.Compact;
return Result = 0;
end Compact;
--
procedure Set_Deferred_Compaction (The : in out Heap_Block_Type;
Defer : in Boolean) is
Result : Integer;
New_State : Integer := 0;
begin
if Defer then
New_State := 1;
end if;
Result := Flex.Set_Deferred_Compaction(New_State);
end Set_Deferred_Compaction;
--
procedure Free (The : in out Heap_Block_Type) is
begin
if Adr_To_Integer (The.Anchor) /= 0 then
Flex.Free (The.Anchor'Address);
end if;
end Free;
--
procedure Initialize(The : in out Heap_Block_Type) is
Result : Integer;
begin
-- Initialise heap if necessary
if not Initialised then
Flex.Init (Heap_Name,Errors,DA_Max_Size);
Set_Budge(true);
Initialised := true;
end if;
-- Allocate block
Result := Flex.Alloc (The.Anchor'Address,The.Extent);
if Result = 0 then
-- 0 = failure, 1 = success
raise Unable_To_Allocate_Block;
end if;
if Get_Size (The) < The.Extent then
Extend (The,The.Extent);
end if;
end Initialize;
--
procedure Adjust(The : in out Heap_Block_Type) is
begin
null;
end Adjust;
--
procedure Finalize(The : in out Heap_Block_Type) is
begin
if Adr_To_Integer (The.Anchor) /= 0 then
Flex.Free (The.Anchor'Address);
end if;
end Finalize;
--
end RASCAL.Heap;
|
with
AdaM.Comment,
gtk.Widget;
private
with
gtk.Text_View,
gtk.Frame,
gtk.Button,
gtk.Alignment;
package aIDE.Editor.of_comment
is
type Item is new Editor.item with private;
type View is access all Item'Class;
package Forge
is
function to_comment_Editor (the_Comment : in AdaM.Comment.view) return View;
end Forge;
overriding
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
private
use gtk.Button,
gtk.Text_View,
gtk.Alignment,
gtk.Frame;
type Item is new Editor.item with
record
Comment : AdaM.Comment.view;
Top : gtk_Frame;
comment_text_View : gtk_Text_View;
parameters_Alignment : Gtk_Alignment;
rid_Button : gtk_Button;
end record;
end aIDE.Editor.of_comment;
|
with Ada.Tags;
with Ada.Unchecked_Deallocation;
with System.Standard_Allocators;
with System.Storage_Elements;
with System.Storage_Pools.Standard_Pools;
procedure Ada.Unchecked_Reallocation (
X : in out Name;
First_Index : Index_Type;
Last_Index : Index_Type'Base)
is
pragma Suppress (All_Checks);
use type Tags.Tag;
Old_First_Index : constant Index_Type := X'First;
Old_Last_Index : constant Index_Type := X'Last;
Min_Last_Index : constant Index_Type'Base :=
Index_Type'Base'Min (Last_Index, Old_Last_Index);
New_Length : constant Index_Type'Base :=
Index_Type'Base'Max (Last_Index - First_Index + 1, 0);
begin
-- reallocate
if Name'Storage_Pool'Tag =
System.Storage_Pools.Standard_Pools.Standard_Pool'Tag
then
-- standard storage pool
-- delete from front
if Old_First_Index < First_Index
and then First_Index <= Min_Last_Index
then
declare
Move_Length : constant Index_Type'Base :=
Min_Last_Index - First_Index + 1;
begin
X (Old_First_Index .. Old_First_Index + Move_Length - 1) :=
X (First_Index .. First_Index + Move_Length - 1);
end;
end if;
-- real reallocation
declare
use type System.Storage_Elements.Storage_Offset;
subtype Storage_Offset is System.Storage_Elements.Storage_Offset;
Object_Address : constant System.Address := X.all'Address;
Pool_Address : constant System.Address := X'Pool_Address;
Constraints_Size : constant Storage_Offset :=
Object_Address - Pool_Address;
New_Object_Size : Storage_Offset;
New_Pool_Size : Storage_Offset;
New_Pool_Address : System.Address;
New_Object_Address : System.Address;
begin
if Array_Type'Component_Size rem Standard'Storage_Unit = 0 then
-- optimized for packed
New_Object_Size :=
Storage_Offset (New_Length)
* (Array_Type'Component_Size / Standard'Storage_Unit);
else -- unpacked
New_Object_Size :=
(Storage_Offset (New_Length) * Array_Type'Component_Size
+ (Standard'Storage_Unit - 1))
/ Standard'Storage_Unit;
end if;
New_Pool_Size := Constraints_Size + New_Object_Size;
New_Pool_Address := System.Standard_Allocators.Reallocate (
Pool_Address,
New_Pool_Size);
New_Object_Address := New_Pool_Address + Constraints_Size;
-- rewrite 'First and 'Last
declare
type Constraints is record
First : Index_Type;
Last : Index_Type'Base;
end record;
pragma Suppress_Initialization (Constraints);
C : Constraints;
for C'Address use New_Pool_Address;
begin
C.First := First_Index;
C.Last := Last_Index;
end;
-- set X
declare
type Repr is record
Data : System.Address;
Constraints : System.Address;
end record;
pragma Suppress_Initialization (Repr);
R : Repr;
for R'Address use X'Address;
begin
R.Data := New_Object_Address;
R.Constraints := New_Pool_Address;
end;
end;
-- insert to front
if First_Index < Old_First_Index
and then Old_First_Index <= Min_Last_Index
then
declare
Move_Length : constant Index_Type'Base :=
Min_Last_Index - Old_First_Index + 1;
begin
X (Old_First_Index .. Old_First_Index + Move_Length - 1) :=
X (First_Index .. First_Index + Move_Length - 1);
end;
end if;
else
-- user defined storage pool
-- allocate, copy, and deallocate
declare
procedure Free is new Unchecked_Deallocation (Array_Type, Name);
Max_First_Index : constant Index_Type :=
Index_Type'Max (First_Index, Old_First_Index);
New_X : constant Name := new Array_Type (First_Index .. Last_Index);
begin
New_X (Max_First_Index .. Min_Last_Index) :=
X (Max_First_Index .. Min_Last_Index);
Free (X);
X := New_X;
end;
end if;
end Ada.Unchecked_Reallocation;
|
package Giza.Bitmap_Fonts.FreeSansBoldOblique8pt7b is
Font : constant Giza.Font.Ref_Const;
private
FreeSansBoldOblique8pt7bBitmaps : aliased constant Font_Bitmap := (
16#39#, 16#CC#, 16#63#, 16#10#, 16#8C#, 16#00#, 16#39#, 16#80#, 16#CF#,
16#38#, 16#A2#, 16#0D#, 16#86#, 16#47#, 16#F9#, 16#FE#, 16#32#, 16#09#,
16#8F#, 16#F3#, 16#FC#, 16#4C#, 16#36#, 16#00#, 16#04#, 16#0F#, 16#8D#,
16#6C#, 16#B6#, 16#C3#, 16#C0#, 16#F8#, 16#1E#, 16#0B#, 16#69#, 16#BD#,
16#8F#, 16#81#, 16#00#, 16#80#, 16#30#, 16#27#, 16#84#, 16#C8#, 16#C8#,
16#98#, 16#99#, 16#0F#, 16#20#, 16#64#, 16#00#, 16#CE#, 16#0B#, 16#F1#,
16#21#, 16#23#, 16#F4#, 16#1C#, 16#07#, 16#01#, 16#F0#, 16#66#, 16#0C#,
16#C1#, 16#F0#, 16#38#, 16#1F#, 16#9F#, 16#3E#, 16#C3#, 16#98#, 16#F3#,
16#FF#, 16#3E#, 16#E0#, 16#FA#, 16#0C#, 16#61#, 16#0C#, 16#61#, 16#8C#,
16#30#, 16#C3#, 16#0C#, 16#30#, 16#C1#, 16#86#, 16#00#, 16#18#, 16#60#,
16#C3#, 16#0C#, 16#30#, 16#C3#, 16#0C#, 16#61#, 16#8C#, 16#21#, 16#8C#,
16#00#, 16#11#, 16#77#, 16#9C#, 16#50#, 16#0C#, 16#06#, 16#1F#, 16#EF#,
16#E1#, 16#80#, 16#C0#, 16#60#, 16#6D#, 16#28#, 16#FF#, 16#C0#, 16#F0#,
16#02#, 16#08#, 16#10#, 16#40#, 16#82#, 16#04#, 16#10#, 16#20#, 16#81#,
16#04#, 16#00#, 16#0F#, 16#1F#, 16#CC#, 16#6C#, 16#36#, 16#1F#, 16#0F#,
16#0F#, 16#86#, 16#C3#, 16#63#, 16#3F#, 16#8F#, 16#00#, 16#1F#, 16#FE#,
16#73#, 16#18#, 16#C6#, 16#73#, 16#18#, 16#0F#, 16#87#, 16#F3#, 16#8C#,
16#C3#, 16#00#, 16#C0#, 16#60#, 16#30#, 16#38#, 16#38#, 16#1C#, 16#07#,
16#FB#, 16#FC#, 16#1F#, 16#1F#, 16#D8#, 16#60#, 16#30#, 16#30#, 16#70#,
16#7C#, 16#06#, 16#03#, 16#63#, 16#BF#, 16#8F#, 16#80#, 16#03#, 16#03#,
16#82#, 16#C2#, 16#62#, 16#73#, 16#33#, 16#FD#, 16#FE#, 16#0E#, 16#06#,
16#03#, 16#00#, 16#1F#, 16#9F#, 16#CC#, 16#05#, 16#C7#, 16#F3#, 16#18#,
16#0C#, 16#06#, 16#C6#, 16#7F#, 16#1E#, 16#00#, 16#0F#, 16#0F#, 16#CC#,
16#6C#, 16#06#, 16#E3#, 16#FB#, 16#8D#, 16#86#, 16#C3#, 16#63#, 16#3F#,
16#8F#, 16#00#, 16#7F#, 16#BF#, 16#C0#, 16#C0#, 16#C0#, 16#C0#, 16#C0#,
16#C0#, 16#60#, 16#60#, 16#30#, 16#38#, 16#00#, 16#1F#, 16#1F#, 16#D8#,
16#6C#, 16#33#, 16#F3#, 16#F9#, 16#8D#, 16#86#, 16#C3#, 16#63#, 16#3F#,
16#8F#, 16#00#, 16#0F#, 16#1F#, 16#CC#, 16#6C#, 16#36#, 16#1B#, 16#1D#,
16#FE#, 16#76#, 16#03#, 16#63#, 16#3F#, 16#0F#, 16#00#, 16#6C#, 16#00#,
16#36#, 16#33#, 16#00#, 16#00#, 16#66#, 16#44#, 16#80#, 16#00#, 16#83#,
16#C7#, 16#CF#, 16#0F#, 16#03#, 16#F0#, 16#3C#, 16#06#, 16#7F#, 16#BF#,
16#C0#, 16#00#, 16#0F#, 16#F7#, 16#F8#, 16#60#, 16#3C#, 16#0F#, 16#C0#,
16#F0#, 16#F3#, 16#E3#, 16#C1#, 16#00#, 16#3C#, 16#FD#, 16#9E#, 16#30#,
16#61#, 16#86#, 16#18#, 16#30#, 16#00#, 16#C3#, 16#80#, 16#01#, 16#F0#,
16#0F#, 16#F8#, 16#38#, 16#30#, 16#C0#, 16#33#, 16#00#, 16#2C#, 16#3E#,
16#58#, 16#CC#, 16#E3#, 16#11#, 16#CC#, 16#67#, 16#99#, 16#9B#, 16#3F#,
16#E7#, 16#3B#, 16#86#, 16#00#, 16#07#, 16#08#, 16#03#, 16#F0#, 16#00#,
16#03#, 16#81#, 16#E0#, 16#78#, 16#3E#, 16#0D#, 16#87#, 16#61#, 16#98#,
16#E6#, 16#7F#, 16#9F#, 16#FE#, 16#0F#, 16#03#, 16#1F#, 16#C7#, 16#FC#,
16#E1#, 16#98#, 16#33#, 16#0C#, 16#7F#, 16#9F#, 16#F3#, 16#86#, 16#60#,
16#CC#, 16#39#, 16#FE#, 16#7F#, 16#80#, 16#0F#, 16#07#, 16#E3#, 16#1D#,
16#83#, 16#60#, 16#30#, 16#0C#, 16#03#, 16#00#, 16#C1#, 16#B8#, 16#E7#,
16#F0#, 16#F0#, 16#1F#, 16#87#, 16#F8#, 16#E3#, 16#98#, 16#33#, 16#06#,
16#60#, 16#DC#, 16#1B#, 16#86#, 16#60#, 16#CC#, 16#31#, 16#FE#, 16#7F#,
16#00#, 16#1F#, 16#E7#, 16#FC#, 16#E0#, 16#18#, 16#03#, 16#00#, 16#7F#,
16#9F#, 16#E3#, 16#80#, 16#60#, 16#0C#, 16#01#, 16#FE#, 16#7F#, 16#C0#,
16#1F#, 16#E7#, 16#FC#, 16#E0#, 16#18#, 16#03#, 16#00#, 16#7F#, 16#1F#,
16#E3#, 16#80#, 16#60#, 16#0C#, 16#03#, 16#80#, 16#70#, 16#00#, 16#0F#,
16#83#, 16#F8#, 16#C3#, 16#B0#, 16#06#, 16#01#, 16#87#, 16#B0#, 16#F6#,
16#06#, 16#C1#, 16#DC#, 16#31#, 16#FE#, 16#1F#, 16#40#, 16#38#, 16#73#,
16#87#, 16#30#, 16#63#, 16#06#, 16#30#, 16#67#, 16#FE#, 16#7F#, 16#E6#,
16#0C#, 16#60#, 16#C6#, 16#0C#, 16#E1#, 16#CE#, 16#1C#, 16#39#, 16#CC#,
16#63#, 16#39#, 16#CC#, 16#63#, 16#39#, 16#80#, 16#01#, 16#80#, 16#C0#,
16#E0#, 16#70#, 16#30#, 16#18#, 16#1D#, 16#8E#, 16#C6#, 16#63#, 16#3F#,
16#8F#, 16#00#, 16#18#, 16#73#, 16#8E#, 16#39#, 16#C3#, 16#38#, 16#37#,
16#03#, 16#E0#, 16#7E#, 16#07#, 16#70#, 16#63#, 16#86#, 16#38#, 16#E1#,
16#CE#, 16#1C#, 16#18#, 16#1C#, 16#0E#, 16#06#, 16#03#, 16#01#, 16#81#,
16#C0#, 16#E0#, 16#60#, 16#30#, 16#1F#, 16#FF#, 16#E0#, 16#1C#, 16#1C#,
16#70#, 16#F1#, 16#C3#, 16#8F#, 16#1E#, 16#34#, 16#58#, 16#DB#, 16#E7#,
16#6B#, 16#9D#, 16#AC#, 16#67#, 16#B1#, 16#9C#, 16#CE#, 16#77#, 16#31#,
16#98#, 16#18#, 16#33#, 16#C7#, 16#3C#, 16#73#, 16#C6#, 16#3E#, 16#67#,
16#66#, 16#76#, 16#E6#, 16#3C#, 16#63#, 16#C6#, 16#3C#, 16#E1#, 16#CC#,
16#1C#, 16#0F#, 16#83#, 16#F8#, 16#C3#, 16#B0#, 16#36#, 16#07#, 16#80#,
16#F0#, 16#1E#, 16#06#, 16#C0#, 16#DC#, 16#31#, 16#FC#, 16#1F#, 16#00#,
16#1F#, 16#C7#, 16#FC#, 16#E1#, 16#98#, 16#33#, 16#06#, 16#61#, 16#9F#,
16#F3#, 16#F8#, 16#60#, 16#0C#, 16#01#, 16#80#, 16#70#, 16#00#, 16#0F#,
16#83#, 16#F8#, 16#C3#, 16#B0#, 16#36#, 16#07#, 16#80#, 16#F0#, 16#1E#,
16#16#, 16#C7#, 16#DC#, 16#71#, 16#FE#, 16#1F#, 16#60#, 16#00#, 16#1F#,
16#C7#, 16#FC#, 16#E1#, 16#98#, 16#33#, 16#0C#, 16#7F#, 16#9F#, 16#F3#,
16#86#, 16#60#, 16#CC#, 16#31#, 16#86#, 16#70#, 16#E0#, 16#0F#, 16#87#,
16#FD#, 16#C1#, 16#B0#, 16#36#, 16#00#, 16#FE#, 16#07#, 16#F0#, 16#0E#,
16#C0#, 16#D8#, 16#33#, 16#FE#, 16#1F#, 16#00#, 16#7F#, 16#FF#, 16#F0#,
16#C0#, 16#30#, 16#1C#, 16#06#, 16#01#, 16#80#, 16#60#, 16#38#, 16#0E#,
16#03#, 16#00#, 16#C0#, 16#70#, 16#EC#, 16#1D#, 16#83#, 16#30#, 16#66#,
16#0C#, 16#C3#, 16#B0#, 16#76#, 16#0C#, 16#C1#, 16#98#, 16#73#, 16#FC#,
16#1E#, 16#00#, 16#C1#, 16#F0#, 16#6C#, 16#33#, 16#8C#, 16#E6#, 16#19#,
16#86#, 16#C1#, 16#B0#, 16#78#, 16#1E#, 16#07#, 16#01#, 16#C0#, 16#C3#,
16#8F#, 16#8F#, 16#1B#, 16#1E#, 16#36#, 16#3C#, 16#CC#, 16#D9#, 16#99#,
16#B7#, 16#36#, 16#6C#, 16#6C#, 16#D8#, 16#F1#, 16#E0#, 16#E3#, 16#C1#,
16#87#, 16#03#, 16#0E#, 16#00#, 16#1C#, 16#30#, 16#63#, 16#83#, 16#B8#,
16#1F#, 16#80#, 16#78#, 16#03#, 16#80#, 16#1C#, 16#01#, 16#F0#, 16#1F#,
16#81#, 16#CC#, 16#0C#, 16#70#, 16#E3#, 16#80#, 16#E1#, 16#F8#, 16#E6#,
16#31#, 16#98#, 16#7E#, 16#0F#, 16#03#, 16#80#, 16#E0#, 16#30#, 16#0C#,
16#03#, 16#01#, 16#C0#, 16#1F#, 16#F1#, 16#FE#, 16#00#, 16#E0#, 16#1C#,
16#03#, 16#80#, 16#70#, 16#0E#, 16#01#, 16#C0#, 16#38#, 16#07#, 16#00#,
16#7F#, 16#C7#, 16#F8#, 16#0E#, 16#3C#, 16#60#, 16#C1#, 16#86#, 16#0C#,
16#18#, 16#30#, 16#61#, 16#83#, 16#06#, 16#0F#, 16#3C#, 16#00#, 16#2A#,
16#AF#, 16#54#, 16#1E#, 16#78#, 16#30#, 16#60#, 16#C3#, 16#06#, 16#0C#,
16#18#, 16#30#, 16#C1#, 16#83#, 16#1E#, 16#38#, 16#00#, 16#0C#, 16#38#,
16#D1#, 16#B6#, 16#68#, 16#F1#, 16#80#, 16#FF#, 16#C0#, 16#D0#, 16#1E#,
16#3F#, 16#63#, 16#03#, 16#3F#, 16#E7#, 16#C6#, 16#FE#, 16#76#, 16#38#,
16#18#, 16#0C#, 16#06#, 16#E7#, 16#FB#, 16#8D#, 16#86#, 16#C3#, 16#61#,
16#F1#, 16#BF#, 16#9B#, 16#80#, 16#1E#, 16#3F#, 16#63#, 16#C0#, 16#C0#,
16#C0#, 16#C6#, 16#FE#, 16#78#, 16#00#, 16#C0#, 16#30#, 16#1C#, 16#7E#,
16#3F#, 16#98#, 16#EC#, 16#3B#, 16#0E#, 16#C7#, 16#31#, 16#CF#, 16#F1#,
16#EC#, 16#1E#, 16#7F#, 16#63#, 16#FF#, 16#FF#, 16#C0#, 16#C6#, 16#FC#,
16#78#, 16#1C#, 16#73#, 16#9F#, 16#7C#, 16#C3#, 16#1C#, 16#61#, 16#86#,
16#18#, 16#0E#, 16#C7#, 16#F3#, 16#1D#, 16#87#, 16#61#, 16#D8#, 16#66#,
16#39#, 16#FE#, 16#3D#, 16#80#, 16#CC#, 16#33#, 16#F8#, 16#7C#, 16#00#,
16#38#, 16#18#, 16#0C#, 16#06#, 16#E3#, 16#FB#, 16#8D#, 16#C6#, 16#C3#,
16#61#, 16#B1#, 16#F8#, 16#D8#, 16#60#, 16#33#, 16#06#, 16#66#, 16#66#,
16#6E#, 16#CC#, 16#0E#, 16#1C#, 16#00#, 16#60#, 16#C3#, 16#86#, 16#0C#,
16#18#, 16#30#, 16#E1#, 16#83#, 16#06#, 16#1C#, 16#70#, 16#38#, 16#18#,
16#0C#, 16#06#, 16#77#, 16#73#, 16#F1#, 16#F0#, 16#F8#, 16#6C#, 16#77#,
16#31#, 16#98#, 16#E0#, 16#33#, 16#76#, 16#66#, 16#66#, 16#6E#, 16#CC#,
16#37#, 16#73#, 16#FF#, 16#DC#, 16#E6#, 16#C6#, 16#36#, 16#31#, 16#B1#,
16#8F#, 16#9C#, 16#78#, 16#E7#, 16#C6#, 16#30#, 16#37#, 16#1F#, 16#DC#,
16#6C#, 16#36#, 16#1B#, 16#0D#, 16#8F#, 16#C6#, 16#C3#, 16#00#, 16#1F#,
16#1F#, 16#D8#, 16#7C#, 16#3C#, 16#1E#, 16#1F#, 16#0D#, 16#FC#, 16#7C#,
16#00#, 16#1B#, 16#8F#, 16#F3#, 16#8C#, 16#C3#, 16#30#, 16#CC#, 16#37#,
16#19#, 16#FE#, 16#6E#, 16#18#, 16#06#, 16#03#, 16#80#, 16#E0#, 16#00#,
16#1D#, 16#8F#, 16#E6#, 16#3B#, 16#0E#, 16#C3#, 16#B0#, 16#CC#, 16#73#,
16#FC#, 16#7B#, 16#01#, 16#C0#, 16#60#, 16#18#, 16#06#, 16#00#, 16#36#,
16#79#, 16#C3#, 16#06#, 16#0C#, 16#18#, 16#70#, 16#C0#, 16#3C#, 16#FF#,
16#1F#, 16#0F#, 16#C7#, 16#F1#, 16#FE#, 16#78#, 16#37#, 16#FE#, 16#C6#,
16#73#, 16#18#, 16#E7#, 16#00#, 16#71#, 16#98#, 16#66#, 16#19#, 16#86#,
16#E3#, 16#B8#, 16#CC#, 16#73#, 16#FC#, 16#7B#, 16#00#, 16#C3#, 16#E7#,
16#E6#, 16#6E#, 16#6C#, 16#78#, 16#78#, 16#70#, 16#70#, 16#C7#, 16#3E#,
16#79#, 16#B3#, 16#CD#, 16#B6#, 16#CD#, 16#B6#, 16#79#, 16#E3#, 16#CF#,
16#1C#, 16#70#, 16#E3#, 16#80#, 16#39#, 16#C6#, 16#61#, 16#F0#, 16#38#,
16#0E#, 16#07#, 16#83#, 16#E1#, 16#DC#, 16#63#, 16#00#, 16#61#, 16#B9#,
16#DC#, 16#CE#, 16#63#, 16#61#, 16#B0#, 16#F0#, 16#78#, 16#38#, 16#18#,
16#0C#, 16#1C#, 16#0C#, 16#00#, 16#3F#, 16#9F#, 16#C0#, 16#C1#, 16#C1#,
16#C1#, 16#C1#, 16#C0#, 16#FE#, 16#FF#, 16#00#, 16#1C#, 16#73#, 16#0C#,
16#30#, 16#CE#, 16#38#, 16#61#, 16#86#, 16#30#, 16#C3#, 16#8E#, 16#00#,
16#13#, 16#22#, 16#22#, 16#64#, 16#44#, 16#CC#, 16#88#, 16#00#, 16#1C#,
16#70#, 16#C3#, 16#18#, 16#61#, 16#87#, 16#1C#, 16#C3#, 16#0C#, 16#33#,
16#8E#, 16#00#, 16#F1#, 16#64#, 16#70#);
FreeSansBoldOblique8pt7bGlyphs : aliased constant Glyph_Array := (
(0, 0, 0, 4, 0, 1), -- 0x20 ' '
(0, 5, 12, 5, 2, -11), -- 0x21 '!'
(8, 6, 4, 8, 3, -11), -- 0x22 '"'
(11, 10, 10, 9, 1, -10), -- 0x23 '#'
(24, 9, 14, 9, 1, -11), -- 0x24 '$'
(40, 12, 12, 14, 2, -11), -- 0x25 '%'
(58, 11, 12, 12, 1, -11), -- 0x26 '&'
(75, 2, 4, 4, 3, -11), -- 0x27 '''
(76, 6, 15, 5, 1, -11), -- 0x28 '('
(88, 6, 15, 5, 0, -10), -- 0x29 ')'
(100, 6, 5, 6, 2, -11), -- 0x2A '*'
(104, 9, 7, 9, 1, -6), -- 0x2B '+'
(112, 3, 5, 4, 0, -1), -- 0x2C ','
(114, 5, 2, 5, 1, -4), -- 0x2D '-'
(116, 2, 2, 4, 1, -1), -- 0x2E '.'
(117, 7, 12, 4, 0, -11), -- 0x2F '/'
(128, 9, 12, 9, 1, -11), -- 0x30 '0'
(142, 5, 11, 9, 3, -10), -- 0x31 '1'
(149, 10, 12, 9, 0, -11), -- 0x32 '2'
(164, 9, 12, 9, 1, -11), -- 0x33 '3'
(178, 9, 11, 9, 1, -10), -- 0x34 '4'
(191, 9, 11, 9, 1, -10), -- 0x35 '5'
(204, 9, 12, 9, 1, -11), -- 0x36 '6'
(218, 9, 11, 9, 2, -10), -- 0x37 '7'
(231, 9, 12, 9, 1, -11), -- 0x38 '8'
(245, 9, 12, 9, 1, -11), -- 0x39 '9'
(259, 3, 8, 5, 2, -7), -- 0x3A ':'
(262, 4, 11, 5, 1, -7), -- 0x3B ';'
(268, 9, 8, 9, 1, -7), -- 0x3C '<'
(277, 9, 6, 9, 1, -6), -- 0x3D '='
(284, 9, 8, 9, 1, -6), -- 0x3E '>'
(293, 7, 12, 10, 3, -11), -- 0x3F '?'
(304, 15, 15, 16, 1, -12), -- 0x40 '@'
(333, 10, 12, 12, 1, -11), -- 0x41 'A'
(348, 11, 12, 12, 1, -11), -- 0x42 'B'
(365, 10, 12, 12, 2, -11), -- 0x43 'C'
(380, 11, 12, 12, 1, -11), -- 0x44 'D'
(397, 11, 12, 11, 1, -11), -- 0x45 'E'
(414, 11, 12, 10, 1, -11), -- 0x46 'F'
(431, 11, 12, 12, 2, -11), -- 0x47 'G'
(448, 12, 12, 12, 1, -11), -- 0x48 'H'
(466, 5, 12, 4, 1, -11), -- 0x49 'I'
(474, 9, 12, 9, 1, -11), -- 0x4A 'J'
(488, 12, 12, 12, 1, -11), -- 0x4B 'K'
(506, 9, 12, 10, 1, -11), -- 0x4C 'L'
(520, 14, 12, 13, 1, -11), -- 0x4D 'M'
(541, 12, 12, 12, 1, -11), -- 0x4E 'N'
(559, 11, 12, 12, 2, -11), -- 0x4F 'O'
(576, 11, 12, 11, 1, -11), -- 0x50 'P'
(593, 11, 13, 12, 2, -11), -- 0x51 'Q'
(611, 11, 12, 12, 1, -11), -- 0x52 'R'
(628, 11, 12, 11, 1, -11), -- 0x53 'S'
(645, 10, 12, 10, 2, -11), -- 0x54 'T'
(660, 11, 12, 12, 2, -11), -- 0x55 'U'
(677, 10, 12, 11, 3, -11), -- 0x56 'V'
(692, 15, 12, 15, 3, -11), -- 0x57 'W'
(715, 13, 12, 11, 0, -11), -- 0x58 'X'
(735, 10, 12, 11, 3, -11), -- 0x59 'Y'
(750, 12, 12, 10, 0, -11), -- 0x5A 'Z'
(768, 7, 15, 5, 0, -11), -- 0x5B '['
(782, 2, 11, 4, 2, -10), -- 0x5C '\'
(785, 7, 15, 5, 0, -10), -- 0x5D ']'
(799, 7, 7, 9, 2, -10), -- 0x5E '^'
(806, 10, 1, 9, -1, 3), -- 0x5F '_'
(808, 2, 2, 5, 3, -11), -- 0x60 '`'
(809, 8, 9, 9, 1, -8), -- 0x61 'a'
(818, 9, 12, 10, 1, -11), -- 0x62 'b'
(832, 8, 9, 9, 1, -8), -- 0x63 'c'
(841, 10, 12, 10, 1, -11), -- 0x64 'd'
(856, 8, 9, 9, 1, -8), -- 0x65 'e'
(865, 6, 12, 5, 1, -11), -- 0x66 'f'
(874, 10, 13, 10, 0, -8), -- 0x67 'g'
(891, 9, 12, 10, 1, -11), -- 0x68 'h'
(905, 4, 12, 4, 1, -11), -- 0x69 'i'
(911, 7, 16, 4, -1, -11), -- 0x6A 'j'
(925, 9, 12, 9, 1, -11), -- 0x6B 'k'
(939, 4, 12, 4, 1, -11), -- 0x6C 'l'
(945, 13, 9, 14, 1, -8), -- 0x6D 'm'
(960, 9, 9, 10, 1, -8), -- 0x6E 'n'
(971, 9, 9, 10, 1, -8), -- 0x6F 'o'
(982, 10, 13, 10, 0, -8), -- 0x70 'p'
(999, 10, 13, 10, 1, -8), -- 0x71 'q'
(1016, 7, 9, 6, 1, -8), -- 0x72 'r'
(1024, 7, 9, 9, 2, -8), -- 0x73 's'
(1032, 5, 10, 5, 2, -9), -- 0x74 't'
(1039, 10, 9, 10, 1, -8), -- 0x75 'u'
(1051, 8, 9, 9, 2, -8), -- 0x76 'v'
(1060, 13, 9, 12, 2, -8), -- 0x77 'w'
(1075, 10, 9, 9, 0, -8), -- 0x78 'x'
(1087, 9, 13, 9, 1, -8), -- 0x79 'y'
(1102, 9, 9, 8, 0, -8), -- 0x7A 'z'
(1113, 6, 15, 6, 1, -11), -- 0x7B '{'
(1125, 4, 15, 4, 1, -11), -- 0x7C '|'
(1133, 6, 15, 6, 1, -10), -- 0x7D '}'
(1145, 7, 3, 9, 2, -4)); -- 0x7E '~'
Font_D : aliased constant Bitmap_Font :=
(FreeSansBoldOblique8pt7bBitmaps'Access,
FreeSansBoldOblique8pt7bGlyphs'Access,
19);
Font : constant Giza.Font.Ref_Const := Font_D'Access;
end Giza.Bitmap_Fonts.FreeSansBoldOblique8pt7b;
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Mobs.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
with Items; use Items;
-- begin read only
-- end read only
package body Mobs.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
function Wrap_Test_GenerateMob_520182_4cad96
(MobIndex, FactionIndex: Unbounded_String) return Member_Data is
begin
begin
pragma Assert
((ProtoMobs_List.Contains(MobIndex) and
Factions_List.Contains(FactionIndex)));
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(mobs.ads:0):Test_GenearateMob test requirement violated");
end;
declare
Test_GenerateMob_520182_4cad96_Result: constant Member_Data :=
GNATtest_Generated.GNATtest_Standard.Mobs.GenerateMob
(MobIndex, FactionIndex);
begin
begin
pragma Assert
(Test_GenerateMob_520182_4cad96_Result.Name /=
Null_Unbounded_String);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(mobs.ads:0:):Test_GenearateMob test commitment violated");
end;
return Test_GenerateMob_520182_4cad96_Result;
end;
end Wrap_Test_GenerateMob_520182_4cad96;
-- end read only
-- begin read only
procedure Test_GenerateMob_test_genearatemob(Gnattest_T: in out Test);
procedure Test_GenerateMob_520182_4cad96(Gnattest_T: in out Test) renames
Test_GenerateMob_test_genearatemob;
-- id:2.2/5201826c898ff8db/GenerateMob/1/0/test_genearatemob/
procedure Test_GenerateMob_test_genearatemob(Gnattest_T: in out Test) is
function GenerateMob
(MobIndex, FactionIndex: Unbounded_String) return Member_Data renames
Wrap_Test_GenerateMob_520182_4cad96;
-- end read only
pragma Unreferenced(Gnattest_T);
NewMob: Member_Data
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount);
begin
NewMob :=
GenerateMob(To_Unbounded_String("5"), To_Unbounded_String("POLEIS"));
Assert(NewMob.Attributes(1).Level = 2, "Failed to generate mob.");
Assert
(NewMob.OrderTime = 15,
"Failed to set order time for the generated mob.");
-- begin read only
end Test_GenerateMob_test_genearatemob;
-- end read only
-- begin read only
function Wrap_Test_GetRandomItem_61c13c_8c2473
(ItemsIndexes: UnboundedString_Container.Vector;
EquipIndex, HighestLevel, WeaponSkillLevel: Positive;
FactionIndex: Unbounded_String) return Unbounded_String is
begin
begin
pragma Assert
((EquipIndex < 8 and HighestLevel < 101 and
WeaponSkillLevel < 101 and Factions_List.Contains(FactionIndex)));
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(mobs.ads:0):Test_GetRandomItem test requirement violated");
end;
declare
Test_GetRandomItem_61c13c_8c2473_Result: constant Unbounded_String :=
GNATtest_Generated.GNATtest_Standard.Mobs.GetRandomItem
(ItemsIndexes, EquipIndex, HighestLevel, WeaponSkillLevel,
FactionIndex);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(mobs.ads:0:):Test_GetRandomItem test commitment violated");
end;
return Test_GetRandomItem_61c13c_8c2473_Result;
end;
end Wrap_Test_GetRandomItem_61c13c_8c2473;
-- end read only
-- begin read only
procedure Test_GetRandomItem_test_getrandomitem(Gnattest_T: in out Test);
procedure Test_GetRandomItem_61c13c_8c2473(Gnattest_T: in out Test) renames
Test_GetRandomItem_test_getrandomitem;
-- id:2.2/61c13cdf12147be3/GetRandomItem/1/0/test_getrandomitem/
procedure Test_GetRandomItem_test_getrandomitem(Gnattest_T: in out Test) is
function GetRandomItem
(ItemsIndexes: UnboundedString_Container.Vector;
EquipIndex, HighestLevel, WeaponSkillLevel: Positive;
FactionIndex: Unbounded_String) return Unbounded_String renames
Wrap_Test_GetRandomItem_61c13c_8c2473;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(GetRandomItem
(Weapons_List, 1, 20, 20, To_Unbounded_String("POLEIS")) /=
Null_Unbounded_String,
"Failed to get random item for mob.");
-- begin read only
end Test_GetRandomItem_test_getrandomitem;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Mobs.Test_Data.Tests;
|
package Pack22_Pkg is
type byte is mod 256;
Temp_buffer : array (0..8) of byte:= (others => 0);
for Temp_buffer'Alignment use 2;
subtype Id is Short_integer;
generic
Dummy : Integer := 0;
package Bit_Map_Generic is
type List is private;
function "xor" (L, R : List) return List;
private
type Offset_T is range 0 .. Id'Last;
type Counter_T is new short_integer;
for Counter_T'Size use 16;
type Bit_List is array (Id range <>) of Boolean;
pragma Pack (Bit_List);
type List_Counter_T (Is_Defined : Boolean := True) is
record
Dummy : Boolean := False;
case Is_Defined is
when True =>
Counter : Counter_T := 0;
when False =>
null;
end case;
end record;
for List_Counter_T use
record
Is_Defined at 0 range 0 .. 7;
Dummy at 1 range 0 .. 7;
Counter at 2 range 0 .. 15;
end record;
type List is
record
Offset : Offset_T := Offset_T (1) - 1;
Counter : List_Counter_T;
Bits : Bit_List (1 .. 6);
end record;
for List use
record
Offset at 0 range 0 .. 15;
Counter at 2 range 0 .. 31;
end record;
type Iterator is
record
No_More_Id : Boolean := True;
Current_Id : Id;
The_List : List;
end record;
end Bit_Map_Generic;
end Pack22_Pkg;
|
with Unchecked_Deallocation;
package body Prot2_Pkg2 is
protected type Rec is
private
M : T;
end Rec;
protected body Rec is end;
procedure Create (B : out Id) is
begin
B := new Rec;
end;
procedure Delete (B : in out Id) is
procedure Free is new Unchecked_Deallocation(Object => Rec, Name => Id);
begin
Free (B);
end;
end Prot2_Pkg2;
|
package body openGL.Frustum
is
procedure normalise (Planes : in out Plane_array)
is
use Geometry_3D;
begin
for Each in Planes'Range
loop
normalise (Planes (Each));
end loop;
end normalise;
end openGL.Frustum;
|
package body Array28_Pkg is
function F return Inner_Type is
begin
return "12345";
end;
end Array28_Pkg;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . --
-- S I N G L E _ E N T R Y --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1998-2001 Ada Core Technologies --
-- --
-- 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 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram ordering check, since restricted GNARLI
-- subprograms are gathered together at end.
-- This package provides an optimized version of Protected_Objects.Operations
-- and Protected_Objects.Entries making the following assumptions:
--
-- PO have only one entry
-- There is only one caller at a time (No_Entry_Queue)
-- There is no dynamic priority support (No_Dynamic_Priorities)
-- No Abort Statements
-- (No_Abort_Statements, Max_Asynchronous_Select_Nesting => 0)
-- PO are at library level
-- No Requeue
-- None of the tasks will terminate (no need for finalization)
--
-- This interface is intended to be used in the ravenscar and restricted
-- profiles, the compiler is responsible for ensuring that the conditions
-- mentioned above are respected, except for the No_Entry_Queue restriction
-- that is checked dynamically in this package, since the check cannot be
-- performed at compile time, and is relatively cheap (see PO_Do_Or_Queue,
-- PO_Service_Entry).
pragma Polling (Off);
-- Turn off polling, we do not want polling to take place during tasking
-- operations. It can cause infinite loops and other problems.
pragma Suppress (All_Checks);
with System.Task_Primitives.Operations;
-- used for Self
-- Finalize_Lock
-- Write_Lock
-- Unlock
with Ada.Exceptions;
-- used for Exception_Id;
with Unchecked_Conversion;
package body System.Tasking.Protected_Objects.Single_Entry is
package STPO renames System.Task_Primitives.Operations;
function To_Address is new
Unchecked_Conversion (Protection_Entry_Access, System.Address);
-----------------------
-- Local Subprograms --
-----------------------
procedure Send_Program_Error
(Self_Id : Task_ID;
Entry_Call : Entry_Call_Link);
pragma Inline (Send_Program_Error);
-- Raise Program_Error in the caller of the specified entry call
--------------------------
-- Entry Calls Handling --
--------------------------
procedure Wakeup_Entry_Caller
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link;
New_State : Entry_Call_State);
pragma Inline (Wakeup_Entry_Caller);
-- This is called at the end of service of an entry call,
-- to abort the caller if he is in an abortable part, and
-- to wake up the caller if he is on Entry_Caller_Sleep.
-- Call it holding the lock of Entry_Call.Self.
--
-- Timed_Call or Simple_Call:
-- The caller is waiting on Entry_Caller_Sleep, in
-- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
procedure Wait_For_Completion
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link);
pragma Inline (Wait_For_Completion);
-- This procedure suspends the calling task until the specified entry call
-- has either been completed or cancelled. On exit, the call will not be
-- queued. This waits for calls on protected entries.
-- Call this only when holding Self_ID locked.
procedure Wait_For_Completion_With_Timeout
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link;
Wakeup_Time : Duration;
Mode : Delay_Modes);
-- Same as Wait_For_Completion but it waits for a timeout with the value
-- specified in Wakeup_Time as well.
-- Self_ID will be locked by this procedure.
procedure Check_Exception
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link);
pragma Inline (Check_Exception);
-- Raise any pending exception from the Entry_Call.
-- This should be called at the end of every compiler interface procedure
-- that implements an entry call.
-- The caller should not be holding any locks, or there will be deadlock.
procedure PO_Do_Or_Queue
(Self_Id : Task_ID;
Object : Protection_Entry_Access;
Entry_Call : Entry_Call_Link);
-- This procedure executes or queues an entry call, depending
-- on the status of the corresponding barrier. It assumes that the
-- specified object is locked.
---------------------
-- Check_Exception --
---------------------
procedure Check_Exception
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link)
is
procedure Internal_Raise (X : Ada.Exceptions.Exception_Id);
pragma Import (C, Internal_Raise, "__gnat_raise_with_msg");
use type Ada.Exceptions.Exception_Id;
E : constant Ada.Exceptions.Exception_Id :=
Entry_Call.Exception_To_Raise;
begin
if E /= Ada.Exceptions.Null_Id then
Internal_Raise (E);
end if;
end Check_Exception;
------------------------
-- Send_Program_Error --
------------------------
procedure Send_Program_Error
(Self_Id : Task_ID;
Entry_Call : Entry_Call_Link)
is
Caller : constant Task_ID := Entry_Call.Self;
begin
Entry_Call.Exception_To_Raise := Program_Error'Identity;
STPO.Write_Lock (Caller);
Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
STPO.Unlock (Caller);
end Send_Program_Error;
-------------------------
-- Wait_For_Completion --
-------------------------
-- Call this only when holding Self_ID locked
procedure Wait_For_Completion
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link) is
begin
pragma Assert (Self_ID = Entry_Call.Self);
Self_ID.Common.State := Entry_Caller_Sleep;
STPO.Sleep (Self_ID, Entry_Caller_Sleep);
Self_ID.Common.State := Runnable;
end Wait_For_Completion;
--------------------------------------
-- Wait_For_Completion_With_Timeout --
--------------------------------------
-- This routine will lock Self_ID.
-- This procedure waits for the entry call to
-- be served, with a timeout. It tries to cancel the
-- call if the timeout expires before the call is served.
-- If we wake up from the timed sleep operation here,
-- it may be for the following possible reasons:
-- 1) The entry call is done being served.
-- 2) The timeout has expired (Timedout = True)
-- Once the timeout has expired we may need to continue to wait if
-- the call is already being serviced. In that case, we want to go
-- back to sleep, but without any timeout. The variable Timedout is
-- used to control this. If the Timedout flag is set, we do not need
-- to Sleep with a timeout. We just sleep until we get a wakeup for
-- some status change.
procedure Wait_For_Completion_With_Timeout
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link;
Wakeup_Time : Duration;
Mode : Delay_Modes)
is
Timedout : Boolean;
Yielded : Boolean;
use type Ada.Exceptions.Exception_Id;
begin
STPO.Write_Lock (Self_ID);
pragma Assert (Entry_Call.Self = Self_ID);
pragma Assert (Entry_Call.Mode = Timed_Call);
Self_ID.Common.State := Entry_Caller_Sleep;
STPO.Timed_Sleep
(Self_ID, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded);
if Timedout then
Entry_Call.State := Cancelled;
else
Entry_Call.State := Done;
end if;
Self_ID.Common.State := Runnable;
STPO.Unlock (Self_ID);
end Wait_For_Completion_With_Timeout;
-------------------------
-- Wakeup_Entry_Caller --
-------------------------
-- This is called at the end of service of an entry call, to abort the
-- caller if he is in an abortable part, and to wake up the caller if it
-- is on Entry_Caller_Sleep. It assumes that the call is already off-queue.
-- (This enforces the rule that a task must be off-queue if its state is
-- Done or Cancelled.) Call it holding the lock of Entry_Call.Self.
-- Timed_Call or Simple_Call:
-- The caller is waiting on Entry_Caller_Sleep, in
-- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
-- Conditional_Call:
-- The caller might be in Wait_For_Completion,
-- waiting for a rendezvous (possibly requeued without abort)
-- to complete.
procedure Wakeup_Entry_Caller
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link;
New_State : Entry_Call_State)
is
Caller : constant Task_ID := Entry_Call.Self;
begin
pragma Assert (New_State = Done or else New_State = Cancelled);
pragma Assert
(Caller.Common.State /= Terminated and then
Caller.Common.State /= Unactivated);
Entry_Call.State := New_State;
STPO.Wakeup (Caller, Entry_Caller_Sleep);
end Wakeup_Entry_Caller;
-----------------------
-- Restricted GNARLI --
-----------------------
--------------------------------
-- Complete_Single_Entry_Body --
--------------------------------
procedure Complete_Single_Entry_Body (Object : Protection_Entry_Access) is
begin
-- Nothing needs to be done since
-- Object.Call_In_Progress.Exception_To_Raise has already been set to
-- Null_Id
null;
end Complete_Single_Entry_Body;
--------------------------------------------
-- Exceptional_Complete_Single_Entry_Body --
--------------------------------------------
procedure Exceptional_Complete_Single_Entry_Body
(Object : Protection_Entry_Access;
Ex : Ada.Exceptions.Exception_Id) is
begin
Object.Call_In_Progress.Exception_To_Raise := Ex;
end Exceptional_Complete_Single_Entry_Body;
---------------------------------
-- Initialize_Protection_Entry --
---------------------------------
procedure Initialize_Protection_Entry
(Object : Protection_Entry_Access;
Ceiling_Priority : Integer;
Compiler_Info : System.Address;
Entry_Body : Entry_Body_Access)
is
Init_Priority : Integer := Ceiling_Priority;
begin
if Init_Priority = Unspecified_Priority then
Init_Priority := System.Priority'Last;
end if;
STPO.Initialize_Lock (Init_Priority, Object.L'Access);
Object.Ceiling := System.Any_Priority (Init_Priority);
Object.Compiler_Info := Compiler_Info;
Object.Call_In_Progress := null;
Object.Entry_Body := Entry_Body;
Object.Entry_Queue := null;
end Initialize_Protection_Entry;
----------------
-- Lock_Entry --
----------------
-- Compiler interface only.
-- Do not call this procedure from within the run-time system.
procedure Lock_Entry (Object : Protection_Entry_Access) is
Ceiling_Violation : Boolean;
begin
STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error;
end if;
end Lock_Entry;
--------------------------
-- Lock_Read_Only_Entry --
--------------------------
-- Compiler interface only.
-- Do not call this procedure from within the runtime system.
procedure Lock_Read_Only_Entry (Object : Protection_Entry_Access) is
Ceiling_Violation : Boolean;
begin
STPO.Read_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error;
end if;
end Lock_Read_Only_Entry;
--------------------
-- PO_Do_Or_Queue --
--------------------
procedure PO_Do_Or_Queue
(Self_Id : Task_ID;
Object : Protection_Entry_Access;
Entry_Call : Entry_Call_Link)
is
Barrier_Value : Boolean;
begin
-- When the Action procedure for an entry body returns, it must be
-- completed (having called [Exceptional_]Complete_Entry_Body).
Barrier_Value := Object.Entry_Body.Barrier (Object.Compiler_Info, 1);
if Barrier_Value then
if Object.Call_In_Progress /= null then
-- This violates the No_Entry_Queue restriction, send
-- Program_Error to the caller.
Send_Program_Error (Self_Id, Entry_Call);
return;
end if;
Object.Call_In_Progress := Entry_Call;
Object.Entry_Body.Action
(Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1);
Object.Call_In_Progress := null;
Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
elsif Entry_Call.Mode /= Conditional_Call then
Object.Entry_Queue := Entry_Call;
else
-- Conditional_Call
STPO.Write_Lock (Entry_Call.Self);
Wakeup_Entry_Caller (Self_Id, Entry_Call, Cancelled);
STPO.Unlock (Entry_Call.Self);
end if;
exception
when others =>
Send_Program_Error
(Self_Id, Entry_Call);
end PO_Do_Or_Queue;
----------------------------
-- Protected_Single_Count --
----------------------------
function Protected_Count_Entry (Object : Protection_Entry) return Natural is
begin
if Object.Call_In_Progress /= null then
return 1;
else
return 0;
end if;
end Protected_Count_Entry;
---------------------------------
-- Protected_Single_Entry_Call --
---------------------------------
procedure Protected_Single_Entry_Call
(Object : Protection_Entry_Access;
Uninterpreted_Data : System.Address;
Mode : Call_Modes)
is
Self_Id : constant Task_ID := STPO.Self;
Entry_Call : Entry_Call_Record renames Self_Id.Entry_Calls (1);
Ceiling_Violation : Boolean;
begin
STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error;
end if;
Entry_Call.Mode := Mode;
Entry_Call.State := Now_Abortable;
Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
PO_Do_Or_Queue (Self_Id, Object, Entry_Call'Access);
Unlock_Entry (Object);
-- The call is either `Done' or not. It cannot be cancelled since there
-- is no ATC construct.
pragma Assert (Entry_Call.State /= Cancelled);
if Entry_Call.State /= Done then
STPO.Write_Lock (Self_Id);
Wait_For_Completion (Self_Id, Entry_Call'Access);
STPO.Unlock (Self_Id);
end if;
Check_Exception (Self_Id, Entry_Call'Access);
end Protected_Single_Entry_Call;
-----------------------------------
-- Protected_Single_Entry_Caller --
-----------------------------------
function Protected_Single_Entry_Caller
(Object : Protection_Entry) return Task_ID is
begin
return Object.Call_In_Progress.Self;
end Protected_Single_Entry_Caller;
-------------------
-- Service_Entry --
-------------------
procedure Service_Entry (Object : Protection_Entry_Access) is
Self_Id : constant Task_ID := STPO.Self;
Entry_Call : constant Entry_Call_Link := Object.Entry_Queue;
Caller : Task_ID;
Barrier_Value : Boolean;
begin
if Entry_Call /= null then
Barrier_Value := Object.Entry_Body.Barrier (Object.Compiler_Info, 1);
if Barrier_Value then
if Object.Call_In_Progress /= null then
-- This violates the No_Entry_Queue restriction, send
-- Program_Error to the caller.
Send_Program_Error (Self_Id, Entry_Call);
return;
end if;
Object.Call_In_Progress := Entry_Call;
Object.Entry_Body.Action
(Object.Compiler_Info, Entry_Call.Uninterpreted_Data, 1);
Object.Call_In_Progress := null;
Caller := Entry_Call.Self;
STPO.Write_Lock (Caller);
Wakeup_Entry_Caller (Self_Id, Entry_Call, Done);
STPO.Unlock (Caller);
end if;
end if;
exception
when others =>
Send_Program_Error (Self_Id, Entry_Call);
end Service_Entry;
---------------------------------------
-- Timed_Protected_Single_Entry_Call --
---------------------------------------
-- Compiler interface only. Do not call from within the RTS.
procedure Timed_Protected_Single_Entry_Call
(Object : Protection_Entry_Access;
Uninterpreted_Data : System.Address;
Timeout : Duration;
Mode : Delay_Modes;
Entry_Call_Successful : out Boolean)
is
Self_Id : constant Task_ID := STPO.Self;
Entry_Call : Entry_Call_Record renames Self_Id.Entry_Calls (1);
Ceiling_Violation : Boolean;
begin
STPO.Write_Lock (Object.L'Access, Ceiling_Violation);
if Ceiling_Violation then
raise Program_Error;
end if;
Entry_Call.Mode := Timed_Call;
Entry_Call.State := Now_Abortable;
Entry_Call.Uninterpreted_Data := Uninterpreted_Data;
Entry_Call.Exception_To_Raise := Ada.Exceptions.Null_Id;
PO_Do_Or_Queue (Self_Id, Object, Entry_Call'Access);
Unlock_Entry (Object);
-- Try to avoid waiting for completed calls.
-- The call is either `Done' or not. It cannot be cancelled since there
-- is no ATC construct and the timed wait has not started yet.
pragma Assert (Entry_Call.State /= Cancelled);
if Entry_Call.State = Done then
Check_Exception (Self_Id, Entry_Call'Access);
Entry_Call_Successful := True;
return;
end if;
Wait_For_Completion_With_Timeout
(Self_Id, Entry_Call'Access, Timeout, Mode);
pragma Assert (Entry_Call.State >= Done);
Check_Exception (Self_Id, Entry_Call'Access);
Entry_Call_Successful := Entry_Call.State = Done;
end Timed_Protected_Single_Entry_Call;
------------------
-- Unlock_Entry --
------------------
procedure Unlock_Entry (Object : Protection_Entry_Access) is
begin
STPO.Unlock (Object.L'Access);
end Unlock_Entry;
end System.Tasking.Protected_Objects.Single_Entry;
|
-- Enter your code here. Read input from STDIN. Print output to STDOUT
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
procedure Solution is
function solveMeFirst (a, b: Integer) return Integer is
begin
-- Hint: Type return a+b; below
return a+b;
end solveMeFirst;
a, b, sum: Integer;
begin
Get (a);
Get (b);
sum := solveMeFirst(a, b);
Put (sum, Width => 1);
end Solution;
|
-- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . V I E W --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2014 David Botton --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- 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/>. --
-- --
-- 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. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
-- Views are used to handle auto insertion of objects in to the DOM and
-- placement. They are also the base of creating custom widgets.
with Ada_GUI.Gnoga.Gui.Element;
package Ada_GUI.Gnoga.Gui.View is
-------------------------------------------------------------------------
-- View_Base_Types
-------------------------------------------------------------------------
type View_Base_Type is new Gnoga.Gui.Element.Element_Type with private;
type View_Base_Access is access all View_Base_Type;
type Pointer_To_View_Base_Class is access all View_Base_Type'Class;
-- Note: In order for views to receive keyboard events the Tab_Index
-- property should be set to any value.
overriding
procedure Finalize (Object : in out View_Base_Type);
-- Deallocate any child element that was marked Dynamic before
-- being added to View. Child element's marked as Dynamic by calling
-- Element_Type.Dynamic then created with a View as the parent should
-- never be deallocated. If you plan on deallocating a child element in
-- your code, do not mark as Dynamic.
-------------------------------------------------------------------------
-- View_Base_Type - Methods
-------------------------------------------------------------------------
procedure Fill_Parent (View : in out View_Base_Type);
-- Cause View to expand its height and width to fill its parent's client
-- area. View's parent must have Position set to Absolute, Fixed or
-- Relative for Fill_Parent to work properly.
-- Note:
-- Position will be modified for View to either Absolute or Relative
-- if Absolute positioning fails (i.e. on IE)
procedure Put_Line (View : in out View_Base_Type;
Message : in String;
Class : in String := "";
ID : in String := "");
-- Create a new DIV with Message and append to end of view.
-- Use View.Overflow (Scroll) to allow scroll bars to view overflow
-- of data added by Put_Line. Class is an optional CSS class and
-- ID and option DOM ID.
procedure Put (View : in out View_Base_Type;
Message : in String;
Class : in String := "";
ID : in String := "");
-- Create a new SPAN with Message and append to end of view.
-- Spans are added inline unlike DIVs that are blocks taking up an
-- an entire row.
procedure New_Line (View : in out View_Base_Type);
-- Create a new <br /> and append to end of view
procedure Horizontal_Rule (View : in out View_Base_Type);
-- Create a new <hr /> and append to end of View
procedure Put_HTML (View : in out View_Base_Type;
HTML : in String;
Class : in String := "";
ID : in String := "");
-- Place HTML directly in to view. The HTML will not be wrapped in a DIV
-- or Span automatically, therefore HTML must be a complete block.
-- e.g. <p>I'm a block</p> <br>One line<br>Two Lines</br>But not a block
-- Use Put_Line or Put to wrap HTML.
procedure Load_File (View : in out View_Base_Type;
File_Name : in String;
Class : in String := "";
ID : in String := "");
-- Load contents of _local_ File_Name in to a <div>.
-- Unless path given uses Gnoga.Server.Templates_Directory
procedure Load_HTML (View : in out View_Base_Type;
File_Name : in String;
Class : in String := "";
ID : in String := "");
-- Load contents of _local_ HTML file called File_Name
-- All contents before <body> and after </body> will be discarded.
-- <body></body> will be replaced with <div></div> and Class and ID
-- set on them.
-- Unless path given uses Gnoga.Server.Templates_Directory
procedure Load_CSS (View : in out View_Base_Type;
URL : in String);
-- Appends <style src=URL> to document head
-- Unless path given uses Gnoga.Server.Templates_Directory
procedure Load_CSS_File (View : in out View_Base_Type;
File_Name : in String);
-- Load contents of local File_Name in to a <style> block and appends it
-- to document head.
-- Unless path given uses Gnoga.Server.Templates_Directory
procedure Add_Element
(View : in out View_Base_Type;
Name : in String;
Element : Gnoga.Gui.Element.Pointer_To_Element_Class);
-- Add Element to associative array of elements at Name and available using
-- the View_Base_Type's Element property. This does not re-parent the
-- Element to View if it was created with a different parent nor does it
-- add Element to the View's DOM. If Element with Name exists it will be
-- overwritten.
function New_Element
(View : access View_Base_Type;
Name : String;
Element : Gnoga.Gui.Element.Pointer_To_Element_Class)
return Gnoga.Gui.Element.Pointer_To_Element_Class;
-- Only use for dynamic objects.
-- Performs like Add_Element (View, Name, Element); Element.Dynamic;
-- It returns Element in order to allow for this idiom:
-- Common.Button_Access
-- (View.New_Element ("my button", new Common.Button_Type)).Create (View);
function Add
(View : access View_Base_Type;
Element : access Gnoga.Gui.Element.Element_Type'Class)
return Gnoga.Gui.Element.Pointer_To_Element_Class;
-- Only use for dynamic objects.
-- Marks Element as Dynamic and returns Element. This is primarily of value
-- for creating a dynamic element that you will no longer interact with
-- in the future since all reference is lost. Use New_Element if future
-- named access desired instead. Use with the following idiom:
-- Common.Button_Access
-- (View.Add (new Common.Button_Type)).Create (View);
-------------------------------------------------------------------------
-- View_Base_Type - Properties
-------------------------------------------------------------------------
function Element (View : View_Base_Type; Name : String)
return Gnoga.Gui.Element.Pointer_To_Element_Class;
-- Access elements added by Add_Element and New_Element
-- returns null if Name not found.
function Element_Names (View : View_Base_Type)
return Gnoga.Data_Array_Type;
-- Return an array of all the names of elements in the view's element
-- array
-------------------------------------------------------------------------
-- View_Base_Type - Event Methods
-------------------------------------------------------------------------
overriding
procedure On_Child_Added
(View : in out View_Base_Type;
Child : in out Gnoga.Gui.Base_Type'Class);
-- All children of views should be Element_Type'Class, if it is not
-- it will be ignored. Any child professing the View as its parent
-- will automatically have Element.Place_Inside_Bottom_Of (View) applied
-- to it.
-- Note: Only if an element is marked as dynamic before its Create is
-- called it is slated for garbage collection by View.
-------------------------------------------------------------------------
-- View_Types
-------------------------------------------------------------------------
type View_Type is new View_Base_Type with private;
type View_Access is access all View_Type;
type Pointer_To_View_Class is access all View_Type'Class;
-------------------------------------------------------------------------
-- View_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create
(View : in out View_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
ID : in String := "");
-- If Parent is a Window_Type'Class will automatically set itself
-- as the View on Parent if Attach is True.
private
type View_Base_Type is new Gnoga.Gui.Element.Element_Type with
record
Child_Array : Gnoga.Gui.Base_Type_Array;
Element_Map : Gnoga.Gui.Element.Element_Type_Map;
end record;
type View_Type is new View_Base_Type with null record;
end Ada_GUI.Gnoga.Gui.View;
|
with Ada.Numerics.Generic_Elementary_Functions;
package RTCH.Maths with
Pure is
pragma Warnings (Off); -- Turn off "unused" warning.
package Float_Elementary_Functions is new Ada.Numerics.Generic_Elementary_Functions (Float);
use Float_Elementary_Functions;
pragma Warnings (On);
Epsilon : constant := 0.00001;
function Equals (Left, Right : in Float) return Boolean is (if abs (Left - Right) < Epsilon then True else False);
end RTCH.Maths;
|
package STM32GD.USART is
pragma Preelaborate;
type USART_Instance is (USART_1, USART_2, USART_3);
end STM32GD.USART;
|
-----------------------------------------------------------------------
-- awa-users-module -- User management module
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 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.Applications;
with AWA.Modules;
with AWA.Users.Services;
with AWA.Users.Filters;
with AWA.Users.Servlets;
-- == Introduction ==
-- The <b>Users.Module</b> manages the creation, update, removal and authentication of users
-- in an application. The module provides the foundations for user management in
-- a web application.
--
-- A user can register himself by using a subscription form. In that case, a verification mail
-- is sent and the user has to follow the verification link defined in the mail to finish
-- the registration process. The user will authenticate using a password.
--
-- A user can also use an OpenID account and be automatically registered.
--
-- A user can have one or several permissions that allow to protect the application data.
-- User permissions are managed by the <b>Permissions.Module</b>.
--
-- == Configuration ==
-- The *users* module uses a set of configuration properties to configure the OpenID
-- integration.
--
-- @include users.xml
--
-- @include awa-users-services.ads
--
-- @include users.xml
--
-- == Model ==
-- [http://ada-awa.googlecode.com/svn/wiki/awa_user_model.png]
--
-- @include User.hbm.xml
package AWA.Users.Modules is
NAME : constant String := "users";
type User_Module is new AWA.Modules.Module with private;
type User_Module_Access is access all User_Module'Class;
-- Initialize the user module.
overriding
procedure Initialize (Plugin : in out User_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config);
-- Get the user manager.
function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Create a user manager. This operation can be overriden to provide another
-- user service implementation.
function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access;
-- Get the user module instance associated with the current application.
function Get_User_Module return User_Module_Access;
-- Get the user manager instance associated with the current application.
function Get_User_Manager return Services.User_Service_Access;
private
type User_Module is new AWA.Modules.Module with record
Manager : Services.User_Service_Access := null;
Key_Filter : aliased AWA.Users.Filters.Verify_Filter;
Auth_Filter : aliased AWA.Users.Filters.Auth_Filter;
Auth : aliased AWA.Users.Servlets.Request_Auth_Servlet;
Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet;
end record;
end AWA.Users.Modules;
|
-- SPDX-License-Identifier: MIT
--
-- Contributed by ITEC - NXP Semiconductors
-- June 2008
--
-- Copyright (c) 2008 - 2018 Gautier de Montmollin (maintainer)
-- SWITZERLAND
--
-- 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.
-- The DCF.Streams package defines an abstract stream
-- type, Root_Zipstream_Type, with name, time and an index for random access.
--
-- In addition, this package provides two ready-to-use derivations:
--
-- - Array_Zipstream, for using in-memory streaming
-- - File_Zipstream, for accessing files
private with Ada.Finalization;
with Ada.Streams.Stream_IO;
with Ada.Strings.Unbounded;
use Ada.Streams;
use Ada.Strings.Unbounded;
package DCF.Streams is
pragma Preelaborate;
type Time is private;
-- We define an own Time (Ada.Calendar's body can be very time-consuming!)
-- See child package Calendar for own Split, Time_Of and Convert from/to
-- Ada.Calendar.Time.
Default_Time : constant Time; -- Some default time
------------------------------------------------------
-- Root_Zipstream_Type: root abstract stream type --
------------------------------------------------------
type Root_Zipstream_Type is abstract new Ada.Streams.Root_Stream_Type with private;
type Zipstream_Class_Access is access all Root_Zipstream_Type'Class;
subtype Zs_Size_Type is Integer_64 range 0 .. Integer_64'Last;
subtype Zs_Index_Type is Zs_Size_Type range 1 .. Zs_Size_Type'Last;
-- Set the index on the stream
procedure Set_Index (S : in out Root_Zipstream_Type; To : Zs_Index_Type) is abstract;
-- Returns the index of the stream
function Index (S : in Root_Zipstream_Type) return Zs_Index_Type is abstract;
-- Returns the Size of the stream
function Size (S : in Root_Zipstream_Type) return Zs_Size_Type is abstract;
procedure Set_Name (S : in out Root_Zipstream_Type; Name : String; UTF_8 : Boolean := False);
-- This procedure returns the name of the stream
function Get_Name (S : in Root_Zipstream_Type) return String;
function UTF_8_Encoding (S : in Root_Zipstream_Type) return Boolean;
-- This procedure sets the Modification_Time of the stream
procedure Set_Time (S : in out Root_Zipstream_Type; Modification_Time : Time);
-- This procedure returns the ModificationTime of the stream
function Get_Time (S : in Root_Zipstream_Type) return Time;
-- Returns true if the index is at the end of the stream, else false
function End_Of_Stream (S : in Root_Zipstream_Type) return Boolean is abstract;
----------------------------------------------
-- File_Zipstream: stream based on a file --
----------------------------------------------
type File_Zipstream is new Root_Zipstream_Type with private;
type File_Mode is new Ada.Streams.Stream_IO.File_Mode;
function Open (File_Name : String) return File_Zipstream;
-- Open a file for reading
function Create (File_Name : String) return File_Zipstream;
-- Create a file on the disk
--------------------------------------------------------------
-- Array_Zipstream: stream based on a Stream_Element_Array --
--------------------------------------------------------------
type Array_Zipstream
(Elements : not null access Stream_Element_Array) is new Root_Zipstream_Type with private;
-----------------------------------------------------------------------------
subtype Dos_Time is Unsigned_32;
function Convert (Date : in Dos_Time) return Time;
function Convert (Date : in Time) return Dos_Time;
private
-- Time. Currently, DOS format (pkzip appnote.txt: part V., J.), as stored
-- in Zip archives. Subject to change, this is why this type is private.
type Time is new Unsigned_32;
Default_Time : constant Time := 16789 * 65536;
type Root_Zipstream_Type is abstract new Ada.Streams.Root_Stream_Type with record
Name : Unbounded_String;
Modification_Time : Time := Default_Time;
UTF_8 : Boolean := False;
end record;
-----------------------------------------------------------------------------
type Open_File is limited new Ada.Finalization.Limited_Controlled with record
File : Ada.Streams.Stream_IO.File_Type;
Finalized : Boolean := False;
end record;
overriding
procedure Finalize (Object : in out Open_File);
-----------------------------------------------------------------------------
type File_Zipstream is new Root_Zipstream_Type with record
File : Open_File;
end record;
-- Read data from the stream
overriding
procedure Read
(Stream : in out File_Zipstream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- Write data to the stream, starting from the current index.
-- Data will be overwritten from index if already available.
overriding
procedure Write (Stream : in out File_Zipstream; Item : Stream_Element_Array);
-- Set the index on the stream
overriding
procedure Set_Index (S : in out File_Zipstream; To : Zs_Index_Type);
-- Returns the index of the stream
overriding
function Index (S : in File_Zipstream) return Zs_Index_Type;
-- Returns the Size of the stream
overriding
function Size (S : in File_Zipstream) return Zs_Size_Type;
-- Returns true if the index is at the end of the stream
overriding
function End_Of_Stream (S : in File_Zipstream) return Boolean;
-----------------------------------------------------------------------------
type Array_Zipstream
(Elements : not null access Stream_Element_Array) is new Root_Zipstream_Type with
record
Index : Stream_Element_Offset := Elements'First;
EOF : Boolean := False;
end record;
overriding
procedure Read
(Stream : in out Array_Zipstream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
overriding
procedure Write
(Stream : in out Array_Zipstream;
Item : Stream_Element_Array);
overriding
procedure Set_Index (Stream : in out Array_Zipstream; To : Zs_Index_Type);
overriding
function Index (Stream : in Array_Zipstream) return Zs_Index_Type is
(Zs_Index_Type (Stream.Index));
overriding
function Size (Stream : in Array_Zipstream) return Zs_Size_Type is
(Zs_Size_Type (Stream.Elements'Length));
overriding
function End_Of_Stream (Stream : in Array_Zipstream) return Boolean is
(Stream.Size < Index (Stream));
end DCF.Streams;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
package Program.Elements.Statements is
pragma Pure (Program.Elements.Statements);
type Statement is limited interface and Program.Elements.Element;
type Statement_Access is access all Statement'Class with Storage_Size => 0;
end Program.Elements.Statements;
|
-- C85006F.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 A RENAMED SLICE CAN BE SLICED AND INDEXED FOR PURPOSES
-- OF ASSIGNMENT AND TO READ THE VALUE.
-- HISTORY:
-- JET 07/26/88 CREATED ORIGINAL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C85006F IS
S : STRING(1..30) := "IT WAS A DARK AND STORMY NIGHT";
ADJECTIVES : STRING RENAMES S(10..24);
BEGIN
TEST ("C85006F", "CHECK THAT A RENAMED SLICE CAN BE SLICED AND " &
"INDEXED FOR PURPOSES OF ASSIGNMENT AND TO " &
"READ THE VALUE");
ADJECTIVES(19..24) := "STARRY";
IF ADJECTIVES /= IDENT_STR("DARK AND STARRY") THEN
FAILED ("INCORRECT VALUE OF SLICE AFTER ASSIGNMENT (1)");
END IF;
IF S /= IDENT_STR("IT WAS A DARK AND STARRY NIGHT") THEN
FAILED ("INCORRECT VALUE OF ORIGINAL STRING (1)");
END IF;
ADJECTIVES(17) := ''';
IF ADJECTIVES /= IDENT_STR("DARK AN' STARRY") THEN
FAILED ("INCORRECT VALUE OF SLICE AFTER ASSIGNMENT (2)");
END IF;
IF S /= IDENT_STR("IT WAS A DARK AN' STARRY NIGHT") THEN
FAILED ("INCORRECT VALUE OF ORIGINAL STRING (2)");
END IF;
IF ADJECTIVES(10..13) /= IDENT_STR("DARK") THEN
FAILED ("INCORRECT VALUE OF SLICE WHEN READING");
END IF;
RESULT;
END C85006F;
|
-- 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.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Tcl.Lists; use Tcl.Lists;
package body Tk.Grid is
-- ****if* Grid/Grid.Options_To_String
-- FUNCTION
-- Convert Ada structure to Tcl command
-- PARAMETERS
-- Options - Ada Grid_Options to convert
-- RESULT
-- String with Tcl command options
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
function Options_To_String(Options: Grid_Options) return String is
-- ****
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "column", Value => Options.Column,
Options_String => Options_String);
Option_Image
(Name => "columnspan", Value => Options.Column_Span,
Options_String => Options_String);
Option_Image
(Name => "in", Value => Options.In_Master,
Options_String => Options_String);
Option_Image
(Name => "ipadx", Value => Options.Internal_Pad_X,
Options_String => Options_String);
Option_Image
(Name => "ipady", Value => Options.Internal_Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "padx", Value => Options.Pad_X,
Options_String => Options_String);
Option_Image
(Name => "pady", Value => Options.Pad_Y,
Options_String => Options_String);
Option_Image
(Name => "row", Value => Options.Row,
Options_String => Options_String);
Option_Image
(Name => "rowspan", Value => Options.Row_Span,
Options_String => Options_String);
if Options.Sticky /= NONE then
Append(Source => Options_String, New_Item => " -sticky ");
case Options.Sticky is
when CENTER =>
Append(Source => Options_String, New_Item => "{}");
when HEIGHT =>
Append(Source => Options_String, New_Item => "ns");
when WIDTH =>
Append(Source => Options_String, New_Item => "we");
when WHOLE =>
Append(Source => Options_String, New_Item => "nwes");
when N =>
Append(Source => Options_String, New_Item => "n");
when W =>
Append(Source => Options_String, New_Item => "w");
when E =>
Append(Source => Options_String, New_Item => "e");
when S =>
Append(Source => Options_String, New_Item => "s");
when NW =>
Append(Source => Options_String, New_Item => "nw");
when NE =>
Append(Source => Options_String, New_Item => "ne");
when SW =>
Append(Source => Options_String, New_Item => "sw");
when SE =>
Append(Source => Options_String, New_Item => "se");
when NONE =>
null;
end case;
end if;
return To_String(Source => Options_String);
end Options_To_String;
procedure Add
(Child: Tk_Widget; Options: Grid_Options := Default_Grid_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid " & Tk_Path_Name(Widgt => Child) &
Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Child));
end Add;
procedure Add
(Widgets: Widgets_Array; Options: Grid_Options := Default_Grid_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid " & Widgets_Array_Image(Widgets => Widgets) &
Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Widgets(1)));
end Add;
procedure Set_Anchor(Master: Tk_Widget; New_Direction: Directions_Type) is
begin
Tcl_Eval
(Tcl_Script =>
"grid anchor " & Tk_Path_Name(Widgt => Master) & " " &
To_Lower(Item => Directions_Type'Image(New_Direction)),
Interpreter => Tk_Interp(Widgt => Master));
end Set_Anchor;
function Get_Bounding_Box
(Master: Tk_Widget; Column, Row, Column2, Row2: Natural)
return Bbox_Data is
Result_List: Array_List(1 .. 4);
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
begin
Result_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"grid bbox " & Tk_Path_Name(Widgt => Master) &
Natural'Image(Column) & Natural'Image(Row) &
Natural'Image(Column2) & Natural'Image(Row2),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
return Coords: Bbox_Data := Empty_Bbox_Data do
Coords.Start_X :=
Natural'Value(To_Ada_String(Source => Result_List(1)));
Coords.Start_Y :=
Natural'Value(To_Ada_String(Source => Result_List(2)));
Coords.Width :=
Natural'Value(To_Ada_String(Source => Result_List(3)));
Coords.Height :=
Natural'Value(To_Ada_String(Source => Result_List(4)));
end return;
end Get_Bounding_Box;
function Get_Bounding_Box
(Master: Tk_Widget; Column, Row: Natural) return Bbox_Data is
Result_List: Array_List(1 .. 4);
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
begin
Result_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"grid bbox " & Tk_Path_Name(Widgt => Master) &
Natural'Image(Column) & Natural'Image(Row),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
return Coords: Bbox_Data := Empty_Bbox_Data do
Coords.Start_X :=
Natural'Value(To_Ada_String(Source => Result_List(1)));
Coords.Start_Y :=
Natural'Value(To_Ada_String(Source => Result_List(2)));
Coords.Width :=
Natural'Value(To_Ada_String(Source => Result_List(3)));
Coords.Height :=
Natural'Value(To_Ada_String(Source => Result_List(4)));
end return;
end Get_Bounding_Box;
function Get_Bounding_Box(Master: Tk_Widget) return Bbox_Data is
Result_List: Array_List(1 .. 4);
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
begin
Result_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "grid bbox " & Tk_Path_Name(Widgt => Master),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
return Coords: Bbox_Data := Empty_Bbox_Data do
Coords.Start_X :=
Natural'Value(To_Ada_String(Source => Result_List(1)));
Coords.Start_Y :=
Natural'Value(To_Ada_String(Source => Result_List(2)));
Coords.Width :=
Natural'Value(To_Ada_String(Source => Result_List(3)));
Coords.Height :=
Natural'Value(To_Ada_String(Source => Result_List(4)));
end return;
end Get_Bounding_Box;
-- ****if* Grid/Grid.Column_Options_To_String
-- FUNCTION
-- Convert Ada structure to Tcl command
-- PARAMETERS
-- Options - Ada Column_Options to convert
-- RESULT
-- String with Tcl command options
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
function Column_Options_To_String(Options: Column_Options) return String is
-- ****
Options_String: Unbounded_String := Null_Unbounded_String;
begin
Option_Image
(Name => "minsize", Value => Options.Min_Size,
Options_String => Options_String);
Option_Image
(Name => "weight", Value => Options.Weight,
Options_String => Options_String);
Option_Image
(Name => "uniform", Value => Options.Uniform,
Options_String => Options_String);
Option_Image
(Name => "pad", Value => Options.Pad,
Options_String => Options_String);
return To_String(Source => Options_String);
end Column_Options_To_String;
procedure Column_Configure
(Master: Tk_Widget; Child_Name: Tcl_String; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid columnconfigure " & Tk_Path_Name(Widgt => Master) & " " &
To_String(Source => Child_Name) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Column_Configure;
procedure Column_Configure
(Master, Child: Tk_Widget; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid columnconfigure " & Tk_Path_Name(Widgt => Master) & " " &
Tk_Path_Name(Widgt => Child) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Column_Configure;
procedure Column_Configure
(Master: Tk_Widget; Column: Natural; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid columnconfigure " & Tk_Path_Name(Widgt => Master) &
Natural'Image(Column) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Column_Configure;
-- ****if* Grid/Grid.Get_Value_(Pixel_Data)
-- FUNCTION
-- Get the value of the selected column or row configuration
-- PARAMETERS
-- Master - Tk_Widget which is master of the selected grid geometry
-- manager
-- Name - Name of the option to get
-- Config_Type - Type of config. Can be column or row
-- Index - Index of the column or row which option will be get
-- RESULT
-- Pixel_Data structure with value of the selected option
-- HISTORY
-- 8.6.0 - Added
-- SEE ALSO
-- Grid.Get_Value_(Tcl_String), Grid.Get_Value_(Extended_Natural)
-- SOURCE
function Get_Value
(Master: Tk_Widget; Name, Config_Type: String; Index: Natural)
return Pixel_Data is
-- ****
begin
return
Pixel_Data_Value
(Value =>
Tcl_Eval
(Tcl_Script =>
"grid " & Config_Type & "configure " &
Tk_Path_Name(Widgt => Master) & Natural'Image(Index) & " -" &
Name,
Interpreter => Tk_Interp(Widgt => Master))
.Result);
end Get_Value;
-- ****if* Grid/Grid.Get_Value_(Tcl_String)
-- FUNCTION
-- Get the value of the selected column or row configuration
-- PARAMETERS
-- Master - Tk_Widget which is master of the selected grid geometry
-- manager
-- Name - Name of the option to get
-- Config_Type - Type of config. Can be column or row
-- Index - Index of the column or row which option will be get
-- RESULT
-- Tcl_String with value of the selected option
-- HISTORY
-- 8.6.0 - Added
-- SEE ALSO
-- Grid.Get_Value_(Pixel_Data), Grid.Get_Value_(Extended_Natural)
-- SOURCE
function Get_Value
(Master: Tk_Widget; Name, Config_Type: String; Index: Natural)
return Tcl_String is
-- ****
begin
return
To_Tcl_String
(Source =>
Tcl_Eval
(Tcl_Script =>
"grid " & Config_Type & "configure " &
Tk_Path_Name(Widgt => Master) & Natural'Image(Index) & " -" &
Name,
Interpreter => Tk_Interp(Widgt => Master))
.Result);
end Get_Value;
-- ****if* Grid/Grid.Get_Value_(Extended_Natural)
-- FUNCTION
-- Get the value of the selected column or row configuration
-- PARAMETERS
-- Master - Tk_Widget which is master of the selected grid geometry
-- manager
-- Name - Name of the option to get
-- Config_Type - Type of config. Can be column or row
-- Index - Index of the column or row which option will be get
-- RESULT
-- Extended_Natural with value of the selected option
-- HISTORY
-- 8.6.0 - Added
-- SEE ALSO
-- Grid.Get_Value_(Pixel_Data), Grid.Get_Value_(Tcl_String)
-- SOURCE
function Get_Value
(Master: Tk_Widget; Name, Config_Type: String; Index: Natural)
return Extended_Natural is
-- ****
begin
return
Extended_Natural'Value
(Tcl_Eval
(Tcl_Script =>
"grid " & Config_Type & "configure " &
Tk_Path_Name(Widgt => Master) & Natural'Image(Index) & " -" &
Name,
Interpreter => Tk_Interp(Widgt => Master))
.Result);
end Get_Value;
function Get_Column_Options
(Master: Tk_Widget; Column: Natural) return Column_Options is
begin
return Options: Column_Options := Default_Column_Options do
Options.Min_Size :=
Get_Value
(Master => Master, Name => "minsize", Config_Type => "column",
Index => Column);
Options.Weight :=
Get_Value
(Master => Master, Name => "weight", Config_Type => "column",
Index => Column);
Options.Uniform :=
Get_Value
(Master => Master, Name => "uniform", Config_Type => "column",
Index => Column);
Options.Pad :=
Get_Value
(Master => Master, Name => "pad", Config_Type => "column",
Index => Column);
end return;
end Get_Column_Options;
procedure Configure(Child: Tk_Widget; Options: Grid_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid configure " & Tk_Path_Name(Widgt => Child) &
Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Child));
end Configure;
procedure Configure(Widgets: Widgets_Array; Options: Grid_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid configure " & Widgets_Array_Image(Widgets => Widgets) &
Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Widgets(1)));
end Configure;
procedure Forget(Child: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "grid forget " & Tk_Path_Name(Widgt => Child),
Interpreter => Tk_Interp(Widgt => Child));
end Forget;
procedure Forget(Widgets: Widgets_Array) is
begin
Tcl_Eval
(Tcl_Script =>
"grid forget " & Widgets_Array_Image(Widgets => Widgets),
Interpreter => Tk_Interp(Widgt => Widgets(1)));
end Forget;
function Get_Info(Child: Tk_Widget) return Grid_Options is
Options_Names: constant array(1 .. 10) of Unbounded_String :=
(1 => To_Unbounded_String(Source => "-in"),
2 => To_Unbounded_String(Source => "-column"),
3 => To_Unbounded_String(Source => "-row"),
4 => To_Unbounded_String(Source => "-columnspan"),
5 => To_Unbounded_String(Source => "-rowspan"),
6 => To_Unbounded_String(Source => "-ipadx"),
7 => To_Unbounded_String(Source => "-ipady"),
8 => To_Unbounded_String(Source => "-padx"),
9 => To_Unbounded_String(Source => "-pady"),
10 => To_Unbounded_String(Source => "-sticky"));
Options: Grid_Options := Default_Grid_Options;
Start_Index, End_Index: Positive := 1;
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Child);
begin
Tcl_Eval
(Tcl_Script => "grid info " & Tk_Path_Name(Widgt => Child),
Interpreter => Interpreter);
Parse_Result_Block :
declare
use Ada.Strings.Fixed;
Result: constant String := Tcl_Get_Result(Interpreter => Interpreter);
function Horizontal_Pad_Data_Value
(Value: String) return Horizontal_Pad_Data is
Result_List: constant Array_List :=
Split_List(List => Value, Interpreter => Interpreter);
begin
return
Result_Pad: Horizontal_Pad_Data := Default_Horizontal_Pad_Data do
Result_Pad.Left :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(1)));
Result_Pad.Right :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(1)));
end return;
end Horizontal_Pad_Data_Value;
function Vertical_Pad_Data_Value
(Value: String) return Vertical_Pad_Data is
Result_List: constant Array_List :=
Split_List(List => Value, Interpreter => Interpreter);
begin
return
Result_Pad: Vertical_Pad_Data := Default_Vertical_Pad_Data do
Result_Pad.Top :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(1)));
Result_Pad.Bottom :=
Pixel_Data_Value
(Value => To_Ada_String(Source => Result_List(1)));
end return;
end Vertical_Pad_Data_Value;
begin
Set_Options_Loop :
for I in Options_Names'Range loop
Start_Index :=
Index
(Source => Result,
Pattern => To_String(Source => Options_Names(I))) +
Length(Source => Options_Names(I)) + 1;
if I < Options_Names'Last then
End_Index :=
Index
(Source => Result,
Pattern => To_String(Source => Options_Names(I + 1))) -
2;
else
End_Index := Result'Last;
end if;
case I is
when 1 =>
Options.In_Master :=
Get_Widget
(Path_Name => Result(Start_Index .. End_Index),
Interpreter => Interpreter);
when 2 =>
Options.Column :=
Extended_Natural'Value(Result(Start_Index .. End_Index));
when 3 =>
Options.Row :=
Extended_Natural'Value(Result(Start_Index .. End_Index));
when 4 =>
Options.Column_Span :=
Extended_Natural'Value(Result(Start_Index .. End_Index));
when 5 =>
Options.Row_Span :=
Extended_Natural'Value(Result(Start_Index .. End_Index));
when 6 =>
Options.Internal_Pad_X :=
Pixel_Data_Value
(Value => Result(Start_Index .. End_Index));
when 7 =>
Options.Internal_Pad_Y :=
Pixel_Data_Value
(Value => Result(Start_Index .. End_Index));
when 8 =>
Options.Pad_X :=
Horizontal_Pad_Data_Value
(Value => Result(Start_Index .. End_Index));
when 9 =>
Options.Pad_Y :=
Vertical_Pad_Data_Value
(Value => Result(Start_Index .. End_Index));
when 10 =>
if Result(Start_Index .. End_Index) = "n" then
Options.Sticky := N;
elsif Result(Start_Index .. End_Index) = "s" then
Options.Sticky := S;
elsif Result(Start_Index .. End_Index) = "w" then
Options.Sticky := W;
elsif Result(Start_Index .. End_Index) = "e" then
Options.Sticky := E;
elsif Result(Start_Index .. End_Index) = "{}" then
Options.Sticky := CENTER;
elsif Result(Start_Index .. End_Index) in "nw" | "wn" then
Options.Sticky := NW;
elsif Result(Start_Index .. End_Index) in "ne" | "en" then
Options.Sticky := NE;
elsif Result(Start_Index .. End_Index) in "sw" | "ws" then
Options.Sticky := SW;
elsif Result(Start_Index .. End_Index) in "se" | "es" then
Options.Sticky := SE;
elsif Result(Start_Index .. End_Index) in "ns" | "sn" then
Options.Sticky := HEIGHT;
elsif Result(Start_Index .. End_Index) in "we" | "ew" then
Options.Sticky := WIDTH;
else
Options.Sticky := WHOLE;
end if;
end case;
end loop Set_Options_Loop;
end Parse_Result_Block;
return Options;
end Get_Info;
function Get_Location
(Master: Tk_Widget; X, Y: Pixel_Data) return Location_Position is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
Result_List: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"grid location " & Tk_Path_Name(Widgt => Master) &
Positive_Float'Image(X.Value) &
To_Lower(Item => Pixel_Unit'Image(X.Value_Unit)) &
Positive_Float'Image(Y.Value) &
To_Lower(Item => Pixel_Unit'Image(Y.Value_Unit)),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return
(Column =>
Extended_Natural'Value(To_Ada_String(Source => Result_List(1))),
Row =>
Extended_Natural'Value(To_Ada_String(Source => Result_List(2))));
end Get_Location;
procedure Set_Propagate(Master: Tk_Widget; Enable: Boolean := True) is
begin
Tcl_Eval
(Tcl_Script =>
"grid propagate " & Tk_Path_Name(Widgt => Master) & " " &
To_Lower(Item => Boolean'Image(Enable)),
Interpreter => Tk_Interp(Widgt => Master));
end Set_Propagate;
procedure Row_Configure
(Master: Tk_Widget; Child_Name: Tcl_String; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid rowconfigure " & Tk_Path_Name(Widgt => Master) & " " &
To_String(Source => Child_Name) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Row_Configure;
procedure Row_Configure
(Master, Child: Tk_Widget; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid rowconfigure " & Tk_Path_Name(Widgt => Master) & " " &
Tk_Path_Name(Widgt => Child) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Row_Configure;
procedure Row_Configure
(Master: Tk_Widget; Row: Natural; Options: Column_Options) is
begin
Tcl_Eval
(Tcl_Script =>
"grid rowconfigure " & Tk_Path_Name(Widgt => Master) &
Natural'Image(Row) & " " &
Column_Options_To_String(Options => Options),
Interpreter => Tk_Interp(Widgt => Master));
end Row_Configure;
function Get_Row_Options
(Master: Tk_Widget; Row: Natural) return Column_Options is
begin
return Options: Column_Options := Default_Column_Options do
Options.Min_Size :=
Get_Value
(Master => Master, Name => "minsize", Config_Type => "row",
Index => Row);
Options.Weight :=
Get_Value
(Master => Master, Name => "weight", Config_Type => "row",
Index => Row);
Options.Uniform :=
Get_Value
(Master => Master, Name => "uniform", Config_Type => "row",
Index => Row);
Options.Pad :=
Get_Value
(Master => Master, Name => "pad", Config_Type => "row",
Index => Row);
end return;
end Get_Row_Options;
procedure Remove(Child: Tk_Widget) is
begin
Tcl_Eval
(Tcl_Script => "grid remove " & Tk_Path_Name(Widgt => Child),
Interpreter => Tk_Interp(Widgt => Child));
end Remove;
procedure Remove(Widgets: Widgets_Array) is
begin
Tcl_Eval
(Tcl_Script =>
"grid remove " & Widgets_Array_Image(Widgets => Widgets),
Interpreter => Tk_Interp(Widgt => Widgets(1)));
end Remove;
function Get_Size(Master: Tk_Widget) return Location_Position is
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
Result_List: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script => "grid size " & Tk_Path_Name(Widgt => Master),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return
(Column =>
Extended_Natural'Value(To_Ada_String(Source => Result_List(1))),
Row =>
Extended_Natural'Value(To_Ada_String(Source => Result_List(2))));
end Get_Size;
function Get_Slaves
(Master: Tk_Widget; Row, Column: Extended_Natural := -1)
return Widgets_Array is
Options: Unbounded_String := Null_Unbounded_String;
Interpreter: constant Tcl_Interpreter := Tk_Interp(Widgt => Master);
begin
if Row > -1 then
Append
(Source => Options,
New_Item => " -row" & Extended_Natural'Image(Row));
end if;
if Column > -1 then
Append
(Source => Options,
New_Item => " -column" & Extended_Natural'Image(Column));
end if;
Return_Block :
declare
Result_List: constant Array_List :=
Split_List
(List =>
Tcl_Eval
(Tcl_Script =>
"grid slaves " & Tk_Path_Name(Widgt => Master) &
To_String(Source => Options),
Interpreter => Interpreter)
.Result,
Interpreter => Interpreter);
begin
return
Widgets: Widgets_Array(1 .. Result_List'Last) :=
(others => Null_Widget) do
Fill_Result_Array_Loop :
for I in 1 .. Result_List'Last loop
Widgets(I) :=
Get_Widget
(Path_Name => To_Ada_String(Source => Result_List(I)),
Interpreter => Interpreter);
end loop Fill_Result_Array_Loop;
end return;
end Return_Block;
end Get_Slaves;
end Tk.Grid;
|
-- C64108A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT ALL PERMITTED FORMS OF VARIABLE NAMES ARE PERMITTED
-- AS ACTUAL PARAMETERS.
-- DAS 2/10/81
-- SPS 10/26/82
-- SPS 11/5/82
WITH REPORT;
PROCEDURE C64108A IS
USE REPORT;
SUBTYPE INT IS INTEGER RANGE 1..3;
TYPE REC (N : INT) IS
RECORD
S : STRING (1..N);
END RECORD;
TYPE PTRSTR IS ACCESS STRING;
R1,R2,R3 : REC(3);
S1,S2,S3 : STRING (1..3);
PTRTBL : ARRAY (1..3) OF PTRSTR;
PROCEDURE P1 (S1 : IN STRING; S2: IN OUT STRING;
S3 : OUT STRING) IS
BEGIN
S3 := S2;
S2 := S1;
END P1;
PROCEDURE P2 (C1 : IN CHARACTER; C2 : IN OUT CHARACTER;
C3 : OUT CHARACTER) IS
BEGIN
C3 := C2;
C2 := C1;
END P2;
FUNCTION F1 (X : INT) RETURN PTRSTR IS
BEGIN
RETURN PTRTBL(X);
END F1;
FUNCTION "+" (S1,S2 : STRING) RETURN PTRSTR IS
BEGIN
RETURN PTRTBL(CHARACTER'POS(S1(1))-CHARACTER'POS('A')+1);
END "+";
BEGIN
TEST ("C64108A", "CHECK THAT ALL PERMITTED FORMS OF VARIABLE" &
" NAMES ARE PERMITTED AS ACTUAL PARAMETERS");
S1 := "AAA";
S2 := "BBB";
P1 (S1, S2, S3);
IF (S2 /= "AAA") OR (S3 /= "BBB") THEN
FAILED ("SIMPLE VARIABLE AS AN ACTUAL PARAMETER NOT WORKING");
END IF;
S1 := "AAA";
S2 := "BBB";
S3 := IDENT_STR("CCC");
P2 (S1(1), S2(IDENT_INT(1)), S3(1));
IF (S2 /= "ABB") OR (S3 /= "BCC") THEN
FAILED ("INDEXED COMPONENT AS AN ACTUAL PARAMETER NOT " &
"WORKING");
END IF;
R1.S := "AAA";
R2.S := "BBB";
P1 (R1.S, R2.S, R3.S);
IF (R2.S /= "AAA") OR (R3.S /= "BBB") THEN
FAILED ("SELECTED COMPONENT AS AN ACTUAL PARAMETER" &
" NOT WORKING");
END IF;
S1 := "AAA";
S2 := "BBB";
P1 (S1(1..IDENT_INT(2)), S2(1..2), S3(IDENT_INT(1)..IDENT_INT(2)));
IF (S2 /= "AAB") OR (S3 /= "BBC") THEN
FAILED ("SLICE AS AN ACTUAL PARAMETER NOT WORKING");
END IF;
PTRTBL(1) := NEW STRING'("AAA");
PTRTBL(2) := NEW STRING'("BBB");
PTRTBL(3) := NEW STRING'("CCC");
P1 (F1(1).ALL, F1(2).ALL, F1(IDENT_INT(3)).ALL);
IF (PTRTBL(2).ALL /= "AAA") OR (PTRTBL(3).ALL /= "BBB") THEN
FAILED ("SELECTED COMPONENT OF FUNCTION VALUE AS AN ACTUAL" &
" PARAMETER NOT WORKING");
END IF;
PTRTBL(1) := NEW STRING'("AAA");
PTRTBL(2) := NEW STRING'("BBB");
PTRTBL(3) := NEW STRING'("CCC");
S1 := IDENT_STR("AAA");
S2 := IDENT_STR("BBB");
S3 := IDENT_STR("CCC");
P1 ("+"(S1,S1).ALL, "+"(S2,S2).ALL, "+"(S3,S3).ALL);
IF (PTRTBL(2).ALL /= "AAA") OR (PTRTBL(3).ALL /= "BBB") THEN
FAILED ("SELECTED COMPONENT OF OVERLOADED OPERATOR FUNCTION" &
" VALUE AS AN ACTUAL PARAMETER NOT WORKING");
END IF;
PTRTBL(1) := NEW STRING'("AAA");
PTRTBL(2) := NEW STRING'("BBB");
PTRTBL(3) := NEW STRING'("CCC");
P2 (F1(1)(1), F1(IDENT_INT(2))(1), F1(3)(IDENT_INT(1)));
IF (PTRTBL(2).ALL /= "ABB") OR (PTRTBL(3).ALL /= "BCC") THEN
FAILED ("INDEXED COMPONENT OF FUNCTION VALUE AS AN ACTUAL" &
" PARAMETER NOT WORKING");
END IF;
PTRTBL(1) := NEW STRING'("AAA");
PTRTBL(2) := NEW STRING'("BBB");
PTRTBL(3) := NEW STRING'("CCC");
P1 (F1(1)(2..3), F1(2)(IDENT_INT(2)..3), F1(3)(2..IDENT_INT(3)));
IF (PTRTBL(2).ALL /= "BAA") OR (PTRTBL(3).ALL /= "CBB") THEN
FAILED ("SLICE OF FUNCTION VALUE AS AN ACTUAL PARAMETER" &
" NOT WORKING");
END IF;
RESULT;
END C64108A;
|
------------------------------------------------------------------------------
-- G E L A X 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 Ada.Strings.Fixed;
with Ada.Strings.Maps.Constants;
package body XASIS.Fractions is
use XASIS.Integers;
function Val (X : Integer) return I.Value;
function NOD (X, Y : I.Value) return I.Value;
procedure Simplify (X : in out Fraction);
---------
-- Val --
---------
function Val (X : Integer) return I.Value is
begin
return Literal (Integer'Image (X));
end Val;
---------
-- "*" --
---------
function "*" (Left, Right : Fraction) return Fraction is
Result : Fraction :=
(Left.Numerator * Right.Numerator,
Left.Denominator * Right.Denominator,
Left.Exponent + Right.Exponent);
begin
Simplify (Result);
return Result;
end "*";
----------
-- "**" --
----------
function "**" (Left : Fraction; Right : I.Value) return Fraction is
begin
if Right > I.Zero then
return (Left.Numerator ** Right,
Left.Denominator ** Right,
Left.Exponent * Right);
else
return (One / Left) ** (-Right);
end if;
end "**";
---------
-- "+" --
---------
function "+" (Left, Right : Fraction) return Fraction is
Min_Exp : I.Value := Left.Exponent;
L : Fraction := Left;
R : Fraction := Right;
Result : Fraction;
begin
if Min_Exp > Right.Exponent then
Min_Exp := Right.Exponent;
end if;
if L.Exponent > Min_Exp then
L.Numerator := L.Numerator * Ten ** (L.Exponent - Min_Exp);
elsif R.Exponent > Min_Exp then
R.Numerator := R.Numerator * Ten ** (R.Exponent - Min_Exp);
end if;
Result := (L.Numerator * R.Denominator + R.Numerator * L.Denominator,
L.Denominator * R.Denominator,
Min_Exp);
Simplify (Result);
return Result;
end "+";
---------
-- "-" --
---------
function "-" (Left : Fraction) return Fraction is
begin
return (-Left.Numerator, Left.Denominator, Left.Exponent);
end "-";
---------
-- "-" --
---------
function "-" (Left, Right : Fraction) return Fraction is
begin
return Left + (-Right);
end "-";
---------
-- "/" --
---------
function "/" (Left, Right : Fraction) return Fraction is
Reciprocal : constant Fraction :=
(Right.Denominator, abs Right.Numerator, -Right.Exponent);
begin
if Right.Numerator = I.Zero then
raise Constraint_Error;
elsif Right.Numerator < I.Zero then
return -(Left * Reciprocal);
else
return Left * Reciprocal;
end if;
end "/";
---------
-- "<" --
---------
function "<" (Left, Right : Fraction) return Boolean is
Diff : constant Fraction := Left - Right;
begin
return Diff.Numerator < I.Zero;
end "<";
----------
-- "<=" --
----------
function "<=" (Left, Right : Fraction) return Boolean is
Diff : constant Fraction := Left - Right;
begin
return Diff.Numerator <= I.Zero;
end "<=";
---------
-- "=" --
---------
function "=" (Left, Right : Fraction) return Boolean is
Diff : constant Fraction := Left - Right;
begin
return Diff.Numerator = I.Zero;
end "=";
---------
-- ">" --
---------
function ">" (Left, Right : Fraction) return Boolean is
Diff : constant Fraction := Left - Right;
begin
return Diff.Numerator > I.Zero;
end ">";
----------
-- ">=" --
----------
function ">=" (Left, Right : Fraction) return Boolean is
Diff : constant Fraction := Left - Right;
begin
return Diff.Numerator >= I.Zero;
end ">=";
-----------
-- "abs" --
-----------
function "abs" (Left : Fraction) return Fraction is
begin
return (abs Left.Numerator, Left.Denominator, Left.Exponent);
end "abs";
-----------
-- Image --
-----------
function Image (Left : Fraction) return String is
begin
return Image (Left.Numerator) & 'e' & Image (Left.Exponent)
& '/' & Image (Left.Denominator);
end Image;
---------
-- Int --
---------
function Int (Value : I.Value) return Fraction is
begin
return (Value, I.One, I.Zero);
end Int;
---------
-- NOD --
---------
function NOD (X, Y : I.Value) return I.Value is
U : I.Value := X;
V : I.Value := Y;
R : I.Value;
begin
while V /= I.Zero loop
R := U mod V;
U := V;
V := R;
end loop;
return U;
end NOD;
--------------
-- Simplify --
--------------
procedure Simplify (X : in out Fraction) is
N : I.Value;
begin
if X.Numerator = I.Zero then
X := Zero;
return;
else
N := NOD (abs X.Numerator, X.Denominator);
end if;
if N > I.One then
X.Numerator := X.Numerator / N;
X.Denominator := X.Denominator / N;
end if;
while X.Numerator mod Ten = I.Zero loop
X.Numerator := X.Numerator / Ten;
X.Exponent := X.Exponent + I.One;
end loop;
while X.Denominator mod Ten = I.Zero loop
X.Denominator := X.Denominator / Ten;
X.Exponent := X.Exponent - I.One;
end loop;
end Simplify;
--------------
-- Truncate --
--------------
function Truncate (X : Fraction) return I.Value is
begin
if X.Exponent >= I.Zero then
return X.Numerator * Ten ** X.Exponent / X.Denominator;
else
return X.Numerator / Ten ** (-X.Exponent) / X.Denominator;
end if;
end Truncate;
-----------
-- Value --
-----------
function Value (Text : String) return Fraction is
use Ada.Strings.Fixed;
use Ada.Strings.Maps.Constants;
Result : Fraction;
Base : Positive := 10;
Sharp : Natural := Index (Text, "#");
Dot : Natural := Index (Text, ".");
E : Natural := Index (Text, "E", Mapping => Upper_Case_Map);
function Count_Denominator (Text : String) return I.Value is
Count : Natural := 0;
begin
for J in Text'Range loop
if Text (J) /= '_' then
Count := Count + 1;
end if;
end loop;
return Val (Count);
end Count_Denominator;
begin
if Sharp /= 0 then
Base := Positive'Value (Text (Text'First .. Sharp - 1));
else
Sharp := Text'First - 1;
end if;
if E = 0 then
Result.Numerator := Literal (Text (Sharp + 1 .. Text'Last));
else
Result.Numerator := Literal (Text (Sharp + 1 .. E - 1));
end if;
if Base = 10 then
if E = 0 then
Result.Exponent := I.Zero -
Count_Denominator (Text (Dot + 1 .. Text'Last));
else
Result.Exponent := Literal (Text (E + 1 .. Text'Last)) -
Count_Denominator (Text (Dot + 1 .. E - 1));
end if;
Result.Denominator := I.One;
else
if E = 0 then
Result.Denominator := Val (Base) **
Count_Denominator (Text (Dot + 1 .. Text'Last));
else
Result.Denominator := Val (Base) **
Count_Denominator (Text (Dot + 1 .. E - 1));
end if;
Result.Exponent := I.Zero;
end if;
Simplify (Result);
return Result;
end Value;
end XASIS.Fractions;
------------------------------------------------------------------------------
-- 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.
------------------------------------------------------------------------------
|
-- MIT License
--
-- Copyright (c) 2020 Max Reznik
--
-- 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.Streams;
with Interfaces;
with League.Strings;
with League.Stream_Element_Vectors;
with League.String_Vectors;
with PB_Support.Boolean_Vectors;
with PB_Support.IEEE_Float_32_Vectors;
with PB_Support.IEEE_Float_64_Vectors;
with PB_Support.Integer_32_Vectors;
with PB_Support.Integer_64_Vectors;
with PB_Support.Internal;
with PB_Support.Stream_Element_Vector_Vectors;
with PB_Support.Unsigned_32_Vectors;
with PB_Support.Unsigned_64_Vectors;
with PB_Support.Vectors;
package PB_Support.IO is
pragma Preelaborate;
subtype Key is PB_Support.Key;
function Read_Key
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Result : access Key) return Boolean;
function Read_Length
(Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Ada.Streams.Stream_Element_Count;
function Read_Array_Length
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item_Size : Ada.Streams.Stream_Element_Count)
return Natural;
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out League.Strings.Universal_String);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out League.String_Vectors.Universal_String_Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out League.Stream_Element_Vectors.Stream_Element_Vector);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Stream_Element_Vector_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Boolean);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Boolean_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.IEEE_Float_64);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.IEEE_Float_64_Vectors.Vector);
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.IEEE_Float_32);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.IEEE_Float_32_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_64);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_64_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Varint
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_32);
procedure Read_Varint_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_32_Vectors.Vector);
procedure Read_Zigzag
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32);
procedure Read_Zigzag_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Zigzag
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64);
procedure Read_Zigzag_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_64) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_64) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_64_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Integer_32) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Integer_32_Vectors.Vector);
procedure Read_Fixed
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Interfaces.Unsigned_32) renames Read_Varint;
procedure Read_Fixed_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out PB_Support.Unsigned_32_Vectors.Vector);
procedure Unknown_Field
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type);
generic
type Element is (<>);
type Integer_Element is range <>;
with package Vectors is new PB_Support.Vectors (Element);
package Enum_IO is
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Element);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out Vectors.Vector);
procedure Write
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Element);
procedure Write
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Vectors.Vector);
procedure Write_Packed
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Vectors.Vector);
procedure Write_Option
(Stream : in out Internal.Stream;
Field : Field_Number;
Value : Element;
Default : Element);
end Enum_IO;
generic
type Element is private;
type Vector is private;
with procedure Append
(Self : in out Vector;
Value : Element);
package Message_IO is
procedure Read
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : out Element);
procedure Read_Vector
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Encoding : Wire_Type;
Value : in out Vector);
end Message_IO;
end PB_Support.IO;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Unchecked_Deallocation;
package body Apsepp.Generic_Shared_Instance is
----------------------------------------------------------------------------
procedure Unl_CB is
begin
if Unlock_CB /= null then
Unlock_CB.all;
end if;
if Deallocation_Needed then
declare
procedure Free is new Ada.Unchecked_Deallocation
(Object => Instance_Ancestor_Type'Class,
Name => Instance_Type_Access);
begin
Deallocation_Needed := False;
Free (Instance_Access);
end;
else
Instance_Access := null;
end if;
end Unl_CB;
----------------------------------------------------------------------------
function Instance return Instance_Type_Access
is (Instance_Access);
----------------------------------------------------------------------------
function Locked return Boolean
is (Locked (Lock));
----------------------------------------------------------------------------
function Instantiated return Boolean
is (Instance_Access /= null);
----------------------------------------------------------------------------
end Apsepp.Generic_Shared_Instance;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ P U T _ I M A G E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Types; use Types;
package Exp_Put_Image is
-- Routines to build Put_Image calls. See Ada.Strings.Text_Output.Utils and
-- System.Put_Images for the run-time routines we are generating calls to.
-- For a call to T'Put_Image, if T is elementary, we expand the code
-- inline. If T is a tagged type, then Put_Image is a primitive procedure
-- of T, and can be dispatched to in the class-wide case. For untagged
-- composite types, we generate a procedure the first time we see a call,
-- and call it. Subsequent calls call the same procedure. Thus, if there
-- are calls to T'Put_Image in different units, there will be duplicates;
-- each unit will get a copy of the T'Put_Image procedure.
function Enable_Put_Image (Typ : Entity_Id) return Boolean;
-- True if the predefined Put_Image should be enabled for type T. Put_Image
-- is always enabled if there is a user-specified one.
function Build_Put_Image_Profile
(Loc : Source_Ptr; Typ : Entity_Id) return List_Id;
-- Builds the parameter profile for Put_Image. This is used for the tagged
-- case to build the spec for the primitive operation.
-- In the following Build_... routines, N is the attribute reference node,
-- from which the procedure to call and the parameters to pass can be
-- determined.
function Build_Elementary_Put_Image_Call (N : Node_Id) return Node_Id;
-- Builds a Put_Image call for an elementary type.
function Build_String_Put_Image_Call (N : Node_Id) return Node_Id;
-- Builds a Put_Image call for a standard string type.
function Build_Protected_Put_Image_Call (N : Node_Id) return Node_Id;
-- Builds a Put_Image call for a protected type.
function Build_Task_Put_Image_Call (N : Node_Id) return Node_Id;
-- Builds a Put_Image call for a task type.
-- The following routines build the Put_Image procedure for composite
-- types. Typ is the base type to which the procedure applies (i.e. the
-- base type of the Put_Image attribute prefix). The returned results are
-- the declaration and name (entity) of the procedure.
procedure Build_Array_Put_Image_Procedure
(Nod : Node_Id;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : out Entity_Id);
-- Nod provides the Sloc value for the generated code
procedure Build_Record_Put_Image_Procedure
(Loc : Source_Ptr;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : out Entity_Id);
-- Loc is the location of the subprogram declaration
function Build_Unknown_Put_Image_Call (N : Node_Id) return Node_Id;
-- Build a call to Put_Image_Unknown
function Image_Should_Call_Put_Image (N : Node_Id) return Boolean;
-- True if T'Image should call T'Put_Image. N is the attribute_reference
-- T'Image.
function Build_Image_Call (N : Node_Id) return Node_Id;
-- N is a call to T'Image, and this translates it into the appropriate code
-- to call T'Put_Image into a buffer and then extract the string from the
-- buffer.
procedure Preload_Sink (Compilation_Unit : Node_Id);
-- Call RTE (RE_Sink) if necessary, to load the packages involved in
-- Put_Image. We need to do this explicitly, fairly early during
-- compilation, because otherwise it happens during freezing, which
-- triggers visibility bugs in generic instantiations.
end Exp_Put_Image;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T Y P E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body Types is
-----------------------
-- Local Subprograms --
-----------------------
function V (T : Time_Stamp_Type; X : Time_Stamp_Index) return Nat;
-- Extract two decimal digit value from time stamp
---------
-- "<" --
---------
function "<" (Left, Right : Time_Stamp_Type) return Boolean is
begin
return not (Left = Right) and then String (Left) < String (Right);
end "<";
----------
-- "<=" --
----------
function "<=" (Left, Right : Time_Stamp_Type) return Boolean is
begin
return not (Left > Right);
end "<=";
---------
-- "=" --
---------
function "=" (Left, Right : Time_Stamp_Type) return Boolean is
Sleft : Nat;
Sright : Nat;
begin
if String (Left) = String (Right) then
return True;
elsif Left (1) = ' ' or else Right (1) = ' ' then
return False;
end if;
-- In the following code we check for a difference of 2 seconds or less
-- Recall that the time stamp format is:
-- Y Y Y Y M M D D H H M M S S
-- 01 02 03 04 05 06 07 08 09 10 11 12 13 14
-- Note that we do not bother to worry about shifts in the day.
-- It seems unlikely that such shifts could ever occur in practice
-- and even if they do we err on the safe side, i.e., we say that the
-- time stamps are different.
Sright := V (Right, 13) + 60 * (V (Right, 11) + 60 * V (Right, 09));
Sleft := V (Left, 13) + 60 * (V (Left, 11) + 60 * V (Left, 09));
-- So the check is: dates must be the same, times differ 2 sec at most
return abs (Sleft - Sright) <= 2
and then String (Left (1 .. 8)) = String (Right (1 .. 8));
end "=";
---------
-- ">" --
---------
function ">" (Left, Right : Time_Stamp_Type) return Boolean is
begin
return not (Left = Right) and then String (Left) > String (Right);
end ">";
----------
-- ">=" --
----------
function ">=" (Left, Right : Time_Stamp_Type) return Boolean is
begin
return not (Left < Right);
end ">=";
-------------------
-- Get_Char_Code --
-------------------
function Get_Char_Code (C : Character) return Char_Code is
begin
return Char_Code'Val (Character'Pos (C));
end Get_Char_Code;
-------------------
-- Get_Character --
-------------------
function Get_Character (C : Char_Code) return Character is
begin
pragma Assert (C <= 255);
return Character'Val (C);
end Get_Character;
--------------------
-- Get_Hex_String --
--------------------
subtype Wordh is Word range 0 .. 15;
Hex : constant array (Wordh) of Character := "0123456789abcdef";
function Get_Hex_String (W : Word) return Word_Hex_String is
X : Word := W;
WS : Word_Hex_String;
begin
for J in reverse 1 .. 8 loop
WS (J) := Hex (X mod 16);
X := X / 16;
end loop;
return WS;
end Get_Hex_String;
------------------------
-- Get_Wide_Character --
------------------------
function Get_Wide_Character (C : Char_Code) return Wide_Character is
begin
pragma Assert (C <= 65535);
return Wide_Character'Val (C);
end Get_Wide_Character;
------------------------
-- In_Character_Range --
------------------------
function In_Character_Range (C : Char_Code) return Boolean is
begin
return (C <= 255);
end In_Character_Range;
-----------------------------
-- In_Wide_Character_Range --
-----------------------------
function In_Wide_Character_Range (C : Char_Code) return Boolean is
begin
return (C <= 65535);
end In_Wide_Character_Range;
---------------------
-- Make_Time_Stamp --
---------------------
procedure Make_Time_Stamp
(Year : Nat;
Month : Nat;
Day : Nat;
Hour : Nat;
Minutes : Nat;
Seconds : Nat;
TS : out Time_Stamp_Type)
is
Z : constant := Character'Pos ('0');
begin
TS (01) := Character'Val (Z + Year / 1000);
TS (02) := Character'Val (Z + (Year / 100) mod 10);
TS (03) := Character'Val (Z + (Year / 10) mod 10);
TS (04) := Character'Val (Z + Year mod 10);
TS (05) := Character'Val (Z + Month / 10);
TS (06) := Character'Val (Z + Month mod 10);
TS (07) := Character'Val (Z + Day / 10);
TS (08) := Character'Val (Z + Day mod 10);
TS (09) := Character'Val (Z + Hour / 10);
TS (10) := Character'Val (Z + Hour mod 10);
TS (11) := Character'Val (Z + Minutes / 10);
TS (12) := Character'Val (Z + Minutes mod 10);
TS (13) := Character'Val (Z + Seconds / 10);
TS (14) := Character'Val (Z + Seconds mod 10);
end Make_Time_Stamp;
----------------------
-- Split_Time_Stamp --
----------------------
procedure Split_Time_Stamp
(TS : Time_Stamp_Type;
Year : out Nat;
Month : out Nat;
Day : out Nat;
Hour : out Nat;
Minutes : out Nat;
Seconds : out Nat)
is
begin
-- Y Y Y Y M M D D H H M M S S
-- 01 02 03 04 05 06 07 08 09 10 11 12 13 14
Year := 100 * V (TS, 01) + V (TS, 03);
Month := V (TS, 05);
Day := V (TS, 07);
Hour := V (TS, 09);
Minutes := V (TS, 11);
Seconds := V (TS, 13);
end Split_Time_Stamp;
-------
-- V --
-------
function V (T : Time_Stamp_Type; X : Time_Stamp_Index) return Nat is
begin
return 10 * (Character'Pos (T (X)) - Character'Pos ('0')) +
Character'Pos (T (X + 1)) - Character'Pos ('0');
end V;
end Types;
|
------------------------------------------------------------------------------
-- Copyright (c) 2017-2019, 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. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Lithium.Spoiler_Filters provides a filter to encode spoilers in rot13, --
-- for situations where CSS might not apply (e.g. ATOM feeds). --
------------------------------------------------------------------------------
with Ada.Streams;
with Natools.S_Expressions.Lockable;
with Natools.Web.Filters;
package Lithium.Spoiler_Filters is
pragma Preelaborate;
type Spoiler_Filter is new Natools.Web.Filters.Filter with private;
overriding procedure Apply
(Object : in Spoiler_Filter;
Output : in out Ada.Streams.Root_Stream_Type'Class;
Data : in Ada.Streams.Stream_Element_Array);
function Create
(Arguments : in out Natools.S_Expressions.Lockable.Descriptor'Class)
return Natools.Web.Filters.Filter'Class;
Begin_HTML : constant Natools.S_Expressions.Atom
:= (1 => Character'Pos ('<'),
2 => Character'Pos ('s'),
3 => Character'Pos ('p'),
4 => Character'Pos ('a'),
5 => Character'Pos ('n'),
6 => Character'Pos (' '),
7 => Character'Pos ('c'),
8 => Character'Pos ('l'),
9 => Character'Pos ('a'),
10 => Character'Pos ('s'),
11 => Character'Pos ('s'),
12 => Character'Pos ('='),
13 => Character'Pos ('"'),
14 => Character'Pos ('s'),
15 => Character'Pos ('p'),
16 => Character'Pos ('o'),
17 => Character'Pos ('i'),
18 => Character'Pos ('l'),
19 => Character'Pos ('e'),
20 => Character'Pos ('r'),
21 => Character'Pos ('"'),
22 => Character'Pos ('>'));
End_HTML : constant Natools.S_Expressions.Atom
:= (1 => Character'Pos ('<'),
2 => Character'Pos ('/'),
3 => Character'Pos ('s'),
4 => Character'Pos ('p'),
5 => Character'Pos ('a'),
6 => Character'Pos ('n'),
7 => Character'Pos ('>'));
Begin_Filtered : constant Natools.S_Expressions.Atom
:= (1 => Character'Pos ('['),
2 => Character'Pos ('S'),
3 => Character'Pos ('P'),
4 => Character'Pos ('O'),
5 => Character'Pos ('I'),
6 => Character'Pos ('L'),
7 => Character'Pos ('E'),
8 => Character'Pos ('R'),
9 => Character'Pos (']'),
10 => Character'Pos ('['));
End_Filtered : constant Natools.S_Expressions.Atom
:= (1 => Character'Pos (']'));
private
type Spoiler_Filter is new Natools.Web.Filters.Filter with null record;
end Lithium.Spoiler_Filters;
|
-----------------------------------------------------------------------
-- gen-artifacts-distribs -- Artifact for distributions
-- Copyright (C) 2012, 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
with Ada.Containers.Indefinite_Vectors;
with Ada.Containers.Indefinite_Ordered_Maps;
with GNAT.Regpat;
with DOM.Core;
with Gen.Model.Packages;
with Util.Log;
-- The <b>Gen.Artifacts.Distribs</b> package is an artifact for the generation of
-- application distributions.
--
-- 1/ The package.xml file contains a set of rules which describe how to build the distribution.
-- This file is read and distribution rules are collected in the <b>Rules</b> artifact.
--
-- 2/ The list of source paths to scan is obtained by looking at the GNAT project files
-- and looking at components which have a <b>dynamo.xml</b> configuration file.
--
-- 3/ The source paths are then scanned and a complete tree of source files is created
-- in the <b>Trees</b> artifact member.
--
-- 4/ The source paths are matched against the distribution rules and each distribution rule
-- is filled with the source files that they match.
--
-- 5/ The distribution rules are executed in the order defined in the <b>package.xml</b> file.
-- Each distribution rule can have its own way to make the distribution for the set of
-- files that matched the rule definition. A distribution rule can copy the file, another
-- can concatenate the source files, another can do some transformation on the source files
-- and prepare it for the distribution.
--
package Gen.Artifacts.Distribs is
-- ------------------------------
-- Distribution artifact
-- ------------------------------
type Artifact is new Gen.Artifacts.Artifact with private;
-- After the configuration file is read, processes the node whose root
-- is passed in <b>Node</b> and initializes the <b>Model</b> with the information.
overriding
procedure Initialize (Handler : in out Artifact;
Path : in String;
Node : in DOM.Core.Node;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Context : in out Generator'Class);
-- Prepare the model after all the configuration files have been read and before
-- actually invoking the generation.
overriding
procedure Prepare (Handler : in out Artifact;
Model : in out Gen.Model.Packages.Model_Definition'Class;
Context : in out Generator'Class);
private
type Directory_List;
type Directory_List_Access is access all Directory_List;
-- A <b>File_Record</b> refers to a source file that must be processed by a distribution
-- rule. It is linked to the directory which contains it through the <b>Dir</b> member.
-- The <b>Name</b> refers to the file name part.
type File_Record (Length : Natural) is record
Dir : Directory_List_Access;
Name : String (1 .. Length);
end record;
package File_Record_Vectors is
new Ada.Containers.Indefinite_Vectors (Index_Type => Positive,
Element_Type => File_Record);
subtype File_Vector is File_Record_Vectors.Vector;
subtype File_Cursor is File_Record_Vectors.Cursor;
-- Get the first source path from the list.
function Get_Source_Path (From : in File_Vector;
Use_First_File : in Boolean := False) return String;
-- The file tree represents the target distribution tree that must be built.
-- Each key represent a target file and it is associated with a <b>File_Vector</b> which
-- represents the list of source files that must be used to build the target.
package File_Tree is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => File_Vector,
"<" => "<",
"=" => File_Record_Vectors."=");
package Directory_List_Vector is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Directory_List_Access);
-- The <b>Directory_List<b> describes the content of a source directory.
type Directory_List (Length : Positive;
Path_Length : Natural)
is record
Files : File_Record_Vectors.Vector;
Directories : Directory_List_Vector.Vector;
Rel_Pos : Positive := 1;
Name : String (1 .. Length);
Path : String (1 .. Path_Length);
end record;
-- Get the relative path of the directory.
function Get_Relative_Path (Dir : in Directory_List) return String;
-- Strip the base part of the path
function Get_Strip_Path (Base : in String;
Path : in String) return String;
-- Build a regular expression pattern from a pattern string.
function Make_Regexp (Pattern : in String) return String;
-- Build a regular expression pattern from a pattern string.
function Make_Regexp (Pattern : in String) return GNAT.Regpat.Pattern_Matcher;
-- Scan the directory whose root path is <b>Path</b> and with the relative path
-- <b>Rel_Path</b> and build in <b>Dir</b> the list of files and directories.
procedure Scan (Path : in String;
Rel_Path : in String;
Dir : in Directory_List_Access);
type Match_Rule is record
Base_Dir : Ada.Strings.Unbounded.Unbounded_String;
Match : Ada.Strings.Unbounded.Unbounded_String;
end record;
package Match_Rule_Vector is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Match_Rule);
-- ------------------------------
-- Distribution rule
-- ------------------------------
-- The <b>Distrib_Rule</b> represents a distribution rule that must be executed on
-- a given file or set of files.
type Distrib_Rule is abstract tagged record
Dir : Ada.Strings.Unbounded.Unbounded_String;
Matches : Match_Rule_Vector.Vector;
Excludes : Match_Rule_Vector.Vector;
Files : File_Tree.Map;
Level : Util.Log.Level_Type := Util.Log.DEBUG_LEVEL;
end record;
type Distrib_Rule_Access is access all Distrib_Rule'Class;
-- Get a name to qualify the installation rule (used for logs).
function Get_Install_Name (Rule : in Distrib_Rule) return String is abstract;
-- Install the file <b>File</b> according to the distribution rule.
procedure Install (Rule : in Distrib_Rule;
Target : in String;
File : in File_Vector;
Context : in out Generator'Class) is abstract;
-- Scan the directory tree whose root is defined by <b>Dir</b> and find the files
-- that match the current rule.
procedure Scan (Rule : in out Distrib_Rule;
Dir : in Directory_List);
procedure Scan (Rule : in out Distrib_Rule;
Dir : in Directory_List;
Base_Dir : in String;
Pattern : in String;
Exclude : in Boolean);
procedure Execute (Rule : in out Distrib_Rule;
Path : in String;
Context : in out Generator'Class);
-- Get the target path associate with the given source file for the distribution rule.
function Get_Target_Path (Rule : in Distrib_Rule;
Base : in String;
File : in File_Record) return String;
-- Get the source path of the file.
function Get_Source_Path (Rule : in Distrib_Rule;
File : in File_Record) return String;
-- Add the file to be processed by the distribution rule. The file has a relative
-- path represented by <b>Path</b>. The path is relative from the base directory
-- specified in <b>Base_Dir</b>.
procedure Add_Source_File (Rule : in out Distrib_Rule;
Path : in String;
File : in File_Record);
-- Remove the file to be processed by the distribution rule. This is the opposite of
-- <tt>Add_Source_File</tt> and used for the <exclude name="xxx"/> rules.
procedure Remove_Source_File (Rule : in out Distrib_Rule;
Path : in String;
File : in File_Record);
-- Create a distribution rule identified by <b>Kind</b>.
-- The distribution rule is configured according to the DOM tree whose node is <b>Node</b>.
function Create_Rule (Kind : in String;
Node : in DOM.Core.Node) return Distrib_Rule_Access;
-- A list of rules that define how to build the distribution.
package Distrib_Rule_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Distrib_Rule_Access);
type Artifact is new Gen.Artifacts.Artifact with record
Rules : Distrib_Rule_Vectors.Vector;
Trees : Directory_List_Vector.Vector;
end record;
end Gen.Artifacts.Distribs;
|
with Ada.Containers.Vectors;
private package Extraction.Utilities is
type Project_Context is private;
function Open_Project (Project : String) return Project_Context;
package Analysis_Unit_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => LAL.Analysis_Unit,
"=" => LAL."=");
package Project_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => GPR.Project_Type,
"=" => GPR."=");
function Open_Analysis_Units
(Context : Project_Context; Recurse_Projects : Boolean)
return Analysis_Unit_Vectors.Vector;
function Get_Projects
(Context : Project_Context; Recurse_Projects : Boolean)
return Project_Vectors.Vector;
function Is_Buildable_File_In_Project_Context
(Filename : String; Context : Project_Context) return Boolean;
function Is_Ada_File_In_Project_Context
(Ada_Filename : String; Context : Project_Context;
Recurse_Projects : Boolean) return Boolean;
function Is_Project_Main_Program
(Node : LAL.Ada_Node'Class; Context : Project_Context) return Boolean;
Standard_Unit_File : constant VFS.Virtual_File;
function Get_Unique_Filename
(Filename : String; Directory_Prefix : VFS.Virtual_File;
Make_Lower_Case : Boolean) return String;
-- Get a unique name for Filename. The name will be relative to
-- Directory_Prefix if Directory_Prefix is a parent of Filename. For file
-- names from the GNATPRO installation path, the installation path will be
-- replaced by with `%GNATPRO_PATH%`.
function Get_Unique_Filename
(File : VFS.Virtual_File; Directory_Prefix : VFS.Virtual_File;
Make_Lower_Case : Boolean) return String;
-- Get a unique name for File. The name will be relative to
-- Directory_Prefix if Directory_Prefix is a parent of File.
-- For files from the GNATPRO installation path, the installation path
-- will be replaced by `%GNATPRO_PATH%`.
function Get_Referenced_Decl (Name : LAL.Name'Class) return LAL.Basic_Decl;
function Get_Referenced_Defining_Name
(Name : LAL.Name'Class) return LAL.Defining_Name;
function Get_Parent_Basic_Decl
(Node : LAL.Ada_Node'Class) return LAL.Basic_Decl;
function Is_Relevant_Basic_Decl (Node : LAL.Ada_Node'Class) return Boolean;
private
use type VFS.Filesystem_String;
type Project_Context is record
Project_Environment : GPR.Project_Environment_Access;
Project_Tree : GPR.Project_Tree_Access;
Unit_Provider : LAL.Unit_Provider_Reference;
Analysis_Context : LAL.Analysis_Context;
end record;
Standard_Unit_Filename : constant String := "__standard";
Standard_Unit_File : constant VFS.Virtual_File :=
VFS.Create (+Standard_Unit_Filename, Normalize => True);
end Extraction.Utilities;
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
with Interfaces.C.Strings;
with bits_types_h;
with stddef_h;
package bits_types_struct_FILE_h is
-- Copyright (C) 1991-2021 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C 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.
-- The GNU C 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 the GNU C Library; if not, see
-- <https://www.gnu.org/licenses/>.
-- Caution: The contents of this file are not part of the official
-- stdio.h API. However, much of it is part of the official *binary*
-- interface, and therefore cannot be changed.
type u_IO_marker is null record; -- incomplete struct
type u_IO_codecvt is null record; -- incomplete struct
type u_IO_wide_data is null record; -- incomplete struct
-- During the build of glibc itself, _IO_lock_t will already have been
-- defined by internal headers.
subtype u_IO_lock_t is System.Address; -- /usr/include/bits/types/struct_FILE.h:43
-- The tag name of this struct is _IO_FILE to preserve historic
-- C++ mangled names for functions taking FILE* arguments.
-- That name should not be used in new code.
-- High-order word is _IO_MAGIC; rest is flags.
type u_IO_FILE;
subtype u_IO_FILE_array1135 is Interfaces.C.char_array (0 .. 0);
subtype u_IO_FILE_array1140 is Interfaces.C.char_array (0 .. 19);
type u_IO_FILE is record
u_flags : aliased int; -- /usr/include/bits/types/struct_FILE.h:51
u_IO_read_ptr : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:54
u_IO_read_end : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:55
u_IO_read_base : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:56
u_IO_write_base : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:57
u_IO_write_ptr : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:58
u_IO_write_end : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:59
u_IO_buf_base : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:60
u_IO_buf_end : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:61
u_IO_save_base : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:64
u_IO_backup_base : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:65
u_IO_save_end : Interfaces.C.Strings.chars_ptr; -- /usr/include/bits/types/struct_FILE.h:66
u_markers : access u_IO_marker; -- /usr/include/bits/types/struct_FILE.h:68
u_chain : access u_IO_FILE; -- /usr/include/bits/types/struct_FILE.h:70
u_fileno : aliased int; -- /usr/include/bits/types/struct_FILE.h:72
u_flags2 : aliased int; -- /usr/include/bits/types/struct_FILE.h:73
u_old_offset : aliased bits_types_h.uu_off_t; -- /usr/include/bits/types/struct_FILE.h:74
u_cur_column : aliased unsigned_short; -- /usr/include/bits/types/struct_FILE.h:77
u_vtable_offset : aliased signed_char; -- /usr/include/bits/types/struct_FILE.h:78
u_shortbuf : aliased u_IO_FILE_array1135; -- /usr/include/bits/types/struct_FILE.h:79
u_lock : System.Address; -- /usr/include/bits/types/struct_FILE.h:81
u_offset : aliased bits_types_h.uu_off64_t; -- /usr/include/bits/types/struct_FILE.h:89
u_codecvt : access u_IO_codecvt; -- /usr/include/bits/types/struct_FILE.h:91
u_wide_data : access u_IO_wide_data; -- /usr/include/bits/types/struct_FILE.h:92
u_freeres_list : access u_IO_FILE; -- /usr/include/bits/types/struct_FILE.h:93
u_freeres_buf : System.Address; -- /usr/include/bits/types/struct_FILE.h:94
uu_pad5 : aliased stddef_h.size_t; -- /usr/include/bits/types/struct_FILE.h:95
u_mode : aliased int; -- /usr/include/bits/types/struct_FILE.h:96
u_unused2 : aliased u_IO_FILE_array1140; -- /usr/include/bits/types/struct_FILE.h:98
end record
with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/struct_FILE.h:49
-- The following pointers correspond to the C++ streambuf protocol.
-- Current read pointer
-- End of get area.
-- Start of putback+get area.
-- Start of put area.
-- Current put pointer.
-- End of put area.
-- Start of reserve area.
-- End of reserve area.
-- The following fields are used to support backing up and undo.
-- Pointer to start of non-current get area.
-- Pointer to first valid character of backup area
-- Pointer to end of non-current get area.
-- This used to be _offset but it's too small.
-- 1+column number of pbase(); 0 is unknown.
-- Wide character stream stuff.
-- Make sure we don't get into trouble again.
-- These macros are used by bits/stdio.h and internal headers.
-- Many more flag bits are defined internally.
end bits_types_struct_FILE_h;
|
with Plugins;
with EU_Projects.Projects;
package Project_Processor.Parsers is
subtype Parser_Parameter is Plugins.Parameter_Map;
subtype Parser_Parameter_access is Plugins.Parameter_Map_Access;
type Parser_ID is new String;
No_Parser : constant Parser_ID := "";
function Find_Parser (File_Extension : String) return Parser_ID;
function Parse_Project (Input : String;
Format : Parser_ID;
Parameters : Parser_Parameter_access)
return EU_Projects.Projects.Project_Descriptor;
Parsing_Error : exception;
private
procedure Register_Extension (Parser : Parser_ID;
File_Extension : String);
end Project_Processor.Parsers;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
package body GBA.Display.Backgrounds is
procedure Set_Offset_X (BG : BG_ID; Value : BG_Scroll_Offset) is
begin
BG_Offsets (BG).X := Value;
end;
procedure Set_Offset_Y (BG : BG_ID; Value : BG_Scroll_Offset) is
begin
BG_Offsets (BG).Y := Value;
end;
procedure Set_Offset (BG : BG_ID; X, Y : BG_Scroll_Offset) is
begin
BG_Offsets (BG) := (X => X, Y => Y);
end;
procedure Set_Offset (BG : BG_ID; Offsets : BG_Offset_Info) is
begin
BG_Offsets (BG) := Offsets;
end;
function Affine_Transform_Address (ID : Affine_BG_ID) return Address is
( BG_Transforms (ID)'Address );
procedure Set_Reference_X (BG : Affine_BG_ID; Value : BG_Reference_Point_Coordinate) is
begin
BG_Transforms (BG).Reference_Point.X := Value;
end;
procedure Set_Reference_Y (BG : Affine_BG_ID; Value : BG_Reference_Point_Coordinate) is
begin
BG_Transforms (BG).Reference_Point.Y := Value;
end;
procedure Set_Reference_Point (BG : Affine_BG_ID; X, Y : BG_Reference_Point_Coordinate) is
begin
BG_Transforms (BG).Reference_Point := (X => X, Y => Y);
end;
procedure Set_Reference_Point (BG : Affine_BG_ID; Reference_Point : BG_Reference_Point) is
begin
BG_Transforms (BG).Reference_Point := Reference_Point;
end;
procedure Set_Affine_Matrix (BG : Affine_BG_ID; Matrix : Affine_Transform_Matrix) is
begin
BG_Transforms (BG).Affine_Matrix := Matrix;
end;
procedure Set_Transform (BG : Affine_BG_ID; Transform : BG_Transform_Info) is
begin
BG_Transforms (BG) := Transform;
end;
end GBA.Display.Backgrounds;
|
pragma License (Unrestricted); -- BSD 3-Clause
-- translated unit from dSFMT
--
-- 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.
--
-- 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 Hiroshima University 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.
--
-- Ada version: 2018 yt
with Ada.IO_Exceptions;
with Interfaces;
generic
-- Mersenne Exponent. The period of the sequence is a multiple of 2^MEXP-1.
MEXP : Natural;
-- the pick up position of the array.
POS1 : Natural;
-- the parameter of shift left as four 32-bit registers.
SL1 : Natural;
-- A bitmask, used in the recursion. These parameters are introduced to
-- break symmetry of SIMD.
MSK1 : Interfaces.Unsigned_64;
MSK2 : Interfaces.Unsigned_64;
FIX1 : Interfaces.Unsigned_64;
FIX2 : Interfaces.Unsigned_64;
-- These definitions are part of a 128-bit period certification vector.
PCV1 : Interfaces.Unsigned_64;
PCV2 : Interfaces.Unsigned_64;
package Ada.Numerics.dSFMT is
-- Double precision SIMD oriented Fast Mersenne Twister(dSFMT)
-- pseudorandom number generator based on IEEE 754 format.
pragma Preelaborate;
type Long_Float_Array is array (Natural range <>) of Long_Float;
for Long_Float_Array'Alignment use 16;
subtype Unsigned_32 is Interfaces.Unsigned_32;
type Unsigned_32_Array is
array (Natural range <>) of aliased Interfaces.Unsigned_32;
for Unsigned_32_Array'Alignment use 16;
-- Identification string
function Id return String;
DSFMT_MEXP : Natural
renames MEXP;
-- Basic facilities
type Generator is limited private;
function Random_1_To_Less_Than_2 (Gen : aliased in out Generator)
return Long_Float;
function Random_0_To_Less_Than_1 (Gen : aliased in out Generator)
return Long_Float;
function Random_Greater_Than_0_To_1 (Gen : aliased in out Generator)
return Long_Float;
function Random_Greater_Than_0_To_Less_Than_1 (
Gen : aliased in out Generator)
return Long_Float;
pragma Inline (Random_1_To_Less_Than_2);
pragma Inline (Random_0_To_Less_Than_1);
pragma Inline (Random_Greater_Than_0_To_1);
pragma Inline (Random_Greater_Than_0_To_Less_Than_1);
procedure Fill_Random_1_To_Less_Than_2 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_0_To_Less_Than_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_Greater_Than_0_To_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
procedure Fill_Random_Greater_Than_0_To_Less_Than_1 (
Gen : aliased in out Generator;
Item : out Long_Float_Array);
function Initialize return Generator;
function Initialize (Initiator : Unsigned_32) return Generator;
function Initialize (Initiator : Unsigned_32_Array) return Generator;
procedure Reset (Gen : in out Generator);
procedure Reset (Gen : in out Generator; Initiator : Integer);
-- Advanced facilities
type State is private;
pragma Preelaborable_Initialization (State); -- uninitialized
function Initialize return State;
function Initialize (Initiator : Unsigned_32) return State;
function Initialize (Initiator : Unsigned_32_Array) return State;
procedure Save (Gen : Generator; To_State : out State);
procedure Reset (Gen : in out Generator; From_State : State);
function Reset (From_State : State) return Generator;
Max_Image_Width : constant Natural;
function Image (Of_State : State) return String;
function Value (Coded_State : String) return State;
Default_Initiator : constant := 1234; -- test.c
-- This constant means the minimum size of array used for
-- Fill_Random_... procedures.
Min_Array_Length : constant Natural;
-- Exceptions
Use_Error : exception
renames IO_Exceptions.Use_Error;
-- Note: Initialize propagates Use_Error if it failed.
private
pragma Compile_Time_Error (Long_Float'Size /= 64, "Long_Float'Size /= 64");
subtype Unsigned_64 is Interfaces.Unsigned_64;
type Unsigned_64_Array is
array (Natural range <>) of aliased Interfaces.Unsigned_64;
for Unsigned_64_Array'Alignment use 16;
-- the parameters of DSFMT
LOW_MASK : constant := 16#000FFFFFFFFFFFFF#;
HIGH_CONST : constant := 16#3FF0000000000000#;
SR : constant := 12;
-- DSFMT generator has an internal state array of 128-bit integers, and N
-- is its size.
N : constant Natural := (MEXP - 128) / 104 + 1;
-- N32 is the size of internal state array when regarded as an array of
-- 32-bit integers.
N32 : constant Natural := N * 4;
-- N64 is the size of internal state array when regarded as an array of
-- 64-bit integers.
Min_Array_Length : constant Natural := N * 2;
N64 : Natural renames Min_Array_Length;
Max_Image_Width : constant Natural := (N64 + 2) * (64 / 4 + 1) + 32 / 4;
-- 128-bit data type
type w128_t is array (0 .. 1) of Unsigned_64;
for w128_t'Alignment use 16;
pragma Suppress_Initialization (w128_t);
type w128_t_Array is array (Natural range <>) of aliased w128_t
with Convention => Ada_Pass_By_Reference;
pragma Suppress_Initialization (w128_t_Array);
subtype w128_t_Array_1 is w128_t_Array (0 .. 0);
subtype w128_t_Array_N is w128_t_Array (0 .. N - 1);
type State is record
-- the 128-bit internal state array
status : aliased w128_t_Array_N;
lung : aliased w128_t; -- status (N)
idx : Integer;
end record;
pragma Suppress_Initialization (State);
type Generator is limited record
dsfmt : aliased State := Initialize (Default_Initiator);
end record;
end Ada.Numerics.dSFMT;
|
-----------------------------------------------------------------------
-- css-core-values -- Representation of CSS property value(s).
-- Copyright (C) 2017, 2018 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.Strings.Unbounded;
package body CSS.Core.Values is
-- ------------------------------
-- Get a printable representation of the value.
-- ------------------------------
function To_String (Value : in Value_Type) return String is
begin
if Value = null then
return "null";
elsif Value.Kind = VALUE_FUNCTION then
return Value.Value & "(" & To_String (Value.Params.all, Sep => ',') & ")";
else
return Value.Value;
end if;
end To_String;
-- ------------------------------
-- Get the value type.
-- ------------------------------
function Get_Type (Value : in Value_Type) return Value_Kind is
begin
if Value = null then
return VALUE_NULL;
else
return Value.Kind;
end if;
end Get_Type;
-- ------------------------------
-- Get the value unit.
-- ------------------------------
function Get_Unit (Value : in Value_Type) return Unit_Type is
begin
if Value = null then
return UNIT_NONE;
else
return Value.Unit;
end if;
end Get_Unit;
-- ------------------------------
-- Get the value.
-- ------------------------------
function Get_Value (Value : in Value_Type) return String is
begin
if Value = null then
return "";
else
return Value.Value;
end if;
end Get_Value;
function "<" (Left, Right : in Value_Type) return Boolean is
begin
if Left = null then
return False;
elsif Right = null then
return True;
elsif Left.Kind /= Right.Kind then
return Left.Kind < Right.Kind;
elsif Left.Unit /= Right.Unit then
return Left.Unit < Right.Unit;
elsif Left.Kind /= VALUE_FUNCTION then
return Left.Value < Right.Value;
else
return Left.Params.all < Right.Params.all;
end if;
end "<";
function "<" (Left, Right : in Value_List) return Boolean is
V1, V2 : Value_Type;
begin
if Left.Count < Right.Count then
return True;
elsif Left.Count > Right.Count then
return False;
else
for I in 1 .. Left.Count loop
V1 := Left.Get_Value (I);
V2 := Right.Get_Value (I);
if not Compare (V1, V2) then
return V1 < V2;
end if;
end loop;
return False;
end if;
end "<";
-- ------------------------------
-- Append the value to the list.
-- ------------------------------
procedure Append (List : in out Value_List;
Value : in Value_Type) is
begin
for I in List.Values'Range loop
if List.Values (I) = null then
List.Values (I) := Value;
List.Count := List.Count + 1;
return;
end if;
end loop;
end Append;
-- ------------------------------
-- Get the number of values in the list.
-- ------------------------------
function Get_Count (List : in Value_List) return Natural is
begin
return List.Count;
end Get_Count;
-- ------------------------------
-- Get the value at the given list position.
-- ------------------------------
function Get_Value (List : in Value_List;
Pos : in Positive) return Value_Type is
begin
return List.Values (Pos);
end Get_Value;
-- ------------------------------
-- Get the function parameters.
-- ------------------------------
function Get_Parameters (Value : in Value_Type) return Value_List_Access is
begin
return Value.Params;
end Get_Parameters;
-- ------------------------------
-- Get a printable representation of the list or a subset of the list.
-- ------------------------------
function To_String (List : in Value_List;
From : in Positive := 1;
To : in Positive := Positive'Last;
Sep : in Character := ' ') return String is
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
for I in From .. To loop
exit when I > List.Count;
if List.Values (I) /= null then
if Ada.Strings.Unbounded.Length (Result) > 0 then
Ada.Strings.Unbounded.Append (Result, Sep);
end if;
Ada.Strings.Unbounded.Append (Result, To_String (List.Values (I)));
end if;
end loop;
return Ada.Strings.Unbounded.To_String (Result);
end To_String;
-- ------------------------------
-- Compare the two values for identity.
-- ------------------------------
function Compare (Left, Right : in Value_Type) return Boolean is
begin
if Left = Right then
return True;
end if;
if Left = null or Right = null then
return False;
end if;
return Left.Kind = Right.Kind and Left.Unit = Right.Unit
and Left.Len = Right.Len and Left.Value = Right.Value;
end Compare;
function Create_Value (Repository : in out Repository_Type;
Value : in Value_Type) return Value_Type is
Pos : constant Value_Sets.Cursor := Repository.Root.Find (Value);
begin
if Value_Sets.Has_Element (Pos) then
return Value_Sets.Element (Pos);
end if;
declare
V : constant Value_Type := new Value_Node '(Len => Value.Len,
Kind => Value.Kind,
Unit => Value.Unit,
Params => null,
Value => Value.Value);
begin
Repository.Root.Insert (V);
return V;
end;
end Create_Value;
-- ------------------------------
-- Create a color value.
-- ------------------------------
function Create_Color (Repository : in out Repository_Type;
Value : in String) return Value_Type is
V : aliased Value_Node := Value_Node '(Len => Value'Length,
Kind => VALUE_COLOR,
Unit => UNIT_NONE,
Params => null,
Value => Value);
begin
return Repository.Create_Value (V'Unchecked_Access);
end Create_Color;
-- ------------------------------
-- Create a URL value.
-- ------------------------------
function Create_URL (Repository : in out Repository_Type;
Value : in String) return Value_Type is
V : aliased Value_Node := Value_Node '(Len => Value'Length,
Kind => VALUE_URL,
Unit => UNIT_NONE,
Params => null,
Value => Value);
begin
return Repository.Create_Value (V'Unchecked_Access);
end Create_URL;
-- ------------------------------
-- Create a String value.
-- ------------------------------
function Create_String (Repository : in out Repository_Type;
Value : in String) return Value_Type is
V : aliased Value_Node := Value_Node '(Len => Value'Length,
Kind => VALUE_STRING,
Unit => UNIT_NONE,
Params => null,
Value => Value);
begin
return Repository.Create_Value (V'Unchecked_Access);
end Create_String;
-- ------------------------------
-- Create an identifier value.
-- ------------------------------
function Create_Ident (Repository : in out Repository_Type;
Value : in String) return Value_Type is
V : aliased Value_Node := Value_Node '(Len => Value'Length,
Kind => VALUE_IDENT,
Unit => UNIT_NONE,
Params => null,
Value => Value);
begin
return Repository.Create_Value (V'Unchecked_Access);
end Create_Ident;
-- ------------------------------
-- Create a number value with an optional unit.
-- ------------------------------
function Create_Number (Repository : in out Repository_Type;
Value : in String;
Unit : in Unit_Type := UNIT_NONE) return Value_Type is
V : aliased Value_Node := Value_Node '(Len => Value'Length,
Kind => VALUE_NUMBER,
Unit => Unit,
Params => null,
Value => Value);
begin
return Repository.Create_Value (V'Unchecked_Access);
end Create_Number;
-- ------------------------------
-- Create a function value with one parameter.
-- ------------------------------
function Create_Function (Repository : in out Repository_Type;
Name : in String;
Parameter : in Value_Type) return Value_Type is
Params : Value_List;
begin
Append (Params, Parameter);
return Repository.Create_Function (Name, Params);
end Create_Function;
-- ------------------------------
-- Create a number value with an optional unit.
-- ------------------------------
-- Create a function value with parameters.
function Create_Function (Repository : in out Repository_Type;
Name : in String;
Parameters : in Value_List'Class) return Value_Type is
Param : aliased Value_List := Value_List (Parameters);
Check : aliased Value_Node := Value_Node '(Len => Name'Length,
Kind => VALUE_FUNCTION,
Unit => UNIT_NONE,
Value => Name,
Params => Param'Unchecked_Access);
Pos : constant Value_Sets.Cursor := Repository.Root.Find (Check'Unchecked_Access);
begin
if Value_Sets.Has_Element (Pos) then
return Value_Sets.Element (Pos);
end if;
declare
V : constant Value_Type
:= new Value_Node '(Len => Name'Length,
Kind => VALUE_FUNCTION,
Unit => UNIT_NONE,
Value => Name,
Params => new Value_List '(Value_List (Parameters)));
begin
Repository.Root.Insert (V);
return V;
end;
end Create_Function;
-- ------------------------------
-- Return the number of entries in the repository.
-- ------------------------------
function Length (Repository : in Repository_Type) return Natural is
begin
return Natural (Repository.Root.Length);
end Length;
-- ------------------------------
-- Iterate over the list of properties and call the <tt>Process</tt> procedure.
-- ------------------------------
procedure Iterate (Repository : in Repository_Type;
Process : not null access procedure (Value : in Value_Type)) is
procedure Process_Value (Pos : in CSS.Core.Values.Value_Sets.Cursor);
procedure Process_Value (Pos : in CSS.Core.Values.Value_Sets.Cursor) is
begin
Process (CSS.Core.Values.Value_Sets.Element (Pos));
end Process_Value;
begin
Repository.Root.Iterate (Process_Value'Access);
end Iterate;
-- ------------------------------
-- Release the storage held by the selector sub-tree.
-- ------------------------------
procedure Finalize (Node : in out Value_Node) is
begin
null;
end Finalize;
-- ------------------------------
-- Release the values held by the repository.
-- ------------------------------
overriding
procedure Finalize (Object : in out Repository_Type) is
begin
null;
end Finalize;
-- ------------------------------
-- Copy the value list chain if there is one.
-- ------------------------------
overriding
procedure Adjust (Object : in out Value_List) is
begin
if Object.Next /= null then
null;
end if;
end Adjust;
-- ------------------------------
-- Release the values.
-- ------------------------------
overriding
procedure Finalize (Object : in out Value_List) is
begin
null;
end Finalize;
end CSS.Core.Values;
|
with System;
with Interfaces.C; use Interfaces.C;
with Interfaces;
package Lv is
subtype Int8_T is Interfaces.Integer_8;
subtype Uint8_T is Interfaces.Unsigned_8;
subtype Int16_T is Interfaces.Integer_16;
subtype Uint16_T is Interfaces.Unsigned_16;
subtype Int32_T is Interfaces.Integer_32;
subtype Uint32_T is Interfaces.Unsigned_32;
subtype Int64_T is Interfaces.Integer_64;
subtype Uint64_T is Interfaces.Unsigned_64;
subtype U_Bool is int;
subtype C_String_Ptr is System.Address;
type String_Array is array (Natural range <>) of C_String_Ptr
with Convention => C;
-- Init. the 'lv' library.
procedure Init;
pragma Import (C, Init, "lv_init");
LV_KEY_UP : constant := 17;
LV_KEY_DOWN : constant := 18;
LV_KEY_RIGHT : constant := 19;
LV_KEY_LEFT : constant := 20;
LV_KEY_ESC : constant := 27;
LV_KEY_DEL : constant := 127;
LV_KEY_BACKSPACE : constant := 8;
LV_KEY_ENTER : constant := 10;
LV_KEY_NEXT : constant := 9;
LV_KEY_PREV : constant := 11;
LV_KEY_HOME : constant := 2;
LV_KEY_END : constant := 3;
subtype C is Character;
SYMBOL_AUDIO : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#80#);
SYMBOL_VIDEO : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#81#);
SYMBOL_LIST : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#82#);
SYMBOL_OK : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#83#);
SYMBOL_CLOSE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#84#);
SYMBOL_POWER : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#85#);
SYMBOL_SETTINGS : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#86#);
SYMBOL_TRASH : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#87#);
SYMBOL_HOME : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#88#);
SYMBOL_DOWNLOAD : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#89#);
SYMBOL_DRIVE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8A#);
SYMBOL_REFRESH : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8B#);
SYMBOL_MUTE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8C#);
SYMBOL_VOLUME_MID : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8D#);
SYMBOL_VOLUME_MAX : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8E#);
SYMBOL_IMAGE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#8F#);
SYMBOL_EDIT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#90#);
SYMBOL_PREV : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#91#);
SYMBOL_PLAY : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#92#);
SYMBOL_PAUSE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#93#);
SYMBOL_STOP : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#94#);
SYMBOL_NEXT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#95#);
SYMBOL_EJECT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#96#);
SYMBOL_LEFT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#97#);
SYMBOL_RIGHT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#98#);
SYMBOL_PLUS : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#99#);
SYMBOL_MINUS : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9A#);
SYMBOL_WARNING : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9B#);
SYMBOL_SHUFFLE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9C#);
SYMBOL_UP : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9D#);
SYMBOL_DOWN : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9E#);
SYMBOL_LOOP : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#9F#);
SYMBOL_DIRECTORY : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A0#);
SYMBOL_UPLOAD : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A1#);
SYMBOL_CALL : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A2#);
SYMBOL_CUT : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A3#);
SYMBOL_COPY : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A4#);
SYMBOL_SAVE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A5#);
SYMBOL_CHARGE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A6#);
SYMBOL_BELL : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A7#);
SYMBOL_KEYBOARD : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A8#);
SYMBOL_GPS : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#A9#);
SYMBOL_FILE : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AA#);
SYMBOL_WIFI : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AB#);
SYMBOL_BATTERY_FUL : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AC#);
SYMBOL_BATTERY_3 : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AD#);
SYMBOL_BATTERY_2 : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AE#);
SYMBOL_BATTERY_1 : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#AF#);
SYMBOL_BATTERY_EMP : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#B0#);
SYMBOL_BLUETOOTH : constant String := C'Val (16#EF#) & C'Val (16#A0#) & C'Val (16#B1#);
end Lv;
|
-- Time-stamp: <23 oct 2012 10:40 queinnec@enseeiht.fr>
with LR.Tasks; use LR.Tasks;
package body LR.Simu is
Is_Running : Boolean := True;
Nb_Procs : Positive;
Timespeed : Positive := 1; -- in 1..100
Basefreq : constant Positive := 100; -- sleep unit : 1/Basefreq
type Proc_Sleep_Record is
record
Duree: Natural := 0;
Wakeup: Boolean := False;
end record;
Infos_Proc : array(Proc_Id) of Proc_Sleep_Record;
procedure Init(Nbproc: Positive) is
begin
Nb_Procs := Nbproc;
Timespeed := 1;
end Init;
procedure Sleep(Id: Proc_Id; Duree: Positive) is
begin
Infos_Proc(Id).Duree := Duree * Basefreq;
Infos_Proc(Id).Wakeup := False;
while (not Infos_Proc(Id).Wakeup) and (Infos_Proc(Id).Duree > 0) loop
if (Is_Running) then
Infos_Proc(Id).Duree := Infos_Proc(Id).Duree - 1;
end if;
delay (1.0 / Basefreq) / Timespeed;
end loop;
end Sleep;
procedure Wakeup(Id: Proc_Id) is
begin
Infos_Proc(Id).Wakeup := True;
end Wakeup;
function Get_Running return Boolean is
begin
return Is_Running;
end Get_Running;
procedure Set_Running(B: Boolean) is
begin
Is_Running := B;
end Set_Running;
procedure Swap_Running is
begin
Is_Running := not Is_Running;
end Swap_Running;
procedure Set_Timespeed(Ts: Integer) is
begin
Timespeed := TS;
end Set_Timespeed;
function Get_Timespeed return Integer is
begin
return Timespeed;
end Get_Timespeed;
Previous_Running : Boolean;
procedure Suspend_Time is
begin
Previous_Running := Is_Running;
Is_Running := False;
end Suspend_Time;
procedure Resume_Time is
begin
Is_Running := Previous_Running;
end Resume_Time;
end LR.Simu;
|
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 euler06 is
type stringptr is access all char_array;
procedure PInt(i : in Integer) is
begin
String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left));
end;
sumcarres : Integer;
sum : Integer;
lim : Integer;
carressum : Integer;
begin
lim := 100;
sum := lim * (lim + 1) / 2;
carressum := sum * sum;
sumcarres := lim * (lim + 1) * (2 * lim + 1) / 6;
PInt(carressum - sumcarres);
end;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Command_Line;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with JSON.Types;
with JSON.Parsers;
with JSON.Streams;
procedure Pretty_Print is
package ACL renames Ada.Command_Line;
package TIO renames Ada.Text_IO;
package Types is new JSON.Types (Long_Integer, Long_Float);
package Parsers is new JSON.Parsers (Types);
type Indent_Type is range 2 .. 8;
procedure Print
(Value : Types.JSON_Value;
Indent : Indent_Type := 4;
Level : Positive := 1)
is
use all type Types.Value_Kind;
use Ada.Strings.Fixed;
Index : Positive := 1;
Spaces : constant Natural := Natural (Indent);
begin
case Value.Kind is
when Object_Kind =>
if Value.Length > 0 then
Ada.Text_IO.Put_Line ("{");
for E of Value loop
if Index > 1 then
Ada.Text_IO.Put_Line (",");
end if;
-- Print key and element
Ada.Text_IO.Put (Spaces * Level * ' ' & E.Image & ": ");
Print (Value (E.Value), Indent, Level + 1);
Index := Index + 1;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "}");
else
Ada.Text_IO.Put ("{}");
end if;
when Array_Kind =>
if Value.Length > 0 then
Ada.Text_IO.Put_Line ("[");
for E of Value loop
if Index > 1 then
Ada.Text_IO.Put_Line (",");
end if;
-- Print element
Ada.Text_IO.Put (Spaces * Level * ' ');
Print (E, Indent, Level + 1);
Index := Index + 1;
end loop;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put (Spaces * (Level - 1) * ' ' & "]");
else
Ada.Text_IO.Put ("[]");
end if;
when others =>
Ada.Text_IO.Put (Value.Image);
end case;
end Print;
File_Only : constant Boolean := ACL.Argument_Count = 1;
Is_Quiet : constant Boolean := ACL.Argument_Count = 2 and then ACL.Argument (1) = "-q";
begin
if not (File_Only or Is_Quiet) then
TIO.Put_Line ("Usage: [-q] <path to .json file>");
ACL.Set_Exit_Status (ACL.Failure);
return;
end if;
declare
Parser : Parsers.Parser := Parsers.Create_From_File (ACL.Argument (ACL.Argument_Count));
Value : constant Types.JSON_Value := Parser.Parse;
begin
if not Is_Quiet then
Print (Value, Indent => 4);
end if;
end;
end Pretty_Print;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Header_Handler --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.20 $
-- $Date: 2014/09/13 19:10:18 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Terminal_Interface.Curses.Text_IO.Integer_IO;
with Sample.Manifest; use Sample.Manifest;
pragma Elaborate_All (Terminal_Interface.Curses.Text_Io.Integer_IO);
-- This package handles the painting of the header line of the screen.
--
package body Sample.Header_Handler is
package Int_IO is new
Terminal_Interface.Curses.Text_IO.Integer_IO (Integer);
use Int_IO;
Header_Window : Window := Null_Window;
Display_Hour : Integer := -1; -- hour last displayed
Display_Min : Integer := -1; -- minute last displayed
Display_Day : Integer := -1; -- day last displayed
Display_Month : Integer := -1; -- month last displayed
-- This is the routine handed over to the curses library to be called
-- as initialization routine when ripping of the header lines from
-- the screen. This routine must follow C conventions.
function Init_Header_Window (Win : Window;
Columns : Column_Count) return Integer;
pragma Convention (C, Init_Header_Window);
procedure Internal_Update_Header_Window (Do_Update : Boolean);
-- The initialization must be called before Init_Screen. It steals two
-- lines from the top of the screen.
procedure Init_Header_Handler
is
begin
Rip_Off_Lines (2, Init_Header_Window'Access);
end Init_Header_Handler;
procedure N_Out (N : Integer);
-- Emit a two digit number and ensure that a leading zero is generated if
-- necessary.
procedure N_Out (N : Integer)
is
begin
if N < 10 then
Add (Header_Window, '0');
Put (Header_Window, N, 1);
else
Put (Header_Window, N, 2);
end if;
end N_Out;
-- Paint the header window. The input parameter is a flag indicating
-- whether or not the screen should be updated physically after painting.
procedure Internal_Update_Header_Window (Do_Update : Boolean)
is
type Month_Name_Array is
array (Month_Number'First .. Month_Number'Last) of String (1 .. 9);
Month_Names : constant Month_Name_Array :=
("January ",
"February ",
"March ",
"April ",
"May ",
"June ",
"July ",
"August ",
"September",
"October ",
"November ",
"December ");
Now : constant Time := Clock;
Sec : constant Integer := Integer (Seconds (Now));
Hour : constant Integer := Sec / 3600;
Minute : constant Integer := (Sec - Hour * 3600) / 60;
Mon : constant Month_Number := Month (Now);
D : constant Day_Number := Day (Now);
begin
if Header_Window /= Null_Window then
if Minute /= Display_Min
or else Hour /= Display_Hour
or else Display_Day /= D
or else Display_Month /= Mon
then
Move_Cursor (Header_Window, 0, 0);
N_Out (D); Add (Header_Window, '.');
Add (Header_Window, Month_Names (Mon));
Move_Cursor (Header_Window, 1, 0);
N_Out (Hour); Add (Header_Window, ':');
N_Out (Minute);
Display_Min := Minute;
Display_Hour := Hour;
Display_Month := Mon;
Display_Day := D;
Refresh_Without_Update (Header_Window);
if Do_Update then
Update_Screen;
end if;
end if;
end if;
end Internal_Update_Header_Window;
-- This routine is called in the keyboard input timeout handler. So it will
-- periodically update the header line of the screen.
procedure Update_Header_Window
is
begin
Internal_Update_Header_Window (True);
end Update_Header_Window;
function Init_Header_Window (Win : Window;
Columns : Column_Count) return Integer
is
Title : constant String := "Ada 95 ncurses Binding Sample";
Pos : Column_Position;
begin
Header_Window := Win;
if Win /= Null_Window then
if Has_Colors then
Set_Background (Win => Win,
Ch => (Ch => ' ',
Color => Header_Color,
Attr => Normal_Video));
Set_Character_Attributes (Win => Win,
Attr => Normal_Video,
Color => Header_Color);
Erase (Win);
end if;
Leave_Cursor_After_Update (Win, True);
Pos := Columns - Column_Position (Title'Length);
Add (Win, 0, Pos / 2, Title);
-- In this phase we must not allow a physical update, because
-- ncurses is not properly initialized at this point.
Internal_Update_Header_Window (False);
return 0;
else
return -1;
end if;
end Init_Header_Window;
end Sample.Header_Handler;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with System;
package Glfw.Monitors is
type Event is (Connected, Disconnected);
type Video_Mode is record
Width, Height : Interfaces.C.int;
Red_Bits, Green_Bits, Blue_Bits : Interfaces.C.int;
Refresh_Rate : Interfaces.C.int;
end record;
type Gamma_Value_Array is array (Positive range <>) of aliased
Interfaces.C.unsigned_short;
type Gamma_Ramp (Size : Positive) is record
Red, Green, Blue : Gamma_Value_Array (1 .. Size);
end record;
type Monitor is tagged private;
No_Monitor : constant Monitor;
type Monitor_List is array (Positive range <>) of Monitor;
type Video_Mode_List is array (Positive range <>) of aliased Video_Mode;
pragma Convention (C, Video_Mode);
pragma Convention (C, Video_Mode_List);
function Monitors return Monitor_List;
function Primary_Monitor return Monitor;
procedure Get_Position (Object : Monitor; X, Y : out Integer);
procedure Get_Physical_Size (Object : Monitor; Width, Height : out Integer);
function Name (Object : Monitor) return String;
function Video_Modes (Object : Monitor) return Video_Mode_List;
function Current_Video_Mode (Object : Monitor) return Video_Mode;
procedure Set_Gamma (Object : Monitor; Gamma : Float);
function Current_Gamma_Ramp (Object : Monitor) return Gamma_Ramp;
procedure Set_Gamma_Ramp (Object : Monitor; Value : Gamma_Ramp);
-- used internally
function Raw_Pointer (Object : Monitor) return System.Address;
private
type Monitor is tagged record
Handle : System.Address;
end record;
No_Monitor : constant Monitor := (Handle => System.Null_Address);
for Event use (Connected => 16#00040001#,
Disconnected => 16#00040002#);
for Event'Size use Interfaces.C.int'Size;
end Glfw.Monitors;
|
package Loop_Optimization14_Pkg is
procedure Proc (B : in out Boolean);
end Loop_Optimization14_Pkg;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . P R I M E _ N U M B E R S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
-- This package declares the prime numbers array used to implement hashed
-- containers. Bucket arrays are always allocated with a prime-number
-- length (computed using To_Prime below), as this produces better scatter
-- when hash values are folded.
package Ada.Containers.Prime_Numbers is
pragma Pure;
type Primes_Type is array (Positive range <>) of Hash_Type;
Primes : constant Primes_Type :=
(53, 97, 193, 389, 769,
1543, 3079, 6151, 12289, 24593,
49157, 98317, 196613, 393241, 786433,
1572869, 3145739, 6291469, 12582917, 25165843,
50331653, 100663319, 201326611, 402653189, 805306457,
1610612741, 3221225473, 4294967291);
function To_Prime (Length : Count_Type) return Hash_Type;
-- Returns the smallest value in Primes not less than Length
end Ada.Containers.Prime_Numbers;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ generic subpools --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Ada.Containers.Vectors;
with Ada.Unchecked_Conversion;
with Skill.Containers.Vectors;
with Skill.Field_Types;
with Skill.Field_Types.Builtin;
with Skill.Field_Types.Builtin.String_Type_P;
with Skill.Files;
with Skill.Internal.File_Parsers;
with Skill.Streams.Reader;
with Skill.Streams.Writer;
with Skill.Types.Pools;
with Skill.Types;
with Skill.Books;
-- generic sub pool packages
generic
type T is new Skill_Object with private;
type P is access all t;
with function To_P (This : Annotation) return P;
package Skill.Types.Pools.Sub is
type Pool_T is new Sub_Pool_T with private;
type Pool is access Pool_T;
-- API methods
function Get (This : access Pool_T; ID : Skill_ID_T) return P;
overriding
function Make_Boxed_Instance (This : access Pool_T) return Box;
----------------------
-- internal methods --
----------------------
-- constructor invoked by new_pool
function Make
(Super : Skill.Types.Pools.Pool;
Type_Id : Natural;
Name : String_Access) return Pools.Pool;
-- destructor invoked by close
procedure Free (This : access Pool_T);
overriding function Add_Field
(This : access Pool_T;
ID : Natural;
T : Field_Types.Field_Type;
Name : String_Access;
Restrictions : Field_Restrictions.Vector) return Skill.Field_Declarations.Field_Declaration;
overriding
procedure Add_Known_Field
(This : access Pool_T;
Name : String_Access;
String_Type : Field_Types.Builtin.String_Type_P.Field_Type;
Annotation_Type : Field_Types.Builtin.Annotation_Type_P
.Field_Type) is null;
overriding procedure Resize_Pool (This : access Pool_T);
overriding
function Make_Sub_Pool
(This : access Pool_T;
ID : Natural;
Name : String_Access) return Skill.Types.Pools.Pool is
(Make (This.To_Pool, ID, Name));
-- RTTI implementation
function Boxed is new Ada.Unchecked_Conversion (P, Types.Box);
function Unboxed is new Ada.Unchecked_Conversion (Types.Box, P);
overriding
function Read_Box
(This : access Pool_T;
Input : Skill.Streams.Reader.Stream) return Types.Box is
(Boxed (This.Get (Skill_ID_T (Input.V64))));
overriding
function Offset_Box
(This : access Pool_T;
Target : Types.Box) return Types.v64;
overriding
procedure Write_Box
(This : access Pool_T;
Output : Streams.Writer.Sub_Stream;
Target : Types.Box);
overriding
function Content_Tag
(This : access Pool_T) return Ada.Tags.Tag is
(This.To_Pool.Super.Dynamic.Content_Tag);
private
package Book_P is new Skill.Books(T, P);
type Pool_T is new Sub_Pool_T with record
Book : aliased Book_P.Book;
end record;
end Skill.Types.Pools.Sub;
|
with Lv.Area;
with System;
package Lv.Hal.Indev is
type Indev_Type_T is (Type_None,
Type_Pointer,
Type_Keypad,
Type_Button,
Type_Encoder);
type Indev_State_T is (State_Rel, State_Pr);
type Indev_Data_T_Union (Discr : unsigned := 0) is record
case Discr is
when 0 =>
Point : aliased Lv.Area.Point_T;
when 1 =>
Key : aliased Uint32_T;
when 2 =>
Btn : aliased Uint32_T;
when others =>
Enc_Diff : aliased Int16_T;
end case;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Data_T_Union);
pragma Unchecked_Union (Indev_Data_T_Union);
type Indev_Data_T is record
Union : aliased Indev_Data_T_Union;
User_Data : System.Address;
State : aliased Indev_State_T;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Data_T);
type Indev_Drv_T is record
C_Type : aliased Indev_Type_T;
Read : access function (Data : access Indev_Data_T) return U_Bool;
User_Data : System.Address;
end record;
pragma Convention (C_Pass_By_Copy, Indev_Drv_T);
type Indev_T is private;
-- Initialize an input device driver with default values.
-- It is used to surly have known values in the fields ant not memory junk.
-- After it you can set the fields.
-- @param driver pointer to driver variable to initialize
procedure Init_Drv (Driver : access Indev_Drv_T);
-- Register an initialized input device driver.
-- @param driver pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)
-- @return pointer to the new input device or NULL on error
function Register
(Driver : access Indev_Drv_T) return Indev_T;
-- Get the next input device.
-- @param indev pointer to the current input device. NULL to initialize.
-- @return the next input devise or NULL if no more. Gives the first input device when the parameter is NULL
function Next
(Indev : access Indev_T) return access Indev_T;
-- Read data from an input device.
-- @param indev pointer to an input device
-- @param data input device will write its data here
-- @return false: no more data; true: there more data to read (buffered)
function Read
(Indev : access Indev_T;
Data : access Indev_Data_T) return U_Bool;
private
type Indev_T is new System.Address;
-------------
-- Imports --
-------------
pragma Import (C, Init_Drv, "lv_indev_drv_init");
pragma Import (C, Register, "lv_indev_drv_register");
pragma Import (C, Next, "lv_indev_next");
pragma Import (C, Read, "lv_indev_read");
for Indev_Type_T'Size use 8;
for Indev_Type_T use
(Type_None => 0,
Type_Pointer => 1,
Type_Keypad => 2,
Type_Button => 3,
Type_Encoder => 4);
for Indev_State_T'Size use 8;
for Indev_State_T use (State_Rel => 0, State_Pr => 1);
end Lv.Hal.Indev;
|
generic
type Element_Type is private;
type Element_Array is array (Positive range <>) of Element_Type;
package Mode is
function Get_Mode (Set : Element_Array) return Element_Array;
end Mode;
|
with AUnit;
--------------------
-- Uuid.Test_Main --
--------------------
with AUnit.Reporter.Text;
with AUnit.Run;
with GNATCOLL.uuid.Suite;
procedure GNATCOLL.uuid.Test_Main is
procedure Run is new AUnit.Run.Test_Runner (GNATCOLL.uuid.Suite.Suite);
reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run (reporter);
end GNATCOLL.uuid.Test_Main;
|
-- Lumen.Joystick -- Support (Linux) joysticks under Lumen
--
-- Chip Richards, NiEstu, Phoenix AZ, Summer 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
-- Environment
with Ada.Streams.Stream_IO;
with Ada.Unchecked_Deallocation;
with Interfaces.C.Strings;
with System;
with PQueue;
with Lumen.Binary.IO;
package body Lumen.Joystick is
---------------------------------------------------------------------------
-- The task type that reads events from the joystick
task type Joystick_Event_Task is
entry Startup (Owner : in Stick_Info_Pointer);
end Joystick_Event_Task;
---------------------------------------------------------------------------
-- Instantiate the protected-queue package with the queue-event type
package Event_Queue_Pkg is new PQueue (Joystick_Event_Data);
---------------------------------------------------------------------------
-- A simple binary semaphore
protected type Signal is
procedure Set;
entry Wait;
private
Is_Set : boolean := false;
end Signal;
---------------------------------------------------------------------------
-- Our internal view of a joystick
type Axis_Array is array (Positive range <>) of Integer;
type Button_Array is array (Positive range <>) of Boolean;
type Stick_Info (Name_Len : Natural; N_Axes : Natural; N_Buttons : Natural) is record
File : Binary.IO.File_Type;
Name : String (1 .. Name_Len);
Axes : Axis_Array (1 .. N_Axes);
Buttons : Button_Array (1 .. N_Buttons);
Shutdown : Signal;
Event_Task : Joystick_Event_Task;
Events : Event_Queue_Pkg.Protected_Queue_Type;
end record;
---------------------------------------------------------------------------
--
-- The event task, reads events from the joystick, then queues them
-- internally so the app can read them
--
---------------------------------------------------------------------------
task body Joystick_Event_Task is
------------------------------------------------------------------------
use type Binary.Byte;
------------------------------------------------------------------------
-- The Linux joystick event
type JS_Event_Type is (JS_Button, JS_Axis, JS_Init, JS_Init_Button, JS_Init_Axis);
for JS_Event_Type use (JS_Button => 16#01#, JS_Axis => 16#02#,
JS_Init => 16#80#, JS_Init_Button => 16#81#, JS_Init_Axis => 16#82#);
type JS_Event_Data is record
Time : Binary.Word;
Value : Binary.S_Short;
Which : JS_Event_Type;
Number : Binary.Byte;
end record;
Base : constant := Binary.Word_Bytes;
for JS_Event_Data use record
Time at 0 range 0 .. Binary.Word'Size - 1;
Value at Base + 0 range 0 .. Binary.S_Short'Size - 1;
Which at Base + 2 range 0 .. Binary.Byte'Size - 1;
Number at Base + 3 range 0 .. Binary.Byte'Size - 1;
end record;
------------------------------------------------------------------------
Info : Stick_Info_Pointer;
Event_Rec : JS_Event_Data;
Index : Positive;
Send : Boolean;
Event_Data : Joystick_Event_Data;
------------------------------------------------------------------------
begin -- Joystick_Event_Task
-- Lets the library tell us which joystick this task belongs to
select
accept Startup (Owner : in Stick_Info_Pointer) do
Info := Owner;
end Startup;
or
terminate;
end select;
loop
-- Wait for an event to come from the joystick, or for a shutdown
-- signal to arrive
select
Info.Shutdown.Wait;
exit;
then abort
JS_Event_Data'Read (Ada.Streams.Stream_IO.Stream (Info.File), Event_Rec);
end select;
-- Only process recogized event types
if Event_Rec.Which'Valid then
Index := Positive (Event_Rec.Number + 1); -- driver uses zero-based axis and button numbers
case Event_Rec.Which is
when JS_Init =>
Send := False; -- dunno what these are, so just ignore them
when JS_Button | JS_Init_Button =>
if Boolean'Pos (Info.Buttons (Index)) /= Natural (Event_Rec.Value) then
if Info.Buttons (Index) then
Event_Data := (Which => Joystick_Button_Release, Number => Index);
else
Event_Data := (Which => Joystick_Button_Press, Number => Index);
end if;
Info.Buttons (Index) := not Info.Buttons (Index);
Send := True;
end if;
when JS_Axis | JS_Init_Axis =>
if Info.Axes (Index) /= Integer (Event_Rec.Value) then
Info.Axes (Index) := Integer (Event_Rec.Value);
Event_Data := (Which => Joystick_Axis_Change, Number => Index, Axis_Value => Info.Axes (Index));
Send := True;
end if;
end case;
-- If we had a value change, push an event into our internal queue
if Send then
Info.Events.Enqueue (Event_Data);
end if;
end if;
end loop;
end Joystick_Event_Task;
---------------------------------------------------------------------------
-- Simple binary semaphore
protected body Signal is
-- Indicate that a shutdown has occurred
procedure Set is
begin -- Set
Is_Set := true;
end Set;
-- Block until the signal is set, then clear it
entry Wait when Is_Set is
begin -- Wait
Is_Set := false;
end Wait;
end Signal;
---------------------------------------------------------------------------
--
-- Public subroutines
--
---------------------------------------------------------------------------
procedure Finalize (Stick : in out Handle) is
begin -- Finalize
if Stick.Info /= null then
Close (Stick);
end if;
end Finalize;
---------------------------------------------------------------------------
-- Open a joystick device
procedure Open (Stick : in out Handle;
Path : in String := Default_Pathname) is
use type Interfaces.C.Strings.chars_ptr;
procedure Joystick_Info (Path : in String;
N_Axes : in System.Address;
N_Buttons : in System.Address;
Name : out Interfaces.C.Strings.chars_ptr);
pragma Import (C, Joystick_Info, "joystick_info");
procedure Free (Pointer : in System.Address);
pragma Import (C, Free, "free");
Axis_Count : Binary.Byte;
Button_Count : Binary.Byte;
Name : Interfaces.C.Strings.chars_ptr;
begin -- Open
-- Ask our C helper to fetch the device's info
Joystick_Info (Path & ASCII.NUL, Axis_Count'Address, Button_Count'Address, Name);
-- If we can't get the name, then the other values are probably no good either
if Name = Interfaces.C.Strings.Null_Ptr then
Stick.Info := null;
raise Open_Failed;
else
-- Local management data for the device
Stick.Info := new Stick_Info (Name_Len => Natural (Interfaces.C.Strings.Strlen (Name)),
N_Axes => Natural (Axis_Count),
N_Buttons => Natural (Button_Count));
Binary.IO.Open (Stick.Info.File, Path);
Stick.Info.Name := Interfaces.C.Strings.Value (Name);
Stick.Info.Axes := (others => 0);
Stick.Info.Buttons := (others => False);
-- Start the events task for this joystick device
Stick.Info.Event_Task.Startup (Stick.Info);
end if;
end Open;
---------------------------------------------------------------------------
-- Close a joystick device
procedure Close (Stick : in out Handle) is
procedure Free is new Ada.Unchecked_Deallocation (Stick_Info, Stick_Info_Pointer);
begin -- Close
-- Close down this joystick
if Stick.Info /= null then
-- Shut down this stick's event task
Stick.Info.Shutdown.Set;
-- Close the stream and free the info record
Binary.IO.Close (Stick.Info.File);
Free (Stick.Info);
end if;
end Close;
---------------------------------------------------------------------------
-- Various joystick information functions
function Name (Stick : in Handle) return String is
begin -- Name
return Stick.Info.Name;
end Name;
---------------------------------------------------------------------------
function Axes (Stick : in Handle) return Natural is
begin -- Axes
return Stick.Info.N_Axes;
end Axes;
---------------------------------------------------------------------------
function Buttons (Stick : in Handle) return Natural is
begin -- Buttons
return Stick.Info.N_Buttons;
end Buttons;
---------------------------------------------------------------------------
-- Returns the number of events that are waiting in the joystick's event
-- queue. Useful to avoid blocking while waiting for the next event to
-- show up.
function Pending (Stick : in Handle) return Natural is
begin -- Pending
return Stick.Info.Events.Length;
end Pending;
---------------------------------------------------------------------------
-- Read a joystick event
function Next_Event (Stick : in Handle) return Joystick_Event_Data is
begin -- Next_Event
return Event : Joystick_Event_Data do
-- Get next event from queue (may block) and return it
Stick.Info.Events.Dequeue (Event);
end return;
end Next_Event;
---------------------------------------------------------------------------
end Lumen.Joystick;
|
pragma License (Unrestricted); -- ICU License
-- translated unit from icu4c of http://site.icu-project.org/
--
-- **********************************************************************
-- * Copyright (C) 1996-2010, International Business Machines
-- * Corporation and others. All Rights Reserved.
-- **********************************************************************
--
-- Ada version: 2013 yt
with C.stdint;
package C.icucore is
pragma Preelaborate;
package unicode is
-- <unicode/umachine.h>
package umachine is
subtype UBool is stdint.int8_t;
U_SIZEOF_UCHAR : constant := 2;
type UChar is new Wide_Character
with Convention => C;
type UChar_ptr is access all UChar
with Convention => C;
for UChar_ptr'Storage_Size use 0;
type UChar_const_ptr is access constant UChar
with Convention => C;
for UChar_const_ptr'Storage_Size use 0;
type UChar_array is array (C.size_t range <>) of aliased UChar
with Convention => C;
type UChar32 is new Wide_Wide_Character
with Convention => C;
end umachine;
-- <unicode/utypes.h>
package utypes is
type UErrorCode is (
U_USING_FALLBACK_WARNING,
U_ERROR_WARNING_LIMIT,
U_ZERO_ERROR,
U_ILLEGAL_ARGUMENT_ERROR,
U_MISSING_RESOURCE_ERROR,
U_INVALID_FORMAT_ERROR,
U_FILE_ACCESS_ERROR,
U_INTERNAL_PROGRAM_ERROR,
U_MESSAGE_PARSE_ERROR,
U_MEMORY_ALLOCATION_ERROR,
U_INDEX_OUTOFBOUNDS_ERROR,
U_PARSE_ERROR,
U_INVALID_CHAR_FOUND,
U_TRUNCATED_CHAR_FOUND,
U_ILLEGAL_CHAR_FOUND,
U_INVALID_TABLE_FORMAT,
U_INVALID_TABLE_FILE,
U_BUFFER_OVERFLOW_ERROR,
U_UNSUPPORTED_ERROR,
U_STANDARD_ERROR_LIMIT,
U_PLUGIN_ERROR_LIMIT)
with Convention => C;
for UErrorCode use (
U_USING_FALLBACK_WARNING => -128,
U_ERROR_WARNING_LIMIT => -119,
U_ZERO_ERROR => 0,
U_ILLEGAL_ARGUMENT_ERROR => 1,
U_MISSING_RESOURCE_ERROR => 2,
U_INVALID_FORMAT_ERROR => 3,
U_FILE_ACCESS_ERROR => 4,
U_INTERNAL_PROGRAM_ERROR => 5,
U_MESSAGE_PARSE_ERROR => 6,
U_MEMORY_ALLOCATION_ERROR => 7,
U_INDEX_OUTOFBOUNDS_ERROR => 8,
U_PARSE_ERROR => 9,
U_INVALID_CHAR_FOUND => 10,
U_TRUNCATED_CHAR_FOUND => 11,
U_ILLEGAL_CHAR_FOUND => 12,
U_INVALID_TABLE_FORMAT => 13,
U_INVALID_TABLE_FILE => 14,
U_BUFFER_OVERFLOW_ERROR => 15,
U_UNSUPPORTED_ERROR => 16,
U_STANDARD_ERROR_LIMIT => 31,
U_PLUGIN_ERROR_LIMIT => 16#10502#);
pragma Discard_Names (UErrorCode);
function U_ERROR_LIMIT return UErrorCode
renames U_PLUGIN_ERROR_LIMIT;
end utypes;
-- <unicode/ucnv_err.h>
package ucnv_err is
type UConverter (<>) is limited private;
type UConverter_ptr is access all UConverter;
for UConverter_ptr'Storage_Size use 0;
type UConverterCallbackReason is (
UCNV_UNASSIGNED,
UCNV_ILLEGAL,
UCNV_IRREGULAR,
UCNV_RESET,
UCNV_CLOSE,
UCNV_CLONE)
with Convention => C;
pragma Discard_Names (UConverterCallbackReason);
type UConverterFromUnicodeArgs is record
size : stdint.uint16_t;
flush : umachine.UBool;
converter : access UConverter;
source : access constant umachine.UChar;
sourceLimit : access constant umachine.UChar;
target : access char;
targetLimit : access constant char;
offsets : access stdint.int32_t;
end record
with Convention => C;
pragma Suppress_Initialization (UConverterFromUnicodeArgs);
type UConverterToUnicodeArgs is record
size : stdint.uint16_t;
flush : umachine.UBool;
converter : access UConverter;
source : access constant char;
sourceLimit : access constant char;
target : access umachine.UChar;
targetLimit : access constant umachine.UChar;
offsets : access stdint.int32_t;
end record
with Convention => C;
pragma Suppress_Initialization (UConverterToUnicodeArgs);
procedure UCNV_FROM_U_CALLBACK_STOP (
context : void_const_ptr;
fromUArgs : access UConverterFromUnicodeArgs;
codeUnits : access constant umachine.UChar;
length : stdint.int32_t;
codePoint : umachine.UChar32;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_FROM_U_CALLBACK_STOP";
procedure UCNV_TO_U_CALLBACK_STOP (
context : void_const_ptr;
toUArgs : access UConverterToUnicodeArgs;
codeUnits : access constant char;
length : stdint.int32_t;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_TO_U_CALLBACK_STOP";
procedure UCNV_FROM_U_CALLBACK_SKIP (
context : void_const_ptr;
fromUArgs : access UConverterFromUnicodeArgs;
codeUnits : access constant umachine.UChar;
length : stdint.int32_t;
codePoint : umachine.UChar32;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_FROM_U_CALLBACK_SKIP";
procedure UCNV_FROM_U_CALLBACK_SUBSTITUTE (
context : void_const_ptr;
fromUArgs : access UConverterFromUnicodeArgs;
codeUnits : access constant umachine.UChar;
length : stdint.int32_t;
codePoint : umachine.UChar32;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C,
External_Name => "UCNV_FROM_U_CALLBACK_SUBSTITUTE";
procedure UCNV_FROM_U_CALLBACK_ESCAPE (
context : void_const_ptr;
fromUArgs : access UConverterFromUnicodeArgs;
codeUnits : access constant umachine.UChar;
length : stdint.int32_t;
codePoint : umachine.UChar32;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_FROM_U_CALLBACK_ESCAPE";
procedure UCNV_TO_U_CALLBACK_SKIP (
context : void_const_ptr;
toUArgs : access UConverterToUnicodeArgs;
codeUnits : access constant char;
length : stdint.int32_t;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_TO_U_CALLBACK_SKIP";
procedure UCNV_TO_U_CALLBACK_SUBSTITUTE (
context : void_const_ptr;
toUArgs : access UConverterToUnicodeArgs;
codeUnits : access constant char;
length : stdint.int32_t;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C,
External_Name => "UCNV_TO_U_CALLBACK_SUBSTITUTE";
procedure UCNV_TO_U_CALLBACK_ESCAPE (
context : void_const_ptr;
toUArgs : access UConverterToUnicodeArgs;
codeUnits : access constant char;
length : stdint.int32_t;
reason : UConverterCallbackReason;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "UCNV_TO_U_CALLBACK_ESCAPE";
private
type UConverter is null record
with Convention => C;
pragma Suppress_Initialization (UConverter);
end ucnv_err;
-- <unicode/ucnv.h>
package ucnv is
type UConverterToUCallback is access procedure (
context : void_const_ptr;
args : access ucnv_err.UConverterToUnicodeArgs;
codeUnits : access constant char;
length : stdint.int32_t;
reason : ucnv_err.UConverterCallbackReason;
pErrorCode : access utypes.UErrorCode)
with Convention => C;
type UConverterFromUCallback is access procedure (
context : void_const_ptr;
args : access ucnv_err.UConverterFromUnicodeArgs;
codeUnits : access constant umachine.UChar;
length : stdint.int32_t;
codePoint : umachine.UChar32;
reason : ucnv_err.UConverterCallbackReason;
pErrorCode : access utypes.UErrorCode)
with Convention => C;
function ucnv_open (
converterName : access constant char;
err : access utypes.UErrorCode)
return ucnv_err.UConverter_ptr
with Import, Convention => C, External_Name => "ucnv_open";
procedure ucnv_close (
converter : access ucnv_err.UConverter)
with Import, Convention => C, External_Name => "ucnv_close";
procedure ucnv_getSubstChars (
converter : access constant ucnv_err.UConverter;
subChars : access char;
len : access stdint.int8_t;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "ucnv_getSubstChars";
procedure ucnv_setSubstChars (
converter : access ucnv_err.UConverter;
subChars : access constant char;
len : stdint.int8_t;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "ucnv_setSubstChars";
function ucnv_getMinCharSize (
converter : access constant ucnv_err.UConverter)
return stdint.int8_t
with Import,
Convention => C, External_Name => "ucnv_getMinCharSize";
procedure ucnv_getToUCallBack (
converter : access constant ucnv_err.UConverter;
action : access UConverterToUCallback;
context : access void_const_ptr)
with Import,
Convention => C, External_Name => "ucnv_getToUCallBack";
procedure ucnv_getFromUCallBack (
converter : access constant ucnv_err.UConverter;
action : access UConverterFromUCallback;
context : access void_const_ptr)
with Import,
Convention => C, External_Name => "ucnv_getFromUCallBack";
procedure ucnv_setToUCallBack (
converter : access ucnv_err.UConverter;
newAction : UConverterToUCallback;
newContext : void_const_ptr;
oldAction : access UConverterToUCallback;
oldContext : access void_const_ptr;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "ucnv_setToUCallBack";
procedure ucnv_setFromUCallBack (
converter : access ucnv_err.UConverter;
newAction : UConverterFromUCallback;
newContext : void_const_ptr;
oldAction : access UConverterFromUCallback;
oldContext : access void_const_ptr;
err : access utypes.UErrorCode)
with Import,
Convention => C, External_Name => "ucnv_setFromUCallBack";
procedure ucnv_fromUnicode (
converter : access ucnv_err.UConverter;
target : access char_ptr;
targetLimit : access constant char;
source : access umachine.UChar_const_ptr;
sourceLimit : access constant umachine.UChar;
offsets : access stdint.int32_t;
flush : umachine.UBool;
err : access utypes.UErrorCode)
with Import, Convention => C, External_Name => "ucnv_fromUnicode";
procedure ucnv_toUnicode (
converter : access ucnv_err.UConverter;
target : access umachine.UChar_ptr;
targetLimit : access constant umachine.UChar;
source : access char_const_ptr;
sourceLimit : access constant char;
offsets : access stdint.int32_t;
flush : umachine.UBool;
err : access utypes.UErrorCode)
with Import, Convention => C, External_Name => "ucnv_toUnicode";
end ucnv;
end unicode;
-- alias
subtype UBool is unicode.umachine.UBool;
subtype UChar is unicode.umachine.UChar;
subtype UChar_ptr is unicode.umachine.UChar_ptr;
subtype UChar_const_ptr is unicode.umachine.UChar_const_ptr;
subtype UChar_array is unicode.umachine.UChar_array;
subtype UChar32 is unicode.umachine.UChar32;
subtype UErrorCode is unicode.utypes.UErrorCode;
subtype UConverter is unicode.ucnv_err.UConverter;
subtype UConverter_ptr is unicode.ucnv_err.UConverter_ptr;
subtype UConverterCallbackReason is
unicode.ucnv_err.UConverterCallbackReason;
subtype UConverterFromUnicodeArgs is
unicode.ucnv_err.UConverterFromUnicodeArgs;
subtype UConverterToUnicodeArgs is
unicode.ucnv_err.UConverterToUnicodeArgs;
subtype UConverterToUCallback is
unicode.ucnv.UConverterToUCallback;
subtype UConverterFromUCallback is
unicode.ucnv.UConverterFromUCallback;
end C.icucore;
|
with Rejuvenation; use Rejuvenation;
with Rejuvenation.Finder; use Rejuvenation.Finder;
with Rejuvenation.Placeholders; use Rejuvenation.Placeholders;
with Rejuvenation.Replacer; use Rejuvenation.Replacer;
with String_Maps; use String_Maps;
package body Rejuvenation.Find_And_Replacer is
function Accept_All_Matches (Match : Match_Pattern) return Boolean is
pragma Unreferenced (Match);
-- In Ada 2022 replace with aspect on formal parameter Match
-- + make function expression!
begin
return True;
end Accept_All_Matches;
procedure Find_And_Replace
(TR : in out Text_Rewrite'Class; Node : Ada_Node'Class;
Find_Pattern, Replace_Pattern : Pattern;
Accept_Match : Match_Accepter := Accept_All_Matches'Access;
Before, After : Node_Location := No_Trivia)
is
function Get_Placeholder_Replacement (Match : Match_Pattern) return Map;
function Get_Placeholder_Replacement (Match : Match_Pattern) return Map
is
Result : Map;
begin
for Placeholder_Name of Rejuvenation.Placeholders
.Get_Placeholder_Names
(Replace_Pattern.As_Ada_Node)
loop
declare
Placeholder_Nodes : constant Node_List.Vector :=
Match.Get_Placeholder_As_Nodes (Placeholder_Name);
begin
if Placeholder_Nodes.Length = 0 then
Result.Insert (Placeholder_Name, "");
else
declare
TN : Text_Rewrite :=
Make_Text_Rewrite_Nodes
(Placeholder_Nodes.First_Element,
Placeholder_Nodes.Last_Element, All_Trivia,
All_Trivia);
-- always include comments of place holders
begin
for Node of Placeholder_Nodes loop
Find_And_Replace
(TN, Node, Find_Pattern, Replace_Pattern,
Accept_Match, Before, After);
end loop;
Result.Insert (Placeholder_Name, TN.ApplyToString);
end;
end if;
end;
end loop;
return Result;
end Get_Placeholder_Replacement;
Matches : constant Match_Pattern_List.Vector :=
(if Find_Pattern.As_Ada_Node.Kind in Ada_Ada_List then
Find_Non_Contained_Sub_List (Node, Find_Pattern)
else Find_Non_Contained_Full (Node, Find_Pattern));
begin
for Match of Matches loop
if Accept_Match (Match) then
declare
Match_Nodes : constant Node_List.Vector := Match.Get_Nodes;
Replacements : constant Map :=
Get_Placeholder_Replacement (Match);
begin
TR.Replace
(Match_Nodes.First_Element, Match_Nodes.Last_Element,
Replace (Replace_Pattern.As_Ada_Node, Replacements), Before,
After, Node.Unit.Get_Charset);
end;
end if;
end loop;
end Find_And_Replace;
function Find_And_Replace
(File_Path : String; Find_Pattern, Replace_Pattern : Pattern;
Accept_Match : Match_Accepter := Accept_All_Matches'Access;
Before, After : Node_Location := No_Trivia) return Boolean
is
Ctx : constant Analysis_Context := Create_Context;
File_Unit : constant Analysis_Unit := Ctx.Get_From_File (File_Path);
TR : Text_Rewrite_Unit := Make_Text_Rewrite_Unit (File_Unit);
begin
Find_And_Replace
(TR, File_Unit.Root, Find_Pattern, Replace_Pattern, Accept_Match,
Before, After);
TR.Apply;
return TR.HasReplacements;
end Find_And_Replace;
end Rejuvenation.Find_And_Replacer;
|
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.USART is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- USART Enable.
type CFG_ENABLE_Field is
(
-- Disabled. The USART is disabled and the internal state machine and
-- counters are reset. While Enable = 0, all USART interrupts and DMA
-- transfers are disabled. When Enable is set again, CFG and most other
-- control bits remain unchanged. When re-enabled, the USART will
-- immediately be ready to transmit because the transmitter has been
-- reset and is therefore available.
Disabled,
-- Enabled. The USART is enabled for operation.
Enabled)
with Size => 1;
for CFG_ENABLE_Field use
(Disabled => 0,
Enabled => 1);
-- Selects the data size for the USART.
type CFG_DATALEN_Field is
(
-- 7 bit Data length.
Bit_7,
-- 8 bit Data length.
Bit_8,
-- 9 bit data length. The 9th bit is commonly used for addressing in
-- multidrop mode. See the ADDRDET bit in the CTL register.
Bit_9)
with Size => 2;
for CFG_DATALEN_Field use
(Bit_7 => 0,
Bit_8 => 1,
Bit_9 => 2);
-- Selects what type of parity is used by the USART.
type CFG_PARITYSEL_Field is
(
-- No parity.
No_Parity,
-- Even parity. Adds a bit to each character such that the number of 1s
-- in a transmitted character is even, and the number of 1s in a
-- received character is expected to be even.
Even_Parity,
-- Odd parity. Adds a bit to each character such that the number of 1s
-- in a transmitted character is odd, and the number of 1s in a received
-- character is expected to be odd.
Odd_Parity)
with Size => 2;
for CFG_PARITYSEL_Field use
(No_Parity => 0,
Even_Parity => 2,
Odd_Parity => 3);
-- Number of stop bits appended to transmitted data. Only a single stop bit
-- is required for received data.
type CFG_STOPLEN_Field is
(
-- 1 stop bit.
Bit_1,
-- 2 stop bits. This setting should only be used for asynchronous
-- communication.
Bits_2)
with Size => 1;
for CFG_STOPLEN_Field use
(Bit_1 => 0,
Bits_2 => 1);
-- Selects standard or 32 kHz clocking mode.
type CFG_MODE32K_Field is
(
-- Disabled. USART uses standard clocking.
Disabled,
-- Enabled. USART uses the 32 kHz clock from the RTC oscillator as the
-- clock source to the BRG, and uses a special bit clocking scheme.
Enabled)
with Size => 1;
for CFG_MODE32K_Field use
(Disabled => 0,
Enabled => 1);
-- LIN break mode enable.
type CFG_LINMODE_Field is
(
-- Disabled. Break detect and generate is configured for normal
-- operation.
Disabled,
-- Enabled. Break detect and generate is configured for LIN bus
-- operation.
Enabled)
with Size => 1;
for CFG_LINMODE_Field use
(Disabled => 0,
Enabled => 1);
-- CTS Enable. Determines whether CTS is used for flow control. CTS can be
-- from the input pin, or from the USART's own RTS if loopback mode is
-- enabled.
type CFG_CTSEN_Field is
(
-- No flow control. The transmitter does not receive any automatic flow
-- control signal.
Disabled,
-- Flow control enabled. The transmitter uses the CTS input (or RTS
-- output in loopback mode) for flow control purposes.
Enabled)
with Size => 1;
for CFG_CTSEN_Field use
(Disabled => 0,
Enabled => 1);
-- Selects synchronous or asynchronous operation.
type CFG_SYNCEN_Field is
(
-- Asynchronous mode.
Asynchronous_Mode,
-- Synchronous mode.
Synchronous_Mode)
with Size => 1;
for CFG_SYNCEN_Field use
(Asynchronous_Mode => 0,
Synchronous_Mode => 1);
-- Selects the clock polarity and sampling edge of received data in
-- synchronous mode.
type CFG_CLKPOL_Field is
(
-- Falling edge. Un_RXD is sampled on the falling edge of SCLK.
Falling_Edge,
-- Rising edge. Un_RXD is sampled on the rising edge of SCLK.
Rising_Edge)
with Size => 1;
for CFG_CLKPOL_Field use
(Falling_Edge => 0,
Rising_Edge => 1);
-- Synchronous mode Master select.
type CFG_SYNCMST_Field is
(
-- Slave. When synchronous mode is enabled, the USART is a slave.
Slave,
-- Master. When synchronous mode is enabled, the USART is a master.
Master)
with Size => 1;
for CFG_SYNCMST_Field use
(Slave => 0,
Master => 1);
-- Selects data loopback mode.
type CFG_LOOP_Field is
(
-- Normal operation.
Normal,
-- Loopback mode. This provides a mechanism to perform diagnostic
-- loopback testing for USART data. Serial data from the transmitter
-- (Un_TXD) is connected internally to serial input of the receive
-- (Un_RXD). Un_TXD and Un_RTS activity will also appear on external
-- pins if these functions are configured to appear on device pins. The
-- receiver RTS signal is also looped back to CTS and performs flow
-- control if enabled by CTSEN.
Loopback)
with Size => 1;
for CFG_LOOP_Field use
(Normal => 0,
Loopback => 1);
-- Output Enable Turnaround time enable for RS-485 operation.
type CFG_OETA_Field is
(
-- Disabled. If selected by OESEL, the Output Enable signal deasserted
-- at the end of the last stop bit of a transmission.
Disabled,
-- Enabled. If selected by OESEL, the Output Enable signal remains
-- asserted for one character time after the end of the last stop bit of
-- a transmission. OE will also remain asserted if another transmit
-- begins before it is deasserted.
Enabled)
with Size => 1;
for CFG_OETA_Field use
(Disabled => 0,
Enabled => 1);
-- Automatic Address matching enable.
type CFG_AUTOADDR_Field is
(
-- Disabled. When addressing is enabled by ADDRDET, address matching is
-- done by software. This provides the possibility of versatile
-- addressing (e.g. respond to more than one address).
Disabled,
-- Enabled. When addressing is enabled by ADDRDET, address matching is
-- done by hardware, using the value in the ADDR register as the address
-- to match.
Enabled)
with Size => 1;
for CFG_AUTOADDR_Field use
(Disabled => 0,
Enabled => 1);
-- Output Enable Select.
type CFG_OESEL_Field is
(
-- Standard. The RTS signal is used as the standard flow control
-- function.
Standard,
-- RS-485. The RTS signal configured to provide an output enable signal
-- to control an RS-485 transceiver.
Rs_485)
with Size => 1;
for CFG_OESEL_Field use
(Standard => 0,
Rs_485 => 1);
-- Output Enable Polarity.
type CFG_OEPOL_Field is
(
-- Low. If selected by OESEL, the output enable is active low.
Low,
-- High. If selected by OESEL, the output enable is active high.
High)
with Size => 1;
for CFG_OEPOL_Field use
(Low => 0,
High => 1);
-- Receive data polarity.
type CFG_RXPOL_Field is
(
-- Standard. The RX signal is used as it arrives from the pin. This
-- means that the RX rest value is 1, start bit is 0, data is not
-- inverted, and the stop bit is 1.
Standard,
-- Inverted. The RX signal is inverted before being used by the USART.
-- This means that the RX rest value is 0, start bit is 1, data is
-- inverted, and the stop bit is 0.
Inverted)
with Size => 1;
for CFG_RXPOL_Field use
(Standard => 0,
Inverted => 1);
-- Transmit data polarity.
type CFG_TXPOL_Field is
(
-- Standard. The TX signal is sent out without change. This means that
-- the TX rest value is 1, start bit is 0, data is not inverted, and the
-- stop bit is 1.
Standard,
-- Inverted. The TX signal is inverted by the USART before being sent
-- out. This means that the TX rest value is 0, start bit is 1, data is
-- inverted, and the stop bit is 0.
Inverted)
with Size => 1;
for CFG_TXPOL_Field use
(Standard => 0,
Inverted => 1);
-- USART Configuration register. Basic USART configuration settings that
-- typically are not changed during operation.
type CFG_Register is record
-- USART Enable.
ENABLE : CFG_ENABLE_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- Selects the data size for the USART.
DATALEN : CFG_DATALEN_Field := NXP_SVD.USART.Bit_7;
-- Selects what type of parity is used by the USART.
PARITYSEL : CFG_PARITYSEL_Field := NXP_SVD.USART.No_Parity;
-- Number of stop bits appended to transmitted data. Only a single stop
-- bit is required for received data.
STOPLEN : CFG_STOPLEN_Field := NXP_SVD.USART.Bit_1;
-- Selects standard or 32 kHz clocking mode.
MODE32K : CFG_MODE32K_Field := NXP_SVD.USART.Disabled;
-- LIN break mode enable.
LINMODE : CFG_LINMODE_Field := NXP_SVD.USART.Disabled;
-- CTS Enable. Determines whether CTS is used for flow control. CTS can
-- be from the input pin, or from the USART's own RTS if loopback mode
-- is enabled.
CTSEN : CFG_CTSEN_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_10_10 : HAL.Bit := 16#0#;
-- Selects synchronous or asynchronous operation.
SYNCEN : CFG_SYNCEN_Field := NXP_SVD.USART.Asynchronous_Mode;
-- Selects the clock polarity and sampling edge of received data in
-- synchronous mode.
CLKPOL : CFG_CLKPOL_Field := NXP_SVD.USART.Falling_Edge;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Synchronous mode Master select.
SYNCMST : CFG_SYNCMST_Field := NXP_SVD.USART.Slave;
-- Selects data loopback mode.
LOOP_k : CFG_LOOP_Field := NXP_SVD.USART.Normal;
-- unspecified
Reserved_16_17 : HAL.UInt2 := 16#0#;
-- Output Enable Turnaround time enable for RS-485 operation.
OETA : CFG_OETA_Field := NXP_SVD.USART.Disabled;
-- Automatic Address matching enable.
AUTOADDR : CFG_AUTOADDR_Field := NXP_SVD.USART.Disabled;
-- Output Enable Select.
OESEL : CFG_OESEL_Field := NXP_SVD.USART.Standard;
-- Output Enable Polarity.
OEPOL : CFG_OEPOL_Field := NXP_SVD.USART.Low;
-- Receive data polarity.
RXPOL : CFG_RXPOL_Field := NXP_SVD.USART.Standard;
-- Transmit data polarity.
TXPOL : CFG_TXPOL_Field := NXP_SVD.USART.Standard;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFG_Register use record
ENABLE at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
DATALEN at 0 range 2 .. 3;
PARITYSEL at 0 range 4 .. 5;
STOPLEN at 0 range 6 .. 6;
MODE32K at 0 range 7 .. 7;
LINMODE at 0 range 8 .. 8;
CTSEN at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
SYNCEN at 0 range 11 .. 11;
CLKPOL at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
SYNCMST at 0 range 14 .. 14;
LOOP_k at 0 range 15 .. 15;
Reserved_16_17 at 0 range 16 .. 17;
OETA at 0 range 18 .. 18;
AUTOADDR at 0 range 19 .. 19;
OESEL at 0 range 20 .. 20;
OEPOL at 0 range 21 .. 21;
RXPOL at 0 range 22 .. 22;
TXPOL at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Break Enable.
type CTL_TXBRKEN_Field is
(
-- Normal operation.
Normal,
-- Continuous break. Continuous break is sent immediately when this bit
-- is set, and remains until this bit is cleared. A break may be sent
-- without danger of corrupting any currently transmitting character if
-- the transmitter is first disabled (TXDIS in CTL is set) and then
-- waiting for the transmitter to be disabled (TXDISINT in STAT = 1)
-- before writing 1 to TXBRKEN.
Continous)
with Size => 1;
for CTL_TXBRKEN_Field use
(Normal => 0,
Continous => 1);
-- Enable address detect mode.
type CTL_ADDRDET_Field is
(
-- Disabled. The USART presents all incoming data.
Disabled,
-- Enabled. The USART receiver ignores incoming data that does not have
-- the most significant bit of the data (typically the 9th bit) = 1.
-- When the data MSB bit = 1, the receiver treats the incoming data
-- normally, generating a received data interrupt. Software can then
-- check the data to see if this is an address that should be handled.
-- If it is, the ADDRDET bit is cleared by software and further incoming
-- data is handled normally.
Enabled)
with Size => 1;
for CTL_ADDRDET_Field use
(Disabled => 0,
Enabled => 1);
-- Transmit Disable.
type CTL_TXDIS_Field is
(
-- Not disabled. USART transmitter is not disabled.
Enabled,
-- Disabled. USART transmitter is disabled after any character currently
-- being transmitted is complete. This feature can be used to facilitate
-- software flow control.
Disabled)
with Size => 1;
for CTL_TXDIS_Field use
(Enabled => 0,
Disabled => 1);
-- Continuous Clock generation. By default, SCLK is only output while data
-- is being transmitted in synchronous mode.
type CTL_CC_Field is
(
-- Clock on character. In synchronous mode, SCLK cycles only when
-- characters are being sent on Un_TXD or to complete a character that
-- is being received.
Clock_On_Character,
-- Continuous clock. SCLK runs continuously in synchronous mode,
-- allowing characters to be received on Un_RxD independently from
-- transmission on Un_TXD).
Continous_Clock)
with Size => 1;
for CTL_CC_Field use
(Clock_On_Character => 0,
Continous_Clock => 1);
-- Clear Continuous Clock.
type CTL_CLRCCONRX_Field is
(
-- No effect. No effect on the CC bit.
No_Effect,
-- Auto-clear. The CC bit is automatically cleared when a complete
-- character has been received. This bit is cleared at the same time.
Auto_Clear)
with Size => 1;
for CTL_CLRCCONRX_Field use
(No_Effect => 0,
Auto_Clear => 1);
-- Autobaud enable.
type CTL_AUTOBAUD_Field is
(
-- Disabled. USART is in normal operating mode.
Disabled,
-- Enabled. USART is in autobaud mode. This bit should only be set when
-- the USART receiver is idle. The first start bit of RX is measured and
-- used the update the BRG register to match the received data rate.
-- AUTOBAUD is cleared once this process is complete, or if there is an
-- AERR.
Enabled)
with Size => 1;
for CTL_AUTOBAUD_Field use
(Disabled => 0,
Enabled => 1);
-- USART Control register. USART control settings that are more likely to
-- change during operation.
type CTL_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Break Enable.
TXBRKEN : CTL_TXBRKEN_Field := NXP_SVD.USART.Normal;
-- Enable address detect mode.
ADDRDET : CTL_ADDRDET_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_3_5 : HAL.UInt3 := 16#0#;
-- Transmit Disable.
TXDIS : CTL_TXDIS_Field := NXP_SVD.USART.Enabled;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Continuous Clock generation. By default, SCLK is only output while
-- data is being transmitted in synchronous mode.
CC : CTL_CC_Field := NXP_SVD.USART.Clock_On_Character;
-- Clear Continuous Clock.
CLRCCONRX : CTL_CLRCCONRX_Field := NXP_SVD.USART.No_Effect;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- Autobaud enable.
AUTOBAUD : CTL_AUTOBAUD_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTL_Register use record
Reserved_0_0 at 0 range 0 .. 0;
TXBRKEN at 0 range 1 .. 1;
ADDRDET at 0 range 2 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
TXDIS at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CC at 0 range 8 .. 8;
CLRCCONRX at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
AUTOBAUD at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- USART Status register. The complete status value can be read here.
-- Writing ones clears some bits in the register. Some bits can be cleared
-- by writing a 1 to them.
type STAT_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Read-only. Receiver Idle. When 0, indicates that the receiver is
-- currently in the process of receiving data. When 1, indicates that
-- the receiver is not currently in the process of receiving data.
RXIDLE : Boolean := True;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Read-only. Transmitter Idle. When 0, indicates that the transmitter
-- is currently in the process of sending data.When 1, indicate that the
-- transmitter is not currently in the process of sending data.
TXIDLE : Boolean := True;
-- Read-only. This bit reflects the current state of the CTS signal,
-- regardless of the setting of the CTSEN bit in the CFG register. This
-- will be the value of the CTS input pin unless loopback mode is
-- enabled.
CTS : Boolean := False;
-- Write-only. This bit is set when a change in the state is detected
-- for the CTS flag above. This bit is cleared by software.
DELTACTS : Boolean := False;
-- Read-only. Transmitter Disabled Status flag. When 1, this bit
-- indicates that the USART transmitter is fully idle after being
-- disabled via the TXDIS bit in the CFG register (TXDIS = 1).
TXDISSTAT : Boolean := False;
-- unspecified
Reserved_7_9 : HAL.UInt3 := 16#0#;
-- Read-only. Received Break. This bit reflects the current state of the
-- receiver break detection logic. It is set when the Un_RXD pin remains
-- low for 16 bit times. Note that FRAMERRINT will also be set when this
-- condition occurs because the stop bit(s) for the character would be
-- missing. RXBRK is cleared when the Un_RXD pin goes high.
RXBRK : Boolean := False;
-- Write-only. This bit is set when a change in the state of receiver
-- break detection occurs. Cleared by software.
DELTARXBRK : Boolean := False;
-- Write-only. This bit is set when a start is detected on the receiver
-- input. Its purpose is primarily to allow wake-up from Deep-sleep or
-- Power-down mode immediately when a start is detected. Cleared by
-- software.
START : Boolean := False;
-- Write-only. Framing Error interrupt flag. This flag is set when a
-- character is received with a missing stop bit at the expected
-- location. This could be an indication of a baud rate or configuration
-- mismatch with the transmitting source.
FRAMERRINT : Boolean := False;
-- Write-only. Parity Error interrupt flag. This flag is set when a
-- parity error is detected in a received character.
PARITYERRINT : Boolean := False;
-- Write-only. Received Noise interrupt flag. Three samples of received
-- data are taken in order to determine the value of each received data
-- bit, except in synchronous mode. This acts as a noise filter if one
-- sample disagrees. This flag is set when a received data bit contains
-- one disagreeing sample. This could indicate line noise, a baud rate
-- or character format mismatch, or loss of synchronization during data
-- reception.
RXNOISEINT : Boolean := False;
-- Write-only. Auto baud Error. An auto baud error can occur if the BRG
-- counts to its limit before the end of the start bit that is being
-- measured, essentially an auto baud time-out.
ABERR : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STAT_Register use record
Reserved_0_0 at 0 range 0 .. 0;
RXIDLE at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
TXIDLE at 0 range 3 .. 3;
CTS at 0 range 4 .. 4;
DELTACTS at 0 range 5 .. 5;
TXDISSTAT at 0 range 6 .. 6;
Reserved_7_9 at 0 range 7 .. 9;
RXBRK at 0 range 10 .. 10;
DELTARXBRK at 0 range 11 .. 11;
START at 0 range 12 .. 12;
FRAMERRINT at 0 range 13 .. 13;
PARITYERRINT at 0 range 14 .. 14;
RXNOISEINT at 0 range 15 .. 15;
ABERR at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- Interrupt Enable read and Set register for USART (not FIFO) status.
-- Contains individual interrupt enable bits for each potential USART
-- interrupt. A complete value may be read from this register. Writing a 1
-- to any implemented bit position causes that bit to be set.
type INTENSET_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- When 1, enables an interrupt when the transmitter becomes idle
-- (TXIDLE = 1).
TXIDLEEN : Boolean := False;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- When 1, enables an interrupt when there is a change in the state of
-- the CTS input.
DELTACTSEN : Boolean := False;
-- When 1, enables an interrupt when the transmitter is fully disabled
-- as indicated by the TXDISINT flag in STAT. See description of the
-- TXDISINT bit for details.
TXDISEN : Boolean := False;
-- unspecified
Reserved_7_10 : HAL.UInt4 := 16#0#;
-- When 1, enables an interrupt when a change of state has occurred in
-- the detection of a received break condition (break condition asserted
-- or deasserted).
DELTARXBRKEN : Boolean := False;
-- When 1, enables an interrupt when a received start bit has been
-- detected.
STARTEN : Boolean := False;
-- When 1, enables an interrupt when a framing error has been detected.
FRAMERREN : Boolean := False;
-- When 1, enables an interrupt when a parity error has been detected.
PARITYERREN : Boolean := False;
-- When 1, enables an interrupt when noise is detected. See description
-- of the RXNOISEINT bit in Table 354.
RXNOISEEN : Boolean := False;
-- When 1, enables an interrupt when an auto baud error occurs.
ABERREN : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
Reserved_0_2 at 0 range 0 .. 2;
TXIDLEEN at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
DELTACTSEN at 0 range 5 .. 5;
TXDISEN at 0 range 6 .. 6;
Reserved_7_10 at 0 range 7 .. 10;
DELTARXBRKEN at 0 range 11 .. 11;
STARTEN at 0 range 12 .. 12;
FRAMERREN at 0 range 13 .. 13;
PARITYERREN at 0 range 14 .. 14;
RXNOISEEN at 0 range 15 .. 15;
ABERREN at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- Interrupt Enable Clear register. Allows clearing any combination of bits
-- in the INTENSET register. Writing a 1 to any implemented bit position
-- causes the corresponding bit to be cleared.
type INTENCLR_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3 := 16#0#;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
TXIDLECLR : Boolean := False;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
DELTACTSCLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
TXDISCLR : Boolean := False;
-- unspecified
Reserved_7_10 : HAL.UInt4 := 16#0#;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
DELTARXBRKCLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
STARTCLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
FRAMERRCLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
PARITYERRCLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
RXNOISECLR : Boolean := False;
-- Write-only. Writing 1 clears the corresponding bit in the INTENSET
-- register.
ABERRCLR : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
TXIDLECLR at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
DELTACTSCLR at 0 range 5 .. 5;
TXDISCLR at 0 range 6 .. 6;
Reserved_7_10 at 0 range 7 .. 10;
DELTARXBRKCLR at 0 range 11 .. 11;
STARTCLR at 0 range 12 .. 12;
FRAMERRCLR at 0 range 13 .. 13;
PARITYERRCLR at 0 range 14 .. 14;
RXNOISECLR at 0 range 15 .. 15;
ABERRCLR at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype BRG_BRGVAL_Field is HAL.UInt16;
-- Baud Rate Generator register. 16-bit integer baud rate divisor value.
type BRG_Register is record
-- This value is used to divide the USART input clock to determine the
-- baud rate, based on the input clock from the FRG. 0 = FCLK is used
-- directly by the USART function. 1 = FCLK is divided by 2 before use
-- by the USART function. 2 = FCLK is divided by 3 before use by the
-- USART function. 0xFFFF = FCLK is divided by 65,536 before use by the
-- USART function.
BRGVAL : BRG_BRGVAL_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BRG_Register use record
BRGVAL at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Interrupt status register. Reflects interrupts that are currently
-- enabled.
type INTSTAT_Register is record
-- unspecified
Reserved_0_2 : HAL.UInt3;
-- Read-only. Transmitter Idle status.
TXIDLE : Boolean;
-- unspecified
Reserved_4_4 : HAL.Bit;
-- Read-only. This bit is set when a change in the state of the CTS
-- input is detected.
DELTACTS : Boolean;
-- Read-only. Transmitter Disabled Interrupt flag.
TXDISINT : Boolean;
-- unspecified
Reserved_7_10 : HAL.UInt4;
-- Read-only. This bit is set when a change in the state of receiver
-- break detection occurs.
DELTARXBRK : Boolean;
-- Read-only. This bit is set when a start is detected on the receiver
-- input.
START : Boolean;
-- Read-only. Framing Error interrupt flag.
FRAMERRINT : Boolean;
-- Read-only. Parity Error interrupt flag.
PARITYERRINT : Boolean;
-- Read-only. Received Noise interrupt flag.
RXNOISEINT : Boolean;
-- Read-only. Auto baud Error Interrupt flag.
ABERRINT : Boolean;
-- unspecified
Reserved_17_31 : HAL.UInt15;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTSTAT_Register use record
Reserved_0_2 at 0 range 0 .. 2;
TXIDLE at 0 range 3 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
DELTACTS at 0 range 5 .. 5;
TXDISINT at 0 range 6 .. 6;
Reserved_7_10 at 0 range 7 .. 10;
DELTARXBRK at 0 range 11 .. 11;
START at 0 range 12 .. 12;
FRAMERRINT at 0 range 13 .. 13;
PARITYERRINT at 0 range 14 .. 14;
RXNOISEINT at 0 range 15 .. 15;
ABERRINT at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype OSR_OSRVAL_Field is HAL.UInt4;
-- Oversample selection register for asynchronous communication.
type OSR_Register is record
-- Oversample Selection Value. 0 to 3 = not supported 0x4 = 5 function
-- clocks are used to transmit and receive each data bit. 0x5 = 6
-- function clocks are used to transmit and receive each data bit. 0xF=
-- 16 function clocks are used to transmit and receive each data bit.
OSRVAL : OSR_OSRVAL_Field := 16#F#;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OSR_Register use record
OSRVAL at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype ADDR_ADDRESS_Field is HAL.UInt8;
-- Address register for automatic address matching.
type ADDR_Register is record
-- 8-bit address used with automatic address matching. Used when address
-- detection is enabled (ADDRDET in CTL = 1) and automatic address
-- matching is enabled (AUTOADDR in CFG = 1).
ADDRESS : ADDR_ADDRESS_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ADDR_Register use record
ADDRESS at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Enable the transmit FIFO.
type FIFOCFG_ENABLETX_Field is
(
-- The transmit FIFO is not enabled.
Disabled,
-- The transmit FIFO is enabled.
Enabled)
with Size => 1;
for FIFOCFG_ENABLETX_Field use
(Disabled => 0,
Enabled => 1);
-- Enable the receive FIFO.
type FIFOCFG_ENABLERX_Field is
(
-- The receive FIFO is not enabled.
Disabled,
-- The receive FIFO is enabled.
Enabled)
with Size => 1;
for FIFOCFG_ENABLERX_Field use
(Disabled => 0,
Enabled => 1);
subtype FIFOCFG_SIZE_Field is HAL.UInt2;
-- DMA configuration for transmit.
type FIFOCFG_DMATX_Field is
(
-- DMA is not used for the transmit function.
Disabled,
-- Trigger DMA for the transmit function if the FIFO is not full.
-- Generally, data interrupts would be disabled if DMA is enabled.
Enabled)
with Size => 1;
for FIFOCFG_DMATX_Field use
(Disabled => 0,
Enabled => 1);
-- DMA configuration for receive.
type FIFOCFG_DMARX_Field is
(
-- DMA is not used for the receive function.
Disabled,
-- Trigger DMA for the receive function if the FIFO is not empty.
-- Generally, data interrupts would be disabled if DMA is enabled.
Enabled)
with Size => 1;
for FIFOCFG_DMARX_Field use
(Disabled => 0,
Enabled => 1);
-- Wake-up for transmit FIFO level. This allows the device to be woken from
-- reduced power modes (up to power-down, as long as the peripheral
-- function works in that power mode) without enabling the TXLVL interrupt.
-- Only DMA wakes up, processes data, and goes back to sleep. The CPU will
-- remain stopped until woken by another cause, such as DMA completion. See
-- Hardware Wake-up control register.
type FIFOCFG_WAKETX_Field is
(
-- Only enabled interrupts will wake up the device form reduced power
-- modes.
Disabled,
-- A device wake-up for DMA will occur if the transmit FIFO level
-- reaches the value specified by TXLVL in FIFOTRIG, even when the TXLVL
-- interrupt is not enabled.
Enabled)
with Size => 1;
for FIFOCFG_WAKETX_Field use
(Disabled => 0,
Enabled => 1);
-- Wake-up for receive FIFO level. This allows the device to be woken from
-- reduced power modes (up to power-down, as long as the peripheral
-- function works in that power mode) without enabling the TXLVL interrupt.
-- Only DMA wakes up, processes data, and goes back to sleep. The CPU will
-- remain stopped until woken by another cause, such as DMA completion. See
-- Hardware Wake-up control register.
type FIFOCFG_WAKERX_Field is
(
-- Only enabled interrupts will wake up the device form reduced power
-- modes.
Disabled,
-- A device wake-up for DMA will occur if the receive FIFO level reaches
-- the value specified by RXLVL in FIFOTRIG, even when the RXLVL
-- interrupt is not enabled.
Enabled)
with Size => 1;
for FIFOCFG_WAKERX_Field use
(Disabled => 0,
Enabled => 1);
-- FIFO configuration and enable register.
type FIFOCFG_Register is record
-- Enable the transmit FIFO.
ENABLETX : FIFOCFG_ENABLETX_Field := NXP_SVD.USART.Disabled;
-- Enable the receive FIFO.
ENABLERX : FIFOCFG_ENABLERX_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Read-only. FIFO size configuration. This is a read-only field. 0x0 =
-- FIFO is configured as 16 entries of 8 bits. 0x1, 0x2, 0x3 = not
-- applicable to USART.
SIZE : FIFOCFG_SIZE_Field := 16#0#;
-- unspecified
Reserved_6_11 : HAL.UInt6 := 16#0#;
-- DMA configuration for transmit.
DMATX : FIFOCFG_DMATX_Field := NXP_SVD.USART.Disabled;
-- DMA configuration for receive.
DMARX : FIFOCFG_DMARX_Field := NXP_SVD.USART.Disabled;
-- Wake-up for transmit FIFO level. This allows the device to be woken
-- from reduced power modes (up to power-down, as long as the peripheral
-- function works in that power mode) without enabling the TXLVL
-- interrupt. Only DMA wakes up, processes data, and goes back to sleep.
-- The CPU will remain stopped until woken by another cause, such as DMA
-- completion. See Hardware Wake-up control register.
WAKETX : FIFOCFG_WAKETX_Field := NXP_SVD.USART.Disabled;
-- Wake-up for receive FIFO level. This allows the device to be woken
-- from reduced power modes (up to power-down, as long as the peripheral
-- function works in that power mode) without enabling the TXLVL
-- interrupt. Only DMA wakes up, processes data, and goes back to sleep.
-- The CPU will remain stopped until woken by another cause, such as DMA
-- completion. See Hardware Wake-up control register.
WAKERX : FIFOCFG_WAKERX_Field := NXP_SVD.USART.Disabled;
-- Empty command for the transmit FIFO. When a 1 is written to this bit,
-- the TX FIFO is emptied.
EMPTYTX : Boolean := False;
-- Empty command for the receive FIFO. When a 1 is written to this bit,
-- the RX FIFO is emptied.
EMPTYRX : Boolean := False;
-- unspecified
Reserved_18_31 : HAL.UInt14 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOCFG_Register use record
ENABLETX at 0 range 0 .. 0;
ENABLERX at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
SIZE at 0 range 4 .. 5;
Reserved_6_11 at 0 range 6 .. 11;
DMATX at 0 range 12 .. 12;
DMARX at 0 range 13 .. 13;
WAKETX at 0 range 14 .. 14;
WAKERX at 0 range 15 .. 15;
EMPTYTX at 0 range 16 .. 16;
EMPTYRX at 0 range 17 .. 17;
Reserved_18_31 at 0 range 18 .. 31;
end record;
subtype FIFOSTAT_TXLVL_Field is HAL.UInt5;
subtype FIFOSTAT_RXLVL_Field is HAL.UInt5;
-- FIFO status register.
type FIFOSTAT_Register is record
-- TX FIFO error. Will be set if a transmit FIFO error occurs. This
-- could be an overflow caused by pushing data into a full FIFO, or by
-- an underflow if the FIFO is empty when data is needed. Cleared by
-- writing a 1 to this bit.
TXERR : Boolean := False;
-- RX FIFO error. Will be set if a receive FIFO overflow occurs, caused
-- by software or DMA not emptying the FIFO fast enough. Cleared by
-- writing a 1 to this bit.
RXERR : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- Read-only. Peripheral interrupt. When 1, this indicates that the
-- peripheral function has asserted an interrupt. The details can be
-- found by reading the peripheral's STAT register.
PERINT : Boolean := False;
-- Read-only. Transmit FIFO empty. When 1, the transmit FIFO is empty.
-- The peripheral may still be processing the last piece of data.
TXEMPTY : Boolean := True;
-- Read-only. Transmit FIFO not full. When 1, the transmit FIFO is not
-- full, so more data can be written. When 0, the transmit FIFO is full
-- and another write would cause it to overflow.
TXNOTFULL : Boolean := True;
-- Read-only. Receive FIFO not empty. When 1, the receive FIFO is not
-- empty, so data can be read. When 0, the receive FIFO is empty.
RXNOTEMPTY : Boolean := False;
-- Read-only. Receive FIFO full. When 1, the receive FIFO is full. Data
-- needs to be read out to prevent the peripheral from causing an
-- overflow.
RXFULL : Boolean := False;
-- Read-only. Transmit FIFO current level. A 0 means the TX FIFO is
-- currently empty, and the TXEMPTY and TXNOTFULL flags will be 1. Other
-- values tell how much data is actually in the TX FIFO at the point
-- where the read occurs. If the TX FIFO is full, the TXEMPTY and
-- TXNOTFULL flags will be 0.
TXLVL : FIFOSTAT_TXLVL_Field := 16#0#;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- Read-only. Receive FIFO current level. A 0 means the RX FIFO is
-- currently empty, and the RXFULL and RXNOTEMPTY flags will be 0. Other
-- values tell how much data is actually in the RX FIFO at the point
-- where the read occurs. If the RX FIFO is full, the RXFULL and
-- RXNOTEMPTY flags will be 1.
RXLVL : FIFOSTAT_RXLVL_Field := 16#0#;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOSTAT_Register use record
TXERR at 0 range 0 .. 0;
RXERR at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
PERINT at 0 range 3 .. 3;
TXEMPTY at 0 range 4 .. 4;
TXNOTFULL at 0 range 5 .. 5;
RXNOTEMPTY at 0 range 6 .. 6;
RXFULL at 0 range 7 .. 7;
TXLVL at 0 range 8 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
RXLVL at 0 range 16 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- Transmit FIFO level trigger enable. This trigger will become an
-- interrupt if enabled in FIFOINTENSET, or a DMA trigger if DMATX in
-- FIFOCFG is set.
type FIFOTRIG_TXLVLENA_Field is
(
-- Transmit FIFO level does not generate a FIFO level trigger.
Disabled,
-- An trigger will be generated if the transmit FIFO level reaches the
-- value specified by the TXLVL field in this register.
Enabled)
with Size => 1;
for FIFOTRIG_TXLVLENA_Field use
(Disabled => 0,
Enabled => 1);
-- Receive FIFO level trigger enable. This trigger will become an interrupt
-- if enabled in FIFOINTENSET, or a DMA trigger if DMARX in FIFOCFG is set.
type FIFOTRIG_RXLVLENA_Field is
(
-- Receive FIFO level does not generate a FIFO level trigger.
Disabled,
-- An trigger will be generated if the receive FIFO level reaches the
-- value specified by the RXLVL field in this register.
Enabled)
with Size => 1;
for FIFOTRIG_RXLVLENA_Field use
(Disabled => 0,
Enabled => 1);
subtype FIFOTRIG_TXLVL_Field is HAL.UInt4;
subtype FIFOTRIG_RXLVL_Field is HAL.UInt4;
-- FIFO trigger settings for interrupt and DMA request.
type FIFOTRIG_Register is record
-- Transmit FIFO level trigger enable. This trigger will become an
-- interrupt if enabled in FIFOINTENSET, or a DMA trigger if DMATX in
-- FIFOCFG is set.
TXLVLENA : FIFOTRIG_TXLVLENA_Field := NXP_SVD.USART.Disabled;
-- Receive FIFO level trigger enable. This trigger will become an
-- interrupt if enabled in FIFOINTENSET, or a DMA trigger if DMARX in
-- FIFOCFG is set.
RXLVLENA : FIFOTRIG_RXLVLENA_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- Transmit FIFO level trigger point. This field is used only when
-- TXLVLENA = 1. If enabled to do so, the FIFO level can wake up the
-- device just enough to perform DMA, then return to the reduced power
-- mode. See Hardware Wake-up control register. 0 = trigger when the TX
-- FIFO becomes empty. 1 = trigger when the TX FIFO level decreases to
-- one entry. 15 = trigger when the TX FIFO level decreases to 15
-- entries (is no longer full).
TXLVL : FIFOTRIG_TXLVL_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- Receive FIFO level trigger point. The RX FIFO level is checked when a
-- new piece of data is received. This field is used only when RXLVLENA
-- = 1. If enabled to do so, the FIFO level can wake up the device just
-- enough to perform DMA, then return to the reduced power mode. See
-- Hardware Wake-up control register. 0 = trigger when the RX FIFO has
-- received one entry (is no longer empty). 1 = trigger when the RX FIFO
-- has received two entries. 15 = trigger when the RX FIFO has received
-- 16 entries (has become full).
RXLVL : FIFOTRIG_RXLVL_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOTRIG_Register use record
TXLVLENA at 0 range 0 .. 0;
RXLVLENA at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
TXLVL at 0 range 8 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
RXLVL at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Determines whether an interrupt occurs when a transmit error occurs,
-- based on the TXERR flag in the FIFOSTAT register.
type FIFOINTENSET_TXERR_Field is
(
-- No interrupt will be generated for a transmit error.
Disabled,
-- An interrupt will be generated when a transmit error occurs.
Enabled)
with Size => 1;
for FIFOINTENSET_TXERR_Field use
(Disabled => 0,
Enabled => 1);
-- Determines whether an interrupt occurs when a receive error occurs,
-- based on the RXERR flag in the FIFOSTAT register.
type FIFOINTENSET_RXERR_Field is
(
-- No interrupt will be generated for a receive error.
Disabled,
-- An interrupt will be generated when a receive error occurs.
Enabled)
with Size => 1;
for FIFOINTENSET_RXERR_Field use
(Disabled => 0,
Enabled => 1);
-- Determines whether an interrupt occurs when a the transmit FIFO reaches
-- the level specified by the TXLVL field in the FIFOTRIG register.
type FIFOINTENSET_TXLVL_Field is
(
-- No interrupt will be generated based on the TX FIFO level.
Disabled,
-- If TXLVLENA in the FIFOTRIG register = 1, an interrupt will be
-- generated when the TX FIFO level decreases to the level specified by
-- TXLVL in the FIFOTRIG register.
Enabled)
with Size => 1;
for FIFOINTENSET_TXLVL_Field use
(Disabled => 0,
Enabled => 1);
-- Determines whether an interrupt occurs when a the receive FIFO reaches
-- the level specified by the TXLVL field in the FIFOTRIG register.
type FIFOINTENSET_RXLVL_Field is
(
-- No interrupt will be generated based on the RX FIFO level.
Disabled,
-- If RXLVLENA in the FIFOTRIG register = 1, an interrupt will be
-- generated when the when the RX FIFO level increases to the level
-- specified by RXLVL in the FIFOTRIG register.
Enabled)
with Size => 1;
for FIFOINTENSET_RXLVL_Field use
(Disabled => 0,
Enabled => 1);
-- FIFO interrupt enable set (enable) and read register.
type FIFOINTENSET_Register is record
-- Determines whether an interrupt occurs when a transmit error occurs,
-- based on the TXERR flag in the FIFOSTAT register.
TXERR : FIFOINTENSET_TXERR_Field := NXP_SVD.USART.Disabled;
-- Determines whether an interrupt occurs when a receive error occurs,
-- based on the RXERR flag in the FIFOSTAT register.
RXERR : FIFOINTENSET_RXERR_Field := NXP_SVD.USART.Disabled;
-- Determines whether an interrupt occurs when a the transmit FIFO
-- reaches the level specified by the TXLVL field in the FIFOTRIG
-- register.
TXLVL : FIFOINTENSET_TXLVL_Field := NXP_SVD.USART.Disabled;
-- Determines whether an interrupt occurs when a the receive FIFO
-- reaches the level specified by the TXLVL field in the FIFOTRIG
-- register.
RXLVL : FIFOINTENSET_RXLVL_Field := NXP_SVD.USART.Disabled;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOINTENSET_Register use record
TXERR at 0 range 0 .. 0;
RXERR at 0 range 1 .. 1;
TXLVL at 0 range 2 .. 2;
RXLVL at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- FIFO interrupt enable clear (disable) and read register.
type FIFOINTENCLR_Register is record
-- Writing one clears the corresponding bits in the FIFOINTENSET
-- register.
TXERR : Boolean := False;
-- Writing one clears the corresponding bits in the FIFOINTENSET
-- register.
RXERR : Boolean := False;
-- Writing one clears the corresponding bits in the FIFOINTENSET
-- register.
TXLVL : Boolean := False;
-- Writing one clears the corresponding bits in the FIFOINTENSET
-- register.
RXLVL : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOINTENCLR_Register use record
TXERR at 0 range 0 .. 0;
RXERR at 0 range 1 .. 1;
TXLVL at 0 range 2 .. 2;
RXLVL at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- FIFO interrupt status register.
type FIFOINTSTAT_Register is record
-- Read-only. TX FIFO error.
TXERR : Boolean;
-- Read-only. RX FIFO error.
RXERR : Boolean;
-- Read-only. Transmit FIFO level interrupt.
TXLVL : Boolean;
-- Read-only. Receive FIFO level interrupt.
RXLVL : Boolean;
-- Read-only. Peripheral interrupt.
PERINT : Boolean;
-- unspecified
Reserved_5_31 : HAL.UInt27;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOINTSTAT_Register use record
TXERR at 0 range 0 .. 0;
RXERR at 0 range 1 .. 1;
TXLVL at 0 range 2 .. 2;
RXLVL at 0 range 3 .. 3;
PERINT at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype FIFOWR_TXDATA_Field is HAL.UInt9;
-- FIFO write data.
type FIFOWR_Register is record
-- Write-only. Transmit data to the FIFO.
TXDATA : FIFOWR_TXDATA_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFOWR_Register use record
TXDATA at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype FIFORD_RXDATA_Field is HAL.UInt9;
-- FIFO read data.
type FIFORD_Register is record
-- Read-only. Received data from the FIFO. The number of bits used
-- depends on the DATALEN and PARITYSEL settings.
RXDATA : FIFORD_RXDATA_Field;
-- unspecified
Reserved_9_12 : HAL.UInt4;
-- Read-only. Framing Error status flag. This bit reflects the status
-- for the data it is read along with from the FIFO, and indicates that
-- the character was received with a missing stop bit at the expected
-- location. This could be an indication of a baud rate or configuration
-- mismatch with the transmitting source.
FRAMERR : Boolean;
-- Read-only. Parity Error status flag. This bit reflects the status for
-- the data it is read along with from the FIFO. This bit will be set
-- when a parity error is detected in a received character.
PARITYERR : Boolean;
-- Read-only. Received Noise flag. See description of the RxNoiseInt bit
-- in Table 354.
RXNOISE : Boolean;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFORD_Register use record
RXDATA at 0 range 0 .. 8;
Reserved_9_12 at 0 range 9 .. 12;
FRAMERR at 0 range 13 .. 13;
PARITYERR at 0 range 14 .. 14;
RXNOISE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FIFORDNOPOP_RXDATA_Field is HAL.UInt9;
-- FIFO data read with no FIFO pop.
type FIFORDNOPOP_Register is record
-- Read-only. Received data from the FIFO. The number of bits used
-- depends on the DATALEN and PARITYSEL settings.
RXDATA : FIFORDNOPOP_RXDATA_Field;
-- unspecified
Reserved_9_12 : HAL.UInt4;
-- Read-only. Framing Error status flag. This bit reflects the status
-- for the data it is read along with from the FIFO, and indicates that
-- the character was received with a missing stop bit at the expected
-- location. This could be an indication of a baud rate or configuration
-- mismatch with the transmitting source.
FRAMERR : Boolean;
-- Read-only. Parity Error status flag. This bit reflects the status for
-- the data it is read along with from the FIFO. This bit will be set
-- when a parity error is detected in a received character.
PARITYERR : Boolean;
-- Read-only. Received Noise flag. See description of the RxNoiseInt bit
-- in Table 354.
RXNOISE : Boolean;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FIFORDNOPOP_Register use record
RXDATA at 0 range 0 .. 8;
Reserved_9_12 at 0 range 9 .. 12;
FRAMERR at 0 range 13 .. 13;
PARITYERR at 0 range 14 .. 14;
RXNOISE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype ID_APERTURE_Field is HAL.UInt8;
subtype ID_MINOR_REV_Field is HAL.UInt4;
subtype ID_MAJOR_REV_Field is HAL.UInt4;
subtype ID_ID_Field is HAL.UInt16;
-- Peripheral identification register.
type ID_Register is record
-- Read-only. Aperture: encoded as (aperture size/4K) -1, so 0x00 means
-- a 4K aperture.
APERTURE : ID_APERTURE_Field;
-- Read-only. Minor revision of module implementation.
MINOR_REV : ID_MINOR_REV_Field;
-- Read-only. Major revision of module implementation.
MAJOR_REV : ID_MAJOR_REV_Field;
-- Read-only. Module identifier for the selected function.
ID : ID_ID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ID_Register use record
APERTURE at 0 range 0 .. 7;
MINOR_REV at 0 range 8 .. 11;
MAJOR_REV at 0 range 12 .. 15;
ID at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- USARTs
type USART_Peripheral is record
-- USART Configuration register. Basic USART configuration settings that
-- typically are not changed during operation.
CFG : aliased CFG_Register;
-- USART Control register. USART control settings that are more likely
-- to change during operation.
CTL : aliased CTL_Register;
-- USART Status register. The complete status value can be read here.
-- Writing ones clears some bits in the register. Some bits can be
-- cleared by writing a 1 to them.
STAT : aliased STAT_Register;
-- Interrupt Enable read and Set register for USART (not FIFO) status.
-- Contains individual interrupt enable bits for each potential USART
-- interrupt. A complete value may be read from this register. Writing a
-- 1 to any implemented bit position causes that bit to be set.
INTENSET : aliased INTENSET_Register;
-- Interrupt Enable Clear register. Allows clearing any combination of
-- bits in the INTENSET register. Writing a 1 to any implemented bit
-- position causes the corresponding bit to be cleared.
INTENCLR : aliased INTENCLR_Register;
-- Baud Rate Generator register. 16-bit integer baud rate divisor value.
BRG : aliased BRG_Register;
-- Interrupt status register. Reflects interrupts that are currently
-- enabled.
INTSTAT : aliased INTSTAT_Register;
-- Oversample selection register for asynchronous communication.
OSR : aliased OSR_Register;
-- Address register for automatic address matching.
ADDR : aliased ADDR_Register;
-- FIFO configuration and enable register.
FIFOCFG : aliased FIFOCFG_Register;
-- FIFO status register.
FIFOSTAT : aliased FIFOSTAT_Register;
-- FIFO trigger settings for interrupt and DMA request.
FIFOTRIG : aliased FIFOTRIG_Register;
-- FIFO interrupt enable set (enable) and read register.
FIFOINTENSET : aliased FIFOINTENSET_Register;
-- FIFO interrupt enable clear (disable) and read register.
FIFOINTENCLR : aliased FIFOINTENCLR_Register;
-- FIFO interrupt status register.
FIFOINTSTAT : aliased FIFOINTSTAT_Register;
-- FIFO write data.
FIFOWR : aliased FIFOWR_Register;
-- FIFO read data.
FIFORD : aliased FIFORD_Register;
-- FIFO data read with no FIFO pop.
FIFORDNOPOP : aliased FIFORDNOPOP_Register;
-- Peripheral identification register.
ID : aliased ID_Register;
end record
with Volatile;
for USART_Peripheral use record
CFG at 16#0# range 0 .. 31;
CTL at 16#4# range 0 .. 31;
STAT at 16#8# range 0 .. 31;
INTENSET at 16#C# range 0 .. 31;
INTENCLR at 16#10# range 0 .. 31;
BRG at 16#20# range 0 .. 31;
INTSTAT at 16#24# range 0 .. 31;
OSR at 16#28# range 0 .. 31;
ADDR at 16#2C# range 0 .. 31;
FIFOCFG at 16#E00# range 0 .. 31;
FIFOSTAT at 16#E04# range 0 .. 31;
FIFOTRIG at 16#E08# range 0 .. 31;
FIFOINTENSET at 16#E10# range 0 .. 31;
FIFOINTENCLR at 16#E14# range 0 .. 31;
FIFOINTSTAT at 16#E18# range 0 .. 31;
FIFOWR at 16#E20# range 0 .. 31;
FIFORD at 16#E30# range 0 .. 31;
FIFORDNOPOP at 16#E40# range 0 .. 31;
ID at 16#FFC# range 0 .. 31;
end record;
-- USARTs
USART0_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40086000#);
-- USARTs
USART1_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40087000#);
-- USARTs
USART2_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40088000#);
-- USARTs
USART3_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40089000#);
-- USARTs
USART4_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#4008A000#);
-- USARTs
USART5_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40096000#);
-- USARTs
USART6_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40097000#);
-- USARTs
USART7_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40098000#);
end NXP_SVD.USART;
|
with Tipos_Tarea; use Tipos_Tarea;
procedure Crea_Tarea_De_Tipo is
T1 : Tarea_Repetitiva(1);
T2 : Tarea_Repetitiva(2);
T3 : Tarea_Repetitiva(3);
type Tarea_Ptr is access Tarea_Repetitiva;
T : Tarea_Ptr;
begin
T := new Tarea_Repetitiva(4);
end Crea_Tarea_De_Tipo;
|
-- pragma SPARK_Mode;
with Wire; use Wire;
package body Zumo_L3gd20h is
Chip_Addr : constant := 2#0110_1011#;
Chip_ID : constant := 2#1101_0111#;
procedure Check_WHOAMI
is
ID : Byte;
begin
ID := Wire.Read_Byte (Addr => Chip_Addr,
Reg => Regs (WHO_AM_I));
if ID /= Chip_ID then
raise L3GD20H_Exception;
end if;
end Check_WHOAMI;
procedure Init
is
Init_Seq : constant Byte_Array := (Regs (CTRL1), 2#1001_1111#,
Regs (CTRL2), 2#0000_0000#,
Regs (CTRL3), 2#0000_0000#,
Regs (CTRL4), 2#0011_0000#,
Regs (CTRL5), 2#0000_0000#,
Regs (LOW_ODR), 2#0000_0001#);
Status : Wire.Transmission_Status_Index;
Index : Byte := Init_Seq'First;
begin
Check_WHOAMI;
while Index <= Init_Seq'Last loop
Status := Wire.Write_Byte (Addr => Chip_Addr,
Reg => Init_Seq (Index),
Data => Init_Seq (Index + 1));
if Status /= Wire.Success then
raise L3GD20H_Exception;
end if;
Index := Index + 2;
end loop;
Initd := True;
end Init;
function Read_Temp return signed_char
is
BB : Byte := 0;
Ret_Val : signed_char
with Address => BB'Address;
begin
BB := Wire.Read_Byte (Addr => Chip_Addr,
Reg => Regs (OUT_TEMP));
return Ret_Val;
end Read_Temp;
function Read_Status return Byte
is
begin
return Wire.Read_Byte (Addr => Chip_Addr,
Reg => Regs (STATUS));
end Read_Status;
procedure Read_Gyro (Data : out Axis_Data)
is
Raw_Arr : Byte_Array (1 .. Data'Length * 2)
with Address => Data'Address;
begin
Wire.Read_Bytes (Addr => Chip_Addr,
Reg => Regs (OUT_X_L),
Data => Raw_Arr);
end Read_Gyro;
end Zumo_L3gd20h;
|
pragma Ada_2012;
with Ada.Containers;
with Protypo.Api.Engine_Values.Constant_Wrappers;
with Protypo.Api.Engine_Values.Range_Iterators;
with Protypo.Api.Field_Names;
pragma Warnings (Off, "no entities of ""Ada.Text_IO"" are referenced");
with Ada.Text_Io; use Ada.Text_Io;
package body Protypo.Api.Engine_Values.Engine_Value_Array_Wrappers is
-- Type that represents the name of the fields that we export
-- every name is preceded by "Field_" in order to avoid clashes
-- with keywords (e.g., 'range')
type Field_Name is
(
Field_First,
Field_Last,
Field_Range,
Field_Iterate,
Field_Length
);
package Field_Names_Package is
new Field_Names (Field_Enumerator => Field_Name,
Prefix => "Field_");
function To_Field (X : Id) return Field_Name
is (Field_Names_Package.To_Field (X));
-- function To_Field (X : String) return Field_Name
-- is (Field_Name'Value ("Field_" & X));
type Array_Iterator is
new Handlers.Iterator_Interface
with
record
Cursor : Engine_Value_Vectors.Cursor;
First : Engine_Value_Vectors.Cursor;
-- Container : Vector_Access;
end record;
--
-- function Force_Handler (Item : Engine_Value) return Handler_Value
-- is (case Item.Class is
-- when Handler_Classes =>
-- Item,
--
-- when Int =>
-- Constant_Wrappers.To_Handler_Value (Get_Integer (Item)),
--
-- when Real =>
-- Constant_Wrappers.To_Handler_Value (Get_Float (Item)),
--
-- when Text =>
-- Constant_Wrappers.To_Handler_Value (Get_String (Item)),
--
-- when logical =>
-- Constant_Wrappers.To_Handler_Value (Get_Logical (Item)),
--
-- when Void | Iterator =>
-- raise Constraint_Error);
overriding procedure Reset (Iter : in out Array_Iterator);
overriding procedure Next (Iter : in out Array_Iterator);
overriding function End_Of_Iteration (Iter : Array_Iterator) return Boolean;
overriding function Element (Iter : Array_Iterator) return Handler_Value;
overriding procedure Reset (Iter : in out Array_Iterator)
is
begin
Iter.Cursor := Iter.First;
end Reset;
overriding procedure Next (Iter : in out Array_Iterator)
is
begin
Engine_Value_Vectors.Next (Iter.Cursor);
end Next;
overriding function End_Of_Iteration (Iter : Array_Iterator) return Boolean
is (not Engine_Value_Vectors.Has_Element (Iter.Cursor));
overriding function Element (Iter : Array_Iterator) return Handler_Value
is (Handlers.Force_Handler (Engine_Value_Vectors.Element (Iter.Cursor)));
------------------
-- Make_Wrapper --
------------------
function Make_Wrapper
(Init : Engine_Value_Vectors.Vector := Engine_Value_Vectors.Empty_Vector)
return Array_Wrapper_Access
is
-- V : constant Vector_Access :=
-- new Engine_Value_Vectors.Vector'(Engine_Value_Vectors.Empty_Vector);
Result : constant Array_Wrapper_Access :=
new Array_Wrapper'(Vector => Engine_Value_Vectors.Empty_Vector);
begin
for El of Init loop
Result.Vector.Append (El);
end loop;
return Result;
end Make_Wrapper;
function Make_Wrapper
(Init : Engine_Value_Vectors.Vector := Engine_Value_Vectors.Empty_Vector)
return Handlers.Ambivalent_Interface_Access
is
Tmp : constant Array_Wrapper_Access := Make_Wrapper (Init);
begin
return Handlers.Ambivalent_Interface_Access (Tmp);
end Make_Wrapper;
---------
-- Set --
---------
procedure Set
(Container : in out Array_Wrapper;
Index : Array_Wrapper_Index;
Value : Engine_Value)
is
begin
Container.Vector.Insert (Index, Value);
end Set;
------------
-- Append --
------------
procedure Append (Container : in out Array_Wrapper;
Item : Engine_Value)
is
begin
Container.Vector.Append (Item);
end Append;
---------
-- Get --
---------
function Get
(X : Array_Wrapper; Index : Engine_Value_Vectors.Vector) return Handler_Value
is
use type Ada.Containers.Count_Type;
begin
if Index.Length /= 1 then
raise Handlers.Out_Of_Range with "Array access with /= 1 index";
end if;
if Index.First_Element.Class /= Int then
raise Handlers.Out_Of_Range with "Array access with non-integer index";
end if;
declare
Idx : constant Integer := Get_Integer (Index.First_Element);
begin
if Idx < X.Vector.First_Index or Idx > X.Vector.Last_Index then
raise Handlers.Out_Of_Range with "Out of bounds index";
end if;
return Constant_Wrappers.To_Handler_Value (X.Vector (Idx));
end;
end Get;
---------
-- Get --
---------
function Get (X : Array_Wrapper; Field : Id) return Handler_Value is
use Constant_Wrappers;
begin
case To_Field (Field) is
when Field_First =>
return To_Handler_Value (X.Vector.First_Index);
when Field_Last =>
return To_Handler_Value (X.Vector.Last_Index);
when Field_Length =>
return To_Handler_Value (Integer (X.Vector.Length));
when Field_Iterate =>
return To_Handler_Value
(Handlers.Create
(Handlers.Iterator_Interface_Access'
(new Array_Iterator'(Cursor => X.Vector.First,
First => X.Vector.First))));
when Field_Range =>
return To_Handler_Value
(Handlers.Create
(Range_Iterators.Create (Start => X.Vector.First_Index,
Stop => X.Vector.Last_Index)));
end case;
end Get;
function Is_Field (X : Array_Wrapper; Field : Id) return Boolean
is (Field_Names_Package.Is_Field (Field));
-- --------------
-- -- Is_Field --
-- --------------
--
-- function Is_Field (X : Array_Wrapper; Field : Id) return Boolean
-- is
-- pragma Unreferenced (X);
-- Ignored : Field_Name;
-- begin
-- Ignored := To_Field (Field);
-- return True;
-- -- Yes, I know, it is not the best practice to use exceptions
-- -- to do flow control, but this is the easiest way
-- exception
-- when Constraint_Error =>
-- return False;
-- end Is_Field;
-- -- return Equal_Case_Insensitive (Field, "first")
-- or Equal_Case_Insensitive (Field, "last")
-- or Equal_Case_Insensitive (Field, "length")
-- or Equal_Case_Insensitive (Field, "iterate")
-- or Equal_Case_Insensitive (Field, "range");
end Protypo.Api.Engine_Values.Engine_Value_Array_Wrappers;
|
with Greetings;
procedure Gmain is
begin
Greetings.Hello;
Greetings.Middle;
Greetings.Goodbye;
end Gmain;
|
with Lumen.Image;
package Mandelbrot is
function Create_Image (Width, Height : Natural) return Lumen.Image.Descriptor;
end Mandelbrot;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Numerics.MT19937;
package Vampire.Villages.Teaming is
type Role_Set is array (Person_Role) of Natural;
type Role_Set_Array is array (Positive range <>) of Role_Set;
function Possibilities (
People_Count : Ada.Containers.Count_Type;
Male_And_Female : Boolean;
Execution : Execution_Mode;
Formation : Formation_Mode;
Unfortunate : Unfortunate_Mode;
Monster_Side : Monster_Side_Mode)
return Role_Set_Array;
function Select_Set (
Sets : Role_Set_Array;
Appearance : Role_Appearances;
Generator : aliased in out Ada.Numerics.MT19937.Generator)
return Role_Set;
procedure Shuffle (
People : in out Villages.People.Vector;
Victim : access Villages.Person_Role;
Set : Role_Set;
Generator : aliased in out Ada.Numerics.MT19937.Generator);
end Vampire.Villages.Teaming;
|
package body Discr10 is
function Get (X : R) return R is
begin
return R'(D1 => False, D2 => False, D3 => X.D3);
end;
end Discr10;
|
pragma License (Unrestricted);
with Ada.Characters.Conversions;
with Ada.Strings.Generic_Hash;
function Ada.Strings.Wide_Hash is
new Generic_Hash (Wide_Character, Wide_String, Characters.Conversions.Get);
pragma Pure (Ada.Strings.Wide_Hash);
|
package openGL.Model.sphere
--
-- Provides an abstract model of a sphere.
--
is
type Item is abstract new Model.item with
record
null;
end record;
type View is access all Item'Class;
--------------
--- Attributes
--
overriding
function Bounds (Self : in Item) return openGL.Bounds;
end openGL.Model.sphere;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
package Discr_Private is
package Dec is
type T_DECIMAL (Prec : Integer := 1) is private;
private
type T_DECIMAL (Prec : Integer := 1) is record
case Prec is
when 1 .. 2 => Value : Integer;
when others => null;
end case;
end record;
end;
type Value_T is record
Bits : Dec.T_DECIMAL(1);
end record;
for Value_T'size use 88;
type Value_Entry_T is record
Index : Integer;
Value : Value_T;
end record;
type Value_Mode is (QI, HI, SI, DI, XI);
for Value_Mode'size use 8;
type Valid_Modes_T is array (Value_Mode) of Boolean;
type Register_T is record
Ventry : Value_Entry_T;
Vmodes : Valid_Modes_T;
end record;
type Regid_T is (Latch, Acc);
for Regid_T use (Latch => 0, Acc => 2);
for Regid_T'Size use 8;
type Regarray_T is array (Regid_T) of Register_T;
type Machine_T (Up : Boolean := True) is record
case Up is
when True => Regs : Regarray_T;
when False => null;
end case;
end record;
end Discr_Private;
|
------------------------------------------------------------------------------
-- --
-- Giza --
-- --
-- Copyright (C) 2016 Fabien Chouteau (chouteau@adacore.com) --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
package body Giza.Types is
------------
-- Center --
------------
function Center (R : Rect_T) return Point_T is
begin
return (R.Org.X + R.Size.W / 2, R.Org.Y + R.Size.H / 2);
end Center;
------------------
-- Intersection --
------------------
function Intersection (A, B : Rect_T) return Rect_T is
P1 : constant Point_T := A.Org;
P2 : constant Point_T := A.Org + A.Size;
P3 : constant Point_T := B.Org;
P4 : constant Point_T := B.Org + B.Size;
Ret1, Ret2 : Point_T;
H, W : Natural;
begin
Ret1.X := Dim'Max (P1.X, P3.X);
Ret1.Y := Dim'Max (P1.Y, P3.Y);
Ret2.X := Dim'Min (P2.X, P4.X);
Ret2.Y := Dim'Min (P2.Y, P4.Y);
if Ret2.X - Ret1.X < 0 then
W := 0;
else
W := Ret2.X - Ret1.X;
end if;
if Ret2.Y - Ret1.Y < 0 then
H := 0;
else
H := Ret2.Y - Ret1.Y;
end if;
return (Ret1, (W, H));
end Intersection;
---------
-- "*" --
---------
function "*" (A, B : HC_Matrix) return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := A.V11 * B.V11 + A.V12 * B.V21 + A.V13 * B.V31;
Res.V12 := A.V11 * B.V12 + A.V12 * B.V22 + A.V13 * B.V32;
Res.V13 := A.V11 * B.V13 + A.V12 * B.V23 + A.V13 * B.V33;
Res.V21 := A.V21 * B.V11 + A.V22 * B.V21 + A.V23 * B.V31;
Res.V22 := A.V21 * B.V12 + A.V22 * B.V22 + A.V23 * B.V32;
Res.V23 := A.V21 * B.V13 + A.V22 * B.V23 + A.V23 * B.V33;
Res.V31 := A.V31 * B.V11 + A.V32 * B.V21 + A.V33 * B.V31;
Res.V32 := A.V31 * B.V12 + A.V32 * B.V22 + A.V33 * B.V32;
Res.V33 := A.V31 * B.V13 + A.V32 * B.V23 + A.V33 * B.V33;
return Res;
end "*";
---------
-- "*" --
---------
function "*" (A : HC_Matrix; B : Point_T) return Point_T is
Res : Point_T;
begin
Res.X := Dim (Float (B.X) * A.V11 + Float (B.Y) * A.V12 + 1.0 * A.V13);
Res.Y := Dim (Float (B.X) * A.V21 + Float (B.Y) * A.V22 + 1.0 * A.V23);
return Res;
end "*";
--------
-- Id --
--------
function Id return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := 1.0;
Res.V22 := 1.0;
Res.V33 := 1.0;
return Res;
end Id;
---------------------
-- Rotation_Matrix --
---------------------
function Rotation_Matrix (Rad : Float) return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := Cos (Rad);
Res.V12 := -Sin (Rad);
Res.V21 := Sin (Rad);
Res.V22 := Cos (Rad);
Res.V33 := 1.0;
return Res;
end Rotation_Matrix;
------------------------
-- Translation_Matrix --
------------------------
function Translation_Matrix (Pt : Point_T) return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := 1.0;
Res.V22 := 1.0;
Res.V33 := 1.0;
Res.V13 := Float (Pt.X);
Res.V23 := Float (Pt.Y);
return Res;
end Translation_Matrix;
------------------
-- Scale_Matrix --
------------------
function Scale_Matrix (Scale : Float) return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := Scale;
Res.V22 := Scale;
Res.V33 := 1.0;
return Res;
end Scale_Matrix;
------------------
-- Scale_Matrix --
------------------
function Scale_Matrix (X, Y : Float) return HC_Matrix is
Res : HC_Matrix;
begin
Res.V11 := X;
Res.V22 := Y;
Res.V33 := 1.0;
return Res;
end Scale_Matrix;
end Giza.Types;
|
pragma Initialize_Scalars;
with Ada.Text_IO; use Ada.Text_IO;
procedure Invalid_Value is
type Color is (Red, Green, Blue);
X : Float;
Y : Color;
begin
if not X'Valid then
Put_Line ("X is not valid");
end if;
X := 1.0;
if X'Valid then
Put_Line ("X is" & Float'Image (X));
end if;
if not Y'Valid then
Put_Line ("Y is not valid");
end if;
Y := Green;
if Y'Valid then
Put_Line ("Y is " & Color'Image (Y));
end if;
end Invalid_Value;
|
with STM32GD.Board;
with STM32GD.Clock;
with STM32GD.Clock.Tree;
with STM32GD.Clock.Timer;
with STM32GD.RTC;
procedure Main is
package Board renames STM32GD.Board;
package Clock renames STM32GD.Clock;
package Delay_Timer is new STM32GD.Clock.Timer (Clock_Tree => Board.CLOCKS, Input => Clock.SYSCLK);
package RTC is new STM32GD.RTC (Clock_Tree => Board.CLOCKS, Clock => Clock.LSI);
begin
Board.Init;
RTC.Init;
loop
Board.LED.Toggle;
Delay_Timer.Delay_s (1);
end loop;
end Main;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with GLOBE_3D;
with Real_Type; use Real_Type;
with Rotations; use Rotations;
with Vectors_2D_N; use Vectors_2D_N;
with Vectors_3D; use Vectors_3D;
package Graphics_Structures is
type RGB is (Red, Green, Blue);
type RGBA is (Red, Green, Blue, Alpha);
subtype Colour_Component_Range is Real range 0.0 .. 1.0;
type RGB_Colour is array (RGB) of Colour_Component_Range;
type RGBA_Colour is array (RGBA) of Colour_Component_Range;
subtype Shininess_Range is Real range 0.0 .. 128.0;
type Materials is record
Ambient,
Diffuse,
Specular,
Emission : RGBA_Colour;
Shininess : Shininess_Range;
end record;
subtype Point_3D is Vector_3D;
type Points_3D is array (Positive range <>) of Point_3D;
type Line_3D is array (Positive range 1 .. 2) of Point_3D;
type Camera is tagged
record
Position,
Scene_Offset,
Object_Offset : Vector_3D;
Rotation : Quaternion_Rotation;
end record;
subtype Point_2D is Vector_2D_N;
subtype Size_2D is Vector_2D_N;
type Points_2D is array (Positive range <>) of Point_2D;
type Line_2D is array (Positive range 1 .. 2) of Point_2D;
type Camera_Mode_T is (Scene, Chase);
type Lights_T is array (Positive range <>) of GLOBE_3D.Light_definition;
-- private
--
-- type RGB_Colour_F is array (RGB) of GL.Float;
-- type RGB_Colour_D is array (RGB) of GL.Double;
-- type RGBA_Colour_F is array (RGBA) of GL.Float;
-- type RGBA_Colour_D is array (RGBA) of GL.Double;
--
-- subtype Shininess_Range_F is GL.Float range 0.0 .. 128.0;
--
-- type Materials_F is record
-- Ambient,
-- Diffuse,
-- Specular,
-- Emission : RGBA_Colour_F;
-- Shininess : Shininess_Range_F;
-- end record;
end Graphics_Structures;
|
-----------------------------------------------------------------------
-- are-generator-ada2012-tests -- Tests for Ada generator
-- Copyright (C) 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Util.Test_Caller;
package body Are.Generator.Ada2012.Tests is
Expect_Dir : constant String := "regtests/expect/ada/";
function Tool return String;
package Caller is new Util.Test_Caller (Test, "Are.Generator.Ada");
function Tool return String is
begin
return "bin/are" & Are.Testsuite.EXE;
end Tool;
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Are.To_Ada_Name",
Test_Ada_Names'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada1",
Test_Generate_Ada1'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada2",
Test_Generate_Ada2'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada3",
Test_Generate_Ada3'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada4",
Test_Generate_Ada4'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada5",
Test_Generate_Ada5'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada6",
Test_Generate_Ada6'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada7",
Test_Generate_Ada7'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Ada8",
Test_Generate_Ada8'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Merge",
Test_Generate_Merge'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Concat",
Test_Generate_Concat'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Bundle",
Test_Generate_Bundle'Access);
Caller.Add_Test (Suite, "Test Are.Generate_Lines",
Test_Generate_Lines'Access);
end Add_Tests;
procedure Test_Generate_Ada1 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-1/web";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir
& " --name-access --content-only --resource=Resources1 --fileset '**/*' "
& Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources1.ads")),
"Resource file 'resources1.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources1.adb")),
"Resource file 'resources1.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-1/test1.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test1" & Are.Testsuite.EXE),
"Binary file 'bin/test1' not created");
T.Execute ("bin/test1" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: body { background: #eee; }"
& "p { color: #2a2a2a; }",
Result,
"Invalid generation");
end Test_Generate_Ada1;
procedure Test_Generate_Ada2 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-2";
Rule : constant String := "regtests/files/test-ada-2/package.xml";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --name-access --content-only --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources2.ads")),
"Resource file 'resources2.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources2.adb")),
"Resource file 'resources2.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-2/test2.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test2" & Are.Testsuite.EXE),
"Binary file 'bin/test2' not created");
T.Execute ("bin/test2" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS", Result,
"Invalid generation");
end Test_Generate_Ada2;
procedure Test_Generate_Ada3 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-3";
Rule : constant String := "regtests/files/test-ada-3/package.xml";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir
& " --no-type-declaration --content-only --name-access --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource-web.ads")),
"Resource file 'resource-web.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource-web.adb")),
"Resource file 'resource-web.adb' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource-config.ads")),
"Resource file 'resource-config.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource-config.adb")),
"Resource file 'resource-config.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-3/test3.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test3" & Are.Testsuite.EXE),
"Binary file 'bin/test3' not created");
T.Execute ("bin/test3" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: <config></config>", Result,
"Invalid generation");
end Test_Generate_Ada3;
procedure Test_Generate_Ada4 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-4";
Rule : constant String := "regtests/files/test-ada-4/package.xml";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --name-access --content-only --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource4.ads")),
"Resource file 'resource4.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resource4.adb")),
"Resource file 'resource4.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-4/test4.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test4" & Are.Testsuite.EXE),
"Binary file 'bin/test4' not created");
T.Execute ("bin/test4" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: <config>test4</config>", Result,
"Invalid generation");
end Test_Generate_Ada4;
procedure Test_Generate_Ada5 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-5/web";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir
& " --name-access --content-only --var-prefix Id_"
& " --resource=Resources5 --fileset '**/*' "
& Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources5.ads")),
"Resource file 'resources5.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources5.adb")),
"Resource file 'resources5.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-5/test5.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test5" & Are.Testsuite.EXE),
"Binary file 'bin/test5' not created");
T.Execute ("bin/test5" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: body { background: #eee; }p"
& " { color: #2a2a2a; }",
Result,
"Invalid generation");
end Test_Generate_Ada5;
procedure Test_Generate_Ada6 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-6/web";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir
& " --content-only --var-prefix Id_ --resource=Resources6 --fileset '**/*' "
& Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources6.ads")),
"Resource file 'resources6.ads' not generated");
T.Assert (not Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources6.adb")),
"Resource file 'resources6.adb' was generated (expecting no body)");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-6/test6.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test6" & Are.Testsuite.EXE),
"Binary file 'bin/test6' not created");
T.Execute ("bin/test6" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: body { background: #eee; }p "
& "{ color: #2a2a2a; }",
Result,
"Invalid generation");
end Test_Generate_Ada6;
procedure Test_Generate_Ada7 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-7";
Rule : constant String := "regtests/files/test-ada-7/package.xml";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --ignore-case --name-access --content-only --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources7.ads")),
"Resource file 'resources7.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources7.adb")),
"Resource file 'resources7.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-7/test7.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test7" & Are.Testsuite.EXE),
"Binary file 'bin/test7' not created");
T.Execute ("bin/test7" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: <config>test7</config>", Result,
"Invalid generation");
end Test_Generate_Ada7;
procedure Test_Generate_Ada8 (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "regtests/files/test-ada-8";
Rule : constant String := "regtests/files/test-ada-8/package.xml";
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the resources.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --ignore-case --name-access --content-only --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources8.ads")),
"Resource file 'resources8.ads' not generated");
T.Assert (Ada.Directories.Exists (Ada.Directories.Compose (Dir, "resources8.adb")),
"Resource file 'resources78.adb' not generated");
-- Build the test program.
T.Execute ("gprbuild -Pregtests/files/test-ada-8/test8.gpr", Result);
T.Assert (Ada.Directories.Exists ("bin/test8" & Are.Testsuite.EXE),
"Binary file 'bin/test8' not created");
T.Execute ("bin/test8" & Are.Testsuite.EXE, Result);
Util.Tests.Assert_Matches (T, "PASS: " & ASCII.HT & "<config>.*", Result,
"Invalid generation");
Util.Tests.Assert_Matches (T, ".*éèà@.*", Result,
"Invalid generation");
end Test_Generate_Ada8;
procedure Test_Generate_Merge (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "examples/c-web";
Rule : constant String := "examples/c-web/package.xml";
Web_Ads : constant String := Ada.Directories.Compose (Dir, "web.ads");
Web_Adb : constant String := Ada.Directories.Compose (Dir, "web.adb");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the web.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --content-only --name-access --rule="
& Rule & " " & Web, Result);
T.Assert (Ada.Directories.Exists (Web_Ads),
"Resource file 'web.ads' not generated");
T.Assert (Ada.Directories.Exists (Web_Adb),
"Resource file 'web.adb' not generated");
Util.Tests.Assert_Equal_Files (T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "web.ads"),
Test => Web_Ads,
Message => "Invalid Ada spec generation");
Util.Tests.Assert_Equal_Files (T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "web.adb"),
Test => Web_Adb,
Message => "Invalid Ada body generation");
end Test_Generate_Merge;
procedure Test_Generate_Concat (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Rule : constant String := "regtests/files/package-concat.xml";
Concat_Ads : constant String := Ada.Directories.Compose (Dir, "concat.ads");
Concat_Adb : constant String := Ada.Directories.Compose (Dir, "concat.adb");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the concat.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --content-only --name-access --rule=" & Rule & " "
& " regtests/files/test-ada-2 regtests/files/test-ada-3"
& " regtests/files/test-ada-4 regtests/files/test-c-1", Result);
T.Assert (Ada.Directories.Exists (Concat_Ads),
"Resource file 'concat.ads' not generated");
T.Assert (Ada.Directories.Exists (Concat_Adb),
"Resource file 'concat.adb' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "concat.ads"),
Test => Concat_Ads,
Message => "Invalid Ada spec generation");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "concat.adb"),
Test => Concat_Adb,
Message => "Invalid Ada body generation");
end Test_Generate_Concat;
procedure Test_Generate_Bundle (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Web : constant String := "examples/ada-bundles";
Rule : constant String := "examples/ada-bundles/package.xml";
Bundle_Ads : constant String := Ada.Directories.Compose (Dir, "bundle.ads");
Bundle_Adb : constant String := Ada.Directories.Compose (Dir, "bundle.adb");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the bundle.ad[bs] files
T.Execute (Tool & " -o " & Dir & " --content-only --name-access --rule=" & Rule & " "
& Web, Result);
T.Assert (Ada.Directories.Exists (Bundle_Ads),
"Resource file 'bundle.ads' not generated");
T.Assert (Ada.Directories.Exists (Bundle_Adb),
"Resource file 'bundle.adb' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "bundle.ads"),
Test => Bundle_Ads,
Message => "Invalid Ada spec generation");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "bundle.adb"),
Test => Bundle_Adb,
Message => "Invalid Ada body generation");
end Test_Generate_Bundle;
procedure Test_Generate_Lines (T : in out Test) is
Dir : constant String := Util.Tests.Get_Test_Path ("");
Rule : constant String := "regtests/files/package-lines.xml";
Files : constant String := "regtests/files";
Lines_Ads : constant String := Ada.Directories.Compose (Dir, "lines.ads");
Result : Ada.Strings.Unbounded.Unbounded_String;
begin
-- Generate the lines.ads files
T.Execute (Tool & " -o " & Dir & " --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-empty", Result);
T.Assert (Ada.Directories.Exists (Lines_Ads),
"Resource file 'lines.ads' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-empty.ads"),
Test => Lines_Ads,
Message => "Invalid Ada spec generation");
Ada.Directories.Delete_File (Lines_Ads);
T.Execute (Tool & " -o " & Dir & " --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-single", Result);
T.Assert (Ada.Directories.Exists (Lines_Ads),
"Resource file 'lines.ads' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-single.ads"),
Test => Lines_Ads,
Message => "Invalid Ada spec generation");
Ada.Directories.Delete_File (Lines_Ads);
T.Execute (Tool & " -o " & Dir & " --content-only --var-prefix Id_ --rule="
& Rule & " " & Files & "/lines-multiple", Result);
T.Assert (Ada.Directories.Exists (Lines_Ads),
"Resource file 'lines.ads' not generated");
Util.Tests.Assert_Equal_Files
(T => T,
Expect => Util.Tests.Get_Path (Expect_Dir & "lines-multiple.ads"),
Test => Lines_Ads,
Message => "Invalid Ada spec generation");
end Test_Generate_Lines;
procedure Test_Ada_Names (T : in out Test) is
begin
Util.Tests.Assert_Equals (T, "Id_file_c",
To_Ada_Name ("Id_", "file.c"),
"Bad conversion");
Util.Tests.Assert_Equals (T, "Id_file_name_h",
To_Ada_Name ("Id_", "file-name.h"),
"Bad conversion");
Util.Tests.Assert_Equals (T, "Plop_File_Dat",
To_Ada_Name ("Plop_", "File.Dat"),
"Bad conversion");
Util.Tests.Assert_Equals (T, "Id_File23_Dat",
To_Ada_Name ("Id_", "File 23 .Dat"),
"Bad conversion");
end Test_Ada_Names;
end Are.Generator.Ada2012.Tests;
|
with P_StructuralTypes; use P_StructuralTypes;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Sequential_IO;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings.Unbounded.Text_IO;
with Ada.Streams; use Ada.Streams;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Calendar; use Ada.Calendar;
package body P_deshandler is
procedure Process (Self : in out DesHandler) is
InputLink : aliased InputHandler;
IPLink : aliased IPHandler;
KeyGenLink : aliased KeyHandler;
FeistelLink : aliased FeistelHandler;
ReverseIPLink : aliased ReverseIPHandler;
OutputLink : aliased OutputHandler;
Start : Time;
Finish : Time;
Final_Time : Duration;
begin
Self.Process_Request;
Start := Clock;
InputLink := Make (InputLink,Self.Input_Name);
IPLink := Make (IPLink);
KeyGenLink := Make (KeyGenLink);
FeistelLink := Make (FeistelLink);
FeistelLink.Set_Mode(Self.Mode);
ReverseIPLink := Make (ReverseIPLink);
OutputLink := Make (OutputLink);
OutputLink.Set_Output_Name(Self.Output_Name);
Self.InputLink := InputLink;
Self.IPLink := IPLink;
Self.KeyGenLink := KeyGenLink;
Self.FeistelLink := FeistelLink;
Self.ReverseIPLink := ReverseIPLink;
Self.OutputLink := OutputLink;
Self.Handle;
Finish := Clock;
Final_Time := Finish - Start;
Put_Line (Final_Time'Image);
end;
procedure Handle (Self : in out DesHandler) is
begin
Put("Container created") ; New_Line;
Self.Create_Binary_Data_Container;
Put("Handlers order set") ; New_Line;
Self.Set_Handlers_Order;
Put("Handlers containers set") ; New_Line;
Self.Set_Handlers_Container;
Self.InputLink.Handle;
end;
procedure Create_Binary_Data_Container (Self : in out DesHandler) is
begin
declare
Ptr_BinaryContainer : constant BinaryContainer_Access
:= new T_BinaryContainer(1..Self.InputLink.Get_Input_Size);
begin
Self.Ptr_Container := Ptr_BinaryContainer;
end;
end;
procedure Process_Request (Self : in out DesHandler) is
Tmp_Mode : Character := ' ';
Tmp_Key : Unbounded_String;
begin
while (Tmp_Mode /= 'D' and Tmp_Mode /= 'E') loop
Put ("Choose mode of algorithm (E for encryption, D for deciphering) : ");
Tmp_Mode := To_String(Ada.Strings.Unbounded.Text_IO.Get_Line)(1);
end loop;
Self.Mode := Tmp_Mode;
Put ("Choose the input file : ");
Self.Input_Name := Ada.Strings.Unbounded.Text_IO.Get_Line;
New_Line;
Put ("Choose the output file (a new file will be created) : ");
Self.Output_Name := Ada.Strings.Unbounded.Text_IO.Get_Line;
while Length(Tmp_Key) /= 8 loop
Put ("Choose a key (must be exactly 8 characters long) : ");
Tmp_Key := Ada.Strings.Unbounded.Text_IO.Get_Line;
New_Line;
end loop;
Self.Ptr_Key.all := To_String(Tmp_Key);
end;
procedure Set_Handlers_Order (Self : in out DesHandler) is
begin
Self.InputLink.Set_NextHandler(Self.IPLink'Unchecked_Access);
Self.IPLink.Set_NextHandler(Self.KeyGenLink'Unchecked_Access);
Self.KeyGenLink.Set_NextHandler(Self.FeistelLink'Unchecked_Access);
Self.FeistelLink.Set_NextHandler(Self.ReverseIPLink'Unchecked_Access);
Self.ReverseIPLink.Set_NextHandler(Self.OutputLink'Unchecked_Access);
end;
procedure Set_Handlers_Container (Self : in out DesHandler) is
begin
Self.InputLink.Set_BinaryContainer(Self.Ptr_Container);
Self.IPLink.Set_BinaryContainer(Self.Ptr_Container);
Self.FeistelLink.Set_BinaryContainer(Self.Ptr_Container);
Self.ReverseIPLink.Set_BinaryContainer(Self.Ptr_Container);
Self.OutputLink.Set_BinaryContainer(Self.Ptr_Container);
Self.KeyGenLink.Set_KeyAccess(Self.Ptr_Key);
Self.KeyGenLink.Set_SubKeyArrayAccess(Self.Ptr_SubKey_Array);
Self.FeistelLink.Set_SubKeyArrayAccess(Self.Ptr_SubKey_Array);
end;
end P_deshandler;
|
with Ada.Command_Line;
with Ada.Streams;
with Ada.Streams.Stream_IO;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with zlib.Streams;
procedure test_streams is
Verbose : Boolean := False;
Text : constant String := "Hello, zlib!";
Temporary_File : Ada.Streams.Stream_IO.File_Type;
Extracted : String (1 .. 1024);
Extracted_Last : Natural;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "-v" then
Verbose := True;
end if;
end loop;
Ada.Streams.Stream_IO.Create (Temporary_File); -- temporary file
declare
Deflator : zlib.Streams.Out_Type :=
zlib.Streams.Open (
Ada.Streams.Stream_IO.Stream (Temporary_File),
Header => zlib.GZip);
begin
String'Write (zlib.Streams.Stream (Deflator), Text);
zlib.Streams.Finish (Deflator);
end;
Ada.Streams.Stream_IO.Reset (Temporary_File, Ada.Streams.Stream_IO.In_File);
declare
Inflator : zlib.Streams.In_Type :=
zlib.Streams.Open (
Ada.Streams.Stream_IO.Stream (Temporary_File),
Header => zlib.GZip);
begin
Extracted_Last := Text'Length;
String'Read (zlib.Streams.Stream (Inflator), Extracted (1 .. Extracted_Last));
begin
String'Read (
zlib.Streams.Stream (Inflator),
Extracted (Extracted_Last + 1 .. Extracted'Last));
raise Program_Error; -- bad
exception
when zlib.Streams.End_Error => null;
end;
end;
declare
use Ada.Text_IO, Ada.Integer_Text_IO;
Compressed_Length : constant Natural :=
Integer (Ada.Streams.Stream_IO.Size (Temporary_File));
Extracted_Length : constant Natural := Extracted_Last - Extracted'First + 1;
begin
if Verbose then
Ada.Integer_Text_IO.Default_Width := 0;
Put ("source length = ");
Put (Text'Length);
New_Line;
Put ("compressed length = ");
Put (Compressed_Length);
New_Line;
Put ("extracted length = ");
Put (Extracted_Length);
New_Line;
end if;
pragma Assert (Extracted (Extracted'First .. Extracted_Last) = Text);
end;
Ada.Streams.Stream_IO.Close (Temporary_File);
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_streams;
|
package inline_scope_p is
procedure Assert (Expr : Boolean; Str : String);
pragma Inline (Assert);
end;
|
-- $Id: scandrv.adb,v 1.2 1997/05/27 21:44:35 grosch rel $
$@ with @, Text_Io, Position, Strings;
$@ use @, Text_Io, Position, Strings;
$@ procedure @Drv is
package Int_Io is new Text_Io.Integer_IO (Integer); use Int_Io;
Token : Integer := 1;
Word : tString;
Debug : Boolean := False;
Count : Integer := 0;
begin
BeginScanner;
while Token /= EofToken loop
Token := GetToken;
Count := Count + 1;
if Debug then
WritePosition (Standard_Output, Attribute.Position);
Put (Standard_Output, Token, 5);
if TokenLength > 0 then
Put (Standard_Output, ' ');
GetWord (Word);
WriteS (Standard_Output, Word);
end if;
New_Line (Standard_Output);
end if;
end loop;
CloseScanner;
Put (Standard_Output, Count, 0);
New_Line (Standard_Output);
$@ end @Drv;
|
with SPARKNaCl; use SPARKNaCl;
with SPARKNaCl.MAC; use SPARKNaCl.MAC;
with SPARKNaCl.Debug; use SPARKNaCl.Debug;
procedure Onetimeauth2
is
RS : constant Poly_1305_Key :=
Construct ((16#ee#, 16#a6#, 16#a7#, 16#25#,
16#1c#, 16#1e#, 16#72#, 16#91#,
16#6d#, 16#11#, 16#c2#, 16#cb#,
16#21#, 16#4d#, 16#3c#, 16#25#,
16#25#, 16#39#, 16#12#, 16#1d#,
16#8e#, 16#23#, 16#4e#, 16#65#,
16#2d#, 16#65#, 16#1f#, 16#a4#,
16#c8#, 16#cf#, 16#f8#, 16#80#));
C : constant Byte_Seq (0 .. 130) :=
(16#8e#, 16#99#, 16#3b#, 16#9f#, 16#48#, 16#68#, 16#12#, 16#73#,
16#c2#, 16#96#, 16#50#, 16#ba#, 16#32#, 16#fc#, 16#76#, 16#ce#,
16#48#, 16#33#, 16#2e#, 16#a7#, 16#16#, 16#4d#, 16#96#, 16#a4#,
16#47#, 16#6f#, 16#b8#, 16#c5#, 16#31#, 16#a1#, 16#18#, 16#6a#,
16#c0#, 16#df#, 16#c1#, 16#7c#, 16#98#, 16#dc#, 16#e8#, 16#7b#,
16#4d#, 16#a7#, 16#f0#, 16#11#, 16#ec#, 16#48#, 16#c9#, 16#72#,
16#71#, 16#d2#, 16#c2#, 16#0f#, 16#9b#, 16#92#, 16#8f#, 16#e2#,
16#27#, 16#0d#, 16#6f#, 16#b8#, 16#63#, 16#d5#, 16#17#, 16#38#,
16#b4#, 16#8e#, 16#ee#, 16#e3#, 16#14#, 16#a7#, 16#cc#, 16#8a#,
16#b9#, 16#32#, 16#16#, 16#45#, 16#48#, 16#e5#, 16#26#, 16#ae#,
16#90#, 16#22#, 16#43#, 16#68#, 16#51#, 16#7a#, 16#cf#, 16#ea#,
16#bd#, 16#6b#, 16#b3#, 16#73#, 16#2b#, 16#c0#, 16#e9#, 16#da#,
16#99#, 16#83#, 16#2b#, 16#61#, 16#ca#, 16#01#, 16#b6#, 16#de#,
16#56#, 16#24#, 16#4a#, 16#9e#, 16#88#, 16#d5#, 16#f9#, 16#b3#,
16#79#, 16#73#, 16#f6#, 16#22#, 16#a4#, 16#3d#, 16#14#, 16#a6#,
16#59#, 16#9b#, 16#1f#, 16#65#, 16#4c#, 16#b4#, 16#5a#, 16#74#,
16#e3#, 16#55#, 16#a5#);
A : constant Bytes_16 :=
(16#f3#, 16#ff#, 16#c7#, 16#70#, 16#3f#, 16#94#, 16#00#, 16#e5#,
16#2a#, 16#7d#, 16#fb#, 16#4b#, 16#3d#, 16#33#, 16#05#, 16#d9#);
R : Boolean;
begin
R := Onetimeauth_Verify (A, C, RS);
DH ("R is", R);
end Onetimeauth2;
|
with Interfaces; use Interfaces;
with MSPGD;
with MSPGD.Board; use MSPGD.Board;
with MSPGD.SPI;
with Drivers.Text_IO;
procedure Main is
pragma Preelaborate;
package Text_IO is new Drivers.Text_IO (USART => MSPGD.Board.UART);
Buffer : MSPGD.Buffer_Type (0 .. 15);
begin
Init;
LED_RED.Init;
SPI.Init;
SCLK.Init;
MISO.Init;
MOSI.Init;
SSEL.Init;
SSEL.Set;
Text_IO.Put_Line ("Hello, World!");
loop
if not BUTTON.Is_Set then
for I in Buffer'Range loop Buffer (I) := Unsigned_8 (I + 32); end loop;
LED_RED.Set;
SSEL.Clear;
SPI.Transfer (Buffer);
SSEL.Set;
LED_RED.Clear;
end if;
end loop;
end Main;
|
------------------------------------------------------------------------------
-- 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 System.Storage_Elements is
pragma Pure (System.Storage_Elements);
type Storage_Offset is
range implementation-Defined .. implementation-defined;
subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last;
type Storage_Element is mod implementation-defined;
for Storage_Element'Size use Storage_Unit;
type Storage_Array is array
(Storage_Offset range <>) of aliased Storage_Element;
for Storage_Array'Component_Size use Storage_Unit;
-- Address Arithmetic:
function "+" (Left : Address; Right : Storage_Offset)
return Address;
function "+" (Left : Storage_Offset; Right : Address)
return Address;
function "-" (Left : Address; Right : Storage_Offset)
return Address;
function "-" (Left, Right : Address)
return Storage_Offset;
function "mod" (Left : Address; Right : Storage_Offset)
return Storage_Offset;
-- Conversion to/from integers:
type Integer_Address is mod implementation-defined;
function To_Address (Value : Integer_Address) return Address;
function To_Integer (Value : Address) return Integer_Address;
pragma Convention (Intrinsic, "+");
pragma Convention (Intrinsic, "-");
pragma Convention (Intrinsic, "mod");
pragma Convention (Intrinsic, "To_Address");
pragma Convention (Intrinsic, "To_Integer");
-- and so on for all language-defined subprograms declared in this package.
end System.Storage_Elements;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Matreshka.Internals.XML.Attribute_Tables is
procedure Free is
new Ada.Unchecked_Deallocation (Attribute_Array, Attribute_Array_Access);
procedure New_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
The_Type : Attribute_Types;
Attribute : out Attribute_Identifier);
-- Allocates new attribute with specified type.
procedure Clear (Self : in out Attribute_Table);
-- Clear existing data.
------------
-- Append --
------------
procedure Append
(Self : in out Attribute_Table;
Attribute : Attribute_Identifier;
Next : Attribute_Identifier) is
begin
Self.Table (Attribute).Next := Next;
end Append;
-----------
-- Clear --
-----------
procedure Clear (Self : in out Attribute_Table) is
begin
for J in Self.Table'First .. Self.Last loop
Matreshka.Internals.Strings.Dereference (Self.Table (J).Default);
end loop;
end Clear;
-------------
-- Default --
-------------
function Default
(Self : Attribute_Table;
Attribute : Attribute_Identifier)
return not null Matreshka.Internals.Strings.Shared_String_Access is
begin
return Self.Table (Attribute).Default;
end Default;
--------------
-- Finalize --
--------------
procedure Finalize (Self : in out Attribute_Table) is
begin
Clear (Self);
Free (Self.Table);
end Finalize;
-----------------
-- Has_Default --
-----------------
function Has_Default
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return
not (Self.Table (Attribute).Is_Required
or Self.Table (Attribute).Is_Implied);
end Has_Default;
--------------
-- Is_CDATA --
--------------
function Is_CDATA
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return Self.Table (Attribute).The_Type = CDATA;
end Is_CDATA;
--------------
-- Is_Fixed --
--------------
function Is_Fixed
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return Self.Table (Attribute).Is_Fixed;
end Is_Fixed;
-----------
-- Is_ID --
-----------
function Is_ID
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return Self.Table (Attribute).The_Type = ID;
end Is_ID;
----------------
-- Is_Implied --
----------------
function Is_Implied
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return Self.Table (Attribute).Is_Implied;
end Is_Implied;
-----------------
-- Is_Required --
-----------------
function Is_Required
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Boolean is
begin
return Self.Table (Attribute).Is_Required;
end Is_Required;
----------
-- Name --
----------
function Name
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Symbol_Identifier is
begin
return Self.Table (Attribute).Name;
end Name;
-------------------
-- New_Attribute --
-------------------
procedure New_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
The_Type : Attribute_Types;
Attribute : out Attribute_Identifier) is
begin
Self.Last := Self.Last + 1;
if Self.Last > Self.Table'Last then
declare
Old : Attribute_Array_Access := Self.Table;
begin
Self.Table := new Attribute_Array (1 .. Old'Last + 16);
Self.Table (Old'Range) := Old.all;
Free (Old);
end;
end if;
Attribute := Self.Last;
Self.Table (Attribute) :=
(Name => Name,
The_Type => The_Type,
Is_Required => False,
Is_Implied => False,
Is_Fixed => False,
Default => Matreshka.Internals.Strings.Shared_Empty'Access,
Next => No_Attribute);
end New_Attribute;
-------------------------
-- New_CDATA_Attribute --
-------------------------
procedure New_CDATA_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, CDATA, Attribute);
end New_CDATA_Attribute;
----------------------------
-- New_Entities_Attribute --
----------------------------
procedure New_Entities_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, ENTITIES, Attribute);
end New_Entities_Attribute;
--------------------------
-- New_Entity_Attribute --
--------------------------
procedure New_Entity_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, ENTITY, Attribute);
end New_Entity_Attribute;
-------------------------------
-- New_Enumeration_Attribute --
-------------------------------
procedure New_Enumeration_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, ENUMERATION, Attribute);
end New_Enumeration_Attribute;
----------------------
-- New_Id_Attribute --
----------------------
procedure New_Id_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, ID, Attribute);
end New_Id_Attribute;
-------------------------
-- New_IdRef_Attribute --
-------------------------
procedure New_IdRef_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, IDREF, Attribute);
end New_IdRef_Attribute;
--------------------------
-- New_IdRefs_Attribute --
--------------------------
procedure New_IdRefs_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, IDREFS, Attribute);
end New_IdRefs_Attribute;
---------------------------
-- New_NmToken_Attribute --
---------------------------
procedure New_NmToken_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, NMTOKEN, Attribute);
end New_NmToken_Attribute;
----------------------------
-- New_NmTokens_Attribute --
----------------------------
procedure New_NmTokens_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, NMTOKENS, Attribute);
end New_NmTokens_Attribute;
----------------------------
-- New_Notation_Attribute --
----------------------------
procedure New_Notation_Attribute
(Self : in out Attribute_Table;
Name : Symbol_Identifier;
Attribute : out Attribute_Identifier) is
begin
New_Attribute (Self, Name, NOTATION, Attribute);
end New_Notation_Attribute;
----------
-- Next --
----------
function Next
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Attribute_Identifier is
begin
return Self.Table (Attribute).Next;
end Next;
-----------
-- Reset --
-----------
procedure Reset (Self : in out Attribute_Table) is
begin
Clear (Self);
-- Resets to initial state.
Self.Last := No_Attribute;
end Reset;
-----------------
-- Set_Default --
-----------------
procedure Set_Default
(Self : in out Attribute_Table;
Attribute : Attribute_Identifier;
Value : not null Matreshka.Internals.Strings.Shared_String_Access) is
begin
Matreshka.Internals.Strings.Reference (Value);
Self.Table (Attribute).Default := Value;
end Set_Default;
------------------
-- Set_Is_Fixed --
------------------
procedure Set_Is_Fixed
(Self : in out Attribute_Table;
Attribute : Attribute_Identifier;
Value : Boolean) is
begin
Self.Table (Attribute).Is_Fixed := Value;
end Set_Is_Fixed;
--------------------
-- Set_Is_Implied --
--------------------
procedure Set_Is_Implied
(Self : in out Attribute_Table;
Attribute : Attribute_Identifier;
Value : Boolean) is
begin
Self.Table (Attribute).Is_Implied := Value;
end Set_Is_Implied;
---------------------
-- Set_Is_Required --
---------------------
procedure Set_Is_Required
(Self : in out Attribute_Table;
Attribute : Attribute_Identifier;
Value : Boolean) is
begin
Self.Table (Attribute).Is_Required := Value;
end Set_Is_Required;
-------------------------
-- Symbol_Of_Type_Name --
-------------------------
function Symbol_Of_Type_Name
(Self : Attribute_Table;
Attribute : Attribute_Identifier) return Symbol_Identifier is
begin
case Self.Table (Attribute).The_Type is
when CDATA =>
return Symbol_CDATA;
when ENTITIES =>
return Symbol_ENTITIES;
when ENTITY =>
return Symbol_ENTITY;
when ID =>
return Symbol_ID;
when IDREF =>
return Symbol_IDREF;
when IDREFS =>
return Symbol_IDREFS;
when NMTOKEN =>
return Symbol_NMTOKEN;
when NMTOKENS =>
return Symbol_NMTOKENS;
when NOTATION =>
return Symbol_NOTATION;
when ENUMERATION =>
-- [SAX2] Attribiutes::getType
--
-- "For an enumerated attribute that is not a notation, the parser
-- will report the type as "NMTOKEN"."
return Symbol_NMTOKEN;
end case;
end Symbol_Of_Type_Name;
end Matreshka.Internals.XML.Attribute_Tables;
|
-- SPDX-License-Identifier: MIT
--
-- Copyright (c) 1999 - 2018 Gautier de Montmollin
-- SWITZERLAND
--
-- 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.
-- UnZip.Streams
-- -------------
--
-- Extracts, as a stream, a file which is has been compressed into a Zip archive.
-- The Zip archive itself (the input) can be a file or a more general stream.
-- This package is resembling Ada.Streams.Stream_IO, to facilitate transition.
with Ada.Streams;
with DCF.Zip;
with DCF.Streams;
package DCF.Unzip.Streams is
pragma Preelaborate;
type Stream_Writer
(Target : access DCF.Streams.Root_Zipstream_Type'Class)
is new Ada.Streams.Root_Stream_Type with private;
-- A simple helper object to extract files to a Root_Zipstream_Type
--
-- To extract to a file on disk, create a Stream_Writer object as follows:
--
-- File_Stream : aliased DCF.Streams.File_Zipstream := DCF.Streams.Create (Path);
-- Stream_Writer : DCF.Unzip.Streams.Stream_Writer (File_Stream'Access);
--
-- And then call procedure Extract below.
use type DCF.Streams.Zipstream_Class_Access;
procedure Extract
(Destination : in out Ada.Streams.Root_Stream_Type'Class;
Archive_Info : in Zip.Zip_Info; -- Archive's Zip_info
File : in Zip.Archived_File; -- Zipped entry
Verify_Integrity : in Boolean)
with Pre => Archive_Info.Is_Loaded and Archive_Info.Stream /= null;
-- Extract a Zip archive entry to the given output stream
--
-- The memory footprint is limited to the decompression structures and
-- buffering, so the outward stream can be an interesting alternative
-- to the inward, albeit less comfortable.
private
type Stream_Writer
(Target : access DCF.Streams.Root_Zipstream_Type'Class)
is new Ada.Streams.Root_Stream_Type with record
Index : DCF.Streams.Zs_Index_Type := DCF.Streams.Zs_Index_Type'First;
end record;
overriding procedure Read
(Stream : in out Stream_Writer;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is null;
overriding procedure Write
(Stream : in out Stream_Writer;
Item : in Ada.Streams.Stream_Element_Array);
end DCF.Unzip.Streams;
|
with ada.containers.indefinite_ordered_maps;
with gnat.regexp;
with numbers; use numbers;
package env is
use type word;
package environment_t is new ada.containers.indefinite_ordered_maps(
element_type => word, key_type => string);
environment : environment_t.map;
function validate_variable (s : string) return boolean;
private
variable_regexp : gnat.regexp.regexp := gnat.regexp.compile("[a-z][a-z0-9_]*");
end env;
|
with Ada.Characters.Latin_1;
with Ada.Command_Line;
with Ada.Streams.Stream_IO.Pipes;
with Ada.Strings.Unbounded_Strings;
package body GNAT.Expect is
use type GNAT.OS_Lib.Argument_List;
function Get_Command_Output (
Command : String;
Arguments : GNAT.OS_Lib.Argument_List;
Input : String;
Status : not null access Integer;
Err_To_Out : Boolean := False)
return String
is
Input_Reading,
Input_Writing,
Output_Reading,
Output_Writing : Ada.Streams.Stream_IO.File_Type;
Child : Ada.Processes.Process;
Command_And_Arguments : Ada.Processes.Command_Type;
Result : Ada.Strings.Unbounded_Strings.Unbounded_String;
begin
-- build command line
Ada.Processes.Append (Command_And_Arguments, Command);
for I in Arguments'Range loop
Ada.Processes.Append (Command_And_Arguments, Arguments (I).all);
end loop;
-- open
Ada.Streams.Stream_IO.Pipes.Create (Input_Reading, Input_Writing);
Ada.Streams.Stream_IO.Pipes.Create (Output_Reading, Output_Writing);
if Err_To_Out then
Ada.Processes.Create (
Child,
Command_And_Arguments,
Search_Path => True,
Input => Input_Reading,
Output => Output_Writing,
Error => Output_Writing);
else
Ada.Processes.Create (
Child,
Command_And_Arguments,
Search_Path => True,
Input => Input_Reading,
Output => Output_Writing);
end if;
-- send input
String'Write (Ada.Streams.Stream_IO.Stream (Input_Writing), Input);
Ada.Streams.Stream_IO.Close (Input_Writing);
-- receive output
begin
loop
declare
Item : Character;
begin
Character'Read (
Ada.Streams.Stream_IO.Stream (Output_Reading),
Item);
Ada.Strings.Unbounded_Strings.Append_Element (Result, Item);
end;
end loop;
exception
when Ada.Streams.Stream_IO.End_Error => null;
end;
-- wait and receive status-code
Ada.Processes.Wait (
Child,
Status => Ada.Command_Line.Exit_Status (Status.all));
return Ada.Strings.Unbounded_Strings.To_String (Result);
end Get_Command_Output;
procedure Close (Descriptor : in out Process_Descriptor) is
begin
Ada.Processes.Wait (Descriptor.Item);
end Close;
procedure Close (
Descriptor : in out Process_Descriptor;
Status : out Integer) is
begin
Ada.Processes.Wait (
Descriptor.Item,
Ada.Command_Line.Exit_Status (Status));
end Close;
procedure Send (
Descriptor : in out Process_Descriptor;
Str : String;
Add_LF : Boolean := True;
Empty_Buffer : Boolean := False)
is
pragma Unreferenced (Empty_Buffer);
LF : constant String (1 .. 1) := (1 => Ada.Characters.Latin_1.LF);
begin
String'Write (
Ada.Streams.Stream_IO.Stream (Descriptor.Input_Writing.all),
Str & LF (1 .. Boolean'Pos (Add_LF)));
end Send;
procedure Expect (
Descriptor : in out Process_Descriptor;
Result : out Expect_Match;
Regexp : String;
Timeout : Integer := 10_000;
Full_Buffer : Boolean := False) is
begin
raise Program_Error; -- unimplemented
end Expect;
procedure Expect (
Descriptor : in out Process_Descriptor;
Result : out Expect_Match;
Regexp : GNAT.Regpat.Pattern_Matcher;
Timeout : Integer := 10_000;
Full_Buffer : Boolean := False) is
begin
raise Program_Error; -- unimplemented
end Expect;
procedure Flush (
Descriptor : in out Process_Descriptor;
Timeout : Integer := 0) is
begin
raise Program_Error; -- unimplemented
end Flush;
function Expect_Out (Descriptor : Process_Descriptor) return String is
begin
raise Program_Error; -- unimplemented
return Expect_Out (Descriptor);
end Expect_Out;
end GNAT.Expect;
|
------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+spat@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
with SPAT.Log;
with SPAT.Proof_Attempt;
package body SPAT.Spark_Info.Heuristics is
Null_Workload : constant Workloads :=
Workloads'(Success_Time => 0.0,
Failed_Time => 0.0,
Max_Success => SPAT.None);
---------------------------------------------------------------------------
-- Min_Failed_Time
--
-- Comparison operator for a proof attempts.
--
-- If we have a total failed time, this takes precedence, as this may mean
-- that the prover fails a lot.
--
-- If none of the provers have a failed time (i.e. = 0.0) that means, they
-- all succeeded whenever they were being called.
--
-- Assuming that the one being called more often is also the most
-- successful one in general, we sort by highest success time.
--
-- NOTE: This is all guesswork and despite the subrouting being called
-- "Find_Optimum", this is definitely far from optimal. For an
-- optimal result, we would need the data for all provers which
-- defeats the whole purpose.
---------------------------------------------------------------------------
function Min_Failed_Time (Left : in Prover_Data;
Right : in Prover_Data) return Boolean;
---------------------------------------------------------------------------
-- By_Name
--
-- Comparison operator for file list.
---------------------------------------------------------------------------
function By_Name (Left : in File_Data;
Right : in File_Data) return Boolean is
(Left.Name < Right.Name);
package File_Sorting is new
File_Vectors.Generic_Sorting ("<" => By_Name);
package Prover_Sorting is new
Prover_Vectors.Generic_Sorting ("<" => Min_Failed_Time);
package Prover_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => Prover_Name,
Element_Type => Workloads,
Hash => SPAT.Hash,
Equivalent_Keys => "=",
"=" => "=");
package Per_File is new
Ada.Containers.Hashed_Maps (Key_Type => SPARK_File_Name,
Element_Type => Prover_Maps.Map,
Hash => SPAT.Hash,
Equivalent_Keys => SPAT."=",
"=" => Prover_Maps."=");
---------------------------------------------------------------------------
-- Find_Optimum
--
-- NOTE: As of now, this implementation is also highly inefficient.
--
-- It uses a lot of lookups where a proper data structure would have
-- been able to prevent that.
-- I just found it more important to get a working prototype, than a
-- blazingly fast one which doesn't.
---------------------------------------------------------------------------
function Find_Optimum
(Info : in T;
File_Map : in SPAT.GPR_Support.SPARK_Source_Maps.Map)
return File_Vectors.Vector
is
-- FIXME: This should probably go into the README.md instead of here.
--
-- For starters, trying to optimize proof times is relatively simple.
-- For that you just need to collect all proofs which failed on one
-- prover, but were successful with the other. Of course, once you
-- change the configuration, the picture may be different.
--
-- The problematic part is that at no point we have the full
-- information (i.e. some provers might have been faster than others,
-- but they were never tried, because slower ones still proved the VC).
--
-- Example:
--
-- RFLX.RFLX_Types.U64_Insert => 120.0 s/1.6 ks
-- `-VC_PRECONDITION rflx-rflx_generic_types.adb:221:39 => 120.0 s/491.0 s
-- `-CVC4: 120.0 s (Timeout)
-- -Z3: 120.0 s (Timeout)
-- -altergo: 188.2 ms (Valid)
-- `-Z3: 120.0 s (Timeout)
-- -CVC4: 5.4 s (Valid)
-- `-Z3: 120.0 s (Timeout)
-- -CVC4: 5.3 s (Valid)
-- `-Z3: 60.0 ms (Valid)
-- `-Z3: 40.0 ms (Valid)
-- `-Z3: 20.0 ms (Valid)
-- `-Trivial: 0.0 s (Valid)
--
-- Here we have 7 proof paths in total, let's ignore the ones that have
-- only one prover (for these we can't say anything), leaving us with
--
-- RFLX.RFLX_Types.U64_Insert => 120.0 s/1.6 ks
-- `-VC_PRECONDITION rflx-rflx_generic_types.adb:221:39 => 120.0 s/491.0 s
-- `-CVC4: 120.0 s (Timeout)
-- -Z3: 120.0 s (Timeout)
-- -altergo: 188.2 ms (Valid)
-- `-Z3: 120.0 s (Timeout)
-- -CVC4: 5.4 s (Valid)
-- `-Z3: 120.0 s (Timeout)
-- -CVC4: 5.3 s (Valid)
--
-- We see, that altergo could proof the first path quite fast, so
-- chances are it might be able to proof the remaining paths similarly
-- fast. But without trying, there's no way of knowing it, so stick to
-- the information we have.
--
-- Path Prover Max_Success Max_Failed Saving
-- 1 "altergo" 188.2 ms -- 119.8 s
-- "Z3" 0.0 s 120.0 s --
-- "CVC4" 0.0 s 120.0 s --
-- 2 "altergo" -- -- --
-- "Z3" -- 120.0 s --
-- "CVC4" 5.4 s -- 114.6
-- 3 "altergo" -- -- --
-- "Z3" -- 120.0 s --
-- "CVC4" 5.3 s -- 114.7
--
-- We take different orders into account (maybe we can even read them
-- from the project file?).
--
-- "altergo", "CVC4", "Z3" : *maybe* -119.8 s
-- "CVC4", "altergo", "Z3" : *maybe* -114.6 s
-- "altergo", "Z3", "CVC4": *maybe* -119.8 s
-- We need to split the proofs per file, as this is the minimum
-- granularity we can specify for the order of provers.
-- TODO: Handle spec/body/separates correctly.
SPARK_List : Per_File.Map;
use type Per_File.Cursor;
Times_Position : Per_File.Cursor;
Dummy_Inserted : Boolean;
begin
-- Collect all proof items in the Per_File/Proof_Records structure.
for E of Info.Entities loop
declare
SPARK_File : constant SPARK_File_Name :=
Spark_Info.File_Sets.Element (E.SPARK_File);
begin
Times_Position := SPARK_List.Find (Key => SPARK_File);
if Times_Position = Per_File.No_Element then
SPARK_List.Insert
(Key => SPARK_File,
New_Item => Prover_Maps.Empty_Map,
Position => Times_Position,
Inserted => Dummy_Inserted);
end if;
declare
File_Ref : constant Per_File.Reference_Type :=
SPARK_List.Reference (Position => Times_Position);
begin
-- Instead of manually iterating through each of the subtrees in
-- a proof, we just collect all Proof_Attempts we find.
for
Item_Position in Entity.Tree.Iterate_Subtree (Position => E.Proofs)
loop
declare
Item : constant SPAT.Entity.T'Class :=
SPAT.Entity.T'Class
(Entity.Tree.Element (Position => Item_Position));
begin
if Item in Proof_Attempt.T'Class then
-- Item is a Proof_Attempt, so evaluate it.
declare
-- Extract our VC component from the tree.
The_Attempt : constant Proof_Attempt.T'Class :=
Proof_Attempt.T'Class (Item);
Prover_Cursor : Prover_Maps.Cursor :=
File_Ref.Element.Find (The_Attempt.Prover);
use type Prover_Maps.Cursor;
begin
if Prover_Cursor = Prover_Maps.No_Element then
-- New prover name, insert it.
File_Ref.Element.Insert
(Key => The_Attempt.Prover,
New_Item => Null_Workload,
Position => Prover_Cursor,
Inserted => Dummy_Inserted);
end if;
declare
Prover_Element : constant Prover_Maps.Reference_Type :=
File_Ref.Reference (Position => Prover_Cursor);
use type Proof_Attempt.Prover_Result;
begin
if The_Attempt.Result = Proof_Attempt.Valid then
Prover_Element.Success_Time :=
Prover_Element.Success_Time + The_Attempt.Time;
Prover_Element.Max_Success.Time :=
Duration'Max
(Prover_Element.Max_Success.Time,
The_Attempt.Time);
Prover_Element.Max_Success.Steps :=
Prover_Steps'Max
(Prover_Element.Max_Success.Steps,
The_Attempt.Steps);
else
Prover_Element.Failed_Time :=
Prover_Element.Failed_Time + The_Attempt.Time;
end if;
end;
end;
end if;
end;
end loop;
end;
end;
end loop;
-- Debug output result.
if Log.Debug_Enabled then
for C in SPARK_List.Iterate loop
Log.Debug (Message => To_String (Per_File.Key (Position => C)));
for Prover in Per_File.Element (Position => C).Iterate loop
declare
E : constant Workloads :=
Prover_Maps.Element (Position => Prover);
begin
Log.Debug
(Message =>
" " &
To_String (Prover_Maps.Key (Position => Prover)));
Log.Debug
(Message => " t(Success) " & SPAT.Image (E.Success_Time));
Log.Debug
(Message => " t(Failed) " & SPAT.Image (E.Failed_Time));
Log.Debug
(Message => " T(Success) " & SPAT.Image (E.Max_Success.Time));
Log.Debug
(Message => " S(Success)" & E.Max_Success.Steps'Image);
end;
end loop;
end loop;
end if;
-- Build the result vector.
declare
Result : File_Vectors.Vector;
begin
for Source_Cursor in SPARK_List.Iterate loop
declare
Prover_Vector : Prover_Vectors.Vector;
begin
for Prover_Cursor in SPARK_List (Source_Cursor).Iterate loop
-- Special handling for the "Trivial" prover. We never
-- want to show this one.
if
Prover_Maps.Key (Position => Prover_Cursor) /=
Prover_Name (To_Name ("Trivial"))
then
Prover_Vector.Append
(New_Item =>
Prover_Data'
(Name =>
Prover_Maps.Key (Position => Prover_Cursor),
Workload => Prover_Maps.Element (Prover_Cursor)));
end if;
end loop;
if not Prover_Vector.Is_Empty then
-- Sort provers by minimum failed time.
Prover_Sorting.Sort (Container => Prover_Vector);
Result.Append
(New_Item =>
File_Data'
(Name =>
File_Map (Per_File.Key (Position => Source_Cursor)),
Provers => Prover_Vector));
end if;
end;
end loop;
File_Sorting.Sort (Container => Result);
return Result;
end;
end Find_Optimum;
---------------------------------------------------------------------------
-- Min_Failed_Time
---------------------------------------------------------------------------
function Min_Failed_Time (Left : in Prover_Data;
Right : in Prover_Data) return Boolean is
begin
if Left.Workload.Failed_Time = Right.Workload.Failed_Time then
-- Failed time is equal (likely zero), so prefer the prover with the
-- *higher* success time. This can be wrong, because this value
-- mostly depends on which prover is called first.
return Left.Workload.Success_Time > Right.Workload.Success_Time;
end if;
-- Prefer the prover that spends less wasted time.
return Left.Workload.Failed_Time < Right.Workload.Failed_Time;
end Min_Failed_Time;
end SPAT.Spark_Info.Heuristics;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Byte_Swapping is
pragma Pure;
type U16 is mod 2 ** 16;
type U32 is mod 2 ** 32;
type U64 is mod 2 ** 64;
function Bswap_16 (X : U16) return U16
with Import,
Convention => Intrinsic, External_Name => "__builtin_bswap16";
function Bswap_32 (X : U32) return U32
with Import,
Convention => Intrinsic, External_Name => "__builtin_bswap32";
function Bswap_64 (X : U64) return U64
with Import,
Convention => Intrinsic, External_Name => "__builtin_bswap64";
end System.Byte_Swapping;
|
separate (Numerics.Sparse_Matrices)
function Plus2 (Left : in Sparse_Matrix;
Right : in Sparse_Matrix) return Sparse_Matrix is
use Ada.Text_IO, Ada.Containers;
X, Y : RVector;
Ai, Aj, Bi, Bj : IVector;
N_Row, N_Col : Pos;
N : constant Count_Type := Left.X.Length + Right.X.Length;
C : Sparse_Matrix;
begin
pragma Assert (Left.N_Row = Right.N_Row);
pragma Assert (Left.N_Col = Right.N_Col);
To_Triplet (Left, Ai, Aj, X, N_Row, N_Col);
To_Triplet (Right, Bi, Bj, Y, N_Row, N_Col);
X.Reserve_Capacity (N);
Ai.Reserve_Capacity (N);
Aj.Reserve_Capacity (N);
for I in 1 .. Pos (Y.Length) loop
Ai.Append (Bi (I));
Aj.Append (Bj (I));
X.Append (Y (I));
end loop;
Triplet_To_Matrix (C, Ai, Aj, X, N_Row, N_Col);
return C;
end Plus2;
|
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Unchecked_Deallocation;
with Debugs;
with Config_Tables;
with Prop_Links;
with Symbol_Sets;
with Errors;
with Symbols;
package body Config_Lists is
function Config_New return Configs.Config_Access;
-- Return a pointer to a new configuration.
procedure Config_Delete (Config : in out Configs.Config_Access);
-- The configuration "old" is no longer Used.
use type Configs.Config_Access;
package Configuration_Lists is
new Ada.Containers.Doubly_Linked_Lists (Element_Type => Configs.Config_Access);
Config_List : Configuration_Lists.List := Configuration_Lists.Empty_List;
Basis_List : Configuration_Lists.List := Configuration_Lists.Empty_List;
procedure Init is
begin
Config_List.Clear;
Basis_List.Clear;
Config_Tables.Init;
end Init;
function Add
(Rule : in Rule_Access;
Dot : in Rules.Dot_Type) return Configs.Config_Access
is
use Configs;
Model : aliased Config_Record;
Config : Config_Access;
begin
Model.Rule := Rule;
Model.Dot := Dot;
Config := Config_Tables.Find (Model'Unchecked_Access);
if Config = null then
Config := Config_New;
Config.all :=
Config_Record'(Rule => Rule,
Dot => Dot,
Follow_Set => Symbol_Sets.Set_New,
State => null,
Forward_PL => Prop_Links.Propagation_Lists.Empty_List,
Backward_PL => Prop_Links.Propagation_Lists.Empty_List,
Status => Incomplete, -- XXX Do not know
Next => null,
Basis => null);
Config_List.Append (Config);
Config_Tables.Insert (Config);
end if;
return Config;
end Add;
function Add_Basis
(Rule : in Rule_Access;
Dot : in Rules.Dot_Type) return Configs.Config_Access
is
use Configs;
Model : aliased Config_Record;
Config : Config_Access;
begin
Model.Rule := Rule;
Model.Dot := Dot;
Config := Config_Tables.Find (Model'Unchecked_Access);
if Config = null then
Config := Config_New;
Config.all :=
Config_Record'(Rule => Rule,
Dot => Dot,
Follow_Set => Symbol_Sets.Set_New,
State => null,
Forward_PL => Prop_Links.Propagation_Lists.Empty_List,
Backward_PL => Prop_Links.Propagation_Lists.Empty_List,
Status => Incomplete, -- XXX Do not know
Next => null,
Basis => null);
Config_List.Append (Config);
Basis_List.Append (Config);
Config_Tables.Insert (Config);
end if;
return Config;
end Add_Basis;
procedure Closure (Session : in Sessions.Session_Type)
is
use Configs;
-- use Rules;
use Symbols;
use Symbol_Sets;
use type Configuration_Lists.Cursor;
use type Rules.Dot_Type;
use type Rule_Access;
New_Config : Config_Access;
Rule : Rule_Access;
New_Rule : Rule_Access;
Symbol : Symbol_Access;
RHS_Symbol : Symbol_Access;
Dot : Rules.Dot_Type;
Dummy : Boolean;
Last_RHS : Boolean;
Config_Pos : Configuration_Lists.Cursor;
begin
pragma Assert (not Config_List.Is_Empty);
-- Use cursor for looping because there will be appended element in loop.
Config_Pos := Config_List.First;
while Config_Pos /= Configuration_Lists.No_Element loop
declare
Config : constant Config_Access := Configuration_Lists.Element (Config_Pos);
begin
Rule := Config.Rule;
Dot := Config.Dot;
Debugs.Debug (True, "Dot: " & Dot'Image);
if Dot < Rule.RHS.Last_Index then
Symbol := Symbol_Access (Rule.RHS.Element (Dot));
if Symbol.Kind = Non_Terminal then
if Symbol.Rule = null and Symbol /= Session.Error_Symbol then
Errors.Parser_Error (Errors.E401,
Line => Rule.Line,
Argument_1 => Name_Of (Symbol));
end if;
New_Rule := Rule_Access (Symbol.Rule);
while New_Rule /= null loop
New_Config := Add (New_Rule, Dot => 0);
Last_RHS := False;
Debugs.Debug (True, "Rule.RHS.Length: " & Rule.RHS.Length'Image);
for I in Dot + 1 .. Rule.RHS.Last_Index loop
if I = Rule.RHS.Last_Index then
Last_RHS := True;
end if;
RHS_Symbol := Symbol_Access (Rule.RHS.Element (I));
case RHS_Symbol.Kind is
when Terminal =>
Dummy := Set_Add (New_Config.Follow_Set, RHS_Symbol.Index);
exit;
when Multi_Terminal =>
for K in
Integer range 0 .. Integer (RHS_Symbol.Sub_Symbol.Length) - 1
loop
Dummy := Set_Add (New_Config.Follow_Set,
RHS_Symbol.Sub_Symbol.Element (K).Index);
end loop;
exit;
when others =>
Dummy := Set_Union (New_Config.Follow_Set, RHS_Symbol.First_Set);
exit when not RHS_Symbol.Lambda;
end case;
end loop;
if Last_RHS then
Config.Forward_PL.Append (Prop_Links.Config_Access (New_Config));
end if;
New_Rule := Rule_Access (New_Rule.Next_LHS);
end loop;
end if;
end if;
end;
Configuration_Lists.Next (Config_Pos);
end loop;
end Closure;
procedure Sort is
package Config_Sorts is
new Configuration_Lists.Generic_Sorting;
begin
Config_Sorts.Sort (Config_List);
end Sort;
procedure Sort_Basis is
package Basis_Sorts is
new Configuration_Lists.Generic_Sorting;
begin
Basis_Sorts.Sort (Basis_List);
end Sort_Basis;
function Xreturn return Configs.Config_Access
is
Old : constant Configs.Config_Access := Config_List.First_Element;
begin
Config_List.Clear;
return Old;
end Xreturn;
function Basis return Configs.Config_Access
is
Old : constant Configs.Config_Access := Basis_List.First_Element;
begin
Basis_List.Clear;
return Old;
end Basis;
procedure Eat (Config : in out Configs.Config_Access)
is
use Symbol_Sets;
use Configs;
Next_Config : Config_Access;
begin
while Config /= null loop
Next_Config := Config.Next;
pragma Assert (Config.Forward_PL.Is_Empty);
pragma Assert (Config.Backward_PL.Is_Empty);
if Config.Follow_Set /= Null_Set then
Symbol_Sets.Set_Free (Config.Follow_Set);
end if;
Config_Delete (Config);
Config := Next_Config;
end loop;
end Eat;
procedure Reset
is
begin
Config_List.Clear;
Basis_List.Clear;
Config_Tables.Clear;
end Reset;
function Config_New return Configs.Config_Access is
begin
return new Configs.Config_Record;
end Config_New;
procedure Config_Delete (Config : in out Configs.Config_Access)
is
use Configs;
procedure Free is
new Ada.Unchecked_Deallocation (Object => Config_Record,
Name => Config_Access);
begin
Free (Config);
Config := null;
end Config_Delete;
end Config_Lists;
|
with Ada.Text_IO, Ada.Calendar, System;
use Ada.Text_IO, Ada.Calendar, System;
procedure Planificador_Ciclico_Con_Prioridades is
Comienzo : Time := Clock; -- hora de comienzo
-- Tarea principal
task Principal is
entry Ejecutar (Id: in Integer; Tiempo : in Integer);
end Principal;
task body Principal is
Semaforo : Integer := 1;
begin
Put_Line("Principal - preparada");
loop
select
when Semaforo = 1 =>
accept Ejecutar (Id : in Integer; Tiempo : in Integer) do
Semaforo := 0;
Put_Line("+++Inicio Tarea" & Integer'Image(Id) & " " &
Duration'Image(Clock-Comienzo));
delay Duration(Tiempo);
Put_Line("+++Fin Tarea" & Integer'Image(Id) & " " &
Duration'Image(Clock-Comienzo));
Semaforo := 1;
end Ejecutar;
end select;
end loop;
end Principal;
-- Tareas dinamicas periodicas del planificador
task type Tarea_Periodica(Id: Integer; T: Integer; D: Integer; C: Integer;
Pri: System.Priority) is
pragma Priority(Pri);
end Tarea_Periodica;
type Tarea_Dinamica is access Tarea_Periodica;
-- Cuerpo de las Tareas Periodicas
task body Tarea_Periodica is
Periodo : constant Duration := Duration(T); -- Segundos
Proximo_Periodo : Time := Clock;
begin
Loopgg
-- Acciones Tarea
Principal.Ejecutar(Id, C);
-- Calculo del tiempo de nueva accion
Proximo_Periodo := Proximo_Periodo + Periodo;
delay until Proximo_Periodo;
end loop;
end Tarea_Periodica;
-- Definicion de las tareas
Tarea_1 : Tarea_Dinamica;
Tarea_2 : Tarea_Dinamica;
Tarea_3 : Tarea_Dinamica;
begin
Put_Line("Inicio Planificador con prioridades");
-- Inicio de las tareas (Id, Periodo, Plazo, Tiempo de Ejecucion, Prioridad)
Tarea_1 := new Tarea_Periodica(1, 4, 4, 1, 6);
Tarea_2 := new Tarea_Periodica(2, 5, 5, 2, 9);
Tarea_3 := new Tarea_Periodica(3, 10, 10, 1, 12);
end Planificador_Ciclico_Con_Prioridades;
|
-- { dg-do run }
with Text_IO; use Text_IO;
with Self; use Self;
procedure Test_Self is
It : Lim := G (5);
begin
Change (It, 10);
if Get (It) /= 35 then
Put_Line ("self-referential aggregate incorrectly built");
end if;
end Test_Self;
|
with Ada.Text_Io; use Ada.Text_Io;
procedure Read_Stream is
Line : String(1..10);
Length : Natural;
begin
while not End_Of_File loop
Get_Line(Line, Length); -- read up to 10 characters at a time
Put(Line(1..Length));
-- The current line of input data may be longer than the string receiving the data.
-- If so, the current input file column number will be greater than 0
-- and the extra data will be unread until the next iteration.
-- If not, we have read past an end of line marker and col will be 1
if Col(Current_Input) = 1 then
New_Line;
end if;
end loop;
end Read_Stream;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
package body GBA.DMA.Generic_Interfaces is
Use_Full_Word : constant Boolean :=
(Element_Type'Size >= 32 and then Element_Type'Size mod 32 = 0);
function Memset_Info ( Count : Transfer_Count_Type ) return Transfer_Info is
(( Dest_Adjustment => Increment
, Source_Adjustment => Fixed
, Repeat => False
, Copy_Unit_Size => (if Use_Full_Word then Word else Half_Word)
, Timing => Start_Immediately
, Enable_Interrupt => False
, Enabled => True
, Transfer_Count => Count * (if Use_Full_Word then Element_Type'Size / 32 else Element_Type'Size / 16)
));
function Memcopy_Info ( Length : Transfer_Count_Type ) return Transfer_Info is
(( Dest_Adjustment => Increment
, Source_Adjustment => Increment
, Repeat => False
, Copy_Unit_Size => (if Use_Full_Word then Word else Half_Word)
, Timing => Start_Immediately
, Enable_Interrupt => False
, Enabled => True
, Transfer_Count => Length * (if Use_Full_Word then Element_Type'Size / 32 else Element_Type'Size / 16)
));
procedure Memset ( Channel : Channel_ID; Source, Dest : Address; Count : Transfer_Count_Type ) is
Info : constant Transfer_Info := Memset_Info(Count);
begin
Setup_DMA_Transfer (Channel, Source, Dest, Info);
end;
procedure Memcopy ( Channel : Channel_ID; Source, Dest : Address; Length : Transfer_Count_Type ) is
Info : constant Transfer_Info := Memcopy_Info(Length);
begin
Setup_DMA_Transfer (Channel, Source, Dest, Info);
end;
end GBA.DMA.Generic_Interfaces;
|
-- { dg-do compile { target i?86-*-* x86_64-*-* } }
-- { dg-options "-O3 -msse2 -fdump-tree-vect-details" }
package body Vect13 is
function "+" (X, Y : Sarray) return Sarray is
R : Sarray;
begin
for I in Sarray'Range loop
pragma Loop_Optimize (Vector);
R(I) := X(I) + Y(I);
end loop;
return R;
end;
procedure Add (X, Y : Sarray; R : out Sarray) is
begin
for I in Sarray'Range loop
pragma Loop_Optimize (Vector);
R(I) := X(I) + Y(I);
end loop;
end;
end Vect13;
-- { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.