content stringlengths 23 1.05M |
|---|
-- This test shows the usage of various alinment and size clauses.
-- It was taken from an online example, but heavily modified.
with System;
procedure Alignment_Component_Clause is
Word : constant := 4; -- storage element is byte, 4 bytes per word
type State is (A,M,W,P);
type Mode is (Fix, Dec, Exp, Signif);
type Byte_Mask is array (0..7) of Boolean;
type State_Mask is array (State) of Boolean;
type Mode_Mask is array (Mode) of Boolean;
type Program_Status_Word is
record
System_Mask : Integer range 0 .. 4;
Protection_Key : Integer range 0 .. 3;
Machine_State : Integer range 0 .. 3;
Interrupt_Cause : Integer range 0 .. 65535;
Ilc : Integer range 0 .. 3;
Cc : Integer range 0 .. 3;
Program_Mask : Integer range 0 .. 3;
Inst_Address : Integer range 0 .. 65535;
end record;
for Program_Status_Word use
record
System_Mask at 0*Word range 0 .. 7;
Protection_Key at 0*Word range 10 .. 11; -- bits 8,9 unused
Machine_State at 0*Word range 12 .. 15;
Interrupt_Cause at 0*Word range 16 .. 31;
Ilc at 1*Word range 0 .. 1; -- second word
Cc at 1*Word range 2 .. 3;
Program_Mask at 1*Word range 4 .. 7;
Inst_Address at 1*Word range 8 .. 31;
end record;
for Program_Status_Word'Size use 24*System.Storage_Unit;
for Program_Status_Word'Alignment use 8;
begin
null;
end Alignment_Component_Clause;
|
-----------------------------------------------------------
-- --
-- IRIS --
-- --
-- Copyright (c) 2017, John Leimon --
-- --
-- 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. --
-----------------------------------------------------------
WITH ADA.CALENDAR; USE ADA.CALENDAR;
WITH ADA.COMMAND_LINE; USE ADA.COMMAND_LINE;
WITH ADA.DIRECTORIES; USE ADA.DIRECTORIES;
WITH ADA.EXCEPTIONS; USE ADA.EXCEPTIONS;
WITH ADA.TASK_IDENTIFICATION; USE ADA.TASK_IDENTIFICATION;
WITH ADA.TEXT_IO; USE ADA.TEXT_IO;
WITH ADA.STRINGS.UNBOUNDED; USE ADA.STRINGS.UNBOUNDED;
WITH ADA.STRINGS.FIXED; USE ADA.STRINGS.FIXED;
WITH GNAT.CALENDAR.TIME_IO;
WITH INTERFACES.C; USE INTERFACES.C;
WITH SIGINT_HANDLER; USE SIGINT_HANDLER;
PROCEDURE IRIS IS
PACKAGE FLOAT_TEXT_IO IS NEW ADA.TEXT_IO.FLOAT_IO (FLOAT);
TYPE IMAGE_ID IS (A, B);
INVALID_ARGUMENT : EXCEPTION;
IMAGE_A_FILENAME : CONSTANT STRING := ".IMAGE_A.jpg";
IMAGE_B_FILENAME : CONSTANT STRING := ".IMAGE_B.jpg";
IPC_FILENAME : CONSTANT STRING := ".iris";
LOG_FILENAME : CONSTANT
GNAT.CALENDAR.TIME_IO.PICTURE_STRING
:= "%Y%m%d-%H%M-%S.%i.jpg";
DIFF_FILENAME : CONSTANT STRING := ".DELTA.jpg";
TRASH_OUTPUTS : CONSTANT STRING := " >&2 2> /dev/null";
CAPTURE_COUNT : NATURAL := 10;
TRIGGER_THRESHOLD : FLOAT := 1.0;
START_VIEWERS : BOOLEAN := FALSE;
MOTION_DEBUG : CONSTANT BOOLEAN := TRUE;
CAPTURE_DEBUG : CONSTANT BOOLEAN := FALSE;
IMAGE_COMPARE_DEBUG : CONSTANT BOOLEAN := FALSE;
NEXT_IMAGE : IMAGE_ID := A;
A_CAPTURE_TIME : TIME;
B_CAPTURE_TIME : TIME;
HELP_MODE : BOOLEAN := FALSE;
CAMERA_NAME : UNBOUNDED_STRING :=
TO_UNBOUNDED_STRING ("NO NAME");
LOG_DIRECTORY : UNBOUNDED_STRING :=
TO_UNBOUNDED_STRING (".");
TASK TYPE VIEWER IS
ENTRY START (IMAGE_FILENAME : IN STRING;
ID : OUT TASK_ID);
END VIEWER;
TYPE VIEWER_ACCESS IS ACCESS ALL VIEWER;
LIVE_VIEWER : VIEWER_ACCESS;
DIFF_VIEWER : VIEWER_ACCESS;
LIVE_VIEWER_ID : TASK_ID;
DIFF_VIEWER_ID : TASK_ID;
PROCEDURE SYSTEM (ARGUMENTS : CHAR_ARRAY);
PRAGMA IMPORT (C, SYSTEM, "system");
---------------
-- PUT_USAGE --
---------------
PROCEDURE PUT_USAGE
IS
BEGIN
PUT ("usage: iris -vh [-cCamera_Name] ");
PUT ("[-tTrigger_Threshold] ");
PUT ("[-ccapture_Count ] ");
PUT ("[-lLog_Directory ");
NEW_LINE;
END PUT_USAGE;
--------------
-- PUT_HELP --
--------------
PROCEDURE PUT_HELP
IS
BEGIN
PUT_USAGE;
PUT_LINE (" Camera_Name: Camera name added to banner of");
PUT_LINE (" logged images.");
PUT_LINE (" default: NO NAME");
PUT_LINE (" Trigger_Threshold: Minimum percent difference between two");
PUT_LINE (" images to trigger image logging.");
PUT_LINE (" default: 1.0");
PUT_LINE (" Capture_Count: Number of consecutive images to capture");
PUT_LINE (" when image capture has been triggered.");
PUT_LINE (" default: 10");
PUT_LINE (" Log_Directory: Path to store captured images on trigger.");
PUT_LINE (" default: .");
PUT_LINE (" -h Show this help text");
PUT_LINE (" -v Start viewers (experimental)");
END PUT_HELP;
-----------------
-- FILE_EXISTS --
-----------------
FUNCTION FILE_EXISTS
(FILE_NAME : STRING)
RETURN BOOLEAN
IS
THE_FILE : FILE_TYPE;
BEGIN
OPEN (THE_FILE, IN_FILE, FILE_NAME);
CLOSE (THE_FILE);
RETURN TRUE;
EXCEPTION
WHEN ADA.TEXT_IO.NAME_ERROR =>
RETURN FALSE;
END FILE_EXISTS;
------------
-- VIEWER --
------------
TASK BODY VIEWER IS
ITERATION_COUNT : NATURAL := 0;
IMAGE : UNBOUNDED_STRING;
BEGIN
ACCEPT START (IMAGE_FILENAME : IN STRING;
ID : OUT TASK_ID)
DO
IMAGE := TO_UNBOUNDED_STRING (IMAGE_FILENAME);
ID := CURRENT_TASK;
END START;
LOOP
EXIT WHEN FILE_EXISTS (TO_STRING (IMAGE));
DELAY 0.1;
END LOOP;
SYSTEM (TO_C ("feh --reload 0.1 " & TO_STRING (IMAGE) & TRASH_OUTPUTS));
EXCEPTION
WHEN ERROR: OTHERS =>
PUT ("IRIS.VIEWER: ");
PUT (EXCEPTION_INFORMATION (ERROR));
END VIEWER;
-------------
-- CAPTURE --
-------------
PROCEDURE CAPTURE
(FILE_NAME : STRING)
IS
IPC_FILE : FILE_TYPE;
BEFORE : TIME;
AFTER : TIME;
COMMAND : STRING := "fswebcam -S2 --subtitle " &
"""" &
TO_STRING (CAMERA_NAME) &
""" " &
FILE_NAME &
TRASH_OUTPUTS;
BEGIN
BEFORE := CLOCK;
SYSTEM (TO_C (COMMAND));
AFTER := CLOCK;
IF CAPTURE_DEBUG THEN
PUT_LINE (COMMAND);
PUT_LINE ("Capture completed in" &
DURATION'IMAGE (AFTER - BEFORE) &
" seconds");
END IF;
END CAPTURE;
-------------
-- COMPARE --
-------------
FUNCTION COMPARE
RETURN FLOAT
IS
BEFORE : TIME;
AFTER : TIME;
IPC_FILE : FILE_TYPE;
OUTPUT : FLOAT;
BEGIN
IF NOT FILE_EXISTS (IMAGE_A_FILENAME) OR
NOT FILE_EXISTS (IMAGE_B_FILENAME)
THEN
RETURN 0.0;
END IF;
BEFORE := CLOCK;
DECLARE
COMMAND : STRING :=
"compare -compose Src " &
"-fuzz 35% " &
"-highlight-color Green " &
"-lowlight-color Black " &
"-metric MAE " &
IMAGE_A_FILENAME & " " &
IMAGE_B_FILENAME &
" " & DIFF_FILENAME & " 2> " &
IPC_FILENAME;
BEGIN
IF IMAGE_COMPARE_DEBUG THEN
PUT_LINE (COMMAND);
END IF;
SYSTEM (TO_C (COMMAND));
END;
AFTER := CLOCK;
IF IMAGE_COMPARE_DEBUG THEN
PUT_LINE ("Compare completed in" & DURATION'IMAGE(AFTER - BEFORE) &
" seconds");
END IF;
OPEN (IPC_FILE, IN_FILE, IPC_FILENAME);
DECLARE
RESULT : STRING := GET_LINE (IPC_FILE);
SPACE_INDEX : NATURAL;
BEGIN
SPACE_INDEX := INDEX (RESULT, " ");
IF SPACE_INDEX = 0 THEN
-- ERROR: SPACE CHARACTER LITERAL NOT FOUND --
PUT_LINE ("IRIS: Unknown compare string found """ &
RESULT & """");
OUTPUT := 0.0;
ELSE
OUTPUT := FLOAT'VALUE (RESULT (RESULT'FIRST .. SPACE_INDEX - 1));
END IF;
END;
CLOSE (IPC_FILE);
RETURN OUTPUT;
END COMPARE;
-------------------------
-- CAPTURE_AND_COMPARE --
-------------------------
PROCEDURE CAPTURE_AND_COMPARE
(DIFFERENCE : OUT FLOAT)
IS
BEGIN
DECLARE
BEGIN
CASE NEXT_IMAGE IS
WHEN A =>
CAPTURE (IMAGE_A_FILENAME);
A_CAPTURE_TIME := CLOCK;
NEXT_IMAGE := B;
WHEN B =>
CAPTURE (IMAGE_B_FILENAME);
B_CAPTURE_TIME := CLOCK;
NEXT_IMAGE := A;
END CASE;
END;
DIFFERENCE := COMPARE;
END CAPTURE_AND_COMPARE;
----------------------------
-- SURVEILLANCE_ITERATION --
----------------------------
PREV_DIFF_AMOUNT : FLOAT := 0.0;
CAPTURES_REMAINING : NATURAL := 0;
PROCEDURE SURVEILLANCE_ITERATION
IS
DIFF_AMOUNT : FLOAT := 0.0;
BEGIN
-- CAPTURE AN IMAGE. IF THIS IS NOT THE FIRST IMAGE --
-- CAPTURED THEN COMPARE IT WITH THE PREVIOUS IMAGE. --
-- IF THE PERCENT DIFFERENCE BETWEEN THIS IMAGE AND --
-- THE PREVIOUS IMAGE IS ABOVE THE USER DEFINED --
-- THRESHOLD THEN START LOGGING CONSECUTIVE IMAGES. --
-- THE NUMBER OF IMAGES LOGGED IS USER DEFINED. --
CAPTURE_AND_COMPARE (DIFF_AMOUNT);
IF PREV_DIFF_AMOUNT /= 0.0 THEN
DECLARE
PERCENT_CHANGE : FLOAT :=
ABS (DIFF_AMOUNT - PREV_DIFF_AMOUNT) / PREV_DIFF_AMOUNT;
BEGIN
IF MOTION_DEBUG THEN
PUT ("Motion Sensor:");
FLOAT_TEXT_IO.PUT (DIFF_AMOUNT, 6, 0, 0);
PUT (" ");
FLOAT_TEXT_IO.PUT (PERCENT_CHANGE, 2, 2, 0);
NEW_LINE;
END IF;
IF PERCENT_CHANGE > TRIGGER_THRESHOLD THEN
CAPTURES_REMAINING := CAPTURE_COUNT;
PUT_LINE (" [CAPTURE TRIGGERED]");
END IF;
END;
END IF;
PREV_DIFF_AMOUNT := DIFF_AMOUNT;
DECLARE
USE GNAT.CALENDAR.TIME_IO;
BEGIN
IF CAPTURES_REMAINING = CAPTURE_COUNT THEN
COPY_FILE (IMAGE_A_FILENAME,
TO_STRING (LOG_DIRECTORY) &
"/" &
IMAGE (A_CAPTURE_TIME, LOG_FILENAME));
COPY_FILE (IMAGE_B_FILENAME,
TO_STRING (LOG_DIRECTORY) &
"/" &
IMAGE (B_CAPTURE_TIME, LOG_FILENAME));
CAPTURES_REMAINING := CAPTURES_REMAINING - 1;
ELSIF CAPTURES_REMAINING > 0 THEN
CASE NEXT_IMAGE IS
WHEN A =>
COPY_FILE (IMAGE_B_FILENAME,
TO_STRING (LOG_DIRECTORY) &
"/" &
IMAGE (B_CAPTURE_TIME, LOG_FILENAME));
WHEN B =>
COPY_FILE (IMAGE_A_FILENAME,
TO_STRING (LOG_DIRECTORY) &
"/" &
IMAGE (A_CAPTURE_TIME, LOG_FILENAME));
END CASE;
CAPTURES_REMAINING := CAPTURES_REMAINING - 1;
END IF;
END;
END SURVEILLANCE_ITERATION;
-----------------------
-- SET_START_VIEWERS --
-----------------------
FUNCTION SET_START_VIEWERS
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-v"
THEN
START_VIEWERS := TRUE;
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SET_START_VIEWERS;
-----------------------
-- SET_LOG_DIRECTORY --
-----------------------
FUNCTION SET_LOG_DIRECTORY
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-l"
THEN
LOG_DIRECTORY := TO_UNBOUNDED_STRING
(ARGUMENT (ARGUMENT'FIRST + 2 .. ARGUMENT'LAST));
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SET_LOG_DIRECTORY;
---------------------
-- SET_CAMERA_NAME --
---------------------
FUNCTION SET_CAMERA_NAME
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-c"
THEN
CAMERA_NAME := TO_UNBOUNDED_STRING
(ARGUMENT (ARGUMENT'FIRST + 2 .. ARGUMENT'LAST));
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SET_CAMERA_NAME;
-----------------------
-- SET_CAPTURE_COUNT --
-----------------------
FUNCTION SET_CAPTURE_COUNT
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-c"
THEN
CAPTURE_COUNT := NATURAL'VALUE
(ARGUMENT (ARGUMENT'FIRST + 2 .. ARGUMENT'LAST));
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SET_CAPTURE_COUNT;
---------------------------
-- SET_TRIGGER_THRESHOLD --
---------------------------
FUNCTION SET_TRIGGER_THRESHOLD
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-t"
THEN
TRIGGER_THRESHOLD := FLOAT'VALUE
(ARGUMENT (ARGUMENT'FIRST + 2 .. ARGUMENT'LAST));
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SET_TRIGGER_THRESHOLD;
---------------
-- SHOW_HELP --
---------------
FUNCTION SHOW_HELP
(ARGUMENT : STRING)
RETURN BOOLEAN
IS
BEGIN
IF ARGUMENT (ARGUMENT'FIRST .. ARGUMENT'FIRST + 1) = "-h"
THEN
PUT_HELP;
HELP_MODE := TRUE;
RETURN TRUE;
END IF;
RETURN FALSE;
EXCEPTION
WHEN CONSTRAINT_ERROR =>
RETURN FALSE;
END SHOW_HELP;
-----------------------
-- PROCESS_ARGUMENTS --
-----------------------
PROCEDURE PROCESS_ARGUMENTS
IS
BEGIN
FOR INDEX IN NATURAL RANGE 1 .. ARGUMENT_COUNT LOOP
IF SET_CAMERA_NAME (ARGUMENT (INDEX)) THEN
NULL;
ELSIF SET_TRIGGER_THRESHOLD (ARGUMENT (INDEX)) THEN
NULL;
ELSIF SET_CAPTURE_COUNT (ARGUMENT (INDEX)) THEN
NULL;
ELSIF SET_LOG_DIRECTORY (ARGUMENT (INDEX)) THEN
NULL;
ELSIF SET_START_VIEWERS (ARGUMENT (INDEX)) THEN
NULL;
ELSIF SHOW_HELP (ARGUMENT (INDEX)) THEN
NULL;
ELSE
PUT ("Invalid argument: ");
PUT_LINE (ARGUMENT (INDEX));
RAISE INVALID_ARGUMENT;
END IF;
END LOOP;
END PROCESS_ARGUMENTS;
------------------
-- PUT_SETTINGS --
------------------
PROCEDURE PUT_SETTINGS
IS
BEGIN
PUT ("Camera Name : ");
PUT_LINE (TO_STRING (CAMERA_NAME));
PUT ("Trigger Threshold :");
FLOAT_TEXT_IO.PUT (TRIGGER_THRESHOLD, 2, 1, 0);
PUT_LINE (" %");
PUT ("Capture Count :");
PUT_LINE (NATURAL'IMAGE (CAPTURE_COUNT));
PUT ("Image Log Directory : ");
PUT_LINE (TO_STRING (LOG_DIRECTORY));
NEW_LINE;
END PUT_SETTINGS;
BEGIN
PROCESS_ARGUMENTS;
IF HELP_MODE THEN
RETURN;
END IF;
PUT_SETTINGS;
IF START_VIEWERS THEN
LIVE_VIEWER := NEW VIEWER;
DIFF_VIEWER := NEW VIEWER;
LIVE_VIEWER.START (IMAGE_A_FILENAME, LIVE_VIEWER_ID);
DIFF_VIEWER.START (DIFF_FILENAME, DIFF_VIEWER_ID);
END IF;
LOOP
SURVEILLANCE_ITERATION;
EXIT WHEN SIGINT;
END LOOP;
EXCEPTION
WHEN INVALID_ARGUMENT =>
PUT_USAGE;
WHEN ERROR: OTHERS =>
PUT ("IRIS: ");
PUT (EXCEPTION_INFORMATION (ERROR));
END IRIS;
|
with RASCAL.Toolbox; use RASCAL.Toolbox;
with RASCAL.OS; use RASCAL.OS;
with RASCAL.Error; use RASCAL.Error;
with RASCAL.MessageTrans; use RASCAL.MessageTrans;
with RASCAL.WimpTask; use RASCAL.WimpTask;
with Interfaces.C; use Interfaces.C;
with Main; use Main;
with Ada.Exceptions;
with Reporter;
package body Controller_Error is
--
package Toolbox renames RASCAL.Toolbox;
package OS renames RASCAL.OS;
package Error renames RASCAL.Error;
package MessageTrans renames RASCAL.MessageTrans;
package WimpTask renames RASCAL.WimpTask;
--
procedure Handle (The : in TEL_Toolbox_Error) is
E : Error_Pointer := WimpTask.Get_Error (Main_Task);
M : Error_Message_Pointer := new Error_Message_Type;
Result : Error_Return_Type := XButton1;
TB_Error : String := To_Ada (The.Event.all.Message);
begin
M.all.Message(1..TB_Error'Length) := TB_Error;
M.all.Category := Warning;
M.all.Flags := Error_Flag_OK;
Result := Error.Show_Message (E,M);
exception
when e2: others => Report_Error("TOOLBOXERROR",Ada.Exceptions.Exception_Information (e2));
end Handle;
--
end Controller_Error;
|
--- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with AdaBase.Results.Generic_Converters;
package AdaBase.Results.Converters is
package GEN renames AdaBase.Results.Generic_Converters;
-------------
-- NByte 0 --
-------------
function convert (nv : NByte0) return NByte1;
function convert (nv : NByte0) return NByte2;
function convert (nv : NByte0) return NByte3;
function convert (nv : NByte0) return NByte4;
function convert (nv : NByte0) return NByte8;
function convert (nv : NByte0) return Byte1;
function convert (nv : NByte0) return Byte2;
function convert (nv : NByte0) return Byte3;
function convert (nv : NByte0) return Byte4;
function convert (nv : NByte0) return Byte8;
function convert (nv : NByte0) return Real9;
function convert (nv : NByte0) return Real18;
function convert (nv : NByte0) return String;
function convert (nv : NByte0) return Wide_String;
function convert (nv : NByte0) return Wide_Wide_String;
function convert (nv : NByte0) return Bits;
function convert (nv : NByte0) return Chain;
function convert (nv : NByte0) return Textual;
function cv2utf8 (nv : NByte0) return Text_UTF8;
-------------
-- NByte 1 --
-------------
function convert (nv : NByte1) return NByte0;
function convert (nv : NByte1) return NByte2;
function convert (nv : NByte1) return NByte3;
function convert (nv : NByte1) return NByte4;
function convert (nv : NByte1) return NByte8;
function convert (nv : NByte1) return Byte1;
function convert (nv : NByte1) return Byte2;
function convert (nv : NByte1) return Byte3;
function convert (nv : NByte1) return Byte4;
function convert (nv : NByte1) return Byte8;
function convert (nv : NByte1) return Real9;
function convert (nv : NByte1) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => NByte1);
function convert is new GEN.convert2str1 (IntType => NByte1);
function convert is new GEN.convert2str2 (IntType => NByte1);
function convert is new GEN.convert2str3 (IntType => NByte1);
function convert is new GEN.convert2bits (ModType => NByte1, width => 7);
function convert is new GEN.convert2chain (ModType => NByte1, width => 1);
function convert (nv : NByte1) return Textual;
-------------
-- NByte 2 --
-------------
function convert (nv : NByte2) return NByte0;
function convert (nv : NByte2) return NByte1;
function convert (nv : NByte2) return NByte3;
function convert (nv : NByte2) return NByte4;
function convert (nv : NByte2) return NByte8;
function convert (nv : NByte2) return Byte1;
function convert (nv : NByte2) return Byte2;
function convert (nv : NByte2) return Byte3;
function convert (nv : NByte2) return Byte4;
function convert (nv : NByte2) return Byte8;
function convert (nv : NByte2) return Real9;
function convert (nv : NByte2) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => NByte2);
function convert is new GEN.convert2str1 (IntType => NByte2);
function convert is new GEN.convert2str2 (IntType => NByte2);
function convert is new GEN.convert2str3 (IntType => NByte2);
function convert is new GEN.convert2bits (ModType => NByte2, width => 15);
function convert is new GEN.convert2chain (ModType => NByte2, width => 2);
function convert (nv : NByte2) return Textual;
-------------
-- NByte 3 --
-------------
function convert (nv : NByte3) return NByte0;
function convert (nv : NByte3) return NByte1;
function convert (nv : NByte3) return NByte2;
function convert (nv : NByte3) return NByte4;
function convert (nv : NByte3) return NByte8;
function convert (nv : NByte3) return Byte1;
function convert (nv : NByte3) return Byte2;
function convert (nv : NByte3) return Byte3;
function convert (nv : NByte3) return Byte4;
function convert (nv : NByte3) return Byte8;
function convert (nv : NByte3) return Real9;
function convert (nv : NByte3) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => NByte3);
function convert is new GEN.convert2str1 (IntType => NByte3);
function convert is new GEN.convert2str2 (IntType => NByte3);
function convert is new GEN.convert2str3 (IntType => NByte3);
function convert is new GEN.convert2bits (ModType => NByte3, width => 23);
function convert is new GEN.convert2chain (ModType => NByte3, width => 3);
function convert (nv : NByte3) return Textual;
-------------
-- NByte 4 --
-------------
function convert (nv : NByte4) return NByte0;
function convert (nv : NByte4) return NByte1;
function convert (nv : NByte4) return NByte2;
function convert (nv : NByte4) return NByte3;
function convert (nv : NByte4) return NByte8;
function convert (nv : NByte4) return Byte1;
function convert (nv : NByte4) return Byte2;
function convert (nv : NByte4) return Byte3;
function convert (nv : NByte4) return Byte4;
function convert (nv : NByte4) return Byte8;
function convert (nv : NByte4) return Real9;
function convert (nv : NByte4) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => NByte4);
function convert is new GEN.convert2str1 (IntType => NByte4);
function convert is new GEN.convert2str2 (IntType => NByte4);
function convert is new GEN.convert2str3 (IntType => NByte4);
function convert is new GEN.convert2bits (ModType => NByte4, width => 31);
function convert is new GEN.convert2chain (ModType => NByte4, width => 4);
function convert (nv : NByte4) return Textual;
-------------
-- NByte 8 --
-------------
function convert (nv : NByte8) return NByte0;
function convert (nv : NByte8) return NByte1;
function convert (nv : NByte8) return NByte2;
function convert (nv : NByte8) return NByte3;
function convert (nv : NByte8) return NByte4;
function convert (nv : NByte8) return Byte1;
function convert (nv : NByte8) return Byte2;
function convert (nv : NByte8) return Byte3;
function convert (nv : NByte8) return Byte4;
function convert (nv : NByte8) return Byte8;
function convert (nv : NByte8) return Real9;
function convert (nv : NByte8) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => NByte8);
function convert is new GEN.convert2str1 (IntType => NByte8);
function convert is new GEN.convert2str2 (IntType => NByte8);
function convert is new GEN.convert2str3 (IntType => NByte8);
function convert is new GEN.convert2bits (ModType => NByte8, width => 63);
function convert is new GEN.convert2chain (ModType => NByte8, width => 8);
function convert (nv : NByte8) return Textual;
------------
-- Byte 1 --
------------
function convert (nv : Byte1) return NByte0;
function convert (nv : Byte1) return NByte1;
function convert (nv : Byte1) return NByte2;
function convert (nv : Byte1) return NByte3;
function convert (nv : Byte1) return NByte4;
function convert (nv : Byte1) return NByte8;
function convert (nv : Byte1) return Byte2;
function convert (nv : Byte1) return Byte3;
function convert (nv : Byte1) return Byte4;
function convert (nv : Byte1) return Byte8;
function convert (nv : Byte1) return Real9;
function convert (nv : Byte1) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => Byte1);
function convert is new GEN.convert2str1 (IntType => Byte1);
function convert is new GEN.convert2str2 (IntType => Byte1);
function convert is new GEN.convert2str3 (IntType => Byte1);
function convert (nv : Byte1) return Textual;
-----------
-- Byte2 --
-----------
function convert (nv : Byte2) return NByte0;
function convert (nv : Byte2) return NByte1;
function convert (nv : Byte2) return NByte2;
function convert (nv : Byte2) return NByte3;
function convert (nv : Byte2) return NByte4;
function convert (nv : Byte2) return NByte8;
function convert (nv : Byte2) return Byte1;
function convert (nv : Byte2) return Byte3;
function convert (nv : Byte2) return Byte4;
function convert (nv : Byte2) return Byte8;
function convert (nv : Byte2) return Real9;
function convert (nv : Byte2) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => Byte2);
function convert is new GEN.convert2str1 (IntType => Byte2);
function convert is new GEN.convert2str2 (IntType => Byte2);
function convert is new GEN.convert2str3 (IntType => Byte2);
function convert (nv : Byte2) return Textual;
-----------
-- Byte3 --
-----------
function convert (nv : Byte3) return NByte0;
function convert (nv : Byte3) return NByte1;
function convert (nv : Byte3) return NByte2;
function convert (nv : Byte3) return NByte3;
function convert (nv : Byte3) return NByte4;
function convert (nv : Byte3) return NByte8;
function convert (nv : Byte3) return Byte1;
function convert (nv : Byte3) return Byte2;
function convert (nv : Byte3) return Byte4;
function convert (nv : Byte3) return Byte8;
function convert (nv : Byte3) return Real9;
function convert (nv : Byte3) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => Byte3);
function convert is new GEN.convert2str1 (IntType => Byte3);
function convert is new GEN.convert2str2 (IntType => Byte3);
function convert is new GEN.convert2str3 (IntType => Byte3);
function convert (nv : Byte3) return Textual;
-----------
-- Byte4 --
-----------
function convert (nv : Byte4) return NByte0;
function convert (nv : Byte4) return NByte1;
function convert (nv : Byte4) return NByte2;
function convert (nv : Byte4) return NByte3;
function convert (nv : Byte4) return NByte4;
function convert (nv : Byte4) return NByte8;
function convert (nv : Byte4) return Byte1;
function convert (nv : Byte4) return Byte2;
function convert (nv : Byte4) return Byte3;
function convert (nv : Byte4) return Byte8;
function convert (nv : Byte4) return Real9;
function convert (nv : Byte4) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => Byte4);
function convert is new GEN.convert2str1 (IntType => Byte4);
function convert is new GEN.convert2str2 (IntType => Byte4);
function convert is new GEN.convert2str3 (IntType => Byte4);
function convert (nv : Byte4) return Textual;
-----------
-- Byte8 --
-----------
function convert (nv : Byte8) return NByte0;
function convert (nv : Byte8) return NByte1;
function convert (nv : Byte8) return NByte2;
function convert (nv : Byte8) return NByte3;
function convert (nv : Byte8) return NByte4;
function convert (nv : Byte8) return NByte8;
function convert (nv : Byte8) return Byte1;
function convert (nv : Byte8) return Byte2;
function convert (nv : Byte8) return Byte3;
function convert (nv : Byte8) return Byte4;
function convert (nv : Byte8) return Real9;
function convert (nv : Byte8) return Real18;
function cv2utf8 is new GEN.convert2utf8 (IntType => Byte8);
function convert is new GEN.convert2str1 (IntType => Byte8);
function convert is new GEN.convert2str2 (IntType => Byte8);
function convert is new GEN.convert2str3 (IntType => Byte8);
function convert (nv : Byte8) return Textual;
-----------
-- Real9 --
-----------
function convert (nv : Real9) return Real18;
function cv2utf8 is new GEN.convert3utf8 (RealType => Real9);
function convert is new GEN.convert3str1 (RealType => Real9);
function convert is new GEN.convert3str2 (RealType => Real9);
function convert is new GEN.convert3str3 (RealType => Real9);
function convert (nv : Real9) return Textual;
------------
-- Real18 --
------------
function convert (nv : Real18) return Real9;
function cv2utf8 is new GEN.convert3utf8 (RealType => Real18);
function convert is new GEN.convert3str1 (RealType => Real18);
function convert is new GEN.convert3str2 (RealType => Real18);
function convert is new GEN.convert3str3 (RealType => Real18);
function convert (nv : Real18) return Textual;
------------
-- String --
------------
function convert (nv : Textual) return NByte0;
function convert is new GEN.convertstr (IntType => NByte1);
function convert is new GEN.convertstr (IntType => NByte2);
function convert is new GEN.convertstr (IntType => NByte3);
function convert is new GEN.convertstr (IntType => NByte4);
function convert is new GEN.convertstr (IntType => NByte8);
function convert is new GEN.convertstr (IntType => Byte1);
function convert is new GEN.convertstr (IntType => Byte2);
function convert is new GEN.convertstr (IntType => Byte3);
function convert is new GEN.convertstr (IntType => Byte4);
function convert is new GEN.convertstr (IntType => Byte8);
function convert is new GEN.convertst2 (RealType => Real9);
function convert is new GEN.convertst2 (RealType => Real18);
function cv2utf8 (nv : Textual) return Text_UTF8;
function convert (nv : Textual) return String;
function convert (nv : Textual) return Wide_String;
function convert (nv : Textual) return Wide_Wide_String;
function convert (nv : Textual) return AC.Time;
function convert (nv : Textual) return Chain;
function convert (nv : Textual) return Enumtype;
function convert (nv : Textual) return Settype;
function convert (nv : Textual) return Bits;
function convert (nv : String) return AC.Time;
function convert (nv : String) return Enumtype;
function convert (nv : String; fixed : Natural := 0) return Chain;
function convert (nv : String; fixed : Natural := 0) return Settype;
function convert (nv : String; fixed : Natural := 0) return Bits;
function convert (nv : String) return Wide_String;
function convert (nv : String) return Wide_Wide_String;
function cv2utf8 (nv : String) return Text_UTF8;
function cvu2str (nv : Textual) return Textual;
function cvu2str (nv : Text_UTF8) return String;
function cvu2str (nv : Text_UTF8) return Wide_String;
function cvu2str (nv : Text_UTF8) return Wide_Wide_String;
-----------------
-- Wide_String --
-----------------
function convert (nv : Textwide) return NByte0;
function convert is new GEN.convertst3 (IntType => NByte1);
function convert is new GEN.convertst3 (IntType => NByte2);
function convert is new GEN.convertst3 (IntType => NByte3);
function convert is new GEN.convertst3 (IntType => NByte4);
function convert is new GEN.convertst3 (IntType => NByte8);
function convert is new GEN.convertst3 (IntType => Byte1);
function convert is new GEN.convertst3 (IntType => Byte2);
function convert is new GEN.convertst3 (IntType => Byte3);
function convert is new GEN.convertst3 (IntType => Byte4);
function convert is new GEN.convertst3 (IntType => Byte8);
function convert is new GEN.convertst4 (RealType => Real9);
function convert is new GEN.convertst4 (RealType => Real18);
function convert (nv : Textwide) return String;
function convert (nv : Textwide) return Wide_String;
function convert (nv : Textwide) return Wide_Wide_String;
function convert (nv : Textwide) return AC.Time;
function convert (nv : Textwide) return Chain;
function convert (nv : Textwide) return Enumtype;
function convert (nv : Textwide) return Settype;
function convert (nv : Textwide) return Textual;
function convert (nv : Textwide) return Bits;
function cv2utf8 (nv : Textwide) return Text_UTF8;
----------------------
-- Wide_Wide_String --
----------------------
function convert (nv : Textsuper) return NByte0;
function convert is new GEN.convertst5 (IntType => NByte1);
function convert is new GEN.convertst5 (IntType => NByte2);
function convert is new GEN.convertst5 (IntType => NByte3);
function convert is new GEN.convertst5 (IntType => NByte4);
function convert is new GEN.convertst5 (IntType => NByte8);
function convert is new GEN.convertst5 (IntType => Byte1);
function convert is new GEN.convertst5 (IntType => Byte2);
function convert is new GEN.convertst5 (IntType => Byte3);
function convert is new GEN.convertst5 (IntType => Byte4);
function convert is new GEN.convertst5 (IntType => Byte8);
function convert is new GEN.convertst6 (RealType => Real9);
function convert is new GEN.convertst6 (RealType => Real18);
function convert (nv : Textsuper) return String;
function convert (nv : Textsuper) return Wide_String;
function convert (nv : Textsuper) return Wide_Wide_String;
function convert (nv : Textsuper) return AC.Time;
function convert (nv : Textsuper) return Chain;
function convert (nv : Textsuper) return Enumtype;
function convert (nv : Textsuper) return Settype;
function convert (nv : Textsuper) return Textual;
function convert (nv : Textsuper) return Bits;
function cv2utf8 (nv : Textsuper) return Text_UTF8;
----------
-- TIME --
----------
function convert (nv : AC.Time) return String;
function convert (nv : AC.Time) return Wide_String;
function convert (nv : AC.Time) return Wide_Wide_String;
function convert (nv : AC.Time) return Textual;
function cv2utf8 (nv : AC.Time) return Text_UTF8;
-----------------
-- ENUMERATION --
-----------------
function convert (nv : Enumtype) return String;
function convert (nv : Enumtype) return Wide_String;
function convert (nv : Enumtype) return Wide_Wide_String;
function convert (nv : Enumtype) return Textual;
function cv2utf8 (nv : Enumtype) return Text_UTF8;
----------------
-- BITS TYPE --
----------------
function convert (nv : Bits) return NByte0;
function convert is new GEN.convert_bits (ModType => NByte1, MSB => 7);
function convert is new GEN.convert_bits (ModType => NByte2, MSB => 15);
function convert is new GEN.convert_bits (ModType => NByte3, MSB => 23);
function convert is new GEN.convert_bits (ModType => NByte4, MSB => 31);
function convert is new GEN.convert_bits (ModType => NByte8, MSB => 63);
function convert (nv : Bits) return String;
function convert (nv : Bits) return Wide_String;
function convert (nv : Bits) return Wide_Wide_String;
function convert (nv : Bits) return Textual;
function convert (nv : Bits) return Chain;
------------------------
-- CHAIN (OF BYTES) --
------------------------
function convert (nv : Chain) return NByte0;
function convert is new GEN.convert_chain (ModType => NByte1, width => 1);
function convert is new GEN.convert_chain (ModType => NByte2, width => 2);
function convert is new GEN.convert_chain (ModType => NByte3, width => 3);
function convert is new GEN.convert_chain (ModType => NByte4, width => 4);
function convert is new GEN.convert_chain (ModType => NByte8, width => 8);
function convert (nv : Chain) return String;
function convert (nv : Chain) return Wide_String;
function convert (nv : Chain) return Wide_Wide_String;
function convert (nv : Chain) return Textual;
function convert (nv : Chain) return Bits;
---------------
-- SET TYPE --
---------------
function convert (nv : Settype) return String;
function convert (nv : Settype) return Wide_String;
function convert (nv : Settype) return Wide_Wide_String;
function convert (nv : Settype) return Textual;
function cv2utf8 (nv : Settype) return Text_UTF8;
end AdaBase.Results.Converters;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32G474xx.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package STM32_SVD.ADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- ISR_AWD array
type ISR_AWD_Field_Array is array (1 .. 3) of Boolean
with Component_Size => 1, Size => 3;
-- Type definition for ISR_AWD
type ISR_AWD_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AWD as a value
Val : HAL.UInt3;
when True =>
-- AWD as an array
Arr : ISR_AWD_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for ISR_AWD_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- interrupt and status register
type ISR_Register is record
-- ADRDY
ADRDY : Boolean := False;
-- EOSMP
EOSMP : Boolean := False;
-- EOC
EOC : Boolean := False;
-- EOS
EOS : Boolean := False;
-- OVR
OVR : Boolean := False;
-- JEOC
JEOC : Boolean := False;
-- JEOS
JEOS : Boolean := False;
-- AWD1
AWD : ISR_AWD_Field := (As_Array => False, Val => 16#0#);
-- JQOVF
JQOVF : Boolean := False;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
ADRDY at 0 range 0 .. 0;
EOSMP at 0 range 1 .. 1;
EOC at 0 range 2 .. 2;
EOS at 0 range 3 .. 3;
OVR at 0 range 4 .. 4;
JEOC at 0 range 5 .. 5;
JEOS at 0 range 6 .. 6;
AWD at 0 range 7 .. 9;
JQOVF at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- interrupt enable register
type IER_Register is record
-- ADRDYIE
ADRDYIE : Boolean := False;
-- EOSMPIE
EOSMPIE : Boolean := False;
-- EOCIE
EOCIE : Boolean := False;
-- EOSIE
EOSIE : Boolean := False;
-- OVRIE
OVRIE : Boolean := False;
-- JEOCIE
JEOCIE : Boolean := False;
-- JEOSIE
JEOSIE : Boolean := False;
-- AWD1IE
AWD1IE : Boolean := False;
-- AWD2IE
AWD2IE : Boolean := False;
-- AWD3IE
AWD3IE : Boolean := False;
-- JQOVFIE
JQOVFIE : Boolean := False;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
ADRDYIE at 0 range 0 .. 0;
EOSMPIE at 0 range 1 .. 1;
EOCIE at 0 range 2 .. 2;
EOSIE at 0 range 3 .. 3;
OVRIE at 0 range 4 .. 4;
JEOCIE at 0 range 5 .. 5;
JEOSIE at 0 range 6 .. 6;
AWD1IE at 0 range 7 .. 7;
AWD2IE at 0 range 8 .. 8;
AWD3IE at 0 range 9 .. 9;
JQOVFIE at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
-- control register
type CR_Register is record
-- ADEN
ADEN : Boolean := False;
-- ADDIS
ADDIS : Boolean := False;
-- ADSTART
ADSTART : Boolean := False;
-- JADSTART
JADSTART : Boolean := False;
-- ADSTP
ADSTP : Boolean := False;
-- JADSTP
JADSTP : Boolean := False;
-- unspecified
Reserved_6_27 : HAL.UInt22 := 16#0#;
-- ADVREGEN
ADVREGEN : Boolean := False;
-- DEEPPWD
DEEPPWD : Boolean := True;
-- ADCALDIF
ADCALDIF : Boolean := False;
-- ADCAL
ADCAL : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
ADEN at 0 range 0 .. 0;
ADDIS at 0 range 1 .. 1;
ADSTART at 0 range 2 .. 2;
JADSTART at 0 range 3 .. 3;
ADSTP at 0 range 4 .. 4;
JADSTP at 0 range 5 .. 5;
Reserved_6_27 at 0 range 6 .. 27;
ADVREGEN at 0 range 28 .. 28;
DEEPPWD at 0 range 29 .. 29;
ADCALDIF at 0 range 30 .. 30;
ADCAL at 0 range 31 .. 31;
end record;
subtype CFGR_RES_Field is HAL.UInt2;
subtype CFGR_EXTSEL_Field is HAL.UInt5;
subtype CFGR_EXTEN_Field is HAL.UInt2;
subtype CFGR_DISCNUM_Field is HAL.UInt3;
subtype CFGR_AWD1CH_Field is HAL.UInt5;
-- configuration register
type CFGR_Register is record
-- DMAEN
DMAEN : Boolean := False;
-- DMACFG
DMACFG : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- RES
RES : CFGR_RES_Field := 16#0#;
-- External trigger selection for regular group
EXTSEL : CFGR_EXTSEL_Field := 16#0#;
-- EXTEN
EXTEN : CFGR_EXTEN_Field := 16#0#;
-- OVRMOD
OVRMOD : Boolean := False;
-- CONT
CONT : Boolean := False;
-- AUTDLY
AUTDLY : Boolean := False;
-- ALIGN
ALIGN : Boolean := False;
-- DISCEN
DISCEN : Boolean := False;
-- DISCNUM
DISCNUM : CFGR_DISCNUM_Field := 16#0#;
-- JDISCEN
JDISCEN : Boolean := False;
-- JQM
JQM : Boolean := False;
-- AWD1SGL
AWD1SGL : Boolean := False;
-- AWD1EN
AWD1EN : Boolean := False;
-- JAWD1EN
JAWD1EN : Boolean := False;
-- JAUTO
JAUTO : Boolean := False;
-- Analog watchdog 1 channel selection
AWD1CH : CFGR_AWD1CH_Field := 16#0#;
-- Injected Queue disable
JQDIS : Boolean := True;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
DMAEN at 0 range 0 .. 0;
DMACFG at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
RES at 0 range 3 .. 4;
EXTSEL at 0 range 5 .. 9;
EXTEN at 0 range 10 .. 11;
OVRMOD at 0 range 12 .. 12;
CONT at 0 range 13 .. 13;
AUTDLY at 0 range 14 .. 14;
ALIGN at 0 range 15 .. 15;
DISCEN at 0 range 16 .. 16;
DISCNUM at 0 range 17 .. 19;
JDISCEN at 0 range 20 .. 20;
JQM at 0 range 21 .. 21;
AWD1SGL at 0 range 22 .. 22;
AWD1EN at 0 range 23 .. 23;
JAWD1EN at 0 range 24 .. 24;
JAUTO at 0 range 25 .. 25;
AWD1CH at 0 range 26 .. 30;
JQDIS at 0 range 31 .. 31;
end record;
subtype CFGR2_OVSR_Field is HAL.UInt3;
subtype CFGR2_OVSS_Field is HAL.UInt4;
-- configuration register
type CFGR2_Register is record
-- DMAEN
ROVSE : Boolean := False;
-- DMACFG
JOVSE : Boolean := False;
-- RES
OVSR : CFGR2_OVSR_Field := 16#0#;
-- ALIGN
OVSS : CFGR2_OVSS_Field := 16#0#;
-- Triggered Regular Oversampling
TROVS : Boolean := False;
-- EXTEN
ROVSM : Boolean := False;
-- unspecified
Reserved_11_15 : HAL.UInt5 := 16#0#;
-- GCOMP
GCOMP : Boolean := False;
-- unspecified
Reserved_17_24 : HAL.UInt8 := 16#0#;
-- SWTRIG
SWTRIG : Boolean := False;
-- BULB
BULB : Boolean := False;
-- SMPTRIG
SMPTRIG : Boolean := False;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR2_Register use record
ROVSE at 0 range 0 .. 0;
JOVSE at 0 range 1 .. 1;
OVSR at 0 range 2 .. 4;
OVSS at 0 range 5 .. 8;
TROVS at 0 range 9 .. 9;
ROVSM at 0 range 10 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
GCOMP at 0 range 16 .. 16;
Reserved_17_24 at 0 range 17 .. 24;
SWTRIG at 0 range 25 .. 25;
BULB at 0 range 26 .. 26;
SMPTRIG at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- SMPR1_SMP array element
subtype SMPR1_SMP_Element is HAL.UInt3;
-- SMPR1_SMP array
type SMPR1_SMP_Field_Array is array (0 .. 9) of SMPR1_SMP_Element
with Component_Size => 3, Size => 30;
-- Type definition for SMPR1_SMP
type SMPR1_SMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SMP as a value
Val : HAL.UInt30;
when True =>
-- SMP as an array
Arr : SMPR1_SMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 30;
for SMPR1_SMP_Field use record
Val at 0 range 0 .. 29;
Arr at 0 range 0 .. 29;
end record;
-- sample time register 1
type SMPR1_Register is record
-- SMP0
SMP : SMPR1_SMP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_30_30 : HAL.Bit := 16#0#;
-- Addition of one clock cycle to the sampling time
SMPPLUS : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR1_Register use record
SMP at 0 range 0 .. 29;
Reserved_30_30 at 0 range 30 .. 30;
SMPPLUS at 0 range 31 .. 31;
end record;
-- SMPR2_SMP array element
subtype SMPR2_SMP_Element is HAL.UInt3;
-- SMPR2_SMP array
type SMPR2_SMP_Field_Array is array (10 .. 18) of SMPR2_SMP_Element
with Component_Size => 3, Size => 27;
-- Type definition for SMPR2_SMP
type SMPR2_SMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SMP as a value
Val : HAL.UInt27;
when True =>
-- SMP as an array
Arr : SMPR2_SMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 27;
for SMPR2_SMP_Field use record
Val at 0 range 0 .. 26;
Arr at 0 range 0 .. 26;
end record;
-- sample time register 2
type SMPR2_Register is record
-- SMP10
SMP : SMPR2_SMP_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR2_Register use record
SMP at 0 range 0 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype TR1_LT1_Field is HAL.UInt12;
subtype TR1_AWDFILT_Field is HAL.UInt3;
subtype TR1_HT1_Field is HAL.UInt12;
-- watchdog threshold register 1
type TR1_Register is record
-- LT1
LT1 : TR1_LT1_Field := 16#0#;
-- AWDFILT
AWDFILT : TR1_AWDFILT_Field := 16#0#;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- HT1
HT1 : TR1_HT1_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TR1_Register use record
LT1 at 0 range 0 .. 11;
AWDFILT at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
HT1 at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype TR2_LT2_Field is HAL.UInt8;
subtype TR2_HT2_Field is HAL.UInt8;
-- watchdog threshold register
type TR2_Register is record
-- LT2
LT2 : TR2_LT2_Field := 16#0#;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- HT2
HT2 : TR2_HT2_Field := 16#FF#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TR2_Register use record
LT2 at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
HT2 at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype TR3_LT3_Field is HAL.UInt8;
subtype TR3_HT3_Field is HAL.UInt8;
-- watchdog threshold register 3
type TR3_Register is record
-- LT3
LT3 : TR3_LT3_Field := 16#0#;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- HT3
HT3 : TR3_HT3_Field := 16#FF#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TR3_Register use record
LT3 at 0 range 0 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
HT3 at 0 range 16 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SQR1_L_Field is HAL.UInt4;
subtype SQR1_SQ1_Field is HAL.UInt5;
subtype SQR1_SQ2_Field is HAL.UInt5;
subtype SQR1_SQ3_Field is HAL.UInt5;
subtype SQR1_SQ4_Field is HAL.UInt5;
-- regular sequence register 1
type SQR1_Register is record
-- Regular channel sequence length
L : SQR1_L_Field := 16#0#;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- SQ1
SQ1 : SQR1_SQ1_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- SQ2
SQ2 : SQR1_SQ2_Field := 16#0#;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- SQ3
SQ3 : SQR1_SQ3_Field := 16#0#;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- SQ4
SQ4 : SQR1_SQ4_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SQR1_Register use record
L at 0 range 0 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
SQ1 at 0 range 6 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
SQ2 at 0 range 12 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
SQ3 at 0 range 18 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
SQ4 at 0 range 24 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype SQR2_SQ5_Field is HAL.UInt5;
subtype SQR2_SQ6_Field is HAL.UInt5;
subtype SQR2_SQ7_Field is HAL.UInt5;
subtype SQR2_SQ8_Field is HAL.UInt5;
subtype SQR2_SQ9_Field is HAL.UInt5;
-- regular sequence register 2
type SQR2_Register is record
-- SQ5
SQ5 : SQR2_SQ5_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- SQ6
SQ6 : SQR2_SQ6_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- SQ7
SQ7 : SQR2_SQ7_Field := 16#0#;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- SQ8
SQ8 : SQR2_SQ8_Field := 16#0#;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- SQ9
SQ9 : SQR2_SQ9_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SQR2_Register use record
SQ5 at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
SQ6 at 0 range 6 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
SQ7 at 0 range 12 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
SQ8 at 0 range 18 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
SQ9 at 0 range 24 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype SQR3_SQ10_Field is HAL.UInt5;
subtype SQR3_SQ11_Field is HAL.UInt5;
subtype SQR3_SQ12_Field is HAL.UInt5;
subtype SQR3_SQ13_Field is HAL.UInt5;
subtype SQR3_SQ14_Field is HAL.UInt5;
-- regular sequence register 3
type SQR3_Register is record
-- SQ10
SQ10 : SQR3_SQ10_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- SQ11
SQ11 : SQR3_SQ11_Field := 16#0#;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- SQ12
SQ12 : SQR3_SQ12_Field := 16#0#;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- SQ13
SQ13 : SQR3_SQ13_Field := 16#0#;
-- unspecified
Reserved_23_23 : HAL.Bit := 16#0#;
-- SQ14
SQ14 : SQR3_SQ14_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SQR3_Register use record
SQ10 at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
SQ11 at 0 range 6 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
SQ12 at 0 range 12 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
SQ13 at 0 range 18 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
SQ14 at 0 range 24 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype SQR4_SQ15_Field is HAL.UInt5;
subtype SQR4_SQ16_Field is HAL.UInt5;
-- regular sequence register 4
type SQR4_Register is record
-- SQ15
SQ15 : SQR4_SQ15_Field := 16#0#;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- SQ16
SQ16 : SQR4_SQ16_Field := 16#0#;
-- unspecified
Reserved_11_31 : HAL.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SQR4_Register use record
SQ15 at 0 range 0 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
SQ16 at 0 range 6 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype DR_RDATA_Field is HAL.UInt16;
-- regular Data Register
type DR_Register is record
-- Read-only. Regular Data converted
RDATA : DR_RDATA_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
RDATA at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype JSQR_JL_Field is HAL.UInt2;
subtype JSQR_JEXTSEL_Field is HAL.UInt5;
subtype JSQR_JEXTEN_Field is HAL.UInt2;
subtype JSQR_JSQ1_Field is HAL.UInt5;
subtype JSQR_JSQ2_Field is HAL.UInt5;
subtype JSQR_JSQ3_Field is HAL.UInt5;
subtype JSQR_JSQ4_Field is HAL.UInt5;
-- injected sequence register
type JSQR_Register is record
-- JL
JL : JSQR_JL_Field := 16#0#;
-- JEXTSEL
JEXTSEL : JSQR_JEXTSEL_Field := 16#0#;
-- JEXTEN
JEXTEN : JSQR_JEXTEN_Field := 16#0#;
-- JSQ1
JSQ1 : JSQR_JSQ1_Field := 16#0#;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- JSQ2
JSQ2 : JSQR_JSQ2_Field := 16#0#;
-- unspecified
Reserved_20_20 : HAL.Bit := 16#0#;
-- JSQ3
JSQ3 : JSQR_JSQ3_Field := 16#0#;
-- unspecified
Reserved_26_26 : HAL.Bit := 16#0#;
-- JSQ4
JSQ4 : JSQR_JSQ4_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for JSQR_Register use record
JL at 0 range 0 .. 1;
JEXTSEL at 0 range 2 .. 6;
JEXTEN at 0 range 7 .. 8;
JSQ1 at 0 range 9 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
JSQ2 at 0 range 15 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
JSQ3 at 0 range 21 .. 25;
Reserved_26_26 at 0 range 26 .. 26;
JSQ4 at 0 range 27 .. 31;
end record;
subtype OFR_OFFSET1_Field is HAL.UInt12;
subtype OFR_OFFSET1_CH_Field is HAL.UInt5;
-- offset register 1
type OFR_Register is record
-- OFFSET1
OFFSET1 : OFR_OFFSET1_Field := 16#0#;
-- unspecified
Reserved_12_23 : HAL.UInt12 := 16#0#;
-- OFFSETPOS
OFFSETPOS : Boolean := False;
-- SATEN
SATEN : Boolean := False;
-- OFFSET1_CH
OFFSET1_CH : OFR_OFFSET1_CH_Field := 16#0#;
-- OFFSET1_EN
OFFSET1_EN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OFR_Register use record
OFFSET1 at 0 range 0 .. 11;
Reserved_12_23 at 0 range 12 .. 23;
OFFSETPOS at 0 range 24 .. 24;
SATEN at 0 range 25 .. 25;
OFFSET1_CH at 0 range 26 .. 30;
OFFSET1_EN at 0 range 31 .. 31;
end record;
subtype OFR2_OFFSET2_Field is HAL.UInt12;
subtype OFR2_OFFSET2_CH_Field is HAL.UInt5;
-- offset register 2
type OFR2_Register is record
-- OFFSET1
OFFSET2 : OFR2_OFFSET2_Field := 16#0#;
-- unspecified
Reserved_12_23 : HAL.UInt12 := 16#0#;
-- OFFSETPOS
OFFSETPOS : Boolean := False;
-- SATEN
SATEN : Boolean := False;
-- OFFSET1_CH
OFFSET2_CH : OFR2_OFFSET2_CH_Field := 16#0#;
-- OFFSET1_EN
OFFSET2_EN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OFR2_Register use record
OFFSET2 at 0 range 0 .. 11;
Reserved_12_23 at 0 range 12 .. 23;
OFFSETPOS at 0 range 24 .. 24;
SATEN at 0 range 25 .. 25;
OFFSET2_CH at 0 range 26 .. 30;
OFFSET2_EN at 0 range 31 .. 31;
end record;
subtype OFR3_OFFSET3_Field is HAL.UInt12;
subtype OFR3_OFFSET3_CH_Field is HAL.UInt5;
-- offset register 3
type OFR3_Register is record
-- OFFSET1
OFFSET3 : OFR3_OFFSET3_Field := 16#0#;
-- unspecified
Reserved_12_23 : HAL.UInt12 := 16#0#;
-- OFFSETPOS
OFFSETPOS : Boolean := False;
-- SATEN
SATEN : Boolean := False;
-- OFFSET1_CH
OFFSET3_CH : OFR3_OFFSET3_CH_Field := 16#0#;
-- OFFSET1_EN
OFFSET3_EN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OFR3_Register use record
OFFSET3 at 0 range 0 .. 11;
Reserved_12_23 at 0 range 12 .. 23;
OFFSETPOS at 0 range 24 .. 24;
SATEN at 0 range 25 .. 25;
OFFSET3_CH at 0 range 26 .. 30;
OFFSET3_EN at 0 range 31 .. 31;
end record;
subtype OFR4_OFFSET4_Field is HAL.UInt12;
subtype OFR4_OFFSET4_CH_Field is HAL.UInt5;
-- offset register 4
type OFR4_Register is record
-- OFFSET1
OFFSET4 : OFR4_OFFSET4_Field := 16#0#;
-- unspecified
Reserved_12_23 : HAL.UInt12 := 16#0#;
-- OFFSETPOS
OFFSETPOS : Boolean := False;
-- SATEN
SATEN : Boolean := False;
-- OFFSET1_CH
OFFSET4_CH : OFR4_OFFSET4_CH_Field := 16#0#;
-- OFFSET1_EN
OFFSET4_EN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OFR4_Register use record
OFFSET4 at 0 range 0 .. 11;
Reserved_12_23 at 0 range 12 .. 23;
OFFSETPOS at 0 range 24 .. 24;
SATEN at 0 range 25 .. 25;
OFFSET4_CH at 0 range 26 .. 30;
OFFSET4_EN at 0 range 31 .. 31;
end record;
subtype JDR1_JDATA1_Field is HAL.UInt16;
-- injected data register 1
type JDR1_Register is record
-- Read-only. JDATA1
JDATA1 : JDR1_JDATA1_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for JDR1_Register use record
JDATA1 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype JDR2_JDATA2_Field is HAL.UInt16;
-- injected data register 2
type JDR2_Register is record
-- Read-only. JDATA2
JDATA2 : JDR2_JDATA2_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for JDR2_Register use record
JDATA2 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype JDR3_JDATA3_Field is HAL.UInt16;
-- injected data register 3
type JDR3_Register is record
-- Read-only. JDATA3
JDATA3 : JDR3_JDATA3_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for JDR3_Register use record
JDATA3 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype JDR4_JDATA4_Field is HAL.UInt16;
-- injected data register 4
type JDR4_Register is record
-- Read-only. JDATA4
JDATA4 : JDR4_JDATA4_Field;
-- unspecified
Reserved_16_31 : HAL.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for JDR4_Register use record
JDATA4 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype AWD2CR_AWD2CH_Field is HAL.UInt19;
-- Analog Watchdog 2 Configuration Register
type AWD2CR_Register is record
-- AWD2CH
AWD2CH : AWD2CR_AWD2CH_Field := 16#0#;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AWD2CR_Register use record
AWD2CH at 0 range 0 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype AWD3CR_AWD3CH_Field is HAL.UInt19;
-- Analog Watchdog 3 Configuration Register
type AWD3CR_Register is record
-- AWD3CH
AWD3CH : AWD3CR_AWD3CH_Field := 16#0#;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AWD3CR_Register use record
AWD3CH at 0 range 0 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype DIFSEL_DIFSEL_1_18_Field is HAL.UInt18;
-- Differential Mode Selection Register 2
type DIFSEL_Register is record
-- Read-only. Differential mode for channels 0
DIFSEL_0 : Boolean := False;
-- Differential mode for channels 15 to 1
DIFSEL_1_18 : DIFSEL_DIFSEL_1_18_Field := 16#0#;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DIFSEL_Register use record
DIFSEL_0 at 0 range 0 .. 0;
DIFSEL_1_18 at 0 range 1 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype CALFACT_CALFACT_S_Field is HAL.UInt7;
subtype CALFACT_CALFACT_D_Field is HAL.UInt7;
-- Calibration Factors
type CALFACT_Register is record
-- CALFACT_S
CALFACT_S : CALFACT_CALFACT_S_Field := 16#0#;
-- unspecified
Reserved_7_15 : HAL.UInt9 := 16#0#;
-- CALFACT_D
CALFACT_D : CALFACT_CALFACT_D_Field := 16#0#;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CALFACT_Register use record
CALFACT_S at 0 range 0 .. 6;
Reserved_7_15 at 0 range 7 .. 15;
CALFACT_D at 0 range 16 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype GCOMP_GCOMPCOEFF_Field is HAL.UInt14;
-- Gain compensation Register
type GCOMP_Register is record
-- GCOMPCOEFF
GCOMPCOEFF : GCOMP_GCOMPCOEFF_Field := 16#0#;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GCOMP_Register use record
GCOMPCOEFF at 0 range 0 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- ADC Common status register
type CSR_Register is record
-- Read-only. ADDRDY_MST
ADDRDY_MST : Boolean;
-- Read-only. EOSMP_MST
EOSMP_MST : Boolean;
-- Read-only. EOC_MST
EOC_MST : Boolean;
-- Read-only. EOS_MST
EOS_MST : Boolean;
-- Read-only. OVR_MST
OVR_MST : Boolean;
-- Read-only. JEOC_MST
JEOC_MST : Boolean;
-- Read-only. JEOS_MST
JEOS_MST : Boolean;
-- Read-only. AWD1_MST
AWD1_MST : Boolean;
-- Read-only. AWD2_MST
AWD2_MST : Boolean;
-- Read-only. AWD3_MST
AWD3_MST : Boolean;
-- Read-only. JQOVF_MST
JQOVF_MST : Boolean;
-- unspecified
Reserved_11_15 : HAL.UInt5;
-- Read-only. ADRDY_SLV
ADRDY_SLV : Boolean;
-- Read-only. EOSMP_SLV
EOSMP_SLV : Boolean;
-- Read-only. End of regular conversion of the slave ADC
EOC_SLV : Boolean;
-- Read-only. End of regular sequence flag of the slave ADC
EOS_SLV : Boolean;
-- Read-only. Overrun flag of the slave ADC
OVR_SLV : Boolean;
-- Read-only. End of injected conversion flag of the slave ADC
JEOC_SLV : Boolean;
-- Read-only. End of injected sequence flag of the slave ADC
JEOS_SLV : Boolean;
-- Read-only. Analog watchdog 1 flag of the slave ADC
AWD1_SLV : Boolean;
-- Read-only. Analog watchdog 2 flag of the slave ADC
AWD2_SLV : Boolean;
-- Read-only. Analog watchdog 3 flag of the slave ADC
AWD3_SLV : Boolean;
-- Read-only. Injected Context Queue Overflow flag of the slave ADC
JQOVF_SLV : Boolean;
-- unspecified
Reserved_27_31 : HAL.UInt5;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
ADDRDY_MST at 0 range 0 .. 0;
EOSMP_MST at 0 range 1 .. 1;
EOC_MST at 0 range 2 .. 2;
EOS_MST at 0 range 3 .. 3;
OVR_MST at 0 range 4 .. 4;
JEOC_MST at 0 range 5 .. 5;
JEOS_MST at 0 range 6 .. 6;
AWD1_MST at 0 range 7 .. 7;
AWD2_MST at 0 range 8 .. 8;
AWD3_MST at 0 range 9 .. 9;
JQOVF_MST at 0 range 10 .. 10;
Reserved_11_15 at 0 range 11 .. 15;
ADRDY_SLV at 0 range 16 .. 16;
EOSMP_SLV at 0 range 17 .. 17;
EOC_SLV at 0 range 18 .. 18;
EOS_SLV at 0 range 19 .. 19;
OVR_SLV at 0 range 20 .. 20;
JEOC_SLV at 0 range 21 .. 21;
JEOS_SLV at 0 range 22 .. 22;
AWD1_SLV at 0 range 23 .. 23;
AWD2_SLV at 0 range 24 .. 24;
AWD3_SLV at 0 range 25 .. 25;
JQOVF_SLV at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype CCR_DUAL_Field is HAL.UInt5;
subtype CCR_DELAY_Field is HAL.UInt4;
subtype CCR_MDMA_Field is HAL.UInt2;
subtype CCR_CKMODE_Field is HAL.UInt2;
subtype CCR_PRESC_Field is HAL.UInt4;
-- ADC common control register
type CCR_Register is record
-- Dual ADC mode selection
DUAL : CCR_DUAL_Field := 16#0#;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Delay between 2 sampling phases
DELAY_k : CCR_DELAY_Field := 16#0#;
-- unspecified
Reserved_12_12 : HAL.Bit := 16#0#;
-- DMA configuration (for multi-ADC mode)
DMACFG : Boolean := False;
-- Direct memory access mode for multi ADC mode
MDMA : CCR_MDMA_Field := 16#0#;
-- ADC clock mode
CKMODE : CCR_CKMODE_Field := 16#0#;
-- ADC prescaler
PRESC : CCR_PRESC_Field := 16#0#;
-- VREFINT enable
VREFEN : Boolean := False;
-- VTS selection
VSENSESEL : Boolean := False;
-- VBAT selection
VBATSEL : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
DUAL at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
DELAY_k at 0 range 8 .. 11;
Reserved_12_12 at 0 range 12 .. 12;
DMACFG at 0 range 13 .. 13;
MDMA at 0 range 14 .. 15;
CKMODE at 0 range 16 .. 17;
PRESC at 0 range 18 .. 21;
VREFEN at 0 range 22 .. 22;
VSENSESEL at 0 range 23 .. 23;
VBATSEL at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype CDR_RDATA_MST_Field is HAL.UInt16;
subtype CDR_RDATA_SLV_Field is HAL.UInt16;
-- ADC common regular data register for dual and triple modes
type CDR_Register is record
-- Read-only. Regular data of the master ADC
RDATA_MST : CDR_RDATA_MST_Field;
-- Read-only. Regular data of the slave ADC
RDATA_SLV : CDR_RDATA_SLV_Field;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CDR_Register use record
RDATA_MST at 0 range 0 .. 15;
RDATA_SLV at 0 range 16 .. 31;
end record;
subtype CFGR_EXTSEL_Field_1 is HAL.UInt4;
subtype CFGR_AWDCH1CH_Field is HAL.UInt5;
-- configuration register
type CFGR_Register_1 is record
-- DMAEN
DMAEN : Boolean := False;
-- DMACFG
DMACFG : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- RES
RES : CFGR_RES_Field := 16#0#;
-- ALIGN_5
ALIGN_5 : Boolean := False;
-- EXTSEL
EXTSEL : CFGR_EXTSEL_Field_1 := 16#0#;
-- EXTEN
EXTEN : CFGR_EXTEN_Field := 16#0#;
-- OVRMOD
OVRMOD : Boolean := False;
-- CONT
CONT : Boolean := False;
-- AUTDLY
AUTDLY : Boolean := False;
-- ALIGN
ALIGN : Boolean := False;
-- DISCEN
DISCEN : Boolean := False;
-- DISCNUM
DISCNUM : CFGR_DISCNUM_Field := 16#0#;
-- JDISCEN
JDISCEN : Boolean := False;
-- JQM
JQM : Boolean := False;
-- AWD1SGL
AWD1SGL : Boolean := False;
-- AWD1EN
AWD1EN : Boolean := False;
-- JAWD1EN
JAWD1EN : Boolean := False;
-- JAUTO
JAUTO : Boolean := False;
-- AWDCH1CH
AWDCH1CH : CFGR_AWDCH1CH_Field := 16#0#;
-- Injected Queue disable
JQDIS : Boolean := True;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register_1 use record
DMAEN at 0 range 0 .. 0;
DMACFG at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
RES at 0 range 3 .. 4;
ALIGN_5 at 0 range 5 .. 5;
EXTSEL at 0 range 6 .. 9;
EXTEN at 0 range 10 .. 11;
OVRMOD at 0 range 12 .. 12;
CONT at 0 range 13 .. 13;
AUTDLY at 0 range 14 .. 14;
ALIGN at 0 range 15 .. 15;
DISCEN at 0 range 16 .. 16;
DISCNUM at 0 range 17 .. 19;
JDISCEN at 0 range 20 .. 20;
JQM at 0 range 21 .. 21;
AWD1SGL at 0 range 22 .. 22;
AWD1EN at 0 range 23 .. 23;
JAWD1EN at 0 range 24 .. 24;
JAUTO at 0 range 25 .. 25;
AWDCH1CH at 0 range 26 .. 30;
JQDIS at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog-to-Digital Converter
type ADC1_Peripheral is record
-- interrupt and status register
ISR : aliased ISR_Register;
-- interrupt enable register
IER : aliased IER_Register;
-- control register
CR : aliased CR_Register;
-- configuration register
CFGR : aliased CFGR_Register;
-- configuration register
CFGR2 : aliased CFGR2_Register;
-- sample time register 1
SMPR1 : aliased SMPR1_Register;
-- sample time register 2
SMPR2 : aliased SMPR2_Register;
-- watchdog threshold register 1
TR1 : aliased TR1_Register;
-- watchdog threshold register
TR2 : aliased TR2_Register;
-- watchdog threshold register 3
TR3 : aliased TR3_Register;
-- regular sequence register 1
SQR1 : aliased SQR1_Register;
-- regular sequence register 2
SQR2 : aliased SQR2_Register;
-- regular sequence register 3
SQR3 : aliased SQR3_Register;
-- regular sequence register 4
SQR4 : aliased SQR4_Register;
-- regular Data Register
DR : aliased DR_Register;
-- injected sequence register
JSQR : aliased JSQR_Register;
-- offset register 1
OFR1 : aliased OFR_Register;
-- offset register 2
OFR2 : aliased OFR2_Register;
-- offset register 3
OFR3 : aliased OFR3_Register;
-- offset register 4
OFR4 : aliased OFR4_Register;
-- injected data register 1
JDR1 : aliased JDR1_Register;
-- injected data register 2
JDR2 : aliased JDR2_Register;
-- injected data register 3
JDR3 : aliased JDR3_Register;
-- injected data register 4
JDR4 : aliased JDR4_Register;
-- Analog Watchdog 2 Configuration Register
AWD2CR : aliased AWD2CR_Register;
-- Analog Watchdog 3 Configuration Register
AWD3CR : aliased AWD3CR_Register;
-- Differential Mode Selection Register 2
DIFSEL : aliased DIFSEL_Register;
-- Calibration Factors
CALFACT : aliased CALFACT_Register;
-- Gain compensation Register
GCOMP : aliased GCOMP_Register;
end record
with Volatile;
for ADC1_Peripheral use record
ISR at 16#0# range 0 .. 31;
IER at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
CFGR at 16#C# range 0 .. 31;
CFGR2 at 16#10# range 0 .. 31;
SMPR1 at 16#14# range 0 .. 31;
SMPR2 at 16#18# range 0 .. 31;
TR1 at 16#20# range 0 .. 31;
TR2 at 16#24# range 0 .. 31;
TR3 at 16#28# range 0 .. 31;
SQR1 at 16#30# range 0 .. 31;
SQR2 at 16#34# range 0 .. 31;
SQR3 at 16#38# range 0 .. 31;
SQR4 at 16#3C# range 0 .. 31;
DR at 16#40# range 0 .. 31;
JSQR at 16#4C# range 0 .. 31;
OFR1 at 16#60# range 0 .. 31;
OFR2 at 16#64# range 0 .. 31;
OFR3 at 16#68# range 0 .. 31;
OFR4 at 16#6C# range 0 .. 31;
JDR1 at 16#80# range 0 .. 31;
JDR2 at 16#84# range 0 .. 31;
JDR3 at 16#88# range 0 .. 31;
JDR4 at 16#8C# range 0 .. 31;
AWD2CR at 16#A0# range 0 .. 31;
AWD3CR at 16#A4# range 0 .. 31;
DIFSEL at 16#B0# range 0 .. 31;
CALFACT at 16#B4# range 0 .. 31;
GCOMP at 16#C0# range 0 .. 31;
end record;
-- Analog-to-Digital Converter
ADC1_Periph : aliased ADC1_Peripheral
with Import, Address => ADC1_Base;
-- Analog-to-Digital Converter
ADC2_Periph : aliased ADC1_Peripheral
with Import, Address => ADC2_Base;
-- Analog-to-Digital Converter
ADC4_Periph : aliased ADC1_Peripheral
with Import, Address => ADC4_Base;
-- Analog-to-Digital Converter
type ADC12_Common_Peripheral is record
-- ADC Common status register
CSR : aliased CSR_Register;
-- ADC common control register
CCR : aliased CCR_Register;
-- ADC common regular data register for dual and triple modes
CDR : aliased CDR_Register;
end record
with Volatile;
for ADC12_Common_Peripheral use record
CSR at 16#0# range 0 .. 31;
CCR at 16#8# range 0 .. 31;
CDR at 16#C# range 0 .. 31;
end record;
-- Analog-to-Digital Converter
ADC12_Common_Periph : aliased ADC12_Common_Peripheral
with Import, Address => ADC12_Common_Base;
-- Analog-to-Digital Converter
ADC345_Common_Periph : aliased ADC12_Common_Peripheral
with Import, Address => ADC345_Common_Base;
-- Analog-to-Digital Converter
type ADC3_Peripheral is record
-- interrupt and status register
ISR : aliased ISR_Register;
-- interrupt enable register
IER : aliased IER_Register;
-- control register
CR : aliased CR_Register;
-- configuration register
CFGR : aliased CFGR_Register_1;
-- configuration register
CFGR2 : aliased CFGR2_Register;
-- sample time register 1
SMPR1 : aliased SMPR1_Register;
-- sample time register 2
SMPR2 : aliased SMPR2_Register;
-- watchdog threshold register 1
TR1 : aliased TR1_Register;
-- watchdog threshold register
TR2 : aliased TR2_Register;
-- watchdog threshold register 3
TR3 : aliased TR3_Register;
-- regular sequence register 1
SQR1 : aliased SQR1_Register;
-- regular sequence register 2
SQR2 : aliased SQR2_Register;
-- regular sequence register 3
SQR3 : aliased SQR3_Register;
-- regular sequence register 4
SQR4 : aliased SQR4_Register;
-- regular Data Register
DR : aliased DR_Register;
-- injected sequence register
JSQR : aliased JSQR_Register;
-- offset register 1
OFR1 : aliased OFR_Register;
-- offset register 2
OFR2 : aliased OFR_Register;
-- offset register 3
OFR3 : aliased OFR_Register;
-- offset register 4
OFR4 : aliased OFR_Register;
-- injected data register 1
JDR1 : aliased JDR1_Register;
-- injected data register 2
JDR2 : aliased JDR2_Register;
-- injected data register 3
JDR3 : aliased JDR3_Register;
-- injected data register 4
JDR4 : aliased JDR4_Register;
-- Analog Watchdog 2 Configuration Register
AWD2CR : aliased AWD2CR_Register;
-- Analog Watchdog 3 Configuration Register
AWD3CR : aliased AWD3CR_Register;
-- Differential Mode Selection Register 2
DIFSEL : aliased DIFSEL_Register;
-- Calibration Factors
CALFACT : aliased CALFACT_Register;
-- Gain compensation Register
GCOMP : aliased GCOMP_Register;
end record
with Volatile;
for ADC3_Peripheral use record
ISR at 16#0# range 0 .. 31;
IER at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
CFGR at 16#C# range 0 .. 31;
CFGR2 at 16#10# range 0 .. 31;
SMPR1 at 16#14# range 0 .. 31;
SMPR2 at 16#18# range 0 .. 31;
TR1 at 16#20# range 0 .. 31;
TR2 at 16#24# range 0 .. 31;
TR3 at 16#28# range 0 .. 31;
SQR1 at 16#30# range 0 .. 31;
SQR2 at 16#34# range 0 .. 31;
SQR3 at 16#38# range 0 .. 31;
SQR4 at 16#3C# range 0 .. 31;
DR at 16#40# range 0 .. 31;
JSQR at 16#4C# range 0 .. 31;
OFR1 at 16#60# range 0 .. 31;
OFR2 at 16#64# range 0 .. 31;
OFR3 at 16#68# range 0 .. 31;
OFR4 at 16#6C# range 0 .. 31;
JDR1 at 16#80# range 0 .. 31;
JDR2 at 16#84# range 0 .. 31;
JDR3 at 16#88# range 0 .. 31;
JDR4 at 16#8C# range 0 .. 31;
AWD2CR at 16#A0# range 0 .. 31;
AWD3CR at 16#A4# range 0 .. 31;
DIFSEL at 16#B0# range 0 .. 31;
CALFACT at 16#B4# range 0 .. 31;
GCOMP at 16#C0# range 0 .. 31;
end record;
-- Analog-to-Digital Converter
ADC3_Periph : aliased ADC3_Peripheral
with Import, Address => ADC3_Base;
-- Analog-to-Digital Converter
ADC5_Periph : aliased ADC3_Peripheral
with Import, Address => ADC5_Base;
end STM32_SVD.ADC;
|
-- Spécification du module Piles.
generic
type T_Element is private; -- Type des éléments de la pile
package Piles is
type T_Pile is limited private;
-- Initilaiser une pile. La pile est vide.
procedure Initialiser (Pile : out T_Pile) with
Post => Est_Vide (Pile);
-- Est-ce que la pile est vide ?
function Est_Vide (Pile : in T_Pile) return Boolean;
-- L'élément en sommet de la pile.
function Sommet (Pile : in T_Pile) return T_Element with
Pre => not Est_Vide (Pile);
-- Empiler l'élément en somment de la pile.
-- Exception : Storage_Exception s'il n'y a plus de mémoire.
procedure Empiler (Pile : in out T_Pile; Element : in T_Element) with
Post => Sommet (Pile) = Element;
-- Supprimer l'élément en sommet de pile
procedure Depiler (Pile : in out T_Pile) with
Pre => not Est_Vide (Pile);
-- Détruire la pile.
-- Elle ne doit plus être utilisée sauf à être de nouveau initialisée.
procedure Detruire (P: in out T_Pile);
-- Afficher les éléments de la pile
generic
with procedure Afficher_Element (Un_Element: in T_Element);
procedure Afficher (Pile : in T_Pile);
private
type T_Cellule;
type T_Pile is access T_Cellule;
type T_Cellule is
record
Element: T_Element;
Suivant: T_Pile;
end record;
end Piles;
|
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Ada.Streams;
with Lzma.Base;
package Lzma.Vli is
-- unsupported macro: LZMA_VLI_MAX (UINT64_MAX / 2)
-- unsupported macro: LZMA_VLI_UNKNOWN UINT64_MAX
LZMA_VLI_BYTES_MAX : constant := 9; -- /usr/include/lzma/vli.h:44
-- arg-macro: procedure LZMA_VLI_C UINT64_C(n)
-- UINT64_C(n)
-- arg-macro: function lzma_vli_is_valid ((vli) <= LZMA_VLI_MAX or else (vli) = LZMA_VLI_UNKNOWN
-- return (vli) <= LZMA_VLI_MAX or else (vli) = LZMA_VLI_UNKNOWN;
--*
-- * \file lzma/vli.h
-- * \brief Variable-length integer handling
-- *
-- * In the .xz format, most integers are encoded in a variable-length
-- * representation, which is sometimes called little endian base-128 encoding.
-- * This saves space when smaller values are more likely than bigger values.
-- *
-- * The encoding scheme encodes seven bits to every byte, using minimum
-- * number of bytes required to represent the given value. Encodings that use
-- * non-minimum number of bytes are invalid, thus every integer has exactly
-- * one encoded representation. The maximum number of bits in a VLI is 63,
-- * thus the vli argument must be less than or equal to UINT64_MAX / 2. You
-- * should use LZMA_VLI_MAX for clarity.
--
-- * Author: Lasse Collin
-- *
-- * This file has been put into the public domain.
-- * You can do whatever you want with this file.
-- *
-- * See ../lzma.h for information about liblzma as a whole.
--
--*
-- * \brief Maximum supported value of a variable-length integer
--
--*
-- * \brief VLI value to denote that the value is unknown
--
--*
-- * \brief Maximum supported encoded length of variable length integers
--
--*
-- * \brief VLI constant suffix
--
--*
-- * \brief Variable-length integer type
-- *
-- * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
-- * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
-- * underlaying integer type.
-- *
-- * lzma_vli will be uint64_t for the foreseeable future. If a bigger size
-- * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
-- * not overflow lzma_vli. This simplifies integer overflow detection.
--
subtype lzma_vli is Long_Long_Integer; -- /usr/include/lzma/vli.h:63
--*
-- * \brief Validate a variable-length integer
-- *
-- * This is useful to test that application has given acceptable values
-- * for example in the uncompressed_size and compressed_size variables.
-- *
-- * \return True if the integer is representable as VLI or if it
-- * indicates unknown value.
--
--*
-- * \brief Encode a variable-length integer
-- *
-- * This function has two modes: single-call and multi-call. Single-call mode
-- * encodes the whole integer at once; it is an error if the output buffer is
-- * too small. Multi-call mode saves the position in *vli_pos, and thus it is
-- * possible to continue encoding if the buffer becomes full before the whole
-- * integer has been encoded.
-- *
-- * \param vli Integer to be encoded
-- * \param vli_pos How many VLI-encoded bytes have already been written
-- * out. When starting to encode a new integer in
-- * multi-call mode, *vli_pos must be set to zero.
-- * To use single-call encoding, set vli_pos to NULL.
-- * \param out Beginning of the output buffer
-- * \param out_pos The next byte will be written to out[*out_pos].
-- * \param out_size Size of the out buffer; the first byte into
-- * which no data is written to is out[out_size].
-- *
-- * \return Slightly different return values are used in multi-call and
-- * single-call modes.
-- *
-- * Single-call (vli_pos == NULL):
-- * - LZMA_OK: Integer successfully encoded.
-- * - LZMA_PROG_ERROR: Arguments are not sane. This can be due
-- * to too little output space; single-call mode doesn't use
-- * LZMA_BUF_ERROR, since the application should have checked
-- * the encoded size with lzma_vli_size().
-- *
-- * Multi-call (vli_pos != NULL):
-- * - LZMA_OK: So far all OK, but the integer is not
-- * completely written out yet.
-- * - LZMA_STREAM_END: Integer successfully encoded.
-- * - LZMA_BUF_ERROR: No output space was provided.
-- * - LZMA_PROG_ERROR: Arguments are not sane.
--
function lzma_vli_encode
(vli : lzma_vli;
vli_pos : access Interfaces.C.size_t;
c_out : access Ada.Streams.Stream_Element;
out_pos : access Interfaces.C.size_t;
out_size : Interfaces.C.size_t) return Lzma.Base.lzma_ret; -- /usr/include/lzma/vli.h:115
pragma Import (C, lzma_vli_encode, "lzma_vli_encode");
--*
-- * \brief Decode a variable-length integer
-- *
-- * Like lzma_vli_encode(), this function has single-call and multi-call modes.
-- *
-- * \param vli Pointer to decoded integer. The decoder will
-- * initialize it to zero when *vli_pos == 0, so
-- * application isn't required to initialize *vli.
-- * \param vli_pos How many bytes have already been decoded. When
-- * starting to decode a new integer in multi-call
-- * mode, *vli_pos must be initialized to zero. To
-- * use single-call decoding, set vli_pos to NULL.
-- * \param in Beginning of the input buffer
-- * \param in_pos The next byte will be read from in[*in_pos].
-- * \param in_size Size of the input buffer; the first byte that
-- * won't be read is in[in_size].
-- *
-- * \return Slightly different return values are used in multi-call and
-- * single-call modes.
-- *
-- * Single-call (vli_pos == NULL):
-- * - LZMA_OK: Integer successfully decoded.
-- * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
-- * the end of the input buffer before the whole integer was
-- * decoded; providing no input at all will use LZMA_DATA_ERROR.
-- * - LZMA_PROG_ERROR: Arguments are not sane.
-- *
-- * Multi-call (vli_pos != NULL):
-- * - LZMA_OK: So far all OK, but the integer is not
-- * completely decoded yet.
-- * - LZMA_STREAM_END: Integer successfully decoded.
-- * - LZMA_DATA_ERROR: Integer is corrupt.
-- * - LZMA_BUF_ERROR: No input was provided.
-- * - LZMA_PROG_ERROR: Arguments are not sane.
--
function lzma_vli_decode
(vli : access lzma_vli;
vli_pos : access Interfaces.C.size_t;
c_in : access Ada.Streams.Stream_Element;
in_pos : access Interfaces.C.size_t;
in_size : Interfaces.C.size_t) return Lzma.Base.lzma_ret; -- /usr/include/lzma/vli.h:154
pragma Import (C, lzma_vli_decode, "lzma_vli_decode");
--*
-- * \brief Get the number of bytes required to encode a VLI
-- *
-- * \return Number of bytes on success (1-9). If vli isn't valid,
-- * zero is returned.
--
function lzma_vli_size (vli : lzma_vli) return Interfaces.C.unsigned; -- /usr/include/lzma/vli.h:165
pragma Import (C, lzma_vli_size, "lzma_vli_size");
end Lzma.Vli;
|
package body Animals is
function Legs
(A : Animal) return Natural
is (A.Number_Of_Legs);
function Wings
(A : Animal) return Natural
is (A.Number_Of_Wings);
procedure Add_Wings (A : in out Animal;
N : Positive) is
begin
A.Number_Of_Wings := A.Wings + 2 * N;
end Add_Wings;
procedure Add_Legs (A : in out Animal;
N : Positive) is
begin
A.Number_Of_Legs := A.Number_Of_Legs + 2 * N;
end Add_Legs;
end Animals;
|
with Ada.Finalization;
package Controlled_Record is
type Point_T is limited private;
procedure Assert_Invariants (PA : Point_T);
private
type Coords_T is array (1 .. 2) of Natural;
type Point_T is new Ada.Finalization.Controlled with record
Pos : Coords_T := (0, 0);
end record;
end Controlled_Record;
|
-- { dg-do compile }
procedure Constant1 is
Def_Const : constant Integer;
pragma Import (Ada, Def_Const);
begin
null;
end;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2020, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Unchecked_Conversion;
with System;
with League.Calendars.ISO_8601;
with League.Text_Codecs;
with Matreshka.Internals.SQL_Parameter_Rewriters.PostgreSQL;
package body Matreshka.Internals.SQL_Drivers.PostgreSQL.Queries is
use type Interfaces.C.int;
Codec : constant League.Text_Codecs.Text_Codec
:= League.Text_Codecs.Codec
(League.Strings.To_Universal_String ("UTF-8"));
-- It is used everywhere to convert text data, PostgreSQL_Database is
-- responsible to set client encodings to UTF-8.
Rewriter : SQL_Parameter_Rewriters.PostgreSQL.PostgreSQL_Parameter_Rewriter;
-- SQL statement parameter rewriter.
Date_Format : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("yyyy-MM-dd");
Timestamp_Format : constant League.Strings.Universal_String
:= League.Strings.To_Universal_String ("yyyy-MM-dd HH:mm:ss.SSSSSS");
-- PostgreSQL supports up to 6 digits in fractional seconds, while
-- Matreshka supports 7 digits.
----------------
-- Bind_Value --
----------------
overriding procedure Bind_Value
(Self : not null access PostgreSQL_Query;
Name : League.Strings.Universal_String;
Value : League.Holders.Holder;
Direction : SQL.Parameter_Directions) is
begin
Self.Parameters.Set_Value (Name, Value);
end Bind_Value;
-----------------
-- Bound_Value --
-----------------
overriding function Bound_Value
(Self : not null access PostgreSQL_Query;
Name : League.Strings.Universal_String)
return League.Holders.Holder is
begin
return League.Holders.Empty_Holder;
end Bound_Value;
-------------------
-- Error_Message --
-------------------
overriding function Error_Message
(Self : not null access PostgreSQL_Query)
return League.Strings.Universal_String is
begin
return Self.Error;
end Error_Message;
-------------
-- Execute --
-------------
overriding function Execute
(Self : not null access PostgreSQL_Query) return Boolean
is
Value : League.Holders.Holder;
Params : Interfaces.C.Strings.chars_ptr_array
(1 .. Interfaces.C.size_t
(Self.Parameters.Number_Of_Positional));
begin
-- Prepare parameter values.
for J in Params'Range loop
Value := Self.Parameters.Value (Positive (J));
if League.Holders.Is_Empty (Value) then
Params (J) := Interfaces.C.Strings.Null_Ptr;
elsif League.Holders.Is_Universal_String (Value) then
Params (J) :=
Databases.New_String (League.Holders.Element (Value));
elsif League.Holders.Is_Abstract_Integer (Value) then
Params (J) :=
Interfaces.C.Strings.New_String
(League.Holders.Universal_Integer'Image
(League.Holders.Element (Value)));
elsif League.Holders.Is_Abstract_Float (Value) then
Params (J) :=
Interfaces.C.Strings.New_String
(League.Holders.Universal_Float'Image
(League.Holders.Element (Value)));
elsif League.Holders.Is_Date (Value) then
-- There was no formatting subprogram available for Date type,
-- thus, convert it into Date_Time.
declare
Date_Value : constant League.Calendars.Date :=
League.Holders.Element (Value);
Date_Time_Value : constant League.Calendars.Date_Time :=
League.Calendars.ISO_8601.Create
(League.Calendars.ISO_8601.Year (Date_Value),
League.Calendars.ISO_8601.Month (Date_Value),
League.Calendars.ISO_8601.Day (Date_Value),
0,
0,
0,
0);
begin
Params (J) :=
Interfaces.C.Strings.New_String
(League.Calendars.ISO_8601.Image
(Date_Format, Date_Time_Value).To_UTF_8_String);
end;
elsif League.Holders.Is_Date_Time (Value) then
Params (J) :=
Interfaces.C.Strings.New_String
(League.Calendars.ISO_8601.Image
(Timestamp_Format,
League.Holders.Element (Value)).To_UTF_8_String);
end if;
end loop;
-- Execute statement with prepared parameters.
Self.Result :=
PQexecPrepared
(Databases.PostgreSQL_Database'Class (Self.Database.all).Handle,
Self.Name,
Params'Length,
Params,
null,
null,
0);
-- Release parameter values.
for J in Params'Range loop
Interfaces.C.Strings.Free (Params (J));
end loop;
-- "The result is a PGresult pointer or possibly a null pointer. A
-- non-null pointer will generally be returned except in out-of-memory
-- conditions or serious errors such as inability to send the command to
-- the server. If a null pointer is returned, it should be treated like
-- a PGRES_FATAL_ERROR result. Use PQerrorMessage to get more
-- information about such errors."
-- Handle fatal error.
if Self.Result = null then
-- Obtain current error message.
Self.Error :=
Databases.PostgreSQL_Database'Class
(Self.Database.all).Get_Error_Message;
return False;
end if;
-- Handle non-fatal errors.
case PQresultStatus (Self.Result) is
when PGRES_COMMAND_OK
| PGRES_TUPLES_OK
=>
Self.Row := -1;
when others =>
-- Obtain error message.
Self.Error :=
Databases.PostgreSQL_Database'Class
(Self.Database.all).Get_Error_Message;
-- Cleanup.
PQclear (Self.Result);
Self.Result := null;
return False;
end case;
return True;
end Execute;
------------
-- Finish --
------------
overriding procedure Finish (Self : not null access PostgreSQL_Query) is
begin
raise Program_Error;
end Finish;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access PostgreSQL_Query'Class;
Database : not null access Databases.PostgreSQL_Database'Class) is
begin
SQL_Drivers.Initialize (Self, Database_Access (Database));
end Initialize;
----------------
-- Invalidate --
----------------
overriding procedure Invalidate (Self : not null access PostgreSQL_Query) is
begin
if Self.Database /= null then
Interfaces.C.Strings.Free (Self.Name);
if Self.Result /= null then
PQclear (Self.Result);
Self.Result := null;
end if;
end if;
-- Call Invalidate of parent tagged type.
Abstract_Query (Self.all).Invalidate;
end Invalidate;
---------------
-- Is_Active --
---------------
overriding function Is_Active
(Self : not null access PostgreSQL_Query) return Boolean is
begin
return Self.Result /= null;
end Is_Active;
--------------
-- Is_Valid --
--------------
overriding function Is_Valid
(Self : not null access PostgreSQL_Query) return Boolean is
begin
return
Self.Result /= null
and then Self.Row in 0 .. PQntuples (Self.Result) - 1;
end Is_Valid;
----------
-- Next --
----------
overriding function Next
(Self : not null access PostgreSQL_Query) return Boolean is
begin
if Self.Row + 1 < PQntuples (Self.Result) then
Self.Row := Self.Row + 1;
return True;
else
return False;
end if;
end Next;
-------------
-- Prepare --
-------------
overriding function Prepare
(Self : not null access PostgreSQL_Query;
Query : League.Strings.Universal_String) return Boolean
is
use type Interfaces.C.Strings.chars_ptr;
Rewritten : League.Strings.Universal_String;
C_Query : Interfaces.C.Strings.chars_ptr;
Result : PGresult_Access;
begin
-- Clear existing result set.
if Self.Result /= null then
PQclear (Self.Result);
Self.Result := null;
end if;
-- Rewrite statement and prepare set of parameters.
Rewriter.Rewrite (Query, Rewritten, Self.Parameters);
-- Convert rewrittent statement into string in client library format.
C_Query := Databases.New_String (Rewritten);
-- Allocates name for the statement when it is not allocated.
if Self.Name = Interfaces.C.Strings.Null_Ptr then
Self.Name :=
Databases.PostgreSQL_Database'Class
(Self.Database.all).Allocate_Statement_Name;
end if;
-- Prepare statement and let server to handle parameters' types.
Result :=
PQprepare
(Databases.PostgreSQL_Database'Class (Self.Database.all).Handle,
Self.Name,
C_Query,
0,
null);
-- Cleanup.
Interfaces.C.Strings.Free (C_Query);
-- "The result is normally a PGresult object whose contents indicate
-- server-side success or failure. A null result indicates out-of-memory
-- or inability to send the command at all. Use PQerrorMessage to get
-- more information about such errors."
-- Handle fatal error.
if Result = null then
-- Obtain error message.
Self.Error :=
Databases.PostgreSQL_Database'Class
(Self.Database.all).Get_Error_Message;
-- Cleanup.
Interfaces.C.Strings.Free (Self.Name);
return False;
end if;
-- Handle non-fatal errors.
if PQresultStatus (Result) /= PGRES_COMMAND_OK then
-- Obtain error message.
Self.Error :=
Databases.PostgreSQL_Database'Class
(Self.Database.all).Get_Error_Message;
-- Cleanup.
Interfaces.C.Strings.Free (Self.Name);
PQclear (Result);
return False;
end if;
-- Local cleanup.
PQclear (Result);
return True;
end Prepare;
-----------
-- Value --
-----------
overriding function Value
(Self : not null access PostgreSQL_Query;
Index : Positive) return League.Holders.Holder
is
Column : constant Interfaces.C.int := Interfaces.C.int (Index - 1);
Value : League.Holders.Holder;
begin
case Databases.PostgreSQL_Database'Class
(Self.Database.all).Get_Type (PQftype (Self.Result, Column))
is
when Databases.Text_Data =>
-- Process text data.
League.Holders.Set_Tag
(Value, League.Holders.Universal_String_Tag);
if PQgetisnull (Self.Result, Self.Row, Column) = 0 then
declare
function To_Address is
new Ada.Unchecked_Conversion
(Interfaces.C.Strings.chars_ptr, System.Address);
S : Ada.Streams.Stream_Element_Array
(1 .. Ada.Streams.Stream_Element_Offset
(PQgetlength (Self.Result, Self.Row, Column)));
for S'Address use
To_Address (PQgetvalue (Self.Result, Self.Row, Column));
pragma Import (Ada, S);
begin
League.Holders.Replace_Element (Value, Codec.Decode (S));
end;
end if;
when Databases.Integer_Data =>
-- Process integer data.
League.Holders.Set_Tag
(Value, League.Holders.Universal_Integer_Tag);
if PQgetisnull (Self.Result, Self.Row, Column) = 0 then
declare
Image : constant String
:= Interfaces.C.Strings.Value
(PQgetvalue (Self.Result, Self.Row, Column));
begin
League.Holders.Replace_Element
(Value, League.Holders.Universal_Integer'Value (Image));
end;
end if;
when Databases.Float_Data =>
-- Process float data.
League.Holders.Set_Tag (Value, League.Holders.Universal_Float_Tag);
if PQgetisnull (Self.Result, Self.Row, Column) = 0 then
declare
Image : constant String
:= Interfaces.C.Strings.Value
(PQgetvalue (Self.Result, Self.Row, Column));
begin
League.Holders.Replace_Element
(Value, League.Holders.Universal_Float'Value (Image));
end;
end if;
when Databases.Date_Data =>
-- Process DATE data.
League.Holders.Set_Tag (Value, League.Holders.Date_Tag);
if PQgetisnull (Self.Result, Self.Row, Column) = 0 then
declare
Image : constant String
:= Interfaces.C.Strings.Value
(PQgetvalue (Self.Result, Self.Row, Column));
Year : League.Calendars.ISO_8601.Year_Number;
Month : League.Calendars.ISO_8601.Month_Number;
Day : League.Calendars.ISO_8601.Day_Number;
begin
Year :=
League.Calendars.ISO_8601.Year_Number'Value
(Image (1 .. 4));
Month :=
League.Calendars.ISO_8601.Month_Number'Value
(Image (6 .. 7));
Day :=
League.Calendars.ISO_8601.Day_Number'Value
(Image (9 .. 10));
League.Holders.Replace_Element
(Value,
League.Calendars.ISO_8601.Create (Year, Month, Day));
end;
end if;
when Databases.Timestamp_Data =>
-- Process TIMESTAMP data.
League.Holders.Set_Tag (Value, League.Holders.Date_Time_Tag);
if PQgetisnull (Self.Result, Self.Row, Column) = 0 then
declare
use type League.Calendars.ISO_8601.Nanosecond_100_Number;
Image : constant String
:= Interfaces.C.Strings.Value
(PQgetvalue (Self.Result, Self.Row, Column));
Year : League.Calendars.ISO_8601.Year_Number;
Month : League.Calendars.ISO_8601.Month_Number;
Day : League.Calendars.ISO_8601.Day_Number;
Hour : League.Calendars.ISO_8601.Hour_Number;
Minute : League.Calendars.ISO_8601.Minute_Number;
Second : League.Calendars.ISO_8601.Second_Number;
Nanosecond_100 :
League.Calendars.ISO_8601.Nanosecond_100_Number;
Multiplicator :
League.Calendars.ISO_8601.Nanosecond_100_Number;
begin
Year :=
League.Calendars.ISO_8601.Year_Number'Value
(Image (1 .. 4));
Month :=
League.Calendars.ISO_8601.Month_Number'Value
(Image (6 .. 7));
Day :=
League.Calendars.ISO_8601.Day_Number'Value
(Image (9 .. 10));
Hour :=
League.Calendars.ISO_8601.Hour_Number'Value
(Image (12 .. 13));
Minute :=
League.Calendars.ISO_8601.Minute_Number'Value
(Image (15 .. 16));
Second :=
League.Calendars.ISO_8601.Second_Number'Value
(Image (18 .. 19));
Nanosecond_100 := 0;
Multiplicator := 1_000_000;
for J in 21 .. Image'Last loop
Nanosecond_100 :=
Nanosecond_100
+ (Character'Pos (Image (J)) - Character'Pos ('0'))
* Multiplicator;
Multiplicator := Multiplicator / 10;
end loop;
League.Holders.Replace_Element
(Value,
League.Calendars.ISO_8601.Create
(Year, Month, Day, Hour, Minute, Second, Nanosecond_100));
end;
end if;
end case;
return Value;
end Value;
end Matreshka.Internals.SQL_Drivers.PostgreSQL.Queries;
|
-- Définition d'une exception commune à toutes les SDA.
package SDA_Exceptions is
Cle_Absente_Exception : Exception; -- une clé est absente d'un SDA
end SDA_Exceptions;
|
-----------------------------------------------------------------------
-- security-oauth-jwt -- OAuth Java Web Token
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Util.Properties;
-- === JSON Web Token ===
-- JSON Web Token (JWT) is a compact URL-safe means of representing claims to be transferred
-- between two parties. A JWT token is returned by an authorization server. It contains
-- useful information that allows to verify the authentication and identify the user.
--
-- The <tt>Security.OAuth.JWT</tt> package implements the decoding part of JWT defined in:
-- JSON Web Token (JWT), http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-07
--
-- A list of pre-defined ID tokens are returned in the JWT token claims and used for
-- the OpenID Connect. This is specified in
-- OpenID Connect Basic Client Profile 1.0 - draft 26,
-- http://openid.net/specs/openid-connect-basic-1_0.html
--
package Security.OAuth.JWT is
-- Exception raised if the encoded token is invalid or cannot be decoded.
Invalid_Token : exception;
type Token is private;
-- Get the issuer claim from the token (the "iss" claim).
function Get_Issuer (From : in Token) return String;
-- Get the subject claim from the token (the "sub" claim).
function Get_Subject (From : in Token) return String;
-- Get the audience claim from the token (the "aud" claim).
function Get_Audience (From : in Token) return String;
-- Get the expiration claim from the token (the "exp" claim).
function Get_Expiration (From : in Token) return Ada.Calendar.Time;
-- Get the not before claim from the token (the "nbf" claim).
function Get_Not_Before (From : in Token) return Ada.Calendar.Time;
-- Get the issued at claim from the token (the "iat" claim).
-- This is the time when the JWT was issued.
function Get_Issued_At (From : in Token) return Ada.Calendar.Time;
-- Get the authentication time claim from the token (the "auth_time" claim).
function Get_Authentication_Time (From : in Token) return Ada.Calendar.Time;
-- Get the JWT ID claim from the token (the "jti" claim).
function Get_JWT_ID (From : in Token) return String;
-- Get the authorized clients claim from the token (the "azp" claim).
function Get_Authorized_Presenters (From : in Token) return String;
-- Get the claim with the given name from the token.
function Get_Claim (From : in Token;
Name : in String;
Default : in String := "") return String;
-- Decode a string representing an encoded JWT token according to the JWT specification:
--
-- Section 7. Rules for Creating and Validating a JWT
--
-- The JWT token is composed of 3 parts encoded in Base64url and separated by '.' .
-- The first part represents the header, the second part the claims and the last part
-- the signature. The <tt>Decode</tt> operation splits the parts, decodes them,
-- parses the JSON content represented by the header and the claims.
-- The <tt>Decode</tt> operation does not verify the signature (yet!).
--
-- Return the decoded token or raise an exception.
function Decode (Content : in String) return Token;
private
type Claims is new Util.Properties.Manager with null record;
type Token is record
Header : Util.Properties.Manager;
Claims : Util.Properties.Manager;
end record;
end Security.OAuth.JWT;
|
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
procedure Lucas_Lehmer_Test is
type Ull is mod 2**64;
function Mersenne(Item : Integer) return Boolean is
S : Ull := 4;
MP : Ull := 2**Item - 1;
begin
if Item = 2 then
return True;
else
for I in 3..Item loop
S := (S * S - 2) mod MP;
end loop;
return S = 0;
end if;
end Mersenne;
Upper_Bound : constant Integer := 64;
begin
Put_Line(" Mersenne primes:");
for P in 2..Upper_Bound loop
if Mersenne(P) then
Put(" M");
Put(Item => P, Width => 1);
end if;
end loop;
end Lucas_Lehmer_Test;
|
-- generated parser support file.
-- command line: wisitoken-bnf-generate.exe --generate LR1 Ada_Emacs re2c PROCESS gpr.wy
--
-- Copyright (C) 2013 - 2019 Free Software Foundation, Inc.
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version.
--
-- This software is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
with Wisi; use Wisi;
with Wisi.Gpr; use Wisi.Gpr;
package body Gpr_Process_Actions is
use WisiToken.Semantic_Checks;
procedure aggregate_g_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
null;
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple,
(Anchored_0, 1, 1))), (False, (Simple, (Anchored_0, 1, 0)))));
end case;
end aggregate_g_0;
procedure attribute_declaration_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (5, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, (1 => (2, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False,
(Simple, (Int, 0)))));
end case;
end attribute_declaration_0;
procedure attribute_declaration_1
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (8, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, (1 => (2, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int, 0))), (False,
(Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int, 0)))));
end case;
end attribute_declaration_1;
procedure attribute_declaration_2
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (10, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, (1 => (2, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int, 0))), (False,
(Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0))), (False,
(Simple, (Int, 0)))));
end case;
end attribute_declaration_2;
procedure attribute_declaration_3
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (8, Statement_End)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken - 1))), (False, (Simple, (Int, 0))), (False,
(Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int, 0)))));
end case;
end attribute_declaration_3;
procedure case_statement_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (7, Statement_End)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (True, (Simple, (Int, Gpr_Indent_When)), (Simple, (Int,
Gpr_Indent_When))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0)))));
end case;
end case_statement_0;
procedure case_item_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, (1 => (1, Motion)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent))), (False, (Simple, (Int, Gpr_Indent)))));
end case;
end case_item_0;
procedure compilation_unit_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
null;
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int, 0))),
(True, (Simple, (Int, 0)), (Simple, (Int, 0)))));
end case;
end compilation_unit_0;
function identifier_opt_1_check
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out WisiToken.Recover_Token;
Tokens : in WisiToken.Recover_Token_Array;
Recover_Active : in Boolean)
return WisiToken.Semantic_Checks.Check_Status
is
pragma Unreferenced (Lexer, Recover_Active);
begin
return Propagate_Name (Nonterm, Tokens, 1);
end identifier_opt_1_check;
procedure package_spec_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (7, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, ((2, 2, 0), (6, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (True, (Simple, (Int, Gpr_Indent)), (Simple, (Int,
Gpr_Indent))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0)))));
end case;
end package_spec_0;
function package_spec_0_check
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out WisiToken.Recover_Token;
Tokens : in WisiToken.Recover_Token_Array;
Recover_Active : in Boolean)
return WisiToken.Semantic_Checks.Check_Status
is
pragma Unreferenced (Nonterm, Recover_Active);
begin
return Match_Names (Lexer, Descriptor, Tokens, 2, 6, End_Names_Optional);
end package_spec_0_check;
procedure package_extension_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (9, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, ((2, 2, 0), (8, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False,
(Simple, (Int, 0))), (True, (Simple, (Int, Gpr_Indent)), (Simple, (Int, Gpr_Indent))), (False, (Simple, (Int,
0))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0)))));
end case;
end package_extension_0;
function package_extension_0_check
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out WisiToken.Recover_Token;
Tokens : in WisiToken.Recover_Token_Array;
Recover_Active : in Boolean)
return WisiToken.Semantic_Checks.Check_Status
is
pragma Unreferenced (Nonterm, Recover_Active);
begin
return Match_Names (Lexer, Descriptor, Tokens, 2, 8, End_Names_Optional);
end package_extension_0_check;
procedure package_renaming_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (5, Statement_End)));
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, ((2, 2, 0), (4, 2, 0)));
when Indent =>
null;
end case;
end package_renaming_0;
procedure project_extension_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (9, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, 2, 1), (2, 2, 0), (8, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False,
(Simple, (Int, 0))), (True, (Simple, (Int, Gpr_Indent)), (Simple, (Int, Gpr_Indent))), (False, (Simple, (Int,
0))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0)))));
end case;
end project_extension_0;
function project_extension_0_check
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out WisiToken.Recover_Token;
Tokens : in WisiToken.Recover_Token_Array;
Recover_Active : in Boolean)
return WisiToken.Semantic_Checks.Check_Status
is
pragma Unreferenced (Nonterm, Recover_Active);
begin
return Match_Names (Lexer, Descriptor, Tokens, 2, 8, End_Names_Optional);
end project_extension_0_check;
procedure simple_declarative_item_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (4, Statement_End)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int, 0)))));
end case;
end simple_declarative_item_0;
procedure simple_declarative_item_1
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (6, Statement_End)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int, 0)))));
end case;
end simple_declarative_item_1;
procedure simple_declarative_item_4
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (2, Statement_End)));
when Face =>
null;
when Indent =>
null;
end case;
end simple_declarative_item_4;
procedure simple_project_declaration_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (7, Statement_End)));
Name_Action (Parse_Data, Tree, Nonterm, Tokens, 2);
when Face =>
Face_Apply_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, 2, 1), (2, 2, 0), (6, 2, 0)));
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0))), (True, (Simple, (Int, Gpr_Indent)), (Simple, (Int,
Gpr_Indent))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0))), (False, (Simple, (Int, 0)))));
end case;
end simple_project_declaration_0;
function simple_project_declaration_0_check
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out WisiToken.Recover_Token;
Tokens : in WisiToken.Recover_Token_Array;
Recover_Active : in Boolean)
return WisiToken.Semantic_Checks.Check_Status
is
pragma Unreferenced (Nonterm, Recover_Active);
begin
return Match_Names (Lexer, Descriptor, Tokens, 2, 6, End_Names_Optional);
end simple_project_declaration_0_check;
procedure typed_string_declaration_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
Parse_Data : Wisi.Parse_Data_Type renames Wisi.Parse_Data_Type (User_Data);
begin
case Parse_Data.Post_Parse_Action is
when Navigate =>
Statement_Action (Parse_Data, Tree, Nonterm, Tokens, ((1, Statement_Start), (5, Statement_End)));
when Face =>
null;
when Indent =>
Indent_Action_0 (Parse_Data, Tree, Nonterm, Tokens, ((False, (Simple, (Int, 0))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, Gpr_Indent_Broken))), (False, (Simple, (Int,
Gpr_Indent_Broken))), (False, (Simple, (Int, 0)))));
end case;
end typed_string_declaration_0;
end Gpr_Process_Actions;
|
procedure Extension_Aggregate is
Str : String := "tmp";
begin
Str := String'("A String");
null;
end;
|
------------------------------------------------------------------------------
-- edp.adb
--
-- A compact Ada 95 simulation of the Enhanced Dining Philosophers Problem.
-- By "compact" it is meant that tasks representing simulation objects are
-- actually made visible to the simulation program as a whole rather than
-- being hidden in packages.
--
-- The objects in the simulation are:
--
-- 5 philosophers;
-- 5 chopsticks;
-- 2 waiters;
-- 3 cooks;
-- A host, who lets the philosophers into the restaurant and escorts them
-- out.
-- Meals, which are certain combinations of foods served by the restaurant;
-- Orders, which are of the form [philosopher, meal];
-- A heat lamp, under which cooks place the cooked orders and from which the
-- waiters pick them up (to bring them back to the philosophers);
-- A reporter, for logging events.
--
-- This is the main subprogram, EDP. The entire program consists of twelve
-- packages and this subprogram. Four packages are very general utilities;
-- the other eight are intrinsic to the simulation. The packages are
--
-- Randoms a collection of operations producing randoms
-- Protected_Counters exports a protected type Protected_Counter
-- Buffers generic package with bounded, blocking queue ADT
-- Reporter unsophisticated package for serializing messages
--
-- Names names for the simulation objects
-- Meals Meal datatype and associated operations
-- Orders Order datatype, order-bin, and heat-lamp
-- Chopsticks the chopsticks
-- Cooks the cooks
-- Host the host
-- Philosophers the philosophers
-- Waiters the waiters
--
-- The main subprogram simply reports that the restaurant is open and then
-- initializes all library tasks. The restaurant will be "closed" by the last
-- waiter to leave.
------------------------------------------------------------------------------
with Ada.Text_IO, Philosophers, Waiters, Cooks, Reporter;
use Ada.Text_IO, Philosophers, Waiters, Cooks, Reporter;
procedure EDP is
begin
Report ("The restaurant is open for business");
for C in Cook_Array'Range loop
Cook_Array(C).Here_Is_Your_Name(C);
end loop;
for W in Waiter_Array'Range loop
Waiter_Array(W).Here_Is_Your_Name(W);
end loop;
for P in Philosopher_Array'Range loop
Philosopher_Array(P).Here_Is_Your_Name(P);
end loop;
end EDP;
|
--
-- Copyright 2021 (C) Jeremy Grosser <jeremy@synack.me>
--
-- SPDX-License-Identifier: Apache-2.0
--
package Tests is
procedure Test_Version;
procedure Test_Hello_World;
procedure Test_Colors;
procedure Test_Palette;
procedure Test_Dimensions;
procedure Test_Input;
procedure Test_Plane_Split;
procedure Test_Progress_Bar;
procedure Test_Visual_File;
procedure Test_Visual_Bitmap;
procedure Test_Visual_Pixel;
procedure Test_Direct;
end Tests;
|
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Text_IO;
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
-- with Latin_Utils.Latin_File_Names; use Latin_Utils.Latin_File_Names;
-- with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package;
-- with Latin_Utils.Dictionary_Package; use Latin_Utils.Dictionary_Package;
-- with line_stuff; use line_stuff;
procedure Fixord is
use Text_IO;
Input, Output : Text_IO.File_Type;
Blank_Line : constant String (1 .. 400) := (others => ' ');
S : String (1 .. 400) := (others => ' ');
Last : Integer := 0;
begin
Put_Line ("FIXORD.IN -> FIXORD.OUT");
Put_Line ("Makes a clean (no #) 3 line ED format from LISTORD output");
Create (Output, Out_File, "FIXORD.OUT");
Open (Input, In_File, "FIXORD.IN");
Over_Lines :
while not End_Of_File (Input) loop
S := Blank_Line;
Get_Line (Input, S, Last);
if Trim (S (1 .. Last)) /= "" then -- Rejecting blank lines
if S (1) /= '#' then
Put_Line (Output, S (1 .. Last));
end if;
end if; -- Rejecting blank lines
end loop Over_Lines;
Close (Output);
exception
when Text_IO.Data_Error =>
Close (Output);
end Fixord;
|
package Tareas is
task type Tarea_1;
task type Tarea_2;
task type Tarea_3;
end Tareas;
|
-----------------------------------------------------------------------
-- util-encoders-hmac-sha1 -- Compute HMAC-SHA1 authentication code
-- Copyright (C) 2011, 2012, 2017, 2019 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.Streams;
with Ada.Finalization;
with Util.Encoders.SHA1;
-- The <b>Util.Encodes.HMAC.SHA1</b> package generates HMAC-SHA1 authentication
-- (See RFC 2104 - HMAC: Keyed-Hashing for Message Authentication).
package Util.Encoders.HMAC.SHA1 is
pragma Preelaborate;
-- Sign the data string with the key and return the HMAC-SHA1 code in binary.
function Sign (Key : in String;
Data : in String) return Util.Encoders.SHA1.Hash_Array;
-- Sign the data string with the key and return the HMAC-SHA1 code as hexadecimal string.
function Sign (Key : in String;
Data : in String) return Util.Encoders.SHA1.Digest;
-- Sign the data array with the key and return the HMAC-SHA256 code in the result.
procedure Sign (Key : in Ada.Streams.Stream_Element_Array;
Data : in Ada.Streams.Stream_Element_Array;
Result : out Util.Encoders.SHA1.Hash_Array);
-- Sign the data string with the key and return the HMAC-SHA1 code as base64 string.
-- When <b>URL</b> is True, use the base64 URL alphabet to encode in base64.
function Sign_Base64 (Key : in String;
Data : in String;
URL : in Boolean := False) return Util.Encoders.SHA1.Base64_Digest;
-- ------------------------------
-- HMAC-SHA1 Context
-- ------------------------------
type Context is limited private;
-- Set the hmac private key. The key must be set before calling any <b>Update</b>
-- procedure.
procedure Set_Key (E : in out Context;
Key : in String);
-- Set the hmac private key. The key must be set before calling any <b>Update</b>
-- procedure.
procedure Set_Key (E : in out Context;
Key : in Ada.Streams.Stream_Element_Array);
-- Update the hash with the string.
procedure Update (E : in out Context;
S : in String);
-- Update the hash with the string.
procedure Update (E : in out Context;
S : in Ada.Streams.Stream_Element_Array);
-- Computes the HMAC-SHA1 with the private key and the data collected by
-- the <b>Update</b> procedures. Returns the raw binary hash in <b>Hash</b>.
procedure Finish (E : in out Context;
Hash : out Util.Encoders.SHA1.Hash_Array);
-- Computes the HMAC-SHA1 with the private key and the data collected by
-- the <b>Update</b> procedures. Returns the hexadecimal hash in <b>Hash</b>.
procedure Finish (E : in out Context;
Hash : out Util.Encoders.SHA1.Digest);
-- Computes the HMAC-SHA1 with the private key and the data collected by
-- the <b>Update</b> procedures. Returns the base64 hash in <b>Hash</b>.
-- When <b>URL</b> is True, use the base64 URL alphabet to encode in base64.
procedure Finish_Base64 (E : in out Context;
Hash : out Util.Encoders.SHA1.Base64_Digest;
URL : in Boolean := False);
-- ------------------------------
-- HMAC-SHA1 encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- an SHA1 hexadecimal stream. The encoding alphabet is: 0123456789ABCDEF.
type Encoder is new Util.Encoders.Transformer with private;
-- Encodes the binary input stream represented by <b>Data</b> into
-- an SHA-1 hash output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in out Encoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
private
type Encoder is new Util.Encoders.Transformer with null record;
type Context is new Ada.Finalization.Limited_Controlled with record
SHA : Util.Encoders.SHA1.Context;
Key : Ada.Streams.Stream_Element_Array (0 .. 63);
Key_Len : Ada.Streams.Stream_Element_Offset;
end record;
-- Initialize the SHA-1 context.
overriding
procedure Initialize (E : in out Context);
end Util.Encoders.HMAC.SHA1;
|
with Ada.Numerics.Generic_Complex_Arrays;
generic
with package Complex_Arrays is
new Ada.Numerics.Generic_Complex_Arrays (<>);
use Complex_Arrays;
function Generic_FFT (X : Complex_Vector) return Complex_Vector;
|
package body Foo is
procedure P is begin
loop
if cond1() then
if cond2() then
Label1 :
while cond3() loop
doIt();
end loop Label1;
end if;
end if;
end loop;
end P;
end Foo;
|
-- { dg-do run }
with Init1; use Init1;
with Text_IO; use Text_IO;
with Dump;
procedure T1 is
Local_R1 : R1;
Local_R2 : R2;
begin
Local_R1.I := My_R1.I + 1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 79 56 34 12.*\n" }
Local_R2.I := My_R2.I + 1;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 79.*\n" }
Local_R1.I := 16#12345678#;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 78 56 34 12.*\n" }
Local_R2.I := 16#12345678#;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 78.*\n" }
Local_R1.I := Local_R1.I + 1;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : 79 56 34 12.*\n" }
Local_R2.I := Local_R2.I + 1;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 12 34 56 79.*\n" }
end;
|
with RP.SPI; use RP.SPI;
with RP.Device;
with RP.GPIO;
with Pico;
package body BB_Pico_Bsp.SPI is
SPI_Port : RP.SPI.SPI_Port renames RP.Device.SPI_0;
DMA_TX_Trigger : constant RP.DMA.DMA_Request_Trigger := RP.DMA.SPI0_TX;
SPI_CLK : RP.GPIO.GPIO_Point renames Pico.GP18;
SPI_DO : RP.GPIO.GPIO_Point renames Pico.GP19;
SPI_DI : RP.GPIO.GPIO_Point renames Pico.GP16;
procedure Initialize;
----------------
-- Initialize --
----------------
procedure Initialize is
Config : RP.SPI.SPI_Configuration;
begin
SPI_CLK.Configure (RP.GPIO.Output, RP.GPIO.Pull_Up, RP.GPIO.SPI);
SPI_DO.Configure (RP.GPIO.Output, RP.GPIO.Pull_Up, RP.GPIO.SPI);
SPI_DI.Configure (RP.GPIO.Output, RP.GPIO.Pull_Up, RP.GPIO.SPI);
Config := RP.SPI.Default_SPI_Configuration;
Config.Baud := 10_000_000;
Config.Blocking := True;
SPI_Port.Configure (Config);
-- DMA --
declare
use RP.DMA;
Config : DMA_Configuration;
begin
Config.Trigger := DMA_TX_Trigger;
Config.High_Priority := True;
Config.Data_Size := Transfer_8;
Config.Increment_Read := True;
Config.Increment_Write := False;
RP.DMA.Configure (SPI_TX_DMA, Config);
end;
end Initialize;
-------------
-- Go_Slow --
-------------
procedure Go_Slow is
begin
SPI_Port.Set_Speed (1_000_000);
end Go_Slow;
-------------
-- Go_Fast --
-------------
procedure Go_Fast is
begin
SPI_Port.Set_Speed (50_000_000);
end Go_Fast;
----------
-- Port --
----------
function Port return not null HAL.SPI.Any_SPI_Port is
begin
return SPI_Port'Access;
end Port;
------------------
-- DMA_Transmit --
------------------
procedure DMA_Transmit (Addr : System.Address; Len : HAL.UInt32) is
begin
loop
exit when not RP.DMA.Busy (SPI_TX_DMA);
-- Previous DMA transfer still in progress
end loop;
RP.DMA.Start (Channel => SPI_TX_DMA,
From => Addr,
To => SPI_Port.FIFO_Address,
Count => Len);
end DMA_Transmit;
--------------
-- DMA_Busy --
--------------
function DMA_Busy return Boolean
is (RP.DMA.Busy (SPI_TX_DMA) or else SPI_Port.Transmit_Status = Busy);
begin
Initialize;
end BB_Pico_Bsp.SPI;
|
--
-- Copyright (C) 2017 secunet Security Networks AG
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.GFX.GMA.Config;
package body HW.GFX.GMA.Connectors.DDI.Buffers
is
subtype Skylake_HDMI_Range is DDI_HDMI_Buf_Trans_Range range 0 .. 10;
type HDMI_Buf_Trans is record
Trans1 : Word32;
Trans2 : Word32;
end record;
type HDMI_Buf_Trans_Array is array (Skylake_HDMI_Range) of HDMI_Buf_Trans;
----------------------------------------------------------------------------
Skylake_Trans_EDP : constant Buf_Trans_Array :=
(16#0000_0018#, 16#0000_00a8#,
16#0000_4013#, 16#0000_00a9#,
16#0000_7011#, 16#0000_00a2#,
16#0000_9010#, 16#0000_009c#,
16#0000_0018#, 16#0000_00a9#,
16#0000_6013#, 16#0000_00a2#,
16#0000_7011#, 16#0000_00a6#,
16#0000_0018#, 16#0000_00ab#,
16#0000_7013#, 16#0000_009f#,
16#0000_0018#, 16#0000_00df#);
Skylake_U_Trans_EDP : constant Buf_Trans_Array :=
(16#0000_0018#, 16#0000_00a8#,
16#0000_4013#, 16#0000_00a9#,
16#0000_7011#, 16#0000_00a2#,
16#0000_9010#, 16#0000_009c#,
16#0000_0018#, 16#0000_00a9#,
16#0000_6013#, 16#0000_00a2#,
16#0000_7011#, 16#0000_00a6#,
16#0000_2016#, 16#0000_00ab#,
16#0000_5013#, 16#0000_009f#,
16#0000_0018#, 16#0000_00df#);
Skylake_Trans_DP : constant Buf_Trans_Array :=
(16#0000_2016#, 16#0000_00a0#,
16#0000_5012#, 16#0000_009b#,
16#0000_7011#, 16#0000_0088#,
16#8000_9010#, 16#0000_00c0#,
16#0000_2016#, 16#0000_009b#,
16#0000_5012#, 16#0000_0088#,
16#8000_7011#, 16#0000_00c0#,
16#0000_2016#, 16#0000_00df#,
16#8000_5012#, 16#0000_00c0#,
others => 0);
Skylake_U_Trans_DP : constant Buf_Trans_Array :=
(16#0000_201b#, 16#0000_00a2#,
16#0000_5012#, 16#0000_0088#,
16#8000_7011#, 16#0000_00cd#,
16#8000_9010#, 16#0000_00c0#,
16#0000_201b#, 16#0000_009d#,
16#8000_5012#, 16#0000_00c0#,
16#8000_7011#, 16#0000_00c0#,
16#0000_2016#, 16#0000_0088#,
16#8000_5012#, 16#0000_00c0#,
others => 0);
Skylake_Trans_HDMI : constant HDMI_Buf_Trans_Array :=
((16#0000_0018#, 16#0000_00ac#),
(16#0000_5012#, 16#0000_009d#),
(16#0000_7011#, 16#0000_0088#),
(16#0000_0018#, 16#0000_00a1#),
(16#0000_0018#, 16#0000_0098#),
(16#0000_4013#, 16#0000_0088#),
(16#8000_6012#, 16#0000_00cd#),
(16#0000_0018#, 16#0000_00df#),
(16#8000_3015#, 16#0000_00cd#),
(16#8000_3015#, 16#0000_00c0#),
(16#8000_0018#, 16#0000_00c0#));
----------------------------------------------------------------------------
procedure Translations (Trans : out Buf_Trans_Array; Port : Digital_Port)
is
DDIA_Low_Voltage_Swing : constant Boolean :=
Config.EDP_Low_Voltage_Swing and then Port = DIGI_A;
HDMI_Trans : constant Skylake_HDMI_Range :=
(if Config.DDI_HDMI_Buffer_Translation in Skylake_HDMI_Range
then Config.DDI_HDMI_Buffer_Translation
else Config.Default_DDI_HDMI_Buffer_Translation);
begin
Trans :=
(case Config.CPU_Var is
when Normal =>
(if DDIA_Low_Voltage_Swing
then Skylake_Trans_EDP
else Skylake_Trans_DP),
when ULT =>
(if DDIA_Low_Voltage_Swing
then Skylake_U_Trans_EDP
else Skylake_U_Trans_DP));
if not DDIA_Low_Voltage_Swing then
Trans (18) := Skylake_Trans_HDMI (HDMI_Trans).Trans1;
Trans (19) := Skylake_Trans_HDMI (HDMI_Trans).Trans2;
end if;
end Translations;
end HW.GFX.GMA.Connectors.DDI.Buffers;
|
-- Copyright (c) 2020 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Calendar.Formatting;
with Ada.Exceptions;
with Ada.Text_IO;
with GNAT.Sockets;
with Torrent.Logs;
package body Torrent.Managers is
task type Seeder is
entry Seed
(Value : not null Torrent.Connections.Connection_Access;
Limit : Ada.Calendar.Time);
-- Seed data to given connection until Limit expired, then accept
-- Stop_Seeding;
entry Stop_Seeding;
entry Stop;
end Seeder;
-------------
-- Manager --
-------------
task body Manager is
use type Torrent.Connections.Connection_Access;
Default_Slowdown : constant := 1.5;
type Protection_Information is record
Connection : Torrent.Connections.Connection_Access;
-- This connection is protected for next Round rounds
Round : Natural := 0; -- Zero means unprotected anymore
Found : Boolean := False; -- We have found the Connection
Skip_Count : Positive := 1;
-- How much connections we should skip to find next candidate
Skipped : Natural := 0; -- How much we have skipped
Candidate : Torrent.Connections.Connection_Access;
-- A candidate to protected position
Fallback : Torrent.Connections.Connection_Access;
-- A second candidate to protected position
end record;
-- Protected connection is unchoked regardless of its upload rate for
-- 30 seconds (3 rounds x 10 seconds).
procedure Best_Connections
(Chocked : Torrent.Connections.Connection_Vectors.Vector;
Protection : in out Protection_Information;
Result : out Torrent.Connections.Connection_Access_Array);
-- Select a few connection to seed them some data.
----------------------
-- Best_Connections --
----------------------
procedure Best_Connections
(Chocked : Torrent.Connections.Connection_Vectors.Vector;
Protection : in out Protection_Information;
Result : out Torrent.Connections.Connection_Access_Array)
is
procedure New_Round (Protection : in out Protection_Information);
-- Adjust Protection_Information for a new cycle
procedure Update_Protection
(Protection : in out Protection_Information;
Connection : Torrent.Connections.Connection_Access);
-- Update protection information
procedure Append
(Connection : Torrent.Connections.Connection_Access;
Protection : in out Protection_Information;
C_Rate : Piece_Offset);
-- Append a connection to Result taking its Rate into account.
-- Update protection information if some connection is skipped.
---------------
-- New_Round --
---------------
procedure New_Round (Protection : in out Protection_Information) is
begin
Protection.Found := False;
Protection.Skipped := 0;
Protection.Candidate := null;
Protection.Fallback := null;
end New_Round;
-----------------------
-- Update_Protection --
-----------------------
procedure Update_Protection
(Protection : in out Protection_Information;
Connection : Torrent.Connections.Connection_Access) is
begin
if Protection.Fallback = null then
-- Remember very first skipped connection as fallback
Protection.Fallback := Connection;
elsif Protection.Skip_Count = Protection.Skipped then
-- Take candidate after skipping Skip_Count connections
Protection.Candidate := Connection;
end if;
if Protection.Connection = Connection and Protection.Round > 0 then
Protection.Found := True;
end if;
Protection.Skipped := Protection.Skipped + 1;
end Update_Protection;
Rate : array (Result'Range) of Piece_Offset;
Last : Natural := Result'First - 1;
------------
-- Append --
------------
procedure Append
(Connection : Torrent.Connections.Connection_Access;
Protection : in out Protection_Information;
C_Rate : Piece_Offset)
is
use type Piece_Offset;
begin
for J in Result'First .. Last loop
if Rate (J) < C_Rate then
-- Found rate worse then C, insert C into Result
if Last = Result'Last then
-- Result is full, skip last element
Update_Protection (Protection, Result (Last));
Result (J + 1 .. Last) := Result (J .. Last - 1);
Rate (J + 1 .. Last) := Rate (J .. Last - 1);
else
Result (J + 1 .. Last + 1) := Result (J .. Last);
Rate (J + 1 .. Last + 1) := Rate (J .. Last);
Last := Last + 1;
end if;
Result (J) := Connection;
Rate (J) := C_Rate;
return;
end if;
end loop;
if Last < Result'Last then
-- Append C to Result if there is free space
Last := Last + 1;
Result (Last) := Connection;
Rate (Last) := C_Rate;
end if;
end Append;
begin
New_Round (Protection);
Result := (Result'Range => null);
for X of Chocked loop
if X.Intrested then
Append (X, Protection, X.Downloaded);
end if;
end loop;
if Protection.Found then
Append (Protection.Connection, Protection, Piece_Offset'Last);
Protection.Round := Protection.Round - 1;
elsif Protection.Candidate /= null then
Append (Protection.Candidate, Protection, Piece_Offset'Last);
Protection.Connection := Protection.Candidate;
Protection.Round := 2;
Protection.Skip_Count := Protection.Skip_Count + 1;
elsif Protection.Fallback /= null then
Append (Protection.Fallback, Protection, Piece_Offset'Last);
Protection.Connection := Protection.Fallback;
Protection.Round := 2;
Protection.Skip_Count := 1;
end if;
end Best_Connections;
Protection : Protection_Information;
Seeders : array (1 .. 4) of Seeder;
Slowdown : Duration := Default_Slowdown;
Chocked : Torrent.Connections.Connection_Vectors.Vector;
Selector : GNAT.Sockets.Selector_Type;
begin
GNAT.Sockets.Create_Selector (Selector);
loop
select
accept Connected
(Value : not null Torrent.Connections.Connection_Access)
do
Chocked.Append (Value);
Slowdown := 0.0;
end Connected;
or
accept Complete;
exit;
else
delay Slowdown;
end select;
declare
use type Ada.Calendar.Time;
List : Torrent.Connections.Connection_Access_Array
(Seeders'Range);
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
Limit : constant Ada.Calendar.Time := Now + Seed_Time;
Count : Natural := 0;
begin
Best_Connections (Chocked, Protection, List);
for J in List'Range loop
if List (J) /= null then
Seeders (J).Seed (List (J), Limit);
Count := Count + 1;
end if;
end loop;
pragma Debug
(Torrent.Logs.Enabled,
Torrent.Logs.Print
(Ada.Calendar.Formatting.Image (Now)
& " Unchocked=" & (Count'Image)
& " /" & (Chocked.Length'Img)));
Torrent.Connections.Serve_All (Selector, Chocked, List, Limit);
-- delete chocked connections.
declare
J : Positive := 1;
Conn : Torrent.Connections.Connection_Access;
begin
while J <= Chocked.Last_Index loop
Conn := Chocked (J);
if Conn.Connected then
J := J + 1;
else
Recycle.Enqueue (Conn);
Chocked.Delete (J);
if Chocked.Is_Empty then
Slowdown := Default_Slowdown;
end if;
end if;
end loop;
end;
for J in List'Range loop
if List (J) /= null then
Seeders (J).Stop_Seeding;
end if;
end loop;
end;
end loop;
for J in Seeders'Range loop
Seeders (J).Stop;
end loop;
GNAT.Sockets.Close_Selector (Selector);
exception
when E : others =>
pragma Debug
(Torrent.Logs.Enabled,
Torrent.Logs.Print
(Ada.Exceptions.Exception_Information (E)));
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
end Manager;
-------------
-- Session --
-------------
task body Seeder is
Conn : Torrent.Connections.Connection_Access;
Time : Ada.Calendar.Time;
begin
loop
select
accept Stop;
exit;
or
accept Seed
(Value : not null Torrent.Connections.Connection_Access;
Limit : Ada.Calendar.Time)
do
Conn := Value;
Time := Limit;
end Seed;
end select;
if Conn.Intrested then
Conn.Set_Choked (False);
Conn.Serve (Time);
Conn.Set_Choked (True);
end if;
accept Stop_Seeding;
end loop;
end Seeder;
end Torrent.Managers;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . C H A R A C T E R S . H A N D L I N G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2021, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package Ada.Characters.Handling is
pragma Pure;
-- In accordance with Ada 2005 AI-362
----------------------------------------
-- Character Classification Functions --
----------------------------------------
function Is_Control (Item : Character) return Boolean;
function Is_Graphic (Item : Character) return Boolean;
function Is_Letter (Item : Character) return Boolean;
function Is_Lower (Item : Character) return Boolean;
function Is_Upper (Item : Character) return Boolean;
function Is_Basic (Item : Character) return Boolean;
function Is_Digit (Item : Character) return Boolean;
function Is_Decimal_Digit (Item : Character) return Boolean
renames Is_Digit;
function Is_Hexadecimal_Digit (Item : Character) return Boolean;
function Is_Alphanumeric (Item : Character) return Boolean;
function Is_Special (Item : Character) return Boolean;
function Is_Line_Terminator (Item : Character) return Boolean;
function Is_Mark (Item : Character) return Boolean;
function Is_Other_Format (Item : Character) return Boolean;
function Is_Punctuation_Connector (Item : Character) return Boolean;
function Is_Space (Item : Character) return Boolean;
function Is_NFKC (Item : Character) return Boolean;
---------------------------------------------------
-- Conversion Functions for Character and String --
---------------------------------------------------
function To_Lower (Item : Character) return Character;
function To_Upper (Item : Character) return Character;
function To_Basic (Item : Character) return Character;
function To_Lower (Item : String) return String;
function To_Upper (Item : String) return String;
function To_Basic (Item : String) return String;
----------------------------------------------------------------------
-- Classifications of and Conversions Between Character and ISO 646 --
----------------------------------------------------------------------
subtype ISO_646 is
Character range Character'Val (0) .. Character'Val (127);
function Is_ISO_646 (Item : Character) return Boolean;
function Is_ISO_646 (Item : String) return Boolean;
function To_ISO_646
(Item : Character;
Substitute : ISO_646 := ' ') return ISO_646;
function To_ISO_646
(Item : String;
Substitute : ISO_646 := ' ') return String;
------------------------------------------------------
-- Classifications of Wide_Character and Characters --
------------------------------------------------------
-- Ada 2005 AI 395: these functions are moved to Ada.Characters.Conversions
-- and are considered obsolete in Ada.Characters.Handling. However we do
-- not complain about this obsolescence, since in practice it is necessary
-- to use these routines when creating code that is intended to run in
-- either Ada 95 or Ada 2005 mode.
-- We do however have to flag these if the pragma No_Obsolescent_Features
-- restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
function Is_Character (Item : Wide_Character) return Boolean;
function Is_String (Item : Wide_String) return Boolean;
------------------------------------------------------
-- Conversions between Wide_Character and Character --
------------------------------------------------------
-- Ada 2005 AI 395: these functions are moved to Ada.Characters.Conversions
-- and are considered obsolete in Ada.Characters.Handling. However we do
-- not complain about this obsolescence, since in practice it is necessary
-- to use these routines when creating code that is intended to run in
-- either Ada 95 or Ada 2005 mode.
-- We do however have to flag these if the pragma No_Obsolescent_Features
-- restriction is active (see Restrict.Check_Obsolescent_2005_Entity).
function To_Character
(Item : Wide_Character;
Substitute : Character := ' ') return Character;
function To_String
(Item : Wide_String;
Substitute : Character := ' ') return String;
function To_Wide_Character
(Item : Character) return Wide_Character;
function To_Wide_String
(Item : String) return Wide_String;
private
pragma Inline (Is_Alphanumeric);
pragma Inline (Is_Basic);
pragma Inline (Is_Character);
pragma Inline (Is_Control);
pragma Inline (Is_Digit);
pragma Inline (Is_Graphic);
pragma Inline (Is_Hexadecimal_Digit);
pragma Inline (Is_ISO_646);
pragma Inline (Is_Letter);
pragma Inline (Is_Line_Terminator);
pragma Inline (Is_Lower);
pragma Inline (Is_Mark);
pragma Inline (Is_Other_Format);
pragma Inline (Is_Punctuation_Connector);
pragma Inline (Is_Space);
pragma Inline (Is_Special);
pragma Inline (Is_Upper);
pragma Inline (To_Basic);
pragma Inline (To_Character);
pragma Inline (To_Lower);
pragma Inline (To_Upper);
pragma Inline (To_Wide_Character);
end Ada.Characters.Handling;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of 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.Unchecked_Conversion;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.PWR; use STM32_SVD.PWR;
with STM32_SVD.SYSCFG; use STM32_SVD.SYSCFG;
with STM32_SVD.Flash; use STM32_SVD.Flash;
package body STM32.RCC is
function To_AHBRSTR_T is new Ada.Unchecked_Conversion
(UInt32, AHBRSTR_Register);
function To_APB1RSTR_T is new Ada.Unchecked_Conversion
(UInt32, APB1RSTR_Register);
function To_APB2RSTR_T is new Ada.Unchecked_Conversion
(UInt32, APB2RSTR_Register);
---------------------------------------------------------------------------
------- Enable/Disable/Reset Routines -----------------------------------
---------------------------------------------------------------------------
procedure BKPSRAM_Clock_Enable is
begin
RCC_Periph.AHBENR.SRAMEN := True;
end BKPSRAM_Clock_Enable;
procedure AHB_Force_Reset is
begin
RCC_Periph.AHBRSTR := To_AHBRSTR_T (16#FFFF_FFFF#);
end AHB_Force_Reset;
procedure AHB_Release_Reset is
begin
RCC_Periph.AHBRSTR := To_AHBRSTR_T (0);
end AHB_Release_Reset;
procedure APB1_Force_Reset is
begin
RCC_Periph.APB1RSTR := To_APB1RSTR_T (16#FFFF_FFFF#);
end APB1_Force_Reset;
procedure APB1_Release_Reset is
begin
RCC_Periph.APB1RSTR := To_APB1RSTR_T (0);
end APB1_Release_Reset;
procedure APB2_Force_Reset is
begin
RCC_Periph.APB2RSTR := To_APB2RSTR_T (16#FFFF_FFFF#);
end APB2_Force_Reset;
procedure APB2_Release_Reset is
begin
RCC_Periph.APB2RSTR := To_APB2RSTR_T (0);
end APB2_Release_Reset;
procedure Backup_Domain_Reset is
begin
RCC_Periph.BDCR.BDRST := True;
RCC_Periph.BDCR.BDRST := False;
end Backup_Domain_Reset;
---------------------------------------------------------------------------
-- Clock Configuration --------------------------------------------------
---------------------------------------------------------------------------
-------------------
-- Set_HSE Clock --
-------------------
procedure Set_HSE_Clock
(Enable : Boolean;
Bypass : Boolean := False;
Enable_CSS : Boolean := False)
is
begin
if Enable and not RCC_Periph.CR.HSEON then
RCC_Periph.CR.HSEON := True;
loop
exit when RCC_Periph.CR.HSERDY;
end loop;
end if;
RCC_Periph.CR.HSEBYP := Bypass;
RCC_Periph.CR.CSSON := Enable_CSS;
end Set_HSE_Clock;
-----------------------
-- HSE Clock_Enabled --
-----------------------
function HSE_Clock_Enabled return Boolean is
begin
return RCC_Periph.CR.HSEON;
end HSE_Clock_Enabled;
-------------------
-- Set_LSE Clock --
-------------------
procedure Set_LSE_Clock
(Enable : Boolean;
Bypass : Boolean := False;
Capability : HSE_Capability)
is
begin
if Enable and not RCC_Periph.BDCR.LSEON then
RCC_Periph.BDCR.LSEON := True;
loop
exit when RCC_Periph.BDCR.LSERDY;
end loop;
end if;
RCC_Periph.BDCR.LSEBYP := Bypass;
RCC_Periph.BDCR.LSEDRV := Capability'Enum_Rep;
end Set_LSE_Clock;
-----------------------
-- LSE Clock_Enabled --
-----------------------
function LSE_Clock_Enabled return Boolean is
begin
return RCC_Periph.BDCR.LSEON;
end LSE_Clock_Enabled;
-------------------
-- Set_HSI_Clock --
-------------------
procedure Set_HSI_Clock (Enable : Boolean) is
begin
if Enable then
if not RCC_Periph.CR.HSION then
RCC_Periph.CR.HSION := True;
loop
exit when RCC_Periph.CR.HSIRDY;
end loop;
end if;
else
RCC_Periph.CR.HSION := False;
end if;
end Set_HSI_Clock;
-----------------------
-- HSI_Clock_Enabled --
-----------------------
function HSI_Clock_Enabled return Boolean is
begin
return RCC_Periph.CR.HSION;
end HSI_Clock_Enabled;
-------------------
-- Set_LSI Clock --
-------------------
procedure Set_LSI_Clock (Enable : Boolean) is
begin
if Enable and not RCC_Periph.CSR.LSION then
RCC_Periph.CSR.LSION := True;
loop
exit when RCC_Periph.CSR.LSIRDY;
end loop;
end if;
end Set_LSI_Clock;
-----------------------
-- LSI Clock_Enabled --
-----------------------
function LSI_Clock_Enabled return Boolean is
begin
return RCC_Periph.CSR.LSION;
end LSI_Clock_Enabled;
--------------------------------
-- Configure_System_Clock_Mux --
--------------------------------
procedure Configure_System_Clock_Mux (Source : SYSCLK_Clock_Source)
is
begin
RCC_Periph.CFGR.SW := Source'Enum_Rep;
loop
exit when RCC_Periph.CFGR.SWS = Source'Enum_Rep;
end loop;
end Configure_System_Clock_Mux;
-----------------------------------
-- Configure_AHB_Clock_Prescaler --
-----------------------------------
procedure Configure_AHB_Clock_Prescaler
(Value : AHB_Prescaler)
is
function To_AHB is new Ada.Unchecked_Conversion
(AHB_Prescaler, UInt4);
begin
RCC_Periph.CFGR.HPRE := To_AHB (Value);
end Configure_AHB_Clock_Prescaler;
-----------------------------------
-- Configure_APB_Clock_Prescaler --
-----------------------------------
procedure Configure_APB_Clock_Prescaler
(Bus : APB_Clock_Range;
Value : APB_Prescaler)
is
function To_APB is new Ada.Unchecked_Conversion
(APB_Prescaler, UInt3);
begin
case Bus is
when APB_1 =>
RCC_Periph.CFGR.PPRE.Arr (1) := To_APB (Value);
when APB_2 =>
RCC_Periph.CFGR.PPRE.Arr (2) := To_APB (Value);
end case;
end Configure_APB_Clock_Prescaler;
------------------------------
-- Configure_PLL_Source_Mux --
------------------------------
procedure Configure_PLL_Source_Mux (Source : PLL_Clock_Source) is
begin
RCC_Periph.CFGR.PLLSRC := Source = PLL_SRC_HSE;
end Configure_PLL_Source_Mux;
-------------------
-- Configure_PLL --
-------------------
procedure Configure_PLL
(Enable : Boolean;
PREDIV : PREDIV_Range := PREDIV_Range'First;
PLLMUL : PLLMUL_Range := PLLMUL_Range'First)
is
begin
-- Disable the main PLL before configuring it
RCC_Periph.CR.PLLON := False;
loop
exit when not RCC_Periph.CR.PLLRDY;
end loop;
if Enable then
RCC_Periph.CFGR.PLLMUL := UInt4 (PLLMUL'Enum_Rep - 2);
RCC_Periph.CFGR2.PREDIV := UInt4 (PREDIV'Enum_Rep - 1);
-- Setup PLL and wait for stabilization.
RCC_Periph.CR.PLLON := Enable;
loop
exit when RCC_Periph.CR.PLLRDY;
end loop;
end if;
end Configure_PLL;
--------------------------------
-- Configure_MCO_Output_Clock --
--------------------------------
procedure Configure_MCO_Output_Clock
(Source : MCO_Clock_Source;
Value : MCO_Prescaler;
Nodiv : Boolean := False)
is
begin
RCC_Periph.CFGR.MCO := Source'Enum_Rep;
RCC_Periph.CFGR.MCOPRE := Value'Enum_Rep;
RCC_Periph.CFGR.PLLNODIV := Nodiv;
end Configure_MCO_Output_Clock;
-----------------------
-- Set_FLASH_Latency --
-----------------------
procedure Set_FLASH_Latency (Latency : FLASH_Wait_State)
is
begin
Flash_Periph.ACR.LATENCY := Latency'Enum_Rep;
end Set_FLASH_Latency;
end STM32.RCC;
|
with Ada.Integer_Text_IO;
procedure Eukl is
A, B : Natural;
Tmp: Natural;
begin
Ada.Integer_Text_IO.Get( A );
Ada.Integer_Text_IO.Get( B );
while B /= 0 loop
Tmp := A mod B;
A := B;
B := Tmp;
end loop;
Ada.Integer_Text_IO.Put( A );
end Eukl;
|
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Strings.Maps;
procedure Natools.Chunked_Strings.Tests.Bugfixes
(Report : in out Natools.Tests.Reporter'Class)
is
package NT renames Natools.Tests;
begin
Report.Section ("Tests for known bugs");
declare
Name : constant String := "Overreach of Index";
CS : Chunked_String := To_Chunked_String ("abcd0123");
N : Natural;
begin
CS.Head (4);
N := CS.Index (Ada.Strings.Maps.To_Set ("0123456789"));
if N /= 0 then
Report.Item (Name, NT.Fail);
Report.Info ("Index of digit" & Natural'Image (N) & ", expected 0.");
else
Report.Item (Name, NT.Success);
end if;
exception
when Error : others => NT.Report_Exception (Report, Name, Error);
end;
Report.End_Section;
end Natools.Chunked_Strings.Tests.Bugfixes;
|
with Ada.Unchecked_Deallocation;
with kv.avm.Log; use kv.avm.Log;
with kv.avm.Actor_Pool;
package body kv.avm.Test.Runners is
use Interfaces;
-----------------------------------------------------------------------------
procedure Execute
(Self : in out Base_Behavior_Type;
Runner : in out Runner_Type'CLASS) is
begin
Put_Line("Base_Behavior_Type for " & Runner.Image & ", Self.Remaining = " & Natural'IMAGE(Self.Remaining));
if Self.Remaining = 0 then
Do_It_Now(Base_Behavior_Type'CLASS(Self), Runner);
Self.Remaining := Self.Cycle_Time;
else
Self.Remaining := Self.Remaining - 1;
end if;
end Execute;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Consume_After_X is new Base_Behavior_Type with null record;
type Consume_After_X_Access is access all Consume_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Consume_After_X, Consume_After_X_Access);
-----------------------------------------------------------------------------
procedure Do_It_Now
(Self : in out Consume_After_X;
Runner : in out Runner_Type'CLASS) is
begin
Runner.Running := False;
end Do_It_Now;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Send_After_X is new Base_Behavior_Type with
record
Destination : kv.avm.Actor_References.Actor_Reference_Type;
end record;
type Send_After_X_Access is access all Send_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Send_After_X, Send_After_X_Access);
-----------------------------------------------------------------------------
procedure Execute
(Self : in out Send_After_X;
Runner : in out Runner_Type'CLASS) is
Machine : kv.avm.Control.Control_Access;
Empty_Tuple : aliased kv.avm.Tuples.Tuple_Type;
Message : kv.avm.Messages.Message_Type;
begin
Put_Line("Send_After_X for " & Runner.Image & ", Self.Remaining = " & Natural'IMAGE(Self.Remaining));
if Self.Remaining = 0 then
Machine := Runner.CPU.Get_Machine;
Empty_Tuple.Initialize;
Empty_Tuple.Fold_Empty;
Message.Initialize
(Source => kv.avm.Actor_References.Null_Reference,
Reply_To => kv.avm.Actor_References.Null_Reference,
Destination => Self.Destination,
Message_Name => "Ping",
Data => Empty_Tuple,
Future => kv.avm.Control.NO_FUTURE);
Machine.Post_Message
(Message => Message,
Status => Runner.Status); -- Important to pass this through
Self.Remaining := Self.Cycle_Time;
else
Runner.Status := kv.avm.Control.Active;
Self.Remaining := Self.Remaining - 1;
end if;
end Execute;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Spawn_After_X is new Base_Behavior_Type with null record;
type Spawn_After_X_Access is access all Spawn_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Spawn_After_X, Spawn_After_X_Access);
-----------------------------------------------------------------------------
procedure Do_It_Now
(Self : in out Spawn_After_X;
Runner : in out Runner_Type'CLASS) is
Machine : kv.avm.Control.Control_Access;
Actor : kv.avm.Actor_References.Actor_Reference_Type;
Empty_Tuple : aliased kv.avm.Tuples.Tuple_Type;
Status : kv.avm.Control.Status_Type;
Message : kv.avm.Messages.Message_Type;
begin
Machine := Runner.CPU.Get_Machine;
Machine.New_Actor("Test_A1", Actor);
Empty_Tuple.Initialize;
Empty_Tuple.Fold_Empty;
Message.Initialize
(Source => kv.avm.Actor_References.Null_Reference,
Reply_To => kv.avm.Actor_References.Null_Reference,
Destination => Actor,
Message_Name => "CONSTRUCTOR",
Data => Empty_Tuple,
Future => kv.avm.Control.NO_FUTURE);
Machine.Post_Message
(Message => Message,
Status => Status);
end Do_It_Now;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Runner_Type;
ID : in Interfaces.Unsigned_32;
Next : in Runner_Access) is
Behavior : Consume_After_X_Access;
begin
Self.ID := ID;
Put_Line(Self.Image & ".Initialize");
Self.Next := kv.avm.Executables.Executable_Access(Next);
Behavior := new Consume_After_X;
Behavior.Cycle_Time := 3;
Behavior.Remaining := 3;
Self.Behavior := Behavior_Access(Behavior);
end Initialize;
-----------------------------------------------------------------------------
procedure Free_Behavior
(Self : in out Runner_Type) is
Free_Me : Consume_After_X_Access;
begin
if Self.Behavior /= null then
if Self.Behavior.all in Consume_After_X'CLASS then
Free_Me := Consume_After_X_Access(Self.Behavior);
Free(Free_Me);
Self.Behavior := null;
end if;
end if;
end Free_Behavior;
-----------------------------------------------------------------------------
procedure Set_Behavior_Send
(Self : in out Runner_Type;
Destination : in kv.avm.Actor_References.Actor_Reference_Type;
Cycle_Time : in Natural) is
Behavior : Send_After_X_Access;
begin
Self.Free_Behavior;
Behavior := new Send_After_X;
Behavior.Cycle_Time := Cycle_Time;
Behavior.Remaining := Cycle_Time;
Behavior.Destination := Destination;
Self.Behavior := Behavior_Access(Behavior);
end Set_Behavior_Send;
-----------------------------------------------------------------------------
procedure Set_Behavior_Spawn
(Self : in out Runner_Type;
Cycle_Time : in Natural) is
Behavior : Spawn_After_X_Access;
begin
Self.Free_Behavior;
Behavior := new Spawn_After_X;
Behavior.Cycle_Time := Cycle_Time;
Behavior.Remaining := Cycle_Time;
Self.Behavior := Behavior_Access(Behavior);
end Set_Behavior_Spawn;
-----------------------------------------------------------------------------
procedure Process_Message
(Self : in out Runner_Type;
Message : in kv.avm.Messages.Message_Type) is
begin
Put_Line(Self.Image & ".Process_Message " & Message.Image);
Self.Running := True;
Self.Last_Msg := Message;
end Process_Message;
-----------------------------------------------------------------------------
procedure Process_Gosub
(Self : access Runner_Type;
Tailcall : in Boolean;
Supercall : in Boolean;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Method : in kv.avm.Registers.String_Type;
Data : access constant kv.avm.Memories.Register_Set_Type;
Future : in Interfaces.Unsigned_32) is
begin
Put_Line(Self.Image & ".Process_Gosub");
end Process_Gosub;
-----------------------------------------------------------------------------
function Can_Accept_Message_Now(Self : Runner_Type; Message : kv.avm.Messages.Message_Type) return Boolean is
begin
Put_Line(Self.Image & ".Can_Accept_Message_Now returning " & Boolean'IMAGE(not Self.Running));
return not Self.Running;
end Can_Accept_Message_Now;
-----------------------------------------------------------------------------
function Program_Counter
(Self : in Runner_Type) return Interfaces.Unsigned_32 is
begin
Put_Line(Self.Image & ".Program_Counter = " & Interfaces.Unsigned_32'IMAGE(Self.PC));
return Self.PC;
end Program_Counter;
-----------------------------------------------------------------------------
function Is_Running
(Self : in Runner_Type) return Boolean is
begin
Put_Line(Self.Image & ".Is_Running = " & Boolean'IMAGE(Self.Running));
return Self.Running;
end Is_Running;
-----------------------------------------------------------------------------
procedure Step
(Self : access Runner_Type;
Processor : access kv.avm.Processors.Processor_Type;
Status : out kv.avm.Control.Status_Type) is
begin
Put_Line(Self.Image & ".Step");
Self.CPU := Processor.all'ACCESS;
Self.PC := Self.PC + 1;
if Self.Behavior /= null then
Self.Behavior.Execute(Self.all);
end if;
Status := Self.Status;
end Step;
-----------------------------------------------------------------------------
procedure Process_Internal_Response
(Self : in out Runner_Type;
Answer : in kv.avm.Tuples.Tuple_Type) is
begin
Put_Line(Self.Image & ".Process_Internal_Response");
end Process_Internal_Response;
-----------------------------------------------------------------------------
procedure Resolve_Future
(Self : in out Runner_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
begin
Put_Line(Self.Image & ".Resolve_Future");
end Resolve_Future;
-----------------------------------------------------------------------------
procedure Halt_Actor
(Self : in out Runner_Type) is
begin
Put_Line(Self.Image & ".Halt_Actor");
Self.Running := False;
end Halt_Actor;
-----------------------------------------------------------------------------
function Reachable(Self : Runner_Type) return kv.avm.Actor_References.Sets.Set is
begin
return kv.avm.Actor_References.Sets.Empty_Set;
end Reachable;
-----------------------------------------------------------------------------
function Image(Self : Runner_Type) return String is
Id_Img : constant String := Interfaces.Unsigned_32'IMAGE(Self.ID);
begin
return "Runner_"&Id_Img(2 .. Id_Img'LAST);
end Image;
-----------------------------------------------------------------------------
function Debug_Info(Self : Runner_Type) return String is
begin
return Self.Image & ".Debug_Info";
end Debug_Info;
-----------------------------------------------------------------------------
procedure New_Executable
(Self : in out Runner_Factory;
Actor : in kv.avm.Actors.Actor_Access;
Machine : in kv.avm.Control.Control_Access;
Executable : out kv.avm.Executables.Executable_Access;
Reference : out kv.avm.Actor_References.Actor_Reference_Type) is
Instance : Runner_Access;
begin
Put_Line("Runner_Factory.New_Executable");
Instance := new Runner_Type;
Self.Count := Self.Count + 1;
Instance.Initialize(Self.Count, Self.Head);
Self.Head := Instance;
kv.avm.Actor_Pool.Add(kv.avm.Executables.Executable_Access(Instance), Reference);
Executable := kv.avm.Executables.Executable_Access(Instance);
end New_Executable;
-----------------------------------------------------------------------------
function Get_Allocated_Count(Self : Runner_Factory) return Natural is
begin
return Natural(Self.Count);
end Get_Allocated_Count;
-----------------------------------------------------------------------------
function Runner_By_ID(Runner : Runner_Access; ID : Interfaces.Unsigned_32) return Runner_Access is
begin
if Runner.ID = ID then
return Runner;
else
return Runner_By_ID(Runner_Access(Runner.Next), ID);
end if;
end Runner_By_ID;
-----------------------------------------------------------------------------
function Get_Runner_By_ID(Self : Runner_Factory; ID : Interfaces.Unsigned_32) return Runner_Access is
begin
return Runner_By_ID(Self.Head, ID);
end Get_Runner_By_ID;
end kv.avm.Test.Runners;
|
package Problem_50 is
-- The prime 41, can be written as the sum of six consecutive primes:
-- 41 = 2 + 3 + 5 + 7 + 11 + 13
-- This is the longest sum of consecutive primes that adds to a prime below
-- one-hundred. The longest sum of consecutive primes below one-thousand that
-- adds to a prime, contains 21 terms, and is equal to 953.
--
-- Which prime, below one-million, can be written as the sum of the most
-- consecutive primes?
procedure Solve;
end Problem_50;
|
pragma License (Unrestricted);
with Ada.Calendar;
with Ada.Directories.Information;
with Ada.Hierarchical_File_Names;
with System;
with GNAT.Calendar;
with GNAT.Strings;
private with System.Native_IO; -- implementation unit
package GNAT.OS_Lib is
-- Note: Ada.Directories is not preelaborate.
-- String Operations
subtype String_Access is Strings.String_Access;
function "=" (Left, Right : String_Access) return Boolean
renames Strings."=";
procedure Free (X : in out String_Access)
renames Strings.Free;
subtype String_List is Strings.String_List;
subtype String_List_Access is Strings.String_List_Access;
procedure Free (Arg : in out String_List_Access)
renames Strings.Free;
function "=" (Left, Right : String_List_Access) return Boolean
renames Strings."=";
-- Time/Date Stuff
subtype OS_Time is Ada.Calendar.Time;
Invalid_Time : constant OS_Time := GNAT.Calendar.No_Time;
subtype Year_Type is Integer range 1900 .. 2099;
subtype Month_Type is Integer range 1 .. 12;
subtype Day_Type is Integer range 1 .. 31;
subtype Hour_Type is Integer range 0 .. 23;
subtype Minute_Type is Integer range 0 .. 59;
subtype Second_Type is Integer range 0 .. 59;
procedure GM_Split (
Date : OS_Time;
Year : out Year_Type;
Month : out Month_Type;
Day : out Day_Type;
Hour : out Hour_Type;
Minute : out Minute_Type;
Second : out Second_Type);
-- File Stuff
type File_Descriptor is private;
function "=" (Left, Right : File_Descriptor) return Boolean
with Import, Convention => Intrinsic;
Standin : constant File_Descriptor;
Standout : constant File_Descriptor;
Standerr : constant File_Descriptor;
Invalid_FD : constant File_Descriptor;
procedure Close (FD : File_Descriptor);
type Copy_Mode is (Copy, Overwrite);
type Attribute is (Time_Stamps, Full);
procedure Copy_File (
Name : String;
Pathname : String;
Success : out Boolean;
Mode : Copy_Mode := Copy;
Preserve : Attribute := Time_Stamps);
procedure Copy_File_Attributes (
From : String;
To : String;
Success : out Boolean;
Copy_Timestamp : Boolean := True;
Copy_Permissions : Boolean := True);
type Mode is (Binary);
function Create_File (Name : String; Fmode : Mode) return File_Descriptor;
Temp_File_Len : constant Integer := 10;
-- The length of a temporary name is 10 ("ADAXXXXXX" & NUL) in drake,
-- against 12 ("GNAT-XXXXXX" & NUL) in GNAT runtime.
subtype Temp_File_Name is String (1 .. Temp_File_Len);
procedure Create_Temp_File (
FD : out File_Descriptor;
Name : out Temp_File_Name);
procedure Create_Temp_File (
FD : out File_Descriptor;
Name : out String_Access);
procedure Delete_File (Name : String; Success : out Boolean);
function File_Length (FD : File_Descriptor) return Long_Integer;
function File_Time_Stamp (Name : String) return OS_Time;
function Is_Absolute_Path (Name : String) return Boolean
renames Ada.Hierarchical_File_Names.Is_Full_Name;
function Is_Directory (Name : String) return Boolean;
function Is_Regular_File (Name : String) return Boolean;
function Is_Symbolic_Link (Name : String) return Boolean
renames Ada.Directories.Information.Is_Symbolic_Link;
function Is_Writable_File (Name : String) return Boolean;
function Locate_Exec_On_Path (Exec_Name : String) return String_Access;
function Locate_Regular_File (File_Name : String; Path : String)
return String_Access;
Seek_Set : constant := 0;
Seek_Cur : constant := 1;
Seek_End : constant := 2;
procedure Lseek (
FD : File_Descriptor;
offset : Long_Integer;
origin : Integer);
function Normalize_Pathname (
Name : String;
Directory : String := "";
Resolve_Links : Boolean := True;
Case_Sensitive : Boolean := True)
return String;
function Open_Read (Name : String; Fmode : Mode) return File_Descriptor;
function Open_Read_Write (Name : String; Fmode : Mode)
return File_Descriptor;
function Read (FD : File_Descriptor; A : System.Address; N : Integer)
return Integer;
procedure Rename_File (
Old_Name : String;
New_Name : String;
Success : out Boolean);
procedure Set_Non_Readable (Name : String);
procedure Set_Non_Writable (Name : String);
procedure Set_Readable (Name : String);
procedure Set_Writable (Name : String);
function Write (FD : File_Descriptor; A : System.Address; N : Integer)
return Integer;
-- Subprocesses
subtype Argument_List is String_List;
subtype Argument_List_Access is String_List_Access;
-- Miscellaneous
function Errno return Integer;
function Getenv (Name : String) return String_Access;
procedure OS_Exit (Status : Integer);
Directory_Separator : constant Character :=
Ada.Hierarchical_File_Names.Default_Path_Delimiter;
pragma Warnings (Off, Directory_Separator); -- condition is always False
Path_Separator : constant Character := ':'; -- ???
private
type File_Descriptor is new System.Native_IO.Handle_Type; -- int or HANDLE
Standin : constant File_Descriptor :=
File_Descriptor (System.Native_IO.Standard_Input);
Standout : constant File_Descriptor :=
File_Descriptor (System.Native_IO.Standard_Output);
Standerr : constant File_Descriptor :=
File_Descriptor (System.Native_IO.Standard_Error);
Invalid_FD : constant File_Descriptor :=
File_Descriptor (System.Native_IO.Invalid_Handle);
end GNAT.OS_Lib;
|
with Render;
with Game_Assets;
with Game_Assets.Tileset;
with Game_Assets.Tileset_Collisions;
with Game_Assets.outside;
with Game_Assets.inside;
with Game_Assets.cave;
with GESTE; use GESTE;
with GESTE.Tile_Bank;
with GESTE.Grid;
with GESTE.Text;
with Player;
package body Levels is
Debug_Collisions : constant Boolean := False;
Tile_Bank : aliased GESTE.Tile_Bank.Instance
(Game_Assets.Tileset.Tiles'Access,
Game_Assets.Tileset_Collisions.Tiles'Access,
Game_Assets.Palette'Access);
Outside_Front : aliased GESTE.Grid.Instance
(Game_Assets.outside.over2.Data'Access,
Tile_Bank'Access);
Outside_Mid : aliased GESTE.Grid.Instance
(Game_Assets.outside.over.Data'Access,
Tile_Bank'Access);
Outside_Back : aliased GESTE.Grid.Instance
(Game_Assets.outside.ground.Data'Access,
Tile_Bank'Access);
Outside_Collisions : aliased GESTE.Grid.Instance
(Game_Assets.outside.collisions.Data'Access,
Tile_Bank'Access);
Inside_Objects2 : aliased GESTE.Grid.Instance
(Game_Assets.inside.objects2.Data'Access,
Tile_Bank'Access);
Inside_Objects : aliased GESTE.Grid.Instance
(Game_Assets.inside.objects.Data'Access,
Tile_Bank'Access);
Inside_Walls : aliased GESTE.Grid.Instance
(Game_Assets.inside.walls.Data'Access,
Tile_Bank'Access);
Inside_Ground : aliased GESTE.Grid.Instance
(Game_Assets.inside.ground.Data'Access,
Tile_Bank'Access);
Inside_Collisions : aliased GESTE.Grid.Instance
(Game_Assets.inside.collisions.Data'Access,
Tile_Bank'Access);
Cave_Mid : aliased GESTE.Grid.Instance
(Game_Assets.cave.Over.Data'Access,
Tile_Bank'Access);
Cave_Back : aliased GESTE.Grid.Instance
(Game_Assets.cave.Ground.Data'Access,
Tile_Bank'Access);
Cave_Collisions : aliased GESTE.Grid.Instance
(Game_Assets.cave.collisions.Data'Access,
Tile_Bank'Access);
Lvl : Levels.Level_Id := Levels.Inside;
Screen_Pos : GESTE.Pix_Point := (0, 0);
procedure Move_To (Obj : Game_Assets.Object);
-------------
-- Move_To --
-------------
procedure Move_To (Obj : Game_Assets.Object) is
begin
Player.Move ((Integer (Obj.X), Integer (Obj.Y)));
end Move_To;
------------
-- Update --
------------
procedure Update is
Pos : constant GESTE.Pix_Point := Player.Position;
function Is_In (Obj : Game_Assets.Object) return Boolean;
-----------
-- Is_In --
-----------
function Is_In (Obj : Game_Assets.Object) return Boolean is
begin
return Pos.X in
Integer (Obj.X) .. Integer (Obj.X) + Integer (Obj.Width) - 1
and then
Pos.Y in
Integer (Obj.Y) .. Integer (Obj.Y) + Integer (Obj.Height) - 1;
end Is_In;
begin
case Lvl is
when Outside =>
for Obj of Game_Assets.outside.screen_border.Objects loop
if Is_In (Obj) then
if Screen_Pos /= (Integer (Obj.X), Integer (Obj.Y)) then
Screen_Pos := (Integer (Obj.X), Integer (Obj.Y));
Render.Set_Screen_Offset (Screen_Pos);
Leave (Outside);
Enter (Outside);
end if;
end if;
end loop;
if Is_In (Game_Assets.outside.gates.To_House) then
Move_To (Game_Assets.inside.gates.From_Outside);
Leave (Outside);
Enter (Inside);
end if;
when Inside =>
if Is_In (Game_Assets.inside.gates.To_Outside) then
Move_To (Game_Assets.outside.gates.From_House);
Leave (Inside);
Enter (Outside);
end if;
if Is_In (Game_Assets.inside.gates.To_Cave) then
Move_To (Game_Assets.cave.gates.From_House);
Leave (Inside);
Enter (Cave);
end if;
when Cave =>
if Is_In (Game_Assets.cave.gates.To_House) then
Move_To (Game_Assets.inside.gates.From_Cave);
Leave (Cave);
Enter (Inside);
end if;
end case;
end Update;
-----------
-- Enter --
-----------
procedure Enter (Id : Level_Id) is
begin
case Id is
when Outside =>
Outside_Collisions.Move ((0, 0));
Outside_Collisions.Enable_Collisions;
GESTE.Add (Outside_Collisions'Access,
(if Debug_Collisions then 6 else 0));
Outside_Back.Move ((0, 0));
GESTE.Add (Outside_Back'Access, 1);
Outside_Mid.Enable_Collisions;
Outside_Mid.Move ((0, 0));
GESTE.Add (Outside_Mid'Access, 2);
Outside_Front.Move ((0, 0));
GESTE.Add (Outside_Front'Access, 5);
when Inside =>
Inside_Collisions.Move ((0, 0));
Inside_Collisions.Enable_Collisions;
GESTE.Add (Inside_Collisions'Access,
(if Debug_Collisions then 6 else 0));
Inside_Ground.Move ((0, 0));
GESTE.Add (Inside_Ground'Access, 1);
Inside_Walls.Move ((0, 0));
GESTE.Add (Inside_Walls'Access, 2);
Inside_Objects.Move ((0, 0));
GESTE.Add (Inside_Objects'Access, 3);
Inside_Objects2.Move ((0, 0));
GESTE.Add (Inside_Objects2'Access, 5);
when Cave =>
Cave_Collisions.Move ((0, 0));
Cave_Collisions.Enable_Collisions;
GESTE.Add (Cave_Collisions'Access,
(if Debug_Collisions then 6 else 0));
Cave_Back.Move ((0, 0));
GESTE.Add (Cave_Back'Access, 1);
Cave_Mid.Move ((0, 0));
GESTE.Add (Cave_Mid'Access, 2);
end case;
Render.Render_All (0);
Lvl := Id;
end Enter;
-----------
-- Leave --
-----------
procedure Leave (Id : Level_Id) is
begin
case Id is
when Outside =>
GESTE.Remove (Outside_Collisions'Access);
GESTE.Remove (Outside_Back'Access);
GESTE.Remove (Outside_Mid'Access);
GESTE.Remove (Outside_Front'Access);
when Inside =>
GESTE.Remove (Inside_Collisions'Access);
GESTE.Remove (Inside_Ground'Access);
GESTE.Remove (Inside_Walls'Access);
GESTE.Remove (Inside_Objects'Access);
GESTE.Remove (Inside_Objects2'Access);
when Cave =>
GESTE.Remove (Cave_Collisions'Access);
GESTE.Remove (Cave_Back'Access);
GESTE.Remove (Cave_Mid'Access);
end case;
end Leave;
begin
Enter (Inside);
Move_To (Game_Assets.inside.gates.From_Outside);
end Levels;
|
with AWS.URL;
with Ada.Text_IO; use Ada.Text_IO;
procedure Encode is
Normal : constant String := "http://foo bar/";
begin
Put_Line (AWS.URL.Encode (Normal));
end Encode;
|
package body ACO.Protocols.Error_Control.Masters is
procedure Periodic_Actions
(This : in out Master;
T_Now : in Ada.Real_Time.Time)
is
begin
This.Timers.Process (T_Now);
This.Monitor.Update_Alarms (T_Now);
end Periodic_Actions;
function Create_Heartbeat
(State : ACO.States.State;
Node_Id : ACO.Messages.Node_Nr)
return ACO.Messages.Message
is
begin
return ACO.Messages.Create
(Code => EC_Id,
Node => Node_Id,
RTR => False,
Data =>
(ACO.Messages.Msg_Data'First =>
ACO.Messages.Data_Type (EC_Commands.To_EC_State (State))));
end Create_Heartbeat;
procedure Send_Heartbeat
(This : in out Master;
Node_State : in ACO.States.State)
is
begin
This.Handler.Put (Create_Heartbeat (Node_State, This.Id));
end Send_Heartbeat;
procedure Send_Bootup
(This : in out Master)
is
begin
This.EC_Log (ACO.Log.Debug, "Sending bootup for node" & This.Id'Img);
This.Send_Heartbeat (ACO.States.Initializing);
end Send_Bootup;
overriding
procedure Signal
(This : access Heartbeat_Producer_Alarm;
T_Now : in Ada.Real_Time.Time)
is
use type Ada.Real_Time.Time;
use Alarms;
Ref : access Master renames This.Ref;
Period : constant Natural := Ref.Od.Get_Heartbeat_Producer_Period;
begin
if Period > 0 then
Ref.Timers.Set
(Alarm_Access (This), T_Now + Ada.Real_Time.Milliseconds (Period));
Ref.Send_Heartbeat (Ref.Od.Get_Node_State);
end if;
end Signal;
procedure Heartbeat_Producer_Start
(This : in out Master)
is
Period : constant Natural := This.Od.Get_Heartbeat_Producer_Period;
Immediately : constant Ada.Real_Time.Time := This.Handler.Current_Time;
begin
if Period > 0 then
This.Timers.Set
(Alarm => This.Producer_Alarm'Unchecked_Access,
Signal_Time => Immediately);
end if;
end Heartbeat_Producer_Start;
procedure Heartbeat_Producer_Stop
(This : in out Master)
is
begin
This.Timers.Cancel (This.Producer_Alarm'Unchecked_Access);
end Heartbeat_Producer_Stop;
overriding
procedure On_Event
(This : in out Node_State_Change_Subscriber;
Data : in ACO.Events.Event_Data)
is
use ACO.States;
Ref : access Master renames This.Ref;
begin
case Data.State.Current is
when Initializing | Unknown_State =>
Ref.Heartbeat_Producer_Stop;
when Pre_Operational =>
if Data.State.Previous = Initializing then
Ref.Send_Bootup;
Ref.Heartbeat_Producer_Start;
end if;
when Operational | Stopped =>
null;
end case;
end On_Event;
procedure On_Heartbeat
(This : in out Master;
Id : in ACO.Messages.Node_Nr;
Hbt_State : in EC_Commands.EC_State)
is
State : constant ACO.States.State := EC_Commands.To_State (Hbt_State);
T_Now : constant Ada.Real_Time.Time := This.Handler.Current_Time;
begin
if This.Monitor.Is_Monitored (Id) then
This.Monitor.Update_State (Id, State, T_Now);
elsif EC_Commands.Is_Bootup (Hbt_State) then
This.Monitor.Start (Id, State, T_Now);
end if;
end On_Heartbeat;
overriding
procedure On_Event
(This : in out Entry_Update_Subscriber;
Data : in ACO.Events.Event_Data)
is
Ref : access Master renames This.Ref;
begin
case Data.Index.Object is
when ACO.OD.Heartbeat_Consumer_Index =>
Ref.Monitor.Restart (Ref.Handler.Current_Time);
when ACO.OD.Heartbeat_Producer_Index =>
if Ref.Timers.Is_Pending (Ref.Producer_Alarm'Unchecked_Access) then
Ref.Heartbeat_Producer_Stop;
Ref.Heartbeat_Producer_Start;
end if;
when others => null;
end case;
end On_Event;
overriding
procedure Initialize
(This : in out Master)
is
begin
EC (This).Initialize;
This.Od.Events.Node_Events.Attach
(This.Entry_Update'Unchecked_Access);
This.Od.Events.Node_Events.Attach
(This.State_Change'Unchecked_Access);
end Initialize;
overriding
procedure Finalize
(This : in out Master)
is
begin
EC (This).Finalize;
This.Od.Events.Node_Events.Detach
(This.Entry_Update'Unchecked_Access);
This.Od.Events.Node_Events.Detach
(This.State_Change'Unchecked_Access);
end Finalize;
end ACO.Protocols.Error_Control.Masters;
|
-- Copyright (c) 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.
-- ****h* Image/Bitmap
-- FUNCTION
-- Provide bindings for manipulate Tk images type bitmap
-- SOURCE
package Tk.Image.Bitmap is
-- ****
--## rule off REDUCEABLE_SCOPE
-- ****s* Bitmap/Bitmap.Bitmap_Options
-- FUNCTION
-- Data structure for all available options for image photo
-- OPTIONS
-- Data - The content of the image as a string. The format of the string
-- must be one of those for which there is an image file format
-- handler that will accept string data. If both the Data and
-- File options are specified, the File option takes precedence.
-- File - The name of the file which will be loaded as an image.
-- Background - The color used for the background of the image. If set as
-- empty string, the background will be transparent
-- Foreground - The foreground color of the image
-- Mask_Data - The bitmap data used as mask for the image. If both Mask_Data
-- and Mask_File are set, then Mask_Data option takes precedence.
-- Mask_File - The file which content will be used as mask for the image
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
type Bitmap_Options is new Image_Options with record
Background: Tcl_String := Null_Tcl_String;
Foreground: Tcl_String := Null_Tcl_String;
Mask_Data: Tcl_String := Null_Tcl_String;
Mask_File: Tcl_String := Null_Tcl_String;
end record;
-- ****
-- ****f* Bitmap/Bitmap.Options_To_String
-- FUNCTION
-- Convert Ada structure to Tcl command
-- PARAMETERS
-- Options - Ada Button_Options to convert
-- RESULT
-- String with Tcl command options
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
function Options_To_String(Options: Bitmap_Options) return String;
-- ****
-- ****f* Bitmap/Bitmap.Create_(procedure)
-- FUNCTION
-- Create a new Tk image of bitmap type with the selected name and options
-- PARAMETERS
-- Name - Tk name for the newly created image
-- Options - Options for the newly created image
-- Interpreter - Tcl interpreter on which the image will be created. Can
-- be empty. Default value is the default Tcl interpreter
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Create the image with name .mybitmap from file mybitmap.bm
-- Create(".mybitmap", Bitmap_Options'(File => "mybitmap.bm", others => <>));
-- SEE ALSO
-- Bitmap.Create_(function)
-- COMMANDS
-- image create bitmap Name Options
-- SOURCE
procedure Create
(Bitmap_Image: Tk_Image; Options: Bitmap_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) with
Pre'Class =>
(Bitmap_Image'Length > 0
and then
Bitmap_Image'Length + Options_To_String(Options => Options)'Length <=
Long_Long_Integer(Natural'Last) - 21) and
Interpreter /= Null_Interpreter,
Test_Case => (Name => "Tests_Create_Bitmap", Mode => Nominal);
-- ****
-- ****f* Bitmap/Bitmap.Create_(function)
-- FUNCTION
-- Create a new Tk image of bitmap type with random name and options
-- PARAMETERS
-- Options - Options for the newly created image
-- Interpreter - Tcl interpreter on which the image will be created. Can
-- be empty. Default value is the default Tcl interpreter
-- RESULT
-- The Tk_Image with the name of the newly created image
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Create the image with random name from file mybitmap.bm
-- My_Bitmap: constant Tk_Image := Create(Bitmap_Options'(File => "mybitmap.bm", others => <>));
-- SEE ALSO
-- Bitmap.Create_(procedure)
-- COMMANDS
-- image create bitmap Options
-- SOURCE
function Create
(Options: Bitmap_Options; Interpreter: Tcl_Interpreter := Get_Interpreter)
return Tk_Image with
Pre'Class => Interpreter /= Null_Interpreter,
Test_Case => (Name => "Tests_Create2_Bitmap", Mode => Nominal);
-- ****
-- ****f* Bitmap/Bitmap.Configure
-- FUNCTION
-- Set the selected options for the selected bitmap image
-- PARAMETERS
-- Bitmap_Image - The bitmap image which will options will be changed
-- Options - The record with image options to change
-- Interpreter - Tcl interpreter on which the image will be configured.
-- Can be empty. Default value is the default Tcl
-- interpreter
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Set My_Image format to GIF on default Tcl interpreter
-- Configure(My_Image, Bitmap_Options'(Format => To_Tcl_String("gif"), others => <>));
-- COMMANDS
-- Bitmap_Image configure Options
-- SOURCE
procedure Configure
(Bitmap_Image: Tk_Image; Options: Bitmap_Options;
Interpreter: Tcl_Interpreter := Get_Interpreter) with
Pre'Class => Bitmap_Image'Length > 0 and Interpreter /= Null_Interpreter,
Test_Case => (Name => "Tests_Configure_Bitmap", Mode => Nominal);
-- ****
-- ****f* Bitmap/Bitmap.Get_Option
-- FUNCTION
-- Get the value of the selected option of the selected bitmap image.
-- It is recommended to use Bitmap.Get_Options instead as it return
-- properly converted the selected option value.
-- PARAMETERS
-- Bitmap_Image - The bitmap image which option will be get
-- Name - The name of the option to get
-- Interpreter - Tcl interpreter on which the image option will be get.
-- Can be empty. Default value is the default Tcl
-- interpreter
-- RESULT
-- The Ada String with the value of the selected option for the selected
-- bitmap image
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the data of image My_Image on default Tcl interpreter
-- Data: constant String := Get_Option(My_Image, "data");
-- SEE ALSO
-- Bitmap.Get_Options
-- COMMANDS
-- Bitmap_Image cget Name
-- SOURCE
function Get_Option
(Bitmap_Image: Tk_Image; Name: String;
Interpreter: Tcl_Interpreter := Get_Interpreter) return String with
Pre => Bitmap_Image'Length > 0 and Name'Length > 0 and
Interpreter /= Null_Interpreter,
Test_Case => (Name => "Tests_Get_Option_Bitmap", Mode => Nominal);
-- ****
-- ****f* Bitmap/Bitmap.Get_Options
-- FUNCTION
-- Get all options of the selected bitmap image
-- PARAMETERS
-- Bitmap_Image - The bitmap image which options will be get
-- Interpreter - Tcl interpreter on which the image options will be get.
-- Can be empty. Default value is the default Tcl
-- interpreter
-- RESULT
-- The record Bitmap_Options with all options of the selected bitmap image
-- HISTORY
-- 8.6.0 - Added
-- EXAMPLE
-- -- Get the options of image My_Image on default Tcl interpreter
-- Options: constant Bitmap_Options := Get_Options(My_Image);
-- SEE ALSO
-- Bitmap.Get_Option
-- COMMANDS
-- Bitmap_Image configure
-- SOURCE
function Get_Options
(Bitmap_Image: Tk_Image; Interpreter: Tcl_Interpreter := Get_Interpreter)
return Bitmap_Options with
Pre'Class => Bitmap_Image'Length > 0 and Interpreter /= Null_Interpreter,
Test_Case => (Name => "Tests_Get_Options_Bitmap", Mode => Nominal);
-- ****
-- ****d* Bitmap/Bitmap.Default_Bitmap_Options
-- FUNCTION
-- Default values for the bitmap image
-- HISTORY
-- 8.6.0 - Added
-- SOURCE
Default_Bitmap_Options: constant Bitmap_Options :=
Bitmap_Options'(others => <>);
-- ****
--## rule on REDUCEABLE_SCOPE
end Tk.Image.Bitmap;
|
-- { dg-do run }
-- { dg-options "-gnatVa" }
with Constant2_Pkg1; use Constant2_Pkg1;
procedure Constant2 is
begin
if Val then
raise Program_Error;
end if;
end;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Formal_Type_Definitions;
with Program.Lexical_Elements;
package Program.Elements.Formal_Signed_Integer_Type_Definitions is
pragma Pure (Program.Elements.Formal_Signed_Integer_Type_Definitions);
type Formal_Signed_Integer_Type_Definition is
limited interface
and Program.Elements.Formal_Type_Definitions.Formal_Type_Definition;
type Formal_Signed_Integer_Type_Definition_Access is
access all Formal_Signed_Integer_Type_Definition'Class
with Storage_Size => 0;
type Formal_Signed_Integer_Type_Definition_Text is limited interface;
type Formal_Signed_Integer_Type_Definition_Text_Access is
access all Formal_Signed_Integer_Type_Definition_Text'Class
with Storage_Size => 0;
not overriding function To_Formal_Signed_Integer_Type_Definition_Text
(Self : aliased in out Formal_Signed_Integer_Type_Definition)
return Formal_Signed_Integer_Type_Definition_Text_Access is abstract;
not overriding function Range_Token
(Self : Formal_Signed_Integer_Type_Definition_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Box_Token
(Self : Formal_Signed_Integer_Type_Definition_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Formal_Signed_Integer_Type_Definitions;
|
-- Copyright ©2022 Steve Merrony
-- This file is a part of DasherA.
-- 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.Directories;
with Logging; use Logging;
with Redirector; use Redirector;
package body Xmodem is
function CRC_16 (Data : in Vector) return Unsigned_16 is
CRC : Unsigned_16 := 0;
Part : Unsigned_16;
begin
for C of Data loop
Part := Unsigned_16(Char_To_U8(C));
CRC := CRC xor Shift_Left (Part, 8);
for I in 0 .. 7 loop
if (CRC and 16#8000#) > 0 then
CRC := Shift_Left(CRC, 1) xor 16#1021#;
else
CRC := Shift_Left(CRC, 1);
end if;
end loop;
end loop;
return CRC;
end CRC_16;
function CRC_16_Fixed_Len (Data : in Vector; FL : in Positive) return Unsigned_16 is
CRC : Unsigned_16 := 0;
begin
-- the data part...
CRC := CRC_16 (Data);
-- the padding to the fixed length...
for C in 0 .. (FL - Positive(Data.Length) - 1) loop
CRC := CRC xor 16#0400#;
for I in 0 .. 7 loop
if (CRC and 16#8000#) > 0 then
CRC := Shift_Left(CRC, 1) xor 16#1021#;
else
CRC := Shift_Left(CRC, 1);
end if;
end loop;
end loop;
return CRC;
end CRC_16_Fixed_Len;
procedure Send_Block (Data : in out Vector; Block_Num : in Natural; Block_Size : in Packet_Size) is
Start_Bytes : string (1..3);
Block_Pos : constant Unsigned_8 := Unsigned_8(Block_Num mod 256);
Block_Inv : constant Unsigned_8 := not Block_Pos;
CRC : Unsigned_16;
CRC_Str : String (1..2);
Padding_String : string (1..1);
begin
if Block_Size = Short then
Start_Bytes(1) := Ascii.SOH;
else
Start_Bytes(1) := Ascii.STX;
end if;
Start_Bytes(2) := Character'Val(Block_Pos);
Start_Bytes(3) := Character'Val(Block_Inv);
if Tracing then
Log (DEBUG, "X-Modem sending start byte and block number: " & Block_Pos'Image);
Log (DEBUG, "X-Modem ... Actual data length: " & Data.Length'Image);
end if;
Router.Send_Data (Start_Bytes);
-- Send the actual data
for C of Data loop
Router.Send_Data ("" & C);
end loop;
-- Pad out block
if Data.Length < Block_Size'Enum_Rep then
if Tracing then
Log (DEBUG, "X-Modem ... Padding packet to full size");
end if;
Padding_String(1) := Ascii.EOT;
for Ix in Data.Length + 1 .. Block_Size'Enum_Rep loop
Router.Send_Data (Padding_String);
Data.Append (Ascii.EOT);
end loop;
if Tracing then
Log (DEBUG, "X-Modem ... Packet size now: " & Data.Length'Image);
end if;
end if;
CRC := CRC_16 (Data);
CRC_Str(1) := Byte_To_Char (Unsigned_8(Shift_Right (CRC and 16#ff00#, 8)));
CRC_Str(2) := Byte_To_Char (Unsigned_8(CRC and 16#00ff#));
if Tracing then
Log (DEBUG, "X-Modem checksum: " & CRC'Image & ", sending: " & CRC_Str);
end if;
Router.Send_Data (CRC_Str);
end Send_Block;
procedure Receive (Filename : in String; Trace_Flag : in Boolean) is
RX_File : File_Type;
RX_Stream : Stream_Access;
begin
Tracing := Trace_Flag;
if Ada.Directories.Exists (Filename) then
raise Already_Exists;
return;
end if;
Create (RX_File, Name => Filename);
RX_Stream := Stream (RX_File);
Log (INFO, "Xmodem Created file: " & Filename);
Router.Set_Handler (Handlr => Xmodem_Rx);
Receiver_Task := new Receiver;
Receiver_Task.Start (RX_Stream);
loop
select
Receiver_Task.Done;
Log (INFO, "Xmodem Receive is complete");
Close (RX_File);
Router.Set_Handler (Handlr => Visual);
exit;
or
delay 1.0;
if Tracing then
Log (DEBUG, "Xmodem waiting for Receive to complete");
end if;
end select;
end loop;
end Receive;
task body Receiver is
Finished : Boolean;
Packet_Size : Natural;
Packet_Count, Inverse_Packet_Count : Unsigned_8;
Rxd_CRC, Calcd_CRC : Unsigned_16;
Write_Stream : Stream_Access;
File_Blob, Packet : Vector;
Pkt_Hdr : Character;
Purged : Boolean;
begin
accept Start (RX_Stream : Stream_Access) do
Write_Stream := RX_Stream;
Finished := False;
File_Blob.Clear;
Packet.Clear;
end Start;
if Tracing then
Log (DEBUG, "Xmodem Sending POLL");
end if;
Router.Send_Data ("" & 'C'); -- POLL
while not Finished loop -- per packet
Packet.Clear;
if Tracing then
Log (DEBUG, "Xmodem Ready for Packet Header");
end if;
accept Accept_Data (Char : in Character) do
Pkt_Hdr := Char;
end Accept_Data;
case Pkt_Hdr is
when Ascii.EOT | Ascii.SUB =>
if Tracing then
Log (DEBUG, "Xmodem Got EOT (End of Transmission)");
end if;
Router.Send_Data ("" & Ascii.ACK);
if Tracing then
Log (DEBUG, "Xmodem Sent final ACK");
end if;
Finished := True;
when Ascii.SOH =>
if Tracing then
Log (DEBUG, "Xmodem Got SOH (Short packets indicator)");
end if;
Packet_Size := 128; -- short packets
when Ascii.STX =>
if Tracing then
Log (DEBUG, "Xmodem Got STX (Long packets indicator)");
end if;
Packet_Size := 1024; -- long packets
when Ascii.CAN =>
raise Sender_Cancelled;
when others =>
raise Protocol_Error;
end case;
if Finished then
Router.Set_Handler (Handlr => Visual);
-- final packet may have trailing EOFs
while File_Blob(File_Blob.Last_Index) = Ascii.SUB loop
File_Blob.Delete (File_Blob.Last_Index);
end loop;
for C of File_Blob loop
Character'Write (Write_Stream, C);
end loop;
accept Done;
else
accept Accept_Data (Char : in Character) do
Packet_Count := Char_To_U8 (Char);
end Accept_Data;
if Tracing then
Log (DEBUG, "Xmodem Got Packet Count " & Packet_Count'Image);
end if;
accept Accept_Data (Char : in Character) do
Inverse_Packet_Count := Char_To_U8 (Char);
end Accept_Data;
if Tracing then
Log (DEBUG, "Xmodem Got Inverse Packet Count " & Inverse_Packet_Count'Image);
end if;
if (not Packet_Count) /= Inverse_Packet_Count then
if Tracing then
Log (DEBUG, "Xmodem Packet counts not right - sending NAK");
end if;
Purged := False;
while not Purged loop
select
accept Accept_Data (Char : in Character) do
pragma Unreferenced (Char);
end Accept_Data;
or
delay 1.0;
Purged := True;
end select;
end loop;
Router.Send_Data ("" & Ascii.NAK);
goto Next_Packet;
end if;
for B in 1 .. Packet_Size loop
accept Accept_Data (Char : in Character) do
Packet.Append (Char);
end Accept_Data;
end loop;
if Tracing then
Log (DEBUG, "Xmodem - Packet received");
end if;
accept Accept_Data (Char : in Character) do
Rxd_CRC := Unsigned_16(Char_To_U8 (Char));
end Accept_Data;
Rxd_CRC := Shift_Left (Rxd_CRC, 8);
accept Accept_Data (Char : in Character) do
Rxd_CRC := Rxd_CRC + Unsigned_16(Char_To_U8 (Char));
end Accept_Data;
if Tracing then
Log (DEBUG, "Xmodem Received CRC is " & Rxd_CRC'Image);
end if;
Calcd_CRC := CRC_16 (Packet);
if Tracing then
Log (DEBUG, "Xmodem Calculated CRC is " & Calcd_CRC'Image);
end if;
if Rxd_CRC = Calcd_CRC then
if Tracing then
Log (DEBUG, "Xmodem CRCs OK - sending ACK");
end if;
Router.Send_Data ("" & Ascii.ACK);
for C of Packet loop
File_Blob.Append (C);
end loop;
else
Log (WARNING, "Xmodem sending NAK due to CRC error");
Purged := False;
while not Purged loop
select
accept Accept_Data (Char : in Character) do
pragma Unreferenced (Char);
end Accept_Data;
or
delay 1.0;
Purged := True;
end select;
end loop;
Router.Send_Data ("" & Ascii.NAK);
end if;
end if;
<<Next_Packet>>
end loop;
end Receiver;
task body Sender is
Packet_Sz : Packet_Size;
Packet_Length : Positive;
Read_Stream : Stream_Access;
This_Block_No : Natural;
Retries : Natural;
Block : Vector;
Ix : Natural;
Sent_OK : Boolean;
Finished : Boolean;
begin
accept Start (TX_Stream : in Stream_Access; Pkt_Len : in Packet_Size) do
Read_Stream := TX_Stream;
Packet_Sz := Pkt_Len;
Packet_Length := Pkt_Len'Enum_Rep;
Finished := False;
Retries := 1;
end Start;
if Tracing then
Log (INFO, "Xmodem Sender waiting for POLL");
end if;
select
accept Accept_Data (Char : in Character) do
if Char /= 'C' then
Retries := Retries + 1;
if Retries > 8 then
raise Protocol_Error with "Did not get POLL character";
end if;
if Tracing then
Log (INFO, "Xmodem Sender did not get POLL - retrying");
end if;
else
Retries := 0;
end if;
end Accept_Data;
while Retries /= 0 loop
accept Accept_Data (Char : in Character) do
if Char /= 'C' then
Retries := Retries + 1;
if Retries > 8 then
raise Protocol_Error with "Did not get POLL character";
end if;
if Tracing then
Log (INFO, "Xmodem Sender did not get POLL - retrying");
end if;
else
Retries := 0;
end if;
end Accept_Data;
end loop;
if Tracing then
Log (DEBUG, "Xmodem Sender got POLLed");
end if;
This_Block_No := 1; -- 1st block is #1, not 0
while not Finished loop
Block.Clear;
Ix := 0;
-- Read a packet's worth of data from the file
while Ix < Packet_Length and not Finished loop
declare
One_Char : Character;
begin
Character'Read (Read_Stream, One_Char);
Block.Append (One_Char);
Ix := Ix + 1;
exception
when End_Error =>
Finished := True;
end;
end loop;
Retries := 0;
Sent_OK := False;
-- attempt to send the packet up to 9 times
while not Sent_OK and Retries < 9 loop
Send_Block (Data => Block, Block_Num => This_Block_No, Block_Size => Packet_Sz);
select
accept Accept_Data (Char : in Character) do
case Char is
when Ascii.ACK =>
This_Block_No := This_Block_No + 1;
if Tracing then
Log (DEBUG, "Xmodem Sent block ACKed");
end if;
Sent_OK := True;
if This_Block_No = 256 then
This_Block_No := 0;
end if;
when Ascii.NAK =>
if Tracing then
Log (DEBUG, "Xmodem Sent block NAKed");
end if;
Sent_OK := False;
Retries := Retries + 1;
when others =>
raise Protocol_Error with "unexpected response to data packet";
end case;
end Accept_Data;
or
delay 5.0;
raise Timeout with "exceeded timeout waiting for ACK";
end select;
end loop; -- retries
if not Sent_OK then
raise Too_Many_Retries;
end if;
end loop;
Router.Send_Data ("" & Ascii.EOT);
accept Done;
or
delay 30.0;
raise Timeout with "exceeded timeout waiting for POLL";
end select;
end Sender;
procedure Send (Filename : in String; Pkt_Len : in Packet_Size; Trace_Flag : in Boolean) is
TX_File : File_Type;
TX_Stream : Stream_Access;
begin
Tracing := Trace_Flag;
if not Ada.Directories.Exists (Filename) then
raise File_Does_Not_Exist;
return;
end if;
Open (File => TX_File, Mode => In_File, Name => Filename);
Router.Set_Handler (Handlr => Xmodem_Tx);
Sender_Task := new Sender;
TX_Stream := Stream (TX_File);
Sender_Task.Start (TX_Stream => TX_Stream, Pkt_Len => Pkt_Len);
loop
select
Sender_Task.Done;
Log (INFO, "Xmodem Transmit is complete");
Close (TX_File);
Router.Set_Handler (Handlr => Visual);
exit;
or
delay 1.0;
if Tracing then
Log (DEBUG, "Xmodem waiting for Transmission to complete");
end if;
end select;
end loop;
exception
when others =>
raise File_Access_Error;
end Send;
end Xmodem; |
pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Val_LLD is
pragma Pure;
-- required for Fixed'Value by compiler (s-valdec.ads)
function Value_Long_Long_Decimal (Str : String; Scale : Integer)
return Long_Long_Integer;
end System.Val_LLD;
|
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with CArgv; use CArgv;
with Tcl; use Tcl;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas;
with Tcl.Tk.Ada.Widgets.Text; use Tcl.Tk.Ada.Widgets.Text;
with Tcl.Tk.Ada.Widgets.TtkEntry; use Tcl.Tk.Ada.Widgets.TtkEntry;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkPanedWindow; use Tcl.Tk.Ada.Widgets.TtkPanedWindow;
with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo;
with Config; use Config;
with CoreUI; use CoreUI;
with Dialogs; use Dialogs;
with Utils.UI; use Utils.UI;
package body Messages.UI is
-- ****if* MUI2/MUI2.ShowMessage
-- FUNCTION
-- Show the selected message to a player
-- PARAMETERS
-- Message - The message to show
-- MessagesView - The treeview in which the message will be shown
-- MessagesType - The selected type of messages to show
-- SOURCE
procedure ShowMessage
(Message: Message_Data; MessagesView: Tk_Text;
MessagesType: Message_Type) is
-- ****
MessageTag: constant String :=
(if Message.Color /= WHITE then
" [list " & To_Lower(Message_Color'Image(Message.Color)) & "]"
else "");
begin
if Message.MType /= MessagesType and MessagesType /= Default then
return;
end if;
Insert
(MessagesView, "end",
"{" & To_String(Message.Message) & LF & "}" & MessageTag);
end ShowMessage;
-- ****o* MUI2/MUI2.Show_Last_Messages_Command
-- FUNCTION
-- Show the list of last messages to a player
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowLastMessages messagestype
-- MessagesType is the type of messages to show, default all
-- SOURCE
function Show_Last_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Last_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData);
MessagesFrame: Ttk_Frame :=
Get_Widget(Main_Paned & ".messagesframe", Interp);
MessagesCanvas: constant Tk_Canvas :=
Get_Widget(MessagesFrame & ".canvas", Interp);
MessagesType: constant Message_Type :=
(if Argc = 1 then Default
else Message_Type'Val(Natural'Value(CArgv.Arg(Argv, 1))));
MessagesView: constant Tk_Text :=
Get_Widget(MessagesCanvas & ".messages.list.view", Interp);
TypeBox: constant Ttk_ComboBox :=
Get_Widget(MessagesCanvas & ".messages.options.types", Interp);
SearchEntry: constant Ttk_Entry :=
Get_Widget(MessagesCanvas & ".messages.options.search", Interp);
begin
if Winfo_Get(MessagesCanvas, "exists") = "0" then
Tcl_EvalFile
(Get_Context,
To_String(Data_Directory) & "ui" & Dir_Separator & "messages.tcl");
Bind(MessagesFrame, "<Configure>", "{ResizeCanvas %W.canvas %w %h}");
elsif Winfo_Get(MessagesCanvas, "ismapped") = "1" and Argc = 1 then
Tcl_Eval(Interp, "InvokeButton " & Close_Button);
Tcl.Tk.Ada.Grid.Grid_Remove(Close_Button);
return TCL_OK;
end if;
if Argc = 1 then
Current(TypeBox, "0");
end if;
Delete(SearchEntry, "0", "end");
configure(MessagesView, "-state normal");
Delete(MessagesView, "1.0", "end");
if MessagesAmount(MessagesType) = 0 then
Insert(MessagesView, "end", "{There are no messages of that type.}");
else
if Game_Settings.Messages_Order = OLDER_FIRST then
Show_Older_First_Loop :
for Message of Messages_List loop
ShowMessage(Message, MessagesView, MessagesType);
end loop Show_Older_First_Loop;
else
Show_Newer_First_Loop :
for Message of reverse Messages_List loop
ShowMessage(Message, MessagesView, MessagesType);
end loop Show_Newer_First_Loop;
end if;
end if;
configure(MessagesView, "-state disabled");
Tcl.Tk.Ada.Grid.Grid(Close_Button, "-row 0 -column 1");
MessagesFrame.Name :=
New_String(Widget_Image(MessagesCanvas) & ".messages");
configure
(MessagesCanvas,
"-height [expr " & SashPos(Main_Paned, "0") & " - 20] -width " &
cget(Main_Paned, "-width"));
Tcl_Eval(Get_Context, "update");
Canvas_Create
(MessagesCanvas, "window",
"0 0 -anchor nw -window " & Widget_Image(MessagesFrame));
Tcl_Eval(Get_Context, "update");
configure
(MessagesCanvas,
"-scrollregion [list " & BBox(MessagesCanvas, "all") & "]");
Show_Screen("messagesframe");
return TCL_OK;
end Show_Last_Messages_Command;
-- ****o* MUI2/MUI2.Select_Messages_Command
-- FUNCTION
-- Show only messages of the selected type
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SelectMessages
-- SOURCE
function Select_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Select_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(Argc);
TypeBox: constant Ttk_ComboBox :=
Get_Widget
(Main_Paned & ".messagesframe.canvas.messages.options.types",
Interp);
begin
return
Show_Last_Messages_Command
(ClientData, Interp, 2, Argv & Current(TypeBox));
end Select_Messages_Command;
-- ****o* MUI2/MUI2.Delete_Messages_Command
-- FUNCTION
-- Delete all messages
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command. Unused
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- DeleteMessages
-- SOURCE
function Delete_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Delete_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc, Argv);
begin
ShowQuestion("Are you sure you want to clear all messages?", "messages");
return TCL_OK;
end Delete_Messages_Command;
-- ****o* MUI2/MUI2.Search_Messages_Command
-- FUNCTION
-- Show only this messages which contains the selected sequence
-- PARAMETERS
-- ClientData - Custom data send to the command.
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SearchMessages text
-- Text is the string to search in the messages
-- SOURCE
function Search_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Search_Messages_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
FrameName: constant String :=
Main_Paned & ".messagesframe.canvas.messages";
TypeBox: constant Ttk_ComboBox :=
Get_Widget(FrameName & ".options.types", Interp);
MessagesType: Message_Type;
MessagesView: constant Tk_Text :=
Get_Widget(FrameName & ".list.view", Interp);
SearchText: constant String := CArgv.Arg(Argv, 1);
begin
MessagesType := Message_Type'Val(Natural'Value(Current(TypeBox)));
configure(MessagesView, "-state normal");
Delete(MessagesView, "1.0", "end");
if SearchText'Length = 0 then
if Game_Settings.Messages_Order = OLDER_FIRST then
Show_Older_First_Loop :
for Message of Messages_List loop
ShowMessage(Message, MessagesView, MessagesType);
end loop Show_Older_First_Loop;
else
Show_Newer_First_Loop :
for Message of reverse Messages_List loop
ShowMessage(Message, MessagesView, MessagesType);
end loop Show_Newer_First_Loop;
end if;
Tcl_SetResult(Interp, "1");
return TCL_OK;
end if;
if Game_Settings.Messages_Order = OLDER_FIRST then
Search_Older_First_Loop :
for Message of Messages_List loop
if Index
(To_Lower(To_String(Message.Message)), To_Lower(SearchText),
1) >
0 then
ShowMessage(Message, MessagesView, MessagesType);
end if;
end loop Search_Older_First_Loop;
else
Search_Newer_First_Loop :
for Message of reverse Messages_List loop
if Index
(To_Lower(To_String(Message.Message)), To_Lower(SearchText),
1) >
0 then
ShowMessage(Message, MessagesView, MessagesType);
end if;
end loop Search_Newer_First_Loop;
end if;
configure(MessagesView, "-state disable");
Tcl_SetResult(Interp, "1");
return TCL_OK;
end Search_Messages_Command;
procedure AddCommands is
begin
Add_Command("ShowLastMessages", Show_Last_Messages_Command'Access);
Add_Command("SelectMessages", Select_Messages_Command'Access);
Add_Command("DeleteMessages", Delete_Messages_Command'Access);
Add_Command("SearchMessages", Search_Messages_Command'Access);
end AddCommands;
end Messages.UI;
|
-----------------------------------------------------------------------------
-- Legal licensing note : !!! Edit the file gate3_license.txt !!!
--
-- Copyright (c) F. J. FABIEN - 2013
-- Berry
-- FRANCE
-- Send bug reports or feedback to : francois_fabien@hotmail.com
--
-- 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.
-- NB: this is the MIT License, as found 12-Sep-2007 on the site
-- http://www.opensource.org/licenses/mit-license.php
-----------------------------------------------------------------------------
with Gtkada.Builder; use Gtkada.Builder;
package Window1_Callbacks is
function On_Window1_Delete_Event (Builder : access Gtkada_Builder_Record'Class)
return Boolean;
procedure Gtk_Main_Quit (Builder : access Gtkada_Builder_Record'Class);
procedure On_Button2_Clicked (Builder : access Gtkada_Builder_Record'Class);
end Window1_Callbacks;
|
with Ada.Containers;
with Ada.Iterator_Interfaces;
with Ada.Strings.Unbounded;
package Serialization is
pragma Preelaborate;
type Stream_Element_Kind is (
Value,
Enter_Mapping,
Leave_Mapping,
Enter_Sequence,
Leave_Sequence,
End_Of_Stream);
type Direction is (Reading, Writing);
type Serializer (Direction : Serialization.Direction) is limited private;
-- scalar
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Ada.Strings.Unbounded.Unbounded_String);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Ada.Strings.Unbounded.Unbounded_String;
Default : in Ada.Strings.Unbounded.Unbounded_String);
procedure IO (
Object : not null access Serializer;
Value : in out Ada.Strings.Unbounded.Unbounded_String);
procedure IO (
Object : not null access Serializer;
Value : in out Ada.Strings.Unbounded.Unbounded_String;
Default : in Ada.Strings.Unbounded.Unbounded_String);
generic
type Custom_Type is private;
with function Image (S : Custom_Type) return String;
with function Value (S : String) return Custom_Type;
Triming : in Boolean := False;
package IO_Custom is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Custom_Type);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Custom_Type;
Default : in Custom_Type);
end IO_Custom;
generic
type Enumeration_Type is (<>);
package IO_Enumeration is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Enumeration_Type);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Enumeration_Type;
Default : in Enumeration_Type);
private
package Enum_IO is
new IO_Custom (
Enumeration_Type,
Enumeration_Type'Image,
Enumeration_Type'Value,
Triming => True);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Enumeration_Type)
renames Enum_IO.IO;
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Enumeration_Type;
Default : in Enumeration_Type)
renames Enum_IO.IO;
end IO_Enumeration;
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Integer);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Integer;
Default : in Integer);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Boolean);
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Boolean;
Default : in Boolean);
-- mapping
procedure IO (
Object : not null access Serializer;
Name : in String;
Callback : not null access procedure);
procedure IO (
Object : not null access Serializer;
Callback : not null access procedure);
type Cursor is private;
function Has_Element (Position : Cursor) return Boolean;
package Mapping_Iterator_Interfaces is
new Ada.Iterator_Interfaces (Cursor, Has_Element);
function IO (Object : not null access Serializer; Name : String)
return Mapping_Iterator_Interfaces.Forward_Iterator'Class;
function IO (Object : not null access Serializer)
return Mapping_Iterator_Interfaces.Forward_Iterator'Class;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
Default : in Element_Type;
with procedure Iterate (
Container : in Container_Type;
Process : not null access procedure (Position : in Cursor)) is <>;
with procedure Update_Element (
Container : in out Container_Type;
Position : in Cursor;
Process : not null access procedure (
Key : in String;
Element : in out Element_Type)) is <>;
with procedure Insert (
Container : in out Container_Type;
Key : in String;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_Map_2005 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Name : in String;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Name : in String;
Item : in out Element_Type));
end IO_Map_2005;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
type Reference_Type (
Element : not null access Element_Type) is limited private;
Default : in Element_Type;
with function Has_Element (Position : Cursor) return Boolean is <>;
with function First (Container : Container_Type) return Cursor is <>;
with function Next (Position : Cursor) return Cursor is <>;
with function Key (Position : Cursor) return String is <>;
with function Reference (
Container : aliased in out Container_Type;
Position : Cursor)
return Reference_Type is <>;
with procedure Insert (
Container : in out Container_Type;
Key : in String;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_Map_2012 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Name : in String;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Name : in String;
Item : in out Element_Type));
end IO_Map_2012;
generic package IO_Map
renames IO_Map_2012;
-- sequence
generic
type Index_Type is (<>);
type Element_Type is private;
type Array_Type is array (Index_Type range <>) of Element_Type;
type Array_Access is access Array_Type;
Default : in Element_Type;
with procedure Free (X : in out Array_Access) is <>;
package IO_Array is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Array_Access;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : in out Array_Access;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
end IO_Array;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
Default : in Element_Type;
with function Last (Container : Container_Type) return Cursor is <>;
with procedure Iterate (
Container : in Container_Type;
Process : not null access procedure (Position : in Cursor)) is <>;
with procedure Update_Element (
Container : in out Container_Type;
Position : in Cursor;
Process : not null access procedure (Element : in out Element_Type)) is <>;
with procedure Append (
Container : in out Container_Type;
New_Item : in Element_Type;
Count : in Ada.Containers.Count_Type := 1) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_List_2005 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
end IO_List_2005;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
type Reference_Type (
Element : not null access Element_Type) is limited private;
Default : in Element_Type;
with function Last (Container : Container_Type) return Cursor is <>;
with function Has_Element (Position : Cursor) return Boolean is <>;
with function First (Container : Container_Type) return Cursor is <>;
with function Next (Position : Cursor) return Cursor is <>;
with function Reference (
Container : aliased in out Container_Type;
Position : Cursor)
return Reference_Type is <>;
with procedure Append (
Container : in out Container_Type;
New_Item : in Element_Type;
Count : in Ada.Containers.Count_Type := 1) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_List_2012 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
end IO_List_2012;
generic package IO_List
renames IO_List_2012;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
Default : in Element_Type;
with procedure Iterate (
Container : in Container_Type;
Process : not null access procedure (Position : in Cursor)) is <>;
with procedure Query_Element (
Position : in Cursor;
Process : not null access procedure (Element : in Element_Type)) is <>;
with procedure Insert (
Container : in out Container_Type;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_Set_2005 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
end IO_Set_2005;
generic
type Cursor is private;
type Element_Type is private;
type Container_Type is limited private;
type Constant_Reference_Type (
Element : not null access constant Element_Type) is limited private;
Default : in Element_Type;
with function Has_Element (Position : Cursor) return Boolean is <>;
with function First (Container : Container_Type) return Cursor is <>;
with function Next (Position : Cursor) return Cursor is <>;
with function Constant_Reference (
Container : aliased Container_Type;
Position : Cursor)
return Constant_Reference_Type is <>;
with procedure Insert (
Container : in out Container_Type;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean) is <>;
with procedure Clear (Container : in out Container_Type) is <>;
package IO_Set_2012 is
procedure IO (
Object : not null access Serializer;
Name : in String;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
procedure IO (
Object : not null access Serializer;
Value : aliased in out Container_Type;
Callback : not null access procedure (
Object : not null access Serializer;
Item : in out Element_Type));
end IO_Set_2012;
generic package IO_Set
renames IO_Set_2012;
private
type State is (In_Mapping, In_Sequence);
pragma Discard_Names (State);
type Reader is abstract tagged limited null record;
function Next_Kind (Object : not null access Reader)
return Stream_Element_Kind is abstract;
function Next_Name (Object : not null access Reader)
return not null access constant String is abstract;
function Next_Value (Object : not null access Reader)
return not null access constant String is abstract;
procedure Advance (
Object : not null access Reader;
Position : in State) is abstract;
procedure Advance_Structure (
Object : not null access Reader;
Position : in State);
type Writer is abstract tagged limited null record;
procedure Put (
Object : not null access Writer;
Name : in String;
Item : in String) is abstract;
procedure Enter_Mapping (
Object : not null access Writer;
Name : in String) is abstract;
procedure Leave_Mapping (Object : not null access Writer) is abstract;
procedure Enter_Sequence (
Object : not null access Writer;
Name : in String) is abstract;
procedure Leave_Sequence (Object : not null access Writer) is abstract;
type Serializer (Direction : Serialization.Direction) is limited record
case Direction is
when Reading =>
Reader : not null access Serialization.Reader'Class;
when Writing =>
Writer : not null access Serialization.Writer'Class;
end case;
end record;
-- mapping
type Cursor is new Boolean;
type Mapping_Iterator is new Mapping_Iterator_Interfaces.Forward_Iterator
with record
Serializer : not null access Serialization.Serializer;
Entry_Presence : Boolean;
end record;
overriding function First (Object : Mapping_Iterator) return Cursor;
overriding function Next (Object : Mapping_Iterator; Position : Cursor)
return Cursor;
end Serialization;
|
with Gtkada.Builder;
with Gtk.List_Store;
with Gtk.Status_Bar;
with Gtk.Text_Buffer;
with Gtk.Widget;
package gui is
builder : Gtkada.Builder.Gtkada_Builder;
topLevelWindow : Gtk.Widget.Gtk_Widget;
textbuf : Gtk.Text_Buffer.Gtk_Text_Buffer;
statusBar : Gtk.Status_Bar.Gtk_Status_Bar;
--statusBarContext : Gtk.Status_Bar.Context_Id;
machinecodeList : Gtk.List_Store.Gtk_List_Store;
memoryList : Gtk.List_Store.Gtk_List_Store;
registerList : Gtk.List_Store.Gtk_List_Store;
procedure load;
procedure setTitle(newTitle : String);
procedure updateGUI_VM;
end gui;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
with Ada.Command_Line;
procedure Main is
generator: Natural;
prime : Natural;
alicePrivateKey : Natural;
bobPrivateKey : Natural;
---------------------
-- DecimalToBinary --
---------------------
function DecimalToBinary (N : Natural) return String
is
ret : Ada.Strings.Unbounded.Unbounded_String;
begin
if N < 2 then
return "1";
else
Ada.Strings.Unbounded.Append(ret, Ada.Strings.Unbounded.To_Unbounded_String(decimalToBinary (N / 2)));
Ada.Strings.Unbounded.Append(ret, Ada.Strings.Fixed.Trim(Integer'Image(N mod 2), Ada.Strings.Left));
end if;
return Ada.Strings.Unbounded.To_String(ret);
end decimalToBinary;
-------------------------------
-- FastModularExponentiation --
-------------------------------
function FastModularExponentiation (b, exp, m : Natural) return Integer
is
x : Integer := 1;
power : Integer;
str : String := DecimalToBinary (exp);
begin
power := b mod m;
for i in 0 .. (str'Length - 1) loop
if str(str'Last - i) = '1' then
x := (x * power) mod m;
end if;
power := (power*power) mod m;
end loop;
return x;
end FastModularExponentiation;
-----------
-- Power --
-----------
function Power (privateKey, g, n : Integer) return Integer
is
begin
if privateKey = 1 then
return 1;
end if;
return FastModularExponentiation (g, privateKey, n);
end Power;
-------------------
-- IsPrimeNumber --
-------------------
function IsPrimeNumber (N : Natural) return Boolean
is
isPrime : Boolean := true;
begin
if N = 0 or N = 1 then
return false;
end if;
for i in 1 .. N / 2 loop
if (N mod (i + 1)) = 0 then
isPrime := false;
exit;
end if;
end loop;
return isPrime;
end IsPrimeNumber;
begin
Ada.Integer_Text_IO.Default_Width := 0;
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line("You forgot to pass in all the arguments! Try --help.");
return;
end if;
if Ada.Command_Line.Argument(1) = "--help" then
Ada.Text_IO.Put_Line("Argument order: Alice, Bob, Generator, Prime");
return;
end if;
if Ada.Command_Line.Argument_Count < 4 then
Ada.Text_IO.Put_Line("You forgot to pass in all the arguments! Try --help.");
return;
end if;
alicePrivateKey := Integer'Value(Ada.Command_Line.Argument(1));
bobPrivateKey := Integer'Value(Ada.Command_Line.Argument(2));
generator := Integer'Value(Ada.Command_Line.Argument(3));
prime := Integer'Value(Ada.Command_Line.Argument(4));
if not IsPrimeNumber (prime) then
Ada.Integer_Text_IO.Put (prime);
Ada.Text_IO.Put_Line(" is not a prime number.");
return;
end if;
Ada.Text_IO.Put ("Generator: ");
Ada.Integer_Text_IO.Put (generator);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("Prime Number: ");
Ada.Integer_Text_IO.Put (prime);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("Alice's Private Key: ");
Ada.Integer_Text_IO.Put (alicePrivateKey);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("Bob's Private Key: ");
Ada.Integer_Text_IO.Put (bobPrivateKey);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("Alice sends the message ");
Ada.Integer_Text_IO.Put (Power(alicePrivateKey, generator, prime));
Ada.Text_IO.Put_Line (" to Bob.");
Ada.Text_IO.Put ("Bob sends the message ");
Ada.Integer_Text_IO.Put (Power(bobPrivateKey, generator, prime));
Ada.Text_IO.Put_Line (" to Alice.");
Ada.Text_IO.Put ("Alice gets the secret key ");
Ada.Integer_Text_IO.Put (Power(alicePrivateKey, Power(bobPrivateKey, generator, prime), prime));
Ada.Text_IO.New_Line;
Ada.Text_IO.Put ("Bob gets the secret key ");
Ada.Integer_Text_IO.Put (Power(bobPrivateKey, Power(alicePrivateKey, generator, prime), prime));
Ada.Text_IO.New_Line;
null;
end Main;
|
-----------------------------------------------------------------------
-- ado-queries-loaders -- Loader for Database Queries
-- Copyright (C) 2011, 2012, 2013, 2014, 2017, 2018, 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces;
with Ada.IO_Exceptions;
with Ada.Directories;
with Util.Files;
with Util.Log.Loggers;
with Util.Beans.Objects;
with Util.Serialize.IO.XML;
with Util.Serialize.Mappers.Record_Mapper;
with ADO.Configs;
package body ADO.Queries.Loaders is
use Util.Log;
use ADO.Connections;
use Interfaces;
use Ada.Calendar;
Log : constant Loggers.Logger := Loggers.Create ("ADO.Queries.Loaders");
Base_Time : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1970,
Month => 1,
Day => 1);
-- Check for file modification time at most every 60 seconds.
FILE_CHECK_DELTA_TIME : constant Unsigned_32 := 60;
-- The list of query files defined by the application.
Query_Files : Query_File_Access := null;
Last_Query : Query_Index := 0;
Last_File : File_Index := 0;
-- Convert a Time to an Unsigned_32.
function To_Unsigned_32 (T : in Ada.Calendar.Time) return Unsigned_32;
pragma Inline_Always (To_Unsigned_32);
-- Get the modification time of the XML query file associated with the query.
function Modification_Time (File : in Query_File_Info) return Unsigned_32;
-- Initialize the query SQL pattern with the value
procedure Set_Query_Pattern (Into : in out Query_Pattern;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Register the query definition in the query file. Registration is done
-- in the package elaboration phase.
-- ------------------------------
procedure Register (File : in Query_File_Access;
Query : in Query_Definition_Access) is
begin
Last_Query := Last_Query + 1;
Query.File := File;
Query.Next := File.Queries;
Query.Query := Last_Query;
File.Queries := Query;
if File.Next = null and then Query_Files /= File then
Last_File := Last_File + 1;
File.Next := Query_Files;
File.File := Last_File;
Query_Files := File;
end if;
end Register;
function Find_Driver (Name : in String) return Integer;
function Find_Driver (Name : in String) return Integer is
begin
if Name'Length = 0 then
return 0;
end if;
declare
Driver : constant Connections.Driver_Access
:= Connections.Get_Driver (Name);
begin
if Driver = null then
-- There is no problem to have an SQL query for unsupported drivers, but still
-- report some warning.
Log.Warn ("Database driver {0} not found", Name);
return -1;
end if;
return Integer (Driver.Get_Driver_Index);
end;
end Find_Driver;
-- ------------------------------
-- Convert a Time to an Unsigned_32.
-- ------------------------------
function To_Unsigned_32 (T : in Ada.Calendar.Time) return Unsigned_32 is
D : constant Duration := Duration '(T - Base_Time);
begin
return Unsigned_32 (D);
end To_Unsigned_32;
-- ------------------------------
-- Get the modification time of the XML query file associated with the query.
-- ------------------------------
function Modification_Time (File : in Query_File_Info) return Unsigned_32 is
Path : constant String := To_String (File.Path);
begin
return To_Unsigned_32 (Ada.Directories.Modification_Time (Path));
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("XML query file '{0}' does not exist", Path);
return 0;
end Modification_Time;
-- ------------------------------
-- Returns True if the XML query file must be reloaded.
-- ------------------------------
function Is_Modified (File : in out Query_File_Info) return Boolean is
Now : constant Unsigned_32 := To_Unsigned_32 (Ada.Calendar.Clock);
begin
-- Have we passed the next check time?
if File.Next_Check > Now then
return False;
end if;
-- Next check in N seconds (60 by default).
File.Next_Check := Now + FILE_CHECK_DELTA_TIME;
-- See if the file was changed.
declare
M : constant Unsigned_32 := Modification_Time (File);
begin
if File.Last_Modified = M then
return False;
end if;
File.Last_Modified := M;
return True;
end;
end Is_Modified;
-- ------------------------------
-- Initialize the query SQL pattern with the value
-- ------------------------------
procedure Set_Query_Pattern (Into : in out Query_Pattern;
Value : in Util.Beans.Objects.Object) is
begin
Into.SQL := Util.Beans.Objects.To_Unbounded_String (Value);
end Set_Query_Pattern;
procedure Read_Query (Manager : in Query_Manager;
File : in out Query_File_Info) is
type Query_Info_Fields is (FIELD_CLASS_NAME, FIELD_PROPERTY_TYPE,
FIELD_PROPERTY_NAME, FIELD_QUERY_NAME,
FIELD_SQL_DRIVER,
FIELD_SQL, FIELD_SQL_COUNT, FIELD_QUERY);
-- The Query_Loader holds context and state information for loading
-- the XML query file and initializing the Query_Definition.
type Query_Loader is record
-- File : Query_File_Access;
Hash_Value : Unbounded_String;
Query_Def : Query_Definition_Access;
Query : Query_Info_Ref.Ref;
Driver : Integer;
end record;
type Query_Loader_Access is access all Query_Loader;
procedure Set_Member (Into : in out Query_Loader;
Field : in Query_Info_Fields;
Value : in Util.Beans.Objects.Object);
-- ------------------------------
-- Called by the de-serialization when a given field is recognized.
-- ------------------------------
procedure Set_Member (Into : in out Query_Loader;
Field : in Query_Info_Fields;
Value : in Util.Beans.Objects.Object) is
begin
case Field is
when FIELD_CLASS_NAME =>
Append (Into.Hash_Value, " class=");
Append (Into.Hash_Value, Util.Beans.Objects.To_Unbounded_String (Value));
when FIELD_PROPERTY_TYPE =>
Append (Into.Hash_Value, " type=");
Append (Into.Hash_Value, Util.Beans.Objects.To_Unbounded_String (Value));
when FIELD_PROPERTY_NAME =>
Append (Into.Hash_Value, " name=");
Append (Into.Hash_Value, Util.Beans.Objects.To_Unbounded_String (Value));
when FIELD_QUERY_NAME =>
Into.Query_Def := Find_Query (File, Util.Beans.Objects.To_String (Value));
Into.Driver := 0;
if Into.Query_Def /= null then
Into.Query := Query_Info_Ref.Create;
end if;
when FIELD_SQL_DRIVER =>
Into.Driver := Find_Driver (Util.Beans.Objects.To_String (Value));
when FIELD_SQL =>
if not Into.Query.Is_Null and Into.Driver >= 0 and Into.Query_Def /= null then
Set_Query_Pattern (Into.Query.Value.Main_Query (Driver_Index (Into.Driver)),
Value);
end if;
Into.Driver := 0;
when FIELD_SQL_COUNT =>
if not Into.Query.Is_Null and Into.Driver >= 0 and Into.Query_Def /= null then
Set_Query_Pattern (Into.Query.Value.Count_Query (Driver_Index (Into.Driver)),
Value);
end if;
Into.Driver := 0;
when FIELD_QUERY =>
if Into.Query_Def /= null then
-- Now we can safely setup the query info associated with the query definition.
Manager.Queries (Into.Query_Def.Query) := Into.Query;
end if;
Into.Query_Def := null;
end case;
end Set_Member;
package Query_Mapper is
new Util.Serialize.Mappers.Record_Mapper (Element_Type => Query_Loader,
Element_Type_Access => Query_Loader_Access,
Fields => Query_Info_Fields,
Set_Member => Set_Member);
Loader : aliased Query_Loader;
Sql_Mapper : aliased Query_Mapper.Mapper;
Reader : Util.Serialize.IO.XML.Parser;
Mapper : Util.Serialize.Mappers.Processing;
Path : constant String := To_String (File.Path);
begin
Log.Info ("Reading XML query {0}", Path);
-- Loader.File := Into;
Loader.Driver := 0;
-- Create the mapping to load the XML query file.
Sql_Mapper.Add_Mapping ("class/@name", FIELD_CLASS_NAME);
Sql_Mapper.Add_Mapping ("class/property/@type", FIELD_PROPERTY_TYPE);
Sql_Mapper.Add_Mapping ("class/property/@name", FIELD_PROPERTY_NAME);
Sql_Mapper.Add_Mapping ("query/@name", FIELD_QUERY_NAME);
Sql_Mapper.Add_Mapping ("query/sql", FIELD_SQL);
Sql_Mapper.Add_Mapping ("query/sql/@driver", FIELD_SQL_DRIVER);
Sql_Mapper.Add_Mapping ("query/sql-count", FIELD_SQL_COUNT);
Sql_Mapper.Add_Mapping ("query/sql-count/@driver", FIELD_SQL_DRIVER);
Sql_Mapper.Add_Mapping ("query", FIELD_QUERY);
Mapper.Add_Mapping ("query-mapping", Sql_Mapper'Unchecked_Access);
-- Set the context for Set_Member.
Query_Mapper.Set_Context (Mapper, Loader'Access);
-- Read the XML query file.
Reader.Parse (Path, Mapper);
File.Next_Check := To_Unsigned_32 (Ada.Calendar.Clock) + FILE_CHECK_DELTA_TIME;
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("XML query file '{0}' does not exist", Path);
end Read_Query;
-- ------------------------------
-- Read the query definition.
-- ------------------------------
procedure Read_Query (Manager : in Query_Manager;
Into : in Query_Definition_Access) is
begin
if Manager.Queries (Into.Query).Is_Null
or else Is_Modified (Manager.Files (Into.File.File))
then
Read_Query (Manager, Manager.Files (Into.File.File));
end if;
end Read_Query;
-- ------------------------------
-- Initialize the queries to look in the list of directories specified by <b>Paths</b>.
-- Each search directory is separated by ';' (yes, even on Unix).
-- When <b>Load</b> is true, read the XML query file and initialize the query
-- definitions from that file.
-- ------------------------------
procedure Initialize (Manager : in out Query_Manager;
Config : in ADO.Connections.Configuration'Class) is
function Get_Config (Name : in String) return String;
function Get_Config (Name : in String) return String is
Value : constant String := Config.Get_Property (Name);
begin
if Value'Length > 0 then
return Value;
else
return ADO.Configs.Get_Config (Name);
end if;
end Get_Config;
Paths : constant String := Get_Config (Configs.QUERY_PATHS_CONFIG);
Load : constant Boolean := Get_Config (Configs.QUERY_LOAD_CONFIG) = "true";
File : Query_File_Access := Query_Files;
begin
Log.Info ("Initializing query search paths to {0}", Paths);
if Manager.Queries = null then
Manager.Queries := new Query_Table (1 .. Last_Query);
end if;
if Manager.Files = null then
Manager.Files := new File_Table (1 .. Last_File);
end if;
Manager.Driver := Config.Get_Driver;
while File /= null loop
declare
Path : constant String := Util.Files.Find_File_Path (Name => File.Name.all,
Paths => Paths);
begin
Manager.Files (File.File).File := File;
Manager.Files (File.File).Last_Modified := 0;
Manager.Files (File.File).Next_Check := 0;
Manager.Files (File.File).Path := To_Unbounded_String (Path);
if Load then
Read_Query (Manager, Manager.Files (File.File));
end if;
end;
File := File.Next;
end loop;
end Initialize;
-- ------------------------------
-- Find the query identified by the given name.
-- ------------------------------
function Find_Query (Name : in String) return Query_Definition_Access is
File : Query_File_Access := Query_Files;
begin
while File /= null loop
declare
Query : Query_Definition_Access := File.Queries;
begin
while Query /= null loop
if Query.Name.all = Name then
return Query;
end if;
Query := Query.Next;
end loop;
end;
File := File.Next;
end loop;
Log.Warn ("Query {0} not found", Name);
return null;
end Find_Query;
package body File is
begin
File.Name := Name'Access;
File.Sha1_Map := Hash'Access;
end File;
package body Query is
begin
Query.Name := Query_Name'Access;
Query.File := File;
Register (File => File, Query => Query'Access);
end Query;
end ADO.Queries.Loaders;
|
-- A lexical scanner generated by aflex
with text_io; use text_io;
with ascan_dfa; use ascan_dfa;
with ascan_io; use ascan_io;
--# line 1 "ascan.l"
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- This software was developed by John Self of the Arcadia project
-- at the University of California, Irvine.
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- TITLE scanner specification file
-- AUTHOR: John Self (UCI)
-- DESCRIPTION regular expressions and actions matching tokens
-- that aflex expects to find in its input.
-- NOTES input to aflex (NOT alex.) It uses exclusive start conditions
-- and case insensitive scanner generation available only in aflex
-- (or flex if you use C.)
-- generate scanner using the command 'aflex -is ascan.l'
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/ascan.l,v 1.18 90/01/12 15:20:53 self Exp Locker: self $
--
-- Modified 3.9.92 by Simon Wright (sjwright@cix.compulink.co.uk), for VAX/VMS
-- in which you _must_ use Text_Io.New_Line() to end a line, rather than just
-- expecting the runtime to translate '\n' (Ascii.Lf) automatically.
--# line 48 "ascan.l"
with misc_defs, misc, sym, parse_tokens, int_io;
with tstring, ascan_dfa, ascan_io, external_file_manager;
use misc_defs, parse_tokens, tstring;
use ascan_dfa, ascan_io, external_file_manager;
package scanner is
call_yylex : boolean := false;
function get_token return Token;
end scanner;
package body scanner is
beglin : boolean := false;
i, bracelevel: integer;
function get_token return Token is
toktype : Token;
didadef, indented_code : boolean;
cclval : integer;
nmdefptr : vstring;
nmdef, tmpbuf : vstring;
procedure ACTION_ECHO is
begin
for i in 1 .. yylength loop
if yytext (i) /= ascii.lf then
text_io.put (temp_action_file, yytext (i));
else
text_io.new_line (temp_action_file);
end if;
end loop;
end ACTION_ECHO;
procedure MARK_END_OF_PROLOG is
begin
text_io.put( temp_action_file, "%%%% end of prolog" );
text_io.new_line( temp_action_file );
end MARK_END_OF_PROLOG;
procedure PUT_BACK_STRING(str : vstring; start : integer) is
begin
for i in reverse start+1..tstring.len(str) loop
unput( CHAR(str,i) );
end loop;
end PUT_BACK_STRING;
function check_yylex_here return boolean is
begin
return ( (yytext'length >= 2) and then
((yytext(1) = '#') and (yytext(2) = '#')));
end check_yylex_here;
function YYLex return Token is
subtype short is integer range -32768..32767;
yy_act : integer;
yy_c : short;
-- returned upon end-of-file
YY_END_TOK : constant integer := 0;
YY_END_OF_BUFFER : constant := 82;
subtype yy_state_type is integer;
yy_current_state : yy_state_type;
INITIAL : constant := 0;
SECT2 : constant := 1;
SECT2PROLOG : constant := 2;
SECT3 : constant := 3;
PICKUPDEF : constant := 4;
SC : constant := 5;
CARETISBOL : constant := 6;
NUM : constant := 7;
QUOTE : constant := 8;
FIRSTCCL : constant := 9;
CCL : constant := 10;
ACTION : constant := 11;
RECOVER : constant := 12;
BRACEERROR : constant := 13;
ACTION_STRING : constant := 14;
yy_accept : constant array(0..205) of short :=
( 0,
0, 0, 0, 0, 0, 0, 80, 80, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
82, 13, 6, 12, 10, 1, 11, 13, 13, 13,
9, 39, 31, 32, 25, 39, 38, 23, 39, 39,
39, 31, 21, 39, 39, 24, 81, 19, 80, 80,
15, 14, 16, 45, 81, 41, 42, 44, 46, 60,
61, 58, 57, 59, 47, 49, 48, 47, 53, 52,
53, 53, 55, 55, 55, 56, 66, 71, 70, 72,
66, 72, 67, 64, 65, 81, 17, 63, 62, 73,
75, 76, 77, 6, 10, 1, 11, 0, 0, 2,
0, 7, 4, 5, 0, 9, 31, 32, 0, 28,
0, 0, 0, 78, 78, 27, 26, 27, 0, 31,
21, 0, 0, 35, 0, 0, 19, 18, 80, 80,
15, 14, 43, 44, 57, 79, 79, 50, 51, 54,
66, 0, 69, 0, 66, 67, 0, 17, 73, 74,
0, 7, 0, 0, 3, 0, 29, 0, 36, 0,
78, 27, 27, 37, 0, 0, 0, 35, 0, 30,
79, 66, 68, 0, 0, 8, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 22, 0, 22, 0,
22, 4, 0, 34, 0
) ;
yy_ec : constant array(CHARACTER'FIRST..CHARACTER'LAST) of short :=
( 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 4, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 5, 1, 6, 7, 8, 9, 1, 10, 11,
11, 11, 11, 12, 13, 11, 14, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 1, 1, 16,
1, 17, 11, 1, 23, 22, 22, 22, 24, 25,
22, 22, 22, 22, 22, 22, 22, 22, 26, 22,
22, 27, 28, 29, 22, 22, 22, 30, 22, 22,
18, 19, 20, 21, 22, 1, 23, 22, 22, 22,
24, 25, 22, 22, 22, 22, 22, 22, 22, 22,
26, 22, 22, 27, 28, 29, 22, 22, 22, 30,
22, 22, 31, 32, 33, 1, 1
) ;
yy_meta : constant array(0..33) of short :=
( 0,
1, 2, 3, 2, 2, 4, 1, 1, 1, 5,
1, 1, 6, 5, 7, 1, 1, 1, 8, 9,
1, 10, 10, 10, 10, 10, 10, 10, 10, 10,
5, 11, 12
) ;
yy_base : constant array(0..253) of short :=
( 0,
0, 29, 58, 89, 498, 305, 304, 303, 4, 8,
119, 147, 284, 283, 32, 34, 65, 67, 93, 96,
110, 113, 177, 0, 300, 299, 12, 15, 82, 121,
301, 880, 12, 880, 0, 37, 880, 297, 11, 286,
0, 880, 72, 880, 880, 76, 880, 282, 278, 281,
196, 225, 880, 286, 281, 880, 290, 0, 289, 880,
0, 78, 880, 880, 880, 880, 270, 0, 880, 880,
880, 880, 274, 880, 880, 880, 880, 273, 880, 880,
272, 273, 880, 0, 270, 880, 0, 880, 880, 109,
271, 880, 0, 880, 880, 280, 880, 880, 880, 0,
880, 880, 0, 133, 0, 148, 880, 264, 273, 880,
261, 0, 236, 880, 261, 0, 122, 880, 260, 880,
238, 133, 119, 880, 246, 0, 880, 245, 246, 277,
880, 243, 152, 0, 252, 251, 0, 880, 250, 880,
0, 158, 880, 0, 237, 880, 236, 880, 880, 880,
0, 147, 880, 0, 309, 0, 247, 880, 0, 880,
246, 0, 225, 244, 880, 243, 880, 219, 880, 197,
229, 0, 0, 880, 230, 155, 228, 0, 239, 880,
225, 0, 880, 236, 232, 880, 207, 208, 217, 212,
164, 153, 89, 94, 194, 84, 880, 40, 880, 18,
880, 880, 2, 880, 880, 342, 354, 366, 378, 390,
402, 414, 426, 438, 450, 462, 474, 486, 493, 502,
508, 520, 527, 536, 547, 559, 571, 583, 595, 607,
619, 631, 638, 648, 660, 672, 684, 695, 702, 712,
724, 736, 748, 760, 772, 784, 795, 807, 819, 831,
843, 855, 867
) ;
yy_def : constant array(0..253) of short :=
( 0,
206, 206, 207, 207, 208, 208, 209, 209, 210, 210,
211, 211, 212, 212, 213, 213, 214, 214, 215, 215,
216, 216, 205, 23, 217, 217, 212, 212, 218, 218,
205, 205, 205, 205, 219, 220, 205, 221, 222, 205,
223, 205, 224, 205, 205, 205, 205, 205, 225, 226,
227, 228, 205, 205, 205, 205, 229, 230, 231, 205,
232, 205, 205, 205, 205, 205, 205, 233, 205, 205,
205, 205, 205, 205, 205, 205, 205, 226, 205, 205,
234, 235, 205, 236, 226, 205, 237, 205, 205, 238,
237, 205, 239, 205, 205, 240, 205, 205, 205, 241,
205, 205, 242, 205, 219, 220, 205, 205, 221, 205,
205, 243, 205, 205, 244, 223, 224, 205, 245, 205,
205, 225, 225, 205, 205, 246, 205, 246, 205, 228,
205, 205, 245, 247, 248, 229, 230, 205, 231, 205,
232, 205, 205, 233, 205, 205, 205, 205, 205, 205,
237, 238, 205, 238, 205, 239, 240, 205, 241, 205,
249, 243, 205, 244, 205, 245, 205, 205, 205, 225,
205, 246, 128, 205, 205, 248, 245, 247, 248, 205,
205, 155, 205, 250, 249, 205, 205, 205, 225, 251,
252, 253, 205, 205, 225, 251, 205, 252, 205, 253,
205, 205, 205, 205, 0, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205
) ;
yy_nxt : constant array(0..913) of short :=
( 0,
205, 33, 34, 33, 33, 62, 63, 62, 62, 62,
63, 62, 62, 104, 98, 104, 104, 98, 204, 112,
201, 35, 35, 35, 35, 35, 35, 35, 35, 35,
36, 37, 36, 36, 71, 38, 71, 39, 113, 107,
114, 40, 199, 72, 99, 72, 73, 99, 73, 108,
41, 41, 41, 41, 41, 41, 41, 41, 41, 43,
44, 43, 43, 45, 74, 46, 74, 76, 47, 76,
77, 47, 77, 48, 118, 49, 50, 120, 120, 142,
120, 142, 142, 78, 101, 78, 197, 102, 51, 47,
52, 53, 52, 52, 45, 65, 46, 54, 65, 47,
103, 55, 47, 119, 48, 80, 49, 50, 80, 56,
203, 81, 65, 82, 81, 65, 82, 202, 153, 51,
47, 65, 84, 101, 118, 84, 102, 154, 85, 86,
66, 85, 86, 170, 104, 67, 104, 104, 122, 103,
68, 68, 68, 68, 68, 68, 68, 68, 68, 65,
107, 123, 169, 119, 167, 201, 153, 180, 66, 142,
108, 142, 142, 67, 177, 154, 199, 191, 68, 68,
68, 68, 68, 68, 68, 68, 68, 87, 87, 88,
87, 87, 89, 87, 87, 87, 90, 87, 87, 91,
92, 87, 87, 87, 87, 87, 87, 87, 93, 93,
93, 93, 93, 93, 93, 93, 93, 94, 87, 95,
127, 189, 123, 169, 197, 123, 169, 128, 128, 128,
128, 128, 128, 128, 128, 128, 130, 131, 130, 130,
167, 195, 194, 193, 186, 123, 169, 132, 183, 146,
192, 180, 190, 124, 188, 167, 165, 187, 186, 158,
181, 145, 140, 137, 180, 176, 133, 173, 175, 173,
171, 168, 167, 165, 163, 161, 173, 173, 173, 173,
173, 173, 173, 173, 173, 110, 115, 174, 130, 131,
130, 130, 158, 155, 125, 149, 147, 125, 145, 132,
143, 140, 137, 135, 134, 125, 123, 121, 115, 110,
205, 97, 97, 69, 69, 60, 60, 58, 133, 182,
182, 183, 182, 182, 184, 182, 182, 182, 184, 182,
182, 182, 184, 182, 182, 182, 182, 182, 182, 182,
184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
182, 184, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 42, 42, 42, 42, 42, 42,
42, 42, 42, 42, 42, 42, 57, 57, 57, 57,
57, 57, 57, 57, 57, 57, 57, 57, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 65, 65, 65, 65, 65, 65,
65, 65, 65, 65, 65, 65, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 75, 75,
75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
79, 79, 83, 83, 83, 83, 83, 83, 83, 83,
83, 83, 83, 83, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 105, 105,
58, 205, 105, 106, 106, 205, 205, 106, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
111, 111, 116, 116, 205, 205, 116, 117, 117, 205,
205, 205, 205, 205, 205, 205, 117, 122, 122, 205,
122, 122, 122, 122, 122, 205, 122, 122, 122, 124,
124, 205, 124, 124, 124, 124, 124, 124, 124, 124,
124, 126, 126, 205, 126, 126, 126, 126, 126, 126,
126, 126, 126, 129, 129, 129, 129, 129, 129, 129,
129, 129, 129, 129, 129, 136, 136, 136, 136, 136,
136, 136, 136, 136, 136, 136, 136, 138, 205, 205,
138, 138, 138, 138, 138, 138, 138, 138, 138, 139,
139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
139, 141, 141, 205, 141, 141, 141, 141, 141, 141,
141, 141, 141, 144, 144, 205, 205, 144, 146, 146,
205, 146, 146, 146, 146, 146, 146, 146, 146, 146,
148, 148, 205, 148, 148, 148, 148, 148, 148, 148,
148, 148, 150, 150, 205, 150, 150, 150, 150, 150,
205, 150, 150, 150, 151, 151, 205, 205, 205, 151,
151, 151, 151, 205, 151, 152, 152, 205, 152, 152,
152, 152, 152, 152, 152, 152, 152, 156, 156, 205,
205, 156, 157, 157, 157, 157, 157, 157, 157, 157,
157, 157, 157, 157, 159, 159, 205, 205, 159, 159,
159, 205, 159, 159, 159, 159, 160, 160, 205, 160,
160, 160, 160, 160, 160, 160, 160, 160, 162, 162,
205, 162, 162, 162, 162, 162, 162, 162, 162, 162,
164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 172, 172, 205, 172, 172, 172,
172, 172, 172, 172, 172, 178, 178, 205, 178, 178,
178, 178, 178, 178, 178, 178, 178, 179, 179, 179,
179, 179, 179, 179, 179, 179, 179, 179, 179, 185,
185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
185, 184, 184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 196, 196, 196, 196, 196, 196, 196,
196, 196, 196, 196, 196, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 31,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205
) ;
yy_chk : constant array(0..913) of short :=
( 0,
0, 1, 1, 1, 1, 9, 9, 9, 9, 10,
10, 10, 10, 33, 27, 33, 33, 28, 203, 39,
200, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 15, 2, 16, 2, 39, 36,
39, 2, 198, 15, 27, 16, 15, 28, 16, 36,
2, 2, 2, 2, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 15, 3, 16, 17, 3, 18,
17, 3, 18, 3, 43, 3, 3, 46, 46, 62,
46, 62, 62, 17, 29, 18, 196, 29, 3, 3,
4, 4, 4, 4, 4, 19, 4, 4, 20, 4,
29, 4, 4, 43, 4, 19, 4, 4, 20, 4,
194, 19, 21, 19, 20, 22, 20, 193, 90, 4,
4, 11, 21, 30, 117, 22, 30, 90, 21, 21,
11, 22, 22, 123, 104, 11, 104, 104, 123, 30,
11, 11, 11, 11, 11, 11, 11, 11, 11, 12,
106, 122, 122, 117, 133, 192, 152, 176, 12, 142,
106, 142, 142, 12, 133, 152, 191, 176, 12, 12,
12, 12, 12, 12, 12, 12, 12, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
51, 170, 195, 195, 190, 170, 170, 51, 51, 51,
51, 51, 51, 51, 51, 51, 52, 52, 52, 52,
177, 189, 188, 187, 185, 189, 189, 52, 184, 181,
177, 179, 175, 171, 168, 166, 164, 163, 161, 157,
147, 145, 139, 136, 135, 132, 52, 128, 129, 128,
125, 121, 119, 115, 113, 111, 128, 128, 128, 128,
128, 128, 128, 128, 128, 109, 108, 128, 130, 130,
130, 130, 96, 91, 85, 82, 81, 78, 73, 130,
67, 59, 57, 55, 54, 50, 49, 48, 40, 38,
31, 26, 25, 14, 13, 8, 7, 6, 130, 155,
155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
155, 155, 155, 155, 155, 155, 155, 155, 155, 155,
155, 155, 206, 206, 206, 206, 206, 206, 206, 206,
206, 206, 206, 206, 207, 207, 207, 207, 207, 207,
207, 207, 207, 207, 207, 207, 208, 208, 208, 208,
208, 208, 208, 208, 208, 208, 208, 208, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
210, 210, 210, 210, 210, 210, 210, 210, 210, 210,
210, 210, 211, 211, 211, 211, 211, 211, 211, 211,
211, 211, 211, 211, 212, 212, 212, 212, 212, 212,
212, 212, 212, 212, 212, 212, 213, 213, 213, 213,
213, 213, 213, 213, 213, 213, 213, 213, 214, 214,
214, 214, 214, 214, 214, 214, 214, 214, 214, 214,
215, 215, 215, 215, 215, 215, 215, 215, 215, 215,
215, 215, 216, 216, 216, 216, 216, 216, 216, 216,
216, 216, 216, 216, 217, 217, 217, 217, 217, 217,
217, 217, 217, 217, 217, 217, 218, 218, 218, 218,
218, 218, 218, 218, 218, 218, 218, 218, 219, 219,
5, 0, 219, 220, 220, 0, 0, 220, 221, 221,
221, 221, 221, 221, 221, 221, 221, 221, 221, 221,
222, 222, 222, 222, 222, 222, 222, 222, 222, 222,
222, 222, 223, 223, 0, 0, 223, 224, 224, 0,
0, 0, 0, 0, 0, 0, 224, 225, 225, 0,
225, 225, 225, 225, 225, 0, 225, 225, 225, 226,
226, 0, 226, 226, 226, 226, 226, 226, 226, 226,
226, 227, 227, 0, 227, 227, 227, 227, 227, 227,
227, 227, 227, 228, 228, 228, 228, 228, 228, 228,
228, 228, 228, 228, 228, 229, 229, 229, 229, 229,
229, 229, 229, 229, 229, 229, 229, 230, 0, 0,
230, 230, 230, 230, 230, 230, 230, 230, 230, 231,
231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
231, 232, 232, 0, 232, 232, 232, 232, 232, 232,
232, 232, 232, 233, 233, 0, 0, 233, 234, 234,
0, 234, 234, 234, 234, 234, 234, 234, 234, 234,
235, 235, 0, 235, 235, 235, 235, 235, 235, 235,
235, 235, 236, 236, 0, 236, 236, 236, 236, 236,
0, 236, 236, 236, 237, 237, 0, 0, 0, 237,
237, 237, 237, 0, 237, 238, 238, 0, 238, 238,
238, 238, 238, 238, 238, 238, 238, 239, 239, 0,
0, 239, 240, 240, 240, 240, 240, 240, 240, 240,
240, 240, 240, 240, 241, 241, 0, 0, 241, 241,
241, 0, 241, 241, 241, 241, 242, 242, 0, 242,
242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
0, 243, 243, 243, 243, 243, 243, 243, 243, 243,
244, 244, 244, 244, 244, 244, 244, 244, 244, 244,
244, 244, 245, 245, 245, 245, 245, 245, 245, 245,
245, 245, 245, 245, 246, 246, 0, 246, 246, 246,
246, 246, 246, 246, 246, 247, 247, 0, 247, 247,
247, 247, 247, 247, 247, 247, 247, 248, 248, 248,
248, 248, 248, 248, 248, 248, 248, 248, 248, 249,
249, 249, 249, 249, 249, 249, 249, 249, 249, 249,
249, 250, 250, 250, 250, 250, 250, 250, 250, 250,
250, 250, 250, 251, 251, 251, 251, 251, 251, 251,
251, 251, 251, 251, 251, 252, 252, 252, 252, 252,
252, 252, 252, 252, 252, 252, 252, 253, 253, 253,
253, 253, 253, 253, 253, 253, 253, 253, 253, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205, 205, 205
) ;
-- copy whatever the last rule matched to the standard output
procedure ECHO is
begin
for i in 1 .. yylength loop
if yytext (i) /= ascii.lf then
text_io.put (yytext (i));
else
text_io.new_line;
end if;
end loop;
end ECHO;
-- enter a start condition.
-- Using procedure requires a () after the ENTER, but makes everything
-- much neater.
procedure ENTER( state : integer ) is
begin
yy_start := 1 + 2 * state;
end ENTER;
-- action number for EOF rule of a given start state
function YY_STATE_EOF(state : integer) return integer is
begin
return YY_END_OF_BUFFER + state + 1;
end YY_STATE_EOF;
-- return all but the first 'n' matched characters back to the input stream
procedure yyless(n : integer) is
begin
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + n;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
end yyless;
-- redefine this if you have something you want each time.
procedure YY_USER_ACTION is
begin
null;
end;
-- yy_get_previous_state - get the state just before the EOB char was reached
function yy_get_previous_state return yy_state_type is
yy_current_state : yy_state_type;
yy_c : short;
yy_bp : integer := yytext_ptr;
begin
yy_current_state := yy_start;
if ( yy_ch_buf(yy_bp-1) = ASCII.LF ) then
yy_current_state := yy_current_state + 1;
end if;
for yy_cp in yytext_ptr..yy_c_buf_p - 1 loop
yy_c := yy_ec(yy_ch_buf(yy_cp));
if ( yy_accept(yy_current_state) /= 0 ) then
yy_last_accepting_state := yy_current_state;
yy_last_accepting_cpos := yy_cp;
end if;
while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop
yy_current_state := yy_def(yy_current_state);
if ( yy_current_state >= 206 ) then
yy_c := yy_meta(yy_c);
end if;
end loop;
yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c);
end loop;
return yy_current_state;
end yy_get_previous_state;
procedure yyrestart( input_file : file_type ) is
begin
set_input(input_file);
yy_init := true;
end yyrestart;
begin -- of YYLex
<<new_file>>
-- this is where we enter upon encountering an end-of-file and
-- yywrap() indicating that we should continue processing
if ( yy_init ) then
if ( yy_start = 0 ) then
yy_start := 1; -- first start state
end if;
-- we put in the '\n' and start reading from [1] so that an
-- initial match-at-newline will be true.
yy_ch_buf(0) := ASCII.LF;
yy_n_chars := 1;
-- we always need two end-of-buffer characters. The first causes
-- a transition to the end-of-buffer state. The second causes
-- a jam in that state.
yy_ch_buf(yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf(yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
yy_eof_has_been_seen := false;
yytext_ptr := 1;
yy_c_buf_p := yytext_ptr;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
yy_init := false;
end if; -- yy_init
loop -- loops until end-of-file is reached
yy_cp := yy_c_buf_p;
-- support of yytext
yy_ch_buf(yy_cp) := yy_hold_char;
-- yy_bp points to the position in yy_ch_buf of the start of the
-- current run.
yy_bp := yy_cp;
yy_current_state := yy_start;
if ( yy_ch_buf(yy_bp-1) = ASCII.LF ) then
yy_current_state := yy_current_state + 1;
end if;
loop
yy_c := yy_ec(yy_ch_buf(yy_cp));
if ( yy_accept(yy_current_state) /= 0 ) then
yy_last_accepting_state := yy_current_state;
yy_last_accepting_cpos := yy_cp;
end if;
while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop
yy_current_state := yy_def(yy_current_state);
if ( yy_current_state >= 206 ) then
yy_c := yy_meta(yy_c);
end if;
end loop;
yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c);
yy_cp := yy_cp + 1;
if ( yy_current_state = 205 ) then
exit;
end if;
end loop;
yy_cp := yy_last_accepting_cpos;
yy_current_state := yy_last_accepting_state;
<<next_action>>
yy_act := yy_accept(yy_current_state);
YY_DO_BEFORE_ACTION;
YY_USER_ACTION;
if aflex_debug then -- output acceptance info. for (-d) debug mode
text_io.put( Standard_Error, "--accepting rule #" );
text_io.put( Standard_Error, INTEGER'IMAGE(yy_act) );
text_io.put_line( Standard_Error, "(""" & yytext & """)");
end if;
<<do_action>> -- this label is used only to access EOF actions
case yy_act is
when 0 => -- must backtrack
-- undo the effects of YY_DO_BEFORE_ACTION
yy_ch_buf(yy_cp) := yy_hold_char;
yy_cp := yy_last_accepting_cpos;
yy_current_state := yy_last_accepting_state;
goto next_action;
when 1 =>
--# line 50 "ascan.l"
indented_code := true;
when 2 =>
--# line 51 "ascan.l"
linenum := linenum + 1; ECHO;
-- treat as a comment;
when 3 =>
--# line 54 "ascan.l"
linenum := linenum + 1; ECHO;
when 4 =>
--# line 55 "ascan.l"
return ( SCDECL );
when 5 =>
--# line 56 "ascan.l"
return ( XSCDECL );
when 6 =>
--# line 58 "ascan.l"
return ( WHITESPACE );
when 7 =>
--# line 60 "ascan.l"
sectnum := 2;
misc.line_directive_out;
ENTER(SECT2PROLOG);
return ( SECTEND );
when 8 =>
--# line 67 "ascan.l"
text_io.put( Standard_Error, "old-style lex command at line " );
int_io.put( Standard_Error, linenum );
text_io.put( Standard_Error, "ignored:" );
text_io.new_line( Standard_Error );
text_io.put( Standard_Error, ASCII.HT );
text_io.put( Standard_Error, yytext(1..YYLength) );
linenum := linenum + 1;
when 9 =>
--# line 77 "ascan.l"
nmstr := vstr(yytext(1..YYLength));
didadef := false;
ENTER(PICKUPDEF);
when 10 =>
--# line 83 "ascan.l"
nmstr := vstr(yytext(1..YYLength));
return NAME;
when 11 =>
--# line 86 "ascan.l"
linenum := linenum + 1;
-- allows blank lines in section 1;
when 12 =>
--# line 89 "ascan.l"
linenum := linenum + 1; return Newline;
when 13 =>
--# line 90 "ascan.l"
misc.synerr( "illegal character" );ENTER(RECOVER);
when 14 =>
--# line 92 "ascan.l"
null;
-- separates name and definition;
when 15 =>
--# line 96 "ascan.l"
nmdef := vstr(yytext(1..YYLength));
i := tstring.len( nmdef );
while ( i >= tstring.first ) loop
if ( (CHAR(nmdef,i) /= ' ') and
(CHAR(nmdef,i) /= ASCII.HT) ) then
exit;
end if;
i := i - 1;
end loop;
sym.ndinstal( nmstr,
tstring.slice(nmdef, tstring.first, i) );
didadef := true;
when 16 =>
--# line 113 "ascan.l"
if ( not didadef ) then
misc.synerr( "incomplete name definition" );
end if;
ENTER(0);
linenum := linenum + 1;
when 17 =>
--# line 121 "ascan.l"
linenum := linenum + 1;
ENTER(0);
nmstr := vstr(yytext(1..YYLength));
return NAME;
when 18 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_cp - 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 127 "ascan.l"
linenum := linenum + 1;
ACTION_ECHO;
MARK_END_OF_PROLOG;
ENTER(SECT2);
when 19 =>
--# line 134 "ascan.l"
linenum := linenum + 1; ACTION_ECHO;
when YY_END_OF_BUFFER +SECT2PROLOG + 1
=>
--# line 136 "ascan.l"
MARK_END_OF_PROLOG;
return End_Of_Input;
when 21 =>
--# line 140 "ascan.l"
linenum := linenum + 1;
-- allow blank lines in sect2;
-- this rule matches indented lines which
-- are not comments.
when 22 =>
--# line 145 "ascan.l"
misc.synerr("indented code found outside of action");
linenum := linenum + 1;
when 23 =>
--# line 150 "ascan.l"
ENTER(SC); return ( '<' );
when 24 =>
--# line 151 "ascan.l"
return ( '^' );
when 25 =>
--# line 152 "ascan.l"
ENTER(QUOTE); return ( '"' );
when 26 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 153 "ascan.l"
ENTER(NUM); return ( '{' );
when 27 =>
--# line 154 "ascan.l"
ENTER(BRACEERROR);
when 28 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 155 "ascan.l"
return ( '$' );
when 29 =>
--# line 157 "ascan.l"
continued_action := true;
linenum := linenum + 1;
return Newline;
when 30 =>
--# line 162 "ascan.l"
linenum := linenum + 1; ACTION_ECHO;
when 31 =>
--# line 164 "ascan.l"
-- this rule is separate from the one below because
-- otherwise we get variable trailing context, so
-- we can't build the scanner using -f,F
bracelevel := 0;
continued_action := false;
ENTER(ACTION);
return Newline;
when 32 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_cp - 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 175 "ascan.l"
bracelevel := 0;
continued_action := false;
ENTER(ACTION);
return Newline;
when 33 =>
--# line 182 "ascan.l"
linenum := linenum + 1; return Newline;
when 34 =>
--# line 184 "ascan.l"
return ( EOF_OP );
when 35 =>
--# line 186 "ascan.l"
sectnum := 3;
ENTER(SECT3);
return ( End_Of_Input );
-- to stop the parser
when 36 =>
--# line 193 "ascan.l"
nmstr := vstr(yytext(1..YYLength));
-- check to see if we've already encountered this ccl
cclval := sym.ccllookup( nmstr );
if ( cclval /= 0 ) then
yylval := cclval;
cclreuse := cclreuse + 1;
return ( PREVCCL );
else
-- we fudge a bit. We know that this ccl will
-- soon be numbered as lastccl + 1 by cclinit
sym.cclinstal( nmstr, lastccl + 1 );
-- push back everything but the leading bracket
-- so the ccl can be rescanned
PUT_BACK_STRING(nmstr, 1);
ENTER(FIRSTCCL);
return ( '[' );
end if;
when 37 =>
--# line 218 "ascan.l"
nmstr := vstr(yytext(1..YYLength));
-- chop leading and trailing brace
tmpbuf := slice(vstr(yytext(1..YYLength)),
2, YYLength-1);
nmdefptr := sym.ndlookup( tmpbuf );
if ( nmdefptr = NUL ) then
misc.synerr( "undefined {name}" );
else
-- push back name surrounded by ()'s
unput(')');
PUT_BACK_STRING(nmdefptr, 0);
unput('(');
end if;
when 38 =>
--# line 235 "ascan.l"
tmpbuf := vstr(yytext(1..YYLength));
case tstring.CHAR(tmpbuf,1) is
when '/' => return '/';
when '|' => return '|';
when '*' => return '*';
when '+' => return '+';
when '?' => return '?';
when '.' => return '.';
when '(' => return '(';
when ')' => return ')';
when others =>
misc.aflexerror("error in aflex case");
end case;
when 39 =>
--# line 249 "ascan.l"
tmpbuf := vstr(yytext(1..YYLength));
yylval := CHARACTER'POS(CHAR(tmpbuf,1));
return CHAR;
when 40 =>
--# line 253 "ascan.l"
linenum := linenum + 1; return Newline;
when 41 =>
--# line 256 "ascan.l"
return ( ',' );
when 42 =>
--# line 257 "ascan.l"
ENTER(SECT2); return ( '>' );
when 43 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 258 "ascan.l"
ENTER(CARETISBOL); return ( '>' );
when 44 =>
--# line 259 "ascan.l"
nmstr := vstr(yytext(1..YYLength));
return NAME;
when 45 =>
--# line 262 "ascan.l"
misc.synerr( "bad start condition name" );
when 46 =>
--# line 264 "ascan.l"
ENTER(SECT2); return ( '^' );
when 47 =>
--# line 267 "ascan.l"
tmpbuf := vstr(yytext(1..YYLength));
yylval := CHARACTER'POS(CHAR(tmpbuf,1));
return CHAR;
when 48 =>
--# line 271 "ascan.l"
ENTER(SECT2); return ( '"' );
when 49 =>
--# line 273 "ascan.l"
misc.synerr( "missing quote" );
ENTER(SECT2);
linenum := linenum + 1;
return ( '"' );
when 50 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 281 "ascan.l"
ENTER(CCL); return ( '^' );
when 51 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 282 "ascan.l"
return ( '^' );
when 52 =>
--# line 283 "ascan.l"
ENTER(CCL); yylval := CHARACTER'POS('-'); return ( CHAR );
when 53 =>
--# line 284 "ascan.l"
ENTER(CCL);
tmpbuf := vstr(yytext(1..YYLength));
yylval := CHARACTER'POS(CHAR(tmpbuf,1));
return CHAR;
when 54 =>
yy_ch_buf(yy_cp) := yy_hold_char; -- undo effects of setting up yytext
yy_cp := yy_bp + 1;
yy_c_buf_p := yy_cp;
YY_DO_BEFORE_ACTION; -- set up yytext again
--# line 290 "ascan.l"
return ( '-' );
when 55 =>
--# line 291 "ascan.l"
tmpbuf := vstr(yytext(1..YYLength));
yylval := CHARACTER'POS(CHAR(tmpbuf,1));
return CHAR;
when 56 =>
--# line 295 "ascan.l"
ENTER(SECT2); return ( ']' );
when 57 =>
--# line 298 "ascan.l"
yylval := misc.myctoi( vstr(yytext(1..YYLength)) );
return ( NUMBER );
when 58 =>
--# line 303 "ascan.l"
return ( ',' );
when 59 =>
--# line 304 "ascan.l"
ENTER(SECT2); return ( '}' );
when 60 =>
--# line 306 "ascan.l"
misc.synerr( "bad character inside {}'s" );
ENTER(SECT2);
return ( '}' );
when 61 =>
--# line 312 "ascan.l"
misc.synerr( "missing }" );
ENTER(SECT2);
linenum := linenum + 1;
return ( '}' );
when 62 =>
--# line 320 "ascan.l"
misc.synerr( "bad name in {}'s" ); ENTER(SECT2);
when 63 =>
--# line 321 "ascan.l"
misc.synerr( "missing }" );
linenum := linenum + 1;
ENTER(SECT2);
when 64 =>
--# line 326 "ascan.l"
bracelevel := bracelevel + 1;
when 65 =>
--# line 327 "ascan.l"
bracelevel := bracelevel - 1;
when 66 =>
--# line 328 "ascan.l"
ACTION_ECHO;
when 67 =>
--# line 329 "ascan.l"
ACTION_ECHO;
when 68 =>
--# line 330 "ascan.l"
linenum := linenum + 1; ACTION_ECHO;
when 69 =>
--# line 331 "ascan.l"
ACTION_ECHO;
-- character constant;
when 70 =>
--# line 335 "ascan.l"
ACTION_ECHO; ENTER(ACTION_STRING);
when 71 =>
--# line 337 "ascan.l"
linenum := linenum + 1;
ACTION_ECHO;
if ( bracelevel = 0 ) then
text_io.new_line ( temp_action_file );
ENTER(SECT2);
end if;
when 72 =>
--# line 345 "ascan.l"
ACTION_ECHO;
when 73 =>
--# line 347 "ascan.l"
ACTION_ECHO;
when 74 =>
--# line 348 "ascan.l"
ACTION_ECHO;
when 75 =>
--# line 349 "ascan.l"
linenum := linenum + 1; ACTION_ECHO;
when 76 =>
--# line 350 "ascan.l"
ACTION_ECHO; ENTER(ACTION);
when 77 =>
--# line 351 "ascan.l"
ACTION_ECHO;
when 78 =>
--# line 354 "ascan.l"
yylval := CHARACTER'POS(misc.myesc( vstr(yytext(1..YYLength)) ));
return ( CHAR );
when 79 =>
--# line 359 "ascan.l"
yylval := CHARACTER'POS(misc.myesc( vstr(yytext(1..YYLength)) ));
ENTER(CCL);
return ( CHAR );
when 80 =>
--# line 366 "ascan.l"
if ( check_yylex_here ) then
return End_Of_Input;
else
ECHO;
end if;
when 81 =>
--# line 372 "ascan.l"
raise AFLEX_SCANNER_JAMMED;
when YY_END_OF_BUFFER + INITIAL + 1 |
YY_END_OF_BUFFER + SECT2 + 1 |
YY_END_OF_BUFFER + SECT3 + 1 |
YY_END_OF_BUFFER + PICKUPDEF + 1 |
YY_END_OF_BUFFER + SC + 1 |
YY_END_OF_BUFFER + CARETISBOL + 1 |
YY_END_OF_BUFFER + NUM + 1 |
YY_END_OF_BUFFER + QUOTE + 1 |
YY_END_OF_BUFFER + FIRSTCCL + 1 |
YY_END_OF_BUFFER + CCL + 1 |
YY_END_OF_BUFFER + ACTION + 1 |
YY_END_OF_BUFFER + RECOVER + 1 |
YY_END_OF_BUFFER + BRACEERROR + 1 |
YY_END_OF_BUFFER + ACTION_STRING + 1 =>
return End_Of_Input;
when YY_END_OF_BUFFER =>
-- undo the effects of YY_DO_BEFORE_ACTION
yy_ch_buf(yy_cp) := yy_hold_char;
yytext_ptr := yy_bp;
case yy_get_next_buffer is
when EOB_ACT_END_OF_FILE =>
begin
if ( yywrap ) then
-- note: because we've taken care in
-- yy_get_next_buffer() to have set up yytext,
-- we can now set up yy_c_buf_p so that if some
-- total hoser (like aflex itself) wants
-- to call the scanner after we return the
-- End_Of_Input, it'll still work - another
-- End_Of_Input will get returned.
yy_c_buf_p := yytext_ptr;
yy_act := YY_STATE_EOF((yy_start - 1) / 2);
goto do_action;
else
-- start processing a new file
yy_init := true;
goto new_file;
end if;
end;
when EOB_ACT_RESTART_SCAN =>
yy_c_buf_p := yytext_ptr;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
when EOB_ACT_LAST_MATCH =>
yy_c_buf_p := yy_n_chars;
yy_current_state := yy_get_previous_state;
yy_cp := yy_c_buf_p;
yy_bp := yytext_ptr;
goto next_action;
when others => null;
end case; -- case yy_get_next_buffer()
when others =>
text_io.put( "action # " );
text_io.put( INTEGER'IMAGE(yy_act) );
text_io.new_line;
raise AFLEX_INTERNAL_ERROR;
end case; -- case (yy_act)
end loop; -- end of loop waiting for end of file
end YYLex;
--# line 372 "ascan.l"
begin
if (call_yylex) then
toktype := YYLex;
call_yylex := false;
return toktype;
end if;
if ( eofseen ) then
toktype := End_Of_Input;
else
toktype := YYLex;
end if;
-- this tracing code allows easy tracing of aflex runs
if (trace) then
text_io.new_line(Standard_Error);
text_io.put(Standard_Error, "toktype = :" );
text_io.put(Standard_Error, Token'image(toktype));
text_io.put_line(Standard_Error, ":" );
end if;
if ( toktype = End_Of_Input ) then
eofseen := true;
if ( sectnum = 1 ) then
misc.synerr( "unexpected EOF" );
sectnum := 2;
toktype := SECTEND;
else
if ( sectnum = 2 ) then
sectnum := 3;
toktype := SECTEND;
end if;
end if;
end if;
if ( trace ) then
if ( beglin ) then
int_io.put( Standard_Error, num_rules + 1 );
text_io.put( Standard_Error, ASCII.HT );
beglin := false;
end if;
case toktype is
when '<' | '>'|'^'|'$'|'"'|'['|']'|'{'|'}'|'|'|'('|
')'|'-'|'/'|'?'|'.'|'*'|'+'|',' =>
text_io.put( Standard_Error, Token'image(toktype) );
when NEWLINE =>
text_io.new_line(Standard_Error);
if ( sectnum = 2 ) then
beglin := true;
end if;
when SCDECL =>
text_io.put( Standard_Error, "%s" );
when XSCDECL =>
text_io.put( Standard_Error, "%x" );
when WHITESPACE =>
text_io.put( Standard_Error, " " );
when SECTEND =>
text_io.put_line( Standard_Error, "%%" );
-- we set beglin to be true so we'll start
-- writing out numbers as we echo rules. aflexscan() has
-- already assigned sectnum
if ( sectnum = 2 ) then
beglin := true;
end if;
when NAME =>
text_io.put( Standard_Error, ''' );
text_io.put( Standard_Error, YYText);
text_io.put( Standard_Error, ''' );
when CHAR =>
if ( (yylval < CHARACTER'POS(' ')) or
(yylval = CHARACTER'POS(ASCII.DEL)) ) then
text_io.put( Standard_Error, '\' );
int_io.put( Standard_Error, yylval );
text_io.put( Standard_Error, '\' );
else
text_io.put( Standard_Error, Token'image(toktype) );
end if;
when NUMBER =>
int_io.put( Standard_Error, yylval );
when PREVCCL =>
text_io.put( Standard_Error, '[' );
int_io.put( Standard_Error, yylval );
text_io.put( Standard_Error, ']' );
when End_Of_Input =>
text_io.put( Standard_Error, "End Marker" );
when others =>
text_io.put( Standard_Error, "Something weird:" );
text_io.put_line( Standard_Error, Token'image(toktype));
end case;
end if;
return toktype;
end get_token;
end scanner;
|
with Ada.Text_IO; use Ada.Text_IO;
with Virtual_File_System; use Virtual_File_System;
with Helpers; use Helpers;
procedure TC_Empty_VFS is
VFS : Virtual_File_System.VFS;
begin
Put_Line ("Dumping the root directory of an empty VFS:");
Dump (VFS, "/");
Put_Line ("Done.");
end TC_Empty_VFS;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Handlers;
with Program.Scanner_Destinations;
with Program.Scanners;
with Program.Symbols;
package body Program.Plain_Compilations is
type Scanner_Destination
(Comp : not null access Compilation;
Scanner : not null access Program.Scanners.Scanner)
is
new Program.Scanner_Destinations.Scanner_Destination with
record
Line_From : Positive := 1;
end record;
overriding procedure New_Line
(Self : in out Scanner_Destination;
Unused : Positive);
overriding procedure New_Token
(Self : in out Scanner_Destination;
Token : Program.Scanner_Destinations.Token);
procedure Read_All_Tokens
(Self : access Compilation;
Buffer : Program.Source_Buffers.Source_Buffer_Access);
-------------
-- Context --
-------------
overriding function Context
(Self : Compilation) return not null Program.Contexts.Context_Access is
begin
return Program.Contexts.Context_Access (Self.Context);
end Context;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Compilation'Class;
Context : not null Program.Contexts.Context_Access) is
begin
Self.Context := Plain_Context_Access (Context);
end Initialize;
---------------------
-- Lexical_Element --
---------------------
overriding function Lexical_Element
(Self : Compilation;
Index : Positive)
return Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Tokens.Element (Index);
end Lexical_Element;
---------------------------
-- Lexical_Element_Count --
---------------------------
overriding function Lexical_Element_Count
(Self : Compilation) return Natural is
begin
return Self.Tokens.Length;
end Lexical_Element_Count;
----------
-- Line --
----------
overriding function Line
(Self : Compilation;
Index : Positive) return Text is
begin
return Self.Buffer.Text (Self.Line_Spans (Index));
end Line;
----------------
-- Line_Count --
----------------
overriding function Line_Count (Self : Compilation) return Natural is
begin
return Self.Line_Spans.Last_Index;
end Line_Count;
--------------
-- New_Line --
--------------
overriding procedure New_Line
(Self : in out Scanner_Destination;
Unused : Positive)
is
Span : constant Program.Source_Buffers.Span :=
Self.Scanner.Get_Span;
begin
Self.Comp.Line_Spans.Append
((From => Self.Line_From,
To => Span.From - 1));
Self.Line_From := Span.To + 1;
end New_Line;
---------------
-- New_Token --
---------------
overriding procedure New_Token
(Self : in out Scanner_Destination;
Token : Program.Scanner_Destinations.Token)
is
Symbol : Program.Symbols.Symbol := Program.Symbols.No_Symbol;
begin
if Token.Kind in
Program.Lexical_Elements.Character_Literal
| Program.Lexical_Elements.String_Literal
| Program.Lexical_Elements.Identifier
then
Self.Comp.Context.Find_Or_Create_Symbol
(Self.Comp.Buffer'Unchecked_Access, Token.Span, Symbol);
end if;
Self.Comp.Tokens.Append
(Self.Comp.Buffer'Unchecked_Access,
Token.Span,
Token.Kind,
Symbol);
end New_Token;
-----------------
-- Object_Name --
-----------------
overriding function Object_Name (Self : Compilation) return Text is
begin
return Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String
(Self.Object_Name);
end Object_Name;
----------------
-- Parse_File --
----------------
not overriding procedure Parse_File
(Self : aliased in out Compilation;
Text_Name : Text;
Units : out Program.Parsers.Unit_Vectors.Vector;
Pragmas : out Program.Parsers.Element_Vectors.Vector) is
begin
Self.Buffer.Initialize (Text_Name);
Self.Read_All_Tokens (Self.Buffer'Unchecked_Access);
Program.Parsers.Parse
(Self'Unchecked_Access,
Self.Tokens'Unchecked_Access,
Self.Subpool,
Units,
Pragmas);
end Parse_File;
---------------------
-- Read_All_Tokens --
---------------------
procedure Read_All_Tokens
(Self : access Compilation;
Buffer : Program.Source_Buffers.Source_Buffer_Access)
is
Token : Program.Lexical_Elements.Lexical_Element_Kind;
Scanner : aliased Program.Scanners.Scanner;
Dest : aliased Scanner_Destination (Self, Scanner'Access);
Handler : aliased Program.Lexical_Handlers.Handler (Dest'Access);
begin
Buffer.Rewind;
Scanner.Set_Source (Buffer);
Scanner.Set_Handler (Handler'Unchecked_Access);
loop
Scanner.Get_Token (Token);
exit when Token in Program.Lexical_Elements.End_Of_Input;
end loop;
end Read_All_Tokens;
---------------
-- Text_Name --
---------------
overriding function Text_Name (Self : Compilation) return Text is
begin
return Ada.Strings.Wide_Wide_Unbounded.To_Wide_Wide_String
(Self.Text_Name);
end Text_Name;
end Program.Plain_Compilations;
|
with Ada.Text_IO;
procedure Hello is
package IO renames Ada.Text_IO;
begin
IO.Put_Line("Hello, world!");
exception
when End_Error =>
IO.Put_Line("break");
when others =>
IO.Put_Line("others");
end Hello;
|
with System;
with Interfaces.C;
with Interfaces.C.Strings;
with System.Storage_Elements; use System.Storage_Elements;
with QOI;
package Reference_QOI is
type Ref_Desc is record
width : Interfaces.C.unsigned;
height : Interfaces.C.unsigned;
channels : Interfaces.C.char;
colorspace : Interfaces.C.char;
end record
with Convention => C;
type Ref_Desc_Acc is access all Ref_Desc;
function Encode (Data : System.Address;
Desc : not null Ref_Desc_Acc;
Out_Len : not null access Interfaces.C.int)
return System.Address;
pragma Import (C, Encode, "qoi_encode");
function Check_Encode (Pix : Storage_Array;
Desc : QOI.QOI_Desc;
Output : Storage_Array)
return Boolean;
function Decode (Data : System.Address;
Size : Interfaces.C.int;
Desc : not null Ref_Desc_Acc;
Channels : Interfaces.C.int)
return System.Address;
pragma Import (C, Decode, "qoi_decode");
function Check_Decode (Data : Storage_Array;
Out_Desc : QOI.QOI_Desc;
Out_Data : Storage_Array)
return Boolean;
end Reference_QOI;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G H O S T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains routines that deal with the static and runtime
-- semantics of Ghost entities.
with Opt; use Opt;
with Types; use Types;
package Ghost is
procedure Add_Ignored_Ghost_Unit (Unit : Node_Id);
-- Add a single ignored Ghost compilation unit to the internal table for
-- post processing.
procedure Check_Ghost_Completion
(Prev_Id : Entity_Id;
Compl_Id : Entity_Id);
-- Verify that the Ghost policy of initial entity Prev_Id is compatible
-- with the Ghost policy of completing entity Compl_Id. Emit an error if
-- this is not the case.
procedure Check_Ghost_Context
(Ghost_Id : Entity_Id;
Ghost_Ref : Node_Id);
-- Determine whether node Ghost_Ref appears within a Ghost-friendly context
-- where Ghost entity Ghost_Id can safely reside.
procedure Check_Ghost_Overriding
(Subp : Entity_Id;
Overridden_Subp : Entity_Id);
-- Verify that the Ghost policy of parent subprogram Overridden_Subp is
-- compatible with the Ghost policy of overriding subprogram Subp. Emit
-- an error if this is not the case.
procedure Check_Ghost_Primitive (Prim : Entity_Id; Typ : Entity_Id);
-- Verify that the Ghost policy of primitive operation Prim is the same as
-- the Ghost policy of tagged type Typ. Emit an error if this is not the
-- case.
procedure Check_Ghost_Refinement
(State : Node_Id;
State_Id : Entity_Id;
Constit : Node_Id;
Constit_Id : Entity_Id);
-- Verify that the Ghost policy of constituent Constit_Id is compatible
-- with the Ghost policy of abstract state State_I.
function Implements_Ghost_Interface (Typ : Entity_Id) return Boolean;
-- Determine whether type Typ implements at least one Ghost interface
procedure Initialize;
-- Initialize internal tables
procedure Install_Ghost_Mode (Mode : Ghost_Mode_Type);
-- Set the value of global variable Ghost_Mode depending on the Ghost
-- policy denoted by Mode.
function Is_Ghost_Assignment (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes an assignment statement whose
-- target is a Ghost entity.
function Is_Ghost_Declaration (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a declaration which defines
-- a Ghost entity.
function Is_Ghost_Pragma (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a pragma which encloses a
-- Ghost entity or is associated with a Ghost entity.
function Is_Ghost_Procedure_Call (N : Node_Id) return Boolean;
-- Determine whether arbitrary node N denotes a procedure call invoking a
-- Ghost procedure.
function Is_Ignored_Ghost_Unit (N : Node_Id) return Boolean;
-- Determine whether compilation unit N is subject to pragma Ghost with
-- policy Ignore.
procedure Lock;
-- Lock internal tables before calling backend
procedure Mark_And_Set_Ghost_Assignment
(N : Node_Id;
Mode : out Ghost_Mode_Type);
-- Mark assignment statement N as Ghost when:
--
-- * The left hand side denotes a Ghost entity
--
-- Install the Ghost mode of the assignment statement. Mode is the Ghost
-- mode in effect prior to processing the assignment. This routine starts
-- a Ghost region and must be used in conjunction with Restore_Ghost_Mode.
procedure Mark_And_Set_Ghost_Body
(N : Node_Id;
Spec_Id : Entity_Id;
Mode : out Ghost_Mode_Type);
-- Mark package or subprogram body N as Ghost when:
--
-- * The body is subject to pragma Ghost
--
-- * The body completes a previous declaration whose spec denoted by
-- Spec_Id is a Ghost entity.
--
-- * The body appears within a Ghost region
--
-- Install the Ghost mode of the body. Mode is the Ghost mode prior to
-- processing the body. This routine starts a Ghost region and must be
-- used in conjunction with Restore_Ghost_Mode.
procedure Mark_And_Set_Ghost_Completion
(N : Node_Id;
Prev_Id : Entity_Id;
Mode : out Ghost_Mode_Type);
-- Mark completion N of a deferred constant or private type [extension]
-- Ghost when:
--
-- * The entity of the previous declaration denoted by Prev_Id is Ghost
--
-- * The completion appears within a Ghost region
--
-- Install the Ghost mode of the completion. Mode is the Ghost mode prior
-- to processing the completion. This routine starts a Ghost region and
-- must be used in conjunction with Restore_Ghost_Mode.
procedure Mark_And_Set_Ghost_Declaration
(N : Node_Id;
Mode : out Ghost_Mode_Type);
-- Mark declaration N as Ghost when:
--
-- * The declaration is subject to pragma Ghost
--
-- * The declaration denotes a child package or subprogram and the parent
-- is a Ghost unit.
--
-- * The declaration appears within a Ghost region
--
-- Install the Ghost mode of the declaration. Mode is the Ghost mode prior
-- to processing the declaration. This routine starts a Ghost region and
-- must be used in conjunction with Restore_Ghost_Mode.
procedure Mark_And_Set_Ghost_Instantiation
(N : Node_Id;
Gen_Id : Entity_Id;
Mode : out Ghost_Mode_Type);
-- Mark instantiation N as Ghost when:
--
-- * The instantiation is subject to pragma Ghost
--
-- * The generic template denoted by Gen_Id is Ghost
--
-- * The instantiation appears within a Ghost region
--
-- Install the Ghost mode of the instantiation. Mode is the Ghost mode
-- prior to processing the instantiation. This routine starts a Ghost
-- region and must be used in conjunction with Restore_Ghost_Mode.
procedure Mark_And_Set_Ghost_Procedure_Call
(N : Node_Id;
Mode : out Ghost_Mode_Type);
-- Mark procedure call N as Ghost when:
--
-- * The procedure being invoked is a Ghost entity
--
-- Install the Ghost mode of the procedure call. Mode is the Ghost mode
-- prior to processing the procedure call. This routine starts a Ghost
-- region and must be used in conjunction with Restore_Ghost_Mode.
procedure Mark_Ghost_Clause (N : Node_Id);
-- Mark use package, use type, or with clause N as Ghost when:
--
-- * The clause mentions a Ghost entity
procedure Mark_Ghost_Pragma
(N : Node_Id;
Id : Entity_Id);
-- Mark pragma N as Ghost when:
--
-- * The pragma encloses Ghost entity Id
--
-- * The pragma is associated with Ghost entity Id
procedure Mark_Ghost_Renaming
(N : Node_Id;
Id : Entity_Id);
-- Mark renaming declaration N as Ghost when:
--
-- * Renamed entity Id denotes a Ghost entity
procedure Remove_Ignored_Ghost_Code;
-- Remove all code marked as ignored Ghost from the trees of all qualifying
-- units (SPARK RM 6.9(4)).
--
-- WARNING: this is a separate front end pass, care should be taken to keep
-- it optimized.
procedure Restore_Ghost_Mode (Mode : Ghost_Mode_Type);
-- Terminate a Ghost region by restoring the Ghost mode prior to the
-- region denoted by Mode. This routine must be used in conjunction
-- with Mark_And_Set_xxx routines as well as Set_Ghost_Mode.
procedure Set_Ghost_Mode
(N : Node_Or_Entity_Id;
Mode : out Ghost_Mode_Type);
-- Install the Ghost mode of arbitrary node N. Mode is the Ghost mode prior
-- to processing the node. This routine starts a Ghost region and must be
-- used in conjunction with Restore_Ghost_Mode.
procedure Set_Is_Ghost_Entity (Id : Entity_Id);
-- Set the relevant Ghost attributes of entity Id depending on the current
-- Ghost assertion policy in effect.
end Ghost;
|
pragma SPARK_Mode;
with System;
package body Sparkduino is
procedure Arduino_Serial_Print (Msg : System.Address);
pragma Import (C, Arduino_Serial_Print, "Serial_Print");
procedure Arduino_Serial_Print_Byte (Msg : System.Address;
Val : Byte);
pragma Import (C, Arduino_Serial_Print_Byte, "Serial_Print_Byte");
procedure Arduino_Serial_Print_Short (Msg : System.Address;
Val : short);
pragma Import (C, Arduino_Serial_Print_Short, "Serial_Print_Short");
procedure Arduino_Serial_Print_Float (Msg : System.Address;
Val : Float);
pragma Import (C, Arduino_Serial_Print_Float, "Serial_Print_Float");
procedure Serial_Print (Msg : String)
with SPARK_Mode => Off
is
Msg_Null : char_array (size_t (Msg'First) .. size_t (Msg'Last + 1));
begin
for I in Msg'Range loop
Msg_Null (size_t (I)) := char (Msg (I));
end loop;
Msg_Null (Msg_Null'Last) := nul;
Arduino_Serial_Print (Msg => Msg_Null'Address);
end Serial_Print;
procedure Serial_Print_Byte (Msg : String;
Val : Byte)
with SPARK_Mode => OFf
is
Msg_Null : char_array (size_t (Msg'First) .. size_t (Msg'Last + 1));
begin
for I in Msg'Range loop
Msg_Null (size_t (I)) := char (Msg (I));
end loop;
Msg_Null (Msg_Null'Last) := nul;
Arduino_Serial_Print_Byte (Msg => Msg_Null'Address,
Val => Val);
end Serial_Print_Byte;
procedure Serial_Print_Short (Msg : String;
Val : short)
with SPARK_Mode => OFf
is
Msg_Null : char_array (size_t (Msg'First) .. size_t (Msg'Last + 1));
begin
for I in Msg'Range loop
Msg_Null (size_t (I)) := char (Msg (I));
end loop;
Msg_Null (Msg_Null'Last) := nul;
Arduino_Serial_Print_Short (Msg => Msg_Null'Address,
Val => Val);
end Serial_Print_Short;
procedure Serial_Print_Float (Msg : String;
Val : Float)
with SPARK_Mode => OFf
is
Msg_Null : char_array (size_t (Msg'First) .. size_t (Msg'Last + 1));
begin
for I in Msg'Range loop
Msg_Null (size_t (I)) := char (Msg (I));
end loop;
Msg_Null (Msg_Null'Last) := nul;
Arduino_Serial_Print_Float (Msg => Msg_Null'Address,
Val => Val);
end Serial_Print_Float;
end Sparkduino;
|
package discr1 is
type R is (One, Two);
type C_Type (Kind : R) is
record
case Kind is
when One =>
Name : Integer;
when Two =>
Designator : String (1 .. 40);
end case;
end record;
for C_Type use record
Name at 0 range 0.. 31;
Designator at 0 range 0..319;
Kind at 40 range 0.. 7;
end record;
for C_Type'Size use 44 * 8;
procedure Assign (Id : String);
end discr1;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Links;
with AMF.Internals.Tables.DC_Notification;
with AMF.Internals.Tables.DD_Element_Table;
with AMF.Internals.Tables.DD_Types;
with AMF.Internals.Tables.DG_Metamodel;
package body AMF.Internals.Tables.DD_Attributes is
use type Matreshka.Internals.Strings.Shared_String_Access;
-- Canvas
--
-- 5 Canvas::backgroundColor
-- 4 Canvas::backgroundFill
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 4 Canvas::packagedFill
-- 5 Canvas::packagedMarker
-- 6 Canvas::packagedStyle
-- 2 GraphicalElement::sharedStyle
-- Circle
--
-- 5 Circle::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Circle::radius
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- ClipPath
--
-- 3 GraphicalElement::clipPath
-- 4 ClipPath::clippedElement
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Ellipse
--
-- 5 Ellipse::center
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 4 Ellipse::radii
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Group
--
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Image
--
-- 4 Image::bounds
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Image::isAspectRatioPreserved
-- 5 Image::source
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Line
--
-- 3 GraphicalElement::clipPath
-- 8 Line::end
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Line::start
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- LinearGradient
--
-- 2 Fill::canvas
-- 3 Gradient::stop
-- 1 Fill::transform
-- 4 LinearGradient::x1
-- 5 LinearGradient::x2
-- 6 LinearGradient::y1
-- 7 LinearGradient::y2
--
-- MarkedElement
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Marker
--
-- 4 Marker::canvas
-- 3 GraphicalElement::clipPath
-- 2 GraphicalElement::group
-- 6 Marker::reference
-- 5 Marker::size
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 3 Group::member
-- 2 GraphicalElement::sharedStyle
-- Path
--
-- 3 GraphicalElement::clipPath
-- 7 Path::command
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Pattern
--
-- 4 Pattern::bounds
-- 2 Fill::canvas
-- 3 Pattern::tile
-- 1 Fill::transform
--
-- Polygon
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polygon::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Polyline
--
-- 3 GraphicalElement::clipPath
-- 5 MarkedElement::endMarker
-- 2 GraphicalElement::group
-- 6 MarkedElement::midMarker
-- 7 Polyline::point
-- 4 MarkedElement::startMarker
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- RadialGradient
--
-- 2 Fill::canvas
-- 5 RadialGradient::centerX
-- 6 RadialGradient::centerY
-- 7 RadialGradient::focusX
-- 8 RadialGradient::focusY
-- 4 RadialGradient::radius
-- 3 Gradient::stop
-- 1 Fill::transform
--
-- Rectangle
--
-- 4 Rectangle::bounds
-- 3 GraphicalElement::clipPath
-- 5 Rectangle::cornerRadius
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
-- Style
--
-- 1 Style::fill
-- 2 Style::fillColor
-- 3 Style::fillOpacity
-- 12 Style::fontBold
-- 10 Style::fontColor
-- 11 Style::fontItalic
-- 9 Style::fontName
-- 8 Style::fontSize
-- 14 Style::fontStrikeThrough
-- 13 Style::fontUnderline
-- 6 Style::strokeColor
-- 7 Style::strokeDashLength
-- 5 Style::strokeOpacity
-- 4 Style::strokeWidth
--
-- Text
--
-- 6 Text::alignment
-- 4 Text::bounds
-- 3 GraphicalElement::clipPath
-- 5 Text::data
-- 2 GraphicalElement::group
-- 1 GraphicalElement::transform
--
-- 1 GraphicalElement::localStyle
-- 2 GraphicalElement::sharedStyle
----------------------------
-- Internal_Get_Alignment --
----------------------------
function Internal_Get_Alignment
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Alignment_Kind is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
end Internal_Get_Alignment;
-----------------------------------
-- Internal_Get_Background_Color --
-----------------------------------
function Internal_Get_Background_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
end Internal_Get_Background_Color;
----------------------------------
-- Internal_Get_Background_Fill --
----------------------------------
function Internal_Get_Background_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Background_Fill;
-------------------------
-- Internal_Get_Bounds --
-------------------------
function Internal_Get_Bounds
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Bounds is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
end Internal_Get_Bounds;
-------------------------
-- Internal_Get_Canvas --
-------------------------
function Internal_Get_Canvas
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Canvas;
-------------------------
-- Internal_Get_Center --
-------------------------
function Internal_Get_Center
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
end Internal_Get_Center;
---------------------------
-- Internal_Get_Center_X --
---------------------------
function Internal_Get_Center_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Center_X;
---------------------------
-- Internal_Get_Center_Y --
---------------------------
function Internal_Get_Center_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Center_Y;
----------------------------
-- Internal_Get_Clip_Path --
----------------------------
function Internal_Get_Clip_Path
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clip_Path;
----------------------------------
-- Internal_Get_Clipped_Element --
----------------------------------
function Internal_Get_Clipped_Element
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Clipped_Element;
--------------------------
-- Internal_Get_Command --
--------------------------
function Internal_Get_Command
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_Path_Command is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Path_Collection;
end Internal_Get_Command;
--------------------------------
-- Internal_Get_Corner_Radius --
--------------------------------
function Internal_Get_Corner_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_Corner_Radius;
-----------------------
-- Internal_Get_Data --
-----------------------
function Internal_Get_Data
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Data;
----------------------
-- Internal_Get_End --
----------------------
function Internal_Get_End
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
end Internal_Get_End;
-----------------------------
-- Internal_Get_End_Marker --
-----------------------------
function Internal_Get_End_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_End_Marker;
-----------------------
-- Internal_Get_Fill --
-----------------------
function Internal_Get_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Fill;
-----------------------------
-- Internal_Get_Fill_Color --
-----------------------------
function Internal_Get_Fill_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
end Internal_Get_Fill_Color;
-------------------------------
-- Internal_Get_Fill_Opacity --
-------------------------------
function Internal_Get_Fill_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
end Internal_Get_Fill_Opacity;
--------------------------
-- Internal_Get_Focus_X --
--------------------------
function Internal_Get_Focus_X
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Focus_X;
--------------------------
-- Internal_Get_Focus_Y --
--------------------------
function Internal_Get_Focus_Y
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
end Internal_Get_Focus_Y;
----------------------------
-- Internal_Get_Font_Bold --
----------------------------
function Internal_Get_Font_Bold
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
end Internal_Get_Font_Bold;
-----------------------------
-- Internal_Get_Font_Color --
-----------------------------
function Internal_Get_Font_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
end Internal_Get_Font_Color;
------------------------------
-- Internal_Get_Font_Italic --
------------------------------
function Internal_Get_Font_Italic
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
end Internal_Get_Font_Italic;
----------------------------
-- Internal_Get_Font_Name --
----------------------------
function Internal_Get_Font_Name
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
end Internal_Get_Font_Name;
----------------------------
-- Internal_Get_Font_Size --
----------------------------
function Internal_Get_Font_Size
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
end Internal_Get_Font_Size;
--------------------------------------
-- Internal_Get_Font_Strike_Through --
--------------------------------------
function Internal_Get_Font_Strike_Through
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
end Internal_Get_Font_Strike_Through;
---------------------------------
-- Internal_Get_Font_Underline --
---------------------------------
function Internal_Get_Font_Underline
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
end Internal_Get_Font_Underline;
------------------------
-- Internal_Get_Group --
------------------------
function Internal_Get_Group
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Group;
--------------------------------------------
-- Internal_Get_Is_Aspect_Ratio_Preserved --
--------------------------------------------
function Internal_Get_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element)
return Boolean is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
end Internal_Get_Is_Aspect_Ratio_Preserved;
------------------------------
-- Internal_Get_Local_Style --
------------------------------
function Internal_Get_Local_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 1;
when others =>
raise Program_Error;
end case;
end Internal_Get_Local_Style;
-------------------------
-- Internal_Get_Member --
-------------------------
function Internal_Get_Member
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 3;
when others =>
raise Program_Error;
end case;
end Internal_Get_Member;
-----------------------------
-- Internal_Get_Mid_Marker --
-----------------------------
function Internal_Get_Mid_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Mid_Marker;
--------------------------------
-- Internal_Get_Packaged_Fill --
--------------------------------
function Internal_Get_Packaged_Fill
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 4;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Fill;
----------------------------------
-- Internal_Get_Packaged_Marker --
----------------------------------
function Internal_Get_Packaged_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 5;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Marker;
---------------------------------
-- Internal_Get_Packaged_Style --
---------------------------------
function Internal_Get_Packaged_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 6;
when others =>
raise Program_Error;
end case;
end Internal_Get_Packaged_Style;
------------------------
-- Internal_Get_Point --
------------------------
function Internal_Get_Point
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Sequence_Of_DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Collection;
end Internal_Get_Point;
------------------------
-- Internal_Get_Radii --
------------------------
function Internal_Get_Radii
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
end Internal_Get_Radii;
-------------------------
-- Internal_Get_Radius --
-------------------------
function Internal_Get_Radius
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_Radius;
----------------------------
-- Internal_Get_Reference --
----------------------------
function Internal_Get_Reference
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
end Internal_Get_Reference;
-------------------------------
-- Internal_Get_Shared_Style --
-------------------------------
function Internal_Get_Shared_Style
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Collection_Of_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (0).Collection + 2;
when others =>
raise Program_Error;
end case;
end Internal_Get_Shared_Style;
-----------------------
-- Internal_Get_Size --
-----------------------
function Internal_Get_Size
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Dimension is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
end Internal_Get_Size;
-------------------------
-- Internal_Get_Source --
-------------------------
function Internal_Get_Source
(Self : AMF.Internals.AMF_Element)
return Matreshka.Internals.Strings.Shared_String_Access is
begin
return
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
end Internal_Get_Source;
------------------------
-- Internal_Get_Start --
------------------------
function Internal_Get_Start
(Self : AMF.Internals.AMF_Element)
return AMF.DC.DC_Point is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
end Internal_Get_Start;
-------------------------------
-- Internal_Get_Start_Marker --
-------------------------------
function Internal_Get_Start_Marker
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Start_Marker;
-----------------------
-- Internal_Get_Stop --
-----------------------
function Internal_Get_Stop
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Set_Of_DG_Gradient_Stop is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Gradient_Collection;
end Internal_Get_Stop;
-------------------------------
-- Internal_Get_Stroke_Color --
-------------------------------
function Internal_Get_Stroke_Color
(Self : AMF.Internals.AMF_Element)
return AMF.DC.Optional_DC_Color is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
end Internal_Get_Stroke_Color;
-------------------------------------
-- Internal_Get_Stroke_Dash_Length --
-------------------------------------
function Internal_Get_Stroke_Dash_Length
(Self : AMF.Internals.AMF_Element)
return AMF.Real_Collections.Sequence_Of_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Collection;
end Internal_Get_Stroke_Dash_Length;
---------------------------------
-- Internal_Get_Stroke_Opacity --
---------------------------------
function Internal_Get_Stroke_Opacity
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
end Internal_Get_Stroke_Opacity;
-------------------------------
-- Internal_Get_Stroke_Width --
-------------------------------
function Internal_Get_Stroke_Width
(Self : AMF.Internals.AMF_Element)
return AMF.Optional_Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
end Internal_Get_Stroke_Width;
-----------------------
-- Internal_Get_Tile --
-----------------------
function Internal_Get_Tile
(Self : AMF.Internals.AMF_Element)
return AMF.Internals.AMF_Element is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
return
AMF.Internals.Links.Opposite_Element
(AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Link, Self);
when others =>
raise Program_Error;
end case;
end Internal_Get_Tile;
----------------------------
-- Internal_Get_Transform --
----------------------------
function Internal_Get_Transform
(Self : AMF.Internals.AMF_Element)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (1).Transform_Collection;
end Internal_Get_Transform;
---------------------
-- Internal_Get_X1 --
---------------------
function Internal_Get_X1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
end Internal_Get_X1;
---------------------
-- Internal_Get_X2 --
---------------------
function Internal_Get_X2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
end Internal_Get_X2;
---------------------
-- Internal_Get_Y1 --
---------------------
function Internal_Get_Y1
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
end Internal_Get_Y1;
---------------------
-- Internal_Get_Y2 --
---------------------
function Internal_Get_Y2
(Self : AMF.Internals.AMF_Element)
return AMF.Real is
begin
return AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
end Internal_Get_Y2;
----------------------------
-- Internal_Set_Alignment --
----------------------------
procedure Internal_Set_Alignment
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Alignment_Kind)
is
Old : AMF.DC.DC_Alignment_Kind;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Alignment_Kind_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Alignment, Old, To);
end Internal_Set_Alignment;
-----------------------------------
-- Internal_Set_Background_Color --
-----------------------------------
procedure Internal_Set_Background_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Canvas_Background_Color, Old, To);
end Internal_Set_Background_Color;
----------------------------------
-- Internal_Set_Background_Fill --
----------------------------------
procedure Internal_Set_Background_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Background_Fill_Canvas,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Background_Fill;
-------------------------
-- Internal_Set_Bounds --
-------------------------
procedure Internal_Set_Bounds
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Bounds)
is
Old : AMF.DC.DC_Bounds;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Bounds_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Bounds, Old, To);
end Internal_Set_Bounds;
-------------------------
-- Internal_Set_Canvas --
-------------------------
procedure Internal_Set_Canvas
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Linear_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Marker_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Radial_Gradient =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Canvas_Packaged_Fill_Canvas,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Canvas;
-------------------------
-- Internal_Set_Center --
-------------------------
procedure Internal_Set_Center
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Center, Old, To);
end Internal_Set_Center;
---------------------------
-- Internal_Set_Center_X --
---------------------------
procedure Internal_Set_Center_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_X, Old, To);
end Internal_Set_Center_X;
---------------------------
-- Internal_Set_Center_Y --
---------------------------
procedure Internal_Set_Center_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Center_Y, Old, To);
end Internal_Set_Center_Y;
----------------------------
-- Internal_Set_Clip_Path --
----------------------------
procedure Internal_Set_Clip_Path
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clip_Path;
----------------------------------
-- Internal_Set_Clipped_Element --
----------------------------------
procedure Internal_Set_Clipped_Element
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Graphical_Element_Clip_Path_Clipped_Element,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Clipped_Element;
--------------------------------
-- Internal_Set_Corner_Radius --
--------------------------------
procedure Internal_Set_Corner_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Rectangle_Corner_Radius, Old, To);
end Internal_Set_Corner_Radius;
-----------------------
-- Internal_Set_Data --
-----------------------
procedure Internal_Set_Data
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Text_Data, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Data;
----------------------
-- Internal_Set_End --
----------------------
procedure Internal_Set_End
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_End, Old, To);
end Internal_Set_End;
-----------------------------
-- Internal_Set_End_Marker --
-----------------------------
procedure Internal_Set_End_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_End_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_End_Marker;
-----------------------
-- Internal_Set_Fill --
-----------------------
procedure Internal_Set_Fill
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Style =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Style_Fill_Style,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Fill;
-----------------------------
-- Internal_Set_Fill_Color --
-----------------------------
procedure Internal_Set_Fill_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (2).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Color, Old, To);
end Internal_Set_Fill_Color;
-------------------------------
-- Internal_Set_Fill_Opacity --
-------------------------------
procedure Internal_Set_Fill_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (3).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Fill_Opacity, Old, To);
end Internal_Set_Fill_Opacity;
--------------------------
-- Internal_Set_Focus_X --
--------------------------
procedure Internal_Set_Focus_X
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_X, Old, To);
end Internal_Set_Focus_X;
--------------------------
-- Internal_Set_Focus_Y --
--------------------------
procedure Internal_Set_Focus_Y
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Radial_Gradient_Focus_Y, Old, To);
end Internal_Set_Focus_Y;
----------------------------
-- Internal_Set_Font_Bold --
----------------------------
procedure Internal_Set_Font_Bold
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (12).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Bold, Old, To);
end Internal_Set_Font_Bold;
-----------------------------
-- Internal_Set_Font_Color --
-----------------------------
procedure Internal_Set_Font_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (10).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Color, Old, To);
end Internal_Set_Font_Color;
------------------------------
-- Internal_Set_Font_Italic --
------------------------------
procedure Internal_Set_Font_Italic
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (11).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Italic, Old, To);
end Internal_Set_Font_Italic;
----------------------------
-- Internal_Set_Font_Name --
----------------------------
procedure Internal_Set_Font_Name
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (9).String_Value;
DD_Element_Table.Table (Self).Member (9).String_Value := To;
if DD_Element_Table.Table (Self).Member (9).String_Value /= null then
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (9).String_Value);
end if;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Name, Old, To);
if Old /= null then
Matreshka.Internals.Strings.Reference (Old);
end if;
end Internal_Set_Font_Name;
----------------------------
-- Internal_Set_Font_Size --
----------------------------
procedure Internal_Set_Font_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (8).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Size, Old, To);
end Internal_Set_Font_Size;
--------------------------------------
-- Internal_Set_Font_Strike_Through --
--------------------------------------
procedure Internal_Set_Font_Strike_Through
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (14).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Strike_Through, Old, To);
end Internal_Set_Font_Strike_Through;
---------------------------------
-- Internal_Set_Font_Underline --
---------------------------------
procedure Internal_Set_Font_Underline
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Boolean)
is
Old : AMF.Optional_Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (13).Boolean_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Font_Underline, Old, To);
end Internal_Set_Font_Underline;
------------------------
-- Internal_Set_Group --
------------------------
procedure Internal_Set_Group
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Canvas =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Circle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Clip_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Ellipse =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Group =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Image =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Marker =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Rectangle =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when AMF.Internals.Tables.DD_Types.E_DG_Text =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Group_Member_Group,
To,
Self);
when others =>
raise Program_Error;
end case;
end Internal_Set_Group;
--------------------------------------------
-- Internal_Set_Is_Aspect_Ratio_Preserved --
--------------------------------------------
procedure Internal_Set_Is_Aspect_Ratio_Preserved
(Self : AMF.Internals.AMF_Element;
To : Boolean)
is
Old : Boolean;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Boolean_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Is_Aspect_Ratio_Preserved, Old, To);
end Internal_Set_Is_Aspect_Ratio_Preserved;
-----------------------------
-- Internal_Set_Mid_Marker --
-----------------------------
procedure Internal_Set_Mid_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Mid_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Mid_Marker;
------------------------
-- Internal_Set_Radii --
------------------------
procedure Internal_Set_Radii
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Ellipse_Radii, Old, To);
end Internal_Set_Radii;
-------------------------
-- Internal_Set_Radius --
-------------------------
procedure Internal_Set_Radius
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Circle_Radius, Old, To);
end Internal_Set_Radius;
----------------------------
-- Internal_Set_Reference --
----------------------------
procedure Internal_Set_Reference
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Reference, Old, To);
end Internal_Set_Reference;
-----------------------
-- Internal_Set_Size --
-----------------------
procedure Internal_Set_Size
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Dimension)
is
Old : AMF.DC.DC_Dimension;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Dimension_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Marker_Size, Old, To);
end Internal_Set_Size;
-------------------------
-- Internal_Set_Source --
-------------------------
procedure Internal_Set_Source
(Self : AMF.Internals.AMF_Element;
To : Matreshka.Internals.Strings.Shared_String_Access)
is
Old : Matreshka.Internals.Strings.Shared_String_Access;
begin
Old :=
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).String_Value;
DD_Element_Table.Table (Self).Member (5).String_Value := To;
Matreshka.Internals.Strings.Reference
(DD_Element_Table.Table (Self).Member (5).String_Value);
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Image_Source, Old, To);
Matreshka.Internals.Strings.Dereference (Old);
end Internal_Set_Source;
------------------------
-- Internal_Set_Start --
------------------------
procedure Internal_Set_Start
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.DC_Point)
is
Old : AMF.DC.DC_Point;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Point_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Line_Start, Old, To);
end Internal_Set_Start;
-------------------------------
-- Internal_Set_Start_Marker --
-------------------------------
procedure Internal_Set_Start_Marker
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Line =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Marked_Element =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Path =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polygon =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when AMF.Internals.Tables.DD_Types.E_DG_Polyline =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Marked_Element_Start_Marker_Marked_Element,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Start_Marker;
-------------------------------
-- Internal_Set_Stroke_Color --
-------------------------------
procedure Internal_Set_Stroke_Color
(Self : AMF.Internals.AMF_Element;
To : AMF.DC.Optional_DC_Color)
is
Old : AMF.DC.Optional_DC_Color;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Color_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Color, Old, To);
end Internal_Set_Stroke_Color;
---------------------------------
-- Internal_Set_Stroke_Opacity --
---------------------------------
procedure Internal_Set_Stroke_Opacity
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Opacity, Old, To);
end Internal_Set_Stroke_Opacity;
-------------------------------
-- Internal_Set_Stroke_Width --
-------------------------------
procedure Internal_Set_Stroke_Width
(Self : AMF.Internals.AMF_Element;
To : AMF.Optional_Real)
is
Old : AMF.Optional_Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Holder := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Style_Stroke_Width, Old, To);
end Internal_Set_Stroke_Width;
-----------------------
-- Internal_Set_Tile --
-----------------------
procedure Internal_Set_Tile
(Self : AMF.Internals.AMF_Element;
To : AMF.Internals.AMF_Element) is
begin
case AMF.Internals.Tables.DD_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.DD_Types.E_DG_Pattern =>
AMF.Internals.Links.Create_Link
(AMF.Internals.Tables.DG_Metamodel.MA_DG_Pattern_Tile_Pattern,
Self,
To);
when others =>
raise Program_Error;
end case;
end Internal_Set_Tile;
---------------------
-- Internal_Set_X1 --
---------------------
procedure Internal_Set_X1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (4).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X1, Old, To);
end Internal_Set_X1;
---------------------
-- Internal_Set_X2 --
---------------------
procedure Internal_Set_X2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (5).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_X2, Old, To);
end Internal_Set_X2;
---------------------
-- Internal_Set_Y1 --
---------------------
procedure Internal_Set_Y1
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (6).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y1, Old, To);
end Internal_Set_Y1;
---------------------
-- Internal_Set_Y2 --
---------------------
procedure Internal_Set_Y2
(Self : AMF.Internals.AMF_Element;
To : AMF.Real)
is
Old : AMF.Real;
begin
Old := AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value;
AMF.Internals.Tables.DD_Element_Table.Table (Self).Member (7).Real_Value := To;
AMF.Internals.Tables.DC_Notification.Notify_Attribute_Set
(Self, AMF.Internals.Tables.DG_Metamodel.MP_DG_Linear_Gradient_Y2, Old, To);
end Internal_Set_Y2;
end AMF.Internals.Tables.DD_Attributes;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Excepciones_4 is
I, J : Integer;
begin
I := 0;
while I < 50 loop
begin
J := 40 / I;
exception
when Constraint_Error =>
Put_Line("Intento de dividir por 0");
end;
Put_Line("Resultado: " & Integer'Image(J));
I := I + 10;
end loop;
end Excepciones_4;
|
with Tkmrpc.Servers.Cfg;
with Tkmrpc.Response.Cfg.Tkm_Reset.Convert;
package body Tkmrpc.Operation_Handlers.Cfg.Tkm_Reset is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
pragma Unreferenced (Req);
Specific_Res : Response.Cfg.Tkm_Reset.Response_Type;
begin
Specific_Res := Response.Cfg.Tkm_Reset.Null_Response;
Servers.Cfg.Tkm_Reset (Result => Specific_Res.Header.Result);
Res := Response.Cfg.Tkm_Reset.Convert.To_Response (S => Specific_Res);
end Handle;
end Tkmrpc.Operation_Handlers.Cfg.Tkm_Reset;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . D I R E C T O R I E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Directories.Validity; use Ada.Directories.Validity;
with Ada.Strings.Fixed;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Unchecked_Deallocation;
with System; use System;
with System.CRTL; use System.CRTL;
with System.File_Attributes; use System.File_Attributes;
with System.File_IO; use System.File_IO;
with System.OS_Constants; use System.OS_Constants;
with System.OS_Lib; use System.OS_Lib;
with System.Regexp; use System.Regexp;
package body Ada.Directories is
type Dir_Type_Value is new Address;
-- This is the low-level address directory structure as returned by the C
-- opendir routine.
No_Dir : constant Dir_Type_Value := Dir_Type_Value (Null_Address);
-- Null directory value
Dir_Separator : constant Character;
pragma Import (C, Dir_Separator, "__gnat_dir_separator");
-- Running system default directory separator
Dir_Seps : constant Character_Set := Strings.Maps.To_Set ("/\");
-- UNIX and DOS style directory separators
Max_Path : Integer;
pragma Import (C, Max_Path, "__gnat_max_path_len");
-- The maximum length of a path
type Search_Data is record
Is_Valid : Boolean := False;
Name : Unbounded_String;
Pattern : Regexp;
Filter : Filter_Type;
Dir : Dir_Type_Value := No_Dir;
Entry_Fetched : Boolean := False;
Dir_Entry : Directory_Entry_Type;
end record;
-- The current state of a search
Empty_String : constant String := (1 .. 0 => ASCII.NUL);
-- Empty string, returned by function Extension when there is no extension
procedure Free is new Ada.Unchecked_Deallocation (Search_Data, Search_Ptr);
procedure Close (Dir : Dir_Type_Value);
function File_Exists (Name : String) return Boolean;
-- Returns True if the named file exists
procedure Fetch_Next_Entry (Search : Search_Type);
-- Get the next entry in a directory, setting Entry_Fetched if successful
-- or resetting Is_Valid if not.
---------------
-- Base_Name --
---------------
function Base_Name (Name : String) return String is
Simple : constant String := Simple_Name (Name);
-- Simple'First is guaranteed to be 1
begin
-- Look for the last dot in the file name and return the part of the
-- file name preceding this last dot. If the first dot is the first
-- character of the file name, the base name is the empty string.
for Pos in reverse Simple'Range loop
if Simple (Pos) = '.' then
return Simple (1 .. Pos - 1);
end if;
end loop;
-- If there is no dot, return the complete file name
return Simple;
end Base_Name;
-----------
-- Close --
-----------
procedure Close (Dir : Dir_Type_Value) is
Discard : Integer;
pragma Warnings (Off, Discard);
function closedir (directory : DIRs) return Integer;
pragma Import (C, closedir, "__gnat_closedir");
begin
Discard := closedir (DIRs (Dir));
end Close;
-------------
-- Compose --
-------------
function Compose
(Containing_Directory : String := "";
Name : String;
Extension : String := "") return String
is
Result : String (1 .. Containing_Directory'Length +
Name'Length + Extension'Length + 2);
Last : Natural;
begin
-- First, deal with the invalid cases
if Containing_Directory /= ""
and then not Is_Valid_Path_Name (Containing_Directory)
then
raise Name_Error with
"invalid directory path name """ & Containing_Directory & '"';
elsif
Extension'Length = 0 and then (not Is_Valid_Simple_Name (Name))
then
raise Name_Error with
"invalid simple name """ & Name & '"';
elsif Extension'Length /= 0
and then not Is_Valid_Simple_Name (Name & '.' & Extension)
then
raise Name_Error with
"invalid file name """ & Name & '.' & Extension & '"';
-- This is not an invalid case so build the path name
else
Last := Containing_Directory'Length;
Result (1 .. Last) := Containing_Directory;
-- Add a directory separator if needed
if Last /= 0 and then not Is_In (Result (Last), Dir_Seps) then
Last := Last + 1;
Result (Last) := Dir_Separator;
end if;
-- Add the file name
Result (Last + 1 .. Last + Name'Length) := Name;
Last := Last + Name'Length;
-- If extension was specified, add dot followed by this extension
if Extension'Length /= 0 then
Last := Last + 1;
Result (Last) := '.';
Result (Last + 1 .. Last + Extension'Length) := Extension;
Last := Last + Extension'Length;
end if;
return Result (1 .. Last);
end if;
end Compose;
--------------------------
-- Containing_Directory --
--------------------------
function Containing_Directory (Name : String) return String is
begin
-- First, the invalid case
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
else
declare
Last_DS : constant Natural :=
Strings.Fixed.Index (Name, Dir_Seps, Going => Strings.Backward);
begin
if Last_DS = 0 then
-- There is no directory separator, returns "." representing
-- the current working directory.
return ".";
-- If Name indicates a root directory, raise Use_Error, because
-- it has no containing directory.
elsif Name = "/"
or else
(Windows
and then
(Name = "\"
or else
(Name'Length = 3
and then Name (Name'Last - 1 .. Name'Last) = ":\"
and then (Name (Name'First) in 'a' .. 'z'
or else
Name (Name'First) in 'A' .. 'Z'))))
then
raise Use_Error with
"directory """ & Name & """ has no containing directory";
else
declare
Last : Positive := Last_DS - Name'First + 1;
Result : String (1 .. Last);
begin
Result := Name (Name'First .. Last_DS);
-- Remove any trailing directory separator, except as the
-- first character or the first character following a drive
-- number on Windows.
while Last > 1 loop
exit when
Result (Last) /= '/'
and then
Result (Last) /= Directory_Separator;
exit when Windows
and then Last = 3
and then Result (2) = ':'
and then
(Result (1) in 'A' .. 'Z'
or else
Result (1) in 'a' .. 'z');
Last := Last - 1;
end loop;
-- Special case of "..": the current directory may be a root
-- directory.
if Last = 2 and then Result (1 .. 2) = ".." then
return Containing_Directory (Current_Directory);
else
return Result (1 .. Last);
end if;
end;
end if;
end;
end if;
end Containing_Directory;
---------------
-- Copy_File --
---------------
procedure Copy_File
(Source_Name : String;
Target_Name : String;
Form : String := "")
is
Success : Boolean;
Mode : Copy_Mode := Overwrite;
Preserve : Attribute := None;
begin
-- First, the invalid cases
if not Is_Valid_Path_Name (Source_Name) then
raise Name_Error with
"invalid source path name """ & Source_Name & '"';
elsif not Is_Valid_Path_Name (Target_Name) then
raise Name_Error with
"invalid target path name """ & Target_Name & '"';
elsif not Is_Regular_File (Source_Name) then
raise Name_Error with '"' & Source_Name & """ is not a file";
elsif Is_Directory (Target_Name) then
raise Use_Error with "target """ & Target_Name & """ is a directory";
else
if Form'Length > 0 then
declare
Formstr : String (1 .. Form'Length + 1);
V1, V2 : Natural;
begin
-- Acquire form string, setting required NUL terminator
Formstr (1 .. Form'Length) := Form;
Formstr (Formstr'Last) := ASCII.NUL;
-- Convert form string to lower case
for J in Formstr'Range loop
if Formstr (J) in 'A' .. 'Z' then
Formstr (J) :=
Character'Val (Character'Pos (Formstr (J)) + 32);
end if;
end loop;
-- Check Form
Form_Parameter (Formstr, "mode", V1, V2);
if V1 = 0 then
Mode := Overwrite;
elsif Formstr (V1 .. V2) = "copy" then
Mode := Copy;
elsif Formstr (V1 .. V2) = "overwrite" then
Mode := Overwrite;
elsif Formstr (V1 .. V2) = "append" then
Mode := Append;
else
raise Use_Error with "invalid Form";
end if;
Form_Parameter (Formstr, "preserve", V1, V2);
if V1 = 0 then
Preserve := None;
elsif Formstr (V1 .. V2) = "timestamps" then
Preserve := Time_Stamps;
elsif Formstr (V1 .. V2) = "all_attributes" then
Preserve := Full;
elsif Formstr (V1 .. V2) = "no_attributes" then
Preserve := None;
else
raise Use_Error with "invalid Form";
end if;
end;
end if;
-- Do actual copy using System.OS_Lib.Copy_File
Copy_File (Source_Name, Target_Name, Success, Mode, Preserve);
if not Success then
raise Use_Error with "copy of """ & Source_Name & """ failed";
end if;
end if;
end Copy_File;
----------------------
-- Create_Directory --
----------------------
procedure Create_Directory
(New_Directory : String;
Form : String := "")
is
C_Dir_Name : constant String := New_Directory & ASCII.NUL;
begin
-- First, the invalid case
if not Is_Valid_Path_Name (New_Directory) then
raise Name_Error with
"invalid new directory path name """ & New_Directory & '"';
else
-- Acquire setting of encoding parameter
declare
Formstr : constant String := To_Lower (Form);
Encoding : CRTL.Filename_Encoding;
-- Filename encoding specified into the form parameter
V1, V2 : Natural;
begin
Form_Parameter (Formstr, "encoding", V1, V2);
if V1 = 0 then
Encoding := CRTL.Unspecified;
elsif Formstr (V1 .. V2) = "utf8" then
Encoding := CRTL.UTF8;
elsif Formstr (V1 .. V2) = "8bits" then
Encoding := CRTL.ASCII_8bits;
else
raise Use_Error with "invalid Form";
end if;
if CRTL.mkdir (C_Dir_Name, Encoding) /= 0 then
raise Use_Error with
"creation of new directory """ & New_Directory & """ failed";
end if;
end;
end if;
end Create_Directory;
-----------------
-- Create_Path --
-----------------
procedure Create_Path
(New_Directory : String;
Form : String := "")
is
New_Dir : String (1 .. New_Directory'Length + 1);
Last : Positive := 1;
Start : Positive := 1;
begin
-- First, the invalid case
if not Is_Valid_Path_Name (New_Directory) then
raise Name_Error with
"invalid new directory path name """ & New_Directory & '"';
else
-- Build New_Dir with a directory separator at the end, so that the
-- complete path will be found in the loop below.
New_Dir (1 .. New_Directory'Length) := New_Directory;
New_Dir (New_Dir'Last) := Directory_Separator;
-- If host is windows, and the first two characters are directory
-- separators, we have an UNC path. Skip it.
if Directory_Separator = '\'
and then New_Dir'Length > 2
and then Is_In (New_Dir (1), Dir_Seps)
and then Is_In (New_Dir (2), Dir_Seps)
then
Start := 2;
loop
Start := Start + 1;
exit when Start = New_Dir'Last
or else Is_In (New_Dir (Start), Dir_Seps);
end loop;
end if;
-- Create, if necessary, each directory in the path
for J in Start + 1 .. New_Dir'Last loop
-- Look for the end of an intermediate directory
if not Is_In (New_Dir (J), Dir_Seps) then
Last := J;
-- We have found a new intermediate directory each time we find
-- a first directory separator.
elsif not Is_In (New_Dir (J - 1), Dir_Seps) then
-- No need to create the directory if it already exists
if not Is_Directory (New_Dir (1 .. Last)) then
begin
Create_Directory
(New_Directory => New_Dir (1 .. Last), Form => Form);
exception
when Use_Error =>
if File_Exists (New_Dir (1 .. Last)) then
-- A file with such a name already exists. If it is
-- a directory, then it was apparently just created
-- by another process or thread, and all is well.
-- If it is of some other kind, report an error.
if not Is_Directory (New_Dir (1 .. Last)) then
raise Use_Error with
"file """ & New_Dir (1 .. Last) &
""" already exists and is not a directory";
end if;
else
-- Create_Directory failed for some other reason:
-- propagate the exception.
raise;
end if;
end;
end if;
end if;
end loop;
end if;
end Create_Path;
-----------------------
-- Current_Directory --
-----------------------
function Current_Directory return String is
Path_Len : Natural := Max_Path;
Buffer : String (1 .. 1 + Max_Path + 1);
procedure Local_Get_Current_Dir (Dir : Address; Length : Address);
pragma Import (C, Local_Get_Current_Dir, "__gnat_get_current_dir");
begin
Local_Get_Current_Dir (Buffer'Address, Path_Len'Address);
-- We need to resolve links because of RM A.16(47), which requires
-- that we not return alternative names for files.
return Normalize_Pathname (Buffer (1 .. Path_Len));
end Current_Directory;
----------------------
-- Delete_Directory --
----------------------
procedure Delete_Directory (Directory : String) is
begin
-- First, the invalid cases
if not Is_Valid_Path_Name (Directory) then
raise Name_Error with
"invalid directory path name """ & Directory & '"';
elsif not Is_Directory (Directory) then
raise Name_Error with '"' & Directory & """ not a directory";
-- Do the deletion, checking for error
else
declare
C_Dir_Name : constant String := Directory & ASCII.NUL;
begin
if rmdir (C_Dir_Name) /= 0 then
raise Use_Error with
"deletion of directory """ & Directory & """ failed";
end if;
end;
end if;
end Delete_Directory;
-----------------
-- Delete_File --
-----------------
procedure Delete_File (Name : String) is
Success : Boolean;
begin
-- First, the invalid cases
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
elsif not Is_Regular_File (Name)
and then not Is_Symbolic_Link (Name)
then
raise Name_Error with "file """ & Name & """ does not exist";
else
-- Do actual deletion using System.OS_Lib.Delete_File
Delete_File (Name, Success);
if not Success then
raise Use_Error with "file """ & Name & """ could not be deleted";
end if;
end if;
end Delete_File;
-----------------
-- Delete_Tree --
-----------------
procedure Delete_Tree (Directory : String) is
Search : Search_Type;
Dir_Ent : Directory_Entry_Type;
begin
-- First, the invalid cases
if not Is_Valid_Path_Name (Directory) then
raise Name_Error with
"invalid directory path name """ & Directory & '"';
elsif not Is_Directory (Directory) then
raise Name_Error with '"' & Directory & """ not a directory";
else
-- We used to change the current directory to Directory here,
-- allowing the use of a local Simple_Name for all references. This
-- turned out unfriendly to multitasking programs, where tasks
-- running in parallel of this Delete_Tree could see their current
-- directory change unpredictably. We now resort to Full_Name
-- computations to reach files and subdirs instead.
Start_Search (Search, Directory => Directory, Pattern => "");
while More_Entries (Search) loop
Get_Next_Entry (Search, Dir_Ent);
declare
Fname : constant String := Full_Name (Dir_Ent);
Sname : constant String := Simple_Name (Dir_Ent);
begin
if OS_Lib.Is_Directory (Fname) then
if Sname /= "." and then Sname /= ".." then
Delete_Tree (Fname);
end if;
else
Delete_File (Fname);
end if;
end;
end loop;
End_Search (Search);
declare
C_Dir_Name : constant String := Directory & ASCII.NUL;
begin
if rmdir (C_Dir_Name) /= 0 then
raise Use_Error with
"directory tree rooted at """ &
Directory & """ could not be deleted";
end if;
end;
end if;
end Delete_Tree;
------------
-- Exists --
------------
function Exists (Name : String) return Boolean is
begin
-- First, the invalid case
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
else
-- The implementation is in File_Exists
return File_Exists (Name);
end if;
end Exists;
---------------
-- Extension --
---------------
function Extension (Name : String) return String is
begin
-- First, the invalid case
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
else
-- Look for first dot that is not followed by a directory separator
for Pos in reverse Name'Range loop
-- If a directory separator is found before a dot, there is no
-- extension.
if Is_In (Name (Pos), Dir_Seps) then
return Empty_String;
elsif Name (Pos) = '.' then
-- We found a dot, build the return value with lower bound 1
declare
subtype Result_Type is String (1 .. Name'Last - Pos);
begin
return Result_Type (Name (Pos + 1 .. Name'Last));
end;
end if;
end loop;
-- No dot were found, there is no extension
return Empty_String;
end if;
end Extension;
----------------------
-- Fetch_Next_Entry --
----------------------
procedure Fetch_Next_Entry (Search : Search_Type) is
Name : String (1 .. NAME_MAX);
Last : Natural;
Kind : File_Kind := Ordinary_File;
-- Initialized to avoid a compilation warning
Filename_Addr : Address;
Filename_Len : aliased Integer;
Buffer : array (1 .. SIZEOF_struct_dirent_alloc) of Character;
function readdir_gnat
(Directory : Address;
Buffer : Address;
Last : not null access Integer) return Address;
pragma Import (C, readdir_gnat, "__gnat_readdir");
begin
-- Search.Value.Is_Valid is always True when Fetch_Next_Entry is called
loop
Filename_Addr :=
readdir_gnat
(Address (Search.Value.Dir),
Buffer'Address,
Filename_Len'Access);
-- If no matching entry is found, set Is_Valid to False
if Filename_Addr = Null_Address then
Search.Value.Is_Valid := False;
exit;
end if;
if Filename_Len > Name'Length then
raise Use_Error with "file name too long";
end if;
declare
subtype Name_String is String (1 .. Filename_Len);
Dent_Name : Name_String;
for Dent_Name'Address use Filename_Addr;
pragma Import (Ada, Dent_Name);
begin
Last := Filename_Len;
Name (1 .. Last) := Dent_Name;
end;
-- Check if the entry matches the pattern
if Match (Name (1 .. Last), Search.Value.Pattern) then
declare
C_Full_Name : constant String :=
Compose (To_String (Search.Value.Name),
Name (1 .. Last)) & ASCII.NUL;
Full_Name : String renames
C_Full_Name
(C_Full_Name'First .. C_Full_Name'Last - 1);
Found : Boolean := False;
Attr : aliased File_Attributes;
Exists : Integer;
Error : Integer;
begin
Reset_Attributes (Attr'Access);
Exists := File_Exists_Attr (C_Full_Name'Address, Attr'Access);
Error := Error_Attributes (Attr'Access);
if Error /= 0 then
raise Use_Error
with Full_Name & ": " & Errno_Message (Err => Error);
end if;
if Exists = 1 then
-- Now check if the file kind matches the filter
if Is_Regular_File_Attr
(C_Full_Name'Address, Attr'Access) = 1
then
if Search.Value.Filter (Ordinary_File) then
Kind := Ordinary_File;
Found := True;
end if;
elsif Is_Directory_Attr
(C_Full_Name'Address, Attr'Access) = 1
then
if Search.Value.Filter (Directory) then
Kind := Directory;
Found := True;
end if;
elsif Search.Value.Filter (Special_File) then
Kind := Special_File;
Found := True;
end if;
-- If it does, update Search and return
if Found then
Search.Value.Entry_Fetched := True;
Search.Value.Dir_Entry :=
(Is_Valid => True,
Simple => To_Unbounded_String (Name (1 .. Last)),
Full => To_Unbounded_String (Full_Name),
Kind => Kind);
exit;
end if;
end if;
end;
end if;
end loop;
end Fetch_Next_Entry;
-----------------
-- File_Exists --
-----------------
function File_Exists (Name : String) return Boolean is
function C_File_Exists (A : Address) return Integer;
pragma Import (C, C_File_Exists, "__gnat_file_exists");
C_Name : String (1 .. Name'Length + 1);
begin
C_Name (1 .. Name'Length) := Name;
C_Name (C_Name'Last) := ASCII.NUL;
return C_File_Exists (C_Name'Address) = 1;
end File_Exists;
--------------
-- Finalize --
--------------
procedure Finalize (Search : in out Search_Type) is
begin
if Search.Value /= null then
-- Close the directory, if one is open
if Search.Value.Dir /= No_Dir then
Close (Search.Value.Dir);
end if;
Free (Search.Value);
end if;
end Finalize;
---------------
-- Full_Name --
---------------
function Full_Name (Name : String) return String is
begin
-- First, the invalid case
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
else
-- Build the return value with lower bound 1
-- Use System.OS_Lib.Normalize_Pathname
declare
-- We need to resolve links because of (RM A.16(47)), which says
-- we must not return alternative names for files.
Value : constant String := Normalize_Pathname (Name);
subtype Result is String (1 .. Value'Length);
begin
return Result (Value);
end;
end if;
end Full_Name;
function Full_Name (Directory_Entry : Directory_Entry_Type) return String is
begin
-- First, the invalid case
if not Directory_Entry.Is_Valid then
raise Status_Error with "invalid directory entry";
else
-- The value to return has already been computed
return To_String (Directory_Entry.Full);
end if;
end Full_Name;
--------------------
-- Get_Next_Entry --
--------------------
procedure Get_Next_Entry
(Search : in out Search_Type;
Directory_Entry : out Directory_Entry_Type)
is
begin
-- First, the invalid case
if Search.Value = null or else not Search.Value.Is_Valid then
raise Status_Error with "invalid search";
end if;
-- Fetch the next entry, if needed
if not Search.Value.Entry_Fetched then
Fetch_Next_Entry (Search);
end if;
-- It is an error if no valid entry is found
if not Search.Value.Is_Valid then
raise Status_Error with "no next entry";
else
-- Reset Entry_Fetched and return the entry
Search.Value.Entry_Fetched := False;
Directory_Entry := Search.Value.Dir_Entry;
end if;
end Get_Next_Entry;
----------
-- Kind --
----------
function Kind (Name : String) return File_Kind is
begin
-- First, the invalid case
if not File_Exists (Name) then
raise Name_Error with "file """ & Name & """ does not exist";
-- If OK, return appropriate kind
elsif Is_Regular_File (Name) then
return Ordinary_File;
elsif Is_Directory (Name) then
return Directory;
else
return Special_File;
end if;
end Kind;
function Kind (Directory_Entry : Directory_Entry_Type) return File_Kind is
begin
-- First, the invalid case
if not Directory_Entry.Is_Valid then
raise Status_Error with "invalid directory entry";
else
-- The value to return has already be computed
return Directory_Entry.Kind;
end if;
end Kind;
-----------------------
-- Modification_Time --
-----------------------
function Modification_Time (Name : String) return Time is
Date : OS_Time;
Year : Year_Type;
Month : Month_Type;
Day : Day_Type;
Hour : Hour_Type;
Minute : Minute_Type;
Second : Second_Type;
begin
-- First, the invalid cases
if not (Is_Regular_File (Name) or else Is_Directory (Name)) then
raise Name_Error with '"' & Name & """ not a file or directory";
else
Date := File_Time_Stamp (Name);
-- Break down the time stamp into its constituents relative to GMT.
-- This version of Split does not recognize leap seconds or buffer
-- space for time zone processing.
GM_Split (Date, Year, Month, Day, Hour, Minute, Second);
-- The result must be in GMT. Ada.Calendar.
-- Formatting.Time_Of with default time zone of zero (0) is the
-- routine of choice.
return Time_Of (Year, Month, Day, Hour, Minute, Second, 0.0);
end if;
end Modification_Time;
function Modification_Time
(Directory_Entry : Directory_Entry_Type) return Ada.Calendar.Time
is
begin
-- First, the invalid case
if not Directory_Entry.Is_Valid then
raise Status_Error with "invalid directory entry";
else
-- The value to return has already be computed
return Modification_Time (To_String (Directory_Entry.Full));
end if;
end Modification_Time;
------------------
-- More_Entries --
------------------
function More_Entries (Search : Search_Type) return Boolean is
begin
if Search.Value = null then
return False;
elsif Search.Value.Is_Valid then
-- Fetch the next entry, if needed
if not Search.Value.Entry_Fetched then
Fetch_Next_Entry (Search);
end if;
end if;
return Search.Value.Is_Valid;
end More_Entries;
------------
-- Rename --
------------
procedure Rename (Old_Name, New_Name : String) is
Success : Boolean;
begin
-- First, the invalid cases
if not Is_Valid_Path_Name (Old_Name) then
raise Name_Error with "invalid old path name """ & Old_Name & '"';
elsif not Is_Valid_Path_Name (New_Name) then
raise Name_Error with "invalid new path name """ & New_Name & '"';
elsif not Is_Regular_File (Old_Name)
and then not Is_Directory (Old_Name)
then
raise Name_Error with "old file """ & Old_Name & """ does not exist";
elsif Is_Regular_File (New_Name) or else Is_Directory (New_Name) then
raise Use_Error with
"new name """ & New_Name
& """ designates a file that already exists";
-- Do actual rename using System.OS_Lib.Rename_File
else
Rename_File (Old_Name, New_Name, Success);
if not Success then
-- AI05-0231-1: Name_Error should be raised in case a directory
-- component of New_Name does not exist (as in New_Name =>
-- "/no-such-dir/new-filename"). ENOENT indicates that. ENOENT
-- also indicate that the Old_Name does not exist, but we already
-- checked for that above. All other errors are Use_Error.
if Errno = ENOENT then
raise Name_Error with
"file """ & Containing_Directory (New_Name) & """ not found";
else
raise Use_Error with
"file """ & Old_Name & """ could not be renamed";
end if;
end if;
end if;
end Rename;
------------
-- Search --
------------
procedure Search
(Directory : String;
Pattern : String;
Filter : Filter_Type := (others => True);
Process : not null access procedure
(Directory_Entry : Directory_Entry_Type))
is
Srch : Search_Type;
Directory_Entry : Directory_Entry_Type;
begin
Start_Search (Srch, Directory, Pattern, Filter);
while More_Entries (Srch) loop
Get_Next_Entry (Srch, Directory_Entry);
Process (Directory_Entry);
end loop;
End_Search (Srch);
end Search;
-------------------
-- Set_Directory --
-------------------
procedure Set_Directory (Directory : String) is
C_Dir_Name : constant String := Directory & ASCII.NUL;
begin
if not Is_Valid_Path_Name (Directory) then
raise Name_Error with
"invalid directory path name & """ & Directory & '"';
elsif not Is_Directory (Directory) then
raise Name_Error with
"directory """ & Directory & """ does not exist";
elsif chdir (C_Dir_Name) /= 0 then
raise Name_Error with
"could not set to designated directory """ & Directory & '"';
end if;
end Set_Directory;
-----------------
-- Simple_Name --
-----------------
function Simple_Name (Name : String) return String is
function Simple_Name_Internal (Path : String) return String;
-- This function does the job
--------------------------
-- Simple_Name_Internal --
--------------------------
function Simple_Name_Internal (Path : String) return String is
Cut_Start : Natural :=
Strings.Fixed.Index (Path, Dir_Seps, Going => Strings.Backward);
Cut_End : Natural;
begin
-- Cut_Start pointS to the first simple name character
Cut_Start := (if Cut_Start = 0 then Path'First else Cut_Start + 1);
-- Cut_End point to the last simple name character
Cut_End := Path'Last;
Check_For_Standard_Dirs : declare
BN : constant String := Path (Cut_Start .. Cut_End);
Has_Drive_Letter : constant Boolean :=
OS_Lib.Path_Separator /= ':';
-- If Path separator is not ':' then we are on a DOS based OS
-- where this character is used as a drive letter separator.
begin
if BN = "." or else BN = ".." then
return "";
elsif Has_Drive_Letter
and then BN'Length > 2
and then Characters.Handling.Is_Letter (BN (BN'First))
and then BN (BN'First + 1) = ':'
then
-- We have a DOS drive letter prefix, remove it
return BN (BN'First + 2 .. BN'Last);
else
return BN;
end if;
end Check_For_Standard_Dirs;
end Simple_Name_Internal;
-- Start of processing for Simple_Name
begin
-- First, the invalid case
if not Is_Valid_Path_Name (Name) then
raise Name_Error with "invalid path name """ & Name & '"';
else
-- Build the value to return with lower bound 1
declare
Value : constant String := Simple_Name_Internal (Name);
subtype Result is String (1 .. Value'Length);
begin
return Result (Value);
end;
end if;
end Simple_Name;
function Simple_Name
(Directory_Entry : Directory_Entry_Type) return String is
begin
-- First, the invalid case
if not Directory_Entry.Is_Valid then
raise Status_Error with "invalid directory entry";
else
-- The value to return has already be computed
return To_String (Directory_Entry.Simple);
end if;
end Simple_Name;
----------
-- Size --
----------
function Size (Name : String) return File_Size is
C_Name : String (1 .. Name'Length + 1);
function C_Size (Name : Address) return int64;
pragma Import (C, C_Size, "__gnat_named_file_length");
begin
-- First, the invalid case
if not Is_Regular_File (Name) then
raise Name_Error with "file """ & Name & """ does not exist";
else
C_Name (1 .. Name'Length) := Name;
C_Name (C_Name'Last) := ASCII.NUL;
return File_Size (C_Size (C_Name'Address));
end if;
end Size;
function Size (Directory_Entry : Directory_Entry_Type) return File_Size is
begin
-- First, the invalid case
if not Directory_Entry.Is_Valid then
raise Status_Error with "invalid directory entry";
else
-- The value to return has already be computed
return Size (To_String (Directory_Entry.Full));
end if;
end Size;
------------------
-- Start_Search --
------------------
procedure Start_Search
(Search : in out Search_Type;
Directory : String;
Pattern : String;
Filter : Filter_Type := (others => True))
is
function opendir (file_name : String) return DIRs;
pragma Import (C, opendir, "__gnat_opendir");
C_File_Name : constant String := Directory & ASCII.NUL;
Pat : Regexp;
Dir : Dir_Type_Value;
begin
-- First, the invalid case Name_Error
if not Is_Directory (Directory) then
raise Name_Error with
"unknown directory """ & Simple_Name (Directory) & '"';
end if;
-- Check the pattern
begin
Pat := Compile
(Pattern,
Glob => True,
Case_Sensitive => Is_Path_Name_Case_Sensitive);
exception
when Error_In_Regexp =>
Free (Search.Value);
raise Name_Error with "invalid pattern """ & Pattern & '"';
end;
Dir := Dir_Type_Value (opendir (C_File_Name));
if Dir = No_Dir then
raise Use_Error with
"unreadable directory """ & Simple_Name (Directory) & '"';
end if;
-- If needed, finalize Search
Finalize (Search);
-- Allocate the default data
Search.Value := new Search_Data;
-- Initialize some Search components
Search.Value.Filter := Filter;
Search.Value.Name := To_Unbounded_String (Full_Name (Directory));
Search.Value.Pattern := Pat;
Search.Value.Dir := Dir;
Search.Value.Is_Valid := True;
end Start_Search;
end Ada.Directories;
|
-----------------------------------------------------------------------
-- Atlas-server -- Application server
-- Copyright (C) 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Exceptions;
with Util.Log.Loggers;
with ASF.Server.Web;
with Atlas.Applications;
procedure Atlas.Server is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Atlas.Server");
App : constant Atlas.Applications.Application_Access := new Atlas.Applications.Application;
WS : ASF.Server.Web.AWS_Container;
begin
Atlas.Applications.Initialize (App);
WS.Register_Application (Atlas.Applications.CONTEXT_PATH, App.all'Access);
Log.Info ("Connect you browser to: http://localhost:8080/atlas/index.html");
WS.Start;
delay 365.0 * 24.0 * 3600.0;
App.Close;
exception
when E : others =>
Log.Error ("Exception in server: " &
Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
end Atlas.Server;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . S E Q U E N T I A L _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with System.File_IO;
with Unchecked_Deallocation;
package body System.Sequential_IO is
subtype AP is FCB.AFCB_Ptr;
package FIO renames System.File_IO;
-------------------
-- AFCB_Allocate --
-------------------
function AFCB_Allocate
(Control_Block : Sequential_AFCB) return FCB.AFCB_Ptr
is
pragma Warnings (Off, Control_Block);
begin
return new Sequential_AFCB;
end AFCB_Allocate;
----------------
-- AFCB_Close --
----------------
-- No special processing required for Sequential_IO close
procedure AFCB_Close (File : access Sequential_AFCB) is
pragma Warnings (Off, File);
begin
null;
end AFCB_Close;
---------------
-- AFCB_Free --
---------------
procedure AFCB_Free (File : access Sequential_AFCB) is
type FCB_Ptr is access all Sequential_AFCB;
FT : FCB_Ptr := FCB_Ptr (File);
procedure Free is new
Unchecked_Deallocation (Sequential_AFCB, FCB_Ptr);
begin
Free (FT);
end AFCB_Free;
------------
-- Create --
------------
procedure Create
(File : in out File_Type;
Mode : FCB.File_Mode := FCB.Out_File;
Name : String := "";
Form : String := "")
is
Dummy_File_Control_Block : Sequential_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
-- Yes, we know this is never assigned a value, only the tag
-- is used for dispatching purposes, so that's expected.
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => Dummy_File_Control_Block,
Mode => Mode,
Name => Name,
Form => Form,
Amethod => 'Q',
Creat => True,
Text => False);
end Create;
----------
-- Open --
----------
procedure Open
(File : in out File_Type;
Mode : FCB.File_Mode;
Name : String;
Form : String := "")
is
Dummy_File_Control_Block : Sequential_AFCB;
pragma Warnings (Off, Dummy_File_Control_Block);
-- Yes, we know this is never assigned a value, only the tag
-- is used for dispatching purposes, so that's expected.
begin
FIO.Open (File_Ptr => AP (File),
Dummy_FCB => Dummy_File_Control_Block,
Mode => Mode,
Name => Name,
Form => Form,
Amethod => 'Q',
Creat => False,
Text => False);
end Open;
----------
-- Read --
----------
-- Not used, since Sequential_IO files are not used as streams
procedure Read
(File : in out Sequential_AFCB;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
begin
raise Program_Error;
end Read;
-----------
-- Write --
-----------
-- Not used, since Sequential_IO files are not used as streams
procedure Write
(File : in out Sequential_AFCB;
Item : Ada.Streams.Stream_Element_Array)
is
begin
raise Program_Error;
end Write;
end System.Sequential_IO;
|
-----------------------------------------------------------------------
-- awa-mail-components-recipients -- Mail UI Recipients
-- Copyright (C) 2012, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with ASF.Contexts.Faces;
-- === Mail Messages ===
-- The `AWA.Mail.Components.Messages` package defines the UI components
-- to represent the email message with its recipients, subject and body.
--
-- The mail message is retrieved by looking at the parent UI component until a
-- `UIMailMessage` component is found. The mail message recipients are initialized
-- during the render response JSF phase, that is when `Encode_End` are called.
--
-- The `<mail:body>` component holds the message body. This component can
-- include a facelet labeled `alternative` in which case it will be used
-- to build the `text/plain` mail message. The default content type for
-- `<mail:body>` is `text/html` but this can be changed by using the
-- `type` attribute.
--
-- <mail:body type='text/html'>
-- <facet name='alternative'>
-- The text/plain mail message.
-- </facet>
-- The text/html mail message.
-- </mail:body>
package AWA.Mail.Components.Messages is
ALTERNATIVE_NAME : constant String := "alternative";
-- ------------------------------
-- The mail recipient
-- ------------------------------
type UIMailMessage is new UIMailComponent with private;
type UIMailMessage_Access is access all UIMailMessage'Class;
-- Set the mail message instance.
procedure Set_Message (UI : in out UIMailMessage;
Message : in AWA.Mail.Clients.Mail_Message_Access);
-- Get the mail message instance.
overriding
function Get_Message (UI : in UIMailMessage) return AWA.Mail.Clients.Mail_Message_Access;
-- Send the mail.
overriding
procedure Encode_End (UI : in UIMailMessage;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Finalize and release the mail message.
overriding
procedure Finalize (UI : in out UIMailMessage);
-- ------------------------------
-- The mail subject
-- ------------------------------
type UIMailSubject is new UIMailComponent with private;
-- Render the mail subject and initializes the message with its content.
overriding
procedure Encode_Children (UI : in UIMailSubject;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- ------------------------------
-- The mail body
-- ------------------------------
type UIMailBody is new UIMailComponent with private;
-- Render the mail body and initializes the message with its content.
overriding
procedure Encode_Children (UI : in UIMailBody;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
private
type UIMailMessage is new UIMailComponent with record
Message : AWA.Mail.Clients.Mail_Message_Access;
end record;
type UIMailBody is new UIMailComponent with null record;
type UIMailSubject is new UIMailComponent with null record;
end AWA.Mail.Components.Messages;
|
package LV_Conf is
LV_DPI : constant := 100;
LV_HOR_RES : constant := 800;
LV_VER_RES : constant := 480;
end LV_Conf;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A U N I T . R E P O R T E R . T E X T --
-- --
-- B o d y --
-- --
-- --
-- Copyright (C) 2000-2013, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- 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 is maintained by AdaCore (http://www.adacore.com) --
-- --
------------------------------------------------------------------------------
with GNAT.IO; use GNAT.IO;
with AUnit.Time_Measure; use AUnit.Time_Measure;
-- Very simple reporter to console
package body AUnit.Reporter.Text is
procedure Indent (N : Natural);
-- Print N indentations to output
procedure Dump_Result_List (L : Result_Lists.List; Prefix : String);
-- Dump a result list
procedure Put_Measure is new Gen_Put_Measure;
-- Output elapsed time
procedure Report_Test (Test : Test_Result; Prefix : String);
-- Report a single assertion failure or unexpected exception
generic
with procedure Get (R : in out Result; L : in out Result_Lists.List);
Label : String;
Color : String;
procedure Report_Tests
(Engine : Text_Reporter;
R : in out Result'Class);
-- Report a series of tests
ANSI_Def : constant String := ASCII.ESC & "[0m";
ANSI_Green : constant String := ASCII.ESC & "[32m";
ANSI_Purple : constant String := ASCII.ESC & "[35m";
ANSI_Red : constant String := ASCII.ESC & "[31m";
-------------------------
-- Set_Use_ANSI_Colors --
-------------------------
procedure Set_Use_ANSI_Colors
(Engine : in out Text_Reporter;
Value : Boolean) is
begin
Engine.Use_ANSI := Value;
end Set_Use_ANSI_Colors;
------------
-- Indent --
------------
procedure Indent (N : Natural) is
begin
for J in 1 .. N loop
Put (" ");
end loop;
end Indent;
----------------------
-- Dump_Result_List --
----------------------
procedure Dump_Result_List (L : Result_Lists.List; Prefix : String) is
use Result_Lists;
C : Cursor := First (L);
begin
if Has_Element (C) then
New_Line;
end if;
-- Note: can't use Iterate because it violates restriction
-- No_Implicit_Dynamic_Code
while Has_Element (C) loop
Report_Test (Element (C), Prefix);
Next (C);
end loop;
end Dump_Result_List;
---------
-- Get --
---------
procedure Report_Tests
(Engine : Text_Reporter;
R : in out Result'Class)
is
S : Result_Lists.List;
begin
Get (Result (R), S);
if Engine.Use_ANSI then
Put (Color);
end if;
Dump_Result_List (S, Label);
if Engine.Use_ANSI then
Put (ANSI_Def);
end if;
end Report_Tests;
---------------------
-- Report_OK_Tests --
---------------------
procedure Report_OK_Tests
(Engine : Text_Reporter;
R : in out Result'Class)
is
procedure Internal is new Report_Tests (Successes, "OK", ANSI_Green);
begin
Internal (Engine, R);
end Report_OK_Tests;
procedure Report_Fail_Tests
(Engine : Text_Reporter;
R : in out Result'Class)
is
procedure Internal is new Report_Tests (Failures, "FAIL", ANSI_Purple);
begin
Internal (Engine, R);
end Report_Fail_Tests;
procedure Report_Error_Tests
(Engine : Text_Reporter;
R : in out Result'Class)
is
procedure Internal is new Report_Tests (Errors, "ERROR", ANSI_Red);
begin
Internal (Engine, R);
end Report_Error_Tests;
------------
-- Report --
------------
procedure Report
(Engine : Text_Reporter;
R : in out Result'Class;
Options : AUnit_Options := Default_Options)
is
S_Count : constant Integer := Integer (Success_Count (R));
F_Count : constant Integer := Integer (Failure_Count (R));
E_Count : constant Integer := Integer (Error_Count (R));
T : AUnit_Duration;
begin
if Options.Report_Successes then
Report_OK_Tests (Text_Reporter'Class (Engine), R);
end if;
Report_Fail_Tests (Text_Reporter'Class (Engine), R);
Report_Error_Tests (Text_Reporter'Class (Engine), R);
New_Line;
Put ("Total Tests Run: ");
Put (Integer (Test_Count (R)));
New_Line;
Put ("Successful Tests: ");
Put (S_Count);
New_Line;
Put ("Failed Assertions: ");
Put (F_Count);
New_Line;
Put ("Unexpected Errors: ");
Put (E_Count);
New_Line;
if Elapsed (R) /= Time_Measure.Null_Time then
T := Get_Measure (Elapsed (R));
Put ("Cumulative Time: ");
Put_Measure (T);
Put_Line (" seconds");
end if;
end Report;
-----------------
-- Report_Test --
-----------------
procedure Report_Test (Test : Test_Result; Prefix : String) is
T : AUnit_Duration;
begin
Put (Prefix);
Put (" ");
Put (Test.Test_Name.all);
if Test.Routine_Name /= null then
Put (" : ");
Put (Test.Routine_Name.all);
end if;
if Test.Elapsed /= Time_Measure.Null_Time then
Put (" (in ");
T := Get_Measure (Test.Elapsed);
Put_Measure (T);
Put (")");
end if;
New_Line;
if Test.Failure /= null then
Indent (1);
Put_Line (Test.Failure.Message.all);
Indent (1);
Put ("at ");
Put (Test.Failure.Source_Name.all);
Put (":");
Put (Test.Failure.Line);
New_Line;
elsif Test.Error /= null then
Indent (1);
Put_Line (Test.Error.Exception_Name.all);
if Test.Error.Exception_Message /= null then
Indent (1);
Put ("Exception Message: ");
Put_Line (Test.Error.Exception_Message.all);
end if;
if Test.Error.Traceback /= null then
Indent (1);
Put_Line ("Traceback:");
declare
From, To : Natural := Test.Error.Traceback'First;
begin
while From <= Test.Error.Traceback'Last loop
To := From;
while To <= Test.Error.Traceback'Last
and then Test.Error.Traceback (To) /= ASCII.LF
loop
To := To + 1;
end loop;
Indent (2);
Put_Line (Test.Error.Traceback (From .. To - 1));
From := To + 1;
end loop;
end;
end if;
New_Line;
end if;
end Report_Test;
end AUnit.Reporter.Text;
|
pragma License (Unrestricted);
-- implementation unit specialized for POSIX (Darwin, FreeBSD, or Linux)
with Ada.IO_Exceptions;
with Ada.IO_Modes;
with Ada.Streams;
with System.Native_IO;
with C.termios;
package System.Native_Text_IO is
pragma Preelaborate;
subtype Handle_Type is Native_IO.Handle_Type;
-- file management
Default_External : constant Ada.IO_Modes.File_External :=
Ada.IO_Modes.UTF_8;
Default_New_Line : constant Ada.IO_Modes.File_New_Line :=
Ada.IO_Modes.LF;
type Packed_Form is record
Stream_Form : Native_IO.Packed_Form;
External : Ada.IO_Modes.File_External_Spec;
New_Line : Ada.IO_Modes.File_New_Line_Spec;
end record;
pragma Suppress_Initialization (Packed_Form);
pragma Pack (Packed_Form);
-- read / write
subtype Buffer_Type is String (1 .. 6); -- one code-point of UTF-8
subtype DBCS_Buffer_Type is String (1 .. 6); -- unused
procedure To_UTF_8 (
Buffer : aliased DBCS_Buffer_Type;
Last : Natural;
Out_Buffer : out Buffer_Type;
Out_Last : out Natural)
with Import, Convention => Ada, External_Name => "__drake_program_error";
procedure To_DBCS (
Buffer : Buffer_Type;
Last : Natural;
Out_Buffer : aliased out DBCS_Buffer_Type;
Out_Last : out Natural)
with Import, Convention => Ada, External_Name => "__drake_program_error";
procedure Write_Just (
Handle : Handle_Type;
Item : String);
-- terminal
procedure Terminal_Get (
Handle : Handle_Type;
Item : Address;
Length : Ada.Streams.Stream_Element_Offset;
Out_Length : out Ada.Streams.Stream_Element_Offset) -- -1 when error
renames Native_IO.Read;
procedure Terminal_Get_Immediate (
Handle : Handle_Type;
Item : Address;
Length : Ada.Streams.Stream_Element_Offset;
Out_Length : out Ada.Streams.Stream_Element_Offset) -- -1 when error
renames Native_IO.Read;
procedure Terminal_Put (
Handle : Handle_Type;
Item : Address;
Length : Ada.Streams.Stream_Element_Offset;
Out_Length : out Ada.Streams.Stream_Element_Offset) -- -1 when error
renames Native_IO.Write;
procedure Terminal_Size (
Handle : Handle_Type;
Line_Length, Page_Length : out Natural);
procedure Set_Terminal_Size (
Handle : Handle_Type;
Line_Length, Page_Length : Natural);
procedure Terminal_View (
Handle : Handle_Type;
Left, Top : out Positive;
Right, Bottom : out Natural);
function Use_Terminal_Position (Handle : Handle_Type) return Boolean;
procedure Terminal_Position (
Handle : Handle_Type;
Col, Line : out Positive);
procedure Set_Terminal_Position (
Handle : Handle_Type;
Col, Line : Positive);
procedure Set_Terminal_Col (
Handle : Handle_Type;
To : Positive);
procedure Terminal_Clear (
Handle : Handle_Type);
subtype Setting is C.termios.struct_termios;
procedure Set_Non_Canonical_Mode (
Handle : Handle_Type;
Wait : Boolean;
Saved_Settings : aliased out Setting);
procedure Restore (
Handle : Handle_Type;
Settings : aliased Setting);
subtype Output_State is Natural; -- stacking count
procedure Save_State (Handle : Handle_Type; To_State : out Output_State);
procedure Reset_State (Handle : Handle_Type; From_State : Output_State);
-- exceptions
Status_Error : exception
renames Ada.IO_Exceptions.Status_Error;
Device_Error : exception
renames Ada.IO_Exceptions.Device_Error;
Data_Error : exception
renames Ada.IO_Exceptions.Data_Error;
end System.Native_Text_IO;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
package body Tabula.Casts.Cast_IO is
procedure IO_Partial (
Serializer : not null access Serialization.Serializer;
Item : in out Person'Class)
is
use Serialization;
use Person_Sex_IO;
begin
IO (Serializer, "name", Item.Name);
IO (Serializer, "work", Item.Work);
IO (Serializer, "image", Item.Image);
IO (Serializer, "sex", Item.Sex);
IO (Serializer, "group", Item.Group);
end IO_Partial;
use Groups;
package Groups_IO is
new Serialization.IO_List (
Cursor => Groups.Cursor,
Element_Type => Group,
Container_Type => Groups.Vector,
Reference_Type => Groups.Reference_Type,
Default => Empty_Group,
Next => Groups.Cursor'Succ);
use People;
package People_IO is
new Serialization.IO_List (
Cursor => People.Cursor,
Element_Type => Person,
Container_Type => People.Vector,
Reference_Type => People.Reference_Type,
Default => Empty_Person,
Has_Element => People.Has_Element,
Next => People.Cursor'Succ);
use Works;
package Works_IO is
new Serialization.IO_List (
Cursor => Works.Cursor,
Element_Type => Work,
Container_Type => Works.Vector,
Reference_Type => Works.Reference_Type,
Default => Empty_Work,
Has_Element => Works.Has_Element,
Next => Works.Cursor'Succ);
procedure IO (
Serializer : not null access Serialization.Serializer;
Item : in out Cast_Collection)
is
use Serialization;
use Neutralable_Sex_IO;
use Groups_IO;
use People_IO;
use Works_IO;
procedure Groups_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Group) is
begin
for P in IO (Serializer) loop
IO (Serializer, "name", Item.Name);
IO (Serializer, "by", Item.By);
IO (Serializer, "width", Item.Width);
IO (Serializer, "height", Item.Height);
IO (Serializer, "group", Item.Group);
end loop;
end Groups_Callback;
procedure People_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Person) is
begin
for P in IO (Serializer) loop
IO_Partial (Serializer, Item);
end loop;
end People_Callback;
procedure Works_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Work) is
begin
for P in IO (Serializer) loop
IO (Serializer, "name", Item.Name);
IO (Serializer, "sex", Item.Sex);
IO (Serializer, "nominated", Item.Nominated);
end loop;
end Works_Callback;
begin
for P in IO (Serializer) loop
IO (Serializer, "groups", Item.Groups, Groups_Callback'Access);
IO (Serializer, "people", Item.People, People_Callback'Access);
IO (Serializer, "works", Item.Works, Works_Callback'Access);
end loop;
end IO;
end Tabula.Casts.Cast_IO;
|
pragma License (Unrestricted);
-- implementation unit specialized for Darwin (or Linux, or Windows)
with System.Long_Long_Complex_Types;
package System.Long_Long_Complex_Elementary_Functions is
pragma Pure;
-- Complex
subtype Imaginary is Long_Long_Complex_Types.Imaginary;
subtype Complex is Long_Long_Complex_Types.Complex;
function clogf (x : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_clogf";
function Fast_Log (X : Complex) return Complex
renames clogf;
function cexpf (x : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cexpf";
function Fast_Exp (X : Complex) return Complex
renames cexpf;
function cexpif (x : Imaginary) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cexpif";
function Fast_Exp (X : Imaginary) return Complex
renames cexpif;
function cpowf (x, y : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cpowf";
function Fast_Pow (Left, Right : Complex) return Complex
renames cpowf;
function csinf (x : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_csinf";
function Fast_Sin (X : Complex) return Complex
renames csinf;
function ccosf (x : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ccosf";
function Fast_Cos (X : Complex) return Complex
renames ccosf;
function ctanf (x : Complex) return Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ctanf";
function Fast_Tan (X : Complex) return Complex
renames ctanf;
function casinf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_casinf";
function Fast_Arcsin (X : Complex) return Complex
renames casinf;
function cacosf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cacosf";
function Fast_Arccos (X : Complex) return Complex
renames cacosf;
function catanf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_catanf";
function Fast_Arctan (X : Complex) return Complex
renames catanf;
function csinhf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_csinhf";
function Fast_Sinh (X : Complex) return Complex
renames csinhf;
function ccoshf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_ccoshf";
function Fast_Cosh (X : Complex) return Complex
renames ccoshf;
function ctanhf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_ctanhf";
function Fast_Tanh (X : Complex) return Complex
renames ctanhf;
function casinhf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_casinhf";
function Fast_Arcsinh (X : Complex) return Complex
renames casinhf;
function cacoshf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cacoshf";
function Fast_Arccosh (X : Complex) return Complex
renames cacoshf;
function catanhf (x : Complex) return Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_catanhf";
function Fast_Arctanh (X : Complex) return Complex
renames catanhf;
-- Long_Complex
subtype Long_Imaginary is Long_Long_Complex_Types.Long_Imaginary;
subtype Long_Complex is Long_Long_Complex_Types.Long_Complex;
function clog (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_clog";
function Fast_Log (X : Long_Complex) return Long_Complex
renames clog;
function cexp (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cexp";
function Fast_Exp (X : Long_Complex) return Long_Complex
renames cexp;
function cexpi (x : Long_Imaginary) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cexpi";
function Fast_Exp (X : Long_Imaginary) return Long_Complex
renames cexpi;
function cpow (x, y : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cpow";
function Fast_Pow (Left, Right : Long_Complex) return Long_Complex
renames cpow;
function csin (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_csin";
function Fast_Sin (X : Long_Complex) return Long_Complex
renames csin;
function ccos (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ccos";
function Fast_Cos (X : Long_Complex) return Long_Complex
renames ccos;
function ctan (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ctan";
function Fast_Tan (X : Long_Complex) return Long_Complex
renames ctan;
function casin (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_casin";
function Fast_Arcsin (X : Long_Complex) return Long_Complex
renames casin;
function cacos (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cacos";
function Fast_Arccos (X : Long_Complex) return Long_Complex
renames cacos;
function catan (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_catan";
function Fast_Arctan (X : Long_Complex) return Long_Complex
renames catan;
function csinh (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_csinh";
function Fast_Sinh (X : Long_Complex) return Long_Complex
renames csinh;
function ccosh (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ccosh";
function Fast_Cosh (X : Long_Complex) return Long_Complex
renames ccosh;
function ctanh (x : Long_Complex) return Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ctanh";
function Fast_Tanh (X : Long_Complex) return Long_Complex
renames ctanh;
function casinh (x : Long_Complex) return Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_casinh";
function Fast_Arcsinh (X : Long_Complex) return Long_Complex
renames casinh;
function cacosh (x : Long_Complex) return Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cacosh";
function Fast_Arccosh (X : Long_Complex) return Long_Complex
renames cacosh;
function catanh (x : Long_Complex) return Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_catanh";
function Fast_Arctanh (X : Long_Complex) return Long_Complex
renames catanh;
-- Long_Long_Complex
subtype Long_Long_Imaginary is Long_Long_Complex_Types.Long_Long_Imaginary;
subtype Long_Long_Complex is Long_Long_Complex_Types.Long_Long_Complex;
function clogl (x : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_clogl";
function Fast_Log (X : Long_Long_Complex) return Long_Long_Complex
renames clogl;
function cexpl (x : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cexpl";
function Fast_Exp (X : Long_Long_Complex) return Long_Long_Complex
renames cexpl;
function cexpil (x : Long_Long_Imaginary) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cexpil";
function Fast_Exp (X : Long_Long_Imaginary) return Long_Long_Complex
renames cexpil;
function cpowl (x, y : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_cpowl";
function Fast_Pow (Left, Right : Long_Long_Complex) return Long_Long_Complex
renames cpowl;
function csinl (x : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_csinl";
function Fast_Sin (X : Long_Long_Complex) return Long_Long_Complex
renames csinl;
function ccosl (x : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ccosl";
function Fast_Cos (X : Long_Long_Complex) return Long_Long_Complex
renames ccosl;
function ctanl (x : Long_Long_Complex) return Long_Long_Complex
with Import, Convention => Intrinsic, External_Name => "__builtin_ctanl";
function Fast_Tan (X : Long_Long_Complex) return Long_Long_Complex
renames ctanl;
function casinl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_casinl";
function Fast_Arcsin (X : Long_Long_Complex) return Long_Long_Complex
renames casinl;
function cacosl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cacosl";
function Fast_Arccos (X : Long_Long_Complex) return Long_Long_Complex
renames cacosl;
function catanl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_catanl";
function Fast_Arctan (X : Long_Long_Complex) return Long_Long_Complex
renames catanl;
function csinhl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_csinhl";
function Fast_Sinh (X : Long_Long_Complex) return Long_Long_Complex
renames csinhl;
function ccoshl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_ccoshl";
function Fast_Cosh (X : Long_Long_Complex) return Long_Long_Complex
renames ccoshl;
function ctanhl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_ctanhl";
function Fast_Tanh (X : Long_Long_Complex) return Long_Long_Complex
renames ctanhl;
function casinhl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_casinhl";
function Fast_Arcsinh (X : Long_Long_Complex) return Long_Long_Complex
renames casinhl;
function cacoshl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_cacoshl";
function Fast_Arccosh (X : Long_Long_Complex) return Long_Long_Complex
renames cacoshl;
function catanhl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_catanhl";
function Fast_Arctanh (X : Long_Long_Complex) return Long_Long_Complex
renames catanhl;
end System.Long_Long_Complex_Elementary_Functions;
|
package Generator.Filtered is
type Filtered_Generator is new Generator with private;
procedure Reset (Gen : in out Filtered_Generator);
function Get_Next (Gen : access Filtered_Generator) return Natural;
procedure Set_Source (Gen : in out Filtered_Generator;
Source : access Generator);
procedure Set_Filter (Gen : in out Filtered_Generator;
Filter : access Generator);
private
type Filtered_Generator is new Generator with record
Last_Filter : Natural := 0;
Source, Filter : access Generator;
end record;
end Generator.Filtered;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . P A R T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Err_Vars; use Err_Vars;
with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Prj.Com; use Prj.Com;
with Prj.Dect;
with Prj.Err; use Prj.Err;
with Prj.Ext; use Prj.Ext;
with Sinput; use Sinput;
with Sinput.P; use Sinput.P;
with Snames;
with Table;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Exceptions; use Ada.Exceptions;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with System.HTable; use System.HTable;
package body Prj.Part is
Buffer : String_Access;
Buffer_Last : Natural := 0;
Dir_Sep : Character renames GNAT.OS_Lib.Directory_Separator;
type Extension_Origin is (None, Extending_Simple, Extending_All);
-- Type of parameter From_Extended for procedures Parse_Single_Project and
-- Post_Parse_Context_Clause. Extending_All means that we are parsing the
-- tree rooted at an extending all project.
------------------------------------
-- Local Packages and Subprograms --
------------------------------------
type With_Id is new Nat;
No_With : constant With_Id := 0;
type With_Record is record
Path : Name_Id;
Location : Source_Ptr;
Limited_With : Boolean;
Node : Project_Node_Id;
Next : With_Id;
end record;
-- Information about an imported project, to be put in table Withs below
package Withs is new Table.Table
(Table_Component_Type => With_Record,
Table_Index_Type => With_Id,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 50,
Table_Name => "Prj.Part.Withs");
-- Table used to store temporarily paths and locations of imported
-- projects. These imported projects will be effectively parsed after the
-- name of the current project has been extablished.
type Names_And_Id is record
Path_Name : Name_Id;
Canonical_Path_Name : Name_Id;
Id : Project_Node_Id;
end record;
package Project_Stack is new Table.Table
(Table_Component_Type => Names_And_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 50,
Table_Name => "Prj.Part.Project_Stack");
-- This table is used to detect circular dependencies
-- for imported and extended projects and to get the project ids of
-- limited imported projects when there is a circularity with at least
-- one limited imported project file.
package Virtual_Hash is new System.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Project_Node_Id,
No_Element => Empty_Node,
Key => Project_Node_Id,
Hash => Prj.Tree.Hash,
Equal => "=");
-- Hash table to store the node id of the project for which a virtual
-- extending project need to be created.
package Processed_Hash is new System.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Boolean,
No_Element => False,
Key => Project_Node_Id,
Hash => Prj.Tree.Hash,
Equal => "=");
-- Hash table to store the project process when looking for project that
-- need to have a virtual extending project, to avoid processing the same
-- project twice.
procedure Create_Virtual_Extending_Project
(For_Project : Project_Node_Id;
Main_Project : Project_Node_Id;
In_Tree : Project_Node_Tree_Ref);
-- Create a virtual extending project of For_Project. Main_Project is
-- the extending all project.
--
-- The String_Value_Of is not set for the automatically added with
-- clause and keeps the default value of No_Name. This enables Prj.PP
-- to skip these automatically added with clauses to be processed.
procedure Look_For_Virtual_Projects_For
(Proj : Project_Node_Id;
In_Tree : Project_Node_Tree_Ref;
Potentially_Virtual : Boolean);
-- Look for projects that need to have a virtual extending project.
-- This procedure is recursive. If called with Potentially_Virtual set to
-- True, then Proj may need an virtual extending project; otherwise it
-- does not (because it is already extended), but other projects that it
-- imports may need to be virtually extended.
procedure Pre_Parse_Context_Clause
(In_Tree : Project_Node_Tree_Ref;
Context_Clause : out With_Id);
-- Parse the context clause of a project.
-- Store the paths and locations of the imported projects in table Withs.
-- Does nothing if there is no context clause (if the current
-- token is not "with" or "limited" followed by "with").
procedure Post_Parse_Context_Clause
(Context_Clause : With_Id;
In_Tree : Project_Node_Tree_Ref;
Imported_Projects : out Project_Node_Id;
Project_Directory : Name_Id;
From_Extended : Extension_Origin;
In_Limited : Boolean;
Packages_To_Check : String_List_Access);
-- Parse the imported projects that have been stored in table Withs,
-- if any. From_Extended is used for the call to Parse_Single_Project
-- below. When In_Limited is True, the importing path includes at least
-- one "limited with".
procedure Parse_Single_Project
(In_Tree : Project_Node_Tree_Ref;
Project : out Project_Node_Id;
Extends_All : out Boolean;
Path_Name : String;
Extended : Boolean;
From_Extended : Extension_Origin;
In_Limited : Boolean;
Packages_To_Check : String_List_Access);
-- Parse a project file.
-- Recursive procedure: it calls itself for imported and extended
-- projects. When From_Extended is not None, if the project has already
-- been parsed and is an extended project A, return the ultimate
-- (not extended) project that extends A. When In_Limited is True,
-- the importing path includes at least one "limited with".
function Project_Path_Name_Of
(Project_File_Name : String;
Directory : String) return String;
-- Returns the path name of a project file. Returns an empty string
-- if project file cannot be found.
function Immediate_Directory_Of (Path_Name : Name_Id) return Name_Id;
-- Get the directory of the file with the specified path name.
-- This includes the directory separator as the last character.
-- Returns "./" if Path_Name contains no directory separator.
function Project_Name_From (Path_Name : String) return Name_Id;
-- Returns the name of the project that corresponds to its path name.
-- Returns No_Name if the path name is invalid, because the corresponding
-- project name does not have the syntax of an ada identifier.
--------------------------------------
-- Create_Virtual_Extending_Project --
--------------------------------------
procedure Create_Virtual_Extending_Project
(For_Project : Project_Node_Id;
Main_Project : Project_Node_Id;
In_Tree : Project_Node_Tree_Ref)
is
Virtual_Name : constant String :=
Virtual_Prefix &
Get_Name_String (Name_Of (For_Project, In_Tree));
-- The name of the virtual extending project
Virtual_Name_Id : Name_Id;
-- Virtual extending project name id
Virtual_Path_Id : Name_Id;
-- Fake path name of the virtual extending project. The directory is
-- the same directory as the extending all project.
Virtual_Dir_Id : constant Name_Id :=
Immediate_Directory_Of (Path_Name_Of (Main_Project, In_Tree));
-- The directory of the extending all project
-- The source of the virtual extending project is something like:
-- project V$<project name> extends <project path> is
-- for Source_Dirs use ();
-- end V$<project name>;
-- The project directory cannot be specified during parsing; it will be
-- put directly in the virtual extending project data during processing.
-- Nodes that made up the virtual extending project
Virtual_Project : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Project);
With_Clause : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_With_Clause);
Project_Declaration : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Project_Declaration);
Source_Dirs_Declaration : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Declarative_Item);
Source_Dirs_Attribute : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Attribute_Declaration, List);
Source_Dirs_Expression : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Expression, List);
Source_Dirs_Term : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Term, List);
Source_Dirs_List : constant Project_Node_Id :=
Default_Project_Node
(In_Tree, N_Literal_String_List, List);
begin
-- Get the virtual name id
Name_Len := Virtual_Name'Length;
Name_Buffer (1 .. Name_Len) := Virtual_Name;
Virtual_Name_Id := Name_Find;
-- Get the virtual path name
Get_Name_String (Path_Name_Of (Main_Project, In_Tree));
while Name_Len > 0
and then Name_Buffer (Name_Len) /= Directory_Separator
and then Name_Buffer (Name_Len) /= '/'
loop
Name_Len := Name_Len - 1;
end loop;
Name_Buffer (Name_Len + 1 .. Name_Len + Virtual_Name'Length) :=
Virtual_Name;
Name_Len := Name_Len + Virtual_Name'Length;
Virtual_Path_Id := Name_Find;
-- With clause
Set_Name_Of (With_Clause, In_Tree, Virtual_Name_Id);
Set_Path_Name_Of (With_Clause, In_Tree, Virtual_Path_Id);
Set_Project_Node_Of (With_Clause, In_Tree, Virtual_Project);
Set_Next_With_Clause_Of
(With_Clause, In_Tree, First_With_Clause_Of (Main_Project, In_Tree));
Set_First_With_Clause_Of (Main_Project, In_Tree, With_Clause);
-- Virtual project node
Set_Name_Of (Virtual_Project, In_Tree, Virtual_Name_Id);
Set_Path_Name_Of (Virtual_Project, In_Tree, Virtual_Path_Id);
Set_Location_Of
(Virtual_Project, In_Tree, Location_Of (Main_Project, In_Tree));
Set_Directory_Of (Virtual_Project, In_Tree, Virtual_Dir_Id);
Set_Project_Declaration_Of
(Virtual_Project, In_Tree, Project_Declaration);
Set_Extended_Project_Path_Of
(Virtual_Project, In_Tree, Path_Name_Of (For_Project, In_Tree));
-- Project declaration
Set_First_Declarative_Item_Of
(Project_Declaration, In_Tree, Source_Dirs_Declaration);
Set_Extended_Project_Of (Project_Declaration, In_Tree, For_Project);
-- Source_Dirs declaration
Set_Current_Item_Node
(Source_Dirs_Declaration, In_Tree, Source_Dirs_Attribute);
-- Source_Dirs attribute
Set_Name_Of (Source_Dirs_Attribute, In_Tree, Snames.Name_Source_Dirs);
Set_Expression_Of
(Source_Dirs_Attribute, In_Tree, Source_Dirs_Expression);
-- Source_Dirs expression
Set_First_Term (Source_Dirs_Expression, In_Tree, Source_Dirs_Term);
-- Source_Dirs term
Set_Current_Term (Source_Dirs_Term, In_Tree, Source_Dirs_List);
-- Source_Dirs empty list: nothing to do
-- Put virtual project into Projects_Htable
Prj.Tree.Tree_Private_Part.Projects_Htable.Set
(T => In_Tree.Projects_HT,
K => Virtual_Name_Id,
E => (Name => Virtual_Name_Id,
Node => Virtual_Project,
Canonical_Path => No_Name,
Extended => False));
end Create_Virtual_Extending_Project;
----------------------------
-- Immediate_Directory_Of --
----------------------------
function Immediate_Directory_Of (Path_Name : Name_Id) return Name_Id is
begin
Get_Name_String (Path_Name);
for Index in reverse 1 .. Name_Len loop
if Name_Buffer (Index) = '/'
or else Name_Buffer (Index) = Dir_Sep
then
-- Remove all chars after last directory separator from name
if Index > 1 then
Name_Len := Index - 1;
else
Name_Len := Index;
end if;
return Name_Find;
end if;
end loop;
-- There is no directory separator in name. Return "./" or ".\"
Name_Len := 2;
Name_Buffer (1) := '.';
Name_Buffer (2) := Dir_Sep;
return Name_Find;
end Immediate_Directory_Of;
-----------------------------------
-- Look_For_Virtual_Projects_For --
-----------------------------------
procedure Look_For_Virtual_Projects_For
(Proj : Project_Node_Id;
In_Tree : Project_Node_Tree_Ref;
Potentially_Virtual : Boolean)
is
Declaration : Project_Node_Id := Empty_Node;
-- Node for the project declaration of Proj
With_Clause : Project_Node_Id := Empty_Node;
-- Node for a with clause of Proj
Imported : Project_Node_Id := Empty_Node;
-- Node for a project imported by Proj
Extended : Project_Node_Id := Empty_Node;
-- Node for the eventual project extended by Proj
begin
-- Nothing to do if Proj is not defined or if it has already been
-- processed.
if Proj /= Empty_Node and then not Processed_Hash.Get (Proj) then
-- Make sure the project will not be processed again
Processed_Hash.Set (Proj, True);
Declaration := Project_Declaration_Of (Proj, In_Tree);
if Declaration /= Empty_Node then
Extended := Extended_Project_Of (Declaration, In_Tree);
end if;
-- If this is a project that may need a virtual extending project
-- and it is not itself an extending project, put it in the list.
if Potentially_Virtual and then Extended = Empty_Node then
Virtual_Hash.Set (Proj, Proj);
end if;
-- Now check the projects it imports
With_Clause := First_With_Clause_Of (Proj, In_Tree);
while With_Clause /= Empty_Node loop
Imported := Project_Node_Of (With_Clause, In_Tree);
if Imported /= Empty_Node then
Look_For_Virtual_Projects_For
(Imported, In_Tree, Potentially_Virtual => True);
end if;
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
end loop;
-- Check also the eventual project extended by Proj. As this project
-- is already extended, call recursively with Potentially_Virtual
-- being False.
Look_For_Virtual_Projects_For
(Extended, In_Tree, Potentially_Virtual => False);
end if;
end Look_For_Virtual_Projects_For;
-----------
-- Parse --
-----------
procedure Parse
(In_Tree : Project_Node_Tree_Ref;
Project : out Project_Node_Id;
Project_File_Name : String;
Always_Errout_Finalize : Boolean;
Packages_To_Check : String_List_Access := All_Packages;
Store_Comments : Boolean := False)
is
Current_Directory : constant String := Get_Current_Dir;
Dummy : Boolean;
begin
Project := Empty_Node;
if Current_Verbosity >= Medium then
Write_Str ("ADA_PROJECT_PATH=""");
Write_Str (Project_Path);
Write_Line ("""");
end if;
declare
Path_Name : constant String :=
Project_Path_Name_Of (Project_File_Name,
Directory => Current_Directory);
begin
Prj.Err.Initialize;
Prj.Err.Scanner.Set_Comment_As_Token (Store_Comments);
Prj.Err.Scanner.Set_End_Of_Line_As_Token (Store_Comments);
-- Parse the main project file
if Path_Name = "" then
Prj.Com.Fail
("project file """, Project_File_Name, """ not found");
Project := Empty_Node;
return;
end if;
Parse_Single_Project
(In_Tree => In_Tree,
Project => Project,
Extends_All => Dummy,
Path_Name => Path_Name,
Extended => False,
From_Extended => None,
In_Limited => False,
Packages_To_Check => Packages_To_Check);
-- If Project is an extending-all project, create the eventual
-- virtual extending projects and check that there are no illegally
-- imported projects.
if Project /= Empty_Node
and then Is_Extending_All (Project, In_Tree)
then
-- First look for projects that potentially need a virtual
-- extending project.
Virtual_Hash.Reset;
Processed_Hash.Reset;
-- Mark the extending all project as processed, to avoid checking
-- the imported projects in case of a "limited with" on this
-- extending all project.
Processed_Hash.Set (Project, True);
declare
Declaration : constant Project_Node_Id :=
Project_Declaration_Of (Project, In_Tree);
begin
Look_For_Virtual_Projects_For
(Extended_Project_Of (Declaration, In_Tree), In_Tree,
Potentially_Virtual => False);
end;
-- Now, check the projects directly imported by the main project.
-- Remove from the potentially virtual any project extended by one
-- of these imported projects. For non extending imported
-- projects, check that they do not belong to the project tree of
-- the project being "extended-all" by the main project.
declare
With_Clause : Project_Node_Id;
Imported : Project_Node_Id := Empty_Node;
Declaration : Project_Node_Id := Empty_Node;
begin
With_Clause := First_With_Clause_Of (Project, In_Tree);
while With_Clause /= Empty_Node loop
Imported := Project_Node_Of (With_Clause, In_Tree);
if Imported /= Empty_Node then
Declaration := Project_Declaration_Of (Imported, In_Tree);
if Extended_Project_Of (Declaration, In_Tree) /=
Empty_Node
then
loop
Imported :=
Extended_Project_Of (Declaration, In_Tree);
exit when Imported = Empty_Node;
Virtual_Hash.Remove (Imported);
Declaration :=
Project_Declaration_Of (Imported, In_Tree);
end loop;
end if;
end if;
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
end loop;
end;
-- Now create all the virtual extending projects
declare
Proj : Project_Node_Id := Virtual_Hash.Get_First;
begin
while Proj /= Empty_Node loop
Create_Virtual_Extending_Project (Proj, Project, In_Tree);
Proj := Virtual_Hash.Get_Next;
end loop;
end;
end if;
-- If there were any kind of error during the parsing, serious
-- or not, then the parsing fails.
if Err_Vars.Total_Errors_Detected > 0 then
Project := Empty_Node;
end if;
if Project = Empty_Node or else Always_Errout_Finalize then
Prj.Err.Finalize;
end if;
end;
exception
when X : others =>
-- Internal error
Write_Line (Exception_Information (X));
Write_Str ("Exception ");
Write_Str (Exception_Name (X));
Write_Line (" raised, while processing project file");
Project := Empty_Node;
end Parse;
------------------------------
-- Pre_Parse_Context_Clause --
------------------------------
procedure Pre_Parse_Context_Clause
(In_Tree : Project_Node_Tree_Ref;
Context_Clause : out With_Id)
is
Current_With_Clause : With_Id := No_With;
Limited_With : Boolean := False;
Current_With : With_Record;
Current_With_Node : Project_Node_Id := Empty_Node;
begin
-- Assume no context clause
Context_Clause := No_With;
With_Loop :
-- If Token is not WITH or LIMITED, there is no context clause, or we
-- have exhausted the with clauses.
while Token = Tok_With or else Token = Tok_Limited loop
Current_With_Node :=
Default_Project_Node (Of_Kind => N_With_Clause, In_Tree => In_Tree);
Limited_With := Token = Tok_Limited;
if Limited_With then
Scan (In_Tree); -- scan past LIMITED
Expect (Tok_With, "WITH");
exit With_Loop when Token /= Tok_With;
end if;
Comma_Loop :
loop
Scan (In_Tree); -- scan past WITH or ","
Expect (Tok_String_Literal, "literal string");
if Token /= Tok_String_Literal then
return;
end if;
-- Store path and location in table Withs
Current_With :=
(Path => Token_Name,
Location => Token_Ptr,
Limited_With => Limited_With,
Node => Current_With_Node,
Next => No_With);
Withs.Increment_Last;
Withs.Table (Withs.Last) := Current_With;
if Current_With_Clause = No_With then
Context_Clause := Withs.Last;
else
Withs.Table (Current_With_Clause).Next := Withs.Last;
end if;
Current_With_Clause := Withs.Last;
Scan (In_Tree);
if Token = Tok_Semicolon then
Set_End_Of_Line (Current_With_Node);
Set_Previous_Line_Node (Current_With_Node);
-- End of (possibly multiple) with clause;
Scan (In_Tree); -- scan past the semicolon.
exit Comma_Loop;
elsif Token = Tok_Comma then
Set_Is_Not_Last_In_List (Current_With_Node, In_Tree);
else
Error_Msg ("expected comma or semi colon", Token_Ptr);
exit Comma_Loop;
end if;
Current_With_Node :=
Default_Project_Node
(Of_Kind => N_With_Clause, In_Tree => In_Tree);
end loop Comma_Loop;
end loop With_Loop;
end Pre_Parse_Context_Clause;
-------------------------------
-- Post_Parse_Context_Clause --
-------------------------------
procedure Post_Parse_Context_Clause
(Context_Clause : With_Id;
In_Tree : Project_Node_Tree_Ref;
Imported_Projects : out Project_Node_Id;
Project_Directory : Name_Id;
From_Extended : Extension_Origin;
In_Limited : Boolean;
Packages_To_Check : String_List_Access)
is
Current_With_Clause : With_Id := Context_Clause;
Current_Project : Project_Node_Id := Empty_Node;
Previous_Project : Project_Node_Id := Empty_Node;
Next_Project : Project_Node_Id := Empty_Node;
Project_Directory_Path : constant String :=
Get_Name_String (Project_Directory);
Current_With : With_Record;
Limited_With : Boolean := False;
Extends_All : Boolean := False;
begin
Imported_Projects := Empty_Node;
while Current_With_Clause /= No_With loop
Current_With := Withs.Table (Current_With_Clause);
Current_With_Clause := Current_With.Next;
Limited_With := In_Limited or Current_With.Limited_With;
declare
Original_Path : constant String :=
Get_Name_String (Current_With.Path);
Imported_Path_Name : constant String :=
Project_Path_Name_Of
(Original_Path, Project_Directory_Path);
Resolved_Path : constant String :=
Normalize_Pathname
(Imported_Path_Name,
Resolve_Links => True,
Case_Sensitive => True);
Withed_Project : Project_Node_Id := Empty_Node;
begin
if Imported_Path_Name = "" then
-- The project file cannot be found
Error_Msg_Name_1 := Current_With.Path;
Error_Msg ("unknown project file: {", Current_With.Location);
-- If this is not imported by the main project file,
-- display the import path.
if Project_Stack.Last > 1 then
for Index in reverse 1 .. Project_Stack.Last loop
Error_Msg_Name_1 := Project_Stack.Table (Index).Path_Name;
Error_Msg ("\imported by {", Current_With.Location);
end loop;
end if;
else
-- New with clause
Previous_Project := Current_Project;
if Current_Project = Empty_Node then
-- First with clause of the context clause
Current_Project := Current_With.Node;
Imported_Projects := Current_Project;
else
Next_Project := Current_With.Node;
Set_Next_With_Clause_Of
(Current_Project, In_Tree, Next_Project);
Current_Project := Next_Project;
end if;
Set_String_Value_Of
(Current_Project, In_Tree, Current_With.Path);
Set_Location_Of
(Current_Project, In_Tree, Current_With.Location);
-- If this is a "limited with", check if we have a circularity.
-- If we have one, get the project id of the limited imported
-- project file, and do not parse it.
if Limited_With and then Project_Stack.Last > 1 then
declare
Canonical_Path_Name : Name_Id;
begin
Name_Len := Resolved_Path'Length;
Name_Buffer (1 .. Name_Len) := Resolved_Path;
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
Canonical_Path_Name := Name_Find;
for Index in 1 .. Project_Stack.Last loop
if Project_Stack.Table (Index).Canonical_Path_Name =
Canonical_Path_Name
then
-- We have found the limited imported project,
-- get its project id, and do not parse it.
Withed_Project := Project_Stack.Table (Index).Id;
exit;
end if;
end loop;
end;
end if;
-- Parse the imported project, if its project id is unknown
if Withed_Project = Empty_Node then
Parse_Single_Project
(In_Tree => In_Tree,
Project => Withed_Project,
Extends_All => Extends_All,
Path_Name => Imported_Path_Name,
Extended => False,
From_Extended => From_Extended,
In_Limited => Limited_With,
Packages_To_Check => Packages_To_Check);
else
Extends_All := Is_Extending_All (Withed_Project, In_Tree);
end if;
if Withed_Project = Empty_Node then
-- If parsing was not successful, remove the
-- context clause.
Current_Project := Previous_Project;
if Current_Project = Empty_Node then
Imported_Projects := Empty_Node;
else
Set_Next_With_Clause_Of
(Current_Project, In_Tree, Empty_Node);
end if;
else
-- If parsing was successful, record project name
-- and path name in with clause
Set_Project_Node_Of
(Node => Current_Project,
In_Tree => In_Tree,
To => Withed_Project,
Limited_With => Current_With.Limited_With);
Set_Name_Of
(Current_Project,
In_Tree,
Name_Of (Withed_Project, In_Tree));
Name_Len := Resolved_Path'Length;
Name_Buffer (1 .. Name_Len) := Resolved_Path;
Set_Path_Name_Of (Current_Project, In_Tree, Name_Find);
if Extends_All then
Set_Is_Extending_All (Current_Project, In_Tree);
end if;
end if;
end if;
end;
end loop;
end Post_Parse_Context_Clause;
--------------------------
-- Parse_Single_Project --
--------------------------
procedure Parse_Single_Project
(In_Tree : Project_Node_Tree_Ref;
Project : out Project_Node_Id;
Extends_All : out Boolean;
Path_Name : String;
Extended : Boolean;
From_Extended : Extension_Origin;
In_Limited : Boolean;
Packages_To_Check : String_List_Access)
is
Normed_Path_Name : Name_Id;
Canonical_Path_Name : Name_Id;
Project_Directory : Name_Id;
Project_Scan_State : Saved_Project_Scan_State;
Source_Index : Source_File_Index;
Extending : Boolean := False;
Extended_Project : Project_Node_Id := Empty_Node;
A_Project_Name_And_Node : Tree_Private_Part.Project_Name_And_Node :=
Tree_Private_Part.Projects_Htable.Get_First
(In_Tree.Projects_HT);
Name_From_Path : constant Name_Id := Project_Name_From (Path_Name);
Name_Of_Project : Name_Id := No_Name;
First_With : With_Id;
use Tree_Private_Part;
Project_Comment_State : Tree.Comment_State;
begin
Extends_All := False;
declare
Normed_Path : constant String := Normalize_Pathname
(Path_Name, Resolve_Links => False,
Case_Sensitive => True);
Canonical_Path : constant String := Normalize_Pathname
(Normed_Path, Resolve_Links => True,
Case_Sensitive => False);
begin
Name_Len := Normed_Path'Length;
Name_Buffer (1 .. Name_Len) := Normed_Path;
Normed_Path_Name := Name_Find;
Name_Len := Canonical_Path'Length;
Name_Buffer (1 .. Name_Len) := Canonical_Path;
Canonical_Path_Name := Name_Find;
end;
-- Check for a circular dependency
for Index in 1 .. Project_Stack.Last loop
if Canonical_Path_Name =
Project_Stack.Table (Index).Canonical_Path_Name
then
Error_Msg ("circular dependency detected", Token_Ptr);
Error_Msg_Name_1 := Normed_Path_Name;
Error_Msg ("\ { is imported by", Token_Ptr);
for Current in reverse 1 .. Project_Stack.Last loop
Error_Msg_Name_1 := Project_Stack.Table (Current).Path_Name;
if Project_Stack.Table (Current).Canonical_Path_Name /=
Canonical_Path_Name
then
Error_Msg
("\ { which itself is imported by", Token_Ptr);
else
Error_Msg ("\ {", Token_Ptr);
exit;
end if;
end loop;
Project := Empty_Node;
return;
end if;
end loop;
-- Put the new path name on the stack
Project_Stack.Increment_Last;
Project_Stack.Table (Project_Stack.Last).Path_Name := Normed_Path_Name;
Project_Stack.Table (Project_Stack.Last).Canonical_Path_Name :=
Canonical_Path_Name;
-- Check if the project file has already been parsed
while
A_Project_Name_And_Node /= Tree_Private_Part.No_Project_Name_And_Node
loop
if A_Project_Name_And_Node.Canonical_Path = Canonical_Path_Name then
if Extended then
if A_Project_Name_And_Node.Extended then
Error_Msg
("cannot extend the same project file several times",
Token_Ptr);
else
Error_Msg
("cannot extend an already imported project file",
Token_Ptr);
end if;
elsif A_Project_Name_And_Node.Extended then
Extends_All :=
Is_Extending_All (A_Project_Name_And_Node.Node, In_Tree);
-- If the imported project is an extended project A,
-- and we are in an extended project, replace A with the
-- ultimate project extending A.
if From_Extended /= None then
declare
Decl : Project_Node_Id :=
Project_Declaration_Of
(A_Project_Name_And_Node.Node, In_Tree);
Prj : Project_Node_Id :=
Extending_Project_Of (Decl, In_Tree);
begin
loop
Decl := Project_Declaration_Of (Prj, In_Tree);
exit when Extending_Project_Of (Decl, In_Tree) =
Empty_Node;
Prj := Extending_Project_Of (Decl, In_Tree);
end loop;
A_Project_Name_And_Node.Node := Prj;
end;
else
Error_Msg
("cannot import an already extended project file",
Token_Ptr);
end if;
end if;
Project := A_Project_Name_And_Node.Node;
Project_Stack.Decrement_Last;
return;
end if;
A_Project_Name_And_Node :=
Tree_Private_Part.Projects_Htable.Get_Next (In_Tree.Projects_HT);
end loop;
-- We never encountered this project file
-- Save the scan state, load the project file and start to scan it.
Save_Project_Scan_State (Project_Scan_State);
Source_Index := Load_Project_File (Path_Name);
Tree.Save (Project_Comment_State);
-- If we cannot find it, we stop
if Source_Index = No_Source_File then
Project := Empty_Node;
Project_Stack.Decrement_Last;
return;
end if;
Prj.Err.Scanner.Initialize_Scanner (Source_Index);
Tree.Reset_State;
Scan (In_Tree);
if Name_From_Path = No_Name then
-- The project file name is not correct (no or bad extension,
-- or not following Ada identifier's syntax).
Error_Msg_Name_1 := Canonical_Path_Name;
Error_Msg ("?{ is not a valid path name for a project file",
Token_Ptr);
end if;
if Current_Verbosity >= Medium then
Write_Str ("Parsing """);
Write_Str (Path_Name);
Write_Char ('"');
Write_Eol;
end if;
-- Is there any imported project?
Pre_Parse_Context_Clause (In_Tree, First_With);
Project_Directory := Immediate_Directory_Of (Normed_Path_Name);
Project := Default_Project_Node
(Of_Kind => N_Project, In_Tree => In_Tree);
Project_Stack.Table (Project_Stack.Last).Id := Project;
Set_Directory_Of (Project, In_Tree, Project_Directory);
Set_Path_Name_Of (Project, In_Tree, Normed_Path_Name);
Set_Location_Of (Project, In_Tree, Token_Ptr);
Expect (Tok_Project, "PROJECT");
-- Mark location of PROJECT token if present
if Token = Tok_Project then
Scan (In_Tree); -- scan past PROJECT
Set_Location_Of (Project, In_Tree, Token_Ptr);
end if;
-- Clear the Buffer
Buffer_Last := 0;
loop
Expect (Tok_Identifier, "identifier");
-- If the token is not an identifier, clear the buffer before
-- exiting to indicate that the name of the project is ill-formed.
if Token /= Tok_Identifier then
Buffer_Last := 0;
exit;
end if;
-- Add the identifier name to the buffer
Get_Name_String (Token_Name);
Add_To_Buffer (Name_Buffer (1 .. Name_Len), Buffer, Buffer_Last);
-- Scan past the identifier
Scan (In_Tree);
-- If we have a dot, add a dot the the Buffer and look for the next
-- identifier.
exit when Token /= Tok_Dot;
Add_To_Buffer (".", Buffer, Buffer_Last);
-- Scan past the dot
Scan (In_Tree);
end loop;
-- See if this is an extending project
if Token = Tok_Extends then
-- Make sure that gnatmake will use mapping files
Create_Mapping_File := True;
-- We are extending another project
Extending := True;
Scan (In_Tree); -- scan past EXTENDS
if Token = Tok_All then
Extends_All := True;
Set_Is_Extending_All (Project, In_Tree);
Scan (In_Tree); -- scan past ALL
end if;
end if;
-- If the name is well formed, Buffer_Last is > 0
if Buffer_Last > 0 then
-- The Buffer contains the name of the project
Name_Len := Buffer_Last;
Name_Buffer (1 .. Name_Len) := Buffer (1 .. Buffer_Last);
Name_Of_Project := Name_Find;
Set_Name_Of (Project, In_Tree, Name_Of_Project);
-- To get expected name of the project file, replace dots by dashes
Name_Len := Buffer_Last;
Name_Buffer (1 .. Name_Len) := Buffer (1 .. Buffer_Last);
for Index in 1 .. Name_Len loop
if Name_Buffer (Index) = '.' then
Name_Buffer (Index) := '-';
end if;
end loop;
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
declare
Expected_Name : constant Name_Id := Name_Find;
begin
-- Output a warning if the actual name is not the expected name
if Name_From_Path /= No_Name
and then Expected_Name /= Name_From_Path
then
Error_Msg_Name_1 := Expected_Name;
Error_Msg ("?file name does not match unit name, " &
"should be `{" & Project_File_Extension & "`",
Token_Ptr);
end if;
end;
declare
Imported_Projects : Project_Node_Id := Empty_Node;
From_Ext : Extension_Origin := None;
begin
-- Extending_All is always propagated
if From_Extended = Extending_All or else Extends_All then
From_Ext := Extending_All;
-- Otherwise, From_Extended is set to Extending_Single if the
-- current project is an extending project.
elsif Extended then
From_Ext := Extending_Simple;
end if;
Post_Parse_Context_Clause
(In_Tree => In_Tree,
Context_Clause => First_With,
Imported_Projects => Imported_Projects,
Project_Directory => Project_Directory,
From_Extended => From_Ext,
In_Limited => In_Limited,
Packages_To_Check => Packages_To_Check);
Set_First_With_Clause_Of (Project, In_Tree, Imported_Projects);
end;
declare
Name_And_Node : Tree_Private_Part.Project_Name_And_Node :=
Tree_Private_Part.Projects_Htable.Get_First
(In_Tree.Projects_HT);
Project_Name : Name_Id := Name_And_Node.Name;
begin
-- Check if we already have a project with this name
while Project_Name /= No_Name
and then Project_Name /= Name_Of_Project
loop
Name_And_Node :=
Tree_Private_Part.Projects_Htable.Get_Next
(In_Tree.Projects_HT);
Project_Name := Name_And_Node.Name;
end loop;
-- Report an error if we already have a project with this name
if Project_Name /= No_Name then
Error_Msg_Name_1 := Project_Name;
Error_Msg
("duplicate project name {", Location_Of (Project, In_Tree));
Error_Msg_Name_1 :=
Path_Name_Of (Name_And_Node.Node, In_Tree);
Error_Msg
("\already in {", Location_Of (Project, In_Tree));
else
-- Otherwise, add the name of the project to the hash table, so
-- that we can check that no other subsequent project will have
-- the same name.
Tree_Private_Part.Projects_Htable.Set
(T => In_Tree.Projects_HT,
K => Name_Of_Project,
E => (Name => Name_Of_Project,
Node => Project,
Canonical_Path => Canonical_Path_Name,
Extended => Extended));
end if;
end;
end if;
if Extending then
Expect (Tok_String_Literal, "literal string");
if Token = Tok_String_Literal then
Set_Extended_Project_Path_Of (Project, In_Tree, Token_Name);
declare
Original_Path_Name : constant String :=
Get_Name_String (Token_Name);
Extended_Project_Path_Name : constant String :=
Project_Path_Name_Of
(Original_Path_Name,
Get_Name_String
(Project_Directory));
begin
if Extended_Project_Path_Name = "" then
-- We could not find the project file to extend
Error_Msg_Name_1 := Token_Name;
Error_Msg ("unknown project file: {", Token_Ptr);
-- If we are not in the main project file, display the
-- import path.
if Project_Stack.Last > 1 then
Error_Msg_Name_1 :=
Project_Stack.Table (Project_Stack.Last).Path_Name;
Error_Msg ("\extended by {", Token_Ptr);
for Index in reverse 1 .. Project_Stack.Last - 1 loop
Error_Msg_Name_1 :=
Project_Stack.Table (Index).Path_Name;
Error_Msg ("\imported by {", Token_Ptr);
end loop;
end if;
else
declare
From_Ext : Extension_Origin := None;
begin
if From_Extended = Extending_All or else Extends_All then
From_Ext := Extending_All;
end if;
Parse_Single_Project
(In_Tree => In_Tree,
Project => Extended_Project,
Extends_All => Extends_All,
Path_Name => Extended_Project_Path_Name,
Extended => True,
From_Extended => From_Ext,
In_Limited => In_Limited,
Packages_To_Check => Packages_To_Check);
end;
-- A project that extends an extending-all project is also
-- an extending-all project.
if Extended_Project /= Empty_Node
and then Is_Extending_All (Extended_Project, In_Tree)
then
Set_Is_Extending_All (Project, In_Tree);
end if;
end if;
end;
Scan (In_Tree); -- scan past the extended project path
end if;
end if;
-- Check that a non extending-all project does not import an
-- extending-all project.
if not Is_Extending_All (Project, In_Tree) then
declare
With_Clause : Project_Node_Id :=
First_With_Clause_Of (Project, In_Tree);
Imported : Project_Node_Id := Empty_Node;
begin
With_Clause_Loop :
while With_Clause /= Empty_Node loop
Imported := Project_Node_Of (With_Clause, In_Tree);
if Is_Extending_All (With_Clause, In_Tree) then
Error_Msg_Name_1 := Name_Of (Imported, In_Tree);
Error_Msg ("cannot import extending-all project {",
Token_Ptr);
exit With_Clause_Loop;
end if;
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
end loop With_Clause_Loop;
end;
end if;
-- Check that a project with a name including a dot either imports
-- or extends the project whose name precedes the last dot.
if Name_Of_Project /= No_Name then
Get_Name_String (Name_Of_Project);
else
Name_Len := 0;
end if;
-- Look for the last dot
while Name_Len > 0 and then Name_Buffer (Name_Len) /= '.' loop
Name_Len := Name_Len - 1;
end loop;
-- If a dot was find, check if the parent project is imported
-- or extended.
if Name_Len > 0 then
Name_Len := Name_Len - 1;
declare
Parent_Name : constant Name_Id := Name_Find;
Parent_Found : Boolean := False;
With_Clause : Project_Node_Id :=
First_With_Clause_Of (Project, In_Tree);
begin
-- If there is an extended project, check its name
if Extended_Project /= Empty_Node then
Parent_Found :=
Name_Of (Extended_Project, In_Tree) = Parent_Name;
end if;
-- If the parent project is not the extended project,
-- check each imported project until we find the parent project.
while not Parent_Found and then With_Clause /= Empty_Node loop
Parent_Found :=
Name_Of (Project_Node_Of (With_Clause, In_Tree), In_Tree) =
Parent_Name;
With_Clause := Next_With_Clause_Of (With_Clause, In_Tree);
end loop;
-- If the parent project was not found, report an error
if not Parent_Found then
Error_Msg_Name_1 := Name_Of_Project;
Error_Msg_Name_2 := Parent_Name;
Error_Msg ("project { does not import or extend project {",
Location_Of (Project, In_Tree));
end if;
end;
end if;
Expect (Tok_Is, "IS");
Set_End_Of_Line (Project);
Set_Previous_Line_Node (Project);
Set_Next_End_Node (Project);
declare
Project_Declaration : Project_Node_Id := Empty_Node;
begin
-- No need to Scan past "is", Prj.Dect.Parse will do it
Prj.Dect.Parse
(In_Tree => In_Tree,
Declarations => Project_Declaration,
Current_Project => Project,
Extends => Extended_Project,
Packages_To_Check => Packages_To_Check);
Set_Project_Declaration_Of (Project, In_Tree, Project_Declaration);
if Extended_Project /= Empty_Node then
Set_Extending_Project_Of
(Project_Declaration_Of (Extended_Project, In_Tree), In_Tree,
To => Project);
end if;
end;
Expect (Tok_End, "END");
Remove_Next_End_Node;
-- Skip "end" if present
if Token = Tok_End then
Scan (In_Tree);
end if;
-- Clear the Buffer
Buffer_Last := 0;
-- Store the name following "end" in the Buffer. The name may be made of
-- several simple names.
loop
Expect (Tok_Identifier, "identifier");
-- If we don't have an identifier, clear the buffer before exiting to
-- avoid checking the name.
if Token /= Tok_Identifier then
Buffer_Last := 0;
exit;
end if;
-- Add the identifier to the Buffer
Get_Name_String (Token_Name);
Add_To_Buffer (Name_Buffer (1 .. Name_Len), Buffer, Buffer_Last);
-- Scan past the identifier
Scan (In_Tree);
exit when Token /= Tok_Dot;
Add_To_Buffer (".", Buffer, Buffer_Last);
Scan (In_Tree);
end loop;
-- If we have a valid name, check if it is the name of the project
if Name_Of_Project /= No_Name and then Buffer_Last > 0 then
if To_Lower (Buffer (1 .. Buffer_Last)) /=
Get_Name_String (Name_Of (Project, In_Tree))
then
-- Invalid name: report an error
Error_Msg ("expected """ &
Get_Name_String (Name_Of (Project, In_Tree)) & """",
Token_Ptr);
end if;
end if;
Expect (Tok_Semicolon, "`;`");
-- Check that there is no more text following the end of the project
-- source.
if Token = Tok_Semicolon then
Set_Previous_End_Node (Project);
Scan (In_Tree);
if Token /= Tok_EOF then
Error_Msg
("unexpected text following end of project", Token_Ptr);
end if;
end if;
-- Restore the scan state, in case we are not the main project
Restore_Project_Scan_State (Project_Scan_State);
-- And remove the project from the project stack
Project_Stack.Decrement_Last;
-- Indicate if there are unkept comments
Tree.Set_Project_File_Includes_Unkept_Comments
(Node => Project,
In_Tree => In_Tree,
To => Tree.There_Are_Unkept_Comments);
-- And restore the comment state that was saved
Tree.Restore (Project_Comment_State);
end Parse_Single_Project;
-----------------------
-- Project_Name_From --
-----------------------
function Project_Name_From (Path_Name : String) return Name_Id is
Canonical : String (1 .. Path_Name'Length) := Path_Name;
First : Natural := Canonical'Last;
Last : Natural := First;
Index : Positive;
begin
if Current_Verbosity = High then
Write_Str ("Project_Name_From (""");
Write_Str (Canonical);
Write_Line (""")");
end if;
-- If the path name is empty, return No_Name to indicate failure
if First = 0 then
return No_Name;
end if;
Canonical_Case_File_Name (Canonical);
-- Look for the last dot in the path name
while First > 0
and then
Canonical (First) /= '.'
loop
First := First - 1;
end loop;
-- If we have a dot, check that it is followed by the correct extension
if First > 0 and then Canonical (First) = '.' then
if Canonical (First .. Last) = Project_File_Extension
and then First /= 1
then
-- Look for the last directory separator, if any
First := First - 1;
Last := First;
while First > 0
and then Canonical (First) /= '/'
and then Canonical (First) /= Dir_Sep
loop
First := First - 1;
end loop;
else
-- Not the correct extension, return No_Name to indicate failure
return No_Name;
end if;
-- If no dot in the path name, return No_Name to indicate failure
else
return No_Name;
end if;
First := First + 1;
-- If the extension is the file name, return No_Name to indicate failure
if First > Last then
return No_Name;
end if;
-- Put the name in lower case into Name_Buffer
Name_Len := Last - First + 1;
Name_Buffer (1 .. Name_Len) := To_Lower (Canonical (First .. Last));
Index := 1;
-- Check if it is a well formed project name. Return No_Name if it is
-- ill formed.
loop
if not Is_Letter (Name_Buffer (Index)) then
return No_Name;
else
loop
Index := Index + 1;
exit when Index >= Name_Len;
if Name_Buffer (Index) = '_' then
if Name_Buffer (Index + 1) = '_' then
return No_Name;
end if;
end if;
exit when Name_Buffer (Index) = '-';
if Name_Buffer (Index) /= '_'
and then not Is_Alphanumeric (Name_Buffer (Index))
then
return No_Name;
end if;
end loop;
end if;
if Index >= Name_Len then
if Is_Alphanumeric (Name_Buffer (Name_Len)) then
-- All checks have succeeded. Return name in Name_Buffer
return Name_Find;
else
return No_Name;
end if;
elsif Name_Buffer (Index) = '-' then
Index := Index + 1;
end if;
end loop;
end Project_Name_From;
--------------------------
-- Project_Path_Name_Of --
--------------------------
function Project_Path_Name_Of
(Project_File_Name : String;
Directory : String) return String
is
Result : String_Access;
begin
if Current_Verbosity = High then
Write_Str ("Project_Path_Name_Of (""");
Write_Str (Project_File_Name);
Write_Str (""", """);
Write_Str (Directory);
Write_Line (""");");
end if;
if not Is_Absolute_Path (Project_File_Name) then
-- First we try <directory>/<file_name>.<extension>
if Current_Verbosity = High then
Write_Str (" Trying ");
Write_Str (Directory);
Write_Char (Directory_Separator);
Write_Str (Project_File_Name);
Write_Line (Project_File_Extension);
end if;
Result :=
Locate_Regular_File
(File_Name => Directory & Directory_Separator &
Project_File_Name & Project_File_Extension,
Path => Project_Path);
-- Then we try <directory>/<file_name>
if Result = null then
if Current_Verbosity = High then
Write_Str (" Trying ");
Write_Str (Directory);
Write_Char (Directory_Separator);
Write_Line (Project_File_Name);
end if;
Result :=
Locate_Regular_File
(File_Name => Directory & Directory_Separator &
Project_File_Name,
Path => Project_Path);
end if;
end if;
if Result = null then
-- Then we try <file_name>.<extension>
if Current_Verbosity = High then
Write_Str (" Trying ");
Write_Str (Project_File_Name);
Write_Line (Project_File_Extension);
end if;
Result :=
Locate_Regular_File
(File_Name => Project_File_Name & Project_File_Extension,
Path => Project_Path);
end if;
if Result = null then
-- Then we try <file_name>
if Current_Verbosity = High then
Write_Str (" Trying ");
Write_Line (Project_File_Name);
end if;
Result :=
Locate_Regular_File
(File_Name => Project_File_Name,
Path => Project_Path);
end if;
-- If we cannot find the project file, we return an empty string
if Result = null then
return "";
else
declare
Final_Result : constant String :=
GNAT.OS_Lib.Normalize_Pathname
(Result.all,
Resolve_Links => False,
Case_Sensitive => True);
begin
Free (Result);
return Final_Result;
end;
end if;
end Project_Path_Name_Of;
end Prj.Part;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with Ada.Characters.Wide_Wide_Latin_1;
with Ada.Wide_Wide_Text_IO;
with League.Strings;
with League.String_Vectors;
with XML.SAX.Attributes;
-- with XML.SAX.HTML5_Writers;
-- with XML.SAX.Pretty_Writers;
with Custom_Writers;
with XML.SAX.Output_Destinations.Strings;
with Markdown.ATX_Headings;
with Markdown.Blockquotes;
with Markdown.Fenced_Code_Blocks;
with Markdown.HTML_Blocks;
with Markdown.Indented_Code_Blocks;
with Markdown.Inline_Parsers;
with Markdown.Link_Reference_Definitions;
with Markdown.List_Items;
with Markdown.Paragraphs;
with Markdown.Parsers;
with Markdown.Thematic_Breaks;
with Markdown.Visitors;
with Markdown.Lists;
procedure MD_Driver is
LF : constant Wide_Wide_Character := Ada.Characters.Wide_Wide_Latin_1.LF;
New_Line : constant Wide_Wide_String := (1 => LF);
function Trim_Doctype (Text : League.Strings.Universal_String)
return League.Strings.Universal_String;
package Visitors is
type Visitor is limited new Markdown.Visitors.Visitor with record
Parser : Markdown.Parsers.Parser;
Is_Tight : Boolean := False;
New_Line : League.Strings.Universal_String;
Namespace : League.Strings.Universal_String;
Writer : aliased Custom_Writers.Writer;
Output : aliased XML.SAX.Output_Destinations.Strings
.String_Output_Destination;
end record;
overriding procedure ATX_Heading
(Self : in out Visitor;
Block : Markdown.ATX_Headings.ATX_Heading);
overriding procedure Blockquote
(Self : in out Visitor;
Block : in out Markdown.Blockquotes.Blockquote);
overriding procedure Fenced_Code_Block
(Self : in out Visitor;
Block : Markdown.Fenced_Code_Blocks.Fenced_Code_Block);
overriding procedure HTML_Block
(Self : in out Visitor;
Block : Markdown.HTML_Blocks.HTML_Block);
overriding procedure Indented_Code_Block
(Self : in out Visitor;
Block : Markdown.Indented_Code_Blocks.Indented_Code_Block);
overriding procedure List
(Self : in out Visitor;
Block : Markdown.Lists.List);
overriding procedure List_Item
(Self : in out Visitor;
Block : in out Markdown.List_Items.List_Item);
overriding procedure Paragraph
(Self : in out Visitor;
Block : Markdown.Paragraphs.Paragraph);
overriding procedure Thematic_Break
(Self : in out Visitor;
Value : Markdown.Thematic_Breaks.Thematic_Break);
end Visitors;
function "+" (Text : Wide_Wide_String)
return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
package body Visitors is
procedure Write_Annotated_Text
(Self : in out Visitor'Class;
Text : Markdown.Inline_Parsers.Annotated_Text);
overriding procedure ATX_Heading
(Self : in out Visitor;
Block : Markdown.ATX_Headings.ATX_Heading)
is
Image : Wide_Wide_String := Block.Level'Wide_Wide_Image;
Lines : League.String_Vectors.Universal_String_Vector;
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
Lines.Append (Block.Title);
Image (1) := 'h';
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +Image,
Attributes => Empty);
Self.Write_Annotated_Text (Self.Parser.Parse_Inlines (Lines));
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +Image);
end ATX_Heading;
overriding procedure Blockquote
(Self : in out Visitor;
Block : in out Markdown.Blockquotes.Blockquote)
is
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"blockquote",
Attributes => Empty);
Block.Visit_Children (Self);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"blockquote");
end Blockquote;
overriding procedure Fenced_Code_Block
(Self : in out Visitor;
Block : Markdown.Fenced_Code_Blocks.Fenced_Code_Block)
is
use type League.Strings.Universal_String;
Words : constant League.String_Vectors.Universal_String_Vector :=
Block.Info_String.Split (' ', League.Strings.Skip_Empty);
Lines : constant League.String_Vectors.Universal_String_Vector :=
Block.Lines;
Attr : XML.SAX.Attributes.SAX_Attributes;
begin
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"pre",
Attributes => Attr);
if not Block.Info_String.Is_Empty then
Attr.Set_Value
(Namespace_URI => Self.Namespace,
Local_Name => +"class",
Value => "language-" & Words (1));
end if;
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code",
Attributes => Attr);
for J in 1 .. Lines.Length loop
Self.Writer.Characters (Lines (J));
Self.Writer.Characters (Self.New_Line);
end loop;
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code");
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"pre");
end Fenced_Code_Block;
overriding procedure HTML_Block
(Self : in out Visitor;
Block : Markdown.HTML_Blocks.HTML_Block)
is
Lines : constant League.String_Vectors.Universal_String_Vector :=
Block.Lines;
begin
for J in 1 .. Lines.Length loop
if J > 1 then
Self.Writer.Characters (Self.New_Line);
end if;
Self.Writer.Unescaped_Characters (Lines (J));
end loop;
end HTML_Block;
overriding procedure Indented_Code_Block
(Self : in out Visitor;
Block : Markdown.Indented_Code_Blocks.Indented_Code_Block)
is
Lines : constant League.String_Vectors.Universal_String_Vector :=
Block.Lines;
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"pre",
Attributes => Empty);
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code",
Attributes => Empty);
for J in 1 .. Lines.Length loop
Self.Writer.Characters (Lines (J));
Self.Writer.Characters (Self.New_Line);
end loop;
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code");
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"pre");
end Indented_Code_Block;
overriding procedure List
(Self : in out Visitor;
Block : Markdown.Lists.List)
is
Attr : XML.SAX.Attributes.SAX_Attributes;
Is_Tight : constant Boolean := Self.Is_Tight;
Name : League.Strings.Universal_String;
begin
if Block.Is_Ordered then
declare
Start : constant Wide_Wide_String :=
Block.Start'Wide_Wide_Image;
begin
Name := +"ol";
if Start /= " 1" then
Attr.Set_Value
(Namespace_URI => Self.Namespace,
Local_Name => +"start",
Value => +Start (2 .. Start'Last));
end if;
end;
else
Name := +"ul";
end if;
Self.Is_Tight := not Block.Is_Loose;
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => Name,
Attributes => Attr);
Block.Visit_Children (Self);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => Name);
Self.Is_Tight := Is_Tight;
end List;
overriding procedure List_Item
(Self : in out Visitor;
Block : in out Markdown.List_Items.List_Item)
is
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"li",
Attributes => Empty);
Block.Visit_Children (Self);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"li");
end List_Item;
overriding procedure Paragraph
(Self : in out Visitor;
Block : Markdown.Paragraphs.Paragraph)
is
Lines : constant League.String_Vectors.Universal_String_Vector :=
Block.Lines;
Text : constant Markdown.Inline_Parsers.Annotated_Text :=
Self.Parser.Parse_Inlines (Lines);
Image : Wide_Wide_String := Block.Setext_Heading'Wide_Wide_Image;
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
if Self.Is_Tight then
Self.Write_Annotated_Text (Text);
elsif Block.Setext_Heading = 0 then
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"p",
Attributes => Empty);
Self.Write_Annotated_Text (Text);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"p");
else
Image (1) := 'h';
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +Image,
Attributes => Empty);
Self.Write_Annotated_Text (Text);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +Image);
end if;
end Paragraph;
overriding procedure Thematic_Break
(Self : in out Visitor;
Value : Markdown.Thematic_Breaks.Thematic_Break)
is
pragma Unreferenced (Value);
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
begin
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"hr",
Attributes => Empty);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"hr");
end Thematic_Break;
procedure Write_Annotated_Text
(Self : in out Visitor'Class;
Text : Markdown.Inline_Parsers.Annotated_Text)
is
procedure Write
(From : in out Positive;
Next : in out Positive;
Limit : Natural);
Empty : XML.SAX.Attributes.SAX_Attributes renames
XML.SAX.Attributes.Empty_SAX_Attributes;
procedure Write
(From : in out Positive;
Next : in out Positive;
Limit : Natural) is
begin
while From <= Text.Annotation.Last_Index and then
Text.Annotation (From).To <= Limit
loop
declare
Item : constant Markdown.Inline_Parsers.Annotation :=
Text.Annotation (From);
begin
if Next <= Item.From - 1 then
Self.Writer.Characters
(Text.Plain_Text.Slice
(Next, Item.From - 1).To_Wide_Wide_String);
Next := Item.From;
end if;
From := From + 1;
case Item.Kind is
when Markdown.Inline_Parsers.Soft_Line_Break =>
Next := Next + 1;
Self.Writer.Characters (Self.New_Line);
when Markdown.Inline_Parsers.Emphasis =>
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"em",
Attributes => Empty);
Write (From, Next, Item.To);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"em");
when Markdown.Inline_Parsers.Strong =>
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"strong",
Attributes => Empty);
Write (From, Next, Item.To);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"strong");
when Markdown.Inline_Parsers.Code_Span =>
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code",
Attributes => Empty);
Write (From, Next, Item.To);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"code");
when Markdown.Inline_Parsers.Link =>
declare
Attr : XML.SAX.Attributes.SAX_Attributes;
Title : constant League.Strings.Universal_String :=
Item.Title.Join (' ');
begin
Attr.Set_Value
(Self.Namespace, +"href", Item.Destination);
if not Title.Is_Empty then
Attr.Set_Value
(Self.Namespace, +"title", Title);
end if;
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"a",
Attributes => Attr);
Write (From, Next, Item.To);
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => +"a");
end;
when Markdown.Inline_Parsers.Open_HTML_Tag =>
declare
Attr : XML.SAX.Attributes.SAX_Attributes;
begin
for J of Item.Attr loop
if J.Value.Is_Empty then
Attr.Set_Value
(Self.Namespace, J.Name, J.Name);
else
Attr.Set_Value
(Self.Namespace, J.Name, J.Value.Join (LF));
end if;
end loop;
Self.Writer.Start_Element
(Namespace_URI => Self.Namespace,
Local_Name => Item.Tag,
Attributes => Attr);
if Item.Is_Empty then
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => Item.Tag);
end if;
end;
when Markdown.Inline_Parsers.Close_HTML_Tag =>
Self.Writer.End_Element
(Namespace_URI => Self.Namespace,
Local_Name => Item.Tag);
when Markdown.Inline_Parsers.HTML_Comment =>
Self.Writer.Comment (Item.HTML_Comment.Join (LF));
when Markdown.Inline_Parsers
.HTML_Processing_Instruction =>
Self.Writer.Processing_Instruction
(Item.HTML_PI.Join (LF));
when Markdown.Inline_Parsers.HTML_Declaration =>
Self.Writer.Comment (Item.HTML_Decl.Join (LF));
when Markdown.Inline_Parsers.HTML_CDATA =>
Self.Writer.Start_CDATA;
Self.Writer.Characters (Item.HTML_CDATA.Join (LF));
Self.Writer.End_CDATA;
end case;
end;
end loop;
if Next <= Limit then
Self.Writer.Characters
(Text.Plain_Text.Slice
(Next, Limit).To_Wide_Wide_String);
Next := Limit + 1;
end if;
end Write;
Next : Positive := 1; -- Position in Text,Plain_Text
From : Positive := Text.Annotation.First_Index;
begin
Write (From, Next, Text.Plain_Text.Length);
end Write_Annotated_Text;
end Visitors;
------------------
-- Trim_Doctype --
------------------
function Trim_Doctype (Text : League.Strings.Universal_String)
return League.Strings.Universal_String
is
Pos : constant Positive := Text.Index (">");
Result : League.Strings.Universal_String :=
Text.Slice (Pos + 1, Text.Length - 8);
begin
if Result.Ends_With (New_Line) then
Result := Result.Head_To (Result.Length - 1);
end if;
return Result;
end Trim_Doctype;
Visitor : Visitors.Visitor;
Parser : Markdown.Parsers.Parser renames Visitor.Parser;
Empty : XML.SAX.Attributes.SAX_Attributes;
Result : League.Strings.Universal_String;
begin
Parser.Register (Markdown.ATX_Headings.Filter'Access);
Parser.Register (Markdown.Blockquotes.Filter'Access);
Parser.Register (Markdown.Thematic_Breaks.Filter'Access);
Parser.Register (Markdown.Indented_Code_Blocks.Filter'Access);
Parser.Register (Markdown.Fenced_Code_Blocks.Filter'Access);
Parser.Register (Markdown.HTML_Blocks.Filter'Access);
Parser.Register (Markdown.Link_Reference_Definitions.Filter'Access);
Parser.Register (Markdown.List_Items.Filter'Access);
Parser.Register (Markdown.Paragraphs.Filter'Access);
Visitor.Writer.Set_Output_Destination (Visitor.Output'Unchecked_Access);
Visitor.New_Line := +New_Line;
Visitor.Namespace := +"http://www.w3.org/1999/xhtml";
while not Ada.Wide_Wide_Text_IO.End_Of_File loop
declare
Line : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String
(Ada.Wide_Wide_Text_IO.Get_Line);
begin
Parser.Append_Line (Line);
end;
end loop;
Parser.Stop;
Visitor.Writer.Start_Document;
Visitor.Writer.Start_Prefix_Mapping
(Prefix => +"",
Namespace_URI => Visitor.Namespace);
Visitor.Writer.Start_Element
(Namespace_URI => Visitor.Namespace,
Local_Name => +"html",
Attributes => Empty);
Parser.Visit (Visitor);
Visitor.Writer.End_Element
(Namespace_URI => Visitor.Namespace,
Local_Name => +"html");
Visitor.Writer.End_Document;
Result := Trim_Doctype (Visitor.Output.Get_Text);
if not Result.Is_Empty then
Ada.Wide_Wide_Text_IO.Put_Line (Result.To_Wide_Wide_String);
end if;
end MD_Driver;
|
with Ada.Text_IO; use Ada.Text_IO;
with ZMQ.Sockets;
with ZMQ.Contexts;
with ZMQ.Messages;
procedure LMCP.Client is
Ctx : ZMQ.Contexts.Context;
Sub : ZMQ.Sockets.Socket;
begin
Ctx.Set_number_of_IO_threads (1);
Sub.Initialize (Ctx, ZMQ.Sockets.SUB);
-- LmcpObjectNetworkPublishPullBridge
-- 'AddressPUB' attribute specifies PUB address (defaults to 'tcp://*:5556')
-- PUB socket is zeromq server (i.e. binds)
Sub.Connect ("tcp://127.0.0.1:5556");
-- Accept all forwarded messages (filtering on PUB side via 'SubscribeToMessage' child elements)
Sub.Establish_Message_Filter ("");
for i in 1 .. 10 loop
declare
ZmqMsg : ZMQ.Messages.Message;
begin
ZmqMsg.Initialize (0);
Sub.Recv (ZmqMsg);
Put_Line (ZmqMsg.GetData);
-- ZMQ.Messages.Message is finalized automatically as controlled types (i.e. ensures
-- call to underlying zmq_msg_close() via its Finalize subprogram)
end;
end loop;
-- Socket is closed (i.e. zmq_close()) automatically via Finalize as a controlled type
end LMCP.Client;
|
package body Hailstones is
function Create_Sequence (N : Positive) return Integer_Sequence is
begin
if N = 1 then
-- terminate
return (1 => N);
elsif N mod 2 = 0 then
-- even
return (1 => N) & Create_Sequence (N / 2);
else
-- odd
return (1 => N) & Create_Sequence (3 * N + 1);
end if;
end Create_Sequence;
end Hailstones;
|
with Ada.Real_Time; use Ada.Real_Time;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.TIM; use STM32_SVD.TIM;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32GD.Timer.Peripheral is
Timer_Callback : Timer_Callback_Type := null;
Frequency : constant Natural := 1_000;
CK_INT : constant Natural := 8_000_000;
Repeat : Boolean;
First : Boolean;
procedure Start (Time : Time_Span; Callback : Timer_Callback_Type);
protected body IRQ_Handler is
procedure Handler is
begin
if Timer = Timer_14 then
TIM14_Periph.SR.UIF := 0;
end if;
if Timer_Callback /= null then
if not First then
if not Repeat then
Stop;
end if;
Timer_Callback.all;
else
First := False;
end if;
end if;
end Handler;
end IRQ_Handler;
procedure Init is
begin
if Timer = Timer_14 then
RCC_Periph.APB1ENR.TIM14EN := 1;
TIM14_Periph.PSC.PSC := UInt16 (CK_INT / Frequency);
TIM14_Periph.CR1.ARPE := 1;
end if;
end Init;
procedure Start (Time : Time_Span; Callback : Timer_Callback_Type) is
MS : UInt16;
begin
MS := UInt16 (To_Duration (Time) * 1_000);
Timer_Callback := Callback;
First := True;
if Timer = Timer_14 then
TIM14_Periph.CNT.CNT := 0;
TIM14_Periph.ARR.ARR := MS;
TIM14_Periph.CR1.CEN := 1;
TIM14_Periph.DIER.UIE := 1;
end if;
end Start;
procedure Stop is
begin
if Timer = Timer_14 then
TIM14_Periph.CR1.CEN := 0;
TIM14_Periph.DIER.UIE := 0;
end if;
end Stop;
procedure After (Time : Time_Span; Callback : Timer_Callback_Type) is
begin
Repeat := False;
Start (Time, Callback);
end After;
procedure Every (Interval : Time_Span; Callback : Timer_Callback_Type) is
begin
Repeat := True;
Start (Interval, Callback);
end Every;
end STM32GD.Timer.Peripheral;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S . T H I N . S I G N A L L I N G _ F D S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2020, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Portable sockets-based implementation of GNAT.Sockets.Thin.Signalling_Fds
-- used for platforms that do not support UNIX pipes.
-- Note: this code used to be in GNAT.Sockets, but has been moved to a
-- platform-specific file. It is now used only for non-UNIX platforms.
separate (GNAT.Sockets.Thin)
package body Signalling_Fds is
-----------
-- Close --
-----------
procedure Close (Sig : C.int) is
Res : C.int;
pragma Unreferenced (Res);
-- Res is assigned but never read, because we purposefully ignore
-- any error returned by the C_Close system call, as per the spec
-- of this procedure.
begin
Res := C_Close (Sig);
end Close;
------------
-- Create --
------------
function Create (Fds : not null access Fd_Pair) return C.int is
Res : constant C.int :=
C_Socketpair (SOSC.AF_INET, SOSC.SOCK_STREAM, 0, Fds);
begin
if Res /= Failure then
-- Set TCP_NODELAY on Fds (Write_End), since we always want to send
-- the data out immediately.
Set_Socket_Option
(Socket => Socket_Type (Fds (Write_End)),
Level => IP_Protocol_For_TCP_Level,
Option => (Name => No_Delay, Enabled => True));
end if;
return Res;
end Create;
----------
-- Read --
----------
function Read (Rsig : C.int) return C.int is
Buf : aliased Character;
begin
return C_Recv (Rsig, Buf'Address, 1, SOSC.MSG_Forced_Flags);
end Read;
-----------
-- Write --
-----------
function Write (Wsig : C.int) return C.int is
Buf : aliased Character := ASCII.NUL;
begin
return C_Sendto
(Wsig, Buf'Address, 1,
Flags => SOSC.MSG_Forced_Flags,
To => System.Null_Address,
Tolen => 0);
end Write;
end Signalling_Fds;
|
-- generated parser support file.
-- command line: wisitoken-bnf-generate.exe --generate LALR Ada re2c wisitoken_grammar.wy
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- Author: Stephen Leake <stephe-leake@stephe-leake.org>
--
-- This file is part of GNU Emacs.
--
-- GNU Emacs is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- GNU Emacs is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
with WisiToken_Grammar_Runtime; use WisiToken_Grammar_Runtime;
package body Wisitoken_Grammar_Actions is
procedure declaration_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Declaration (User_Data, Tree, Tokens);
end declaration_0;
procedure declaration_1
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Declaration (User_Data, Tree, Tokens);
end declaration_1;
procedure declaration_2
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Declaration (User_Data, Tree, Tokens);
end declaration_2;
procedure declaration_3
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Declaration (User_Data, Tree, Tokens);
end declaration_3;
procedure declaration_4
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Start_If (User_Data, Tree, Tokens);
end declaration_4;
procedure declaration_5
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Tree, Nonterm, Tokens);
begin
End_If (User_Data);
end declaration_5;
procedure nonterminal_0
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Nonterminal (User_Data, Tree, Tokens);
end nonterminal_0;
procedure nonterminal_1
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Add_Nonterminal (User_Data, Tree, Tokens);
end nonterminal_1;
procedure rhs_item_1
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_item_1;
procedure rhs_item_2
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_item_2;
procedure rhs_item_3
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_item_3;
procedure rhs_item_4
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_item_4;
procedure rhs_item_5
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_item_5;
procedure rhs_optional_item_3
(User_Data : in out WisiToken.Syntax_Trees.User_Data_Type'Class;
Tree : in out WisiToken.Syntax_Trees.Tree;
Nonterm : in WisiToken.Syntax_Trees.Valid_Node_Index;
Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array)
is
pragma Unreferenced (Nonterm);
begin
Check_EBNF (User_Data, Tree, Tokens, 1);
end rhs_optional_item_3;
end Wisitoken_Grammar_Actions;
|
-----------------------------------------------------------------------
-- util-encoders -- Encode/Decode streams and strings from one format to another
-- Copyright (C) 2009, 2010, 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 Ada.Streams;
with Ada.Finalization;
with Ada.Strings.Unbounded;
with Interfaces;
-- The <b>Util.Encoders</b> package defines the <b>Encoder</b> object
-- which represents a mechanism to transform a stream from one format into
-- another format.
package Util.Encoders is
pragma Preelaborate;
Not_Supported : exception;
Encoding_Error : exception;
-- Encoder/decoder for Base64 (RFC 4648)
BASE_64 : constant String := "base64";
-- Encoder/decoder for Base64 (RFC 4648) using the URL alphabet
-- (+ and / are replaced by - and _)
BASE_64_URL : constant String := "base64url";
-- Encoder/decoder for Base16 (RFC 4648)
BASE_16 : constant String := "base16";
HEX : constant String := "hex";
-- Encoder for SHA1 (RFC 3174)
HASH_SHA1 : constant String := "sha1";
-- ------------------------------
-- Encoder context object
-- ------------------------------
-- The <b>Encoder</b> provides operations to encode and decode
-- strings or stream of data from one format to another.
-- The <b>Encoded</b> contains two <b>Transformer</b>
-- which either <i>encodes</i> or <i>decodes</i> the stream.
type Encoder is tagged limited private;
-- Encodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be encoded.
-- Raises the <b>Not_Supported</b> exception if the encoding is not
-- supported.
function Encode (E : in Encoder;
Data : in String) return String;
-- Decodes the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> encoder.
--
-- Returns the encoded string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be decoded.
-- Raises the <b>Not_Supported</b> exception if the decoding is not
-- supported.
function Decode (E : in Encoder;
Data : in String) return String;
-- Create the encoder object for the specified encoding format.
function Create (Name : String) return Encoder;
-- ------------------------------
-- Stream Transformation interface
-- ------------------------------
-- The <b>Transformer</b> interface defines the operation to transform
-- a stream from one data format to another.
type Transformer is limited interface;
type Transformer_Access is access all Transformer'Class;
-- Transform the input stream represented by <b>Data</b> into
-- the output stream <b>Into</b>. The transformation made by
-- the object can be of any nature (Hex encoding, Base64 encoding,
-- Hex decoding, Base64 decoding, ...).
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
procedure Transform (E : in Transformer;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset) is abstract;
procedure Transform (E : in Transformer;
Data : in String;
Result : out Ada.Strings.Unbounded.Unbounded_String) is null;
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
function Transform (E : in Transformer'Class;
Data : in String) return String;
-- Transform the input string <b>Data</b> using the transformation
-- rules provided by the <b>E</b> transformer.
--
-- Returns the transformed string.
--
-- Raises the <b>Encoding_Error</b> exception if the source string
-- cannot be transformed
function Transform (E : in Transformer'Class;
Data : in Ada.Streams.Stream_Element_Array) return String;
-- Encode the value represented by <tt>Val</tt> in the stream array <tt>Into</tt> starting
-- at position <tt>Pos</tt> in that array. The value is encoded using LEB128 format, 7-bits
-- at a time until all non zero bits are written. The <tt>Last</tt> parameter is updated
-- to indicate the position of the last valid byte written in <tt>Into</tt>.
procedure Encode_LEB128 (Into : in out Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : in Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset);
-- Decode from the byte array <tt>From</tt> the value represented as LEB128 format starting
-- at position <tt>Pos</tt> in that array. After decoding, the <tt>Last</tt> index is updated
-- to indicate the last position in the byte array.
procedure Decode_LEB128 (From : in Ada.Streams.Stream_Element_Array;
Pos : in Ada.Streams.Stream_Element_Offset;
Val : out Interfaces.Unsigned_64;
Last : out Ada.Streams.Stream_Element_Offset);
private
type Encoder is new Ada.Finalization.Limited_Controlled with record
Encode : Transformer_Access := null;
Decode : Transformer_Access := null;
end record;
-- Delete the transformers
overriding
procedure Finalize (E : in out Encoder);
end Util.Encoders;
|
type T is array (Positive range <>) of Integer;
X : T := (1, 2, 3);
Y : T := X & (4, 5, 6); -- Concatenate X and (4, 5, 6)
|
------------------------------------------------------------------------------
-- Copyright (C) 2012-2020 by Heisenbug Ltd.
--
-- 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);
--------------------------------------------------------------------------------
-- Abstract class providing an iterator-like interface to implement different
-- access patterns.
--------------------------------------------------------------------------------
package Caches.Access_Patterns is
pragma Preelaborate;
-- The pattern class.
type Pattern is abstract tagged private;
-----------------------------------------------------------------------------
-- End_Of_Pattern
--
-- Returns True if the end of the pattern is reached. Can be overridden by
-- derived types if more complex pattern require a more sophisticated
-- end-of-pattern detection than a simple comparison with the count.
-----------------------------------------------------------------------------
function End_Of_Pattern (This : in Pattern) return Boolean;
-----------------------------------------------------------------------------
-- Next
--
-- Provides the next address of the access pattern.
-----------------------------------------------------------------------------
function Next (This_Ptr : access Pattern) return Address is abstract;
private
-- The pattern class.
type Pattern is abstract tagged
record
Length : Bytes;
Count : Unsigned;
Start_Address : Address;
end record;
end Caches.Access_Patterns;
|
-----------------------------------------------------------------------
-- awa-storages-stores-files -- File system store
-- 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 Ada.Streams;
with Ada.Directories;
with Interfaces;
with Util.Files;
with Util.Encoders;
with Util.Encoders.Base64;
package body AWA.Storages.Stores.Files is
-- ------------------------------
-- Create a file storage service and use the <tt>Root</tt> directory to store the files.
-- ------------------------------
function Create_File_Store (Root : in String) return Store_Access is
Result : constant File_Store_Access := new File_Store '(Len => Root'Length,
Root => Root);
begin
return Result.all'Access;
end Create_File_Store;
-- ------------------------------
-- Build a path where the file store represented by <tt>Store</tt> is saved.
-- ------------------------------
function Get_Path (Storage : in File_Store;
Store : in AWA.Storages.Models.Storage_Ref'Class) return String is
use Interfaces;
use type Ada.Streams.Stream_Element_Offset;
T : Util.Encoders.Base64.Encoder;
Buffer : Ada.Streams.Stream_Element_Array (1 .. 10);
R : Ada.Streams.Stream_Element_Array (1 .. 32);
Last : Ada.Streams.Stream_Element_Offset;
Encoded : Ada.Streams.Stream_Element_Offset;
Pos : Positive := 1;
Res : String (1 .. 16 + 5);
Workspace_Id : constant ADO.Identifier := Store.Get_Workspace.Get_Id;
begin
Util.Encoders.Encode_LEB128 (Buffer, Buffer'First, Unsigned_64 (Workspace_Id), Last);
Util.Encoders.Encode_LEB128 (Buffer, Last, Unsigned_64 (Store.Get_Id), Last);
T.Transform (Data => Buffer (1 .. Last),
Into => R, Last => Last,
Encoded => Encoded);
for I in 1 .. Last loop
Res (Pos) := Character'Val (R (I));
Pos := Pos + 1;
if (I mod 2) = 0 and I /= Last then
Res (Pos) := '/';
Pos := Pos + 1;
end if;
end loop;
return Util.Files.Compose (Storage.Root, Res (1 .. Pos - 1));
end Get_Path;
-- ------------------------------
-- Save the file represented by the `Path` variable into a store and associate that
-- content with the storage reference represented by `Into`.
-- ------------------------------
procedure Save (Storage : in File_Store;
Session : in out ADO.Sessions.Master_Session;
Into : in out AWA.Storages.Models.Storage_Ref'Class;
Path : in String) is
pragma Unreferenced (Session);
Store : constant String := Storage.Get_Path (Into);
Dir : constant String := Ada.Directories.Containing_Directory (Store);
begin
Ada.Directories.Create_Path (Dir);
Ada.Directories.Copy_File (Source_Name => Path,
Target_Name => Store,
Form => "all");
end Save;
procedure Load (Storage : in File_Store;
Session : in out ADO.Sessions.Session'Class;
From : in AWA.Storages.Models.Storage_Ref'Class;
Into : in out Storage_File) is
pragma Unreferenced (Session);
Store : constant String := Storage.Get_Path (From);
begin
Into.Path := Ada.Strings.Unbounded.To_Unbounded_String (Store);
end Load;
-- Create a storage
procedure Create (Storage : in File_Store;
Session : in out ADO.Sessions.Master_Session;
From : in AWA.Storages.Models.Storage_Ref'Class;
Into : in out AWA.Storages.Storage_File) is
Store : constant String := Storage.Get_Path (From);
Dir : constant String := Ada.Directories.Containing_Directory (Store);
begin
Ada.Directories.Create_Path (Dir);
Into.Path := Ada.Strings.Unbounded.To_Unbounded_String (Store);
end Create;
-- ------------------------------
-- Delete the content associate with the storage represented by `From`.
-- ------------------------------
procedure Delete (Storage : in File_Store;
Session : in out ADO.Sessions.Master_Session;
From : in out AWA.Storages.Models.Storage_Ref'Class) is
pragma Unreferenced (Session);
Store : constant String := Storage.Get_Path (From);
begin
if Ada.Directories.Exists (Store) then
Ada.Directories.Delete_File (Store);
end if;
end Delete;
end AWA.Storages.Stores.Files;
|
-- auto generated, do not edit
with GNAT.Compiler_Version;
with GNAT.Regpat;
with Ada.Text_IO;
with Ada.Strings.Fixed;
with Ada.Strings;
procedure Ver_GNAT is
--
-- gnatver.ads
--
type Variant_t is
(GNAT_UNKNOWN,
GNAT_FSF,
GNAT_GPL,
GNAT_PRO,
GNAT_GAP);
type Version_t is record
Variant : Variant_t := GNAT_UNKNOWN;
Major : Natural := 0;
Minor : Natural := 0;
Patch : Natural := 0;
end record;
procedure Decode
(Version : out Version_t;
Image : in String);
procedure Decode_Current
(Version : out Version_t);
--
-- gnatver.adb
--
package Ver is new GNAT.Compiler_Version;
use type GNAT.Regpat.Match_Location;
Regex_FSF : constant String := "^(GNAT Version: ){0,1}([0-9]).([0-9]).([0-9])";
Regex_GPL : constant String := "^(GNAT Version: ){0,1}GPL [0-9]+ \(([0-9]{4})([0-9]{2})([0-9]{2})\)";
Regex_GAP : constant String := "^(GNAT Version: ){0,1}GAP [0-9]+ \(([0-9]{4})([0-9]{2})([0-9]{2})\)";
Regex_Pro : constant String := "^(GNAT Version: ){0,1}Pro ([0-9]).([0-9]).([0-9])";
procedure Decode
(Version : out Version_t;
Image : in String)
is
Matches : GNAT.Regpat.Match_Array (0 .. 4);
begin
-- check FSF
GNAT.Regpat.Match
(Expression => Regex_FSF,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_FSF;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check GPL
GNAT.Regpat.Match
(Expression => Regex_GPL,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_GPL;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check GAP
GNAT.Regpat.Match
(Expression => Regex_GAP,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_GAP;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check Pro
GNAT.Regpat.Match
(Expression => Regex_Pro,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_PRO;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
end Decode;
procedure Decode_Current
(Version : out Version_t) is
begin
Decode
(Version => Version,
Image => Ver.Version);
end Decode_Current;
-- ver_gnat.adb
function To_String (Number : Integer) return String is
begin
return Ada.Strings.Fixed.Trim (Integer'Image (Number), Ada.Strings.Left);
end To_String;
Version : Version_t;
begin
Decode_Current (Version);
Ada.Text_IO.Put_Line
(Variant_t'Image (Version.Variant) & " " &
To_String (Version.Major) & "." &
To_String (Version.Minor) & "." &
To_String (Version.Patch));
end Ver_GNAT;
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Ada.Unchecked_Deallocation;
with Ada.Strings.Unbounded;
package body Symbols is
function Min (Left, Right : Symbol) return Symbol
renames Symbol'Min;
function Max (Left, Right : Symbol) return Symbol
renames Symbol'Max;
---------
-- "*" --
---------
function "*" (Left, Right : Symbol_Set) return Boolean is
L : Symbol_Ranges renames Left.Node.Ranges;
R : Symbol_Ranges renames Right.Node.Ranges;
begin
if L'Length > R'Length then
return Right * Left;
elsif L'Length = 0 then
return False;
end if;
declare
L_Wide : constant Symbol_Range :=
(L (L'First).Lower, L (L'Last).Upper);
R_Wide : constant Symbol_Range :=
(R (R'First).Lower, R (R'Last).Upper);
begin
if not (L_Wide * R_Wide) then
return False;
end if;
end;
for I in L'Range loop
declare
F : Positive := R'First;
T : Natural := R'Last;
J : Natural;
begin
while F <= T loop
J := (F + T) / 2;
if R (J).Lower > L (I).Upper then
T := J - 1;
elsif R (J).Upper < L (I).Lower then
F := J + 1;
else
return True;
end if;
end loop;
end;
end loop;
return False;
end "*";
---------
-- "*" --
---------
function "*" (Left, Right : Symbol_Range) return Boolean is
begin
if Left.Upper < Right.Lower or Left.Lower > Right.Upper then
return False; -- no intersect
else
return True; -- intersect
end if;
end "*";
----------
-- "or" --
----------
function "or" (Left, Right : Symbol_Range) return Symbol_Range is
begin
return (Min (Left.Lower, Right.Lower), Max (Left.Upper, Right.Upper));
end "or";
-----------
-- "and" --
-----------
function "and" (Left, Right : Symbol_Range) return Symbol_Range is
begin
return (Max (Left.Lower, Right.Lower), Min (Left.Upper, Right.Upper));
end "and";
---------
-- "-" --
---------
function "-" (Left, Right : Symbol_Set) return Symbol_Set is
L : Symbol_Ranges renames Left.Node.Ranges;
R : Symbol_Ranges renames Right.Node.Ranges;
Max_Len : constant Natural := L'Length + 2 * R'Length;
Result : Symbol_Ranges (1 .. Max_Len);
Last : Natural := 0;
Index : Positive;
Start : Symbol;
procedure New_Range (Lower, Upper : Symbol) is
begin
if Lower <= Upper then
Last := Last + 1;
Result (Last) := (Lower, Upper);
end if;
end New_Range;
begin
for I in L'Range loop
Start := L (I).Lower;
-- Binary search max Index of range less then Start
declare
F : Positive := R'First;
T : Natural := R'Last;
J : Natural;
begin
while F <= T loop
J := (F + T) / 2;
if R (J).Lower > Start then
T := J - 1;
elsif R (J).Upper < Start then
F := J + 1;
else
T := J;
exit;
end if;
end loop;
Index := Positive'Max (T, R'First);
end;
-- End of binary search
while Index in R'Range and then R (Index).Lower <= L (I).Upper loop
if R (Index) * L (I) then
if R (Index).Lower /= 0 then
New_Range (Start, R (Index).Lower - 1);
end if;
Start := R (Index).Upper + 1;
end if;
Index := Index + 1;
end loop;
if Start /= 0 then
New_Range (Start, L (I).Upper);
end if;
end loop;
return (F.Controlled with new Set_Node'(Last, 1, Result (1 .. Last)));
end "-";
-----------
-- "and" --
-----------
function "and" (Left, Right : Symbol_Set) return Symbol_Set is
L : Symbol_Ranges renames Left.Node.Ranges;
R : Symbol_Ranges renames Right.Node.Ranges;
Max_Len : constant Natural := L'Length + R'Length; -- actual Max (R,L)
Result : Symbol_Ranges (1 .. Max_Len);
Last : Natural := 0;
begin
for I in L'Range loop
for J in R'Range loop
if R (J) * L (I) then
Last := Last + 1;
Result (Last) := R (J) and L (I);
end if;
end loop;
end loop;
return (F.Controlled with new Set_Node'(Last, 1, Result (1 .. Last)));
end "and";
----------
-- "or" --
----------
function "or" (Left, Right : Symbol_Set) return Symbol_Set is
L : Symbol_Ranges renames Left.Node.Ranges;
R : Symbol_Ranges renames Right.Node.Ranges;
Max_Len : constant Natural := L'Length + R'Length;
Result : Symbol_Ranges (1 .. Max_Len);
Last : Positive := 1;
I, J : Positive := 1;
procedure New_Range (R : Symbol_Range) is
begin
if Result (Last) * R then
Result (Last) := Result (Last) or R;
else
Last := Last + 1;
Result (Last) := R;
end if;
end New_Range;
begin
if L'Length = 0 then
return Right;
elsif R'Length = 0 then
return Left;
end if;
Result (Last) := (Min (R (J).Lower, L (I).Lower),
Min (R (J).Lower, L (I).Lower));
while I in L'Range or J in R'Range loop
if I in L'Range then
if J in R'Range then
if R (J).Lower < L (I).Lower then
New_Range (R (J));
J := J + 1;
else
New_Range (L (I));
I := I + 1;
end if;
else
New_Range (L (I));
I := I + 1;
end if;
else
New_Range (R (J));
J := J + 1;
end if;
end loop;
return (F.Controlled with new Set_Node'(Last, 1, Result (1 .. Last)));
end "or";
------------
-- Adjust --
------------
procedure Adjust (Object : in out Symbol_Set) is
begin
if Object.Node /= null then
Object.Node.Count := Object.Node.Count + 1;
end if;
end Adjust;
--------------------------
-- Distinct_Symbol_Sets --
--------------------------
function Distinct_Symbol_Sets
(Next : in Symbol_Set_Array) return Symbol_Set_Array is
begin
for I in Next'Range loop
for J in I + 1 .. Next'Last loop
if not Is_Empty (Next (I))
and then not Is_Empty (Next (J))
and then Next (I) * Next (J)
then
declare
A : constant Symbol_Set := Next (I) - Next (J);
B : constant Symbol_Set := Next (J) - Next (I);
C : constant Symbol_Set := Next (J) and Next (I);
Index: Natural := 1;
Sets : Symbol_Set_Array (1 .. Next'Length + 1);
procedure Append (S : Symbol_Set_Array) is
begin
Sets (Index .. Index + S'Length - 1) := S;
Index := Index + S'Length;
end Append;
begin
Append (Next (Next'First .. I - 1));
if not Is_Empty (A) then
Append ((1 => A));
end if;
Append (Next (I + 1 .. J - 1));
if not Is_Empty (B) then
Append ((1 => B));
end if;
Append (Next (J + 1 .. Next'Last));
Append ((1 => C));
Index := Index - 1;
return Distinct_Symbol_Sets (Sets (1 .. Index));
end;
end if;
end loop;
end loop;
return Next;
end Distinct_Symbol_Sets;
--------------
-- Finalize --
--------------
procedure Finalize (Object : in out Symbol_Set) is
procedure Free is
new Ada.Unchecked_Deallocation (Set_Node, Node_Access);
begin
if Object.Node /= null then
Object.Node.Count := Object.Node.Count - 1;
if Object.Node.Count = 0 then
Free (Object.Node);
end if;
end if;
end Finalize;
--------------
-- Is_Empty --
--------------
function Is_Empty (Left : Symbol_Set) return Boolean is
begin
return Left.Node.Length = 0;
end Is_Empty;
--------------
-- Is_Equal --
--------------
function Is_Equal (Left, Right : Symbol_Set) return Boolean is
begin
return Left.Node.Ranges = Right.Node.Ranges;
end Is_Equal;
-----------------
-- Range_Image --
-----------------
function Range_Image
(Left : Symbol_Set;
Indent : String) return String
is
use Ada.Strings.Unbounded;
L : Symbol_Ranges renames Left.Node.Ranges;
NL : constant Character := ASCII.LF;
Result : Unbounded_String;
begin
Result := Indent & To_Unbounded_String ("when ");
for I in L'Range loop
if I /= L'First then
Result := Result & NL & Indent & " | ";
end if;
if L (I).Lower = L (I).Upper then
Result := Result & Symbol'Image (L (I).Lower);
else
Result := Result
& Symbol'Image (L (I).Lower) & " .."
& Symbol'Image (L (I).Upper);
end if;
end loop;
return To_String (Result);
end Range_Image;
--------------
-- To_Range --
--------------
function To_Range (Single : Symbol) return Symbol_Set is
begin
return (F.Controlled with new Set_Node'(1, 1, (1 => (Single, Single))));
end To_Range;
--------------
-- To_Range --
--------------
function To_Range (Sequence : Symbol_Array) return Symbol_Set is
Result : Symbol_Set;
begin
for I in Sequence'Range loop
Result := Result or To_Range (Sequence (I));
end loop;
return Result;
end To_Range;
--------------
-- To_Range --
--------------
function To_Range (Lower, Upper : Symbol) return Symbol_Set is
begin
return (F.Controlled with new Set_Node'(1, 1, (1 => (Lower, Upper))));
end To_Range;
end Symbols;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
-- Copyright 2016 Steven Stewart-Gallus
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-- implied. See the License for the specific language governing
-- permissions and limitations under the License.
with System;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with Libc.Stdint;
with Libc.Stddef;
package Pulse.Sample with
Spark_Mode => Off is
-- unsupported macro: PA_CHANNELS_MAX 32U
-- unsupported macro: PA_RATE_MAX (48000U*4U)
-- unsupported macro: PA_SAMPLE_S16NE PA_SAMPLE_S16LE
-- unsupported macro: PA_SAMPLE_FLOAT32NE PA_SAMPLE_FLOAT32LE
-- unsupported macro: PA_SAMPLE_S32NE PA_SAMPLE_S32LE
-- unsupported macro: PA_SAMPLE_S24NE PA_SAMPLE_S24LE
-- unsupported macro: PA_SAMPLE_S24_32NE PA_SAMPLE_S24_32LE
-- unsupported macro: PA_SAMPLE_S16RE PA_SAMPLE_S16BE
-- unsupported macro: PA_SAMPLE_FLOAT32RE PA_SAMPLE_FLOAT32BE
-- unsupported macro: PA_SAMPLE_S32RE PA_SAMPLE_S32BE
-- unsupported macro: PA_SAMPLE_S24RE PA_SAMPLE_S24BE
-- unsupported macro: PA_SAMPLE_S24_32RE PA_SAMPLE_S24_32BE
-- unsupported macro: PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
-- unsupported macro: PA_SAMPLE_U8 PA_SAMPLE_U8
-- unsupported macro: PA_SAMPLE_ALAW PA_SAMPLE_ALAW
-- unsupported macro: PA_SAMPLE_ULAW PA_SAMPLE_ULAW
-- unsupported macro: PA_SAMPLE_S16LE PA_SAMPLE_S16LE
-- unsupported macro: PA_SAMPLE_S16BE PA_SAMPLE_S16BE
-- unsupported macro: PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE
-- unsupported macro: PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE
-- unsupported macro: PA_SAMPLE_S32LE PA_SAMPLE_S32LE
-- unsupported macro: PA_SAMPLE_S32BE PA_SAMPLE_S32BE
-- unsupported macro: PA_SAMPLE_S24LE PA_SAMPLE_S24LE
-- unsupported macro: PA_SAMPLE_S24BE PA_SAMPLE_S24BE
-- unsupported macro: PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE
-- unsupported macro: PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE
-- unsupported macro: PA_SAMPLE_SPEC_SNPRINT_MAX 32
-- unsupported macro: PA_BYTES_SNPRINT_MAX 11
-- arg-macro: procedure pa_sample_format_is_ne (f)
-- pa_sample_format_is_le(f)
-- arg-macro: procedure pa_sample_format_is_re (f)
-- pa_sample_format_is_be(f)
subtype pa_sample_format is unsigned;
PA_SAMPLE_U8 : constant pa_sample_format := 0;
PA_SAMPLE_ALAW : constant pa_sample_format := 1;
PA_SAMPLE_ULAW : constant pa_sample_format := 2;
PA_SAMPLE_S16LE : constant pa_sample_format := 3;
PA_SAMPLE_S16BE : constant pa_sample_format := 4;
PA_SAMPLE_FLOAT32LE : constant pa_sample_format := 5;
PA_SAMPLE_FLOAT32BE : constant pa_sample_format := 6;
PA_SAMPLE_S32LE : constant pa_sample_format := 7;
PA_SAMPLE_S32BE : constant pa_sample_format := 8;
PA_SAMPLE_S24LE : constant pa_sample_format := 9;
PA_SAMPLE_S24BE : constant pa_sample_format := 10;
PA_SAMPLE_S24_32LE : constant pa_sample_format := 11;
PA_SAMPLE_S24_32BE : constant pa_sample_format := 12;
PA_SAMPLE_MAX : constant pa_sample_format := 13;
PA_SAMPLE_INVALID : constant pa_sample_format :=
-1; -- /usr/include/pulse/sample.h:136
subtype pa_sample_format_t is pa_sample_format;
type pa_sample_spec is record
format : aliased pa_sample_format_t; -- /usr/include/pulse/sample.h:251
rate : aliased Libc.Stdint.uint32_t; -- /usr/include/pulse/sample.h:254
channels : aliased Libc.Stdint
.uint8_t; -- /usr/include/pulse/sample.h:257
end record;
subtype pa_usec_t is
Libc.Stdint.uint64_t; -- /usr/include/pulse/sample.h:262
function pa_bytes_per_second
(spec : pa_sample_spec)
return Libc.Stddef.size_t; -- /usr/include/pulse/sample.h:265
pragma Import (C, pa_bytes_per_second, "pa_bytes_per_second");
function pa_frame_size
(spec : pa_sample_spec)
return Libc.Stddef.size_t; -- /usr/include/pulse/sample.h:268
pragma Import (C, pa_frame_size, "pa_frame_size");
function pa_sample_size
(spec : pa_sample_spec)
return Libc.Stddef.size_t; -- /usr/include/pulse/sample.h:271
pragma Import (C, pa_sample_size, "pa_sample_size");
function pa_sample_size_of_format
(f : pa_sample_format_t)
return Libc.Stddef.size_t; -- /usr/include/pulse/sample.h:275
pragma Import (C, pa_sample_size_of_format, "pa_sample_size_of_format");
function pa_bytes_to_usec
(length : Libc.Stdint.uint64_t;
spec : pa_sample_spec)
return pa_usec_t; -- /usr/include/pulse/sample.h:280
pragma Import (C, pa_bytes_to_usec, "pa_bytes_to_usec");
function pa_usec_to_bytes
(t : pa_usec_t;
spec : pa_sample_spec)
return Libc.Stddef.size_t; -- /usr/include/pulse/sample.h:285
pragma Import (C, pa_usec_to_bytes, "pa_usec_to_bytes");
procedure pa_sample_spec_init
(spec : in out pa_sample_spec); -- /usr/include/pulse/sample.h:290
pragma Import (C, pa_sample_spec_init, "pa_sample_spec_init");
function pa_sample_spec_valid
(spec : pa_sample_spec) return int; -- /usr/include/pulse/sample.h:293
pragma Import (C, pa_sample_spec_valid, "pa_sample_spec_valid");
function pa_sample_spec_equal
(a : System.Address;
b : System.Address) return int; -- /usr/include/pulse/sample.h:296
pragma Import (C, pa_sample_spec_equal, "pa_sample_spec_equal");
function pa_sample_format_to_string
(f : pa_sample_format_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/sample.h:299
pragma Import (C, pa_sample_format_to_string, "pa_sample_format_to_string");
function pa_parse_sample_format
(format : Interfaces.C.Strings.chars_ptr)
return pa_sample_format_t; -- /usr/include/pulse/sample.h:302
pragma Import (C, pa_parse_sample_format, "pa_parse_sample_format");
function pa_sample_spec_snprint
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t;
spec : pa_sample_spec)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/sample.h:312
pragma Import (C, pa_sample_spec_snprint, "pa_sample_spec_snprint");
function pa_bytes_snprint
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t;
v : unsigned)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/sample.h:322
pragma Import (C, pa_bytes_snprint, "pa_bytes_snprint");
function pa_sample_format_is_le
(f : pa_sample_format_t) return int; -- /usr/include/pulse/sample.h:326
pragma Import (C, pa_sample_format_is_le, "pa_sample_format_is_le");
function pa_sample_format_is_be
(f : pa_sample_format_t) return int; -- /usr/include/pulse/sample.h:330
pragma Import (C, pa_sample_format_is_be, "pa_sample_format_is_be");
end Pulse.Sample;
|
with S_Expr.Parser, Ada.Text_IO;
procedure Test_S_Expr is
procedure Put_Line(Indention: Natural; Line: String) is
begin
for I in 1 .. 3*Indention loop
Ada.Text_IO.Put(" ");
end loop;
Ada.Text_IO.Put_Line(Line);
end Put_Line;
package S_Exp is new S_Expr(Put_Line);
package S_Par is new S_Exp.Parser;
Input: String := "((data ""quoted data"" 123 4.5)" &
"(data (!@# (4.5) ""(more"" ""data)"")))";
Expression_List: S_Exp.List_Of_Data := S_Par.Parse(Input);
begin
Expression_List.First.Print(Indention => 0);
-- Parse will output a list of S-Expressions. We need the first Expression.
end Test_S_Expr;
|
with
ada.Tags;
package body lace.Response
is
function Name (Self : in Item) return String
is
begin
return ada.Tags.expanded_Name (Item'Class (Self)'Tag);
end Name;
end lace.Response;
|
-- part of OpenGLAda, (c) 2020 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Buffers;
with GL.Types.Colors;
with GL.Fixed.Matrix;
with GL.Images;
with GL.Immediate;
with GL.Objects.Textures.Targets;
with GL.Pixels;
with GL.Toggles;
with GL.Types;
with GL_Test.Display_Backend;
procedure Images_Test_JPG is
use GL.Fixed.Matrix;
use GL.Types;
use GL.Types.Doubles;
Texture : GL.Objects.Textures.Texture;
begin
GL_Test.Display_Backend.Init;
GL_Test.Display_Backend.Open_Window (1000, 498);
GL.Images.Load_File_To_Texture
("../ada2012-color.jpg", Texture, GL.Pixels.RGB);
Projection.Load_Identity;
Projection.Apply_Orthogonal (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
GL.Buffers.Set_Color_Clear_Value (Colors.Color'(1.0, 0.0, 0.0, 1.0));
while GL_Test.Display_Backend.Window_Opened loop
GL.Buffers.Clear ((others => True));
GL.Objects.Textures.Set_Active_Unit (0);
GL.Toggles.Enable (GL.Toggles.Texture_2D);
GL.Objects.Textures.Targets.Texture_2D.Bind (Texture);
declare
Token : GL.Immediate.Input_Token := GL.Immediate.Start (Quads);
begin
GL.Immediate.Set_Texture_Coordinates (Vector2'(0.0, 0.0));
Token.Add_Vertex (Vector2'(-1.0, -1.0));
GL.Immediate.Set_Texture_Coordinates (Vector2'(0.0, 1.0));
Token.Add_Vertex (Vector2'(-1.0, 1.0));
GL.Immediate.Set_Texture_Coordinates (Vector2'(1.0, 1.0));
Token.Add_Vertex (Vector2'(1.0, 1.0));
GL.Immediate.Set_Texture_Coordinates (Vector2'(1.0, 0.0));
Token.Add_Vertex (Vector2'(1.0, -1.0));
end;
GL.Toggles.Disable (GL.Toggles.Texture_2D);
GL_Test.Display_Backend.Swap_Buffers;
GL_Test.Display_Backend.Poll_Events;
end loop;
GL_Test.Display_Backend.Shutdown;
end Images_Test_JPG;
|
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 pathfindList 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;
procedure SkipSpaces is
C : Character;
Eol : Boolean;
begin
loop
Look_Ahead(C, Eol);
exit when Eol or C /= ' ';
Get(C);
end loop;
end;
type a is Array (Integer range <>) of Integer;
type a_PTR is access a;
function pathfind_aux(cache : in a_PTR; tab : in a_PTR; len : in Integer; pos : in Integer) return Integer is
posval : Integer;
out0 : Integer;
oneval : Integer;
begin
if pos >= len - 1
then
return 0;
else
if cache(pos) /= (-1)
then
return cache(pos);
else
cache(pos) := len * 2;
posval := pathfind_aux(cache, tab, len, tab(pos));
oneval := pathfind_aux(cache, tab, len, pos + 1);
out0 := 0;
if posval < oneval
then
out0 := 1 + posval;
else
out0 := 1 + oneval;
end if;
cache(pos) := out0;
return out0;
end if;
end if;
end;
function pathfind(tab : in a_PTR; len : in Integer) return Integer is
cache : a_PTR;
begin
cache := new a (0..len - 1);
for i in integer range 0..len - 1 loop
cache(i) := (-1);
end loop;
return pathfind_aux(cache, tab, len, 0);
end;
tmp : Integer;
tab : a_PTR;
result : Integer;
len : Integer;
begin
len := 0;
Get(len);
SkipSpaces;
tab := new a (0..len - 1);
for i in integer range 0..len - 1 loop
tmp := 0;
Get(tmp);
SkipSpaces;
tab(i) := tmp;
end loop;
result := pathfind(tab, len);
PInt(result);
end;
|
-- RUN: %llvmgcc -c %s
procedure Array_Size is
subtype S is String (1 .. 2);
type R is record
A : S;
end record;
X : R;
begin
null;
end;
|
-- { dg-do compile }
package double_record_extension1 is
type T1(n: natural) is tagged record
s1: string (1..n);
end record;
type T2(j,k: natural) is new T1(j) with record
s2: string (1..k);
end record;
type T3 is new T2 (10, 10) with null record;
end double_record_extension1;
|
with EU_Projects.Nodes.Timed_Nodes.Milestones;
with EU_Projects.Nodes.Action_Nodes.WPs;
with EU_Projects.Nodes.Timed_Nodes.Deliverables;
with EU_Projects.Nodes.Action_Nodes.Tasks;
with EU_Projects.Identifiers;
package EU_Projects.Event_Names is
use EU_Projects.Nodes.Timed_Nodes;
use EU_Projects.Nodes.Action_Nodes;
function Milestone_Var (Label : Identifiers.Identifier)
return String;
function Deliverable_Var (Parent_Task : Tasks.Project_Task_Access;
Label : Identifiers.Identifier)
return String;
type Event_Class is (Start_Time, End_Time, Duration_Time);
function Task_Var (Parent_WP : WPs.WP_Label;
Label : Tasks.Task_Label;
Event : Event_Class)
return String;
function WP_Var
(Label : WPs.WP_Label;
Event : Event_Class)
return String;
end EU_Projects.Event_Names;
|
-- Abstract :
--
-- Type and operations for building a grammar directly in Ada source.
--
-- Copyright (C) 2003, 2013 - 2015, 2017, 2018 Free Software Foundation, Inc.
--
-- This file is part of the WisiToken package.
--
-- The WisiToken package is free software; you can redistribute it
-- and/or modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 3, or
-- (at your option) any later version. The WisiToken package is
-- distributed in the hope that it will be useful, but WITHOUT ANY
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-- License for more details. You should have received a copy of the
-- GNU General Public License distributed with the WisiToken package;
-- see file GPL.txt. 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.
pragma License (Modified_GPL);
with WisiToken.Productions;
with WisiToken.Syntax_Trees;
package WisiToken.Wisi_Ada is
function Only (Item : in Token_ID) return WisiToken.Token_ID_Arrays.Vector;
function "&" (Left : in Token_ID; Right : in Token_ID) return WisiToken.Token_ID_Arrays.Vector;
function "+"
(Tokens : in WisiToken.Token_ID_Arrays.Vector;
Action : in WisiToken.Syntax_Trees.Semantic_Action)
return WisiToken.Productions.Right_Hand_Side;
function "+"
(Tokens : in Token_ID;
Action : in WisiToken.Syntax_Trees.Semantic_Action)
return WisiToken.Productions.Right_Hand_Side;
function "+" (Action : in WisiToken.Syntax_Trees.Semantic_Action) return WisiToken.Productions.Right_Hand_Side;
-- Create the right hand side of a production.
function Only (Item : in WisiToken.Productions.Right_Hand_Side) return WisiToken.Productions.RHS_Arrays.Vector;
function "+" (Item : in WisiToken.Productions.Right_Hand_Side) return WisiToken.Productions.RHS_Arrays.Vector
renames Only;
function "or"
(Left : in WisiToken.Productions.Instance;
Right : in WisiToken.Productions.Right_Hand_Side)
return WisiToken.Productions.Instance;
function "<="
(LHS : in Token_ID;
RHSs : in WisiToken.Productions.RHS_Arrays.Vector)
return WisiToken.Productions.Instance;
function Only (Subject : in WisiToken.Productions.Instance) return WisiToken.Productions.Prod_Arrays.Vector;
function "+" (Subject : in WisiToken.Productions.Instance) return WisiToken.Productions.Prod_Arrays.Vector
renames Only;
-- First production in a grammar.
function "and"
(Left : in WisiToken.Productions.Instance;
Right : in WisiToken.Productions.Instance)
return WisiToken.Productions.Prod_Arrays.Vector;
function "and"
(Left : in WisiToken.Productions.Prod_Arrays.Vector;
Right : in WisiToken.Productions.Instance)
return WisiToken.Productions.Prod_Arrays.Vector;
function "and"
(Left : in WisiToken.Productions.Prod_Arrays.Vector;
Right : in WisiToken.Productions.Prod_Arrays.Vector)
return WisiToken.Productions.Prod_Arrays.Vector;
-- Create a grammar
end WisiToken.Wisi_Ada;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with GBA.Memory.IO_Registers;
package GBA.Input is
type Key is
( A_Button
, B_Button
, Select_Button
, Start_Button
, Right_Direction
, Left_Direction
, Up_Direction
, Down_Direction
, Left_Shoulder
, Right_Shoulder
)
with Size => 16;
for Key use
( A_Button => 0
, B_Button => 1
, Select_Button => 2
, Start_Button => 3
, Right_Direction => 4
, Left_Direction => 5
, Up_Direction => 6
, Down_Direction => 7
, Left_Shoulder => 8
, Right_Shoulder => 9
);
type Key_Flags is mod 2**10
with Size => 16;
type Key_Set is array (Key) of Boolean
with Pack, Size => 16;
function To_Flags (S : Key_Set) return Key_Flags
with Inline_Always;
function To_Flags (K : Key) return Key_Flags
with Inline_Always;
function "or" (K1, K2 : Key) return Key_Flags
with Pure_Function, Inline_Always;
function "or" (F : Key_Flags; K : Key) return Key_Flags
with Pure_Function, Inline_Always;
function Read_Key_State return Key_Flags
with Inline_Always;
function Read_Key_State return Key_Set
with Inline_Always;
procedure Disable_Input_Interrupt_Request;
procedure Request_Interrupt_If_Key_Pressed(K : Key);
procedure Request_Interrupt_If_Any_Pressed(F : Key_Flags);
procedure Request_Interrupt_If_All_Pressed(F : Key_Flags);
-- Unsafe Interface --
type Key_Control_Op is
( Disjunction, Conjunction );
for Key_Control_Op use
( Disjunction => 0, Conjunction => 1 );
type Key_Control_Info is
record
Flags : Key_Flags;
Interrupt_Requested : Boolean;
Interrupt_Op : Key_Control_Op;
end record
with Size => 16;
for Key_Control_Info use
record
Flags at 0 range 0 .. 9;
Interrupt_Requested at 0 range 14 .. 14;
Interrupt_Op at 0 range 15 .. 15;
end record;
use GBA.Memory.IO_Registers;
Key_Input : Key_Flags
with Import, Address => KEYINPUT;
Key_Control : Key_Control_Info
with Import, Address => KEYCNT;
end GBA.Input; |
with Glib; use Glib;
with Gdk.Event; use Gdk.Event;
with Gtk.Widget, Gtk.Handlers; use Gtk.Widget, Gtk.Handlers;
package GA_Sine_Package is
package Handlers is new Gtk.Handlers.Callback
(Widget_Type => Gtk_Widget_Record);
package Return_Handlers is new Gtk.Handlers.Return_Callback
(Widget_Type => Gtk_Widget_Record,
Return_Type => Boolean);
function Delete_Event
(Widget : access Gtk_Widget_Record'Class;
Event : Gdk_Event) return Boolean;
procedure Destroy (Widget : access Gtk_Widget_Record'Class);
end GA_Sine_Package;
|
with Ada.Characters.Conversions;
package body Lal_Adapter is
package Acc renames Ada.Characters.Conversions;
-----------
-- PRIVATE:
-----------
function To_String (Item : in Wide_String) return String is
(Acc.To_String (Item, Substitute => ' '));
-----------
-- PRIVATE:
-----------
function To_String (Item : in Wide_Wide_String) return String is
(Acc.To_String (Item, Substitute => ' '));
-----------
-- PRIVATE:
-----------
function To_Quoted_String (Item : in String) return String is
('"' & Item & '"');
-----------
-- PRIVATE:
-----------
function To_Chars_Ptr (Item : in Wide_String) return Interfaces.C.Strings.chars_ptr is
(Interfaces.C.Strings.New_String (To_String(Item)));
-----------
-- PRIVATE:
-----------
function Spaceless_Image (Item : in Natural) return String is
Leading_Space_Image : constant String := Item'Image;
begin
return Leading_Space_Image (2 .. Leading_Space_Image'Last);
end;
-----------
-- PRIVATE:
-----------
function To_String
(Id : in IC.int;
Kind : in ID_Kind)
return String
is
function Add_Prefix_To (Item : in String) return String is
begin
case Kind is
when Unit_ID_Kind =>
return "Unit_" & Item;
when Element_ID_Kind =>
return "LAL_Node_" & Item;
end case;
end Add_Prefix_To;
use type IC.int;
begin
if anhS.Is_Empty (ID) then
return "(none)";
elsif not anhS.Is_Valid (ID) then
return "***Invalid ID***";
else
return Add_Prefix_To (Spaceless_Image (Natural (Id)));
end if;
exception
when Constraint_Error =>
raise Program_Error with "Id =>" & Id'Image & ", Kind => " & Kind'Image;
end To_String;
-----------
-- PRIVATE:
-----------
function To_Dot_ID_Type
(Id : in IC.int;
Kind : in ID_Kind)
return Dot.ID_Type is
(Dot.To_ID_Type (To_String (Id, Kind)));
------------
-- EXPORTED:
------------
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in Output_Accesses_Record;
Value : in String) is
begin
Dot_Label.Add_3_Col_Cell(Value);
Outputs.Text.Put_Indented_Line (Value);
end;
------------
-- EXPORTED:
------------
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in Output_Accesses_Record;
Name : in String;
Value : in String) is
begin
Dot_Label.Add_Eq_Row (L => Name, R => Value);
Outputs.Text.Put_Indented_Line (Name & " => " & Value);
end;
------------
-- EXPORTED:
------------
procedure Add_To_Dot_Label
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in Output_Accesses_Record;
Name : in String;
Value : in Boolean) is
begin
if Value then
declare
Value_String : constant String := Value'Image;
begin
Dot_Label.Add_Eq_Row (L => Name, R => Value_String);
Outputs.Text.Put_Indented_Line (Name & " => " & Value_String);
end;
end if;
end;
------------
-- EXPORTED:
------------
procedure Add_Dot_Edge
(Outputs : in Output_Accesses_Record;
From : in IC.int;
From_Kind : in ID_Kind;
To : in IC.int;
To_Kind : in ID_Kind;
Label : in String)
is
Edge_Stmt : Dot.Edges.Stmts.Class; -- Initialized
begin
if not anhS.Is_Empty (To) then
Edge_Stmt.LHS.Node_Id.ID := To_Dot_ID_Type (From, From_Kind);
Edge_Stmt.RHS.Node_Id.ID := To_Dot_ID_Type (To, To_Kind);
Edge_Stmt.Attr_List.Add_Assign_To_First_Attr
(Name => "label",
Value => Label);
Outputs.Graph.Append_Stmt (new Dot.Edges.Stmts.Class'(Edge_Stmt));
end if;
end Add_Dot_Edge;
end Lal_Adapter;
|
-- { dg-do compile }
with Discr12_Pkg; use Discr12_Pkg;
procedure Discr12 is
subtype Small_Int is Integer range 1..10;
package P is
type PT_W_Disc (D : Small_Int) is private;
type Rec_W_Private (D1 : Integer) is
record
C : PT_W_Disc (D1);
end record;
type Rec_01 (D3 : Integer) is
record
C1 : Rec_W_Private (D3);
end record;
type Arr is array (1 .. 5) of Rec_01(Dummy(0));
private
type PT_W_Disc (D : Small_Int) is
record
Str : String (1 .. D);
end record;
end P;
begin
Null;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- Copyright (C) 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. --
-- --
------------------------------------------------------------------------------
-- This file provides register definitions for the TMS570LS31 (ARM Cortex R4F)
-- microcontrollers from Texas Instruments.
pragma Restrictions (No_Elaboration_Code);
package TMS570.GPIO is
type GPIO_Register is record
DIR : Word; -- Data Direction Register
DIN : Word; -- Data Input Register
DOUT : Word; -- Data Output Register
DSET : Word; -- Data Output Set Register
DCLR : Word; -- Data Output Clear Register
PDR : Word; -- Open Drain Register
PULDIS : Word; -- Pullup Disable Register
PSL : Word; -- Pull Up/Down Selection Register
end record;
for GPIO_Register use record
DIR at 0 range 0 .. 31;
DIN at 4 range 0 .. 31;
DOUT at 8 range 0 .. 31;
DSET at 12 range 0 .. 31;
DCLR at 16 range 0 .. 31;
PDR at 20 range 0 .. 31;
PULDIS at 24 range 0 .. 31;
PSL at 28 range 0 .. 31;
end record;
-- GPIO pin definitions
GPIO_Pin_0 : constant := 16#0000_0001#;
GPIO_Pin_1 : constant := 16#0000_0002#;
GPIO_Pin_2 : constant := 16#0000_0004#;
GPIO_Pin_3 : constant := 16#0000_0008#;
GPIO_Pin_4 : constant := 16#0000_0010#;
GPIO_Pin_5 : constant := 16#0000_0020#;
GPIO_Pin_6 : constant := 16#0000_0040#;
GPIO_Pin_7 : constant := 16#0000_0080#;
GPIO_Pin_8 : constant := 16#0000_0100#;
GPIO_Pin_9 : constant := 16#0000_0200#;
GPIO_Pin_10 : constant := 16#0000_0400#;
GPIO_Pin_11 : constant := 16#0000_0800#;
GPIO_Pin_12 : constant := 16#0000_1000#;
GPIO_Pin_13 : constant := 16#0000_2000#;
GPIO_Pin_14 : constant := 16#0000_4000#;
GPIO_Pin_15 : constant := 16#0000_8000#;
GPIO_Pin_16 : constant := 16#0001_0000#;
GPIO_Pin_17 : constant := 16#0002_0000#;
GPIO_Pin_18 : constant := 16#0004_0000#;
GPIO_Pin_19 : constant := 16#0008_0000#;
GPIO_Pin_20 : constant := 16#0010_0000#;
GPIO_Pin_21 : constant := 16#0020_0000#;
GPIO_Pin_22 : constant := 16#0040_0000#;
GPIO_Pin_23 : constant := 16#0080_0000#;
GPIO_Pin_24 : constant := 16#0100_0000#;
GPIO_Pin_25 : constant := 16#0200_0000#;
GPIO_Pin_26 : constant := 16#0400_0000#;
GPIO_Pin_27 : constant := 16#0800_0000#;
GPIO_Pin_28 : constant := 16#1000_0000#;
GPIO_Pin_29 : constant := 16#2000_0000#;
GPIO_Pin_30 : constant := 16#4000_0000#;
GPIO_Pin_31 : constant := 16#8000_0000#;
GPIO_Pin_All : constant := 16#FFFF_FFFF#; -- All pins selected
subtype GPIO_Pin_Number is Word;
function Set (This : GPIO_Register; Pin : GPIO_Pin_Number) return Boolean;
pragma Inline (Set);
procedure Set_Pin (This : in out GPIO_Register; Pin : GPIO_Pin_Number);
pragma Inline (Set_Pin);
procedure Clear_Pin (This : in out GPIO_Register; Pin : GPIO_Pin_Number);
pragma Inline (Clear_Pin);
procedure Toggle_Pin (This : in out GPIO_Register; Pin : GPIO_Pin_Number);
pragma Inline (Toggle_Pin);
end TMS570.GPIO;
|
with interfaces.c.strings;
package body agar.gui.window is
package cs renames interfaces.c.strings;
use type c.int;
function allocate_named
(flags : flags_t := 0;
name : cs.chars_ptr) return window_access_t;
pragma import (c, allocate_named, "AG_WindowNewNamedS");
function allocate_named
(flags : flags_t := 0;
name : string) return window_access_t
is
ca_name : aliased c.char_array := c.to_c (name);
begin
return allocate_named
(flags => flags,
name => cs.to_chars_ptr (ca_name'unchecked_access));
end allocate_named;
procedure set_caption
(window : window_access_t;
caption : cs.chars_ptr);
pragma import (c, set_caption, "AG_WindowSetCaptionS");
procedure set_caption
(window : window_access_t;
caption : string)
is
ca_caption : aliased c.char_array := c.to_c (caption);
begin
set_caption
(window => window,
caption => cs.to_chars_ptr (ca_caption'unchecked_access));
end set_caption;
procedure set_padding
(window : window_access_t;
left : c.int;
right : c.int;
top : c.int;
bottom : c.int);
pragma import (c, set_padding, "AG_WindowSetPadding");
procedure set_padding
(window : window_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural) is
begin
set_padding
(window => window,
left => c.int (left),
right => c.int (right),
top => c.int (top),
bottom => c.int (bottom));
end set_padding;
procedure set_spacing
(window : window_access_t;
spacing : c.int);
pragma import (c, set_spacing, "AG_WindowSetSpacing");
procedure set_spacing
(window : window_access_t;
spacing : natural) is
begin
set_spacing (window, c.int (spacing));
end set_spacing;
procedure set_position
(window : window_access_t;
alignment : alignment_t;
cascade : c.int);
pragma import (c, set_position, "AG_WindowSetPosition");
procedure set_position
(window : window_access_t;
alignment : alignment_t;
cascade : boolean) is
begin
if cascade then
set_position (window, alignment, 1);
else
set_position (window, alignment, 0);
end if;
end set_position;
procedure set_geometry
(window : window_access_t;
x : c.int;
y : c.int;
width : c.int;
height : c.int);
pragma import (c, set_geometry, "agar_window_set_geometry");
procedure set_geometry
(window : window_access_t;
x : natural;
y : natural;
width : natural;
height : natural) is
begin
set_geometry
(window => window,
x => c.int (x),
y => c.int (y),
width => c.int (width),
height => c.int (height));
end set_geometry;
procedure set_geometry_aligned
(window : window_access_t;
alignment : alignment_t;
width : c.int;
height : c.int);
pragma import (c, set_geometry_aligned, "agar_window_set_geometry_aligned");
procedure set_geometry_aligned
(window : window_access_t;
alignment : alignment_t;
width : positive;
height : positive) is
begin
set_geometry_aligned
(window => window,
alignment => alignment,
width => c.int (width),
height => c.int (height));
end set_geometry_aligned;
procedure set_geometry_aligned_percent
(window : window_access_t;
alignment : alignment_t;
width : c.int;
height : c.int);
pragma import (c, set_geometry_aligned_percent, "agar_window_set_geometry_aligned_percent");
procedure set_geometry_aligned_percent
(window : window_access_t;
alignment : alignment_t;
width : percent_t;
height : percent_t) is
begin
set_geometry_aligned_percent
(window => window,
alignment => alignment,
width => c.int (width),
height => c.int (height));
end set_geometry_aligned_percent;
procedure set_geometry_bounded
(window : window_access_t;
x : c.int;
y : c.int;
width : c.int;
height : c.int);
pragma import (c, set_geometry_bounded, "agar_window_set_geometry_bounded");
procedure set_geometry_bounded
(window : window_access_t;
x : natural;
y : natural;
width : natural;
height : natural) is
begin
set_geometry_bounded
(window => window,
x => c.int (x),
y => c.int (y),
width => c.int (width),
height => c.int (height));
end set_geometry_bounded;
procedure set_minimum_size
(window : window_access_t;
width : c.int;
height : c.int);
pragma import (c, set_minimum_size, "AG_WindowSetMinSize");
procedure set_minimum_size
(window : window_access_t;
width : natural;
height : natural) is
begin
set_minimum_size
(window => window,
width => c.int (width),
height => c.int (height));
end set_minimum_size;
procedure set_minimum_size_percentage
(window : window_access_t;
percent : c.int);
pragma import (c, set_minimum_size_percentage, "AG_WindowSetMinSizePct");
procedure set_minimum_size_percentage
(window : window_access_t;
percent : percent_t) is
begin
set_minimum_size_percentage
(window => window,
percent => c.int (percent));
end set_minimum_size_percentage;
function is_visible (window : window_access_t) return boolean is
begin
return is_visible (window) = 1;
end is_visible;
procedure set_visibility
(window : window_access_t;
visible : c.int);
pragma import (c, set_visibility, "AG_WindowSetVisibility");
procedure set_visibility
(window : window_access_t;
visible : boolean) is
begin
if visible then
set_visibility (window, 1);
else
set_visibility (window, 0);
end if;
end set_visibility;
function focus_named (name : cs.chars_ptr) return c.int;
pragma import (c, focus_named, "AG_WindowFocusNamed");
function focus_named (name : string) return boolean is
ca_name : aliased c.char_array := c.to_c (name);
begin
return focus_named (cs.to_chars_ptr (ca_name'unchecked_access)) = 0;
end focus_named;
function is_focused (window : window_access_t) return boolean is
begin
return is_focused (window) = 1;
end is_focused;
end agar.gui.window;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Strings.Wide_Wide_Fixed;
package body Program.Symbol_Lists is
-----------------------
-- Empty_Symbol_List --
-----------------------
function Empty_Symbol_List return Symbol_List is
begin
return 0;
end Empty_Symbol_List;
----------
-- Find --
----------
function Find
(Self : Symbol_List_Table'Class;
Value : Program.Text) return Symbol_List
is
Cursor : Symbol_List_Maps.Cursor;
Item : Symbol_List_Item :=
(Empty_Symbol_List, Program.Symbols.No_Symbol);
Result : Symbol_List;
Prev : Positive;
Dot : Natural := Value'First - 1;
begin
loop
Prev := Dot + 1;
Dot := Ada.Strings.Wide_Wide_Fixed.Index (Value, ".", Prev);
exit when Dot not in Value'Range;
Item.Symbol := Self.Table.Find (Value (Prev .. Dot - 1));
Cursor := Self.Map.Find (Item);
if Symbol_List_Maps.Has_Element (Cursor) then
Item.Prefix := Symbol_List_Maps.Element (Cursor);
else
return Empty_Symbol_List;
end if;
end loop;
Item.Symbol := Self.Table.Find (Value (Dot + 1 .. Value'Last));
Cursor := Self.Map.Find (Item);
if Symbol_List_Maps.Has_Element (Cursor) then
Result := Symbol_List_Maps.Element (Cursor);
else
return Empty_Symbol_List;
end if;
return Result;
end Find;
--------------------
-- Find_Or_Create --
--------------------
procedure Find_Or_Create
(Self : in out Symbol_List_Table'Class;
Value : Program.Text;
Result : out Symbol_List)
is
Prefix : Symbol_List := Empty_Symbol_List;
Suffix : Program.Symbols.Symbol;
Prev : Positive;
Dot : Natural := Value'First - 1;
begin
loop
Prev := Dot + 1;
Dot := Ada.Strings.Wide_Wide_Fixed.Index (Value, ".", Prev);
exit when Dot not in Value'Range;
Suffix := Self.Table.Find (Value (Prev .. Dot - 1));
Self.Find_Or_Create (Prefix, Suffix, Result => Prefix);
end loop;
Suffix := Self.Table.Find (Value (Dot + 1 .. Value'Last));
Self.Find_Or_Create (Prefix, Suffix, Result);
end Find_Or_Create;
--------------------
-- Find_Or_Create --
--------------------
procedure Find_Or_Create
(Self : in out Symbol_List_Table'Class;
Prefix : Symbol_List := Empty_Symbol_List;
Suffix : Program.Symbols.Symbol;
Result : out Symbol_List)
is
Item : constant Symbol_List_Item := (Prefix, Suffix);
Cursor : constant Symbol_List_Maps.Cursor := Self.Map.Find (Item);
begin
if Symbol_List_Maps.Has_Element (Cursor) then
Result := Symbol_List_Maps.Element (Cursor);
else
Self.Back.Append (Item);
Result := Self.Back.Last_Index;
Self.Map.Insert (Item, Result);
end if;
end Find_Or_Create;
----------
-- Hash --
----------
function Hash (Value : Symbol_List) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type'Mod (Value);
end Hash;
----------
-- Hash --
----------
function Hash (Value : Symbol_List_Item) return Ada.Containers.Hash_Type is
use type Ada.Containers.Hash_Type;
begin
return Ada.Containers.Hash_Type'Mod (Value.Prefix)
+ 100003 * Program.Symbols.Hash (Value.Symbol);
end Hash;
------------
-- Prefix --
------------
function Prefix
(Self : Symbol_List_Table'Class;
List : Program.Symbol_Lists.Symbol_List)
return Program.Symbol_Lists.Symbol_List is
begin
return Self.Back (List).Prefix;
end Prefix;
------------
-- Suffix --
------------
function Suffix
(Self : Symbol_List_Table'Class;
List : Program.Symbol_Lists.Symbol_List)
return Program.Symbols.Symbol is
begin
return Self.Back (List).Symbol;
end Suffix;
----------------------
-- Symbol_List_Text --
----------------------
function Symbol_List_Text
(Self : Symbol_List_Table'Class;
List : Symbol_List) return Program.Text
is
Prefix : Symbol_List;
Symbol : Program.Symbols.Symbol;
begin
if List = Empty_Symbol_List then
return "";
end if;
Prefix := Self.Prefix (List);
Symbol := Self.Suffix (List);
if Prefix = Empty_Symbol_List then
return Self.Table.Symbol_Text (Symbol);
else
return Self.Symbol_List_Text (Prefix) & "." &
Self.Table.Symbol_Text (Symbol);
end if;
end Symbol_List_Text;
end Program.Symbol_Lists;
|
with Ada.Text_IO;
procedure Cursor_Pos is
begin
Ada.Text_IO.Set_Line(6);
Ada.Text_IO.Set_Col(3);
Ada.Text_IO.Put("Hello");
end Cursor_Pos;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with Ada.Containers;
with AdaBase.Connection.Base.PostgreSQL;
with AdaBase.Bindings.PostgreSQL;
package AdaBase.Statement.Base.PostgreSQL is
package BND renames AdaBase.Bindings.PostgreSQL;
package CON renames AdaBase.Connection.Base.PostgreSQL;
package AC renames Ada.Containers;
type PostgreSQL_statement
(type_of_statement : Stmt_Type;
log_handler : ALF.LogFacility_access;
pgsql_conn : CON.PostgreSQL_Connection_Access;
identifier : Trax_ID;
initial_sql : SQL_Access;
next_calls : SQL_Access;
con_error_mode : Error_Modes;
con_case_mode : Case_Modes;
con_max_blob : BLOB_Maximum;
con_buffered : Boolean)
is new Base_Statement and AIS.iStatement with private;
type PostgreSQL_statement_access is access all PostgreSQL_statement;
overriding
function column_count (Stmt : PostgreSQL_statement) return Natural;
overriding
function last_insert_id (Stmt : PostgreSQL_statement) return Trax_ID;
overriding
function last_sql_state (Stmt : PostgreSQL_statement) return SQL_State;
overriding
function last_driver_code (Stmt : PostgreSQL_statement) return Driver_Codes;
overriding
function last_driver_message (Stmt : PostgreSQL_statement) return String;
overriding
procedure discard_rest (Stmt : out PostgreSQL_statement);
overriding
function execute (Stmt : out PostgreSQL_statement) return Boolean;
overriding
function execute (Stmt : out PostgreSQL_statement; parameters : String;
delimiter : Character := '|') return Boolean;
overriding
function rows_returned (Stmt : PostgreSQL_statement) return Affected_Rows;
overriding
function column_name (Stmt : PostgreSQL_statement; index : Positive)
return String;
overriding
function column_table (Stmt : PostgreSQL_statement; index : Positive)
return String;
overriding
function column_native_type (Stmt : PostgreSQL_statement; index : Positive)
return field_types;
overriding
function fetch_next (Stmt : out PostgreSQL_statement) return ARS.Datarow;
overriding
function fetch_all (Stmt : out PostgreSQL_statement)
return ARS.Datarow_Set;
overriding
function fetch_bound (Stmt : out PostgreSQL_statement) return Boolean;
overriding
procedure fetch_next_set (Stmt : out PostgreSQL_statement;
data_present : out Boolean;
data_fetched : out Boolean);
function returned_refcursors (Stmt : PostgreSQL_statement)
return Boolean;
POSTGIS_READ_ERROR : exception;
private
type column_info is record
table : CT.Text;
field_name : CT.Text;
field_type : field_types;
field_size : Natural;
binary_format : Boolean;
end record;
type string_box is record
payload : CT.Text;
end record;
package VRefcursors is new Ada.Containers.Vectors (Natural, string_box);
package VColumns is new AC.Vectors (Positive, column_info);
type PostgreSQL_statement
(type_of_statement : Stmt_Type;
log_handler : ALF.LogFacility_access;
pgsql_conn : CON.PostgreSQL_Connection_Access;
identifier : Trax_ID;
initial_sql : SQL_Access;
next_calls : SQL_Access;
con_error_mode : Error_Modes;
con_case_mode : Case_Modes;
con_max_blob : BLOB_Maximum;
con_buffered : Boolean)
is new Base_Statement and AIS.iStatement with
record
result_handle : aliased BND.PGresult_Access := null;
prepared_stmt : aliased BND.PGresult_Access := null;
stmt_allocated : Boolean := False;
insert_prepsql : Boolean := False;
insert_return : Boolean := False;
assign_counter : Natural := 0;
num_columns : Natural := 0;
size_of_rowset : Trax_ID := 0;
result_arrow : Trax_ID := 0;
last_inserted : Trax_ID := 0;
column_info : VColumns.Vector;
refcursors : VRefcursors.Vector;
sql_final : SQL_Access;
end record;
procedure log_problem
(statement : PostgreSQL_statement;
category : Log_Category;
message : String;
pull_codes : Boolean := False;
break : Boolean := False);
procedure initialize (Object : in out PostgreSQL_statement);
procedure Adjust (Object : in out PostgreSQL_statement);
procedure finalize (Object : in out PostgreSQL_statement);
function reformat_markers (parameterized_sql : String) return String;
procedure scan_column_information (Stmt : out PostgreSQL_statement;
pgresult : BND.PGresult_Access);
function assemble_datarow (Stmt : out PostgreSQL_statement;
row_number : Trax_ID) return ARS.Datarow;
function show_statement_name (Stmt : PostgreSQL_statement) return String;
function bind_text_value (Stmt : PostgreSQL_statement; marker : Positive)
return AR.Textual;
function pop_result_set_reference (Stmt : out PostgreSQL_statement)
return String;
procedure push_result_references (Stmt : out PostgreSQL_statement;
calls : String);
function postgis_to_WKB (postgis : String) return String;
end AdaBase.Statement.Base.PostgreSQL;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.