content stringlengths 23 1.05M |
|---|
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
type Days_Of_Week_T is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
-- type Unconstrained_Array_T is ?
-- Constant_Array : ?
-- Array2 : ?
-- type Name_T is ? (array of characters)
-- Weekly_Staff : ? (2-dimensional array using day and counter as indices)
begin
Put_Line ("Array Types");
-- Copy Constant_Array to Array2
-- For every item of Array2
-- Print the item
-- Initialize Array2 via aggregate
-- For every item of Array2
-- Print the array index and the item
-- Copy part of Constant_Array to part of Array2
-- Set another part of Array2 to a known value
-- For every item of Array2
-- Print the item
-- Initialize Weekly_Staff using nested aggregates
-- For every day of the week
-- Print the day of the week
-- Print each staff member
end Main;
|
with System;
package STM32GD.Vectors is
pragma Preelaborate;
procedure Default_Handler;
type IRQ_Vectors is
record
HardFault_Handler : System.Address;
MemManage_Handler : System.Address;
BusFault_Handler : System.Address;
UsageFault_Handler : System.Address;
Reserved_1C : System.Address;
Reserved_20 : System.Address;
Reserved_24 : System.Address;
Reserved_28 : System.Address;
SVCall_Handler : System.Address;
DebugMonitor_Handler : System.Address;
Reserved_34 : System.Address;
PendSV_Handler : System.Address;
SysTick_Handler : System.Address;
WWDG_Handler : System.Address;
PVD_Handler : System.Address;
RTC_Handler : System.Address;
FLASH_Handler : System.Address;
end record;
end STM32GD.Vectors;
|
------------------------------------------------------------------------------
-- --
-- Unicode Utilities --
-- --
-- General Category Query Utility --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package Unicode.General_Category with Pure is
-- Unicode Standard 12.0.0, Chapter 4.5, Table 4-4
type General_Category_Type is
(Letter_Uppercase, -- Letter, uppercase (Lu)
Letter_Lowercase, -- Letter, lowercase (Ll)
Letter_Titlecase, -- Letter, titlecase (Lt)
Letter_Modifier, -- Letter, modifier (Lm)
Letter_Other, -- Letter, other (Lo)
Mark_Nonspacing, -- Mark, nonspacing (Mn)
Mark_Spacing_Combining, -- Mark, spacing combining (Mc)
Mark_Enclosing, -- Mark, enclosing (Me)
Number_Decimal_Digit, -- Number, decimal digit (Nd)
Number_Letter, -- Number, letter (Nl)
Number_Other, -- Number, other (No)
Punctuation_Connector, -- Punctuation, connector (Pc)
Punctuation_Dash, -- Punctuation, dash (Pd)
Punctuation_Open, -- Punctuation, open (Ps)
Punctuation_Close, -- Punctuation, close (Pe)
Punctuation_Initial_Quote, -- Punctuation, initial quote (Pi)
Punctuation_Final_Quote, -- Punctuation, final quote (Pf)
Punctuation_Other, -- Punctuation, other (Po)
Symbol_Math, -- Symbol, math (Sm)
Symbol_Currency, -- Symbol, currency (Sc)
Symbol_Modifier, -- Symbol, modifier (Sk)
Symbol_Other, -- Symbol, other (So)
Separator_Space, -- Separator, space (Zs)
Separator_Line, -- Separator, line (Zl)
Separator_Paragraph, -- Separator, paragraph (Zp)
Other_Control, -- Other, control (Cc)
Other_Format, -- Other, format (Cf)
Other_Surrogate, -- Other, surrogate (Cs)
Other_Private_Use, -- Other, private use (Co)
Other_Not_Assigned); -- Other, not assigned (Cn)
function General_Category (C: Wide_Wide_Character)
return General_Category_Type;
-- Returns the General_Category value of C, as per the UCD.
-- Codepoints not listed in UCD (including codepoints above U+10FFFF)
-- return "Other_Not_Assigned"
function Is_Category (C : Wide_Wide_Character;
Category: General_Category_Type)
return Boolean
is (General_Category (C) = Category);
-- Returns True if Character C is of the General_Category Category.
--
-- Useful in renames with a default set for Category.
end Unicode.General_Category;
|
with Prime_Numbers, Ada.Text_IO;
procedure Test_Prime is
package Integer_Numbers is new
Prime_Numbers (Natural, 0, 1, 2);
use Integer_Numbers;
procedure Put (List : Number_List) is
begin
for Index in List'Range loop
Ada.Text_IO.Put (Positive'Image (List (Index)));
end loop;
end Put;
begin
Put (Decompose (12));
end Test_Prime;
|
-- Automatically generated, do not edit.
with System;
with OpenAL.Types;
package OpenAL.Extension.EFX_Thin is
ALC_EFX_MAJOR_VERSION : constant := 16#20001#;
ALC_EFX_MINOR_VERSION : constant := 16#20002#;
ALC_MAX_AUXILIARY_SENDS : constant := 16#20003#;
AL_AIR_ABSORPTION_FACTOR : constant := 16#20007#;
AL_AUTOWAH_ATTACK_TIME : constant := 16#0001#;
AL_AUTOWAH_DEFAULT_ATTACK_TIME : constant := 0.06;
AL_AUTOWAH_DEFAULT_PEAK_GAIN : constant := 11.22;
AL_AUTOWAH_DEFAULT_RELEASE_TIME : constant := 0.06;
AL_AUTOWAH_DEFAULT_RESONANCE : constant := 1000.0;
AL_AUTOWAH_MAX_ATTACK_TIME : constant := 1.0;
AL_AUTOWAH_MAX_PEAK_GAIN : constant := 31621.0;
AL_AUTOWAH_MAX_RELEASE_TIME : constant := 1.0;
AL_AUTOWAH_MAX_RESONANCE : constant := 1000.0;
AL_AUTOWAH_MIN_ATTACK_TIME : constant := 0.0001;
AL_AUTOWAH_MIN_PEAK_GAIN : constant := 0.00003;
AL_AUTOWAH_MIN_RELEASE_TIME : constant := 0.0001;
AL_AUTOWAH_MIN_RESONANCE : constant := 2.0;
AL_AUTOWAH_PEAK_GAIN : constant := 16#0004#;
AL_AUTOWAH_RELEASE_TIME : constant := 16#0002#;
AL_AUTOWAH_RESONANCE : constant := 16#0003#;
AL_AUXILIARY_SEND_FILTER : constant := 16#20006#;
AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO : constant := 16#2000C#;
AL_AUXILIARY_SEND_FILTER_GAIN_AUTO : constant := 16#2000B#;
AL_BANDPASS_GAIN : constant := 16#0001#;
AL_BANDPASS_GAINHF : constant := 16#0003#;
AL_BANDPASS_GAINLF : constant := 16#0002#;
AL_CHORUS_DEFAULT_DELAY : constant := 0.016;
AL_CHORUS_DEFAULT_DEPTH : constant := 0.1;
AL_CHORUS_DEFAULT_FEEDBACK : constant := 0.25;
AL_CHORUS_DEFAULT_PHASE : constant := 16#90#;
AL_CHORUS_DEFAULT_RATE : constant := 1.1;
AL_CHORUS_DEFAULT_WAVEFORM : constant := 16#1#;
AL_CHORUS_DELAY : constant := 16#0006#;
AL_CHORUS_DEPTH : constant := 16#0004#;
AL_CHORUS_FEEDBACK : constant := 16#0005#;
AL_CHORUS_MAX_DELAY : constant := 0.016;
AL_CHORUS_MAX_DEPTH : constant := 1.0;
AL_CHORUS_MAX_FEEDBACK : constant := 1.0;
AL_CHORUS_MAX_PHASE : constant := 16#180#;
AL_CHORUS_MAX_RATE : constant := 10.0;
AL_CHORUS_MAX_WAVEFORM : constant := 16#1#;
AL_CHORUS_MIN_DELAY : constant := 0.0;
AL_CHORUS_MIN_DEPTH : constant := 0.0;
AL_CHORUS_MIN_FEEDBACK : constant := -1.0;
AL_CHORUS_MIN_PHASE : constant := -16#180#;
AL_CHORUS_MIN_RATE : constant := 0.0;
AL_CHORUS_MIN_WAVEFORM : constant := 16#0#;
AL_CHORUS_PHASE : constant := 16#0002#;
AL_CHORUS_RATE : constant := 16#0003#;
AL_CHORUS_WAVEFORM : constant := 16#0001#;
AL_CHORUS_WAVEFORM_SINUSOID : constant := 16#0#;
AL_CHORUS_WAVEFORM_TRIANGLE : constant := 16#1#;
AL_COMPRESSOR_DEFAULT_ONOFF : constant := 16#1#;
AL_COMPRESSOR_MAX_ONOFF : constant := 16#1#;
AL_COMPRESSOR_MIN_ONOFF : constant := 16#0#;
AL_COMPRESSOR_ONOFF : constant := 16#0001#;
AL_CONE_OUTER_GAINHF : constant := 16#20009#;
AL_DIRECT_FILTER : constant := 16#20005#;
AL_DIRECT_FILTER_GAINHF_AUTO : constant := 16#2000A#;
AL_DISTORTION_DEFAULT_EDGE : constant := 0.2;
AL_DISTORTION_DEFAULT_EQBANDWIDTH : constant := 3600.0;
AL_DISTORTION_DEFAULT_EQCENTER : constant := 3600.0;
AL_DISTORTION_DEFAULT_GAIN : constant := 0.05;
AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF : constant := 8000.0;
AL_DISTORTION_EDGE : constant := 16#0001#;
AL_DISTORTION_EQBANDWIDTH : constant := 16#0005#;
AL_DISTORTION_EQCENTER : constant := 16#0004#;
AL_DISTORTION_GAIN : constant := 16#0002#;
AL_DISTORTION_LOWPASS_CUTOFF : constant := 16#0003#;
AL_DISTORTION_MAX_EDGE : constant := 1.0;
AL_DISTORTION_MAX_EQBANDWIDTH : constant := 24000.0;
AL_DISTORTION_MAX_EQCENTER : constant := 24000.0;
AL_DISTORTION_MAX_GAIN : constant := 1.0;
AL_DISTORTION_MAX_LOWPASS_CUTOFF : constant := 24000.0;
AL_DISTORTION_MIN_EDGE : constant := 0.0;
AL_DISTORTION_MIN_EQBANDWIDTH : constant := 80.0;
AL_DISTORTION_MIN_EQCENTER : constant := 80.0;
AL_DISTORTION_MIN_GAIN : constant := 0.01;
AL_DISTORTION_MIN_LOWPASS_CUTOFF : constant := 80.0;
AL_EAXREVERB_AIR_ABSORPTION_GAINHF : constant := 16#0013#;
AL_EAXREVERB_DECAY_HFLIMIT : constant := 16#0017#;
AL_EAXREVERB_DECAY_HFRATIO : constant := 16#0007#;
AL_EAXREVERB_DECAY_LFRATIO : constant := 16#0008#;
AL_EAXREVERB_DECAY_TIME : constant := 16#0006#;
AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF : constant := 0.994;
AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT : constant := 16#1#;
AL_EAXREVERB_DEFAULT_DECAY_HFRATIO : constant := 0.83;
AL_EAXREVERB_DEFAULT_DECAY_LFRATIO : constant := 1.0;
AL_EAXREVERB_DEFAULT_DECAY_TIME : constant := 1.49;
AL_EAXREVERB_DEFAULT_DENSITY : constant := 1.0;
AL_EAXREVERB_DEFAULT_DIFFUSION : constant := 1.0;
AL_EAXREVERB_DEFAULT_ECHO_DEPTH : constant := 0.0;
AL_EAXREVERB_DEFAULT_ECHO_TIME : constant := 0.25;
AL_EAXREVERB_DEFAULT_GAIN : constant := 0.32;
AL_EAXREVERB_DEFAULT_GAINHF : constant := 0.89;
AL_EAXREVERB_DEFAULT_GAINLF : constant := 1.0;
AL_EAXREVERB_DEFAULT_HFREFERENCE : constant := 5000.0;
AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY : constant := 0.011;
AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN : constant := 1.26;
AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ : constant := 0.0;
AL_EAXREVERB_DEFAULT_LFREFERENCE : constant := 250.0;
AL_EAXREVERB_DEFAULT_MODULATION_DEPTH : constant := 0.0;
AL_EAXREVERB_DEFAULT_MODULATION_TIME : constant := 0.25;
AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY : constant := 0.007;
AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN : constant := 0.05;
AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ : constant := 0.0;
AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR : constant := 0.0;
AL_EAXREVERB_DENSITY : constant := 16#0001#;
AL_EAXREVERB_DIFFUSION : constant := 16#0002#;
AL_EAXREVERB_ECHO_DEPTH : constant := 16#0010#;
AL_EAXREVERB_ECHO_TIME : constant := 16#000F#;
AL_EAXREVERB_GAIN : constant := 16#0003#;
AL_EAXREVERB_GAINHF : constant := 16#0004#;
AL_EAXREVERB_GAINLF : constant := 16#0005#;
AL_EAXREVERB_HFREFERENCE : constant := 16#0014#;
AL_EAXREVERB_LATE_REVERB_DELAY : constant := 16#000D#;
AL_EAXREVERB_LATE_REVERB_GAIN : constant := 16#000C#;
AL_EAXREVERB_LATE_REVERB_PAN : constant := 16#000E#;
AL_EAXREVERB_LFREFERENCE : constant := 16#0015#;
AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF : constant := 1.0;
AL_EAXREVERB_MAX_DECAY_HFLIMIT : constant := 16#1#;
AL_EAXREVERB_MAX_DECAY_HFRATIO : constant := 2.0;
AL_EAXREVERB_MAX_DECAY_LFRATIO : constant := 2.0;
AL_EAXREVERB_MAX_DECAY_TIME : constant := 20.0;
AL_EAXREVERB_MAX_DENSITY : constant := 1.0;
AL_EAXREVERB_MAX_DIFFUSION : constant := 1.0;
AL_EAXREVERB_MAX_ECHO_DEPTH : constant := 1.0;
AL_EAXREVERB_MAX_ECHO_TIME : constant := 0.25;
AL_EAXREVERB_MAX_GAIN : constant := 1.0;
AL_EAXREVERB_MAX_GAINHF : constant := 1.0;
AL_EAXREVERB_MAX_GAINLF : constant := 1.0;
AL_EAXREVERB_MAX_HFREFERENCE : constant := 20000.0;
AL_EAXREVERB_MAX_LATE_REVERB_DELAY : constant := 0.1;
AL_EAXREVERB_MAX_LATE_REVERB_GAIN : constant := 10.0;
AL_EAXREVERB_MAX_LFREFERENCE : constant := 1000.0;
AL_EAXREVERB_MAX_MODULATION_DEPTH : constant := 1.0;
AL_EAXREVERB_MAX_MODULATION_TIME : constant := 4.0;
AL_EAXREVERB_MAX_REFLECTIONS_DELAY : constant := 0.3;
AL_EAXREVERB_MAX_REFLECTIONS_GAIN : constant := 3.16;
AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR : constant := 10.0;
AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF : constant := 0.892;
AL_EAXREVERB_MIN_DECAY_HFLIMIT : constant := 16#0#;
AL_EAXREVERB_MIN_DECAY_HFRATIO : constant := 0.1;
AL_EAXREVERB_MIN_DECAY_LFRATIO : constant := 0.1;
AL_EAXREVERB_MIN_DECAY_TIME : constant := 0.1;
AL_EAXREVERB_MIN_DENSITY : constant := 0.0;
AL_EAXREVERB_MIN_DIFFUSION : constant := 0.0;
AL_EAXREVERB_MIN_ECHO_DEPTH : constant := 0.0;
AL_EAXREVERB_MIN_ECHO_TIME : constant := 0.075;
AL_EAXREVERB_MIN_GAIN : constant := 0.0;
AL_EAXREVERB_MIN_GAINHF : constant := 0.0;
AL_EAXREVERB_MIN_GAINLF : constant := 0.0;
AL_EAXREVERB_MIN_HFREFERENCE : constant := 1000.0;
AL_EAXREVERB_MIN_LATE_REVERB_DELAY : constant := 0.0;
AL_EAXREVERB_MIN_LATE_REVERB_GAIN : constant := 0.0;
AL_EAXREVERB_MIN_LFREFERENCE : constant := 20.0;
AL_EAXREVERB_MIN_MODULATION_DEPTH : constant := 0.0;
AL_EAXREVERB_MIN_MODULATION_TIME : constant := 0.04;
AL_EAXREVERB_MIN_REFLECTIONS_DELAY : constant := 0.0;
AL_EAXREVERB_MIN_REFLECTIONS_GAIN : constant := 0.0;
AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR : constant := 0.0;
AL_EAXREVERB_MODULATION_DEPTH : constant := 16#0012#;
AL_EAXREVERB_MODULATION_TIME : constant := 16#0011#;
AL_EAXREVERB_REFLECTIONS_DELAY : constant := 16#000A#;
AL_EAXREVERB_REFLECTIONS_GAIN : constant := 16#0009#;
AL_EAXREVERB_REFLECTIONS_PAN : constant := 16#000B#;
AL_EAXREVERB_ROOM_ROLLOFF_FACTOR : constant := 16#0016#;
AL_ECHO_DAMPING : constant := 16#0003#;
AL_ECHO_DEFAULT_DAMPING : constant := 0.5;
AL_ECHO_DEFAULT_DELAY : constant := 0.1;
AL_ECHO_DEFAULT_FEEDBACK : constant := 0.5;
AL_ECHO_DEFAULT_LRDELAY : constant := 0.1;
AL_ECHO_DEFAULT_SPREAD : constant := -1.0;
AL_ECHO_DELAY : constant := 16#0001#;
AL_ECHO_FEEDBACK : constant := 16#0004#;
AL_ECHO_LRDELAY : constant := 16#0002#;
AL_ECHO_MAX_DAMPING : constant := 0.99;
AL_ECHO_MAX_DELAY : constant := 0.207;
AL_ECHO_MAX_FEEDBACK : constant := 1.0;
AL_ECHO_MAX_LRDELAY : constant := 0.404;
AL_ECHO_MAX_SPREAD : constant := 1.0;
AL_ECHO_MIN_DAMPING : constant := 0.0;
AL_ECHO_MIN_DELAY : constant := 0.0;
AL_ECHO_MIN_FEEDBACK : constant := 0.0;
AL_ECHO_MIN_LRDELAY : constant := 0.0;
AL_ECHO_MIN_SPREAD : constant := -1.0;
AL_ECHO_SPREAD : constant := 16#0005#;
AL_EFFECTSLOT_AUXILIARY_SEND_AUTO : constant := 16#0003#;
AL_EFFECTSLOT_EFFECT : constant := 16#0001#;
AL_EFFECTSLOT_GAIN : constant := 16#0002#;
AL_EFFECTSLOT_NULL : constant := 16#0000#;
AL_EFFECT_AUTOWAH : constant := 16#000A#;
AL_EFFECT_CHORUS : constant := 16#0002#;
AL_EFFECT_COMPRESSOR : constant := 16#000B#;
AL_EFFECT_DISTORTION : constant := 16#0003#;
AL_EFFECT_EAXREVERB : constant := 16#8000#;
AL_EFFECT_ECHO : constant := 16#0004#;
AL_EFFECT_EQUALIZER : constant := 16#000C#;
AL_EFFECT_FLANGER : constant := 16#0005#;
AL_EFFECT_FREQUENCY_SHIFTER : constant := 16#0006#;
AL_EFFECT_NULL : constant := 16#0000#;
AL_EFFECT_PITCH_SHIFTER : constant := 16#0008#;
AL_EFFECT_REVERB : constant := 16#0001#;
AL_EFFECT_RING_MODULATOR : constant := 16#0009#;
AL_EFFECT_TYPE : constant := 16#8001#;
AL_EFFECT_VOCAL_MORPHER : constant := 16#0007#;
AL_EQUALIZER_DEFAULT_HIGH_CUTOFF : constant := 6000.0;
AL_EQUALIZER_DEFAULT_HIGH_GAIN : constant := 1.0;
AL_EQUALIZER_DEFAULT_LOW_CUTOFF : constant := 200.0;
AL_EQUALIZER_DEFAULT_LOW_GAIN : constant := 1.0;
AL_EQUALIZER_DEFAULT_MID1_CENTER : constant := 500.0;
AL_EQUALIZER_DEFAULT_MID1_GAIN : constant := 1.0;
AL_EQUALIZER_DEFAULT_MID1_WIDTH : constant := 1.0;
AL_EQUALIZER_DEFAULT_MID2_CENTER : constant := 3000.0;
AL_EQUALIZER_DEFAULT_MID2_GAIN : constant := 1.0;
AL_EQUALIZER_DEFAULT_MID2_WIDTH : constant := 1.0;
AL_EQUALIZER_HIGH_CUTOFF : constant := 16#000A#;
AL_EQUALIZER_HIGH_GAIN : constant := 16#0009#;
AL_EQUALIZER_LOW_CUTOFF : constant := 16#0002#;
AL_EQUALIZER_LOW_GAIN : constant := 16#0001#;
AL_EQUALIZER_MAX_HIGH_CUTOFF : constant := 16000.0;
AL_EQUALIZER_MAX_HIGH_GAIN : constant := 7.943;
AL_EQUALIZER_MAX_LOW_CUTOFF : constant := 800.0;
AL_EQUALIZER_MAX_LOW_GAIN : constant := 7.943;
AL_EQUALIZER_MAX_MID1_CENTER : constant := 3000.0;
AL_EQUALIZER_MAX_MID1_GAIN : constant := 7.943;
AL_EQUALIZER_MAX_MID1_WIDTH : constant := 1.0;
AL_EQUALIZER_MAX_MID2_CENTER : constant := 8000.0;
AL_EQUALIZER_MAX_MID2_GAIN : constant := 7.943;
AL_EQUALIZER_MAX_MID2_WIDTH : constant := 1.0;
AL_EQUALIZER_MID1_CENTER : constant := 16#0004#;
AL_EQUALIZER_MID1_GAIN : constant := 16#0003#;
AL_EQUALIZER_MID1_WIDTH : constant := 16#0005#;
AL_EQUALIZER_MID2_CENTER : constant := 16#0007#;
AL_EQUALIZER_MID2_GAIN : constant := 16#0006#;
AL_EQUALIZER_MID2_WIDTH : constant := 16#0008#;
AL_EQUALIZER_MIN_HIGH_CUTOFF : constant := 4000.0;
AL_EQUALIZER_MIN_HIGH_GAIN : constant := 0.126;
AL_EQUALIZER_MIN_LOW_CUTOFF : constant := 50.0;
AL_EQUALIZER_MIN_LOW_GAIN : constant := 0.126;
AL_EQUALIZER_MIN_MID1_CENTER : constant := 200.0;
AL_EQUALIZER_MIN_MID1_GAIN : constant := 0.126;
AL_EQUALIZER_MIN_MID1_WIDTH : constant := 0.01;
AL_EQUALIZER_MIN_MID2_CENTER : constant := 1000.0;
AL_EQUALIZER_MIN_MID2_GAIN : constant := 0.126;
AL_EQUALIZER_MIN_MID2_WIDTH : constant := 0.01;
AL_FILTER_BANDPASS : constant := 16#0003#;
AL_FILTER_HIGHPASS : constant := 16#0002#;
AL_FILTER_LOWPASS : constant := 16#0001#;
AL_FILTER_NULL : constant := 16#0000#;
AL_FILTER_TYPE : constant := 16#8001#;
AL_FLANGER_DEFAULT_DELAY : constant := 0.002;
AL_FLANGER_DEFAULT_DEPTH : constant := 1.0;
AL_FLANGER_DEFAULT_FEEDBACK : constant := -0.5;
AL_FLANGER_DEFAULT_PHASE : constant := 16#0#;
AL_FLANGER_DEFAULT_RATE : constant := 0.27;
AL_FLANGER_DEFAULT_WAVEFORM : constant := 16#1#;
AL_FLANGER_DELAY : constant := 16#0006#;
AL_FLANGER_DEPTH : constant := 16#0004#;
AL_FLANGER_FEEDBACK : constant := 16#0005#;
AL_FLANGER_MAX_DELAY : constant := 0.004;
AL_FLANGER_MAX_DEPTH : constant := 1.0;
AL_FLANGER_MAX_FEEDBACK : constant := 1.0;
AL_FLANGER_MAX_PHASE : constant := 16#180#;
AL_FLANGER_MAX_RATE : constant := 10.0;
AL_FLANGER_MAX_WAVEFORM : constant := 16#1#;
AL_FLANGER_MIN_DELAY : constant := 0.0;
AL_FLANGER_MIN_DEPTH : constant := 0.0;
AL_FLANGER_MIN_FEEDBACK : constant := -1.0;
AL_FLANGER_MIN_PHASE : constant := -16#180#;
AL_FLANGER_MIN_RATE : constant := 0.0;
AL_FLANGER_MIN_WAVEFORM : constant := 16#0#;
AL_FLANGER_PHASE : constant := 16#0002#;
AL_FLANGER_RATE : constant := 16#0003#;
AL_FLANGER_WAVEFORM : constant := 16#0001#;
AL_FLANGER_WAVEFORM_SINUSOID : constant := 16#0#;
AL_FLANGER_WAVEFORM_TRIANGLE : constant := 16#1#;
AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY : constant := 0.0;
AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION : constant := 16#0#;
AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION : constant := 16#0#;
AL_FREQUENCY_SHIFTER_DIRECTION_DOWN : constant := 16#0#;
AL_FREQUENCY_SHIFTER_DIRECTION_OFF : constant := 16#2#;
AL_FREQUENCY_SHIFTER_DIRECTION_UP : constant := 16#1#;
AL_FREQUENCY_SHIFTER_FREQUENCY : constant := 16#0001#;
AL_FREQUENCY_SHIFTER_LEFT_DIRECTION : constant := 16#0002#;
AL_FREQUENCY_SHIFTER_MAX_FREQUENCY : constant := 24000.0;
AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION : constant := 16#2#;
AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION : constant := 16#2#;
AL_FREQUENCY_SHIFTER_MIN_FREQUENCY : constant := 0.0;
AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION : constant := 16#0#;
AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION : constant := 16#0#;
AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION : constant := 16#0003#;
AL_HIGHPASS_GAIN : constant := 16#0001#;
AL_HIGHPASS_GAINLF : constant := 16#0002#;
AL_LOWPASS_GAIN : constant := 16#0001#;
AL_LOWPASS_GAINHF : constant := 16#0002#;
AL_METERS_PER_UNIT : constant := 16#20004#;
AL_PITCH_SHIFTER_COARSE_TUNE : constant := 16#0001#;
AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE : constant := 16#12#;
AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE : constant := 16#0#;
AL_PITCH_SHIFTER_FINE_TUNE : constant := 16#0002#;
AL_PITCH_SHIFTER_MAX_COARSE_TUNE : constant := 16#12#;
AL_PITCH_SHIFTER_MAX_FINE_TUNE : constant := 16#50#;
AL_PITCH_SHIFTER_MIN_COARSE_TUNE : constant := -16#12#;
AL_PITCH_SHIFTER_MIN_FINE_TUNE : constant := -16#50#;
AL_REVERB_AIR_ABSORPTION_GAINHF : constant := 16#000B#;
AL_REVERB_DECAY_HFLIMIT : constant := 16#000D#;
AL_REVERB_DECAY_HFRATIO : constant := 16#0006#;
AL_REVERB_DECAY_TIME : constant := 16#0005#;
AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF : constant := 0.994;
AL_REVERB_DEFAULT_DECAY_HFLIMIT : constant := 16#1#;
AL_REVERB_DEFAULT_DECAY_HFRATIO : constant := 0.83;
AL_REVERB_DEFAULT_DECAY_TIME : constant := 1.49;
AL_REVERB_DEFAULT_DENSITY : constant := 1.0;
AL_REVERB_DEFAULT_DIFFUSION : constant := 1.0;
AL_REVERB_DEFAULT_GAIN : constant := 0.32;
AL_REVERB_DEFAULT_GAINHF : constant := 0.89;
AL_REVERB_DEFAULT_LATE_REVERB_DELAY : constant := 0.011;
AL_REVERB_DEFAULT_LATE_REVERB_GAIN : constant := 1.26;
AL_REVERB_DEFAULT_REFLECTIONS_DELAY : constant := 0.007;
AL_REVERB_DEFAULT_REFLECTIONS_GAIN : constant := 0.05;
AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR : constant := 0.0;
AL_REVERB_DENSITY : constant := 16#0001#;
AL_REVERB_DIFFUSION : constant := 16#0002#;
AL_REVERB_GAIN : constant := 16#0003#;
AL_REVERB_GAINHF : constant := 16#0004#;
AL_REVERB_LATE_REVERB_DELAY : constant := 16#000A#;
AL_REVERB_LATE_REVERB_GAIN : constant := 16#0009#;
AL_REVERB_MAX_AIR_ABSORPTION_GAINHF : constant := 1.0;
AL_REVERB_MAX_DECAY_HFLIMIT : constant := 16#1#;
AL_REVERB_MAX_DECAY_HFRATIO : constant := 2.0;
AL_REVERB_MAX_DECAY_TIME : constant := 20.0;
AL_REVERB_MAX_DENSITY : constant := 1.0;
AL_REVERB_MAX_DIFFUSION : constant := 1.0;
AL_REVERB_MAX_GAIN : constant := 1.0;
AL_REVERB_MAX_GAINHF : constant := 1.0;
AL_REVERB_MAX_LATE_REVERB_DELAY : constant := 0.1;
AL_REVERB_MAX_LATE_REVERB_GAIN : constant := 10.0;
AL_REVERB_MAX_REFLECTIONS_DELAY : constant := 0.3;
AL_REVERB_MAX_REFLECTIONS_GAIN : constant := 3.16;
AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR : constant := 10.0;
AL_REVERB_MIN_AIR_ABSORPTION_GAINHF : constant := 0.892;
AL_REVERB_MIN_DECAY_HFLIMIT : constant := 16#0#;
AL_REVERB_MIN_DECAY_HFRATIO : constant := 0.1;
AL_REVERB_MIN_DECAY_TIME : constant := 0.1;
AL_REVERB_MIN_DENSITY : constant := 0.0;
AL_REVERB_MIN_DIFFUSION : constant := 0.0;
AL_REVERB_MIN_GAIN : constant := 0.0;
AL_REVERB_MIN_GAINHF : constant := 0.0;
AL_REVERB_MIN_LATE_REVERB_DELAY : constant := 0.0;
AL_REVERB_MIN_LATE_REVERB_GAIN : constant := 0.0;
AL_REVERB_MIN_REFLECTIONS_DELAY : constant := 0.0;
AL_REVERB_MIN_REFLECTIONS_GAIN : constant := 0.0;
AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR : constant := 0.0;
AL_REVERB_REFLECTIONS_DELAY : constant := 16#0008#;
AL_REVERB_REFLECTIONS_GAIN : constant := 16#0007#;
AL_REVERB_ROOM_ROLLOFF_FACTOR : constant := 16#000C#;
AL_RING_MODULATOR_DEFAULT_FREQUENCY : constant := 440.0;
AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF : constant := 800.0;
AL_RING_MODULATOR_DEFAULT_WAVEFORM : constant := 16#0#;
AL_RING_MODULATOR_FREQUENCY : constant := 16#0001#;
AL_RING_MODULATOR_HIGHPASS_CUTOFF : constant := 16#0002#;
AL_RING_MODULATOR_MAX_FREQUENCY : constant := 8000.0;
AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF : constant := 24000.0;
AL_RING_MODULATOR_MAX_WAVEFORM : constant := 16#2#;
AL_RING_MODULATOR_MIN_FREQUENCY : constant := 0.0;
AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF : constant := 0.0;
AL_RING_MODULATOR_MIN_WAVEFORM : constant := 16#0#;
AL_RING_MODULATOR_SAWTOOTH : constant := 16#1#;
AL_RING_MODULATOR_SINUSOID : constant := 16#0#;
AL_RING_MODULATOR_SQUARE : constant := 16#2#;
AL_RING_MODULATOR_WAVEFORM : constant := 16#0003#;
AL_ROOM_ROLLOFF_FACTOR : constant := 16#20008#;
AL_VOCAL_MORPHER_DEFAULT_PHONEMEA : constant := 16#0#;
AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING : constant := 16#0#;
AL_VOCAL_MORPHER_DEFAULT_PHONEMEB : constant := 16#10#;
AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING : constant := 16#0#;
AL_VOCAL_MORPHER_DEFAULT_RATE : constant := 1.41;
AL_VOCAL_MORPHER_DEFAULT_WAVEFORM : constant := 16#0#;
AL_VOCAL_MORPHER_MAX_PHONEMEA : constant := 16#29#;
AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING : constant := 16#24#;
AL_VOCAL_MORPHER_MAX_PHONEMEB : constant := 16#29#;
AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING : constant := 16#24#;
AL_VOCAL_MORPHER_MAX_RATE : constant := 10.0;
AL_VOCAL_MORPHER_MAX_WAVEFORM : constant := 16#2#;
AL_VOCAL_MORPHER_MIN_PHONEMEA : constant := 16#0#;
AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING : constant := -16#24#;
AL_VOCAL_MORPHER_MIN_PHONEMEB : constant := 16#0#;
AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING : constant := -16#24#;
AL_VOCAL_MORPHER_MIN_RATE : constant := 0.0;
AL_VOCAL_MORPHER_MIN_WAVEFORM : constant := 16#0#;
AL_VOCAL_MORPHER_PHONEMEA : constant := 16#0001#;
AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING : constant := 16#0002#;
AL_VOCAL_MORPHER_PHONEMEB : constant := 16#0003#;
AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING : constant := 16#0004#;
AL_VOCAL_MORPHER_PHONEME_A : constant := 16#0#;
AL_VOCAL_MORPHER_PHONEME_AA : constant := 16#5#;
AL_VOCAL_MORPHER_PHONEME_AE : constant := 16#6#;
AL_VOCAL_MORPHER_PHONEME_AH : constant := 16#7#;
AL_VOCAL_MORPHER_PHONEME_AO : constant := 16#8#;
AL_VOCAL_MORPHER_PHONEME_B : constant := 16#15#;
AL_VOCAL_MORPHER_PHONEME_D : constant := 16#16#;
AL_VOCAL_MORPHER_PHONEME_E : constant := 16#1#;
AL_VOCAL_MORPHER_PHONEME_EH : constant := 16#9#;
AL_VOCAL_MORPHER_PHONEME_ER : constant := 16#10#;
AL_VOCAL_MORPHER_PHONEME_F : constant := 16#17#;
AL_VOCAL_MORPHER_PHONEME_G : constant := 16#18#;
AL_VOCAL_MORPHER_PHONEME_I : constant := 16#2#;
AL_VOCAL_MORPHER_PHONEME_IH : constant := 16#11#;
AL_VOCAL_MORPHER_PHONEME_IY : constant := 16#12#;
AL_VOCAL_MORPHER_PHONEME_J : constant := 16#19#;
AL_VOCAL_MORPHER_PHONEME_K : constant := 16#20#;
AL_VOCAL_MORPHER_PHONEME_L : constant := 16#21#;
AL_VOCAL_MORPHER_PHONEME_M : constant := 16#22#;
AL_VOCAL_MORPHER_PHONEME_N : constant := 16#23#;
AL_VOCAL_MORPHER_PHONEME_O : constant := 16#3#;
AL_VOCAL_MORPHER_PHONEME_P : constant := 16#24#;
AL_VOCAL_MORPHER_PHONEME_R : constant := 16#25#;
AL_VOCAL_MORPHER_PHONEME_S : constant := 16#26#;
AL_VOCAL_MORPHER_PHONEME_T : constant := 16#27#;
AL_VOCAL_MORPHER_PHONEME_U : constant := 16#4#;
AL_VOCAL_MORPHER_PHONEME_UH : constant := 16#13#;
AL_VOCAL_MORPHER_PHONEME_UW : constant := 16#14#;
AL_VOCAL_MORPHER_PHONEME_V : constant := 16#28#;
AL_VOCAL_MORPHER_PHONEME_Z : constant := 16#29#;
AL_VOCAL_MORPHER_RATE : constant := 16#0006#;
AL_VOCAL_MORPHER_WAVEFORM : constant := 16#0005#;
AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH : constant := 16#2#;
AL_VOCAL_MORPHER_WAVEFORM_SINUSOID : constant := 16#0#;
AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE : constant := 16#1#;
--
-- OpenAL EFX
--
-- alAuxiliaryEffectSlotf
type Auxiliary_Effect_Slotf_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Float_t);
pragma Convention (C, Auxiliary_Effect_Slotf_t);
-- alAuxiliaryEffectSlotfv
type Auxiliary_Effect_Slotfv_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Auxiliary_Effect_Slotfv_t);
-- alAuxiliaryEffectSloti
type Auxiliary_Effect_Sloti_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Integer_t);
pragma Convention (C, Auxiliary_Effect_Sloti_t);
-- alAuxiliaryEffectSlotiv
type Auxiliary_Effect_Slotiv_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Auxiliary_Effect_Slotiv_t);
-- alDeleteAuxiliaryEffectSlots
type Delete_Auxiliary_Effect_Slots_t is access procedure
(Size : Types.Size_t;
Slots : System.Address);
pragma Convention (C, Delete_Auxiliary_Effect_Slots_t);
-- alDeleteEffects
type Delete_Effects_t is access procedure
(Size : Types.Size_t;
Effects : System.Address);
pragma Convention (C, Delete_Effects_t);
-- alDeleteFilters
type Delete_Filters_t is access procedure
(Size : Types.Size_t;
Filters : System.Address);
pragma Convention (C, Delete_Filters_t);
-- alEffectf
type Effectf_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Float_t);
pragma Convention (C, Effectf_t);
-- alEffectfv
type Effectfv_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Effectfv_t);
-- alEffecti
type Effecti_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Integer_t);
pragma Convention (C, Effecti_t);
-- alEffectiv
type Effectiv_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Effectiv_t);
-- alFilterf
type Filterf_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Float_t);
pragma Convention (C, Filterf_t);
-- alFilterfv
type Filterfv_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Filterfv_t);
-- alFilteri
type Filteri_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : Types.Integer_t);
pragma Convention (C, Filteri_t);
-- alFilteriv
type Filteriv_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Filteriv_t);
-- alGenAuxiliaryEffectSlots
type Gen_Auxiliary_Effect_Slots_t is access procedure
(Size : Types.Size_t;
Slots : System.Address);
pragma Convention (C, Gen_Auxiliary_Effect_Slots_t);
-- alGenEffects
type Gen_Effects_t is access procedure
(Size : Types.Size_t;
Effects : System.Address);
pragma Convention (C, Gen_Effects_t);
-- alGenFilters
type Gen_Filters_t is access procedure
(Size : Types.Size_t;
Filters : System.Address);
pragma Convention (C, Gen_Filters_t);
-- alGetAuxiliaryEffectSlotf
type Get_Auxiliary_Effect_Slotf_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Auxiliary_Effect_Slotf_t);
-- alGetAuxiliaryEffectSlotfv
type Get_Auxiliary_Effect_Slotfv_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Auxiliary_Effect_Slotfv_t);
-- alGetAuxiliaryEffectSloti
type Get_Auxiliary_Effect_Sloti_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Auxiliary_Effect_Sloti_t);
-- alGetAuxiliaryEffectSlotiv
type Get_Auxiliary_Effect_Slotiv_t is access procedure
(Slot : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Auxiliary_Effect_Slotiv_t);
-- alGetEffectf
type Get_Effectf_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : System.Address);
pragma Convention (C, Get_Effectf_t);
-- alGetEffectfv
type Get_Effectfv_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Effectfv_t);
-- alGetEffecti
type Get_Effecti_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : System.Address);
pragma Convention (C, Get_Effecti_t);
-- alGetEffectiv
type Get_Effectiv_t is access procedure
(Effect : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Effectiv_t);
-- alGetFilterf
type Get_Filterf_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : System.Address);
pragma Convention (C, Get_Filterf_t);
-- alGetFilterfv
type Get_Filterfv_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Filterfv_t);
-- alGetFilteri
type Get_Filteri_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Value : System.Address);
pragma Convention (C, Get_Filteri_t);
-- alGetFilteriv
type Get_Filteriv_t is access procedure
(Filter : Types.Unsigned_Integer_t;
Parameter : Types.Enumeration_t;
Values : System.Address);
pragma Convention (C, Get_Filteriv_t);
-- alIsAuxiliaryEffectSlot
type Is_Auxiliary_Effect_Slot_t is access function
(Slot : Types.Unsigned_Integer_t) return Types.Boolean_t;
pragma Convention (C, Is_Auxiliary_Effect_Slot_t);
-- alIsEffect
type Is_Effect_t is access function
(Effect : Types.Unsigned_Integer_t) return Types.Boolean_t;
pragma Convention (C, Is_Effect_t);
-- alIsFilter
type Is_Filter_t is access function
(Filter : Types.Unsigned_Integer_t) return Types.Boolean_t;
pragma Convention (C, Is_Filter_t);
--
-- Record type for API pointers
--
type API_t is record
Auxiliary_Effect_Slotf : Auxiliary_Effect_Slotf_t;
Auxiliary_Effect_Slotfv : Auxiliary_Effect_Slotfv_t;
Auxiliary_Effect_Sloti : Auxiliary_Effect_Sloti_t;
Auxiliary_Effect_Slotiv : Auxiliary_Effect_Slotiv_t;
Delete_Auxiliary_Effect_Slots : Delete_Auxiliary_Effect_Slots_t;
Delete_Effects : Delete_Effects_t;
Delete_Filters : Delete_Filters_t;
Effectf : Effectf_t;
Effectfv : Effectfv_t;
Effecti : Effecti_t;
Effectiv : Effectiv_t;
Filterf : Filterf_t;
Filterfv : Filterfv_t;
Filteri : Filteri_t;
Filteriv : Filteriv_t;
Gen_Auxiliary_Effect_Slots : Gen_Auxiliary_Effect_Slots_t;
Gen_Effects : Gen_Effects_t;
Gen_Filters : Gen_Filters_t;
Get_Auxiliary_Effect_Slotf : Get_Auxiliary_Effect_Slotf_t;
Get_Auxiliary_Effect_Slotfv : Get_Auxiliary_Effect_Slotfv_t;
Get_Auxiliary_Effect_Sloti : Get_Auxiliary_Effect_Sloti_t;
Get_Auxiliary_Effect_Slotiv : Get_Auxiliary_Effect_Slotiv_t;
Get_Effectf : Get_Effectf_t;
Get_Effectfv : Get_Effectfv_t;
Get_Effecti : Get_Effecti_t;
Get_Effectiv : Get_Effectiv_t;
Get_Filterf : Get_Filterf_t;
Get_Filterfv : Get_Filterfv_t;
Get_Filteri : Get_Filteri_t;
Get_Filteriv : Get_Filteriv_t;
Is_Auxiliary_Effect_Slot : Is_Auxiliary_Effect_Slot_t;
Is_Effect : Is_Effect_t;
Is_Filter : Is_Filter_t;
end record;
function Load_API return API_t;
end OpenAL.Extension.EFX_Thin;
|
-- gamma(1+x) = x! for x=0,1,2 ...
-- gamma(0.5) = sqrt(pi)
-- ln (sqrt(pi)) = 0.57236494292470008707171367567652935582354993281988
-- sqrt(pi) = 1.77245385090551602729816748334114518279737668859774
with Gamma;
with text_io; use text_io;
with ada.numerics.generic_elementary_functions;
procedure gamma_tst_1 is
type Real is digits 15;
x : real;
package G is new Gamma (Real); use G;
package math is new ada.numerics.generic_elementary_functions(Real); use math;
--for exp
function Factorial (n : in Natural) return Real is
Prod : Real := 1.0;
begin
if n < 2 then
return 1.0;
end if;
for j in 2 .. n loop
Prod := Prod * Real(j);
end loop;
return Prod;
end;
begin
Test_Stieltjes_Coefficients;
for j in 0 .. 159 loop
x := 0.1 + Real(j) * 0.1;
new_line;
put(Real'image(x));
put(real'image(log_gamma(x)-log_gamma_0_to_16(x)));
end loop;
new_line;
put(real'image(log_gamma(0.5)-0.57236494292470008707171367567652935582355));
new_line;
put(real'image(Exp (log_gamma(0.5))-1.7724538509055160272981674833411451828));
new_line;
new_line; put(real'image( (log_gamma(7.0) - Log (Factorial(6)) )));
new_line; put(real'image( (log_gamma(11.0) - Log (Factorial(10)) )));
new_line; put(real'image( (log_gamma(15.0) - Log (Factorial(14)) )));
new_line; put(real'image( (log_gamma(28.0) - Log (Factorial(27)) )));
end;
|
with Ada.Text_IO; use Ada.Text_IO;
with System.OS_Lib; use System.OS_Lib;
procedure Execute_Synchronously is
Result : Integer;
Arguments : Argument_List :=
( 1=> new String'("cmd.exe"),
2=> new String'("/C dir c:\temp\*.adb")
);
begin
Spawn
( Program_Name => "cmd.exe",
Args => Arguments,
Output_File_Descriptor => Standout,
Return_Code => Result
);
for Index in Arguments'Range loop
Free (Arguments (Index)); -- Free the argument list
end loop;
end Execute_Synchronously;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Buffers;
with GL.Objects.Renderbuffers;
with GL.Objects.Textures;
private with GL.Low_Level.Enums;
package GL.Objects.Framebuffers is
pragma Preelaborate;
type Framebuffer_Status is (Undefined, Complete, Incomplete_Attachment,
Incomplete_Missing_Attachment,
Incomplete_Draw_Buffer, Incomplete_Read_Buffer,
Unsupported, Incomplete_Multisample,
Incomplete_Layer_Targets);
type Attachment_Point is (Depth_Stencil_Attachment,
Color_Attachment_0, Color_Attachment_1,
Color_Attachment_2, Color_Attachment_3,
Color_Attachment_4, Color_Attachment_5,
Color_Attachment_6, Color_Attachment_7,
Color_Attachment_8, Color_Attachment_9,
Color_Attachment_10, Color_Attachment_11,
Color_Attachment_12, Color_Attachment_13,
Color_Attachment_14, Color_Attachment_15,
Depth_Attachment, Stencil_Attachment);
type Attachment_List is array (Positive range <>) of Attachment_Point;
type Framebuffer_Target (<>) is tagged limited private;
function Status (Target : Framebuffer_Target) return Framebuffer_Status;
procedure Attach_Renderbuffer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Renderbuffers.Renderbuffer'Class);
procedure Attach_Texture (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level);
procedure Attach_Texture_Layer (Target : Framebuffer_Target;
Attachment : Attachment_Point;
Object : Textures.Texture'Class;
Level : Textures.Mipmap_Level;
Layer : Int);
procedure Invalidate (Target : in out Framebuffer_Target;
Attachments : Attachment_List);
procedure Invalidate_Sub (Target : in out Framebuffer_Target;
Attachments : Attachment_List;
X, Y : Int;
Width, Height : Size);
procedure Set_Default_Width (Target : in out Framebuffer_Target;
Value : Size);
function Default_Width (Target : Framebuffer_Target) return Size;
function Max_Framebuffer_Width return Size;
procedure Set_Default_Height (Target : in out Framebuffer_Target;
Value : Size);
function Default_Height (Target : Framebuffer_Target) return Size;
function Max_Framebuffer_Height return Size;
procedure Set_Default_Layers (Target : in out Framebuffer_Target;
Value : Size);
function Default_Layers (Target : Framebuffer_Target) return Size;
function Max_Framebuffer_Layers return Size;
procedure Set_Default_Samples (Target : in out Framebuffer_Target;
Value : Size);
function Default_Samples
(Target : Framebuffer_Target) return Size;
function Max_Framebuffer_Samples return Size;
procedure Set_Default_Fixed_Sample_Locactions
(Target : in out Framebuffer_Target; Value : Boolean);
function Default_Fixed_Sample_Locations (Target : Framebuffer_Target)
return Boolean;
-- copy from current Read to current Draw framebuffer
procedure Blit (Src_X0, Src_Y0, Src_X1, Src_Y1,
Dst_X0, Dst_Y0, Dst_X1, Dst_Y1 : Int;
Mask : Buffers.Buffer_Bits;
Filter : Textures.Magnifying_Function);
type Framebuffer is new GL_Object with private;
procedure Bind (Target : Framebuffer_Target;
Object : Framebuffer'Class);
function Current (Target : Framebuffer_Target) return Framebuffer'Class;
Read_Target : constant Framebuffer_Target;
Draw_Target : constant Framebuffer_Target;
Read_And_Draw_Target : constant Framebuffer_Target;
Default_Framebuffer : constant Framebuffer;
private
for Framebuffer_Status use (Undefined => 16#8219#,
Complete => 16#8CD5#,
Incomplete_Attachment => 16#8CD6#,
Incomplete_Missing_Attachment => 16#8CD7#,
Incomplete_Draw_Buffer => 16#8CDB#,
Incomplete_Read_Buffer => 16#8CDC#,
Unsupported => 16#8CDD#,
Incomplete_Multisample => 16#8D56#,
Incomplete_Layer_Targets => 16#8DA8#);
for Framebuffer_Status'Size use Low_Level.Enum'Size;
for Attachment_Point use (Depth_Stencil_Attachment => 16#821A#,
Color_Attachment_0 => 16#8CE0#,
Color_Attachment_1 => 16#8CE1#,
Color_Attachment_2 => 16#8CE2#,
Color_Attachment_3 => 16#8CE3#,
Color_Attachment_4 => 16#8CE4#,
Color_Attachment_5 => 16#8CE5#,
Color_Attachment_6 => 16#8CE6#,
Color_Attachment_7 => 16#8CE7#,
Color_Attachment_8 => 16#8CE8#,
Color_Attachment_9 => 16#8CE9#,
Color_Attachment_10 => 16#8CEA#,
Color_Attachment_11 => 16#8CEB#,
Color_Attachment_12 => 16#8CEC#,
Color_Attachment_13 => 16#8CED#,
Color_Attachment_14 => 16#8CEE#,
Color_Attachment_15 => 16#8CEF#,
Depth_Attachment => 16#8D00#,
Stencil_Attachment => 16#8D01#);
for Attachment_Point'Size use Low_Level.Enum'Size;
pragma Convention (C, Attachment_List);
type Framebuffer is new GL_Object with null record;
overriding
procedure Internal_Create_Id (Object : Framebuffer; Id : out UInt);
overriding
procedure Internal_Release_Id (Object : Framebuffer; Id : UInt);
type Framebuffer_Target (Kind : Low_Level.Enums.Framebuffer_Kind) is
tagged limited null record;
Read_Target : constant Framebuffer_Target :=
Framebuffer_Target'(Kind => Low_Level.Enums.Read);
Draw_Target : constant Framebuffer_Target :=
Framebuffer_Target'(Kind => Low_Level.Enums.Draw);
Read_And_Draw_Target : constant Framebuffer_Target :=
Framebuffer_Target'(Kind => Low_Level.Enums.Read_Draw);
Default_Framebuffer : constant Framebuffer :=
Framebuffer'(Ada.Finalization.Controlled with Reference =>
Reference_To_Null_Object'Access);
end GL.Objects.Framebuffers;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A T R E E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2015, 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 Alloc;
with Sinfo; use Sinfo;
with Einfo; use Einfo;
with Namet; use Namet;
with Types; use Types;
with Snames; use Snames;
with System; use System;
with Table;
with Uintp; use Uintp;
with Urealp; use Urealp;
with Unchecked_Conversion;
package Atree is
-- This package defines the format of the tree used to represent the Ada
-- program internally. Syntactic and semantic information is combined in
-- this tree. There is no separate symbol table structure.
-- WARNING: There is a C version of this package. Any changes to this source
-- file must be properly reflected in the C header file atree.h
-- Package Atree defines the basic structure of the tree and its nodes and
-- provides the basic abstract interface for manipulating the tree. Two other
-- packages use this interface to define the representation of Ada programs
-- using this tree format. The package Sinfo defines the basic representation
-- of the syntactic structure of the program, as output by the parser. The
-- package Einfo defines the semantic information which is added to the tree
-- nodes that represent declared entities (i.e. the information which might
-- typically be described in a separate symbol table structure).
-- The front end of the compiler first parses the program and generates a
-- tree that is simply a syntactic representation of the program in abstract
-- syntax tree format. Subsequent processing in the front end traverses the
-- tree, transforming it in various ways and adding semantic information.
----------------------
-- Size of Entities --
----------------------
-- Currently entities are composed of 7 sequentially allocated 32-byte
-- nodes, considered as a single record. The following definition gives
-- the number of extension nodes.
Num_Extension_Nodes : Node_Id := 6;
-- This value is increased by one if debug flag -gnatd.N is set. This is
-- for testing performance impact of adding a new extension node. We make
-- this of type Node_Id for easy reference in loops using this value.
----------------------------------------
-- Definitions of Fields in Tree Node --
----------------------------------------
-- The representation of the tree is completely hidden, using a functional
-- interface for accessing and modifying the contents of nodes. Logically
-- a node contains a number of fields, much as though the nodes were
-- defined as a record type. The fields in a node are as follows:
-- Nkind Indicates the kind of the node. This field is present
-- in all nodes. The type is Node_Kind, which is declared
-- in the package Sinfo.
-- Sloc Location (Source_Ptr) of the corresponding token
-- in the Source buffer. The individual node definitions
-- show which token is referenced by this pointer.
-- In_List A flag used to indicate if the node is a member
-- of a node list.
-- Rewrite_Ins A flag set if a node is marked as a rewrite inserted
-- node as a result of a call to Mark_Rewrite_Insertion.
-- Paren_Count A 2-bit count used in sub-expression nodes to indicate
-- the level of parentheses. The settings are 0,1,2 and
-- 3 for many. If the value is 3, then an auxiliary table
-- is used to indicate the real value. Set to zero for
-- non-subexpression nodes.
-- Note: the required parentheses surrounding conditional
-- and quantified expressions count as a level of parens
-- for this purpose, so e.g. in X := (if A then B else C);
-- Paren_Count for the right side will be 1.
-- Comes_From_Source
-- This flag is present in all nodes. It is set if the
-- node is built by the scanner or parser, and clear if
-- the node is built by the analyzer or expander. It
-- indicates that the node corresponds to a construct
-- that appears in the original source program.
-- Analyzed This flag is present in all nodes. It is set when
-- a node is analyzed, and is used to avoid analyzing
-- the same node twice. Analysis includes expansion if
-- expansion is active, so in this case if the flag is
-- set it means the node has been analyzed and expanded.
-- Error_Posted This flag is present in all nodes. It is set when
-- an error message is posted which is associated with
-- the flagged node. This is used to avoid posting more
-- than one message on the same node.
-- Field1
-- Field2
-- Field3
-- Field4
-- Field5 Five fields holding Union_Id values
-- ElistN Synonym for FieldN typed as Elist_Id (Empty = No_Elist)
-- ListN Synonym for FieldN typed as List_Id
-- NameN Synonym for FieldN typed as Name_Id
-- NodeN Synonym for FieldN typed as Node_Id
-- StrN Synonym for FieldN typed as String_Id
-- UintN Synonym for FieldN typed as Uint (Empty = Uint_0)
-- UrealN Synonym for FieldN typed as Ureal
-- Note: in the case of ElistN and UintN fields, it is common that we
-- end up with a value of Union_Id'(0) as the default value. This value
-- is meaningless as a Uint or Elist_Id value. We have two choices here.
-- We could require that all Uint and Elist fields be initialized to an
-- appropriate value, but that's error prone, since it would be easy to
-- miss an initialization. So instead we have the retrieval functions
-- generate an appropriate default value (Uint_0 or No_Elist). Probably
-- it would be cleaner to generate No_Uint in the Uint case but we got
-- stuck with representing an "unset" size value as zero early on, and
-- it will take a bit of fiddling to change that ???
-- Note: the actual usage of FieldN (i.e. whether it contains a Elist_Id,
-- List_Id, Name_Id, Node_Id, String_Id, Uint or Ureal) depends on the
-- value in Nkind. Generally the access to this field is always via the
-- functional interface, so the field names ElistN, ListN, NameN, NodeN,
-- StrN, UintN and UrealN are used only in the bodies of the access
-- functions (i.e. in the bodies of Sinfo and Einfo). These access
-- functions contain debugging code that checks that the use is
-- consistent with Nkind and Ekind values.
-- However, in specialized circumstances (examples are the circuit in
-- generic instantiation to copy trees, and in the tree dump routine),
-- it is useful to be able to do untyped traversals, and an internal
-- package in Atree allows for direct untyped accesses in such cases.
-- Flag0 Nineteen Boolean flags (use depends on Nkind and
-- Flag1 Ekind, as described for FieldN). Again the access
-- Flag2 is usually via subprograms in Sinfo and Einfo which
-- Flag3 provide high-level synonyms for these flags, and
-- Flag4 contain debugging code that checks that the values
-- Flag5 in Nkind and Ekind are appropriate for the access.
-- Flag6
-- Flag7
-- Flag8
-- Flag9
-- Flag10
-- Flag11 Note that Flag0-3 are stored separately in the Flags
-- Flag12 table, but that's a detail of the implementation which
-- Flag13 is entirely hidden by the funcitonal interface.
-- Flag14
-- Flag15
-- Flag16
-- Flag17
-- Flag18
-- Link For a node, points to the Parent. For a list, points
-- to the list header. Note that in the latter case, a
-- client cannot modify the link field. This field is
-- private to the Atree package (but is also modified
-- by the Nlists package).
-- The following additional fields are present in extended nodes used
-- for entities (Nkind in N_Entity).
-- Ekind Entity type. This field indicates the type of the
-- entity, it is of type Entity_Kind which is defined
-- in package Einfo.
-- Flag19 299 additional flags
-- ...
-- Flag317
-- Convention Entity convention (Convention_Id value)
-- Field6 Additional Union_Id value stored in tree
-- Node6 Synonym for Field6 typed as Node_Id
-- Elist6 Synonym for Field6 typed as Elist_Id (Empty = No_Elist)
-- Uint6 Synonym for Field6 typed as Uint (Empty = Uint_0)
-- Similar definitions for Field7 to Field41 (and also Node7-Node41,
-- Elist7-Elist41, Uint7-Uint41, Ureal7-Ureal41). Note that not all
-- these functions are defined, only the ones that are actually used.
function Last_Node_Id return Node_Id;
pragma Inline (Last_Node_Id);
-- Returns Id of last allocated node Id
function Nodes_Address return System.Address;
-- Return address of Nodes table (used in Back_End for Gigi call)
function Flags_Address return System.Address;
-- Return address of Flags table (used in Back_End for Gigi call)
function Num_Nodes return Nat;
-- Total number of nodes allocated, where an entity counts as a single
-- node. This count is incremented every time a node or entity is
-- allocated, and decremented every time a node or entity is deleted.
-- This value is used by Xref and by Treepr to allocate hash tables of
-- suitable size for hashing Node_Id values.
-----------------------
-- Use of Empty Node --
-----------------------
-- The special Node_Id Empty is used to mark missing fields. Whenever the
-- syntax has an optional component, then the corresponding field will be
-- set to Empty if the component is missing.
-- Note: Empty is not used to describe an empty list. Instead in this
-- case the node field contains a list which is empty, and these cases
-- should be distinguished (essentially from a type point of view, Empty
-- is a Node, and is thus not a list).
-- Note: Empty does in fact correspond to an allocated node. Only the
-- Nkind field of this node may be referenced. It contains N_Empty, which
-- uniquely identifies the empty case. This allows the Nkind field to be
-- dereferenced before the check for Empty which is sometimes useful.
-----------------------
-- Use of Error Node --
-----------------------
-- The Error node is used during syntactic and semantic analysis to
-- indicate that the corresponding piece of syntactic structure or
-- semantic meaning cannot properly be represented in the tree because
-- of an illegality in the program.
-- If an Error node is encountered, then you know that a previous
-- illegality has been detected. The proper reaction should be to
-- avoid posting related cascaded error messages, and to propagate
-- the error node if necessary.
------------------------
-- Current_Error_Node --
------------------------
-- The current error node is a global location indicating the current
-- node that is being processed for the purposes of placing a compiler
-- abort message. This is not necessarily perfectly accurate, it is
-- just a reasonably accurate best guess. It is used to output the
-- source location in the abort message by Comperr, and also to
-- implement the d3 debugging flag. This is also used by Rtsfind
-- to generate error messages for high integrity mode.
-- There are two ways this gets set. During parsing, when new source
-- nodes are being constructed by calls to New_Node and New_Entity,
-- either one of these calls sets Current_Error_Node to the newly
-- created node. During semantic analysis, this mechanism is not
-- used, and instead Current_Error_Node is set by the subprograms in
-- Debug_A that mark the start and end of analysis/expansion of a
-- node in the tree.
Current_Error_Node : Node_Id;
-- Node to place error messages
------------------
-- Error Counts --
------------------
-- The following variables denote the count of errors of various kinds
-- detected in the tree. Note that these might be more logically located
-- in Err_Vars, but we put it to deal with licensing issues (we need this
-- to have the GPL exception licensing, since Check_Error_Detected can
-- be called from units with this licensing).
Serious_Errors_Detected : Nat := 0;
-- This is a count of errors that are serious enough to stop expansion,
-- and hence to prevent generation of an object file even if the
-- switch -gnatQ is set. Initialized to zero at the start of compilation.
-- Initialized for -gnatVa use, see comment above.
Total_Errors_Detected : Nat := 0;
-- Number of errors detected so far. Includes count of serious errors and
-- non-serious errors, so this value is always greater than or equal to the
-- Serious_Errors_Detected value. Initialized to zero at the start of
-- compilation. Initialized for -gnatVa use, see comment above.
Warnings_Detected : Nat := 0;
-- Number of warnings detected. Initialized to zero at the start of
-- compilation. Initialized for -gnatVa use, see comment above. This
-- count includes the count of style and info messages.
Info_Messages : Nat := 0;
-- Number of info messages generated. Info messages are neved treated as
-- errors (whether from use of the pragma, or the compiler switch -gnatwe).
Check_Messages : Nat := 0;
-- Number of check messages generated. Check messages are neither warnings
-- nor errors.
Warnings_Treated_As_Errors : Nat := 0;
-- Number of warnings changed into errors as a result of matching a pattern
-- given in a Warning_As_Error configuration pragma.
Configurable_Run_Time_Violations : Nat := 0;
-- Count of configurable run time violations so far. This is used to
-- suppress certain cascaded error messages when we know that we may not
-- have fully expanded some items, due to high integrity violations (e.g.
-- the use of constructs not permitted by the library in use, or improper
-- constructs in No_Run_Time mode).
procedure Check_Error_Detected;
-- When an anomaly is found in the tree, many semantic routines silently
-- bail out, assuming that the anomaly was caused by a previously detected
-- serious error (or configurable run time violation). This routine should
-- be called in these cases, and will raise an exception if no such error
-- has been detected. This ensure that the anomaly is never allowed to go
-- unnoticed.
-------------------------------
-- Default Setting of Fields --
-------------------------------
-- Nkind is set to N_Unused_At_Start
-- Ekind is set to E_Void
-- Sloc is always set, there is no default value
-- Field1-5 fields are set to Empty
-- Field6-41 fields in extended nodes are set to Empty
-- Parent is set to Empty
-- All Boolean flag fields are set to False
-- Note: the value Empty is used in Field1-Field41 to indicate a null node.
-- The usage varies. The common uses are to indicate absence of an optional
-- clause or a completely unused Field1-35 field.
-------------------------------------
-- Use of Synonyms for Node Fields --
-------------------------------------
-- A subpackage Atree.Unchecked_Access provides routines for reading and
-- writing the fields defined above (Field1-35, Node1-35, Flag0-317 etc).
-- These unchecked access routines can be used for untyped traversals.
-- In addition they are used in the implementations of the Sinfo and
-- Einfo packages. These packages both provide logical synonyms for
-- the generic fields, together with an appropriate set of access routines.
-- Normally access to information within tree nodes uses these synonyms,
-- providing a high level typed interface to the tree information.
--------------------------------------------------
-- Node Allocation and Modification Subprograms --
--------------------------------------------------
-- Generally the parser builds the tree and then it is further decorated
-- (e.g. by setting the entity fields), but not fundamentally modified.
-- However, there are cases in which the tree must be restructured by
-- adding and rearranging nodes, as a result of disambiguating cases
-- which the parser could not parse correctly, and adding additional
-- semantic information (e.g. making constraint checks explicit). The
-- following subprograms are used for constructing the tree in the first
-- place, and then for subsequent modifications as required.
procedure Initialize;
-- Called at the start of compilation to initialize the allocation of
-- the node and list tables and make the standard entries for Empty,
-- Error and Error_List. Note that Initialize must not be called if
-- Tree_Read is used.
procedure Lock;
-- Called before the back end is invoked to lock the nodes table
-- Also called after Unlock to relock???
procedure Unlock;
-- Unlocks nodes table, in cases where the back end needs to modify it
procedure Tree_Read;
-- Initializes internal tables from current tree file using the relevant
-- Table.Tree_Read routines. Note that Initialize should not be called if
-- Tree_Read is used. Tree_Read includes all necessary initialization.
procedure Tree_Write;
-- Writes out internal tables to current tree file using the relevant
-- Table.Tree_Write routines.
function New_Node
(New_Node_Kind : Node_Kind;
New_Sloc : Source_Ptr) return Node_Id;
-- Allocates a completely new node with the given node type and source
-- location values. All other fields are set to their standard defaults:
--
-- Empty for all FieldN fields
-- False for all FlagN fields
--
-- The usual approach is to build a new node using this function and
-- then, using the value returned, use the Set_xxx functions to set
-- fields of the node as required. New_Node can only be used for
-- non-entity nodes, i.e. it never generates an extended node.
--
-- If we are currently parsing, as indicated by a previous call to
-- Set_Comes_From_Source_Default (True), then this call also resets
-- the value of Current_Error_Node.
function New_Entity
(New_Node_Kind : Node_Kind;
New_Sloc : Source_Ptr) return Entity_Id;
-- Similar to New_Node, except that it is used only for entity nodes
-- and returns an extended node.
procedure Set_Comes_From_Source_Default (Default : Boolean);
-- Sets value of Comes_From_Source flag to be used in all subsequent
-- New_Node and New_Entity calls until another call to this procedure
-- changes the default. This value is set True during parsing and
-- False during semantic analysis. This is also used to determine
-- if New_Node and New_Entity should set Current_Error_Node.
function Get_Comes_From_Source_Default return Boolean;
pragma Inline (Get_Comes_From_Source_Default);
-- Gets the current value of the Comes_From_Source flag
procedure Preserve_Comes_From_Source (NewN, OldN : Node_Id);
pragma Inline (Preserve_Comes_From_Source);
-- When a node is rewritten, it is sometimes appropriate to preserve the
-- original comes from source indication. This is true when the rewrite
-- essentially corresponds to a transformation corresponding exactly to
-- semantics in the reference manual. This procedure copies the setting
-- of Comes_From_Source from OldN to NewN.
function Has_Extension (N : Node_Id) return Boolean;
pragma Inline (Has_Extension);
-- Returns True if the given node has an extension (i.e. was created by
-- a call to New_Entity rather than New_Node, and Nkind is in N_Entity)
procedure Change_Node (N : Node_Id; New_Node_Kind : Node_Kind);
-- This procedure replaces the given node by setting its Nkind field to
-- the indicated value and resetting all other fields to their default
-- values except for Sloc, which is unchanged, and the Parent pointer
-- and list links, which are also unchanged. All other information in
-- the original node is lost. The new node has an extension if the
-- original node had an extension.
procedure Copy_Node (Source : Node_Id; Destination : Node_Id);
-- Copy the entire contents of the source node to the destination node.
-- The contents of the source node is not affected. If the source node
-- has an extension, then the destination must have an extension also.
-- The parent pointer of the destination and its list link, if any, are
-- not affected by the copy. Note that parent pointers of descendents
-- are not adjusted, so the descendents of the destination node after
-- the Copy_Node is completed have dubious parent pointers. Note that
-- this routine does NOT copy aspect specifications, the Has_Aspects
-- flag in the returned node will always be False. The caller must deal
-- with copying aspect specifications where this is required.
function New_Copy (Source : Node_Id) return Node_Id;
-- This function allocates a completely new node, and then initializes
-- it by copying the contents of the source node into it. The contents of
-- the source node is not affected. The target node is always marked as
-- not being in a list (even if the source is a list member), and not
-- overloaded. The new node will have an extension if the source has
-- an extension. New_Copy (Empty) returns Empty, and New_Copy (Error)
-- returns Error. Note that, unlike Copy_Separate_Tree, New_Copy does not
-- recursively copy any descendents, so in general parent pointers are not
-- set correctly for the descendents of the copied node. Both normal and
-- extended nodes (entities) may be copied using New_Copy.
function Relocate_Node (Source : Node_Id) return Node_Id;
-- Source is a non-entity node that is to be relocated. A new node is
-- allocated, and the contents of Source are copied to this node, using
-- New_Copy. The parent pointers of descendents of the node are then
-- adjusted to point to the relocated copy. The original node is not
-- modified, but the parent pointers of its descendents are no longer
-- valid. The new copy is always marked as not overloaded. This routine is
-- used in conjunction with the tree rewrite routines (see descriptions of
-- Replace/Rewrite).
--
-- Note that the resulting node has the same parent as the source node, and
-- is thus still attached to the tree. It is valid for Source to be Empty,
-- in which case Relocate_Node simply returns Empty as the result.
function Copy_Separate_Tree (Source : Node_Id) return Node_Id;
-- Given a node that is the root of a subtree, Copy_Separate_Tree copies
-- the entire syntactic subtree, including recursively any descendants
-- whose parent field references a copied node (descendants not linked to
-- a copied node by the parent field are also copied.) The parent pointers
-- in the copy are properly set. Copy_Separate_Tree (Empty/Error) returns
-- Empty/Error. The new subtree does not share entities with the source,
-- but has new entities with the same name.
--
-- Most of the time this routine is called on an unanalyzed tree, and no
-- semantic information is copied. However, to ensure that no entities
-- are shared between the two when the source is already analyzed, and
-- that the result looks like an unanalyzed tree from the parser, Entity
-- fields and Etype fields are set to Empty, and Analyzed flags set False.
--
-- In addition, Expanded_Name nodes are converted back into the original
-- parser form (where they are Selected_Components), so that reanalysis
-- does the right thing.
function Copy_Separate_List (Source : List_Id) return List_Id;
-- Applies Copy_Separate_Tree to each element of the Source list, returning
-- a new list of the results of these copy operations.
procedure Exchange_Entities (E1 : Entity_Id; E2 : Entity_Id);
-- Exchange the contents of two entities. The parent pointers are switched
-- as well as the Defining_Identifier fields in the parents, so that the
-- entities point correctly to their original parents. The effect is thus
-- to leave the tree completely unchanged in structure, except that the
-- entity ID values of the two entities are interchanged. Neither of the
-- two entities may be list members. Note that entities appear on two
-- semantic chains: Homonym and Next_Entity: the corresponding links must
-- be adjusted by the caller, according to context.
function Extend_Node (Node : Node_Id) return Entity_Id;
-- This function returns a copy of its input node with an extension added.
-- The fields of the extension are set to Empty. Due to the way extensions
-- are handled (as four consecutive array elements), it may be necessary
-- to reallocate the node, so that the returned value is not the same as
-- the input value, but where possible the returned value will be the same
-- as the input value (i.e. the extension will occur in place). It is the
-- caller's responsibility to ensure that any pointers to the original node
-- are appropriately updated. This function is used only by Sinfo.CN to
-- change nodes into their corresponding entities.
type Report_Proc is access procedure (Target : Node_Id; Source : Node_Id);
procedure Set_Reporting_Proc (P : Report_Proc);
-- Register a procedure that is invoked when a node is allocated, replaced
-- or rewritten.
type Traverse_Result is (Abandon, OK, OK_Orig, Skip);
-- This is the type of the result returned by the Process function passed
-- to Traverse_Func and Traverse_Proc. See below for details.
subtype Traverse_Final_Result is Traverse_Result range Abandon .. OK;
-- This is the type of the final result returned Traverse_Func, based on
-- the results of Process calls. See below for details.
generic
with function Process (N : Node_Id) return Traverse_Result is <>;
function Traverse_Func (Node : Node_Id) return Traverse_Final_Result;
-- This is a generic function that, given the parent node for a subtree,
-- traverses all syntactic nodes of this tree, calling the given function
-- Process on each one, in pre order (i.e. top-down). The order of
-- traversing subtrees is arbitrary. The traversal is controlled as follows
-- by the result returned by Process:
-- OK The traversal continues normally with the syntactic
-- children of the node just processed.
-- OK_Orig The traversal continues normally with the syntactic
-- children of the original node of the node just processed.
-- Skip The children of the node just processed are skipped and
-- excluded from the traversal, but otherwise processing
-- continues elsewhere in the tree.
-- Abandon The entire traversal is immediately abandoned, and the
-- original call to Traverse returns Abandon.
-- The result returned by Traverse is Abandon if processing was terminated
-- by a call to Process returning Abandon, otherwise it is OK (meaning that
-- all calls to process returned either OK, OK_Orig, or Skip).
generic
with function Process (N : Node_Id) return Traverse_Result is <>;
procedure Traverse_Proc (Node : Node_Id);
pragma Inline (Traverse_Proc);
-- This is the same as Traverse_Func except that no result is returned,
-- i.e. Traverse_Func is called and the result is simply discarded.
---------------------------
-- Node Access Functions --
---------------------------
-- The following functions return the contents of the indicated field of
-- the node referenced by the argument, which is a Node_Id.
function Analyzed (N : Node_Id) return Boolean;
pragma Inline (Analyzed);
function Comes_From_Source (N : Node_Id) return Boolean;
pragma Inline (Comes_From_Source);
function Error_Posted (N : Node_Id) return Boolean;
pragma Inline (Error_Posted);
function Has_Aspects (N : Node_Id) return Boolean;
pragma Inline (Has_Aspects);
function Is_Ignored_Ghost_Node
(N : Node_Id) return Boolean;
pragma Inline (Is_Ignored_Ghost_Node);
function Nkind (N : Node_Id) return Node_Kind;
pragma Inline (Nkind);
function No (N : Node_Id) return Boolean;
pragma Inline (No);
-- Tests given Id for equality with the Empty node. This allows notations
-- like "if No (Variant_Part)" as opposed to "if Variant_Part = Empty".
function Parent (N : Node_Id) return Node_Id;
pragma Inline (Parent);
-- Returns the parent of a node if the node is not a list member, or else
-- the parent of the list containing the node if the node is a list member.
function Paren_Count (N : Node_Id) return Nat;
pragma Inline (Paren_Count);
function Present (N : Node_Id) return Boolean;
pragma Inline (Present);
-- Tests given Id for inequality with the Empty node. This allows notations
-- like "if Present (Statement)" as opposed to "if Statement /= Empty".
function Sloc (N : Node_Id) return Source_Ptr;
pragma Inline (Sloc);
---------------------
-- Node_Kind Tests --
---------------------
-- These are like the functions in Sinfo, but the first argument is a
-- Node_Id, and the tested field is Nkind (N).
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind;
V8 : Node_Kind) return Boolean;
function Nkind_In
(N : Node_Id;
V1 : Node_Kind;
V2 : Node_Kind;
V3 : Node_Kind;
V4 : Node_Kind;
V5 : Node_Kind;
V6 : Node_Kind;
V7 : Node_Kind;
V8 : Node_Kind;
V9 : Node_Kind) return Boolean;
pragma Inline (Nkind_In);
-- Inline all above functions
-----------------------
-- Entity_Kind_Tests --
-----------------------
-- Utility functions to test whether an Entity_Kind value, either given
-- directly as the first argument, or the Ekind field of an Entity give
-- as the first argument, matches any of the given list of Entity_Kind
-- values. Return True if any match, False if no match.
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind;
V8 : Entity_Kind) return Boolean;
function Ekind_In
(E : Entity_Id;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind;
V8 : Entity_Kind;
V9 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind;
V8 : Entity_Kind) return Boolean;
function Ekind_In
(T : Entity_Kind;
V1 : Entity_Kind;
V2 : Entity_Kind;
V3 : Entity_Kind;
V4 : Entity_Kind;
V5 : Entity_Kind;
V6 : Entity_Kind;
V7 : Entity_Kind;
V8 : Entity_Kind;
V9 : Entity_Kind) return Boolean;
pragma Inline (Ekind_In);
-- Inline all above functions
-----------------------------
-- Entity Access Functions --
-----------------------------
-- The following functions apply only to Entity_Id values, i.e.
-- to extended nodes.
function Ekind (E : Entity_Id) return Entity_Kind;
pragma Inline (Ekind);
function Convention (E : Entity_Id) return Convention_Id;
pragma Inline (Convention);
----------------------------
-- Node Update Procedures --
----------------------------
-- The following functions set a specified field in the node whose Id is
-- passed as the first argument. The second parameter is the new value
-- to be set in the specified field. Note that Set_Nkind is in the next
-- section, since its use is restricted.
procedure Set_Analyzed (N : Node_Id; Val : Boolean := True);
pragma Inline (Set_Analyzed);
procedure Set_Comes_From_Source (N : Node_Id; Val : Boolean);
pragma Inline (Set_Comes_From_Source);
-- Note that this routine is very rarely used, since usually the default
-- mechanism provided sets the right value, but in some unusual cases, the
-- value needs to be reset (e.g. when a source node is copied, and the copy
-- must not have Comes_From_Source set).
procedure Set_Error_Posted (N : Node_Id; Val : Boolean := True);
pragma Inline (Set_Error_Posted);
procedure Set_Has_Aspects (N : Node_Id; Val : Boolean := True);
pragma Inline (Set_Has_Aspects);
procedure Set_Is_Ignored_Ghost_Node (N : Node_Id; Val : Boolean := True);
pragma Inline (Set_Is_Ignored_Ghost_Node);
procedure Set_Original_Node (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Original_Node);
-- Note that this routine is used only in very peculiar cases. In normal
-- cases, the Original_Node link is set by calls to Rewrite. We currently
-- use it in ASIS mode to manually set the link from pragma expressions to
-- their aspect original source expressions, so that the original source
-- expressions accessed by ASIS are also semantically analyzed.
procedure Set_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Parent);
procedure Set_Paren_Count (N : Node_Id; Val : Nat);
pragma Inline (Set_Paren_Count);
procedure Set_Sloc (N : Node_Id; Val : Source_Ptr);
pragma Inline (Set_Sloc);
------------------------------
-- Entity Update Procedures --
------------------------------
-- The following procedures apply only to Entity_Id values, i.e.
-- to extended nodes.
procedure Basic_Set_Convention (E : Entity_Id; Val : Convention_Id);
pragma Inline (Basic_Set_Convention);
-- Clients should use Sem_Util.Set_Convention rather than calling this
-- routine directly, as Set_Convention also deals with the special
-- processing required for access types.
procedure Set_Ekind (E : Entity_Id; Val : Entity_Kind);
pragma Inline (Set_Ekind);
---------------------------
-- Tree Rewrite Routines --
---------------------------
-- During the compilation process it is necessary in a number of situations
-- to rewrite the tree. In some cases, such rewrites do not affect the
-- structure of the tree, for example, when an indexed component node is
-- replaced by the corresponding call node (the parser cannot distinguish
-- between these two cases).
-- In other situations, the rewrite does affect the structure of the
-- tree. Examples are the replacement of a generic instantiation by the
-- instantiated spec and body, and the static evaluation of expressions.
-- If such structural modifications are done by the expander, there are
-- no difficulties, since the form of the tree after the expander has no
-- special significance, except as input to the backend of the compiler.
-- However, if these modifications are done by the semantic phase, then
-- it is important that they be done in a manner which allows the original
-- tree to be preserved. This is because tools like pretty printers need
-- to have this original tree structure available.
-- The subprograms in this section allow rewriting of the tree by either
-- insertion of new nodes in an existing list, or complete replacement of
-- a subtree. The resulting tree for most purposes looks as though it has
-- been really changed, and there is no trace of the original. However,
-- special subprograms, also defined in this section, allow the original
-- tree to be reconstructed if necessary.
-- For tree modifications done in the expander, it is permissible to
-- destroy the original tree, although it is also allowable to use the
-- tree rewrite routines where it is convenient to do so.
procedure Mark_Rewrite_Insertion (New_Node : Node_Id);
pragma Inline (Mark_Rewrite_Insertion);
-- This procedure marks the given node as an insertion made during a tree
-- rewriting operation. Only the root needs to be marked. The call does
-- not do the actual insertion, which must be done using one of the normal
-- list insertion routines. The node is treated normally in all respects
-- except for its response to Is_Rewrite_Insertion. The function of these
-- calls is to be able to get an accurate original tree. This helps the
-- accuracy of Sprint.Sprint_Node, and in particular, when stubs are being
-- generated, it is essential that the original tree be accurate.
function Is_Rewrite_Insertion (Node : Node_Id) return Boolean;
pragma Inline (Is_Rewrite_Insertion);
-- Tests whether the given node was marked using Mark_Rewrite_Insertion.
-- This is used in reconstructing the original tree (where such nodes are
-- to be eliminated).
procedure Rewrite (Old_Node, New_Node : Node_Id);
-- This is used when a complete subtree is to be replaced. Old_Node is the
-- root of the old subtree to be replaced, and New_Node is the root of the
-- newly constructed replacement subtree. The actual mechanism is to swap
-- the contents of these two nodes fixing up the parent pointers of the
-- replaced node (we do not attempt to preserve parent pointers for the
-- original node). Neither Old_Node nor New_Node can be extended nodes.
--
-- Note: New_Node may not contain references to Old_Node, for example as
-- descendents, since the rewrite would make such references invalid. If
-- New_Node does need to reference Old_Node, then these references should
-- be to a relocated copy of Old_Node (see Relocate_Node procedure).
--
-- Note: The Original_Node function applied to Old_Node (which has now
-- been replaced by the contents of New_Node), can be used to obtain the
-- original node, i.e. the old contents of Old_Node.
procedure Replace (Old_Node, New_Node : Node_Id);
-- This is similar to Rewrite, except that the old value of Old_Node is
-- not saved, and the New_Node is deleted after the replace, since it
-- is assumed that it can no longer be legitimately needed. The flag
-- Is_Rewrite_Substitution will be False for the resulting node, unless
-- it was already true on entry, and Original_Node will not return the
-- original contents of the Old_Node, but rather the New_Node value (unless
-- Old_Node had already been rewritten using Rewrite). Replace also
-- preserves the setting of Comes_From_Source.
--
-- Note, New_Node may not contain references to Old_Node, for example as
-- descendents, since the rewrite would make such references invalid. If
-- New_Node does need to reference Old_Node, then these references should
-- be to a relocated copy of Old_Node (see Relocate_Node procedure).
--
-- Replace is used in certain circumstances where it is desirable to
-- suppress any history of the rewriting operation. Notably, it is used
-- when the parser has mis-classified a node (e.g. a task entry call
-- that the parser has parsed as a procedure call).
function Is_Rewrite_Substitution (Node : Node_Id) return Boolean;
pragma Inline (Is_Rewrite_Substitution);
-- Return True iff Node has been rewritten (i.e. if Node is the root
-- of a subtree which was installed using Rewrite).
function Original_Node (Node : Node_Id) return Node_Id;
pragma Inline (Original_Node);
-- If Node has not been rewritten, then returns its input argument
-- unchanged, else returns the Node for the original subtree. Note that
-- this is used extensively by ASIS on the trees constructed in ASIS mode
-- to reconstruct the original semantic tree. See section in sinfo.ads
-- for requirements on original nodes returned by this function.
--
-- Note: Parents are not preserved in original tree nodes that are
-- retrieved in this way (i.e. their children may have children whose
-- pointers which reference some other node). This needs more details???
--
-- Note: there is no direct mechanism for deleting an original node (in
-- a manner that can be reversed later). One possible approach is to use
-- Rewrite to substitute a null statement for the node to be deleted.
-----------------------------------
-- Generic Field Access Routines --
-----------------------------------
-- This subpackage provides the functions for accessing and procedures for
-- setting fields that are normally referenced by wrapper subprograms (e.g.
-- logical synonyms defined in packages Sinfo and Einfo, or specialized
-- routines such as Rewrite (for Original_Node), or the node creation
-- routines (for Set_Nkind). The implementations of these wrapper
-- subprograms use the package Atree.Unchecked_Access as do various
-- special case accesses where no wrapper applies. Documentation is always
-- required for such a special case access explaining why it is needed.
package Unchecked_Access is
-- Functions to allow interpretation of Union_Id values as Uint and
-- Ureal values.
function To_Union is new Unchecked_Conversion (Uint, Union_Id);
function To_Union is new Unchecked_Conversion (Ureal, Union_Id);
function From_Union is new Unchecked_Conversion (Union_Id, Uint);
function From_Union is new Unchecked_Conversion (Union_Id, Ureal);
-- Functions to fetch contents of indicated field. It is an error to
-- attempt to read the value of a field which is not present.
function Field1 (N : Node_Id) return Union_Id;
pragma Inline (Field1);
function Field2 (N : Node_Id) return Union_Id;
pragma Inline (Field2);
function Field3 (N : Node_Id) return Union_Id;
pragma Inline (Field3);
function Field4 (N : Node_Id) return Union_Id;
pragma Inline (Field4);
function Field5 (N : Node_Id) return Union_Id;
pragma Inline (Field5);
function Field6 (N : Node_Id) return Union_Id;
pragma Inline (Field6);
function Field7 (N : Node_Id) return Union_Id;
pragma Inline (Field7);
function Field8 (N : Node_Id) return Union_Id;
pragma Inline (Field8);
function Field9 (N : Node_Id) return Union_Id;
pragma Inline (Field9);
function Field10 (N : Node_Id) return Union_Id;
pragma Inline (Field10);
function Field11 (N : Node_Id) return Union_Id;
pragma Inline (Field11);
function Field12 (N : Node_Id) return Union_Id;
pragma Inline (Field12);
function Field13 (N : Node_Id) return Union_Id;
pragma Inline (Field13);
function Field14 (N : Node_Id) return Union_Id;
pragma Inline (Field14);
function Field15 (N : Node_Id) return Union_Id;
pragma Inline (Field15);
function Field16 (N : Node_Id) return Union_Id;
pragma Inline (Field16);
function Field17 (N : Node_Id) return Union_Id;
pragma Inline (Field17);
function Field18 (N : Node_Id) return Union_Id;
pragma Inline (Field18);
function Field19 (N : Node_Id) return Union_Id;
pragma Inline (Field19);
function Field20 (N : Node_Id) return Union_Id;
pragma Inline (Field20);
function Field21 (N : Node_Id) return Union_Id;
pragma Inline (Field21);
function Field22 (N : Node_Id) return Union_Id;
pragma Inline (Field22);
function Field23 (N : Node_Id) return Union_Id;
pragma Inline (Field23);
function Field24 (N : Node_Id) return Union_Id;
pragma Inline (Field24);
function Field25 (N : Node_Id) return Union_Id;
pragma Inline (Field25);
function Field26 (N : Node_Id) return Union_Id;
pragma Inline (Field26);
function Field27 (N : Node_Id) return Union_Id;
pragma Inline (Field27);
function Field28 (N : Node_Id) return Union_Id;
pragma Inline (Field28);
function Field29 (N : Node_Id) return Union_Id;
pragma Inline (Field29);
function Field30 (N : Node_Id) return Union_Id;
pragma Inline (Field30);
function Field31 (N : Node_Id) return Union_Id;
pragma Inline (Field31);
function Field32 (N : Node_Id) return Union_Id;
pragma Inline (Field32);
function Field33 (N : Node_Id) return Union_Id;
pragma Inline (Field33);
function Field34 (N : Node_Id) return Union_Id;
pragma Inline (Field34);
function Field35 (N : Node_Id) return Union_Id;
pragma Inline (Field35);
function Field36 (N : Node_Id) return Union_Id;
pragma Inline (Field36);
function Field37 (N : Node_Id) return Union_Id;
pragma Inline (Field37);
function Field38 (N : Node_Id) return Union_Id;
pragma Inline (Field38);
function Field39 (N : Node_Id) return Union_Id;
pragma Inline (Field39);
function Field40 (N : Node_Id) return Union_Id;
pragma Inline (Field40);
function Field41 (N : Node_Id) return Union_Id;
pragma Inline (Field41);
function Node1 (N : Node_Id) return Node_Id;
pragma Inline (Node1);
function Node2 (N : Node_Id) return Node_Id;
pragma Inline (Node2);
function Node3 (N : Node_Id) return Node_Id;
pragma Inline (Node3);
function Node4 (N : Node_Id) return Node_Id;
pragma Inline (Node4);
function Node5 (N : Node_Id) return Node_Id;
pragma Inline (Node5);
function Node6 (N : Node_Id) return Node_Id;
pragma Inline (Node6);
function Node7 (N : Node_Id) return Node_Id;
pragma Inline (Node7);
function Node8 (N : Node_Id) return Node_Id;
pragma Inline (Node8);
function Node9 (N : Node_Id) return Node_Id;
pragma Inline (Node9);
function Node10 (N : Node_Id) return Node_Id;
pragma Inline (Node10);
function Node11 (N : Node_Id) return Node_Id;
pragma Inline (Node11);
function Node12 (N : Node_Id) return Node_Id;
pragma Inline (Node12);
function Node13 (N : Node_Id) return Node_Id;
pragma Inline (Node13);
function Node14 (N : Node_Id) return Node_Id;
pragma Inline (Node14);
function Node15 (N : Node_Id) return Node_Id;
pragma Inline (Node15);
function Node16 (N : Node_Id) return Node_Id;
pragma Inline (Node16);
function Node17 (N : Node_Id) return Node_Id;
pragma Inline (Node17);
function Node18 (N : Node_Id) return Node_Id;
pragma Inline (Node18);
function Node19 (N : Node_Id) return Node_Id;
pragma Inline (Node19);
function Node20 (N : Node_Id) return Node_Id;
pragma Inline (Node20);
function Node21 (N : Node_Id) return Node_Id;
pragma Inline (Node21);
function Node22 (N : Node_Id) return Node_Id;
pragma Inline (Node22);
function Node23 (N : Node_Id) return Node_Id;
pragma Inline (Node23);
function Node24 (N : Node_Id) return Node_Id;
pragma Inline (Node24);
function Node25 (N : Node_Id) return Node_Id;
pragma Inline (Node25);
function Node26 (N : Node_Id) return Node_Id;
pragma Inline (Node26);
function Node27 (N : Node_Id) return Node_Id;
pragma Inline (Node27);
function Node28 (N : Node_Id) return Node_Id;
pragma Inline (Node28);
function Node29 (N : Node_Id) return Node_Id;
pragma Inline (Node29);
function Node30 (N : Node_Id) return Node_Id;
pragma Inline (Node30);
function Node31 (N : Node_Id) return Node_Id;
pragma Inline (Node31);
function Node32 (N : Node_Id) return Node_Id;
pragma Inline (Node32);
function Node33 (N : Node_Id) return Node_Id;
pragma Inline (Node33);
function Node34 (N : Node_Id) return Node_Id;
pragma Inline (Node34);
function Node35 (N : Node_Id) return Node_Id;
pragma Inline (Node35);
function Node36 (N : Node_Id) return Node_Id;
pragma Inline (Node36);
function Node37 (N : Node_Id) return Node_Id;
pragma Inline (Node37);
function Node38 (N : Node_Id) return Node_Id;
pragma Inline (Node38);
function Node39 (N : Node_Id) return Node_Id;
pragma Inline (Node39);
function Node40 (N : Node_Id) return Node_Id;
pragma Inline (Node40);
function Node41 (N : Node_Id) return Node_Id;
pragma Inline (Node41);
function List1 (N : Node_Id) return List_Id;
pragma Inline (List1);
function List2 (N : Node_Id) return List_Id;
pragma Inline (List2);
function List3 (N : Node_Id) return List_Id;
pragma Inline (List3);
function List4 (N : Node_Id) return List_Id;
pragma Inline (List4);
function List5 (N : Node_Id) return List_Id;
pragma Inline (List5);
function List10 (N : Node_Id) return List_Id;
pragma Inline (List10);
function List14 (N : Node_Id) return List_Id;
pragma Inline (List14);
function List25 (N : Node_Id) return List_Id;
pragma Inline (List25);
function Elist1 (N : Node_Id) return Elist_Id;
pragma Inline (Elist1);
function Elist2 (N : Node_Id) return Elist_Id;
pragma Inline (Elist2);
function Elist3 (N : Node_Id) return Elist_Id;
pragma Inline (Elist3);
function Elist4 (N : Node_Id) return Elist_Id;
pragma Inline (Elist4);
function Elist5 (N : Node_Id) return Elist_Id;
pragma Inline (Elist5);
function Elist8 (N : Node_Id) return Elist_Id;
pragma Inline (Elist8);
function Elist9 (N : Node_Id) return Elist_Id;
pragma Inline (Elist9);
function Elist10 (N : Node_Id) return Elist_Id;
pragma Inline (Elist10);
function Elist13 (N : Node_Id) return Elist_Id;
pragma Inline (Elist13);
function Elist15 (N : Node_Id) return Elist_Id;
pragma Inline (Elist15);
function Elist16 (N : Node_Id) return Elist_Id;
pragma Inline (Elist16);
function Elist18 (N : Node_Id) return Elist_Id;
pragma Inline (Elist18);
function Elist21 (N : Node_Id) return Elist_Id;
pragma Inline (Elist21);
function Elist23 (N : Node_Id) return Elist_Id;
pragma Inline (Elist23);
function Elist24 (N : Node_Id) return Elist_Id;
pragma Inline (Elist24);
function Elist25 (N : Node_Id) return Elist_Id;
pragma Inline (Elist25);
function Elist26 (N : Node_Id) return Elist_Id;
pragma Inline (Elist26);
function Name1 (N : Node_Id) return Name_Id;
pragma Inline (Name1);
function Name2 (N : Node_Id) return Name_Id;
pragma Inline (Name2);
function Str3 (N : Node_Id) return String_Id;
pragma Inline (Str3);
-- Note: the following Uintnn functions have a special test for the
-- Field value being Empty. If an Empty value is found then Uint_0 is
-- returned. This avoids the rather tricky requirement of initializing
-- all Uint fields in nodes and entities.
function Uint2 (N : Node_Id) return Uint;
pragma Inline (Uint2);
function Uint3 (N : Node_Id) return Uint;
pragma Inline (Uint3);
function Uint4 (N : Node_Id) return Uint;
pragma Inline (Uint4);
function Uint5 (N : Node_Id) return Uint;
pragma Inline (Uint5);
function Uint8 (N : Node_Id) return Uint;
pragma Inline (Uint8);
function Uint9 (N : Node_Id) return Uint;
pragma Inline (Uint9);
function Uint10 (N : Node_Id) return Uint;
pragma Inline (Uint10);
function Uint11 (N : Node_Id) return Uint;
pragma Inline (Uint11);
function Uint12 (N : Node_Id) return Uint;
pragma Inline (Uint12);
function Uint13 (N : Node_Id) return Uint;
pragma Inline (Uint13);
function Uint14 (N : Node_Id) return Uint;
pragma Inline (Uint14);
function Uint15 (N : Node_Id) return Uint;
pragma Inline (Uint15);
function Uint16 (N : Node_Id) return Uint;
pragma Inline (Uint16);
function Uint17 (N : Node_Id) return Uint;
pragma Inline (Uint17);
function Uint22 (N : Node_Id) return Uint;
pragma Inline (Uint22);
function Uint24 (N : Node_Id) return Uint;
pragma Inline (Uint24);
function Ureal3 (N : Node_Id) return Ureal;
pragma Inline (Ureal3);
function Ureal18 (N : Node_Id) return Ureal;
pragma Inline (Ureal18);
function Ureal21 (N : Node_Id) return Ureal;
pragma Inline (Ureal21);
function Flag0 (N : Node_Id) return Boolean;
pragma Inline (Flag0);
function Flag1 (N : Node_Id) return Boolean;
pragma Inline (Flag1);
function Flag2 (N : Node_Id) return Boolean;
pragma Inline (Flag2);
function Flag3 (N : Node_Id) return Boolean;
pragma Inline (Flag3);
function Flag4 (N : Node_Id) return Boolean;
pragma Inline (Flag4);
function Flag5 (N : Node_Id) return Boolean;
pragma Inline (Flag5);
function Flag6 (N : Node_Id) return Boolean;
pragma Inline (Flag6);
function Flag7 (N : Node_Id) return Boolean;
pragma Inline (Flag7);
function Flag8 (N : Node_Id) return Boolean;
pragma Inline (Flag8);
function Flag9 (N : Node_Id) return Boolean;
pragma Inline (Flag9);
function Flag10 (N : Node_Id) return Boolean;
pragma Inline (Flag10);
function Flag11 (N : Node_Id) return Boolean;
pragma Inline (Flag11);
function Flag12 (N : Node_Id) return Boolean;
pragma Inline (Flag12);
function Flag13 (N : Node_Id) return Boolean;
pragma Inline (Flag13);
function Flag14 (N : Node_Id) return Boolean;
pragma Inline (Flag14);
function Flag15 (N : Node_Id) return Boolean;
pragma Inline (Flag15);
function Flag16 (N : Node_Id) return Boolean;
pragma Inline (Flag16);
function Flag17 (N : Node_Id) return Boolean;
pragma Inline (Flag17);
function Flag18 (N : Node_Id) return Boolean;
pragma Inline (Flag18);
function Flag19 (N : Node_Id) return Boolean;
pragma Inline (Flag19);
function Flag20 (N : Node_Id) return Boolean;
pragma Inline (Flag20);
function Flag21 (N : Node_Id) return Boolean;
pragma Inline (Flag21);
function Flag22 (N : Node_Id) return Boolean;
pragma Inline (Flag22);
function Flag23 (N : Node_Id) return Boolean;
pragma Inline (Flag23);
function Flag24 (N : Node_Id) return Boolean;
pragma Inline (Flag24);
function Flag25 (N : Node_Id) return Boolean;
pragma Inline (Flag25);
function Flag26 (N : Node_Id) return Boolean;
pragma Inline (Flag26);
function Flag27 (N : Node_Id) return Boolean;
pragma Inline (Flag27);
function Flag28 (N : Node_Id) return Boolean;
pragma Inline (Flag28);
function Flag29 (N : Node_Id) return Boolean;
pragma Inline (Flag29);
function Flag30 (N : Node_Id) return Boolean;
pragma Inline (Flag30);
function Flag31 (N : Node_Id) return Boolean;
pragma Inline (Flag31);
function Flag32 (N : Node_Id) return Boolean;
pragma Inline (Flag32);
function Flag33 (N : Node_Id) return Boolean;
pragma Inline (Flag33);
function Flag34 (N : Node_Id) return Boolean;
pragma Inline (Flag34);
function Flag35 (N : Node_Id) return Boolean;
pragma Inline (Flag35);
function Flag36 (N : Node_Id) return Boolean;
pragma Inline (Flag36);
function Flag37 (N : Node_Id) return Boolean;
pragma Inline (Flag37);
function Flag38 (N : Node_Id) return Boolean;
pragma Inline (Flag38);
function Flag39 (N : Node_Id) return Boolean;
pragma Inline (Flag39);
function Flag40 (N : Node_Id) return Boolean;
pragma Inline (Flag40);
function Flag41 (N : Node_Id) return Boolean;
pragma Inline (Flag41);
function Flag42 (N : Node_Id) return Boolean;
pragma Inline (Flag42);
function Flag43 (N : Node_Id) return Boolean;
pragma Inline (Flag43);
function Flag44 (N : Node_Id) return Boolean;
pragma Inline (Flag44);
function Flag45 (N : Node_Id) return Boolean;
pragma Inline (Flag45);
function Flag46 (N : Node_Id) return Boolean;
pragma Inline (Flag46);
function Flag47 (N : Node_Id) return Boolean;
pragma Inline (Flag47);
function Flag48 (N : Node_Id) return Boolean;
pragma Inline (Flag48);
function Flag49 (N : Node_Id) return Boolean;
pragma Inline (Flag49);
function Flag50 (N : Node_Id) return Boolean;
pragma Inline (Flag50);
function Flag51 (N : Node_Id) return Boolean;
pragma Inline (Flag51);
function Flag52 (N : Node_Id) return Boolean;
pragma Inline (Flag52);
function Flag53 (N : Node_Id) return Boolean;
pragma Inline (Flag53);
function Flag54 (N : Node_Id) return Boolean;
pragma Inline (Flag54);
function Flag55 (N : Node_Id) return Boolean;
pragma Inline (Flag55);
function Flag56 (N : Node_Id) return Boolean;
pragma Inline (Flag56);
function Flag57 (N : Node_Id) return Boolean;
pragma Inline (Flag57);
function Flag58 (N : Node_Id) return Boolean;
pragma Inline (Flag58);
function Flag59 (N : Node_Id) return Boolean;
pragma Inline (Flag59);
function Flag60 (N : Node_Id) return Boolean;
pragma Inline (Flag60);
function Flag61 (N : Node_Id) return Boolean;
pragma Inline (Flag61);
function Flag62 (N : Node_Id) return Boolean;
pragma Inline (Flag62);
function Flag63 (N : Node_Id) return Boolean;
pragma Inline (Flag63);
function Flag64 (N : Node_Id) return Boolean;
pragma Inline (Flag64);
function Flag65 (N : Node_Id) return Boolean;
pragma Inline (Flag65);
function Flag66 (N : Node_Id) return Boolean;
pragma Inline (Flag66);
function Flag67 (N : Node_Id) return Boolean;
pragma Inline (Flag67);
function Flag68 (N : Node_Id) return Boolean;
pragma Inline (Flag68);
function Flag69 (N : Node_Id) return Boolean;
pragma Inline (Flag69);
function Flag70 (N : Node_Id) return Boolean;
pragma Inline (Flag70);
function Flag71 (N : Node_Id) return Boolean;
pragma Inline (Flag71);
function Flag72 (N : Node_Id) return Boolean;
pragma Inline (Flag72);
function Flag73 (N : Node_Id) return Boolean;
pragma Inline (Flag73);
function Flag74 (N : Node_Id) return Boolean;
pragma Inline (Flag74);
function Flag75 (N : Node_Id) return Boolean;
pragma Inline (Flag75);
function Flag76 (N : Node_Id) return Boolean;
pragma Inline (Flag76);
function Flag77 (N : Node_Id) return Boolean;
pragma Inline (Flag77);
function Flag78 (N : Node_Id) return Boolean;
pragma Inline (Flag78);
function Flag79 (N : Node_Id) return Boolean;
pragma Inline (Flag79);
function Flag80 (N : Node_Id) return Boolean;
pragma Inline (Flag80);
function Flag81 (N : Node_Id) return Boolean;
pragma Inline (Flag81);
function Flag82 (N : Node_Id) return Boolean;
pragma Inline (Flag82);
function Flag83 (N : Node_Id) return Boolean;
pragma Inline (Flag83);
function Flag84 (N : Node_Id) return Boolean;
pragma Inline (Flag84);
function Flag85 (N : Node_Id) return Boolean;
pragma Inline (Flag85);
function Flag86 (N : Node_Id) return Boolean;
pragma Inline (Flag86);
function Flag87 (N : Node_Id) return Boolean;
pragma Inline (Flag87);
function Flag88 (N : Node_Id) return Boolean;
pragma Inline (Flag88);
function Flag89 (N : Node_Id) return Boolean;
pragma Inline (Flag89);
function Flag90 (N : Node_Id) return Boolean;
pragma Inline (Flag90);
function Flag91 (N : Node_Id) return Boolean;
pragma Inline (Flag91);
function Flag92 (N : Node_Id) return Boolean;
pragma Inline (Flag92);
function Flag93 (N : Node_Id) return Boolean;
pragma Inline (Flag93);
function Flag94 (N : Node_Id) return Boolean;
pragma Inline (Flag94);
function Flag95 (N : Node_Id) return Boolean;
pragma Inline (Flag95);
function Flag96 (N : Node_Id) return Boolean;
pragma Inline (Flag96);
function Flag97 (N : Node_Id) return Boolean;
pragma Inline (Flag97);
function Flag98 (N : Node_Id) return Boolean;
pragma Inline (Flag98);
function Flag99 (N : Node_Id) return Boolean;
pragma Inline (Flag99);
function Flag100 (N : Node_Id) return Boolean;
pragma Inline (Flag100);
function Flag101 (N : Node_Id) return Boolean;
pragma Inline (Flag101);
function Flag102 (N : Node_Id) return Boolean;
pragma Inline (Flag102);
function Flag103 (N : Node_Id) return Boolean;
pragma Inline (Flag103);
function Flag104 (N : Node_Id) return Boolean;
pragma Inline (Flag104);
function Flag105 (N : Node_Id) return Boolean;
pragma Inline (Flag105);
function Flag106 (N : Node_Id) return Boolean;
pragma Inline (Flag106);
function Flag107 (N : Node_Id) return Boolean;
pragma Inline (Flag107);
function Flag108 (N : Node_Id) return Boolean;
pragma Inline (Flag108);
function Flag109 (N : Node_Id) return Boolean;
pragma Inline (Flag109);
function Flag110 (N : Node_Id) return Boolean;
pragma Inline (Flag110);
function Flag111 (N : Node_Id) return Boolean;
pragma Inline (Flag111);
function Flag112 (N : Node_Id) return Boolean;
pragma Inline (Flag112);
function Flag113 (N : Node_Id) return Boolean;
pragma Inline (Flag113);
function Flag114 (N : Node_Id) return Boolean;
pragma Inline (Flag114);
function Flag115 (N : Node_Id) return Boolean;
pragma Inline (Flag115);
function Flag116 (N : Node_Id) return Boolean;
pragma Inline (Flag116);
function Flag117 (N : Node_Id) return Boolean;
pragma Inline (Flag117);
function Flag118 (N : Node_Id) return Boolean;
pragma Inline (Flag118);
function Flag119 (N : Node_Id) return Boolean;
pragma Inline (Flag119);
function Flag120 (N : Node_Id) return Boolean;
pragma Inline (Flag120);
function Flag121 (N : Node_Id) return Boolean;
pragma Inline (Flag121);
function Flag122 (N : Node_Id) return Boolean;
pragma Inline (Flag122);
function Flag123 (N : Node_Id) return Boolean;
pragma Inline (Flag123);
function Flag124 (N : Node_Id) return Boolean;
pragma Inline (Flag124);
function Flag125 (N : Node_Id) return Boolean;
pragma Inline (Flag125);
function Flag126 (N : Node_Id) return Boolean;
pragma Inline (Flag126);
function Flag127 (N : Node_Id) return Boolean;
pragma Inline (Flag127);
function Flag128 (N : Node_Id) return Boolean;
pragma Inline (Flag128);
function Flag129 (N : Node_Id) return Boolean;
pragma Inline (Flag129);
function Flag130 (N : Node_Id) return Boolean;
pragma Inline (Flag130);
function Flag131 (N : Node_Id) return Boolean;
pragma Inline (Flag131);
function Flag132 (N : Node_Id) return Boolean;
pragma Inline (Flag132);
function Flag133 (N : Node_Id) return Boolean;
pragma Inline (Flag133);
function Flag134 (N : Node_Id) return Boolean;
pragma Inline (Flag134);
function Flag135 (N : Node_Id) return Boolean;
pragma Inline (Flag135);
function Flag136 (N : Node_Id) return Boolean;
pragma Inline (Flag136);
function Flag137 (N : Node_Id) return Boolean;
pragma Inline (Flag137);
function Flag138 (N : Node_Id) return Boolean;
pragma Inline (Flag138);
function Flag139 (N : Node_Id) return Boolean;
pragma Inline (Flag139);
function Flag140 (N : Node_Id) return Boolean;
pragma Inline (Flag140);
function Flag141 (N : Node_Id) return Boolean;
pragma Inline (Flag141);
function Flag142 (N : Node_Id) return Boolean;
pragma Inline (Flag142);
function Flag143 (N : Node_Id) return Boolean;
pragma Inline (Flag143);
function Flag144 (N : Node_Id) return Boolean;
pragma Inline (Flag144);
function Flag145 (N : Node_Id) return Boolean;
pragma Inline (Flag145);
function Flag146 (N : Node_Id) return Boolean;
pragma Inline (Flag146);
function Flag147 (N : Node_Id) return Boolean;
pragma Inline (Flag147);
function Flag148 (N : Node_Id) return Boolean;
pragma Inline (Flag148);
function Flag149 (N : Node_Id) return Boolean;
pragma Inline (Flag149);
function Flag150 (N : Node_Id) return Boolean;
pragma Inline (Flag150);
function Flag151 (N : Node_Id) return Boolean;
pragma Inline (Flag151);
function Flag152 (N : Node_Id) return Boolean;
pragma Inline (Flag152);
function Flag153 (N : Node_Id) return Boolean;
pragma Inline (Flag153);
function Flag154 (N : Node_Id) return Boolean;
pragma Inline (Flag154);
function Flag155 (N : Node_Id) return Boolean;
pragma Inline (Flag155);
function Flag156 (N : Node_Id) return Boolean;
pragma Inline (Flag156);
function Flag157 (N : Node_Id) return Boolean;
pragma Inline (Flag157);
function Flag158 (N : Node_Id) return Boolean;
pragma Inline (Flag158);
function Flag159 (N : Node_Id) return Boolean;
pragma Inline (Flag159);
function Flag160 (N : Node_Id) return Boolean;
pragma Inline (Flag160);
function Flag161 (N : Node_Id) return Boolean;
pragma Inline (Flag161);
function Flag162 (N : Node_Id) return Boolean;
pragma Inline (Flag162);
function Flag163 (N : Node_Id) return Boolean;
pragma Inline (Flag163);
function Flag164 (N : Node_Id) return Boolean;
pragma Inline (Flag164);
function Flag165 (N : Node_Id) return Boolean;
pragma Inline (Flag165);
function Flag166 (N : Node_Id) return Boolean;
pragma Inline (Flag166);
function Flag167 (N : Node_Id) return Boolean;
pragma Inline (Flag167);
function Flag168 (N : Node_Id) return Boolean;
pragma Inline (Flag168);
function Flag169 (N : Node_Id) return Boolean;
pragma Inline (Flag169);
function Flag170 (N : Node_Id) return Boolean;
pragma Inline (Flag170);
function Flag171 (N : Node_Id) return Boolean;
pragma Inline (Flag171);
function Flag172 (N : Node_Id) return Boolean;
pragma Inline (Flag172);
function Flag173 (N : Node_Id) return Boolean;
pragma Inline (Flag173);
function Flag174 (N : Node_Id) return Boolean;
pragma Inline (Flag174);
function Flag175 (N : Node_Id) return Boolean;
pragma Inline (Flag175);
function Flag176 (N : Node_Id) return Boolean;
pragma Inline (Flag176);
function Flag177 (N : Node_Id) return Boolean;
pragma Inline (Flag177);
function Flag178 (N : Node_Id) return Boolean;
pragma Inline (Flag178);
function Flag179 (N : Node_Id) return Boolean;
pragma Inline (Flag179);
function Flag180 (N : Node_Id) return Boolean;
pragma Inline (Flag180);
function Flag181 (N : Node_Id) return Boolean;
pragma Inline (Flag181);
function Flag182 (N : Node_Id) return Boolean;
pragma Inline (Flag182);
function Flag183 (N : Node_Id) return Boolean;
pragma Inline (Flag183);
function Flag184 (N : Node_Id) return Boolean;
pragma Inline (Flag184);
function Flag185 (N : Node_Id) return Boolean;
pragma Inline (Flag185);
function Flag186 (N : Node_Id) return Boolean;
pragma Inline (Flag186);
function Flag187 (N : Node_Id) return Boolean;
pragma Inline (Flag187);
function Flag188 (N : Node_Id) return Boolean;
pragma Inline (Flag188);
function Flag189 (N : Node_Id) return Boolean;
pragma Inline (Flag189);
function Flag190 (N : Node_Id) return Boolean;
pragma Inline (Flag190);
function Flag191 (N : Node_Id) return Boolean;
pragma Inline (Flag191);
function Flag192 (N : Node_Id) return Boolean;
pragma Inline (Flag192);
function Flag193 (N : Node_Id) return Boolean;
pragma Inline (Flag193);
function Flag194 (N : Node_Id) return Boolean;
pragma Inline (Flag194);
function Flag195 (N : Node_Id) return Boolean;
pragma Inline (Flag195);
function Flag196 (N : Node_Id) return Boolean;
pragma Inline (Flag196);
function Flag197 (N : Node_Id) return Boolean;
pragma Inline (Flag197);
function Flag198 (N : Node_Id) return Boolean;
pragma Inline (Flag198);
function Flag199 (N : Node_Id) return Boolean;
pragma Inline (Flag199);
function Flag200 (N : Node_Id) return Boolean;
pragma Inline (Flag200);
function Flag201 (N : Node_Id) return Boolean;
pragma Inline (Flag201);
function Flag202 (N : Node_Id) return Boolean;
pragma Inline (Flag202);
function Flag203 (N : Node_Id) return Boolean;
pragma Inline (Flag203);
function Flag204 (N : Node_Id) return Boolean;
pragma Inline (Flag204);
function Flag205 (N : Node_Id) return Boolean;
pragma Inline (Flag205);
function Flag206 (N : Node_Id) return Boolean;
pragma Inline (Flag206);
function Flag207 (N : Node_Id) return Boolean;
pragma Inline (Flag207);
function Flag208 (N : Node_Id) return Boolean;
pragma Inline (Flag208);
function Flag209 (N : Node_Id) return Boolean;
pragma Inline (Flag209);
function Flag210 (N : Node_Id) return Boolean;
pragma Inline (Flag210);
function Flag211 (N : Node_Id) return Boolean;
pragma Inline (Flag211);
function Flag212 (N : Node_Id) return Boolean;
pragma Inline (Flag212);
function Flag213 (N : Node_Id) return Boolean;
pragma Inline (Flag213);
function Flag214 (N : Node_Id) return Boolean;
pragma Inline (Flag214);
function Flag215 (N : Node_Id) return Boolean;
pragma Inline (Flag215);
function Flag216 (N : Node_Id) return Boolean;
pragma Inline (Flag216);
function Flag217 (N : Node_Id) return Boolean;
pragma Inline (Flag217);
function Flag218 (N : Node_Id) return Boolean;
pragma Inline (Flag218);
function Flag219 (N : Node_Id) return Boolean;
pragma Inline (Flag219);
function Flag220 (N : Node_Id) return Boolean;
pragma Inline (Flag220);
function Flag221 (N : Node_Id) return Boolean;
pragma Inline (Flag221);
function Flag222 (N : Node_Id) return Boolean;
pragma Inline (Flag222);
function Flag223 (N : Node_Id) return Boolean;
pragma Inline (Flag223);
function Flag224 (N : Node_Id) return Boolean;
pragma Inline (Flag224);
function Flag225 (N : Node_Id) return Boolean;
pragma Inline (Flag225);
function Flag226 (N : Node_Id) return Boolean;
pragma Inline (Flag226);
function Flag227 (N : Node_Id) return Boolean;
pragma Inline (Flag227);
function Flag228 (N : Node_Id) return Boolean;
pragma Inline (Flag228);
function Flag229 (N : Node_Id) return Boolean;
pragma Inline (Flag229);
function Flag230 (N : Node_Id) return Boolean;
pragma Inline (Flag230);
function Flag231 (N : Node_Id) return Boolean;
pragma Inline (Flag231);
function Flag232 (N : Node_Id) return Boolean;
pragma Inline (Flag232);
function Flag233 (N : Node_Id) return Boolean;
pragma Inline (Flag233);
function Flag234 (N : Node_Id) return Boolean;
pragma Inline (Flag234);
function Flag235 (N : Node_Id) return Boolean;
pragma Inline (Flag235);
function Flag236 (N : Node_Id) return Boolean;
pragma Inline (Flag236);
function Flag237 (N : Node_Id) return Boolean;
pragma Inline (Flag237);
function Flag238 (N : Node_Id) return Boolean;
pragma Inline (Flag238);
function Flag239 (N : Node_Id) return Boolean;
pragma Inline (Flag239);
function Flag240 (N : Node_Id) return Boolean;
pragma Inline (Flag240);
function Flag241 (N : Node_Id) return Boolean;
pragma Inline (Flag241);
function Flag242 (N : Node_Id) return Boolean;
pragma Inline (Flag242);
function Flag243 (N : Node_Id) return Boolean;
pragma Inline (Flag243);
function Flag244 (N : Node_Id) return Boolean;
pragma Inline (Flag244);
function Flag245 (N : Node_Id) return Boolean;
pragma Inline (Flag245);
function Flag246 (N : Node_Id) return Boolean;
pragma Inline (Flag246);
function Flag247 (N : Node_Id) return Boolean;
pragma Inline (Flag247);
function Flag248 (N : Node_Id) return Boolean;
pragma Inline (Flag248);
function Flag249 (N : Node_Id) return Boolean;
pragma Inline (Flag249);
function Flag250 (N : Node_Id) return Boolean;
pragma Inline (Flag250);
function Flag251 (N : Node_Id) return Boolean;
pragma Inline (Flag251);
function Flag252 (N : Node_Id) return Boolean;
pragma Inline (Flag252);
function Flag253 (N : Node_Id) return Boolean;
pragma Inline (Flag253);
function Flag254 (N : Node_Id) return Boolean;
pragma Inline (Flag254);
function Flag255 (N : Node_Id) return Boolean;
pragma Inline (Flag255);
function Flag256 (N : Node_Id) return Boolean;
pragma Inline (Flag256);
function Flag257 (N : Node_Id) return Boolean;
pragma Inline (Flag257);
function Flag258 (N : Node_Id) return Boolean;
pragma Inline (Flag258);
function Flag259 (N : Node_Id) return Boolean;
pragma Inline (Flag259);
function Flag260 (N : Node_Id) return Boolean;
pragma Inline (Flag260);
function Flag261 (N : Node_Id) return Boolean;
pragma Inline (Flag261);
function Flag262 (N : Node_Id) return Boolean;
pragma Inline (Flag262);
function Flag263 (N : Node_Id) return Boolean;
pragma Inline (Flag263);
function Flag264 (N : Node_Id) return Boolean;
pragma Inline (Flag264);
function Flag265 (N : Node_Id) return Boolean;
pragma Inline (Flag265);
function Flag266 (N : Node_Id) return Boolean;
pragma Inline (Flag266);
function Flag267 (N : Node_Id) return Boolean;
pragma Inline (Flag267);
function Flag268 (N : Node_Id) return Boolean;
pragma Inline (Flag268);
function Flag269 (N : Node_Id) return Boolean;
pragma Inline (Flag269);
function Flag270 (N : Node_Id) return Boolean;
pragma Inline (Flag270);
function Flag271 (N : Node_Id) return Boolean;
pragma Inline (Flag271);
function Flag272 (N : Node_Id) return Boolean;
pragma Inline (Flag272);
function Flag273 (N : Node_Id) return Boolean;
pragma Inline (Flag273);
function Flag274 (N : Node_Id) return Boolean;
pragma Inline (Flag274);
function Flag275 (N : Node_Id) return Boolean;
pragma Inline (Flag275);
function Flag276 (N : Node_Id) return Boolean;
pragma Inline (Flag276);
function Flag277 (N : Node_Id) return Boolean;
pragma Inline (Flag277);
function Flag278 (N : Node_Id) return Boolean;
pragma Inline (Flag278);
function Flag279 (N : Node_Id) return Boolean;
pragma Inline (Flag279);
function Flag280 (N : Node_Id) return Boolean;
pragma Inline (Flag280);
function Flag281 (N : Node_Id) return Boolean;
pragma Inline (Flag281);
function Flag282 (N : Node_Id) return Boolean;
pragma Inline (Flag282);
function Flag283 (N : Node_Id) return Boolean;
pragma Inline (Flag283);
function Flag284 (N : Node_Id) return Boolean;
pragma Inline (Flag284);
function Flag285 (N : Node_Id) return Boolean;
pragma Inline (Flag285);
function Flag286 (N : Node_Id) return Boolean;
pragma Inline (Flag286);
function Flag287 (N : Node_Id) return Boolean;
pragma Inline (Flag287);
function Flag288 (N : Node_Id) return Boolean;
pragma Inline (Flag288);
function Flag289 (N : Node_Id) return Boolean;
pragma Inline (Flag289);
function Flag290 (N : Node_Id) return Boolean;
pragma Inline (Flag290);
function Flag291 (N : Node_Id) return Boolean;
pragma Inline (Flag291);
function Flag292 (N : Node_Id) return Boolean;
pragma Inline (Flag292);
function Flag293 (N : Node_Id) return Boolean;
pragma Inline (Flag293);
function Flag294 (N : Node_Id) return Boolean;
pragma Inline (Flag294);
function Flag295 (N : Node_Id) return Boolean;
pragma Inline (Flag295);
function Flag296 (N : Node_Id) return Boolean;
pragma Inline (Flag296);
function Flag297 (N : Node_Id) return Boolean;
pragma Inline (Flag297);
function Flag298 (N : Node_Id) return Boolean;
pragma Inline (Flag298);
function Flag299 (N : Node_Id) return Boolean;
pragma Inline (Flag299);
function Flag300 (N : Node_Id) return Boolean;
pragma Inline (Flag300);
function Flag301 (N : Node_Id) return Boolean;
pragma Inline (Flag301);
function Flag302 (N : Node_Id) return Boolean;
pragma Inline (Flag302);
function Flag303 (N : Node_Id) return Boolean;
pragma Inline (Flag303);
function Flag304 (N : Node_Id) return Boolean;
pragma Inline (Flag304);
function Flag305 (N : Node_Id) return Boolean;
pragma Inline (Flag305);
function Flag306 (N : Node_Id) return Boolean;
pragma Inline (Flag306);
function Flag307 (N : Node_Id) return Boolean;
pragma Inline (Flag307);
function Flag308 (N : Node_Id) return Boolean;
pragma Inline (Flag308);
function Flag309 (N : Node_Id) return Boolean;
pragma Inline (Flag309);
function Flag310 (N : Node_Id) return Boolean;
pragma Inline (Flag310);
function Flag311 (N : Node_Id) return Boolean;
pragma Inline (Flag311);
function Flag312 (N : Node_Id) return Boolean;
pragma Inline (Flag312);
function Flag313 (N : Node_Id) return Boolean;
pragma Inline (Flag313);
function Flag314 (N : Node_Id) return Boolean;
pragma Inline (Flag314);
function Flag315 (N : Node_Id) return Boolean;
pragma Inline (Flag315);
function Flag316 (N : Node_Id) return Boolean;
pragma Inline (Flag316);
function Flag317 (N : Node_Id) return Boolean;
pragma Inline (Flag317);
-- Procedures to set value of indicated field
procedure Set_Nkind (N : Node_Id; Val : Node_Kind);
pragma Inline (Set_Nkind);
procedure Set_Field1 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field1);
procedure Set_Field2 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field2);
procedure Set_Field3 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field3);
procedure Set_Field4 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field4);
procedure Set_Field5 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field5);
procedure Set_Field6 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field6);
procedure Set_Field7 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field7);
procedure Set_Field8 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field8);
procedure Set_Field9 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field9);
procedure Set_Field10 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field10);
procedure Set_Field11 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field11);
procedure Set_Field12 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field12);
procedure Set_Field13 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field13);
procedure Set_Field14 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field14);
procedure Set_Field15 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field15);
procedure Set_Field16 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field16);
procedure Set_Field17 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field17);
procedure Set_Field18 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field18);
procedure Set_Field19 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field19);
procedure Set_Field20 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field20);
procedure Set_Field21 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field21);
procedure Set_Field22 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field22);
procedure Set_Field23 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field23);
procedure Set_Field24 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field24);
procedure Set_Field25 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field25);
procedure Set_Field26 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field26);
procedure Set_Field27 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field27);
procedure Set_Field28 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field28);
procedure Set_Field29 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field29);
procedure Set_Field30 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field30);
procedure Set_Field31 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field31);
procedure Set_Field32 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field32);
procedure Set_Field33 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field33);
procedure Set_Field34 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field34);
procedure Set_Field35 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field35);
procedure Set_Field36 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field36);
procedure Set_Field37 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field37);
procedure Set_Field38 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field38);
procedure Set_Field39 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field39);
procedure Set_Field40 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field40);
procedure Set_Field41 (N : Node_Id; Val : Union_Id);
pragma Inline (Set_Field41);
procedure Set_Node1 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node1);
procedure Set_Node2 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node2);
procedure Set_Node3 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node3);
procedure Set_Node4 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node4);
procedure Set_Node5 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node5);
procedure Set_Node6 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node6);
procedure Set_Node7 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node7);
procedure Set_Node8 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node8);
procedure Set_Node9 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node9);
procedure Set_Node10 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node10);
procedure Set_Node11 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node11);
procedure Set_Node12 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node12);
procedure Set_Node13 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node13);
procedure Set_Node14 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node14);
procedure Set_Node15 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node15);
procedure Set_Node16 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node16);
procedure Set_Node17 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node17);
procedure Set_Node18 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node18);
procedure Set_Node19 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node19);
procedure Set_Node20 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node20);
procedure Set_Node21 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node21);
procedure Set_Node22 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node22);
procedure Set_Node23 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node23);
procedure Set_Node24 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node24);
procedure Set_Node25 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node25);
procedure Set_Node26 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node26);
procedure Set_Node27 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node27);
procedure Set_Node28 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node28);
procedure Set_Node29 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node29);
procedure Set_Node30 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node30);
procedure Set_Node31 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node31);
procedure Set_Node32 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node32);
procedure Set_Node33 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node33);
procedure Set_Node34 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node34);
procedure Set_Node35 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node35);
procedure Set_Node36 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node36);
procedure Set_Node37 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node37);
procedure Set_Node38 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node38);
procedure Set_Node39 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node39);
procedure Set_Node40 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node40);
procedure Set_Node41 (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node41);
procedure Set_List1 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List1);
procedure Set_List2 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List2);
procedure Set_List3 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List3);
procedure Set_List4 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List4);
procedure Set_List5 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List5);
procedure Set_List10 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List10);
procedure Set_List14 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List14);
procedure Set_List25 (N : Node_Id; Val : List_Id);
pragma Inline (Set_List25);
procedure Set_Elist1 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist1);
procedure Set_Elist2 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist2);
procedure Set_Elist3 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist3);
procedure Set_Elist4 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist4);
procedure Set_Elist5 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist5);
procedure Set_Elist8 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist8);
procedure Set_Elist9 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist9);
procedure Set_Elist10 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist10);
procedure Set_Elist13 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist13);
procedure Set_Elist15 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist15);
procedure Set_Elist16 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist16);
procedure Set_Elist18 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist18);
procedure Set_Elist21 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist21);
procedure Set_Elist23 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist23);
procedure Set_Elist24 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist24);
procedure Set_Elist25 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist25);
procedure Set_Elist26 (N : Node_Id; Val : Elist_Id);
pragma Inline (Set_Elist26);
procedure Set_Name1 (N : Node_Id; Val : Name_Id);
pragma Inline (Set_Name1);
procedure Set_Name2 (N : Node_Id; Val : Name_Id);
pragma Inline (Set_Name2);
procedure Set_Str3 (N : Node_Id; Val : String_Id);
pragma Inline (Set_Str3);
procedure Set_Uint2 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint2);
procedure Set_Uint3 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint3);
procedure Set_Uint4 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint4);
procedure Set_Uint5 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint5);
procedure Set_Uint8 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint8);
procedure Set_Uint9 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint9);
procedure Set_Uint10 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint10);
procedure Set_Uint11 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint11);
procedure Set_Uint12 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint12);
procedure Set_Uint13 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint13);
procedure Set_Uint14 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint14);
procedure Set_Uint15 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint15);
procedure Set_Uint16 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint16);
procedure Set_Uint17 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint17);
procedure Set_Uint22 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint22);
procedure Set_Uint24 (N : Node_Id; Val : Uint);
pragma Inline (Set_Uint24);
procedure Set_Ureal3 (N : Node_Id; Val : Ureal);
pragma Inline (Set_Ureal3);
procedure Set_Ureal18 (N : Node_Id; Val : Ureal);
pragma Inline (Set_Ureal18);
procedure Set_Ureal21 (N : Node_Id; Val : Ureal);
pragma Inline (Set_Ureal21);
procedure Set_Flag0 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag0);
procedure Set_Flag1 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag1);
procedure Set_Flag2 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag2);
procedure Set_Flag3 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag3);
procedure Set_Flag4 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag4);
procedure Set_Flag5 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag5);
procedure Set_Flag6 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag6);
procedure Set_Flag7 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag7);
procedure Set_Flag8 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag8);
procedure Set_Flag9 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag9);
procedure Set_Flag10 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag10);
procedure Set_Flag11 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag11);
procedure Set_Flag12 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag12);
procedure Set_Flag13 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag13);
procedure Set_Flag14 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag14);
procedure Set_Flag15 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag15);
procedure Set_Flag16 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag16);
procedure Set_Flag17 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag17);
procedure Set_Flag18 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag18);
procedure Set_Flag19 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag19);
procedure Set_Flag20 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag20);
procedure Set_Flag21 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag21);
procedure Set_Flag22 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag22);
procedure Set_Flag23 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag23);
procedure Set_Flag24 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag24);
procedure Set_Flag25 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag25);
procedure Set_Flag26 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag26);
procedure Set_Flag27 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag27);
procedure Set_Flag28 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag28);
procedure Set_Flag29 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag29);
procedure Set_Flag30 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag30);
procedure Set_Flag31 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag31);
procedure Set_Flag32 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag32);
procedure Set_Flag33 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag33);
procedure Set_Flag34 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag34);
procedure Set_Flag35 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag35);
procedure Set_Flag36 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag36);
procedure Set_Flag37 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag37);
procedure Set_Flag38 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag38);
procedure Set_Flag39 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag39);
procedure Set_Flag40 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag40);
procedure Set_Flag41 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag41);
procedure Set_Flag42 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag42);
procedure Set_Flag43 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag43);
procedure Set_Flag44 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag44);
procedure Set_Flag45 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag45);
procedure Set_Flag46 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag46);
procedure Set_Flag47 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag47);
procedure Set_Flag48 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag48);
procedure Set_Flag49 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag49);
procedure Set_Flag50 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag50);
procedure Set_Flag51 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag51);
procedure Set_Flag52 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag52);
procedure Set_Flag53 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag53);
procedure Set_Flag54 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag54);
procedure Set_Flag55 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag55);
procedure Set_Flag56 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag56);
procedure Set_Flag57 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag57);
procedure Set_Flag58 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag58);
procedure Set_Flag59 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag59);
procedure Set_Flag60 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag60);
procedure Set_Flag61 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag61);
procedure Set_Flag62 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag62);
procedure Set_Flag63 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag63);
procedure Set_Flag64 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag64);
procedure Set_Flag65 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag65);
procedure Set_Flag66 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag66);
procedure Set_Flag67 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag67);
procedure Set_Flag68 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag68);
procedure Set_Flag69 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag69);
procedure Set_Flag70 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag70);
procedure Set_Flag71 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag71);
procedure Set_Flag72 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag72);
procedure Set_Flag73 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag73);
procedure Set_Flag74 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag74);
procedure Set_Flag75 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag75);
procedure Set_Flag76 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag76);
procedure Set_Flag77 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag77);
procedure Set_Flag78 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag78);
procedure Set_Flag79 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag79);
procedure Set_Flag80 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag80);
procedure Set_Flag81 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag81);
procedure Set_Flag82 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag82);
procedure Set_Flag83 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag83);
procedure Set_Flag84 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag84);
procedure Set_Flag85 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag85);
procedure Set_Flag86 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag86);
procedure Set_Flag87 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag87);
procedure Set_Flag88 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag88);
procedure Set_Flag89 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag89);
procedure Set_Flag90 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag90);
procedure Set_Flag91 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag91);
procedure Set_Flag92 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag92);
procedure Set_Flag93 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag93);
procedure Set_Flag94 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag94);
procedure Set_Flag95 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag95);
procedure Set_Flag96 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag96);
procedure Set_Flag97 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag97);
procedure Set_Flag98 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag98);
procedure Set_Flag99 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag99);
procedure Set_Flag100 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag100);
procedure Set_Flag101 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag101);
procedure Set_Flag102 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag102);
procedure Set_Flag103 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag103);
procedure Set_Flag104 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag104);
procedure Set_Flag105 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag105);
procedure Set_Flag106 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag106);
procedure Set_Flag107 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag107);
procedure Set_Flag108 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag108);
procedure Set_Flag109 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag109);
procedure Set_Flag110 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag110);
procedure Set_Flag111 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag111);
procedure Set_Flag112 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag112);
procedure Set_Flag113 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag113);
procedure Set_Flag114 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag114);
procedure Set_Flag115 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag115);
procedure Set_Flag116 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag116);
procedure Set_Flag117 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag117);
procedure Set_Flag118 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag118);
procedure Set_Flag119 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag119);
procedure Set_Flag120 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag120);
procedure Set_Flag121 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag121);
procedure Set_Flag122 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag122);
procedure Set_Flag123 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag123);
procedure Set_Flag124 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag124);
procedure Set_Flag125 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag125);
procedure Set_Flag126 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag126);
procedure Set_Flag127 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag127);
procedure Set_Flag128 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag128);
procedure Set_Flag129 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag129);
procedure Set_Flag130 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag130);
procedure Set_Flag131 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag131);
procedure Set_Flag132 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag132);
procedure Set_Flag133 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag133);
procedure Set_Flag134 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag134);
procedure Set_Flag135 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag135);
procedure Set_Flag136 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag136);
procedure Set_Flag137 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag137);
procedure Set_Flag138 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag138);
procedure Set_Flag139 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag139);
procedure Set_Flag140 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag140);
procedure Set_Flag141 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag141);
procedure Set_Flag142 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag142);
procedure Set_Flag143 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag143);
procedure Set_Flag144 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag144);
procedure Set_Flag145 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag145);
procedure Set_Flag146 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag146);
procedure Set_Flag147 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag147);
procedure Set_Flag148 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag148);
procedure Set_Flag149 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag149);
procedure Set_Flag150 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag150);
procedure Set_Flag151 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag151);
procedure Set_Flag152 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag152);
procedure Set_Flag153 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag153);
procedure Set_Flag154 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag154);
procedure Set_Flag155 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag155);
procedure Set_Flag156 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag156);
procedure Set_Flag157 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag157);
procedure Set_Flag158 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag158);
procedure Set_Flag159 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag159);
procedure Set_Flag160 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag160);
procedure Set_Flag161 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag161);
procedure Set_Flag162 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag162);
procedure Set_Flag163 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag163);
procedure Set_Flag164 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag164);
procedure Set_Flag165 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag165);
procedure Set_Flag166 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag166);
procedure Set_Flag167 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag167);
procedure Set_Flag168 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag168);
procedure Set_Flag169 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag169);
procedure Set_Flag170 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag170);
procedure Set_Flag171 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag171);
procedure Set_Flag172 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag172);
procedure Set_Flag173 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag173);
procedure Set_Flag174 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag174);
procedure Set_Flag175 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag175);
procedure Set_Flag176 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag176);
procedure Set_Flag177 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag177);
procedure Set_Flag178 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag178);
procedure Set_Flag179 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag179);
procedure Set_Flag180 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag180);
procedure Set_Flag181 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag181);
procedure Set_Flag182 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag182);
procedure Set_Flag183 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag183);
procedure Set_Flag184 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag184);
procedure Set_Flag185 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag185);
procedure Set_Flag186 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag186);
procedure Set_Flag187 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag187);
procedure Set_Flag188 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag188);
procedure Set_Flag189 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag189);
procedure Set_Flag190 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag190);
procedure Set_Flag191 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag191);
procedure Set_Flag192 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag192);
procedure Set_Flag193 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag193);
procedure Set_Flag194 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag194);
procedure Set_Flag195 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag195);
procedure Set_Flag196 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag196);
procedure Set_Flag197 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag197);
procedure Set_Flag198 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag198);
procedure Set_Flag199 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag199);
procedure Set_Flag200 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag200);
procedure Set_Flag201 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag201);
procedure Set_Flag202 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag202);
procedure Set_Flag203 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag203);
procedure Set_Flag204 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag204);
procedure Set_Flag205 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag205);
procedure Set_Flag206 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag206);
procedure Set_Flag207 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag207);
procedure Set_Flag208 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag208);
procedure Set_Flag209 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag209);
procedure Set_Flag210 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag210);
procedure Set_Flag211 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag211);
procedure Set_Flag212 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag212);
procedure Set_Flag213 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag213);
procedure Set_Flag214 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag214);
procedure Set_Flag215 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag215);
procedure Set_Flag216 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag216);
procedure Set_Flag217 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag217);
procedure Set_Flag218 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag218);
procedure Set_Flag219 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag219);
procedure Set_Flag220 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag220);
procedure Set_Flag221 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag221);
procedure Set_Flag222 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag222);
procedure Set_Flag223 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag223);
procedure Set_Flag224 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag224);
procedure Set_Flag225 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag225);
procedure Set_Flag226 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag226);
procedure Set_Flag227 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag227);
procedure Set_Flag228 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag228);
procedure Set_Flag229 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag229);
procedure Set_Flag230 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag230);
procedure Set_Flag231 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag231);
procedure Set_Flag232 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag232);
procedure Set_Flag233 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag233);
procedure Set_Flag234 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag234);
procedure Set_Flag235 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag235);
procedure Set_Flag236 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag236);
procedure Set_Flag237 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag237);
procedure Set_Flag238 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag238);
procedure Set_Flag239 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag239);
procedure Set_Flag240 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag240);
procedure Set_Flag241 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag241);
procedure Set_Flag242 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag242);
procedure Set_Flag243 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag243);
procedure Set_Flag244 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag244);
procedure Set_Flag245 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag245);
procedure Set_Flag246 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag246);
procedure Set_Flag247 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag247);
procedure Set_Flag248 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag248);
procedure Set_Flag249 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag249);
procedure Set_Flag250 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag250);
procedure Set_Flag251 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag251);
procedure Set_Flag252 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag252);
procedure Set_Flag253 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag253);
procedure Set_Flag254 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag254);
procedure Set_Flag255 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag255);
procedure Set_Flag256 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag256);
procedure Set_Flag257 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag257);
procedure Set_Flag258 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag258);
procedure Set_Flag259 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag259);
procedure Set_Flag260 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag260);
procedure Set_Flag261 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag261);
procedure Set_Flag262 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag262);
procedure Set_Flag263 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag263);
procedure Set_Flag264 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag264);
procedure Set_Flag265 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag265);
procedure Set_Flag266 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag266);
procedure Set_Flag267 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag267);
procedure Set_Flag268 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag268);
procedure Set_Flag269 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag269);
procedure Set_Flag270 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag270);
procedure Set_Flag271 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag271);
procedure Set_Flag272 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag272);
procedure Set_Flag273 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag273);
procedure Set_Flag274 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag274);
procedure Set_Flag275 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag275);
procedure Set_Flag276 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag276);
procedure Set_Flag277 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag277);
procedure Set_Flag278 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag278);
procedure Set_Flag279 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag279);
procedure Set_Flag280 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag280);
procedure Set_Flag281 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag281);
procedure Set_Flag282 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag282);
procedure Set_Flag283 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag283);
procedure Set_Flag284 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag284);
procedure Set_Flag285 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag285);
procedure Set_Flag286 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag286);
procedure Set_Flag287 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag287);
procedure Set_Flag288 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag288);
procedure Set_Flag289 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag289);
procedure Set_Flag290 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag290);
procedure Set_Flag291 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag291);
procedure Set_Flag292 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag292);
procedure Set_Flag293 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag293);
procedure Set_Flag294 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag294);
procedure Set_Flag295 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag295);
procedure Set_Flag296 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag296);
procedure Set_Flag297 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag297);
procedure Set_Flag298 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag298);
procedure Set_Flag299 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag299);
procedure Set_Flag300 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag300);
procedure Set_Flag301 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag301);
procedure Set_Flag302 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag302);
procedure Set_Flag303 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag303);
procedure Set_Flag304 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag304);
procedure Set_Flag305 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag305);
procedure Set_Flag306 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag306);
procedure Set_Flag307 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag307);
procedure Set_Flag308 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag308);
procedure Set_Flag309 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag309);
procedure Set_Flag310 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag310);
procedure Set_Flag311 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag311);
procedure Set_Flag312 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag312);
procedure Set_Flag313 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag313);
procedure Set_Flag314 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag314);
procedure Set_Flag315 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag315);
procedure Set_Flag316 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag316);
procedure Set_Flag317 (N : Node_Id; Val : Boolean);
pragma Inline (Set_Flag317);
-- The following versions of Set_Noden also set the parent pointer of
-- the referenced node if it is not Empty.
procedure Set_Node1_With_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node1_With_Parent);
procedure Set_Node2_With_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node2_With_Parent);
procedure Set_Node3_With_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node3_With_Parent);
procedure Set_Node4_With_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node4_With_Parent);
procedure Set_Node5_With_Parent (N : Node_Id; Val : Node_Id);
pragma Inline (Set_Node5_With_Parent);
-- The following versions of Set_Listn also set the parent pointer of
-- the referenced node if it is not Empty.
procedure Set_List1_With_Parent (N : Node_Id; Val : List_Id);
pragma Inline (Set_List1_With_Parent);
procedure Set_List2_With_Parent (N : Node_Id; Val : List_Id);
pragma Inline (Set_List2_With_Parent);
procedure Set_List3_With_Parent (N : Node_Id; Val : List_Id);
pragma Inline (Set_List3_With_Parent);
procedure Set_List4_With_Parent (N : Node_Id; Val : List_Id);
pragma Inline (Set_List4_With_Parent);
procedure Set_List5_With_Parent (N : Node_Id; Val : List_Id);
pragma Inline (Set_List5_With_Parent);
end Unchecked_Access;
-----------------------------
-- Private Part Subpackage --
-----------------------------
-- The following package contains the definition of the data structure
-- used by the implementation of the Atree package. Logically it really
-- corresponds to the private part, hence the name. The reason that it
-- is defined as a sub-package is to allow special access from clients
-- that need to see the internals of the data structures.
package Atree_Private_Part is
-------------------------
-- Tree Representation --
-------------------------
-- The nodes of the tree are stored in a table (i.e. an array). In the
-- case of extended nodes six consecutive components in the array are
-- used. There are thus two formats for array components. One is used
-- for non-extended nodes, and for the first component of extended
-- nodes. The other is used for the extension parts (second, third,
-- fourth, fifth, and sixth components) of an extended node. A variant
-- record structure is used to distinguish the two formats.
type Node_Record (Is_Extension : Boolean := False) is record
-- Logically, the only field in the common part is the above
-- Is_Extension discriminant (a single bit). However, Gigi cannot
-- yet handle such a structure, so we fill out the common part of
-- the record with fields that are used in different ways for
-- normal nodes and node extensions.
Pflag1, Pflag2 : Boolean;
-- The Paren_Count field is represented using two boolean flags,
-- where Pflag1 is worth 1, and Pflag2 is worth 2. This is done
-- because we need to be easily able to reuse this field for
-- extra flags in the extended node case.
In_List : Boolean;
-- Flag used to indicate if node is a member of a list.
-- This field is considered private to the Atree package.
Has_Aspects : Boolean;
-- Flag used to indicate that a node has aspect specifications that
-- are associated with the node. See Aspects package for details.
Rewrite_Ins : Boolean;
-- Flag set by Mark_Rewrite_Insertion procedure.
-- This field is considered private to the Atree package.
Analyzed : Boolean;
-- Flag to indicate the node has been analyzed (and expanded)
Comes_From_Source : Boolean;
-- Flag to indicate that node comes from the source program (i.e.
-- was built by the parser or scanner, not the analyzer or expander).
Error_Posted : Boolean;
-- Flag to indicate that an error message has been posted on the
-- node (to avoid duplicate flags on the same node)
Flag4 : Boolean;
Flag5 : Boolean;
Flag6 : Boolean;
Flag7 : Boolean;
Flag8 : Boolean;
Flag9 : Boolean;
Flag10 : Boolean;
Flag11 : Boolean;
Flag12 : Boolean;
Flag13 : Boolean;
Flag14 : Boolean;
Flag15 : Boolean;
Flag16 : Boolean;
Flag17 : Boolean;
Flag18 : Boolean;
-- Flags 4-18 for a normal node. Note that Flags 0-3 are stored
-- separately in the Flags array.
-- The above fields are used as follows in components 2-6 of an
-- extended node entry. Currently they are not used in component 7,
-- since for now we have all the flags we need, but of course they
-- can be used for additional flags when needed in component 7.
-- In_List used as Flag19,Flag40,Flag129,Flag216,Flag287
-- Has_Aspects used as Flag20,Flag41,Flag130,Flag217,Flag288
-- Rewrite_Ins used as Flag21,Flag42,Flag131,Flag218,Flag289
-- Analyzed used as Flag22,Flag43,Flag132,Flag219,Flag290
-- Comes_From_Source used as Flag23,Flag44,Flag133,Flag220,Flag291
-- Error_Posted used as Flag24,Flag45,Flag134,Flag221,Flag292
-- Flag4 used as Flag25,Flag46,Flag135,Flag222,Flag293
-- Flag5 used as Flag26,Flag47,Flag136,Flag223,Flag294
-- Flag6 used as Flag27,Flag48,Flag137,Flag224,Flag295
-- Flag7 used as Flag28,Flag49,Flag138,Flag225,Flag296
-- Flag8 used as Flag29,Flag50,Flag139,Flag226,Flag297
-- Flag9 used as Flag30,Flag51,Flag140,Flag227,Flag298
-- Flag10 used as Flag31,Flag52,Flag141,Flag228,Flag299
-- Flag11 used as Flag32,Flag53,Flag142,Flag229,Flag300
-- Flag12 used as Flag33,Flag54,Flag143,Flag230,Flag301
-- Flag13 used as Flag34,Flag55,Flag144,Flag231,Flag302
-- Flag14 used as Flag35,Flag56,Flag145,Flag232,Flag303
-- Flag15 used as Flag36,Flag57,Flag146,Flag233,Flag304
-- Flag16 used as Flag37,Flag58,Flag147,Flag234,Flag305
-- Flag17 used as Flag38,Flag59,Flag148,Flag235,Flag306
-- Flag18 used as Flag39,Flag60,Flag149,Flag236,Flag307
-- Pflag1 used as Flag61,Flag62,Flag150,Flag237,Flag308
-- Pflag2 used as Flag63,Flag64,Flag151,Flag238,Flag309
Nkind : Node_Kind;
-- For a non-extended node, or the initial section of an extended
-- node, this field holds the Node_Kind value. For an extended node,
-- The Nkind field is used as follows:
--
-- Second entry: holds the Ekind field of the entity
-- Third entry: holds 8 additional flags (Flag65-Flag72)
-- Fourth entry: holds 8 additional flags (Flag239-246)
-- Fifth entry: holds 8 additional flags (Flag247-254)
-- Sixth entry: holds 8 additional flags (Flag310-317)
-- Seventh entry: currently unused
-- Now finally (on an 32-bit boundary) comes the variant part
case Is_Extension is
-- Non-extended node, or first component of extended node
when False =>
Sloc : Source_Ptr;
-- Source location for this node
Link : Union_Id;
-- This field is used either as the Parent pointer (if In_List
-- is False), or to point to the list header (if In_List is
-- True). This field is considered private and can be modified
-- only by Atree or by Nlists.
Field1 : Union_Id;
Field2 : Union_Id;
Field3 : Union_Id;
Field4 : Union_Id;
Field5 : Union_Id;
-- Five general use fields, which can contain Node_Id, List_Id,
-- Elist_Id, String_Id, or Name_Id values depending on the
-- values in Nkind and (for extended nodes), in Ekind. See
-- packages Sinfo and Einfo for details of their use.
-- Extension (second component) of extended node
when True =>
Field6 : Union_Id;
Field7 : Union_Id;
Field8 : Union_Id;
Field9 : Union_Id;
Field10 : Union_Id;
Field11 : Union_Id;
Field12 : Union_Id;
-- Seven additional general fields available only for entities
-- See package Einfo for details of their use (which depends
-- on the value in the Ekind field).
-- In the third component, the extension format as described
-- above is used to hold additional general fields and flags
-- as follows:
-- Field6-11 Holds Field13-Field18
-- Field12 Holds Flag73-Flag96 and Convention
-- In the fourth component, the extension format as described
-- above is used to hold additional general fields and flags
-- as follows:
-- Field6-10 Holds Field19-Field23
-- Field11 Holds Flag152-Flag183
-- Field12 Holds Flag97-Flag128
-- In the fifth component, the extension format as described
-- above is used to hold additional general fields and flags
-- as follows:
-- Field6-11 Holds Field24-Field29
-- Field12 Holds Flag184-Flag215
-- In the sixth component, the extension format as described
-- above is used to hold additional general fields and flags
-- as follows:
-- Field6-11 Holds Field30-Field35
-- Field12 Holds Flag255-Flag286
-- In the seventh component, the extension format as described
-- above is used to hold additional general fields as follows.
-- Flags are also available potentially, but not used now, as
-- we are not short of entity flags.
-- Field6-11 Holds Field36-Field41
end case;
end record;
pragma Pack (Node_Record);
for Node_Record'Size use 8 * 32;
for Node_Record'Alignment use 4;
function E_To_N is new Unchecked_Conversion (Entity_Kind, Node_Kind);
function N_To_E is new Unchecked_Conversion (Node_Kind, Entity_Kind);
-- Default value used to initialize default nodes. Note that some of the
-- fields get overwritten, and in particular, Nkind always gets reset.
Default_Node : Node_Record := (
Is_Extension => False,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Has_Aspects => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False,
-- modified by Set_Comes_From_Source_Default
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => N_Unused_At_Start,
Sloc => No_Location,
Link => Empty_List_Or_Node,
Field1 => Empty_List_Or_Node,
Field2 => Empty_List_Or_Node,
Field3 => Empty_List_Or_Node,
Field4 => Empty_List_Or_Node,
Field5 => Empty_List_Or_Node);
-- Default value used to initialize node extensions (i.e. the second
-- through seventh components of an extended node). Note we are cheating
-- a bit here when it comes to Node12, which often holds flags and (for
-- the third component), the convention. But it works because Empty,
-- False, Convention_Ada, all happen to be all zero bits.
Default_Node_Extension : constant Node_Record := (
Is_Extension => True,
Pflag1 => False,
Pflag2 => False,
In_List => False,
Has_Aspects => False,
Rewrite_Ins => False,
Analyzed => False,
Comes_From_Source => False,
Error_Posted => False,
Flag4 => False,
Flag5 => False,
Flag6 => False,
Flag7 => False,
Flag8 => False,
Flag9 => False,
Flag10 => False,
Flag11 => False,
Flag12 => False,
Flag13 => False,
Flag14 => False,
Flag15 => False,
Flag16 => False,
Flag17 => False,
Flag18 => False,
Nkind => E_To_N (E_Void),
Field6 => Empty_List_Or_Node,
Field7 => Empty_List_Or_Node,
Field8 => Empty_List_Or_Node,
Field9 => Empty_List_Or_Node,
Field10 => Empty_List_Or_Node,
Field11 => Empty_List_Or_Node,
Field12 => Empty_List_Or_Node);
-- The following defines the extendable array used for the nodes table
-- Nodes with extensions use six consecutive entries in the array
package Nodes is new Table.Table (
Table_Component_Type => Node_Record,
Table_Index_Type => Node_Id'Base,
Table_Low_Bound => First_Node_Id,
Table_Initial => Alloc.Nodes_Initial,
Table_Increment => Alloc.Nodes_Increment,
Table_Name => "Nodes");
-- The following is a parallel table to Nodes, which provides 8 more
-- bits of space that logically belong to the corresponding node. This
-- is currently used to implement Flags 0,1,2,3 for normal nodes, or
-- the first component of an extended node (four bits unused). Entries
-- for extending components are completely unused.
type Flags_Byte is record
Flag0 : Boolean;
Flag1 : Boolean;
Flag2 : Boolean;
Flag3 : Boolean;
Is_Ignored_Ghost_Node : Boolean;
-- Flag denothing whether the node is subject to pragma Ghost with
-- policy Ignore. The name of the flag should be Flag4, however this
-- requires changing the names of all remaining 300+ flags.
Spare1 : Boolean;
Spare2 : Boolean;
Spare3 : Boolean;
end record;
for Flags_Byte'Size use 8;
pragma Pack (Flags_Byte);
Default_Flags : constant Flags_Byte := (others => False);
-- Default value used to initialize new entries
package Flags is new Table.Table (
Table_Component_Type => Flags_Byte,
Table_Index_Type => Node_Id'Base,
Table_Low_Bound => First_Node_Id,
Table_Initial => Alloc.Nodes_Initial,
Table_Increment => Alloc.Nodes_Increment,
Table_Name => "Flags");
end Atree_Private_Part;
end Atree;
|
with Blueprint; use Blueprint;
package Init_Project is
procedure Init(Path: String; ToDo: Action);
private
end Init_Project; |
------------------------------------------------------------------------------
-- Copyright (c) 2016, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with AWS.Config;
with AWS.Messages;
with AWS.Parameters;
with AWS.Response;
with AWS.Server;
with AWS.Status;
with Vision.Engine;
package body Vision.Input is
WS : AWS.Server.HTTP;
Count : Positive := 1;
function Handler (Request : in AWS.Status.Data) return AWS.Response.Data;
function Form_Page return AWS.Response.Data;
function Invalid_Input return AWS.Response.Data;
function Handler (Request : in AWS.Status.Data) return AWS.Response.Data is
URI : constant String := AWS.Status.URI (Request);
begin
if URI = "/" then
return Form_Page;
elsif URI = "/entry" then
declare
P : constant AWS.Parameters.List
:= AWS.Status.Parameters (Request);
Img : constant String := AWS.Parameters.Get (P, "direction");
D : Directions.Extended;
begin
begin
D := Directions.Extended'Value (Img);
exception
when Constraint_Error =>
return Invalid_Input;
end;
Engine.User_Input (D);
Count := Count + 1;
end;
return AWS.Response.URL (Location => "/");
else
return AWS.Response.Acknowledge
(AWS.Messages.S404, "<p>Page '" & URI & "' Not found.");
end if;
end Handler;
procedure Start is
begin
AWS.Server.Start (WS, Handler'Access, AWS.Config.Get_Current);
end Start;
procedure Stop is
begin
AWS.Server.Shutdown (WS);
end Stop;
function Form_Page return AWS.Response.Data is
begin
return AWS.Response.Build ("text/html",
"<html><head><title>Vision Test</title><style>"
& "input { font-size: 1000%; text-align: center; "
& "width: 1.2em; height: 1.2em }"
& "</style></head><body>"
& "<h1>Vision Test</h1><p>Display "
& Positive'Image (Count) & "</p><table><tr><td></td>"
& "<td><form method=""POST"" action=""/entry"">"
& "<input name=""direction"" value=""north"" type=""hidden"">"
& "<input type=""submit"" value=""m"">"
& "</form></td><td></td></tr><tr>"
& "<td><form method=""POST"" action=""/entry"">"
& "<input name=""direction"" value=""west"" type=""hidden"">"
& "<input type=""submit"" value=""E"">"
& "</form></td>"
& "<td><form method=""POST"" action=""/entry"">"
& "<input name=""direction"" value=""unknown"" type=""hidden"">"
& "<input type=""submit"" value=""X"">"
& "</form></td>"
& "<td><form method=""POST"" action=""/entry"">"
& "<input name=""direction"" value=""east"" type=""hidden"">"
& "<input type=""submit"" value=""∃"">"
& "</form></td></tr><tr><td></td>"
& "<td><form method=""POST"" action=""/entry"">"
& "<input name=""direction"" value=""south"" type=""hidden"">"
& "<input type=""submit"" value=""Ш"">"
& "</form></td><td></td></tr>"
& "</table></body></html>");
end Form_Page;
function Invalid_Input return AWS.Response.Data is
begin
return AWS.Response.Build ("text/plain", "Invalid input");
end Invalid_Input;
end Vision.Input;
|
package prefix1 is
type Arr is array (1..10) of Natural;
type T is tagged null record;
function Func (Object : T) return Arr;
end prefix1;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Streams.Stream_IO;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Registrar.Source_Files;
with Unicode.UTF8_Stream_Decoder;
with Unicode.Case_Folding.Simple;
separate (Configuration)
-- Step 2 - we are creating a new configuration unit from the manifest.
--
-- This means both that the registry does not contain a unit corresponding to
-- the configuration unit, and that the registry does cointain a unit
-- corresponding to the manifest. We need to process the entire manifest unit.
--
-- The biggest part of this job is replacing the manifest's package name from
-- Target.AURA to AURA.Target. We will do text substituation, but we need to
-- comply with the Ada standard to 1) allow unicode (utf-8) identifiers, and
-- 2) apply case-folding.
--
-- The Ada standard requires all content to be in Normalization Form 'C' (202X)
-- but we don't need to check for that here as the Ada Lexical Parser will
-- pick that out during unit entry
procedure Step_2 (Target: in out Subsystem) is
use type Registrar.Source_Files.Source_File_Access;
-- These are already case folded
Manifest_Name: constant Unit_Name := Manifest_Unit_Name (Target);
Config_Name : constant Unit_Name := Config_Unit_Name (Target);
-- The manifest has to exist before a call to Step_2, so we don't need
-- to worry about pulling it out of the registry.
Manifest: constant Library_Unit
:= Reg_Qs.Lookup_Unit (Manifest_Name);
-- The basic gyst is: we are reading the manifest as a utf-8 stream,
-- looking for Expected_Name, and if we find it (we should at least
-- one), we replace that in the output stream with Substitute name.
-- Everything else passes through unchanged.
Expected_Name: constant Wide_Wide_String
:= Manifest_Name.To_String;
Substitute_Name: constant Wide_Wide_String
:= Config_Name.To_String;
Scan_Buffer : Wide_Wide_String (1 .. Expected_Name'Length);
Match_Buffer: Wide_Wide_String (Scan_Buffer'Range);
Match_Depth: Positive;
procedure Find_And_Replace
(In_Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Out_Stream: not null access Ada.Streams.Root_Stream_Type'Class)
is
subtype UTF_8_String is Ada.Strings.UTF_Encoding.UTF_8_String;
use type UTF_8_String;
package UTF_8 renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
function Decode_Next
(UTF8_Stream: not null access Ada.Streams.Root_Stream_Type'Class
:= In_Stream)
return Wide_Wide_Character
renames Unicode.UTF8_Stream_Decoder.Decode_Next;
begin
Match_Depth := Scan_Buffer'First;
loop
-- The Scan_Buffer will hold the source while we see if it matches
-- the expected name, however to match accoring to the Ada rules,
-- we need to first do simple case folding before checking for a
-- match. Since we don't want to apply that case folding to the
-- source itself, we need to have a parallel case-folded buffer
Scan_Buffer(Match_Depth) := Decode_Next;
Match_Buffer(Match_Depth)
:= Unicode.Case_Folding.Simple (Scan_Buffer(Match_Depth));
if Match_Buffer(Match_Depth) = Expected_Name(Match_Depth) then
if Match_Depth = Scan_Buffer'Last then
-- It is not really worth the effort to check for weird things
-- showing up where this naieve replace might mangle the middle
-- of something that happens to match. It should be rare enough
-- (especially in a manifest) to not often cause a problem.
--
-- The Ada compiler will almost certainly spot it later.
--
-- If we wanted to check for that, we'd really want to bring
-- in the Ada lexical parser since we really should not be
-- handling the various rules ourselves and creating redundant
-- code. However using the parser would mess up our stream.
--
-- We considered possibly "rewriting" the unit via the parser,
-- but since the Configuration unit really should be human
-- -readable and human-changable, this seemed like the wrong
-- approach.
--
-- If this really becomes a problem, we can always make
-- improvements.
UTF_8_String'Write
(Out_Stream,
UTF_8.Encode (Substitute_Name));
Match_Depth := Scan_Buffer'First;
else
-- Keep trying
Match_Depth := Match_Depth + 1;
end if;
else
-- Flush buffer
UTF_8_String'Write
(Out_Stream,
UTF_8.Encode (Scan_Buffer(Scan_Buffer'First .. Match_Depth)));
Match_Depth := Scan_Buffer'First;
end if;
end loop;
exception
when Ada.Streams.Stream_IO.End_Error =>
-- The Ada lexical parser on entry is not used to dig down through the
-- whole spec, lets do a little check for funny business while we're
-- at it (we shouldn't get here if we were in the middle of the
-- Expected_Name)
Assert (Check => Match_Depth = Scan_Buffer'First,
Message => "Unexpected end of manifest");
return;
when others =>
raise;
end Find_And_Replace;
procedure Register (Name: in String) is
use Ada.Directories;
Search : Search_Type;
New_Reg: Directory_Entry_Type;
begin
Start_Search (Search => Search,
Directory => Current_Directory,
Pattern => Name);
Assert (Check => More_Entries (Search),
Message => "Error registering configuration unit - cannot find "
& "generated file " & Name & '!');
Get_Next_Entry (Search => Search, Directory_Entry => New_Reg);
Registrar.Registration.Enter_Unit (New_Reg);
End_Search (Search);
end Register;
begin
-- The following could be generic, but the parameters would be pretty
-- complex, and the code is so simple, it doesn't seem worth it.
-- Spec
declare
use Ada.Streams.Stream_IO;
use Registrar.Source_Files;
Spec_Name: constant String
:= "aura-" & Target.Name.To_UTF8_String & ".ads";
File : File_Type;
M_Stream : aliased Source_Stream
:= Checkout_Read_Stream (Manifest.Spec_File);
begin
Create (File => File,
Mode => Out_File,
Name => Spec_Name);
Find_And_Replace (In_Stream => M_Stream'Access,
Out_Stream => Stream (File));
Close (File);
Register (Spec_Name);
end;
if Manifest.Body_File /= null then
-- Body
declare
use Ada.Streams.Stream_IO;
use Registrar.Source_Files;
Body_Name: constant String
:= "aura-" & Target.Name.To_UTF8_String & ".adb";
File : File_Type;
M_Stream : aliased Source_Stream
:= Checkout_Read_Stream (Manifest.Body_File);
begin
Create (File => File,
Mode => Out_File,
Name => Body_Name);
Find_And_Replace (In_Stream => M_Stream'Access,
Out_Stream => Stream (File));
Close (File);
Register (Body_Name);
end;
end if;
-- Next is Step 3, but we need to wait for the registrar to register the
-- configuration unit before we can process it, so we need to defer
-- Step_3
Workers.Disable_Completion_Reports;
Configuration_Progress.Increment_Total_Items;
Workers.Defer_Order
(Order => Step_3a_Deferral'(Tracker => Configuration_Progress'Access,
Target => Target),
Wait_Tracker => Registrar.Registration.Entry_Progress'Access);
end Step_2;
|
-----------------------------------------------------------------------
-- strings.tests -- Unit tests for strings
-- 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.Strings;
with Ada.Strings.Unbounded;
with Ada.Strings.Fixed;
with Ada.Strings.Fixed.Hash;
with Ada.Strings.Unbounded.Hash;
with Ada.Containers;
with Util.Test_Caller;
with Util.Strings.Transforms;
with Util.Strings.Maps;
with Util.Perfect_Hash;
with Util.Strings.Tokenizers;
with Ada.Streams;
with Util.Measures;
package body Util.Strings.Tests is
use Ada.Strings.Unbounded;
use Util.Tests;
use Util.Strings.Transforms;
package Caller is new Util.Test_Caller (Test, "Strings");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Escape_Javascript",
Test_Escape_Javascript'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Escape_Xml",
Test_Escape_Xml'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Unescape_Xml",
Test_Unescape_Xml'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.Capitalize",
Test_Capitalize'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Upper_Case",
Test_To_Upper_Case'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Lower_Case",
Test_To_Lower_Case'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Transforms.To_Hex",
Test_To_Hex'Access);
Caller.Add_Test (Suite, "Test Measure",
Test_Measure_Copy'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Index",
Test_Index'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Rindex",
Test_Rindex'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Benchmark",
Test_Measure_Hash'Access);
Caller.Add_Test (Suite, "Test Util.Strings.String_Ref",
Test_String_Ref'Access);
Caller.Add_Test (Suite, "Test perfect hash",
Test_Perfect_Hash'Access);
Caller.Add_Test (Suite, "Test Util.Strings.Tokenizers.Iterate_Token",
Test_Iterate_Token'Access);
end Add_Tests;
procedure Test_Escape_Javascript (T : in out Test) is
Result : Unbounded_String;
begin
Escape_Javascript (Content => ASCII.LF & " ""a string"" a 'single quote'",
Into => Result);
Assert_Equals (T, "\n \""a string\"" a \'single quote\'", Result);
Result := To_Unbounded_String ("");
Escape_Javascript (Content => ASCII.ESC & "[m " & Character'Val (255),
Into => Result);
Assert_Equals (T, "\u001B[m " & Character'Val (255), Result);
end Test_Escape_Javascript;
procedure Test_Escape_Xml (T : in out Test) is
Result : Unbounded_String;
begin
Escape_Xml (Content => ASCII.LF & " < ""a string"" a 'single quote' >& ",
Into => Result);
Assert_Equals (T, ASCII.LF & " < ""a string"" a 'single quote' >& ",
Result);
Result := To_Unbounded_String ("");
Escape_Xml (Content => ASCII.ESC & "[m " & Character'Val (255),
Into => Result);
Assert_Equals (T, ASCII.ESC & "[m ÿ", Result);
end Test_Escape_Xml;
procedure Test_Unescape_Xml (T : in out Test) is
Result : Unbounded_String;
begin
Unescape_Xml (Content => "<>&" ' A",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "<>&"" ' A", Result, "Invalid unescape");
Set_Unbounded_String (Result, "");
Unescape_Xml (Content => "Test Ao~ end",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "Test Ao~ end", Result, "Invalid decimal unescape");
Set_Unbounded_String (Result, "");
Unescape_Xml (Content => "Test eÀđĦË end",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
Util.Tests.Assert_Equals (T, "Test eÀđĦË end", Result, "Invalid Decimal Unescape");
Unescape_Xml (Content => "&;&#qsf;&qsd;�; )",
Translator => Util.Strings.Transforms.TR.Translate_Xml_Entity'Access,
Into => Result);
end Test_Unescape_Xml;
procedure Test_Capitalize (T : in out Test) is
Result : Unbounded_String;
begin
Assert_Equals (T, "Capitalize_A_String", Capitalize ("capITalIZe_a_strING"));
Capitalize ("CapAS_String", Result);
Assert_Equals (T, "Capas_String", Result);
end Test_Capitalize;
procedure Test_To_Upper_Case (T : in out Test) is
begin
Assert_Equals (T, "UPPERCASE_0123_STR", To_Upper_Case ("upperCase_0123_str"));
end Test_To_Upper_Case;
procedure Test_To_Lower_Case (T : in out Test) is
begin
Assert_Equals (T, "lowercase_0123_str", To_Lower_Case ("LowERCase_0123_STR"));
end Test_To_Lower_Case;
procedure Test_To_Hex (T : in out Test) is
Result : Unbounded_String;
begin
To_Hex (Result, Character'Val (23));
Assert_Equals (T, "\u0017", Result);
To_Hex (Result, Character'Val (31));
Assert_Equals (T, "\u0017\u001F", Result);
To_Hex (Result, Character'Val (255));
Assert_Equals (T, "\u0017\u001F\u00FF", Result);
end Test_To_Hex;
procedure Test_Measure_Copy (T : in out Test) is
pragma Unreferenced (T);
Buf : constant Ada.Streams.Stream_Element_Array (1 .. 10_024) := (others => 23);
pragma Suppress (All_Checks, Buf);
begin
declare
T : Util.Measures.Stamp;
R : Ada.Strings.Unbounded.Unbounded_String;
begin
for I in Buf'Range loop
Append (R, Character'Val (Buf (I)));
end loop;
Util.Measures.Report (T, "Stream transform using Append (1024 bytes)");
end;
declare
T : Util.Measures.Stamp;
R : Ada.Strings.Unbounded.Unbounded_String;
S : String (1 .. 10_024);
pragma Suppress (All_Checks, S);
begin
for I in Buf'Range loop
S (Natural (I)) := Character'Val (Buf (I));
end loop;
Append (R, S);
Util.Measures.Report (T, "Stream transform using temporary string (1024 bytes)");
end;
-- declare
-- T : Util.Measures.Stamp;
-- R : Ada.Strings.Unbounded.Unbounded_String;
-- P : constant Ptr := new String (1 .. Buf'Length);
--
-- pragma Suppress (All_Checks, P);
-- begin
-- for I in P'Range loop
-- P (I) := Character'Val (Buf (Ada.Streams.Stream_Element_Offset (I)));
-- end loop;
-- Ada.Strings.Unbounded.Aux.Set_String (R, P.all'Access);
-- Util.Measures.Report (T, "Stream transform using Aux string (1024 bytes)");
-- end;
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash");
end;
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash");
end;
end Test_Measure_Copy;
-- Test the Index operation
procedure Test_Index (T : in out Test) is
Str : constant String := "0123456789abcdefghijklmnopq";
begin
declare
St : Util.Measures.Stamp;
Pos : Integer;
begin
for I in 1 .. 10 loop
Pos := Index (Str, 'q');
end loop;
Util.Measures.Report (St, "Util.Strings.Index");
Assert_Equals (T, 27, Pos, "Invalid index position");
end;
declare
St : Util.Measures.Stamp;
Pos : Integer;
begin
for I in 1 .. 10 loop
Pos := Ada.Strings.Fixed.Index (Str, "q");
end loop;
Util.Measures.Report (St, "Ada.Strings.Fixed.Index");
Assert_Equals (T, 27, Pos, "Invalid index position");
end;
end Test_Index;
-- Test the Rindex operation
procedure Test_Rindex (T : in out Test) is
Str : constant String := "0123456789abcdefghijklmnopq";
begin
declare
St : Util.Measures.Stamp;
Pos : Natural;
begin
for I in 1 .. 10 loop
Pos := Rindex (Str, '0');
end loop;
Util.Measures.Report (St, "Util.Strings.Rindex");
Assert_Equals (T, 1, Pos, "Invalid rindex position");
end;
declare
St : Util.Measures.Stamp;
Pos : Natural;
begin
for I in 1 .. 10 loop
Pos := Ada.Strings.Fixed.Index (Str, "0", Ada.Strings.Backward);
end loop;
Util.Measures.Report (St, "Ada.Strings.Fixed.Rindex");
Assert_Equals (T, 1, Pos, "Invalid rindex position");
end;
end Test_Rindex;
package String_Map is new Ada.Containers.Hashed_Maps
(Key_Type => Unbounded_String,
Element_Type => Unbounded_String,
Hash => Hash,
Equivalent_Keys => "=");
package String_Ref_Map is new Ada.Containers.Hashed_Maps
(Key_Type => String_Ref,
Element_Type => String_Ref,
Hash => Hash,
Equivalent_Keys => Equivalent_Keys);
-- Do some benchmark on String -> X hash mapped.
procedure Test_Measure_Hash (T : in out Test) is
KEY : aliased constant String := "testing";
Str_Map : Util.Strings.Maps.Map;
Ptr_Map : Util.Strings.String_Access_Map.Map;
Ref_Map : String_Ref_Map.Map;
Unb_Map : String_Map.Map;
Name : String_Access := new String '(KEY);
Ref : constant String_Ref := To_String_Ref (KEY);
begin
Str_Map.Insert (Name.all, Name.all);
Ptr_Map.Insert (Name.all'Access, Name.all'Access);
Unb_Map.Insert (To_Unbounded_String (KEY), To_Unbounded_String (KEY));
Ref_Map.Insert (Ref, Ref);
declare
T : Util.Measures.Stamp;
H : Ada.Containers.Hash_Type;
pragma Unreferenced (H);
begin
for I in 1 .. 1_000 loop
H := Ada.Strings.Fixed.Hash ("http://code.google.com/p/ada-awa/jsf:wiki");
end loop;
Util.Measures.Report (T, "Ada.Strings.Fixed.Hash (1000 calls)");
end;
-- Performance of Hashed_Map Name_Access -> Name_Access
-- (the fastest hash)
declare
St : Util.Measures.Stamp;
Pos : constant Strings.String_Access_Map.Cursor := Ptr_Map.Find (KEY'Unchecked_Access);
Val : constant Name_Access := Util.Strings.String_Access_Map.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.String_Access_Maps.Find+Element");
Assert_Equals (T, "testing", Val.all, "Invalid value returned");
end;
-- Performance of Hashed_Map String_Ref -> String_Ref
-- (almost same performance as Hashed_Map Name_Access -> Name_Access)
declare
St : Util.Measures.Stamp;
Pos : constant String_Ref_Map.Cursor := Ref_Map.Find (Ref);
Val : constant String_Ref := String_Ref_Map.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.String_Ref_Maps.Find+Element");
Assert_Equals (T, "testing", String '(To_String (Val)), "Invalid value returned");
end;
-- Performance of Hashed_Map Unbounded_String -> Unbounded_String
-- (little overhead due to String copy made by Unbounded_String)
declare
St : Util.Measures.Stamp;
Pos : constant String_Map.Cursor := Unb_Map.Find (To_Unbounded_String (KEY));
Val : constant Unbounded_String := String_Map.Element (Pos);
begin
Util.Measures.Report (St, "Hashed_Maps<Unbounded,Unbounded..Find+Element");
Assert_Equals (T, "testing", Val, "Invalid value returned");
end;
-- Performance for Indefinite_Hashed_Map String -> String
-- (the slowest hash, string copy to get the result, pointer to key and element
-- in the hash map implementation)
declare
St : Util.Measures.Stamp;
Pos : constant Util.Strings.Maps.Cursor := Str_Map.Find (KEY);
Val : constant String := Util.Strings.Maps.Element (Pos);
begin
Util.Measures.Report (St, "Util.Strings.Maps.Find+Element");
Assert_Equals (T, "testing", Val, "Invalid value returned");
end;
Free (Name);
end Test_Measure_Hash;
-- ------------------------------
-- Test String_Ref creation
-- ------------------------------
procedure Test_String_Ref (T : in out Test) is
R1 : String_Ref := To_String_Ref ("testing a string");
begin
for I in 1 .. 1_000 loop
declare
S : constant String (1 .. I) := (others => 'x');
R2 : constant String_Ref := To_String_Ref (S);
begin
Assert_Equals (T, S, To_String (R2), "Invalid String_Ref");
T.Assert (R2 = S, "Invalid comparison");
Assert_Equals (T, I, Length (R2), "Invalid length");
R1 := R2;
T.Assert (R1 = R2, "Invalid String_Ref copy");
end;
end loop;
end Test_String_Ref;
-- Test perfect hash (samples/gperfhash)
procedure Test_Perfect_Hash (T : in out Test) is
begin
for I in Util.Perfect_Hash.Keywords'Range loop
declare
K : constant String := Util.Perfect_Hash.Keywords (I).all;
begin
Assert_Equals (T, I, Util.Perfect_Hash.Hash (K),
"Invalid hash");
Assert_Equals (T, I, Util.Perfect_Hash.Hash (To_Lower_Case (K)),
"Invalid hash");
Assert (T, Util.Perfect_Hash.Is_Keyword (K), "Keyword " & K & " is not a keyword");
Assert (T, Util.Perfect_Hash.Is_Keyword (To_Lower_Case (K)),
"Keyword " & K & " is not a keyword");
end;
end loop;
end Test_Perfect_Hash;
-- ------------------------------
-- Test the token iteration.
-- ------------------------------
procedure Test_Iterate_Token (T : in out Test) is
procedure Process_Token (Token : in String;
Done : out Boolean);
Called : Natural := 0;
procedure Process_Token (Token : in String;
Done : out Boolean) is
begin
T.Assert (Token = "one" or Token = "two" or Token = "three"
or Token = "four five" or Token = "six seven",
"Invalid token: [" & Token & "]");
Called := Called + 1;
Done := False;
end Process_Token;
begin
Util.Strings.Tokenizers.Iterate_Tokens (Content => "one two three",
Pattern => " ",
Process => Process_Token'Access);
Util.Tests.Assert_Equals (T, 3, Called, "Iterate_Tokens calls Process incorrectly");
Util.Strings.Tokenizers.Iterate_Tokens (Content => "one two three",
Pattern => " ",
Process => Process_Token'Access,
Going => Ada.Strings.Backward);
Util.Tests.Assert_Equals (T, 6, Called, "Iterate_Tokens calls Process incorrectly");
Util.Strings.Tokenizers.Iterate_Tokens (Content => "four five blob six seven",
Pattern => " blob ",
Process => Process_Token'Access);
Util.Tests.Assert_Equals (T, 8, Called, "Iterate_Tokens calls Process incorrectly");
end Test_Iterate_Token;
end Util.Strings.Tests;
|
-----------------------------------------------------------------------
-- files.tests -- Unit tests for files
-- Copyright (C) 2009, 2010, 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.Directories;
with Util.Test_Caller;
package body Util.Files.Tests is
use Util.Tests;
package Caller is new Util.Test_Caller (Test, "Files");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Files.Read_File",
Test_Read_File'Access);
Caller.Add_Test (Suite, "Test Util.Files.Read_File (missing)",
Test_Read_File_Missing'Access);
Caller.Add_Test (Suite, "Test Util.Files.Read_File (truncate)",
Test_Read_File'Access);
Caller.Add_Test (Suite, "Test Util.Files.Write_File",
Test_Write_File'Access);
Caller.Add_Test (Suite, "Test Util.Files.Iterate_Path",
Test_Iterate_Path'Access);
Caller.Add_Test (Suite, "Test Util.Files.Find_File_Path",
Test_Find_File_Path'Access);
Caller.Add_Test (Suite, "Test Util.Files.Compose_Path",
Test_Compose_Path'Access);
Caller.Add_Test (Suite, "Test Util.Files.Get_Relative_Path",
Test_Get_Relative_Path'Access);
end Add_Tests;
-- ------------------------------
-- Test reading a file into a string
-- Reads this ada source file and checks we have read it correctly
-- ------------------------------
procedure Test_Read_File (T : in out Test) is
Result : Unbounded_String;
begin
Read_File (Path => "regtests/util-files-tests.adb", Into => Result);
T.Assert (Index (Result, "Util.Files.Tests") > 0,
"Content returned by Read_File is not correct");
T.Assert (Index (Result, "end Util.Files.Tests;") > 0,
"Content returned by Read_File is not correct");
end Test_Read_File;
procedure Test_Read_File_Missing (T : in out Test) is
Result : Unbounded_String;
pragma Unreferenced (Result);
begin
Read_File (Path => "regtests/files-test--util.adb", Into => Result);
T.Assert (False, "No exception raised");
exception
when others =>
null;
end Test_Read_File_Missing;
procedure Test_Read_File_Truncate (T : in out Test) is
Result : Unbounded_String;
begin
Read_File (Path => "regtests/util-files-tests.adb", Into => Result,
Max_Size => 50);
Assert_Equals (T, Length (Result), 50,
"Read_File did not truncate correctly");
T.Assert (Index (Result, "Apache License") > 0,
"Content returned by Read_File is not correct");
end Test_Read_File_Truncate;
-- ------------------------------
-- Check writing a file
-- ------------------------------
procedure Test_Write_File (T : in out Test) is
Path : constant String := Util.Tests.Get_Test_Path ("test-write.txt");
Content : constant String := "Testing Util.Files.Write_File" & ASCII.LF;
Result : Unbounded_String;
begin
Write_File (Path => Path, Content => Content);
Read_File (Path => Path, Into => Result);
Assert_Equals (T, To_String (Result), Content,
"Invalid content written or read");
end Test_Write_File;
-- ------------------------------
-- Check Find_File_Path
-- ------------------------------
procedure Test_Find_File_Path (T : in out Test) is
Dir : constant String := Util.Tests.Get_Path ("regtests");
Paths : constant String := ".;" & Dir;
begin
declare
P : constant String := Util.Files.Find_File_Path ("test.properties", Paths);
begin
Assert_Equals (T, Dir & "/test.properties", P,
"Invalid path returned");
end;
Assert_Equals (T, "blablabla.properties",
Util.Files.Find_File_Path ("blablabla.properties", Paths));
end Test_Find_File_Path;
-- ------------------------------
-- Check Iterate_Path
-- ------------------------------
procedure Test_Iterate_Path (T : in out Test) is
procedure Check_Path (Dir : in String;
Done : out Boolean);
Last : Unbounded_String;
procedure Check_Path (Dir : in String;
Done : out Boolean) is
begin
if Dir = "a" or Dir = "bc" or Dir = "de" then
Done := False;
else
Done := True;
end if;
Last := To_Unbounded_String (Dir);
end Check_Path;
begin
Iterate_Path ("a;bc;de;f", Check_Path'Access);
Assert_Equals (T, "f", Last, "Invalid last path");
Iterate_Path ("de;bc;de;b", Check_Path'Access);
Assert_Equals (T, "b", Last, "Invalid last path");
Iterate_Path ("de;bc;de;a", Check_Path'Access, Ada.Strings.Backward);
Assert_Equals (T, "de", Last, "Invalid last path");
end Test_Iterate_Path;
-- ------------------------------
-- Test the Compose_Path operation
-- ------------------------------
procedure Test_Compose_Path (T : in out Test) is
begin
Assert_Equals (T, "src/os-none",
Compose_Path ("src;regtests", "os-none"),
"Invalid path composition");
Assert_Equals (T, "regtests/bundles",
Compose_Path ("src;regtests", "bundles"),
"Invalid path composition");
if Ada.Directories.Exists ("/usr/bin") then
Assert_Equals (T, "/usr/bin;/usr/local/bin;/usr/bin",
Compose_Path ("/usr;/usr/local;/usr", "bin"),
"Invalid path composition");
end if;
end Test_Compose_Path;
-- ------------------------------
-- Test the Get_Relative_Path operation.
-- ------------------------------
procedure Test_Get_Relative_Path (T : in out Test) is
begin
Assert_Equals (T, "../util",
Get_Relative_Path ("/home/john/src/asf", "/home/john/src/util"),
"Invalid relative path");
Assert_Equals (T, "../util",
Get_Relative_Path ("/home/john/src/asf/", "/home/john/src/util"),
"Invalid relative path");
Assert_Equals (T, "../util/b",
Get_Relative_Path ("/home/john/src/asf", "/home/john/src/util/b"),
"Invalid relative path");
Assert_Equals (T, "../as",
Get_Relative_Path ("/home/john/src/asf", "/home/john/src/as"),
"Invalid relative path");
Assert_Equals (T, "../../",
Get_Relative_Path ("/home/john/src/asf", "/home/john"),
"Invalid relative path");
Assert_Equals (T, "/usr/share/admin",
Get_Relative_Path ("/home/john/src/asf", "/usr/share/admin"),
"Invalid absolute path");
Assert_Equals (T, "/home/john",
Get_Relative_Path ("home/john/src/asf", "/home/john"),
"Invalid relative path");
Assert_Equals (T, "e",
Get_Relative_Path ("/home/john/src/asf", "/home/john/src/asf/e"),
"Invalid relative path");
Assert_Equals (T, ".",
Get_Relative_Path ("/home/john/src/asf", "/home/john/src/asf/"),
"Invalid relative path");
end Test_Get_Relative_Path;
end Util.Files.Tests;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . T A S K _ A T T R I B U T E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-1994, Florida State University --
-- Copyright (C) 1995-2010, 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides support for the body of Ada.Task_Attributes
with Ada.Finalization;
with System.Storage_Elements;
package System.Tasking.Task_Attributes is
type Attribute is new Integer;
-- A stand-in for the generic formal type of Ada.Task_Attributes
-- in the following declarations.
type Node;
type Access_Node is access all Node;
-- This needs comments ???
function To_Access_Node is new Ada.Unchecked_Conversion
(Access_Address, Access_Node);
-- Used to fetch pointer to indirect attribute list. Declaration is in
-- spec to avoid any problems with aliasing assumptions.
type Dummy_Wrapper;
type Access_Dummy_Wrapper is access all Dummy_Wrapper;
pragma No_Strict_Aliasing (Access_Dummy_Wrapper);
-- Needed to avoid possible incorrect aliasing situations from
-- instantiation of Unchecked_Conversion in body of Ada.Task_Attributes.
for Access_Dummy_Wrapper'Storage_Size use 0;
-- Access_Dummy_Wrapper is a stand-in for the generic type Wrapper defined
-- in Ada.Task_Attributes. The real objects allocated are always
-- of type Wrapper, no Dummy_Wrapper objects are ever created.
type Deallocator is access procedure (P : in out Access_Node);
-- Called to deallocate an Wrapper. P is a pointer to a Node within
type Instance;
type Access_Instance is access all Instance;
type Instance is new Ada.Finalization.Limited_Controlled with record
Deallocate : Deallocator;
Initial_Value : aliased System.Storage_Elements.Integer_Address;
Index : Direct_Index;
-- The index of the TCB location used by this instantiation, if it is
-- stored in the TCB, otherwise zero.
Next : Access_Instance;
-- Next instance in All_Attributes list
end record;
procedure Finalize (X : in out Instance);
type Node is record
Wrapper : Access_Dummy_Wrapper;
Instance : Access_Instance;
Next : Access_Node;
end record;
-- The following type is a stand-in for the actual wrapper type, which is
-- different for each instantiation of Ada.Task_Attributes.
type Dummy_Wrapper is record
Dummy_Node : aliased Node;
Value : aliased Attribute;
-- The generic formal type, may be controlled
end record;
for Dummy_Wrapper'Alignment use Standard'Maximum_Alignment;
-- A number of unchecked conversions involving Dummy_Wrapper_Access
-- sources are performed in other units (e.g. Ada.Task_Attributes).
-- Ensure that the designated object is always strictly enough aligned.
In_Use : Direct_Index_Vector := 0;
-- Set True for direct indexes that are already used (True??? type???)
All_Attributes : Access_Instance;
-- A linked list of all indirectly access attributes, which includes all
-- those that require finalization.
procedure Initialize_Attributes (T : Task_Id);
-- Initialize all attributes created via Ada.Task_Attributes for T. This
-- must be called by the creator of the task, inside Create_Task, via
-- soft-link Initialize_Attributes_Link. On entry, abort must be deferred
-- and the caller must hold no locks
procedure Finalize_Attributes (T : Task_Id);
-- Finalize all attributes created via Ada.Task_Attributes for T.
-- This is to be called by the task after it is marked as terminated
-- (and before it actually dies), inside Vulnerable_Free_Task, via the
-- soft-link Finalize_Attributes_Link. On entry, abort must be deferred
-- and T.L must be write-locked.
end System.Tasking.Task_Attributes;
|
-----------------------------------------------------------------------
-- words -- Extract words and links from a Wiki or HTML document
-- Copyright (C) 2016 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.Text_IO;
with Ada.Wide_Wide_Text_IO;
with Ada.IO_Exceptions;
with GNAT.Command_Line;
with Wiki.Documents;
with Wiki.Parsers;
with Wiki.Streams.Text_IO;
with Wiki.Filters.Html;
with Wiki.Filters.Autolink;
with Wiki.Filters.Collectors;
procedure Words is
use GNAT.Command_Line;
procedure Usage;
procedure Print (Pos : in Wiki.Filters.Collectors.Cursor);
procedure Usage is
begin
Ada.Text_IO.Put_Line ("Report list of words or links used in a wiki text file or HTML file");
Ada.Text_IO.Put_Line ("Usage: words [-l] [-i] [-m] [-H] [-M] [-d] [-c] {wiki-file}");
Ada.Text_IO.Put_Line (" -l Report links instead of words");
Ada.Text_IO.Put_Line (" -i Report images instead of words");
Ada.Text_IO.Put_Line (" -m Parse a Markdown wiki content");
Ada.Text_IO.Put_Line (" -M Parse a Mediawiki wiki content");
Ada.Text_IO.Put_Line (" -d Parse a Dotclear wiki content");
Ada.Text_IO.Put_Line (" -g Parse a Google wiki content");
Ada.Text_IO.Put_Line (" -c Parse a Creole wiki content");
Ada.Text_IO.Put_Line (" -H Parse an HTML content");
end Usage;
procedure Print (Pos : in Wiki.Filters.Collectors.Cursor) is
Count : constant Natural := Wiki.Filters.Collectors.WString_Maps.Element (Pos);
begin
Ada.Wide_Wide_Text_IO.Put (Wiki.Filters.Collectors.WString_Maps.Key (Pos));
Ada.Wide_Wide_Text_IO.Put (" ");
Ada.Wide_Wide_Text_IO.Put_Line (Natural'Wide_Wide_Image (Count));
end Print;
Count : Natural := 0;
Syntax : Wiki.Wiki_Syntax := Wiki.SYNTAX_MARKDOWN;
Link_Mode : Boolean := False;
Image_Mode : Boolean := False;
Words : aliased Wiki.Filters.Collectors.Word_Collector_Type;
Links : aliased Wiki.Filters.Collectors.Link_Collector_Type;
Images : aliased Wiki.Filters.Collectors.Image_Collector_Type;
begin
loop
case Getopt ("m M H d c g l i") is
when 'm' =>
Syntax := Wiki.SYNTAX_MARKDOWN;
when 'M' =>
Syntax := Wiki.SYNTAX_MEDIA_WIKI;
when 'H' =>
Syntax := Wiki.SYNTAX_HTML;
when 'c' =>
Syntax := Wiki.SYNTAX_CREOLE;
when 'd' =>
Syntax := Wiki.SYNTAX_DOTCLEAR;
when 'g' =>
Syntax := Wiki.SYNTAX_GOOGLE;
when 'l' =>
Link_Mode := True;
when 'i' =>
Image_Mode := True;
when others =>
exit;
end case;
end loop;
loop
declare
Name : constant String := GNAT.Command_Line.Get_Argument;
Input : aliased Wiki.Streams.Text_IO.File_Input_Stream;
Filter : aliased Wiki.Filters.Html.Html_Filter_Type;
Autolink : aliased Wiki.Filters.Autolink.Autolink_Filter;
Doc : Wiki.Documents.Document;
Engine : Wiki.Parsers.Parser;
begin
if Name = "" then
if Count = 0 then
Usage;
end if;
exit;
end if;
Count := Count + 1;
-- Open the file and parse it (assume UTF-8).
Input.Open (Name, "WCEM=8");
Engine.Add_Filter (Words'Unchecked_Access);
Engine.Add_Filter (Links'Unchecked_Access);
Engine.Add_Filter (Images'Unchecked_Access);
Engine.Add_Filter (Filter'Unchecked_Access);
Engine.Add_Filter (Autolink'Unchecked_Access);
Engine.Set_Syntax (Syntax);
Engine.Parse (Input'Unchecked_Access, Doc);
exception
when Ada.IO_Exceptions.Name_Error =>
Ada.Text_IO.Put_Line ("Cannot read file '" & Name & "'");
end;
end loop;
if Image_Mode then
Images.Iterate (Print'Access);
elsif Link_Mode then
Links.Iterate (Print'Access);
else
Words.Iterate (Print'Access);
end if;
exception
when Invalid_Switch =>
Ada.Text_IO.Put_Line ("Invalid option.");
Usage;
end Words;
|
with Person;
with Ada.Text_IO; use Ada.Text_IO;
package body A is
procedure Print_Modify is
package I is new Ada.Text_IO.Integer_IO (Integer);
begin
I.Put (Person.Unit_Age); New_Line;
Person.Unit_Age := 10;
end Print_Modify;
end A;
|
-- --
-- package Strings_Edit.Quoted Copyright (c) Dmitry A. Kazakov --
-- Interface Luebeck --
-- Summer, 2004 --
-- --
-- Last revision : 11:50 30 May 2014 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
package Strings_Edit.Quoted is
--
-- Get_Quoted -- Get a quoted text from string
--
-- Source - The string
-- Pointer - To where the name begins (a pointer to)
-- Mark - Quotation marks character
--
-- This function is used to get a quoted string. String (Pointer.all) is
-- the first character of the string. Pointer is advanced to the the
-- first character following the input. The parameter Marks specifies
-- the quotation marks to use. Within the string body this character is
-- GDoubled.
--
-- Returns :
--
-- The quoted string with quotation marks stripped off
--
-- Exceptions :
--
-- Data_Error - Syntax error
-- Layout_Error - Pointer.all is not in Source'First..Source'Last + 1
--
function Get_Quoted
( Source : String;
Pointer : access Integer;
Mark : Character := '"'
) return String;
--
-- Put_Quoted -- Put a quoted string
--
-- Destination - The output string
-- Pointer - To where the name to put
-- Text - The text to be put
-- Mark - The quotation mark character
--
-- This procedure puts Text in Mark quotes and stores it starting with
-- String (Pointer). Pointer value is advanced to the the first
-- character following the output. Mark characters are GDoubled within
-- the string body.
--
-- Exceptions :
--
-- Layout_Error - No room for output or Pointer is not in
-- Source'First..Source'Last + 1
--
procedure Put_Quoted
( Destination : in out String;
Pointer : in out Integer;
Text : String;
Mark : Character := '"';
Field : Natural := 0;
Justify : Alignment := Left;
Fill : Character := ' '
);
--
-- Quote -- A string
--
-- Text - The string
-- Mark - The quotation mark character
--
-- Returns :
--
-- Quited text
--
function Quote (Text : String; Mark : Character := '"')
return String;
end Strings_Edit.Quoted;
|
-- @summary this package serves as config lookup in HIL.
-- actually this should not be here. Rather, HIL should
-- offer an API for that.
package HIL.Config is
-- PX4IO
PX4IO_BAUD_RATE_HZ : constant := 1_500_000;
-- UBLOX Baudrate: Default: 9_600, PX4-FMU configured: 38_400
UBLOX_BAUD_RATE_HZ : constant := 38_400;
type Buzzer_Out_T is (BUZZER_USE_PORT, BUZZER_USE_AUX5);
BUZZER_PORT : constant Buzzer_Out_T := BUZZER_USE_PORT; -- Pixlite: BUZZER_USE_AUX5. Pixhawk: BUZZER_USE_PORT
-- MPU6000
MPU6000_SAMPLE_RATE_HZ : constant := 100;
end HIL.Config;
|
package Real_Typedecl is
type FloatT is digits 10;
IndianaPi : FloatT := 3.2;
end Real_Typedecl;
|
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
with Ada.Text_Io; use Ada.Text_Io;
procedure Array_Selection is
type Array_Type is array (Positive range <>) of Integer;
Null_Array : Array_Type(1..0);
function Evens (Item : Array_Type) return Array_Type is
begin
if Item'Length > 0 then
if Item(Item'First) mod 2 = 0 then
return Item(Item'First) & Evens(Item((Item'First + 1)..Item'Last));
else
return Evens(Item((Item'First + 1)..Item'Last));
end if;
else
return Null_Array;
end if;
end Evens;
procedure Print(Item : Array_Type) is
begin
for I in Item'range loop
Put(Item(I));
New_Line;
end loop;
end Print;
Foo : Array_Type := (1,2,3,4,5,6,7,8,9,10);
begin
Print(Evens(Foo));
end Array_Selection;
|
with Ada.Text_IO; use Ada.Text_IO;
package body Yeison_Experiments is
------------
-- Append --
------------
procedure Append (L : in out List; I : Integer) is
begin
Put_Line ("Append Integer " & I'Image);
end Append;
------------
-- Append --
------------
procedure Append (L : in out List; S : String) is
begin
Put_Line ("Append String " & S);
end Append;
end Yeison_Experiments;
|
package addr2_p is
type Block is array (1 .. 9) of Integer;
procedure Process (Blk : Block);
B1 : constant Block := Block'((1,2,3,4,5, others => 0));
B2 : constant Block := (1,2,3,4,5, others => 0);
end;
|
-- Copyright 2015,2016,2017 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 Ada.Real_Time;
with Interfaces.C;
with System;
private with Linted.Channels;
with Linted.Errors;
with Linted.KOs;
with Linted.Triggers;
with Linted.Wait_Lists;
pragma Elaborate_All (Linted.Wait_Lists);
package Linted.IO_Pool with
Spark_Mode,
Initializes => (State => Wait_Lists.State),
Abstract_State => (State with External) is
pragma Elaborate_Body;
use type Interfaces.C.int;
type Writer_Event is record
Bytes_Written : Interfaces.C.size_t := 0;
Err : Errors.Error;
end record;
type Reader_Event is record
Bytes_Read : Interfaces.C.size_t := 0;
Err : Errors.Error;
end record;
type Poller_Event_Type is (Readable, Writable);
type Poller_Event_Set is array (Poller_Event_Type) of Boolean with
Pack;
type Poller_Event is record
Events : Poller_Event_Set :=
(Poller_Event_Type'First .. Poller_Event_Type'Last => False);
Err : Errors.Error;
end record;
type Remind_Me_Event is record
Dummy : Natural := 0;
end record;
type Read_Future is limited private with
Preelaborable_Initialization;
function Read_Future_Is_Live (Future : Read_Future) return Boolean with
Ghost,
Global => null,
Depends => (Read_Future_Is_Live'Result => Future);
procedure Read
(Object : KOs.KO;
Buf : System.Address;
Count : Interfaces.C.size_t;
Signaller : Triggers.Signaller;
Future : out Read_Future) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(State =>+ (Buf, Count, Object, Signaller, Wait_Lists.State),
Future => State,
Wait_Lists.State =>+ (Buf, Count, State, Object, Signaller)),
Post => Read_Future_Is_Live (Future);
procedure Read_Wait
(Future : in out Read_Future;
Event : out Reader_Event) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => null,
Event => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Read_Future_Is_Live (Future),
Post => not Read_Future_Is_Live (Future);
procedure Read_Poll
(Future : in out Read_Future;
Event : out Reader_Event;
Init : out Boolean) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future =>+ State,
Event => (State, Future),
Init => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Read_Future_Is_Live (Future),
Post =>
(if Init then not Read_Future_Is_Live (Future)
else Read_Future_Is_Live (Future));
type Write_Future is limited private with
Preelaborable_Initialization;
function Write_Future_Is_Live (Future : Write_Future) return Boolean with
Ghost,
Global => null,
Depends => (Write_Future_Is_Live'Result => Future);
procedure Write
(Object : KOs.KO;
Buf : System.Address;
Count : Interfaces.C.size_t;
Signaller : Triggers.Signaller;
Future : out Write_Future) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => State,
State =>+ (Buf, Count, Object, Signaller, Wait_Lists.State),
Wait_Lists.State =>+ (Buf, Count, State, Object, Signaller)),
Post => Write_Future_Is_Live (Future);
procedure Write_Wait
(Future : in out Write_Future;
Event : out Writer_Event) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => null,
Event => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Write_Future_Is_Live (Future),
Post => not Write_Future_Is_Live (Future);
procedure Write_Poll
(Future : in out Write_Future;
Event : out Writer_Event;
Init : out Boolean) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future =>+ State,
Event => (State, Future),
Init => (State, Future),
State =>+ (Future, State, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Write_Future_Is_Live (Future),
Post =>
(if Init then not Write_Future_Is_Live (Future)
else Write_Future_Is_Live (Future));
type Poll_Future is limited private with
Preelaborable_Initialization;
function Poll_Future_Is_Live (Future : Poll_Future) return Boolean with
Ghost,
Global => null,
Depends => (Poll_Future_Is_Live'Result => Future);
procedure Poll
(Object : KOs.KO;
Events : Poller_Event_Set;
Signaller : Triggers.Signaller;
Future : out Poll_Future) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => State,
State =>+ (Events, State, Object, Signaller, Wait_Lists.State),
Wait_Lists.State =>+ (Events, State, Object, Signaller)),
Post => Poll_Future_Is_Live (Future);
procedure Poll_Wait
(Future : in out Poll_Future;
Event : out Poller_Event) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => null,
Event => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Poll_Future_Is_Live (Future),
Post => not Poll_Future_Is_Live (Future);
procedure Poll_Poll
(Future : in out Poll_Future;
Event : out Poller_Event;
Init : out Boolean) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future =>+ State,
Event => (State, Future),
Init => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Poll_Future_Is_Live (Future),
Post =>
(if Init then not Poll_Future_Is_Live (Future)
else Poll_Future_Is_Live (Future));
type Remind_Me_Future is limited private with
Preelaborable_Initialization;
function Remind_Me_Future_Is_Live
(Future : Remind_Me_Future) return Boolean with
Ghost,
Global => null,
Depends => (Remind_Me_Future_Is_Live'Result => Future);
procedure Remind_Me
(Time : Ada.Real_Time.Time;
Signaller : Triggers.Signaller;
Future : out Remind_Me_Future) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => State,
State =>+ (Signaller, Time, Wait_Lists.State),
Wait_Lists.State =>+ (State, Signaller, Time)),
Post => Remind_Me_Future_Is_Live (Future);
procedure Remind_Me_Wait
(Future : in out Remind_Me_Future;
Event : out Remind_Me_Event) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future => null,
Event => (Future, State),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Remind_Me_Future_Is_Live (Future),
Post => not Remind_Me_Future_Is_Live (Future);
procedure Remind_Me_Poll
(Future : in out Remind_Me_Future;
Event : out Remind_Me_Event;
Init : out Boolean) with
Global => (In_Out => (State, Wait_Lists.State)),
Depends =>
(Future =>+ State,
Event => (Future, State),
Init => (State, Future),
State =>+ (Future, Wait_Lists.State),
Wait_Lists.State =>+ (Future, State)),
Pre => Remind_Me_Future_Is_Live (Future),
Post =>
(if Init then not Remind_Me_Future_Is_Live (Future)
else Remind_Me_Future_Is_Live (Future));
private
Max_Read_Futures : constant := 10;
Max_Write_Futures : constant := 10;
Max_Poll_Futures : constant := 10;
Max_Remind_Me_Futures : constant := 10;
Max_Command_Queue_Capacity : constant := 10;
type Read_Future is mod Max_Read_Futures + 1 with
Default_Value => 0;
type Write_Future is mod Max_Write_Futures + 1 with
Default_Value => 0;
type Poll_Future is mod Max_Poll_Futures + 1 with
Default_Value => 0;
type Remind_Me_Future is mod Max_Remind_Me_Futures + 1 with
Default_Value => 0;
package Writer_Event_Channels is new Channels (Writer_Event);
package Reader_Event_Channels is new Channels (Reader_Event);
package Poller_Event_Channels is new Channels (Poller_Event);
package Remind_Me_Event_Channels is new Channels (Remind_Me_Event);
end Linted.IO_Pool;
|
M:main
F:G$main$0_0$0({2}DF,SV:S),C,0,0,0,0,0
S:G$tiles$0_0$0({1}SC:U),E,0,0
S:G$bgmap$0_0$0({1}SC:U),E,0,0
S:G$NR52$0_0$0({1}SC:U),I,0,0
S:G$LCDC$0_0$0({1}SC:U),I,0,0
S:G$STAT$0_0$0({1}SC:U),I,0,0
S:G$SCY$0_0$0({1}SC:U),I,0,0
S:G$SCX$0_0$0({1}SC:U),I,0,0
S:G$LY$0_0$0({1}SC:U),I,0,0
S:G$LYC$0_0$0({1}SC:U),I,0,0
S:G$BGP$0_0$0({1}SC:U),I,0,0
S:G$memccpy$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$memcpy$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strdup$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strndup$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0_0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0_0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0_0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0_0$0({2}DF,SI:U),C,0,0
S:G$memchr$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0_0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0_0$0({2}DF,SI:U),C,0,0
S:G$strstr$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0_0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0_0$0({2}DF,SI:U),C,0,0
S:G$__memcpy$0_0$0({2}DF,DG,SV:S),C,0,0
S:G$main$0_0$0({2}DF,SV:S),C,0,0
|
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Incr.Version_Trees is
----------------------
-- Versioned_Values --
----------------------
package body Versioned_Values is
-------------
-- Discard --
-------------
procedure Discard
(Self : in out Container;
Time : Version;
Changes : out Integer) is
begin
if Time = Self.Versions (Self.Index) then
Self.Index := Self.Index - 1;
Changes := -1;
elsif Time < Self.Versions (Self.Index) then
-- Reverting of earlyer version is not allowed
raise Constraint_Error;
else
Changes := 0;
end if;
end Discard;
---------
-- Get --
---------
function Get (Self : Container; Time : Version) return Element is
begin
for J in Self.Versions'Range loop
if Time >= Self.Versions (Self.Index - J) then
return Self.Elements (Self.Index - J);
end if;
end loop;
raise Constraint_Error with "version is too old";
end Get;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Container;
Initial_Value : Element)
is
begin
Self.Versions := (others => 0);
Self.Elements := (others => Initial_Value);
Self.Index := 0;
end Initialize;
---------
-- Set --
---------
procedure Set
(Self : in out Container;
Value : Element;
Time : Version;
Changes : in out Integer)
is
Prev : constant Version := Time - 1; -- Tree.Parent (Time)
Old : constant Element := Get (Self, Prev);
Is_Old : constant Boolean := Value = Old;
begin
if Time = Self.Versions (Self.Index) and Is_Old then
Self.Index := Self.Index - 1;
Changes := Changes - 1;
elsif Time > Self.Versions (Self.Index) and not Is_Old then
Self.Index := Self.Index + 1;
Self.Versions (Self.Index) := Time;
Changes := Changes + 1;
elsif Time < Self.Versions (Self.Index) then
-- Update of earlyer version is not allowed
raise Constraint_Error;
end if;
if not Is_Old then
Self.Elements (Self.Index) := Value;
end if;
end Set;
end Versioned_Values;
function "<" (Left, Right : Version) return Boolean is
L : constant Natural := Natural (Left);
R : constant Natural := Natural (Right);
begin
if L < 128 xor R < 128 then
return Natural (L + 8) < Natural (R + 8);
else
return L < R;
end if;
end "<";
--------------
-- Changing --
--------------
function Changing (Self : Version_Tree) return Version is
begin
return Self.Changing;
end Changing;
-----------------
-- Is_Changing --
-----------------
function Is_Changing
(Self : Version_Tree; Value : Version) return Boolean is
begin
return Self.Changing = Value;
end Is_Changing;
------------
-- Parent --
------------
function Parent (Self : Version_Tree; Value : Version) return Version is
pragma Unreferenced (Self);
begin
return Value - 1;
end Parent;
------------------
-- Start_Change --
------------------
procedure Start_Change
(Self : in out Version_Tree;
Parent : Version;
Changing : out Version)
is
begin
if Parent /= Self.Changing then
raise Constraint_Error with "not implemented";
end if;
Self.Changing := Self.Changing + 1;
Changing := Self.Changing;
end Start_Change;
end Incr.Version_Trees;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . O S _ I N T E R F A C E --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 1997-2001 Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package includes all direct interfaces to OS services
-- that are needed by children of System.
-- PLEASE DO NOT add any with-clauses to this package
-- or remove the pragma Elaborate_Body.
-- It is designed to be a bottom-level (leaf) package.
with Interfaces.C;
package System.OS_Interface is
pragma Preelaborate;
pragma Linker_Options ("-lposix");
pragma Linker_Options ("-lpthread");
subtype int is Interfaces.C.int;
subtype short is Interfaces.C.short;
subtype long is Interfaces.C.long;
subtype unsigned is Interfaces.C.unsigned;
subtype unsigned_short is Interfaces.C.unsigned_short;
subtype unsigned_long is Interfaces.C.unsigned_long;
subtype unsigned_char is Interfaces.C.unsigned_char;
subtype plain_char is Interfaces.C.plain_char;
subtype size_t is Interfaces.C.size_t;
type int32_t is range -2**31 .. (2**31)-1;
for int32_t'Size use 32;
-----------
-- Errno --
-----------
function Errno return int;
pragma Import (C, Errno, "__get_errno");
EPERM : constant := 1; -- Operation not permitted
ENOENT : constant := 2; -- No such file or directory
ESRCH : constant := 3; -- No such process
EINTR : constant := 4; -- Interrupted system call
EIO : constant := 5; -- Input/output error
ENXIO : constant := 6; -- Device not configured
E2BIG : constant := 7; -- Argument list too long
ENOEXEC : constant := 8; -- Exec format error
EBADF : constant := 9; -- Bad file descriptor
ECHILD : constant := 10; -- No child processes
EDEADLK : constant := 11; -- Resource deadlock avoided
ENOMEM : constant := 12; -- Cannot allocate memory
EACCES : constant := 13; -- Permission denied
EFAULT : constant := 14; -- Bad address
ENOTBLK : constant := 15; -- Block device required
EBUSY : constant := 16; -- Device busy
EEXIST : constant := 17; -- File exists
EXDEV : constant := 18; -- Cross-device link
ENODEV : constant := 19;
ENOTDIR : constant := 20; -- Not a directory
EISDIR : constant := 21; -- Is a directory
EINVAL : constant := 22; -- Invalid argument
ENFILE : constant := 23;
EMFILE : constant := 24; -- Too many open files
ENOTTY : constant := 25;
ETXTBSY : constant := 26; -- Text file busy
EFBIG : constant := 27; -- File too large
ENOSPC : constant := 28; -- No space left on device
ESPIPE : constant := 29; -- Illegal seek
EROFS : constant := 30; -- Read-only file system
EMLINK : constant := 31; -- Too many links
EPIPE : constant := 32; -- Broken pipe
EDOM : constant := 33;
ERANGE : constant := 34;
EAGAIN : constant := 35;
EWOULDBLOCK : constant := EAGAIN; -- Operation would block
EINPROGRESS : constant := 36; -- Operation now in progress
EALREADY : constant := 37;
ENOTSOCK : constant := 38;
EDESTADDRREQ : constant := 39;
EMSGSIZE : constant := 40; -- Message too long
EPROTOTYPE : constant := 41;
ENOPROTOOPT : constant := 42; -- Protocol not available
EPROTONOSUPPORT : constant := 43; -- Protocol not supported
ESOCKTNOSUPPORT : constant := 44; -- Socket type not supported
EOPNOTSUPP : constant := 45; -- Operation not supported
EPFNOSUPPORT : constant := 46;
EAFNOSUPPORT : constant := 47;
EADDRINUSE : constant := 48; -- Address already in use
EADDRNOTAVAIL : constant := 49;
ENETDOWN : constant := 50; -- Network is down
ENETUNREACH : constant := 51; -- Network is unreachable
ENETRESET : constant := 52;
ECONNABORTED : constant := 53;
ECONNRESET : constant := 54; -- Connection reset by peer
ENOBUFS : constant := 55; -- No buffer space available
EISCONN : constant := 56;
ENOTCONN : constant := 57; -- Socket is not connected
ESHUTDOWN : constant := 58;
ETOOMANYREFS : constant := 59;
ETIMEDOUT : constant := 60; -- Operation timed out
ECONNREFUSED : constant := 61; -- Connection refused
ELOOP : constant := 62;
ENAMETOOLONG : constant := 63; -- File name too long
EHOSTDOWN : constant := 64; -- Host is down
EHOSTUNREACH : constant := 65; -- No route to host
ENOTEMPTY : constant := 66; -- Directory not empty
EPROCLIM : constant := 67; -- Too many processes
EUSERS : constant := 68; -- Too many users
EDQUOT : constant := 69; -- Disc quota exceeded
ESTALE : constant := 70; -- Stale NFS file handle
EREMOTE : constant := 71;
EBADRPC : constant := 72; -- RPC struct is bad
ERPCMISMATCH : constant := 73; -- RPC version wrong
EPROGUNAVAIL : constant := 74; -- RPC prog. not avail
EPROGMISMATCH : constant := 75; -- Program version wrong
EPROCUNAVAIL : constant := 76; -- Bad procedure for program
ENOLCK : constant := 77; -- No locks available
ENOSYS : constant := 78; -- Function not implemented
EFTYPE : constant := 79;
EAUTH : constant := 80; -- Authentication error
ENEEDAUTH : constant := 81; -- Need authenticator
EIDRM : constant := 82; -- Identifier removed
ENOMSG : constant := 83; -- No message of desired type
EOVERFLOW : constant := 84;
EILSEQ : constant := 85; -- Illegal byte sequence
ENOTSUP : constant := 86; -- Not supported
ECANCELED : constant := 87; -- Operation canceled
EBADMSG : constant := 88; -- Bad or Corrupt message
ENODATA : constant := 89; -- No message available
ENOSR : constant := 90; -- No STREAM resources
ENOSTR : constant := 91; -- Not a STREAM
ETIME : constant := 92; -- STREAM ioctl timeout
ELAST : constant := 92; -- Must equal largest errno
-------------
-- Signals --
-------------
Max_Interrupt : constant := 64;
type Signal is new int range 0 .. Max_Interrupt;
for Signal'Size use int'Size;
sighup : constant := 1; -- hangup
sigint : constant := 2; -- interrupt
sigquit : constant := 3; -- quit
sigill : constant := 4; -- illegal instruction (not reset when caught)
sigtrap : constant := 5; -- trace trap (not reset when caught)
SIGABRT : constant := 6; -- abort()
sigiot : constant := SIGABRT; -- compatibility
sigemt : constant := 7; -- EMT instruction
sigfpe : constant := 8; -- floating point exception
sigkill : constant := 9; -- kill (cannot be caught or ignored)
sigbus : constant := 10; -- bus error
sigsegv : constant := 11; -- segmentation violation
sigsys : constant := 12; -- bad argument to system call
sigpipe : constant := 13; -- write on a pipe with no one to read it
sigalrm : constant := 14; -- alarm clock
sigterm : constant := 15; -- software termination signal from kill
sigurg : constant := 16; -- urgent condition on IO channel
sigstop : constant := 17; -- sendable stop signal not from tty
sigtstp : constant := 18; -- stop signal from tty
sigcont : constant := 19; -- continue a stopped process
sigchld : constant := 20; -- to parent on child stop or exit
sigttin : constant := 21; -- to readers pgrp upon background tty read
sigttou : constant := 22; -- like TTIN for output if (tp->t_local<OSTOP)
sigio : constant := 23; -- input/output possible signal
sigxcpu : constant := 24; -- exceeded CPU time limit
sigxfsz : constant := 25; -- exceeded file size limit
sigvtalrm : constant := 26; -- virtual time alarm
sigprof : constant := 27; -- profiling time alarm
sigwinch : constant := 28; -- window size changes
siginfo : constant := 29; -- information request
sigusr1 : constant := 30; -- user defined signal 1
sigusr2 : constant := 31; -- user defined signal 2
sigpwr : constant := 32; -- power fail/restart (not reset when caught)
sigwaiting : constant := 0; -- process's lwps blocked (Solaris)
sigcancel : constant := 0; -- thread cancellation signal (libthread)
SIGADAABORT : constant := SIGABRT;
type signal_set is array (Natural range <>) of Signal;
Unmasked : constant signal_set := (sigkill, sigill, sigprof, sigtrap,
sigpwr);
-- Following signals should not be disturbed.
-- See c-posix-signals.c in FLORIST
Reserved : constant signal_set := (sigalrm, sigbus, sigill, sigsegv,
sigfpe, SIGABRT, sigkill, sigstop);
-- PTHREAD_SIGMASK(3)
SIG_BLOCK : constant := 1;
SIG_SETMASK : constant := 3;
SIG_UNBLOCK : constant := 2;
type sigset_t is private;
type sigset_t_ptr is access all sigset_t;
-- Binding to macros defined in <signal.h>
function sigaddset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigaddset, "adasigaddset");
function sigdelset (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigdelset, "adasigdelset");
function sigfillset (set : access sigset_t) return int;
pragma Import (C, sigfillset, "adasigfillset");
function sigismember (set : access sigset_t; sig : Signal) return int;
pragma Import (C, sigismember, "adasigismember");
function sigemptyset (set : access sigset_t) return int;
pragma Import (C, sigemptyset, "adasigemptyset");
type struct_sigaction is record
sa_handler : System.Address;
sa_mask : sigset_t;
sa_flags : int;
end record;
pragma Convention (C, struct_sigaction);
type struct_sigaction_ptr is access all struct_sigaction;
SIG_DFL : constant := 0;
SIG_IGN : constant := 1;
function sigaction
(sig : Signal;
act : struct_sigaction_ptr;
oact : struct_sigaction_ptr := null) return int;
pragma Import (C, sigaction, "adasigaction");
----------
-- Time --
----------
type clockid_t is new int;
CLOCK_REALTIME : constant := 0;
type timespec is private;
function To_Duration (
TS : timespec)
return Duration;
pragma Inline (To_Duration);
function To_Timespec (
D : Duration)
return timespec;
pragma Inline (To_Timespec);
type Struct_Timeval is private;
function To_Duration (
TV : Struct_Timeval)
return Duration;
pragma Inline (To_Duration);
function To_Timeval (
D : Duration)
return Struct_Timeval;
pragma Inline (To_Timeval);
function Gettimeofday (
Tv : access Struct_Timeval;
Tz : System.Address := System.Null_Address)
return int;
pragma Import (C, Gettimeofday, "gettimeofday");
function clock_gettime
(clock_id : clockid_t;
tp : access timespec) return int;
pragma Import (C, clock_gettime, "clock_gettime");
---------
-- LWP --
---------
-- From <sys/types.h>
type lwpid_t is new int32_t;
function lwp_self return System.Address;
pragma Import (C, lwp_self, "ada_lwp_self");
-------------------------
-- Priority Scheduling --
-------------------------
SCHED_FIFO : constant := 1;
SCHED_RR : constant := 2;
SCHED_TS : constant := 3;
SCHED_OTHER : constant := 3;
SCHED_NP : constant := 4;
function sched_get_priority_min (Policy : int) return int;
pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
function sched_get_priority_max (Policy : int) return int;
pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
-------------
-- Process --
-------------
type pid_t is private;
function kill (pid : pid_t; sig : Signal) return int;
pragma Import (C, kill, "kill");
function getpid return pid_t;
pragma Import (C, getpid, "getpid");
-------------
-- Threads --
-------------
type Thread_Body is access
function (arg : System.Address) return System.Address;
type pthread_t is private;
subtype Thread_Id is pthread_t;
type pthread_mutex_t is limited private;
type pthread_cond_t is limited private;
type pthread_attr_t is limited private;
type pthread_mutexattr_t is limited private;
type pthread_condattr_t is limited private;
type pthread_key_t is private;
subtype cond_t is pthread_cond_t;
PTHREAD_CREATE_DETACHED : constant := 1;
---------------------------------------
-- Nonstandard Thread Initialization --
---------------------------------------
procedure pthread_init;
pragma Inline (pthread_init);
-- This is a dummy procedure to share some GNULLI files
-------------------------
-- POSIX.1c Section 3 --
-------------------------
function sigwait
(set : access sigset_t;
sig : access Signal) return int;
pragma Import (C, sigwait, "adasigwait");
function pthread_kill
(thread : pthread_t;
sig : Signal) return int;
pragma Import (C, pthread_kill, "pthread_kill");
function pthread_sigmask
(how : int;
set : sigset_t_ptr;
oset : sigset_t_ptr) return int;
pragma Import (C, pthread_sigmask, "pthread_sigmask");
--------------------------
-- POSIX.1c Section 11 --
--------------------------
function pthread_mutexattr_init
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
function pthread_mutexattr_destroy
(attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
function pthread_mutex_init
(mutex : access pthread_mutex_t;
attr : access pthread_mutexattr_t) return int;
pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
function pthread_condattr_init
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
function pthread_condattr_destroy
(attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
function pthread_cond_init
(cond : access pthread_cond_t;
attr : access pthread_condattr_t) return int;
pragma Import (C, pthread_cond_init, "pthread_cond_init");
function pthread_cond_destroy (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
function pthread_cond_signal (cond : access pthread_cond_t) return int;
pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
function pthread_cond_wait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t) return int;
pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
function pthread_cond_timedwait
(cond : access pthread_cond_t;
mutex : access pthread_mutex_t;
abstime : access timespec) return int;
pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
--------------------------
-- POSIX.1c Section 13 --
--------------------------
PTHREAD_PRIO_NONE : constant := 0;
PTHREAD_PRIO_PROTECT : constant := 2;
PTHREAD_PRIO_INHERIT : constant := 1;
function pthread_mutexattr_setprotocol
(attr : access pthread_mutexattr_t;
protocol : int) return int;
pragma Import
(C, pthread_mutexattr_setprotocol, "pthread_mutexattr_setprotocol");
function pthread_mutexattr_setprioceiling
(attr : access pthread_mutexattr_t;
prioceiling : int) return int;
pragma Import
(C, pthread_mutexattr_setprioceiling, "pthread_mutexattr_setprioceiling");
type struct_sched_param is record
sched_priority : int;
end record;
for struct_sched_param use record
sched_priority at 0 range 0 .. 31;
end record;
pragma Convention (C, struct_sched_param);
function pthread_setschedparam
(thread : pthread_t;
policy : int;
param : access struct_sched_param)
return int;
pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
function pthread_attr_setscope
(attr : access pthread_attr_t;
contentionscope : int) return int;
pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
function pthread_attr_setinheritsched
(attr : access pthread_attr_t;
inheritsched : int) return int;
pragma Import
(C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
function pthread_attr_setschedpolicy
(attr : access pthread_attr_t;
policy : int) return int;
pragma Import (C, pthread_attr_setschedpolicy);
function pthread_attr_setschedparam
(attr : access pthread_attr_t;
sched_param : access struct_sched_param)
return int;
pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
function sched_yield return int;
pragma Import (C, sched_yield, "sched_yield");
---------------------------
-- P1003.1c - Section 16 --
---------------------------
function pthread_attr_init (attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_init, "pthread_attr_init");
function pthread_attr_destroy
(attributes : access pthread_attr_t) return int;
pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
function pthread_attr_setdetachstate
(attr : access pthread_attr_t;
detachstate : int) return int;
pragma Import (C, pthread_attr_setdetachstate);
function pthread_attr_setstacksize
(attr : access pthread_attr_t;
stacksize : size_t) return int;
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
function pthread_create
(thread : access pthread_t;
attributes : access pthread_attr_t;
start_routine : Thread_Body;
arg : System.Address) return int;
pragma Import (C, pthread_create, "pthread_create");
procedure pthread_exit (status : System.Address);
pragma Import (C, pthread_exit, "pthread_exit");
function pthread_self return pthread_t;
pragma Import (C, pthread_self, "pthread_self");
--------------------------
-- POSIX.1c Section 17 --
--------------------------
function pthread_setspecific
(key : pthread_key_t;
value : System.Address) return int;
pragma Import (C, pthread_setspecific, "pthread_setspecific");
function pthread_getspecific (key : pthread_key_t) return System.Address;
pragma Import (C, pthread_getspecific, "pthread_getspecific");
type destructor_pointer is access procedure (arg : System.Address);
function pthread_key_create
(key : access pthread_key_t;
destructor : destructor_pointer) return int;
pragma Import (C, pthread_key_create, "pthread_key_create");
---------------------------------------------------------------
-- Non portable SGI 6.5 additions to the pthread interface --
-- must be executed from within the context of a system --
-- scope task --
---------------------------------------------------------------
function pthread_setrunon_np (cpu : int) return int;
pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
private
type array_type_1 is array (Integer range 0 .. 3) of unsigned;
type sigset_t is record
X_X_sigbits : array_type_1;
end record;
pragma Convention (C, sigset_t);
-- From <sys/ansi.h>
type pid_t is new int32_t;
type time_t is new int32_t;
type timespec is record
tv_sec : time_t;
tv_nsec : long;
end record;
for timespec use record
tv_sec at 0 range 0 .. 63;
tv_nsec at 8 range 0 .. 63;
end record;
pragma Warnings (Off);
-- There may be holes in the record, due to
-- components not defined by POSIX standard.
for timespec'Size use 128;
pragma Convention (C, timespec);
type suseconds_t is range -2**63 .. (2**63)-1;
for suseconds_t'Size use 64;
type struct_timeval is record
tv_sec : time_t;
tv_usec : suseconds_t;
end record;
for struct_timeval use record
tv_sec at 0 range 0 .. 63;
tv_usec at 8 range 0 .. 63;
end record;
pragma Convention (C, struct_timeval);
pragma Warnings (Off);
-- There may be holes in the record, due to
-- components not defined by POSIX standard.
for struct_timeval'Size use 128;
pragma Warnings (On);
type array_type_9 is array (Integer range 0 .. 4) of long;
type pthread_attr_t is record
X_X_D : array_type_9;
end record;
pragma Convention (C, pthread_attr_t);
type array_type_8 is array (Integer range 0 .. 1) of long;
type pthread_condattr_t is record
X_X_D : array_type_8;
end record;
pragma Convention (C, pthread_condattr_t);
type array_type_7 is array (Integer range 0 .. 1) of long;
type pthread_mutexattr_t is record
X_X_D : array_type_7;
end record;
pragma Convention (C, pthread_mutexattr_t);
type pthread_t is new System.Address;
type array_type_10 is array (Integer range 0 .. 7) of long;
type pthread_mutex_t is record
X_X_D : array_type_10;
end record;
pragma Convention (C, pthread_mutex_t);
type array_type_11 is array (Integer range 0 .. 7) of long;
type pthread_cond_t is record
X_X_D : array_type_11;
end record;
pragma Convention (C, pthread_cond_t);
type pthread_key_t is new int;
end System.OS_Interface;
|
--
-- Copyright (C) 2018, AdaCore
--
-- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * 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 Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from this
-- software without specific prior written permission.
--
-- 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.
--
-- This spec has been automatically generated from nrf51.svd
-- This is a version for the nRF51 reference description for radio MCU with
-- ARM 32-bit Cortex-M0 Microcontroller at 16MHz CPU clock MCU
package Ada.Interrupts.Names is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
----------------
-- Interrupts --
----------------
-- System tick
Sys_Tick : constant Interrupt_ID := -1;
POWER_CLOCK : constant Interrupt_ID := 0;
RADIO : constant Interrupt_ID := 1;
UART0 : constant Interrupt_ID := 2;
SPI0_TWI0 : constant Interrupt_ID := 3;
SPI1_TWI1 : constant Interrupt_ID := 4;
GPIOTE : constant Interrupt_ID := 6;
ADC : constant Interrupt_ID := 7;
TIMER0 : constant Interrupt_ID := 8;
TIMER1 : constant Interrupt_ID := 9;
TIMER2 : constant Interrupt_ID := 10;
RTC0 : constant Interrupt_ID := 11;
TEMP : constant Interrupt_ID := 12;
RNG : constant Interrupt_ID := 13;
ECB : constant Interrupt_ID := 14;
CCM_AAR : constant Interrupt_ID := 15;
WDT : constant Interrupt_ID := 16;
RTC1 : constant Interrupt_ID := 17;
QDEC : constant Interrupt_ID := 18;
LPCOMP : constant Interrupt_ID := 19;
SWI0 : constant Interrupt_ID := 20;
SWI1 : constant Interrupt_ID := 21;
SWI2 : constant Interrupt_ID := 22;
SWI3 : constant Interrupt_ID := 23;
SWI4 : constant Interrupt_ID := 24;
SWI5 : constant Interrupt_ID := 25;
end Ada.Interrupts.Names;
|
-- Copyright 2017-2021 Bartek thindil Jasicki
--
-- This file is part of Steam Sky.
--
-- Steam Sky is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- Steam Sky is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Steam Sky. If not, see <http://www.gnu.org/licenses/>.
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with DOM.Core.Documents; use DOM.Core.Documents;
with DOM.Core.Nodes; use DOM.Core.Nodes;
with DOM.Core.Elements; use DOM.Core.Elements;
with Maps; use Maps;
package body Bases.SaveLoad is
procedure SaveBases
(SaveData: not null Document; MainNode: not null DOM.Core.Element) is
RawValue: Unbounded_String;
BaseNode, SubNode: DOM.Core.Element;
procedure SaveNumber
(Value: Integer; Name: String; Node: DOM.Core.Element := SubNode) is
RawValue: constant String :=
Trim(Integer'Image(Value), Ada.Strings.Left);
begin
Set_Attribute(Node, Name, RawValue);
end SaveNumber;
begin
Save_Bases_Loop :
for SkyBase of Sky_Bases loop
BaseNode := Create_Element(SaveData, "base");
BaseNode := Append_Child(MainNode, BaseNode);
Set_Attribute(BaseNode, "name", To_String(SkyBase.Name));
if SkyBase.Visited.Year = 0 then
goto Save_Location;
end if;
SubNode := Create_Element(SaveData, "visiteddate");
SubNode := Append_Child(BaseNode, SubNode);
SaveNumber(SkyBase.Visited.Year, "year");
SaveNumber(SkyBase.Visited.Month, "month");
SaveNumber(SkyBase.Visited.Day, "day");
SaveNumber(SkyBase.Visited.Hour, "hour");
SaveNumber(SkyBase.Visited.Minutes, "minutes");
<<Save_Location>>
SaveNumber(SkyBase.Sky_X, "x", BaseNode);
SaveNumber(SkyBase.Sky_Y, "y", BaseNode);
Set_Attribute(BaseNode, "type", To_String(SkyBase.Base_Type));
SaveNumber(SkyBase.Population, "population", BaseNode);
if SkyBase.Visited.Year = 0 then
goto Save_Reputation;
end if;
SubNode := Create_Element(SaveData, "recruitdate");
SubNode := Append_Child(BaseNode, SubNode);
SaveNumber(SkyBase.Recruit_Date.Year, "year");
SaveNumber(SkyBase.Recruit_Date.Month, "month");
SaveNumber(SkyBase.Recruit_Date.Day, "day");
if SkyBase.Recruits.Is_Empty then
goto Save_AskForBases;
end if;
declare
RecruitNode, RecruitDataNode: DOM.Core.Element;
begin
Save_Recruits_Loop :
for Recruit of SkyBase.Recruits loop
RecruitNode := Create_Element(SaveData, "recruit");
RecruitNode := Append_Child(BaseNode, RecruitNode);
Set_Attribute(RecruitNode, "name", To_String(Recruit.Name));
Set_Attribute(RecruitNode, "gender", Recruit.Gender & "");
RawValue := To_Unbounded_String(Integer'Image(Recruit.Price));
Set_Attribute
(RecruitNode, "price",
To_String(Trim(RawValue, Ada.Strings.Left)));
Save_Skills_Loop :
for Skill of Recruit.Skills loop
RecruitDataNode := Create_Element(SaveData, "skill");
RecruitDataNode :=
Append_Child(RecruitNode, RecruitDataNode);
SaveNumber(Skill.Index, "index", RecruitDataNode);
SaveNumber(Skill.Level, "level", RecruitDataNode);
end loop Save_Skills_Loop;
Save_Attributes_Loop :
for Attribute of Recruit.Attributes loop
RecruitDataNode := Create_Element(SaveData, "attribute");
RecruitDataNode :=
Append_Child(RecruitNode, RecruitDataNode);
SaveNumber(Attribute.Level, "level", RecruitDataNode);
end loop Save_Attributes_Loop;
Save_Inventory_Loop :
for Item of Recruit.Inventory loop
RecruitDataNode := Create_Element(SaveData, "item");
RecruitDataNode :=
Append_Child(RecruitNode, RecruitDataNode);
Set_Attribute(RecruitDataNode, "index", To_String(Item));
end loop Save_Inventory_Loop;
Save_Equipment_Loop :
for J in Recruit.Equipment'Range loop
if Recruit.Equipment(J) > 0 then
RecruitDataNode := Create_Element(SaveData, "equipment");
RecruitDataNode :=
Append_Child(RecruitNode, RecruitDataNode);
SaveNumber(J, "slot", RecruitDataNode);
SaveNumber
(Recruit.Equipment(J), "index", RecruitDataNode);
end if;
end loop Save_Equipment_Loop;
SaveNumber(Recruit.Payment, "payment", RecruitNode);
SaveNumber(Recruit.Home_Base, "homebase", RecruitNode);
Set_Attribute
(RecruitNode, "faction", To_String(Recruit.Faction));
end loop Save_Recruits_Loop;
end;
<<Save_AskForBases>>
if SkyBase.Asked_For_Bases then
Set_Attribute(BaseNode, "askedforbases", "Y");
else
Set_Attribute(BaseNode, "askedforbases", "N");
end if;
SubNode := Create_Element(SaveData, "askedforeventsdate");
SubNode := Append_Child(BaseNode, SubNode);
SaveNumber(SkyBase.Asked_For_Events.Year, "year");
SaveNumber(SkyBase.Asked_For_Events.Month, "month");
SaveNumber(SkyBase.Asked_For_Events.Day, "day");
<<Save_Reputation>>
if SkyBase.Reputation(1) /= 0 then
SubNode := Create_Element(SaveData, "reputation");
SubNode := Append_Child(BaseNode, SubNode);
SaveNumber(SkyBase.Reputation(1), "level");
if SkyBase.Reputation(2) > 0 then
SaveNumber(SkyBase.Reputation(2), "progress");
end if;
end if;
if SkyBase.Visited.Year = 0 then
goto Save_Cargo;
end if;
SubNode := Create_Element(SaveData, "missionsdate");
SubNode := Append_Child(BaseNode, SubNode);
SaveNumber(SkyBase.Missions_Date.Year, "year");
SaveNumber(SkyBase.Missions_Date.Month, "month");
SaveNumber(SkyBase.Missions_Date.Day, "day");
declare
MissionNode: DOM.Core.Element;
begin
Save_Missions_Loop :
for Mission of SkyBase.Missions loop
MissionNode := Create_Element(SaveData, "mission");
MissionNode := Append_Child(BaseNode, MissionNode);
SaveNumber
(Missions_Types'Pos(Mission.MType), "type", MissionNode);
RawValue :=
(case Mission.MType is when Deliver => Mission.ItemIndex,
when Passenger =>
To_Unbounded_String(Integer'Image(Mission.Data)),
when Destroy => Mission.ShipIndex,
when others =>
To_Unbounded_String(Integer'Image(Mission.Target)));
Set_Attribute
(MissionNode, "target",
To_String(Trim(RawValue, Ada.Strings.Left)));
SaveNumber(Mission.Time, "time", MissionNode);
SaveNumber(Mission.TargetX, "targetx", MissionNode);
SaveNumber(Mission.TargetY, "targety", MissionNode);
SaveNumber(Mission.Reward, "reward", MissionNode);
end loop Save_Missions_Loop;
end;
<<Save_Cargo>>
if SkyBase.Cargo.Is_Empty then
goto Save_Known;
end if;
declare
ItemNode: DOM.Core.Element;
begin
Save_Cargo_Loop :
for Item of SkyBase.Cargo loop
ItemNode := Create_Element(SaveData, "item");
ItemNode := Append_Child(BaseNode, ItemNode);
Set_Attribute(ItemNode, "index", To_String(Item.Proto_Index));
SaveNumber(Item.Amount, "amount", ItemNode);
SaveNumber(Item.Durability, "durability", ItemNode);
SaveNumber(Item.Price, "price", ItemNode);
end loop Save_Cargo_Loop;
end;
<<Save_Known>>
if SkyBase.Known then
Set_Attribute(BaseNode, "known", "Y");
else
Set_Attribute(BaseNode, "known", "N");
end if;
Set_Attribute(BaseNode, "owner", To_String(SkyBase.Owner));
Set_Attribute(BaseNode, "size", Bases_Size'Image(SkyBase.Size));
end loop Save_Bases_Loop;
end SaveBases;
procedure LoadBases(SaveData: not null Document) is
BaseRecruits: Recruit_Container.Vector;
BaseMissions: Mission_Container.Vector;
BaseCargo: BaseCargo_Container.Vector;
NodesList, BaseData: Node_List;
BaseIndex: Bases_Range;
NodeName: Unbounded_String;
BaseNode, ChildNode: Node;
begin
NodesList :=
DOM.Core.Documents.Get_Elements_By_Tag_Name(SaveData, "base");
Load_Bases_Loop :
for I in 0 .. Length(NodesList) - 1 loop
BaseIndex := I + 1;
BaseNode := Item(NodesList, I);
Sky_Bases(BaseIndex) :=
(Name => To_Unbounded_String(Get_Attribute(BaseNode, "name")),
Visited => (others => 0),
Sky_X => Integer'Value(Get_Attribute(BaseNode, "x")),
Sky_Y => Integer'Value(Get_Attribute(BaseNode, "y")),
Base_Type => To_Unbounded_String(Get_Attribute(BaseNode, "type")),
Population => Integer'Value(Get_Attribute(BaseNode, "population")),
Recruit_Date => (others => 0), Recruits => BaseRecruits,
Known => False, Asked_For_Bases => False,
Asked_For_Events => (others => 0), Reputation => (0, 0),
Missions_Date => (others => 0), Missions => BaseMissions,
Owner => Factions_Container.Key(Factions_List.First),
Cargo => BaseCargo,
Size => Bases_Size'Value(Get_Attribute(BaseNode, "size")));
Sky_Bases(BaseIndex).Owner :=
To_Unbounded_String(Get_Attribute(BaseNode, "owner"));
if Get_Attribute(BaseNode, "known") = "Y" then
Sky_Bases(BaseIndex).Known := True;
end if;
if Get_Attribute(BaseNode, "askedforbases") = "Y" then
Sky_Bases(BaseIndex).Asked_For_Bases := True;
end if;
BaseData := Child_Nodes(BaseNode);
Load_Base_Loop :
for J in 0 .. Length(BaseData) - 1 loop
ChildNode := Item(BaseData, J);
NodeName := To_Unbounded_String(Node_Name(ChildNode));
if NodeName = To_Unbounded_String("visiteddate") then
Sky_Bases(BaseIndex).Visited :=
(Year => Natural'Value(Get_Attribute(ChildNode, "year")),
Month => Natural'Value(Get_Attribute(ChildNode, "month")),
Day => Natural'Value(Get_Attribute(ChildNode, "day")),
Hour => Natural'Value(Get_Attribute(ChildNode, "hour")),
Minutes =>
Natural'Value(Get_Attribute(ChildNode, "minutes")));
elsif NodeName = To_Unbounded_String("recruitdate") then
Sky_Bases(BaseIndex).Recruit_Date :=
(Year => Natural'Value(Get_Attribute(ChildNode, "year")),
Month => Natural'Value(Get_Attribute(ChildNode, "month")),
Day => Natural'Value(Get_Attribute(ChildNode, "day")),
Hour => 0, Minutes => 0);
elsif NodeName = To_Unbounded_String("recruit") then
declare
RecruitData: Node_List;
RecruitName, RecruitFaction: Unbounded_String;
Gender: String(1 .. 1);
HomeBase: Bases_Range;
Price, Payment: Positive;
Skills: Skills_Container.Vector;
Index: SkillsData_Container.Extended_Index;
Inventory: UnboundedString_Container.Vector;
Equipment: Equipment_Array;
RecruitNode: Node;
Level: Skill_Range;
Attributes: Mob_Attributes
(1 ..
Positive
(AttributesData_Container.Length
(Container => Attributes_List)));
Attribute_Index: Positive := 1;
begin
Skills.Clear;
Attributes := (others => <>);
Inventory.Clear;
Equipment := (others => 0);
RecruitName :=
To_Unbounded_String(Get_Attribute(ChildNode, "name"));
Gender := Get_Attribute(ChildNode, "gender");
Price := Positive'Value(Get_Attribute(ChildNode, "price"));
Payment := 20;
RecruitData := Child_Nodes(ChildNode);
Load_Recruits_Loop :
for L in 0 .. Length(RecruitData) - 1 loop
RecruitNode := Item(RecruitData, L);
NodeName := To_Unbounded_String(Node_Name(RecruitNode));
if NodeName = To_Unbounded_String("skill") then
Index :=
SkillsData_Container.Extended_Index'Value
(Get_Attribute(RecruitNode, "index"));
Level :=
Skill_Range'Value
(Get_Attribute(RecruitNode, "level"));
Skills.Append(New_Item => (Index, Level, 0));
elsif NodeName = To_Unbounded_String("attribute") then
Level :=
Natural'Value(Get_Attribute(RecruitNode, "level"));
Attributes(Attribute_Index) := (Level, 0);
Attribute_Index := Attribute_Index + 1;
elsif NodeName = To_Unbounded_String("item") then
Inventory.Append
(New_Item =>
To_Unbounded_String
(Get_Attribute(RecruitNode, "index")));
elsif NodeName = To_Unbounded_String("equipment") then
Equipment
(Positive'Value
(Get_Attribute(RecruitNode, "slot"))) :=
Natural'Value(Get_Attribute(RecruitNode, "index"));
end if;
if Get_Attribute(ChildNode, "payment") /= "" then
Payment :=
Natural'Value(Get_Attribute(ChildNode, "payment"));
end if;
if Get_Attribute(ChildNode, "homebase") /= "" then
HomeBase :=
Bases_Range'Value
(Get_Attribute(ChildNode, "homebase"));
end if;
if Get_Attribute(ChildNode, "faction") /= "" then
RecruitFaction :=
To_Unbounded_String
(Get_Attribute(ChildNode, "faction"));
end if;
end loop Load_Recruits_Loop;
Sky_Bases(BaseIndex).Recruits.Append
(New_Item =>
(Amount_Of_Attributes => Attributes_Amount,
Amount_Of_Skills => Skills_Amount, Name => RecruitName,
Gender => Gender(1), Price => Price, Skills => Skills,
Attributes => Attributes, Inventory => Inventory,
Equipment => Equipment, Payment => Payment,
Home_Base => HomeBase, Faction => RecruitFaction));
end;
elsif NodeName = To_Unbounded_String("askedforeventsdate") then
Sky_Bases(BaseIndex).Asked_For_Events :=
(Year => Natural'Value(Get_Attribute(ChildNode, "year")),
Month => Natural'Value(Get_Attribute(ChildNode, "month")),
Day => Natural'Value(Get_Attribute(ChildNode, "day")),
Hour => 0, Minutes => 0);
elsif NodeName = To_Unbounded_String("reputation") then
Sky_Bases(BaseIndex).Reputation(1) :=
Natural'Value(Get_Attribute(ChildNode, "level"));
if Get_Attribute(ChildNode, "progress") /= "" then
Sky_Bases(BaseIndex).Reputation(2) :=
Natural'Value(Get_Attribute(ChildNode, "progress"));
end if;
elsif NodeName = To_Unbounded_String("missionsdate") then
Sky_Bases(BaseIndex).Missions_Date :=
(Year => Natural'Value(Get_Attribute(ChildNode, "year")),
Month => Natural'Value(Get_Attribute(ChildNode, "month")),
Day => Natural'Value(Get_Attribute(ChildNode, "day")),
Hour => 0, Minutes => 0);
elsif NodeName = To_Unbounded_String("mission") then
declare
MType: Missions_Types;
TargetX, TargetY: Natural range 0 .. 1_024;
Time, Reward: Positive;
Target: Integer;
Index: Unbounded_String;
begin
MType :=
Missions_Types'Val
(Integer'Value(Get_Attribute(ChildNode, "type")));
if MType = Deliver or MType = Destroy then
Index :=
To_Unbounded_String(Get_Attribute(ChildNode, "target"));
else
Target :=
Integer'Value(Get_Attribute(ChildNode, "target"));
end if;
Time := Positive'Value(Get_Attribute(ChildNode, "time"));
TargetX :=
Natural'Value(Get_Attribute(ChildNode, "targetx"));
TargetY :=
Natural'Value(Get_Attribute(ChildNode, "targety"));
Reward := Positive'Value(Get_Attribute(ChildNode, "reward"));
case MType is
when Deliver =>
Sky_Bases(BaseIndex).Missions.Append
(New_Item =>
(MType => Deliver, ItemIndex => Index,
Time => Time, TargetX => TargetX,
TargetY => TargetY, Reward => Reward,
StartBase => BaseIndex, Finished => False,
Multiplier => 1.0));
when Destroy =>
Sky_Bases(BaseIndex).Missions.Append
(New_Item =>
(MType => Destroy, ShipIndex => Index,
Time => Time, TargetX => TargetX,
TargetY => TargetY, Reward => Reward,
StartBase => BaseIndex, Finished => False,
Multiplier => 1.0));
when Patrol =>
Sky_Bases(BaseIndex).Missions.Append
(New_Item =>
(MType => Patrol, Target => Target, Time => Time,
TargetX => TargetX, TargetY => TargetY,
Reward => Reward, StartBase => BaseIndex,
Finished => False, Multiplier => 1.0));
when Explore =>
Sky_Bases(BaseIndex).Missions.Append
(New_Item =>
(MType => Explore, Target => Target, Time => Time,
TargetX => TargetX, TargetY => TargetY,
Reward => Reward, StartBase => BaseIndex,
Finished => False, Multiplier => 1.0));
when Passenger =>
if Target > 91 then
Target := 91;
end if;
Sky_Bases(BaseIndex).Missions.Append
(New_Item =>
(MType => Passenger, Data => Target, Time => Time,
TargetX => TargetX, TargetY => TargetY,
Reward => Reward, StartBase => BaseIndex,
Finished => False, Multiplier => 1.0));
end case;
end;
elsif NodeName = To_Unbounded_String("item") then
declare
Durability: Items_Durability;
Amount, Price: Natural;
ProtoIndex: Unbounded_String;
begin
ProtoIndex :=
To_Unbounded_String(Get_Attribute(ChildNode, "index"));
Durability :=
Items_Durability'Value
(Get_Attribute(ChildNode, "durability"));
Amount := Natural'Value(Get_Attribute(ChildNode, "amount"));
Price := Natural'Value(Get_Attribute(ChildNode, "price"));
Sky_Bases(BaseIndex).Cargo.Append
(New_Item =>
(Proto_Index => ProtoIndex, Amount => Amount,
Durability => Durability, Price => Price));
end;
end if;
end loop Load_Base_Loop;
SkyMap(Sky_Bases(BaseIndex).Sky_X, Sky_Bases(BaseIndex).Sky_Y)
.BaseIndex :=
BaseIndex;
end loop Load_Bases_Loop;
end LoadBases;
end Bases.SaveLoad;
|
-- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package body Text.Pool is
procedure Create (P : in out Reference'Class;
Initial_Size : Pool_Offset := Default_Size)
is
Initial_Chunk : constant Chunk := new Pool_Array
(Pool_Offset (1) .. Round_To_Header_Size (Initial_Size));
begin
if P.Data /= null then
Finalize (P);
end if;
P.Data := new Pool_Data;
P.Data.Chunks (1) := Initial_Chunk;
P.Data.Pos := 1;
declare
H : Header with Import;
for H'Address use Initial_Chunk.all (1)'Address;
begin
H.Refcount := 0;
H.Last := Pool_Offset (Initial_Chunk'Last) - Header_Size;
end;
end Create;
function With_Capacity (Size : Pool_Offset) return Reference is
begin
return Ret : Reference do
Create (Ret, Size);
end return;
end With_Capacity;
function From_String (P : Reference'Class; Data : String)
return Text.Reference is
New_String_Address : constant System.Address :=
Fitting_Position (Data'Length, P.Data);
Target_Data : constant UTF_8_String_Access :=
To_UTF_8_String_Access (New_String_Address);
Null_Terminator : Character with Import;
for Null_Terminator'Address use New_String_Address + Data'Length;
begin
Null_Terminator := Character'Val (0);
Target_Data.all := UTF_8_String (Data);
return (Ada.Finalization.Controlled with Data => Target_Data);
end From_String;
function With_Length (P : Reference'Class; Length : Positive)
return Text.Reference is
use System.Storage_Elements;
New_String_Address : constant System.Address :=
Fitting_Position (Storage_Offset (Length), P.Data);
Target_Data : constant UTF_8_String_Access :=
To_UTF_8_String_Access (New_String_Address);
Null_Terminator : Character with Import;
for Null_Terminator'Address use New_String_Address + Storage_Offset (Length);
begin
Null_Terminator := Character'Val (0);
return (Ada.Finalization.Controlled with Data => Target_Data);
end With_Length;
procedure Adjust (Object : in out Reference) is
begin
if Object.Data /= null then
Object.Data.Refcount := Object.Data.Refcount + 1;
end if;
end Adjust;
procedure Finalize (Object : in out Reference) is
Reference : Pool_Data_Access := Object.Data;
begin
Object.Data := null;
if Reference /= null then
Reference.Refcount := Reference.Refcount - 1;
if Reference.Refcount = 0 then
-- no reference around; take away Usage + 1 from the current Chunk.
-- this enables the whole pool data to be freed once all Content
-- references vanish.
Decrease_Usage (Reference, Reference.Cur);
end if;
end if;
end Finalize;
function Current_Chunk_As_String (P : Reference) return String is
(As_String (P.Data.Chunks (P.Data.Cur)));
end Text.Pool;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T B I N D --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with ALI; use ALI;
with ALI.Util; use ALI.Util;
with Bcheck; use Bcheck;
with Binde; use Binde;
with Binderr; use Binderr;
with Bindgen; use Bindgen;
with Bindusg;
with Butil; use Butil;
with Csets;
with Gnatvsn; use Gnatvsn;
with Namet; use Namet;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Switch; use Switch;
with Types; use Types;
procedure Gnatbind is
Total_Errors : Nat := 0;
-- Counts total errors in all files
Total_Warnings : Nat := 0;
-- Total warnings in all files
Main_Lib_File : File_Name_Type;
-- Current main library file
Std_Lib_File : File_Name_Type;
-- Standard library
Text : Text_Buffer_Ptr;
Id : ALI_Id;
Next_Arg : Positive;
Output_File_Name_Seen : Boolean := False;
Output_File_Name : String_Ptr := new String'("");
procedure Scan_Bind_Arg (Argv : String);
-- Scan and process binder specific arguments. Argv is a single argument.
-- All the one character arguments are still handled by Switch. This
-- routine handles -aO -aI and -I-.
-------------------
-- Scan_Bind_Arg --
-------------------
procedure Scan_Bind_Arg (Argv : String) is
begin
-- Now scan arguments that are specific to the binder and are not
-- handled by the common circuitry in Switch.
if Opt.Output_File_Name_Present
and then not Output_File_Name_Seen
then
Output_File_Name_Seen := True;
if Argv'Length = 0
or else (Argv'Length >= 1
and then (Argv (1) = Switch_Character
or else Argv (1) = '-'))
then
Fail ("output File_Name missing after -o");
else
Output_File_Name := new String'(Argv);
end if;
elsif Argv'Length >= 2
and then (Argv (1) = Switch_Character
or else Argv (1) = '-')
then
-- -I-
if Argv (2 .. Argv'Last) = "I-" then
Opt.Look_In_Primary_Dir := False;
-- -Idir
elsif Argv (2) = 'I' then
Add_Src_Search_Dir (Argv (3 .. Argv'Last));
Add_Lib_Search_Dir (Argv (3 .. Argv'Last));
-- -Ldir
elsif Argv (2) = 'L' then
if Argv'Length >= 3 then
Opt.Bind_For_Library := True;
Opt.Ada_Init_Name :=
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Init_Suffix);
Opt.Ada_Final_Name :=
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Final_Suffix);
Opt.Ada_Main_Name :=
new String'(Argv (3 .. Argv'Last) & Opt.Ada_Main_Name_Suffix);
-- This option (-Lxxx) implies -n
Opt.Bind_Main_Program := False;
else
Fail
("Prefix of initialization and finalization " &
"procedure names missing in -L");
end if;
-- -Sin -Slo -Shi -Sxx
elsif Argv'Length = 4
and then Argv (2) = 'S'
then
declare
C1 : Character := Argv (3);
C2 : Character := Argv (4);
begin
if C1 in 'a' .. 'z' then
C1 := Character'Val (Character'Pos (C1) - 32);
end if;
if C2 in 'a' .. 'z' then
C2 := Character'Val (Character'Pos (C2) - 32);
end if;
if C1 = 'I' and then C2 = 'N' then
Initialize_Scalars_Mode := 'I';
elsif C1 = 'L' and then C2 = 'O' then
Initialize_Scalars_Mode := 'L';
elsif C1 = 'H' and then C2 = 'I' then
Initialize_Scalars_Mode := 'H';
elsif (C1 in '0' .. '9' or else C1 in 'A' .. 'F')
and then
(C2 in '0' .. '9' or else C2 in 'A' .. 'F')
then
Initialize_Scalars_Mode := 'X';
Initialize_Scalars_Val (1) := C1;
Initialize_Scalars_Val (2) := C2;
-- Invalid -S switch, let Switch give error
else
Scan_Binder_Switches (Argv);
end if;
end;
-- -aIdir
elsif Argv'Length >= 3
and then Argv (2 .. 3) = "aI"
then
Add_Src_Search_Dir (Argv (4 .. Argv'Last));
-- -aOdir
elsif Argv'Length >= 3
and then Argv (2 .. 3) = "aO"
then
Add_Lib_Search_Dir (Argv (4 .. Argv'Last));
-- -nostdlib
elsif Argv (2 .. Argv'Last) = "nostdlib" then
Opt.No_Stdlib := True;
-- -nostdinc
elsif Argv (2 .. Argv'Last) = "nostdinc" then
Opt.No_Stdinc := True;
-- -static
elsif Argv (2 .. Argv'Last) = "static" then
Opt.Shared_Libgnat := False;
-- -shared
elsif Argv (2 .. Argv'Last) = "shared" then
Opt.Shared_Libgnat := True;
-- -Mname
elsif Argv'Length >= 3 and then Argv (2) = 'M' then
Opt.Bind_Alternate_Main_Name := True;
Opt.Alternate_Main_Name := new String '(Argv (3 .. Argv'Last));
-- All other options are single character and are handled
-- by Scan_Binder_Switches.
else
Scan_Binder_Switches (Argv);
end if;
-- Not a switch, so must be a file name (if non-empty)
elsif Argv'Length /= 0 then
if Argv'Length > 4
and then Argv (Argv'Last - 3 .. Argv'Last) = ".ali"
then
Set_Main_File_Name (Argv);
else
Set_Main_File_Name (Argv & ".ali");
end if;
end if;
end Scan_Bind_Arg;
-- Start of processing for Gnatbind
begin
Osint.Initialize (Binder);
-- Set default for Shared_Libgnat option
declare
Shared_Libgnat_Default : Character;
pragma Import (C, Shared_Libgnat_Default, "shared_libgnat_default");
SHARED : constant Character := 'H';
STATIC : constant Character := 'T';
begin
pragma Assert
(Shared_Libgnat_Default = SHARED
or else
Shared_Libgnat_Default = STATIC);
Shared_Libgnat := (Shared_Libgnat_Default = SHARED);
end;
-- Use low level argument routines to avoid dragging in the secondary stack
Next_Arg := 1;
Scan_Args : while Next_Arg < Arg_Count loop
declare
Next_Argv : String (1 .. Len_Arg (Next_Arg));
begin
Fill_Arg (Next_Argv'Address, Next_Arg);
Scan_Bind_Arg (Next_Argv);
end;
Next_Arg := Next_Arg + 1;
end loop Scan_Args;
-- Test for trailing -o switch
if Opt.Output_File_Name_Present
and then not Output_File_Name_Seen
then
Fail ("output file name missing after -o");
end if;
-- Output usage if requested
if Usage_Requested then
Bindusg;
end if;
-- Check that the Ada binder file specified has extension .adb and that
-- the C binder file has extension .c
if Opt.Output_File_Name_Present
and then Output_File_Name_Seen
then
Check_Extensions : declare
Length : constant Natural := Output_File_Name'Length;
Last : constant Natural := Output_File_Name'Last;
begin
if Ada_Bind_File then
if Length <= 4
or else Output_File_Name (Last - 3 .. Last) /= ".adb"
then
Fail ("output file name should have .adb extension");
end if;
else
if Length <= 2
or else Output_File_Name (Last - 1 .. Last) /= ".c"
then
Fail ("output file name should have .c extension");
end if;
end if;
end Check_Extensions;
end if;
Osint.Add_Default_Search_Dirs;
if Verbose_Mode then
Write_Eol;
Write_Str ("GNATBIND ");
Write_Str (Gnat_Version_String);
Write_Str (" Copyright 1995-2001 Free Software Foundation, Inc.");
Write_Eol;
end if;
-- Output usage information if no files
if not More_Lib_Files then
Bindusg;
Exit_Program (E_Fatal);
end if;
-- The block here is to catch the Unrecoverable_Error exception in the
-- case where we exceed the maximum number of permissible errors or some
-- other unrecoverable error occurs.
begin
-- Carry out package initializations. These are initializations which
-- might logically be performed at elaboration time, but Namet at
-- least can't be done that way (because it is used in the Compiler),
-- and we decide to be consistent. Like elaboration, the order in
-- which these calls are made is in some cases important.
Csets.Initialize;
Namet.Initialize;
Initialize_Binderr;
Initialize_ALI;
Initialize_ALI_Source;
if Verbose_Mode then
Write_Eol;
end if;
-- Input ALI files
while More_Lib_Files loop
Main_Lib_File := Next_Main_Lib_File;
if Verbose_Mode then
if Check_Only then
Write_Str ("Checking: ");
else
Write_Str ("Binding: ");
end if;
Write_Name (Main_Lib_File);
Write_Eol;
end if;
Text := Read_Library_Info (Main_Lib_File, True);
Id := Scan_ALI
(F => Main_Lib_File,
T => Text,
Ignore_ED => Force_RM_Elaboration_Order,
Err => False);
Free (Text);
end loop;
-- Add System.Standard_Library to list to ensure that these files are
-- included in the bind, even if not directly referenced from Ada code
-- This is of course omitted in No_Run_Time mode
if not No_Run_Time_Specified then
Name_Buffer (1 .. 12) := "s-stalib.ali";
Name_Len := 12;
Std_Lib_File := Name_Find;
Text := Read_Library_Info (Std_Lib_File, True);
Id :=
Scan_ALI
(F => Std_Lib_File,
T => Text,
Ignore_ED => Force_RM_Elaboration_Order,
Err => False);
Free (Text);
end if;
-- Acquire all information in ALI files that have been read in
for Index in ALIs.First .. ALIs.Last loop
Read_ALI (Index);
end loop;
-- Warn if -f switch used
if Force_RM_Elaboration_Order then
Error_Msg
("?-f is obsolescent and should not be used");
Error_Msg
("?may result in missing run-time elaboration checks");
Error_Msg
("?use -gnatE, pragma Suppress (Elaboration_Checks) instead");
end if;
-- Quit if some file needs compiling
if No_Object_Specified then
raise Unrecoverable_Error;
end if;
-- Build source file table from the ALI files we have read in
Set_Source_Table;
-- Check that main library file is a suitable main program
if Bind_Main_Program
and then ALIs.Table (ALIs.First).Main_Program = None
and then not No_Main_Subprogram
then
Error_Msg_Name_1 := Main_Lib_File;
Error_Msg ("% does not contain a unit that can be a main program");
end if;
-- Perform consistency and correctness checks
Check_Duplicated_Subunits;
Check_Versions;
Check_Consistency;
Check_Configuration_Consistency;
-- Complete bind if no errors
if Errors_Detected = 0 then
Find_Elab_Order;
if Errors_Detected = 0 then
if Elab_Order_Output then
Write_Eol;
Write_Str ("ELABORATION ORDER");
Write_Eol;
for J in Elab_Order.First .. Elab_Order.Last loop
Write_Str (" ");
Write_Unit_Name (Units.Table (Elab_Order.Table (J)).Uname);
Write_Eol;
end loop;
Write_Eol;
end if;
if not Check_Only then
Gen_Output_File (Output_File_Name.all);
end if;
end if;
end if;
Total_Errors := Total_Errors + Errors_Detected;
Total_Warnings := Total_Warnings + Warnings_Detected;
exception
when Unrecoverable_Error =>
Total_Errors := Total_Errors + Errors_Detected;
Total_Warnings := Total_Warnings + Warnings_Detected;
end;
-- All done. Set proper exit status.
Finalize_Binderr;
Namet.Finalize;
if Total_Errors > 0 then
Exit_Program (E_Errors);
elsif Total_Warnings > 0 then
Exit_Program (E_Warnings);
else
Exit_Program (E_Success);
end if;
end Gnatbind;
|
with
Ada.Text_IO,
Ada.Integer_Text_IO;
use Ada;
procedure fizz_buzz is
begin
for i in 1..100 loop
if i mod 15 = 0 then
Text_IO.Put_Line("fizz buzz");
elsif i mod 5 = 0 then
Text_IO.Put_Line("buzz");
elsif i mod 3 = 0 then
Text_IO.Put_Line("fizz");
else
Integer_Text_IO.put(i, Width => 0);
Text_IO.New_Line;
end if;
end loop;
end fizz_buzz;
|
with registre;
with text_io; use text_io;
with ada.integer_text_io; use ada.integer_text_io;
procedure Test_Registre is
package Registre_Test is new registre (20, integer);
use Registre_Test;
mon_reg : t_registre;
begin
initialiser(mon_reg);
if not existe(mon_reg, 42) then
put("ca marche");
end if;
attribuer(mon_reg, 42, 0);
attribuer(mon_reg, 22, 1);
attribuer(mon_reg, 42, 2);
if existe(mon_reg, 42) then
put("ca marche");
end if;
if existe(mon_reg, 22) then
put("ca marche");
end if;
put(acceder(mon_reg, 42));
put(acceder(mon_reg, 22));
--Supprimer(mon_reg, 42);
--Supprimer(mon_reg, 22);
if not Est_Vide(mon_reg) then put(" c'est bon "); end if;
Detruire(mon_reg);
if Est_Vide(mon_reg) then put(" c'est bon "); end if;
end Test_Registre;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Pathname_Manipulation; use Pathname_Manipulation;
package body Virtual_File_System is
-------------
-- Find_FS --
-------------
function Find_FS (This : in out VFS;
Path : Pathname;
Path_Reminder_Start : out Integer)
return Any_FS_Driver
is
Start, Stop : Integer;
Elt : Mount_Point_Access := This.Mount_points;
begin
Root_Dir (Path, Start, Stop);
if Start not in Path'Range or else Stop not in Path'Range then
Path_Reminder_Start := Path'Last + 1;
return null;
end if;
declare
Root_Dir_Name : constant String := Path (Start .. Stop);
begin
while Elt /= null and then Elt.Directory.all /= Root_Dir_Name loop
Elt := Elt.Next;
end loop;
Path_Reminder_Start := Stop + 1;
return (if Elt /= null then Elt.FS else null);
end;
end Find_FS;
-----------
-- Mount --
-----------
function Mount (This : in out VFS;
Path : Pathname;
Filesystem : not null Any_FS_Driver)
return Status_Kind
is
MP : constant Mount_Point_Access :=
new Mount_Point'(Directory => new String'(Path),
FS => Filesystem,
Next => This.Mount_points);
begin
This.Mount_points := MP;
return Status_Ok;
end Mount;
------------
-- Umount --
------------
function Umount (This : in out VFS;
Path : Pathname)
return Status_Kind
is
pragma Unreferenced (This, Path);
begin
return Permission_Denied;
end Umount;
-----------------
-- Create_Node --
-----------------
overriding
function Create_Node (This : in out VFS;
Path : Pathname;
Kind : File_Kind)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Create_Node (Sub_Path, Kind);
end if;
end Create_Node;
----------------------
-- Create_Directory --
----------------------
overriding
function Create_Directory (This : in out VFS;
Path : Pathname)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Create_Directory (Sub_Path);
end if;
end Create_Directory;
------------
-- Unlink --
------------
overriding
function Unlink (This : in out VFS;
Path : Pathname)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Unlink (Sub_Path);
end if;
end Unlink;
----------------------
-- Remove_Directory --
----------------------
overriding
function Remove_Directory (This : in out VFS;
Path : Pathname)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Remove_Directory (Sub_Path);
end if;
end Remove_Directory;
------------
-- Rename --
------------
overriding
function Rename (This : in out VFS;
Old_Path : Pathname;
New_Path : Pathname)
return Status_Kind
is
pragma Unreferenced (This, Old_Path, New_Path);
begin
return Permission_Denied;
end Rename;
------------------------
-- Change_Permissions --
------------------------
overriding
function Truncate_File (This : in out VFS;
Path : Pathname;
Length : IO_Count)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Truncate_File (Sub_Path, Length);
end if;
end Truncate_File;
----------
-- Open --
----------
overriding
function Open (This : in out VFS;
Path : Pathname;
Mode : File_Mode;
Handler : out Any_File_Handle)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
begin
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Open (Path (Path_Reminder_Start .. Path'Last), Mode, Handler);
end if;
end Open;
--------------------
-- Open_Directory --
--------------------
overriding
function Open_Directory (This : in out VFS;
Path : Pathname;
Handle : out Any_Directory_Handle)
return Status_Kind
is
Path_Reminder_Start : Integer;
FS : constant Any_FS_Driver := This.Find_FS (Path, Path_Reminder_Start);
Sub_Path : constant String := (if Path_Reminder_Start not in Path'Range
then ""
else Path (Path_Reminder_Start .. Path'Last));
begin
if Path = "/" or else Path = "" then
This.Dir_Handle.FS := This'Unchecked_Access;
Handle := This.Dir_Handle'Unchecked_Access;
return Status_Ok;
else
if FS = null then
return No_Such_File_Or_Directory;
else
return FS.Open_Directory (Sub_Path,
Handle);
end if;
end if;
end Open_Directory;
----------------
-- Read_Entry --
----------------
overriding
function Read_Entry (This : in out VFS_Directory_Handle;
Entry_Number : Positive;
Dir_Entry : out Directory_Entry)
return Status_Kind
is
Pt : Mount_Point_Access := This.FS.Mount_points;
Nbr : Positive := Positive'First;
begin
while Pt /= null and then Nbr /= Entry_Number loop
Pt := Pt.Next;
Nbr := Nbr + 1;
end loop;
if Pt /= null then
Dir_Entry.Entry_Type := Directory;
return Status_Ok;
else
return No_Such_File_Or_Directory;
end if;
end Read_Entry;
----------------
-- Entry_Name --
----------------
overriding
function Entry_Name (This : in out VFS_Directory_Handle;
Entry_Number : Positive)
return Pathname
is
Pt : Mount_Point_Access := This.FS.Mount_points;
Nbr : Positive := Positive'First;
begin
while Pt /= null and then Nbr /= Entry_Number loop
Pt := Pt.Next;
Nbr := Nbr + 1;
end loop;
if Pt /= null then
return Pt.Directory.all;
else
return "";
end if;
end Entry_Name;
-----------
-- Close --
-----------
overriding
function Close (This : in out VFS_Directory_Handle)
return Status_Kind
is
pragma Unreferenced (This);
begin
return Status_Ok;
end Close;
end Virtual_File_System;
|
------------------------------------------------------------------------------
-- --
-- J E W L . W I N D O W _ I M P L E M E N T A T I O N --
-- --
-- This is a private package containing implementation details for --
-- JEWL.Windows. Because this package is non-generic, the type --
-- Window_Internals can be defined here at library level by deriving --
-- from JEWL.Reference_Counted_Type, thus avoiding scope problems --
-- arising from the use of a controlled type in a generic package --
-- (which would otherwise have to be instantiated at library level). --
-- Besides, JEWL.Windows is far too big anyway... --
-- --
-- Copyright (C) John English 2000. Contact address: je@brighton.ac.uk --
-- This software is released under the terms of the GNU General Public --
-- License and is intended primarily for educational use. Please contact --
-- the author to report bugs, suggestions and modifications. --
-- --
------------------------------------------------------------------------------
-- $Id: jewl-window_implementation.ads 1.7 2007/01/08 17:00:00 JE Exp $
------------------------------------------------------------------------------
--
-- $Log: jewl-window_implementation.ads $
-- Revision 1.7 2007/01/08 17:00:00 JE
-- * Fixed linker options in JEWL.Win32_Interface to accommodate changes to GNAT
-- GPL 2006 compiler (thanks to John McCormick for this)
-- * Added delay in message loop to avoid the appearance of hogging 100% of CPU
-- time
--
-- Revision 1.6 2001/11/02 16:00:00 JE
-- * Fixed canvas bug when saving an empty canvas
-- * Restore with no prior save now acts as erase
-- * Removed redundant variable declaration in Image function
--
-- Revision 1.5 2001/08/22 15:00:00 JE
-- * Minor bugfix to Get_Text for combo boxes
-- * Minor changes to documentation (including new example involving dialogs)
--
-- Revision 1.4 2001/01/25 09:00:00 je
-- Changes visible to the user:
--
-- * Added support for drawing bitmaps on canvases (Draw_Image operations
-- and new type Image_Type)
-- * Added Play_Sound
-- * Added several new operations on all windows: Get_Origin, Get_Width,
-- Get_Height, Set_Origin, Set_Size and Focus
-- * Added several functions giving screen and window dimensions: Screen_Width,
-- Screen_Height, Frame_Width, Frame_Height, Dialog_Width, Dialog_Height and
-- Menu_Height
-- * Canvases can now handle keyboard events: new constructor and Key_Code added
-- * Added procedure Play_Sound
-- * Operations "+" and "-" added for Point_Type
-- * Pens can now be zero pixels wide
-- * The absolute origin of a frame can now have be specified when the frame
-- is created
-- * Added new File_Dialog operations Add_Filter and Set_Directory
-- * Added Get_Line renames to JEWL.IO for compatibility with Ada.Text_IO
-- * Added all the Get(File,Item) operations mentioned in documentation but
-- unaccountably missing :-(
-- * Documentation updated to reflect the above changes
-- * HTML versions of public package specifications added with links from
-- main documentation pages
--
-- Other internal changes:
--
-- * Canvas fonts, pens etc. now use JEWL.Reference_Counted_Type rather than
-- reinventing this particular wheel, as do images
-- * Various minor code formatting changes: some code reordered for clarity,
-- some comments added or amended,
-- * Changes introduced in 1.2 to support GNAT 3.10 have been reversed, since
-- GNAT 3.10 still couldn't compile this code correctly... ;-(
--
-- Outstanding issues:
--
-- * Optimisation breaks the code (workaround: don't optimise)
--
-- Revision 1.3 2000/07/07 12:00:00 je
-- * JEWL.Simple_Windows added; JEWL.IO modified to use JEWL.Simple_Windows.
-- * JEWL.IO bug fix: Put_Line to file wrote newline to standard output
-- instead of to the file (thanks to Jeff Carter for pointing this out).
-- * Panels fixed so that mouse clicks are passed on correctly to subwindows.
-- * Memos fixed so that tabs are handled properly.
-- * Password feature added to editboxes.
-- * Minor typos fixed in comments within the package sources.
-- * Documentation corrected and updated following comments from Moti Ben-Ari
-- and Don Overheu.
--
-- Revision 1.2 2000/04/18 20:00:00 je
-- * Minor code changes to enable compilation by GNAT 3.10
-- * Minor documentation errors corrected
-- * Some redundant "with" clauses removed
--
-- Revision 1.1 2000/04/09 21:00:00 je
-- Initial revision
--
------------------------------------------------------------------------------
with JEWL.Canvas_Implementation; use JEWL.Canvas_Implementation;
with JEWL.Win32_Interface; use JEWL.Win32_Interface;
with System;
private package JEWL.Window_Implementation is
type Window_Internals;
type Window_Ptr is access all Window_Internals'Class;
type Container_Internals;
type Container_Ptr is access all Container_Internals;
----------------------------------------------------------------------------
--
-- W I N D O W _ I N T E R N A L S
--
-- Window_Internals (or a type derived from Window_Internals) is what
-- the Controlled_Type object in every Window_Type object actually
-- points to. It contains the following fields:
--
-- Handle : the native Windows handle for the window
-- Parent : the parent window (null for top-level windows)
-- Next : link to the next sibling of this window
-- First : link to the first child window of this window
-- Last : link to the last child window
-- Action : the command code associated with window (-1 if none)
-- Font : font handle for the window's font
-- Top : position of top of window (negative if relative to parent)
-- Left : position of top of window (negative if relative to parent)
-- Height : position of top of window (non-positive if relative to parent)
-- Width : position of top of window (non-positive if relative to parent)
-- WndProc : old window procedure for subclassed windows
--
-- The Cleanup procedure is called automatically when a Window_Internals
-- object is deleted and should not be called directly.
--
----------------------------------------------------------------------------
type Window_Internals is new Reference_Counted_Type with
record
Handle : Win32_HWND := System.Null_Address;
Parent : Container_Ptr;
Next : Controlled_Type;
First : Controlled_Type;
Last : Window_Ptr;
Action : Integer := -1;
Font : Win32_HFONT := System.Null_Address;
Top : Integer := 0;
Left : Integer := 0;
Height : Integer := 0;
Width : Integer := 0;
WndProc : Win32_LONG := 0;
end record;
procedure Cleanup (Object : in out Window_Internals);
----------------------------------------------------------------------------
--
-- C O N T A I N E R _ I N T E R N A L S
--
-- This is a type derived from Window_Internals for use by container
-- windows. It includes the following additional component:
--
-- Group : a flag to determine whether the WS_GROUP style should be
-- applied to child controls (used to ensure that radiobutton
-- groups are correctly delimited).
--
----------------------------------------------------------------------------
type Container_Internals is new Window_Internals with
record
Group : Boolean := True;
end record;
----------------------------------------------------------------------------
--
-- M A I N _ W I N D O W _ I N T E R N A L S
--
-- This is a type derived from Container_Internals for use by top-level
-- windows. It includes the following additional component:
--
-- Focus : the handle of the child window to activate when the top-level
-- window is activated (if any).
--
----------------------------------------------------------------------------
type Main_Window_Internals is new Container_Internals with
record
Focus : Win32_HWND := System.Null_Address;
end record;
type Main_Window_Ptr is access all Main_Window_Internals;
procedure Cleanup (Object : in out Main_Window_Internals);
----------------------------------------------------------------------------
--
-- C A N V A S _ I N T E R N A L S
--
-- This is a type derived from Window_Internals for use by canvas
-- window. It includes the following additional component:
--
-- Monitor : a protected record (defined in Canvas_Implementation)
-- to record the drawing operations and mouse state and
-- to synchronise accesses from the message loop task.
--
----------------------------------------------------------------------------
type Canvas_Internals is new Window_Internals with
record
Monitor : Canvas_Monitor;
Keypress : Integer := -1;
end record;
procedure Cleanup (Object : in out Canvas_Internals);
type Canvas_Ptr is access all Canvas_Internals;
----------------------------------------------------------------------------
--
-- C O M M O N _ D I A L O G _ I N T E R N A L S
--
-- Common_Dialog_Internals (or a type derived from it) is what the
-- Controlled_Type object in every Common_Dialog_Type object actually
-- points to.
--
----------------------------------------------------------------------------
type Common_Dialog_Internals is
abstract new Reference_Counted_Type with null record;
type Common_Dialog_Ptr is access all Common_Dialog_Internals'Class;
function Show_Dialog (Dialog : access Common_Dialog_Internals)
return Boolean is abstract;
----------------------------------------------------------------------------
--
-- C O L O U R _ D I A L O G _ I N T E R N A L S
--
----------------------------------------------------------------------------
type Custom_Colours is array (1..16) of aliased Win32_COLORREF;
type Colour_Dialog_Internals is new Common_Dialog_Internals with
record
Struct : aliased Win32_CHOOSECOLOR;
Colour : Colour_Type;
Custom : Custom_Colours;
end record;
type Colour_Dialog_Ptr is access all Colour_Dialog_Internals'Class;
function Show_Dialog (Dialog : access Colour_Dialog_Internals)
return Boolean;
----------------------------------------------------------------------------
--
-- F O N T _ D I A L O G _ I N T E R N A L S
--
----------------------------------------------------------------------------
type Font_Dialog_Internals is new Common_Dialog_Internals with
record
Struct : aliased Win32_CHOOSEFONT;
Font : aliased Win32_LOGFONT;
end record;
type Font_Dialog_Ptr is access all Font_Dialog_Internals'Class;
function Show_Dialog (Dialog : access Font_Dialog_Internals)
return Boolean;
----------------------------------------------------------------------------
--
-- F I L E _ D I A L O G _ I N T E R N A L S
--
----------------------------------------------------------------------------
type File_Dialog_Internals (N : Win32_SIZE) is
abstract new Common_Dialog_Internals with
record
Struct : aliased Win32_OPENFILENAME;
Title : Win32_String (1..N);
Buffer : Win32_String (1..300);
Directory : aliased Win32_String (1..300);
Filter : aliased Win32_String (1..300);
Length : Win32_SIZE := 0;
end record;
type File_Dialog_Ptr is access all File_Dialog_Internals'Class;
----------------------------------------------------------------------------
--
-- O P E N _ D I A L O G _ I N T E R N A L S
--
----------------------------------------------------------------------------
type Open_Dialog_Internals is new File_Dialog_Internals with null record;
function Show_Dialog (Dialog : access Open_Dialog_Internals)
return Boolean;
----------------------------------------------------------------------------
--
-- S A V E _ D I A L O G _ I N T E R N A L S
--
----------------------------------------------------------------------------
type Save_Dialog_Internals is new File_Dialog_Internals with null record;
function Show_Dialog (Dialog : access Save_Dialog_Internals)
return Boolean;
end JEWL.Window_Implementation;
|
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.UCPD is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CFG1_HBITCLKDIV_Field is HAL.UInt6;
subtype CFG1_IFRGAP_Field is HAL.UInt5;
subtype CFG1_TRANSWIN_Field is HAL.UInt5;
subtype CFG1_PSC_USBPDCLK_Field is HAL.UInt3;
subtype CFG1_RXORDSETEN_Field is HAL.UInt9;
-- UCPD configuration register 1
type CFG1_Register is record
-- HBITCLKDIV
HBITCLKDIV : CFG1_HBITCLKDIV_Field := 16#0#;
-- IFRGAP
IFRGAP : CFG1_IFRGAP_Field := 16#0#;
-- TRANSWIN
TRANSWIN : CFG1_TRANSWIN_Field := 16#0#;
-- unspecified
Reserved_16_16 : HAL.Bit := 16#0#;
-- PSC_USBPDCLK
PSC_USBPDCLK : CFG1_PSC_USBPDCLK_Field := 16#0#;
-- RXORDSETEN
RXORDSETEN : CFG1_RXORDSETEN_Field := 16#0#;
-- TXDMAEN
TXDMAEN : Boolean := False;
-- RXDMAEN
RXDMAEN : Boolean := False;
-- UCPDEN
UCPDEN : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFG1_Register use record
HBITCLKDIV at 0 range 0 .. 5;
IFRGAP at 0 range 6 .. 10;
TRANSWIN at 0 range 11 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
PSC_USBPDCLK at 0 range 17 .. 19;
RXORDSETEN at 0 range 20 .. 28;
TXDMAEN at 0 range 29 .. 29;
RXDMAEN at 0 range 30 .. 30;
UCPDEN at 0 range 31 .. 31;
end record;
-- UCPD configuration register 2
type CFG2_Register is record
-- RXFILTDIS
RXFILTDIS : Boolean := False;
-- RXFILT2N3
RXFILT2N3 : Boolean := False;
-- FORCECLK
FORCECLK : Boolean := False;
-- WUPEN
WUPEN : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFG2_Register use record
RXFILTDIS at 0 range 0 .. 0;
RXFILT2N3 at 0 range 1 .. 1;
FORCECLK at 0 range 2 .. 2;
WUPEN at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype CR_TXMODE_Field is HAL.UInt2;
subtype CR_ANASUBMODE_Field is HAL.UInt2;
subtype CR_CCENABLE_Field is HAL.UInt2;
-- UCPD configuration register 2
type CR_Register is record
-- TXMODE
TXMODE : CR_TXMODE_Field := 16#0#;
-- TXSEND
TXSEND : Boolean := False;
-- TXHRST
TXHRST : Boolean := False;
-- RXMODE
RXMODE : Boolean := False;
-- PHYRXEN
PHYRXEN : Boolean := False;
-- PHYCCSEL
PHYCCSEL : Boolean := False;
-- ANASUBMODE
ANASUBMODE : CR_ANASUBMODE_Field := 16#0#;
-- ANAMODE
ANAMODE : Boolean := False;
-- CCENABLE
CCENABLE : CR_CCENABLE_Field := 16#0#;
-- unspecified
Reserved_12_15 : HAL.UInt4 := 16#0#;
-- FRSRXEN
FRSRXEN : Boolean := False;
-- FRSTX
FRSTX : Boolean := False;
-- RDCH
RDCH : Boolean := False;
-- unspecified
Reserved_19_19 : HAL.Bit := 16#0#;
-- CC1TCDIS
CC1TCDIS : Boolean := False;
-- CC2TCDIS
CC2TCDIS : Boolean := False;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
TXMODE at 0 range 0 .. 1;
TXSEND at 0 range 2 .. 2;
TXHRST at 0 range 3 .. 3;
RXMODE at 0 range 4 .. 4;
PHYRXEN at 0 range 5 .. 5;
PHYCCSEL at 0 range 6 .. 6;
ANASUBMODE at 0 range 7 .. 8;
ANAMODE at 0 range 9 .. 9;
CCENABLE at 0 range 10 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
FRSRXEN at 0 range 16 .. 16;
FRSTX at 0 range 17 .. 17;
RDCH at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
CC1TCDIS at 0 range 20 .. 20;
CC2TCDIS at 0 range 21 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- UCPD Interrupt Mask Register
type IMR_Register is record
-- TXISIE
TXISIE : Boolean := False;
-- TXMSGDISCIE
TXMSGDISCIE : Boolean := False;
-- TXMSGSENTIE
TXMSGSENTIE : Boolean := False;
-- TXMSGABTIE
TXMSGABTIE : Boolean := False;
-- HRSTDISCIE
HRSTDISCIE : Boolean := False;
-- HRSTSENTIE
HRSTSENTIE : Boolean := False;
-- TXUNDIE
TXUNDIE : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- RXNEIE
RXNEIE : Boolean := False;
-- RXORDDETIE
RXORDDETIE : Boolean := False;
-- RXHRSTDETIE
RXHRSTDETIE : Boolean := False;
-- RXOVRIE
RXOVRIE : Boolean := False;
-- RXMSGENDIE
RXMSGENDIE : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- TYPECEVT1IE
TYPECEVT1IE : Boolean := False;
-- TYPECEVT2IE
TYPECEVT2IE : Boolean := False;
-- unspecified
Reserved_16_19 : HAL.UInt4 := 16#0#;
-- FRSEVTIE
FRSEVTIE : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IMR_Register use record
TXISIE at 0 range 0 .. 0;
TXMSGDISCIE at 0 range 1 .. 1;
TXMSGSENTIE at 0 range 2 .. 2;
TXMSGABTIE at 0 range 3 .. 3;
HRSTDISCIE at 0 range 4 .. 4;
HRSTSENTIE at 0 range 5 .. 5;
TXUNDIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
RXNEIE at 0 range 8 .. 8;
RXORDDETIE at 0 range 9 .. 9;
RXHRSTDETIE at 0 range 10 .. 10;
RXOVRIE at 0 range 11 .. 11;
RXMSGENDIE at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TYPECEVT1IE at 0 range 14 .. 14;
TYPECEVT2IE at 0 range 15 .. 15;
Reserved_16_19 at 0 range 16 .. 19;
FRSEVTIE at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- SR_TYPECEVT array
type SR_TYPECEVT_Field_Array is array (1 .. 2) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for SR_TYPECEVT
type SR_TYPECEVT_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TYPECEVT as a value
Val : HAL.UInt2;
when True =>
-- TYPECEVT as an array
Arr : SR_TYPECEVT_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SR_TYPECEVT_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- SR_TYPEC_VSTATE_CC array element
subtype SR_TYPEC_VSTATE_CC_Element is HAL.UInt2;
-- SR_TYPEC_VSTATE_CC array
type SR_TYPEC_VSTATE_CC_Field_Array is array (1 .. 2)
of SR_TYPEC_VSTATE_CC_Element
with Component_Size => 2, Size => 4;
-- Type definition for SR_TYPEC_VSTATE_CC
type SR_TYPEC_VSTATE_CC_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- TYPEC_VSTATE_CC as a value
Val : HAL.UInt4;
when True =>
-- TYPEC_VSTATE_CC as an array
Arr : SR_TYPEC_VSTATE_CC_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for SR_TYPEC_VSTATE_CC_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- UCPD Status Register
type SR_Register is record
-- TXIS
TXIS : Boolean := False;
-- TXMSGDISC
TXMSGDISC : Boolean := False;
-- TXMSGSENT
TXMSGSENT : Boolean := False;
-- TXMSGABT
TXMSGABT : Boolean := False;
-- HRSTDISC
HRSTDISC : Boolean := False;
-- HRSTSENT
HRSTSENT : Boolean := False;
-- TXUND
TXUND : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- RXNE
RXNE : Boolean := False;
-- RXORDDET
RXORDDET : Boolean := False;
-- RXHRSTDET
RXHRSTDET : Boolean := False;
-- RXOVR
RXOVR : Boolean := False;
-- RXMSGEND
RXMSGEND : Boolean := False;
-- RXERR
RXERR : Boolean := False;
-- TYPECEVT1
TYPECEVT : SR_TYPECEVT_Field :=
(As_Array => False, Val => 16#0#);
-- TYPEC_VSTATE_CC1
TYPEC_VSTATE_CC : SR_TYPEC_VSTATE_CC_Field :=
(As_Array => False, Val => 16#0#);
-- FRSEVT
FRSEVT : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
TXIS at 0 range 0 .. 0;
TXMSGDISC at 0 range 1 .. 1;
TXMSGSENT at 0 range 2 .. 2;
TXMSGABT at 0 range 3 .. 3;
HRSTDISC at 0 range 4 .. 4;
HRSTSENT at 0 range 5 .. 5;
TXUND at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
RXNE at 0 range 8 .. 8;
RXORDDET at 0 range 9 .. 9;
RXHRSTDET at 0 range 10 .. 10;
RXOVR at 0 range 11 .. 11;
RXMSGEND at 0 range 12 .. 12;
RXERR at 0 range 13 .. 13;
TYPECEVT at 0 range 14 .. 15;
TYPEC_VSTATE_CC at 0 range 16 .. 19;
FRSEVT at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- UCPD Interrupt Clear Register
type ICR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- TXMSGDISCCF
TXMSGDISCCF : Boolean := False;
-- TXMSGSENTCF
TXMSGSENTCF : Boolean := False;
-- TXMSGABTCF
TXMSGABTCF : Boolean := False;
-- HRSTDISCCF
HRSTDISCCF : Boolean := False;
-- HRSTSENTCF
HRSTSENTCF : Boolean := False;
-- TXUNDCF
TXUNDCF : Boolean := False;
-- unspecified
Reserved_7_8 : HAL.UInt2 := 16#0#;
-- RXORDDETCF
RXORDDETCF : Boolean := False;
-- RXHRSTDETCF
RXHRSTDETCF : Boolean := False;
-- RXOVRCF
RXOVRCF : Boolean := False;
-- RXMSGENDCF
RXMSGENDCF : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- TYPECEVT1CF
TYPECEVT1CF : Boolean := False;
-- TYPECEVT2CF
TYPECEVT2CF : Boolean := False;
-- unspecified
Reserved_16_19 : HAL.UInt4 := 16#0#;
-- FRSEVTCF
FRSEVTCF : Boolean := False;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
TXMSGDISCCF at 0 range 1 .. 1;
TXMSGSENTCF at 0 range 2 .. 2;
TXMSGABTCF at 0 range 3 .. 3;
HRSTDISCCF at 0 range 4 .. 4;
HRSTSENTCF at 0 range 5 .. 5;
TXUNDCF at 0 range 6 .. 6;
Reserved_7_8 at 0 range 7 .. 8;
RXORDDETCF at 0 range 9 .. 9;
RXHRSTDETCF at 0 range 10 .. 10;
RXOVRCF at 0 range 11 .. 11;
RXMSGENDCF at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TYPECEVT1CF at 0 range 14 .. 14;
TYPECEVT2CF at 0 range 15 .. 15;
Reserved_16_19 at 0 range 16 .. 19;
FRSEVTCF at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype TX_ORDSET_TXORDSET_Field is HAL.UInt20;
-- UCPD Tx Ordered Set Type Register
type TX_ORDSET_Register is record
-- TXORDSET
TXORDSET : TX_ORDSET_TXORDSET_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TX_ORDSET_Register use record
TXORDSET at 0 range 0 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype TX_PAYSZ_TXPAYSZ_Field is HAL.UInt10;
-- UCPD Tx Paysize Register
type TX_PAYSZ_Register is record
-- TXPAYSZ
TXPAYSZ : TX_PAYSZ_TXPAYSZ_Field := 16#0#;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TX_PAYSZ_Register use record
TXPAYSZ at 0 range 0 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype TXDR_TXDATA_Field is HAL.UInt8;
-- UCPD Tx Data Register
type TXDR_Register is record
-- TXDATA
TXDATA : TXDR_TXDATA_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TXDR_Register use record
TXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype RX_ORDSET_RXORDSET_Field is HAL.UInt3;
subtype RX_ORDSET_RXSOPKINVALID_Field is HAL.UInt3;
-- UCPD Rx Ordered Set Register
type RX_ORDSET_Register is record
-- Read-only. RXORDSET
RXORDSET : RX_ORDSET_RXORDSET_Field;
-- Read-only. RXSOP3OF4
RXSOP3OF4 : Boolean;
-- Read-only. RXSOPKINVALID
RXSOPKINVALID : RX_ORDSET_RXSOPKINVALID_Field;
-- unspecified
Reserved_7_31 : HAL.UInt25;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RX_ORDSET_Register use record
RXORDSET at 0 range 0 .. 2;
RXSOP3OF4 at 0 range 3 .. 3;
RXSOPKINVALID at 0 range 4 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype RX_PAYSZ_RXPAYSZ_Field is HAL.UInt10;
-- UCPD Rx Paysize Register
type RX_PAYSZ_Register is record
-- Read-only. RXPAYSZ
RXPAYSZ : RX_PAYSZ_RXPAYSZ_Field;
-- unspecified
Reserved_10_31 : HAL.UInt22;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RX_PAYSZ_Register use record
RXPAYSZ at 0 range 0 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype RXDR_RXDATA_Field is HAL.UInt8;
-- UCPD Rx Data Register
type RXDR_Register is record
-- Read-only. RXDATA
RXDATA : RXDR_RXDATA_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RXDR_Register use record
RXDATA at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype RX_ORDEXT1_RXSOPX1_Field is HAL.UInt20;
-- UCPD Rx Ordered Set Extension Register 1
type RX_ORDEXT1_Register is record
-- RXSOPX1
RXSOPX1 : RX_ORDEXT1_RXSOPX1_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RX_ORDEXT1_Register use record
RXSOPX1 at 0 range 0 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype RX_ORDEXT2_RXSOPX2_Field is HAL.UInt20;
-- UCPD Rx Ordered Set Extension Register 2
type RX_ORDEXT2_Register is record
-- RXSOPX2
RXSOPX2 : RX_ORDEXT2_RXSOPX2_Field := 16#0#;
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RX_ORDEXT2_Register use record
RXSOPX2 at 0 range 0 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- UCPD1
type UCPD1_Peripheral is record
-- UCPD configuration register 1
CFG1 : aliased CFG1_Register;
-- UCPD configuration register 2
CFG2 : aliased CFG2_Register;
-- UCPD configuration register 2
CR : aliased CR_Register;
-- UCPD Interrupt Mask Register
IMR : aliased IMR_Register;
-- UCPD Status Register
SR : aliased SR_Register;
-- UCPD Interrupt Clear Register
ICR : aliased ICR_Register;
-- UCPD Tx Ordered Set Type Register
TX_ORDSET : aliased TX_ORDSET_Register;
-- UCPD Tx Paysize Register
TX_PAYSZ : aliased TX_PAYSZ_Register;
-- UCPD Tx Data Register
TXDR : aliased TXDR_Register;
-- UCPD Rx Ordered Set Register
RX_ORDSET : aliased RX_ORDSET_Register;
-- UCPD Rx Paysize Register
RX_PAYSZ : aliased RX_PAYSZ_Register;
-- UCPD Rx Data Register
RXDR : aliased RXDR_Register;
-- UCPD Rx Ordered Set Extension Register 1
RX_ORDEXT1 : aliased RX_ORDEXT1_Register;
-- UCPD Rx Ordered Set Extension Register 2
RX_ORDEXT2 : aliased RX_ORDEXT2_Register;
end record
with Volatile;
for UCPD1_Peripheral use record
CFG1 at 16#0# range 0 .. 31;
CFG2 at 16#4# range 0 .. 31;
CR at 16#C# range 0 .. 31;
IMR at 16#10# range 0 .. 31;
SR at 16#14# range 0 .. 31;
ICR at 16#18# range 0 .. 31;
TX_ORDSET at 16#1C# range 0 .. 31;
TX_PAYSZ at 16#20# range 0 .. 31;
TXDR at 16#24# range 0 .. 31;
RX_ORDSET at 16#28# range 0 .. 31;
RX_PAYSZ at 16#2C# range 0 .. 31;
RXDR at 16#30# range 0 .. 31;
RX_ORDEXT1 at 16#34# range 0 .. 31;
RX_ORDEXT2 at 16#38# range 0 .. 31;
end record;
-- UCPD1
UCPD1_Periph : aliased UCPD1_Peripheral
with Import, Address => UCPD1_Base;
end STM32_SVD.UCPD;
|
with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Rejuvenation.Patterns; use Rejuvenation.Patterns;
with Rejuvenation.Simple_Factory; use Rejuvenation.Simple_Factory;
with Rejuvenation.Utils; use Rejuvenation.Utils;
with Finder; use Finder;
procedure Rejuvenation_Find is
Units : constant Analysis_Units.Vector :=
Analyze_Project ("C:\path\to\your.gpr");
Find_Pattern : constant Pattern :=
-- Make_Pattern ("for $S_Var'$S_Attribute use $S_Expr;",
-- Basic_Decls_Rule);
Make_Pattern
("if $S_Cond then " &
" $S_f ($M_before, $M_Designator => $S_Value1, $M_after); " &
"else " &
" $S_f ($M_before, $M_Designator => $S_Value2, $M_after); " &
"end if;",
If_Stmt_Rule);
-- Make_Pattern
-- ("for $S_I in $S_Range "
-- & "loop if $S_Cond then $S_Var := false; end if; end loop;",
-- Loop_Stmt_Rule);
-- Make_Pattern
-- ("for $S_I in $S_Range "
-- & "loop if $S_Cond then $S_Var := true; end if; end loop;",
-- Loop_Stmt_Rule);
-- Make_Pattern
-- ("if $S_Cond then $M_Stmts_True; $S_Tail; "
-- & "else $M_Stmts_False; $S_Tail; end if;",
-- If_Stmt_Rule);
Count : Natural := 0;
begin
for Unit of Units loop
for Match of Find (Unit.Root, Find_Pattern) loop
Count := Count + 1;
Put_Line
(Image (Match.Get_Nodes.First_Element.Full_Sloc_Image) &
Raw_Signature
(Match.Get_Nodes.First_Element, Match.Get_Nodes.Last_Element));
end loop;
end loop;
Put_Line ("# Matches = " & Count'Image);
end Rejuvenation_Find;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
package body Vectors_3D_LF is
function "*" (V_Left, V_Right : Vector_3D_LF) return Vector_3D_LF is
(x => (V_Left (y) * V_Right (z) - V_Left (z) * V_Right (y)),
y => (V_Left (z) * V_Right (x) - V_Left (x) * V_Right (z)),
z => (V_Left (x) * V_Right (y) - V_Left (y) * V_Right (x)));
end Vectors_3D_LF;
|
with DOM.Core.Documents;
with Project_Processor.Parsers.Parser_Tables;
with XML_Utilities;
with XML_Scanners;
with DOM.Core.Nodes;
with EU_Projects.Nodes.Action_Nodes.Tasks;
with EU_Projects.Nodes.Action_Nodes.WPs;
with EU_Projects.Nodes.Timed_Nodes.Milestones;
with Project_Processor.Parsers.XML_Parsers.Sub_Parsers;
with EU_Projects.Nodes.Timed_Nodes.Deliverables;
package body Project_Processor.Parsers.XML_Parsers is
use XML_Scanners;
use EU_Projects.Projects;
------------
-- Create --
------------
function Create
(Params : not null access Plugins.Parameter_Maps.Map)
return Parser_Type
is
pragma Unreferenced (Params);
Result : Parser_Type;
begin
return Result;
end Create;
procedure Parse_Project
(Parser : in out Parser_Type;
Project : out Project_Descriptor;
N : in DOM.Core.Node)
is
pragma Unreferenced (Parser);
use EU_Projects.Nodes;
Scanner : XML_Scanner := Create_Child_Scanner (N);
procedure Add_Partner (N : DOM.Core.Node) is
begin
Project.Add_Partner (Sub_Parsers.Parse_Partner (N));
end Add_Partner;
procedure Add_Milestone (N : DOM.Core.Node) is
Milestone : Timed_Nodes.Milestones.Milestone_Access;
begin
Sub_Parsers.Parse_Milestone (N, Milestone);
Project.Add_Milestone (Milestone);
end Add_Milestone;
procedure Add_WP (N : DOM.Core.Node) is
WP : Action_Nodes.WPs.Project_WP_Access;
begin
Sub_Parsers.Parse_WP (N, WP);
Project.Add_WP (WP);
end Add_WP;
procedure Handle_Configuration (N : DOM.Core.Node) is
begin
Sub_Parsers.Parse_Configuration (Project, N);
end Handle_Configuration;
procedure Add_Risk (N : DOM.Core.Node) is
begin
Project.Add_Risk (Sub_Parsers.Parse_Risk (N));
end Add_Risk;
procedure Add_Deliverable (N : DOM.Core.Node) is
Deliv : Timed_Nodes.Deliverables.Deliverable_Access;
begin
Sub_Parsers.Parse_Deliverable (N, Deliv);
Project.Add_Deliverable (Deliv);
end Add_Deliverable;
begin
if DOM.Core.Nodes.Node_Name (N) /= "project" then
raise Parsing_Error;
end if;
Dom.Core.Nodes.Print (N);
Scanner.Parse_Optional ("configuration", Handle_Configuration'Access);
Scanner.Parse_Sequence ("partner", Add_Partner'Access);
Scanner.Parse_Sequence ("wp", Add_WP'Access);
Scanner.Parse_Sequence ("milestone", Add_Milestone'Access);
Scanner.Parse_Sequence (Name => "deliverable",
Callback => Add_Deliverable'Access,
Min_Length => 0);
Scanner.Parse_Sequence (Name => "risk",
Callback => Add_Risk'Access,
Min_Length => 0);
end Parse_Project;
-----------
-- Parse --
-----------
procedure Parse
(Parser : in out Parser_Type;
Project : out EU_Projects.Projects.Project_Descriptor;
Input : String)
is
use DOM.Core.Documents;
begin
Parse_Project
(Parser => Parser,
Project => Project,
N => Get_Element (XML_Utilities.Parse_String (Input)));
Project.Freeze;
end Parse;
begin
Parser_Tables.Register (ID => "xml",
Tag => Parser_Type'Tag);
end Project_Processor.Parsers.XML_Parsers;
|
with Ada.Text_Io,Ada.Integer_Text_IO; use Ada.Text_Io,Ada.Integer_Text_IO;
with vectores; use vectores;
with posicion;
procedure prueba_posicion is
-- este programa hace llamadas a la funcion Esta_en_vector y es util
-- para comprobar si su funcionamiento es correcto
Vector1: Vector_De_Enteros(1..10);
Vector2: Vector_De_enteros(11..20);
Vector3: Vector_De_enteros(32..41);
begin
vector1 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 1: el valor esta en medio");
put_line(" posicion(13, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser 7 y el resultado es ");
put(posicion(13, vector1));
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
vector2 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 2: el valor esta al final");
put_line(" posicion(9, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser 20 y el resultado es ");
put(posicion(9, vector2));
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Vector1 := (1, 3, 5, 7, 19, 6, 13, 15, 17, 9);
put_line("Caso 3: el valor no esta, se debe recorrer todo el vector");
put_line(" posicion(45, (1, 3, 5, 7, 19, 6, 13, 15, 17, 9))");
put_line(" debe ser -1 y el resultado es ");
put((posicion(45, vector1)));
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
--Mis casos de prueba
vector3 := (2, 4, 6, 8, 10, 12, 14, 16, 18, 20);
put_line("Caso 4: el valor no esta, se debe recorrer todo el vector");
put_line(" posicion(13, (2, 4, 6, 8, 10, 12, 14, 16, 18, 20))");
put_line(" debe ser -1 y el resultado es ");
put(posicion(13, vector3));
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
vector3 := (2, 4, 6, 8, 10, 12, 14, 16, 18, 20);
put_line("Caso 5: el valor esta, al final del vector");
put_line(" posicion(18, (2, 4, 6, 8, 10, 12, 14, 16, 18, 20))");
put_line(" debe ser 40 y el resultado es ");
put(posicion(18, vector3));
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
end prueba_posicion;
|
with System.Storage_Elements;
with Hide.BMP;
package body Hide.file_coder is
use type Posix.C_String;
procedure Encode (Source_File_Name : Posix.C_String;
Output_File_Name : Posix.C_String;
Offset : Natural;
Text : String) is
File : Posix.File;
File_Status : Posix.File_Status;
Mmap : Posix.Memory_Map;
begin
pragma Debug (Posix.Put ("Source_File_Name => ")); pragma Debug (Put_Line (-Source_File_Name));
pragma Debug (Posix.Put ("Text => ")); pragma Debug (Put_Line ( Text));
pragma Debug (Posix.Put ("Output_File_Name => ")); pragma Debug (Put_Line (-Output_File_Name));
File.Open (Source_File_Name, Posix.O_RDONLY, Posix.S_IRUSR);
if File.Is_Closed then
Put_Line ("Failed to open file: " & (-Source_File_Name));
return;
end if;
File.Get_File_Status (File_Status);
if not File_Status.Is_Valid then
Put_Line ("Failed to read file status: " & (-Source_File_Name));
return;
end if;
File.Map_Memory (Address => Posix.Nil,
Len => Posix.Unsigned_Long (File_Status.Size),
Prot => Posix.PROT_READ,
Flags => Posix.MAP_SHARED,
Offset => 0,
Memory_Map => MMap);
if not Mmap.Has_Mapping then
Put_Line ("Failed to map memory");
File.Close;
return;
end if;
declare
Info : BMP.Header with
Import => True,
Address => MMap.Mapping;
begin
if
not (Info.Signature_1 = Character'Pos ('B') and
Info.Signature_2 = Character'Pos ('M'))
then
Put_Line ("Expected signature is 'BM'");
File.Close;
return;
end if;
if Info.Size /= Integer_32 (File_Status.Size) then
Put_Line ("Expected file size is" & File_Status.Size'Image);
Put_Line ("Was specified in file" & Info.Size'Image);
File.Close;
return;
end if;
if Info.Offset /= 138 then
Put_Line ("Offset is expected to be 138 but was" & Info.Offset'Image);
File.Close;
return;
end if;
end;
declare
Info : BMP.Info with
Import => True,
Address => MMap.Mapping;
begin
if Info.Compression /= 0 then
Put_Line ("Expected compression 0 was" & Info.Compression'Image);
File.Close;
return;
end if;
declare
Src_Bytes : Posix.Byte_Array (1 .. System.Storage_Elements.Storage_Offset (File_Status.Size)) with
Import => True,
Address => MMap.Mapping;
Bytes : Posix.Byte_Array := Src_Bytes; -- To get a read/write copy.
Pixels : BMP.Image_ARGB32 (1 .. Integer (Info.Width * Info.Height)) with
Import => True,
Address => Bytes (138)'Address;
Output_File : Posix.File;
use type Posix.O_FLag;
begin
Output_File.Open (Output_File_Name, Posix.O_CREAT or Posix.O_WRONLY, Posix.S_IRUSR);
if not Output_File.Is_Open then
Put_Line ("Failed to open " & (-Output_File_Name) & " for writing");
return;
end if;
BMP.Encode (Info, Pixels, offset, Text);
Output_File.Write (Bytes);
Output_File.Close;
end;
end;
declare
I : Integer;
begin
I := MMap.Unmap_Memory;
if I /= 0 then
Put_Line ("Failed to unmap memory");
end if;
end;
File.Close;
end;
function Decode (File_Name : Posix.C_String) return String is
File : Posix.File;
File_Status : Posix.File_Status;
Mmap : Posix.Memory_Map;
begin
File.Open (File_Name, Posix.O_RDONLY, Posix.S_IRUSR);
if File.Is_Closed then
Put_Line ("Failed to open file: " & (-File_Name));
return "";
end if;
File.Get_File_Status (File_Status);
if not File_Status.Is_Valid then
Put_Line ("Failed to read file status: " & (-File_Name));
return "";
end if;
File.Map_Memory (Address => Posix.Nil,
Len => Posix.Unsigned_Long (File_Status.Size),
Prot => Posix.PROT_READ,
Flags => Posix.MAP_SHARED,
Offset => 0,
Memory_Map => MMap);
if not Mmap.Has_Mapping then
Put_Line ("Failed to map memory");
File.Close;
return "";
end if;
declare
Info : BMP.Header with
Import => True,
Address => MMap.Mapping;
begin
if
not (Info.Signature_1 = Character'Pos ('B') and
Info.Signature_2 = Character'Pos ('M'))
then
Put_Line ("Expected signature is 'BM'");
File.Close;
return "";
end if;
if Info.Size /= Integer_32 (File_Status.Size) then
Put_Line ("Expected file size is" & File_Status.Size'Image);
Put_Line ("Was specified in file" & Info.Size'Image);
File.Close;
return "";
end if;
if Info.Offset /= 138 then
Put_Line ("Offset is expected to be 138 but was" & Info.Offset'Image);
File.Close;
return "";
end if;
-- declare
-- S : constant String := Posix.Get_Line;
-- begin
-- Put_Line (S'Length'Image);
-- end;
end;
declare
Info : BMP.Info with
Import => True,
Address => MMap.Mapping;
begin
-- Put_Line (Bmp.Image (Inf));
if Info.Compression /= 0 then
Put_Line ("Expected compression 0 was" & Info.Compression'Image);
-- File.Close;
-- return;
end if;
declare
Src_Bytes : Posix.Byte_Array (1 .. System.Storage_Elements.Storage_Offset (File_Status.Size)) with
Import => True,
Address => MMap.Mapping;
Bytes : Posix.Byte_Array := Src_Bytes; -- To get a read/write copy.
Pixels : BMP.Image_ARGB32 (1 .. Integer (Info.Width * Info.Height)) with
Import => True,
Address => Bytes (138)'Address;
begin
return Ret : constant String := BMP.Decode (Info, Pixels) do
declare
I : Integer;
begin
I := MMap.Unmap_Memory;
if I /= 0 then
Put_Line ("Failed to unmap memory");
end if;
end;
File.Close;
end return;
end;
end;
end;
end hide.file_coder;
|
package FLTK.Devices is
type Device is new Wrapper with private;
private
type Device is new Wrapper with null record;
end FLTK.Devices;
|
------------------------------------------------------------------------------
-- --
-- GESTE --
-- --
-- Copyright (C) 2018 Fabien Chouteau --
-- --
-- --
-- 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 GESTE_Config; use GESTE_Config;
package GESTE is
type Pix_Point is record
X, Y : Integer;
end record;
type Pix_Rect is record
TL : Pix_Point; -- Top Left
BR : Pix_Point; -- Bottom right
end record;
-- Palette --
type Palette_Type is array (Color_Index) of Output_Color;
type Palette_Ref is access constant Palette_Type;
No_Palette : constant Palette_Ref := null;
-- Tile --
type Tile is array (0 .. Tile_Size - 1,
0 .. Tile_Size - 1)
of Color_Index;
type Tile_Array is array (Tile_Index range <>) of Tile;
type Tile_Array_Ref is access constant Tile_Array;
-- Collisions --
type Tile_Collisions is array (0 .. Tile_Size - 1,
0 .. Tile_Size - 1)
of Boolean;
type Tile_Collisions_Array is array (Tile_Index range <>)
of Tile_Collisions;
type Tile_Collisions_Array_Ref is access constant Tile_Collisions_Array;
No_Collisions : constant Tile_Collisions_Array_Ref := null;
-- Layer --
type Layer_Type is abstract tagged limited private;
function Position (This : Layer_Type) return Pix_Point;
function Width (This : Layer_Type) return Natural;
function Height (This : Layer_Type) return Natural;
procedure Move (This : in out Layer_Type;
Pt : Pix_Point);
procedure Enable_Collisions (This : in out Layer_Type;
Enable : Boolean := True);
package Layer is
subtype Instance is Layer_Type;
subtype Class is Instance'Class;
type Ref is access all Class;
type Const_Ref is access constant Class;
end Layer;
-- Engine --
type Layer_Priority is new Natural;
procedure Add (L : not null Layer.Ref;
Priority : Layer_Priority);
procedure Remove (L : not null Layer.Ref);
procedure Remove_All;
subtype Output_Buffer_Index is Natural;
type Output_Buffer is array (Output_Buffer_Index range <>) of Output_Color;
type Push_Pixels_Proc is
access procedure (Buffer : Output_Buffer);
type Set_Drawing_Area_Proc is access procedure (Area : Pix_Rect);
procedure Render_Window (Window : Pix_Rect;
Background : Output_Color;
Buffer : in out Output_Buffer;
Push_Pixels : Push_Pixels_Proc;
Set_Drawing_Area : Set_Drawing_Area_Proc);
procedure Render_All (Screen_Rect : Pix_Rect;
Background : Output_Color;
Buffer : in out Output_Buffer;
Push_Pixels : Push_Pixels_Proc;
Set_Drawing_Area : Set_Drawing_Area_Proc);
procedure Render_Dirty (Screen_Rect : Pix_Rect;
Background : Output_Color;
Buffer : in out Output_Buffer;
Push_Pixels : Push_Pixels_Proc;
Set_Drawing_Area : Set_Drawing_Area_Proc);
-- Collisions --
function Collides (Pt : Pix_Point) return Boolean;
private
subtype Coordinate is Integer;
subtype Lenght is Natural;
-- Layer --
type Layer_Type is abstract tagged limited record
Next : Layer.Ref := null;
Prev : Layer.Ref := null;
Prio : Layer_Priority := 0;
Pt : Pix_Point := (0, 0);
A_Width : Natural := 0;
A_Height : Natural := 0;
Dirty : Boolean := True;
Last_Pt : Pix_Point := (0, 0);
Collisions_Enabled : Boolean := False;
end record;
function Pix (This : Layer_Type;
Unused_X, Unused_Y : Integer)
return Output_Color
is (Transparent);
function Collides (This : Layer_Type;
Unused_X, Unused_Y : Integer)
return Boolean
is (False);
procedure Update_Size (This : in out Layer_Type)
is null;
Layer_List : Layer.Ref := null;
end GESTE;
|
pragma License (Restricted);
--
-- Copyright (C) 2020 Jesper Quorning All Rights Reserved.
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
-----------------------------------------------------------------------------
-- Output to terminal screen
--
with Ada.Text_IO;
with Ada.Strings.Unbounded;
with Commands;
with Database.Events;
with Database.Jobs;
with Navigate;
with Decoration;
with Status;
with Setup;
package body Terminal_IO is
procedure Put_Jobs is
use Ada.Text_IO;
use Navigate;
use Types;
begin
if List.Set.Is_Empty then
Put_Line ("<< No Jobs >>");
return;
end if;
for Index in List.Set.First_Index .. List.Set.Last_Index loop
declare
use Ada.Strings.Unbounded;
Pair : Ref_Pair renames List.Refs (Index);
Desc : Job_Desc renames List.Set (Index);
TITLE : String renames To_String (Desc.Title);
IS_DONE : constant Boolean := Database.Events.Is_Done (Desc.Id);
STATE : constant Status.State_Type :=
(if IS_DONE then Status.Done else Status.Fresh);
STAT : constant Status.Status_Type := (STATE, True, True);
begin
-- Current job marking
Put (Decoration.Current_Image (STAT));
-- if Desc.Id = List.Current then
-- Put (Symbols.UTF8 (Symbols.Black_Right_Pointing_Index));
-- else
-- Put (" ");
-- end if;
Put (" ");
-- Indent
for Indent in 1 .. Pair.Level loop
Put (" ");
end loop;
-- DONE star
Put (Decoration.Status_Image (STAT));
-- if Database.Events.Is_Done (Desc.Id) then
-- Put (Symbols.UTF8 (Symbols.Black_Star));
-- else
-- Put (Symbols.UTF8 (Symbols.White_Star));
-- end if;
Put (" ");
-- Reference indication
Put (String (Pair.Ref));
Put (" ");
-- Job title
Put (Decoration.Title_Image (Status => STAT,
Title => TITLE));
-- Put (Ada.Strings.Unbounded.To_String (Desc.Title));
New_Line;
end;
end loop;
end Put_Jobs;
procedure Show_Job (Job : in Types.Job_Id) is
use Ada.Text_IO, Ada.Strings.Unbounded;
Info : constant Types.Job_Info
:= Database.Jobs.Get_Job_Info (Job);
Events : constant Database.Events.Event_Lists.Vector
:= Database.Events.Get_Job_Events (Job);
Done : constant Boolean := Database.Events.Is_Done (Job);
Done_Image : constant String := Boolean'Image (Done);
begin
Put_Line (To_String (Info.Title) & " (Id" & Job'Img & ")");
Put_Line ("Parent (Id" & Info.Parent'Img & ")");
Put_Line ("Owner (" & To_String (Info.Owner) & ")");
Put_Line ("Status DONE: " & Done_Image);
New_Line;
for Event of Events loop
Put (To_String (Event.Stamp));
Put (" ");
Put (To_String (Event.Kind));
New_Line;
end loop;
end Show_Job;
procedure Put_Help is
use Ada.Text_IO;
use Ada.Strings.Unbounded;
begin
for Line of Commands.Help_Lines loop
Set_Col (1);
Put (To_String (Line.Command));
Set_Col (33);
Put_Line (To_String (Line.Comment));
end loop;
end Put_Help;
procedure Put_Error (Text : in String) is
begin
Ada.Text_IO.Put_Line (Text);
end Put_Error;
procedure Put_Banner is
use Ada.Text_IO;
use Setup;
Image : constant String :=
(Program_Name & " " &
Program_Version & " " &
Build_ISO8601_UTC);
Hline : constant String (Image'Range) := (others => '=');
begin
Put_Line (Image);
Put_Line (Hline);
Put_Line ("(type help to show help text)");
end Put_Banner;
procedure Put_Path is
begin
Ada.Text_IO.Put_Line (Navigate.Path_Image);
end Put_Path;
end Terminal_IO;
|
with Ada.Containers;
with Adda;
with Adda.Generator;
package Adda.Defaults is
use Ada.Containers;
function Hash
(Element : in Integer)
return Hash_Type;
package All_Integer is new Adda.Generator (Variable_Type => Integer,
Value_Type => Integer, Terminal_Type => Integer, Hash_Variable => Hash,
Hash_Value => Hash, Hash_Terminal => Hash);
end Adda.Defaults;
|
with Ada.Finalization;
with Interfaces; use Interfaces;
package My_Class is
type Object is
new Ada.Finalization.Limited_Controlled with private;
overriding
procedure Initialize (O : in out Object);
overriding
procedure Finalize (O : in out Object);
procedure Write (O : in Object);
-- write the object?
private
type Buffer is array (Positive range <>) of Unsigned_32;
type Buffer_Ptr is access Buffer;
type Object is
new Ada.Finalization.Limited_Controlled
with record
A : Buffer_Ptr;
end record;
end My_Class;
|
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.PINT is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ISEL_PMODE_Field is HAL.UInt8;
-- Pin Interrupt Mode register
type ISEL_Register is record
-- Selects the interrupt mode for each pin interrupt. Bit n configures
-- the pin interrupt selected in PINTSELn. 0 = Edge sensitive 1 = Level
-- sensitive
PMODE : ISEL_PMODE_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISEL_Register use record
PMODE at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype IENR_ENRL_Field is HAL.UInt8;
-- Pin interrupt level or rising edge interrupt enable register
type IENR_Register is record
-- Enables the rising edge or level interrupt for each pin interrupt.
-- Bit n configures the pin interrupt selected in PINTSELn. 0 = Disable
-- rising edge or level interrupt. 1 = Enable rising edge or level
-- interrupt.
ENRL : IENR_ENRL_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IENR_Register use record
ENRL at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype SIENR_SETENRL_Field is HAL.UInt8;
-- Pin interrupt level or rising edge interrupt set register
type SIENR_Register is record
-- Write-only. Ones written to this address set bits in the IENR, thus
-- enabling interrupts. Bit n sets bit n in the IENR register. 0 = No
-- operation. 1 = Enable rising edge or level interrupt.
SETENRL : SIENR_SETENRL_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SIENR_Register use record
SETENRL at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CIENR_CENRL_Field is HAL.UInt8;
-- Pin interrupt level (rising edge interrupt) clear register
type CIENR_Register is record
-- Write-only. Ones written to this address clear bits in the IENR, thus
-- disabling the interrupts. Bit n clears bit n in the IENR register. 0
-- = No operation. 1 = Disable rising edge or level interrupt.
CENRL : CIENR_CENRL_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIENR_Register use record
CENRL at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype IENF_ENAF_Field is HAL.UInt8;
-- Pin interrupt active level or falling edge interrupt enable register
type IENF_Register is record
-- Enables the falling edge or configures the active level interrupt for
-- each pin interrupt. Bit n configures the pin interrupt selected in
-- PINTSELn. 0 = Disable falling edge interrupt or set active interrupt
-- level LOW. 1 = Enable falling edge interrupt enabled or set active
-- interrupt level HIGH.
ENAF : IENF_ENAF_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IENF_Register use record
ENAF at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype SIENF_SETENAF_Field is HAL.UInt8;
-- Pin interrupt active level or falling edge interrupt set register
type SIENF_Register is record
-- Write-only. Ones written to this address set bits in the IENF, thus
-- enabling interrupts. Bit n sets bit n in the IENF register. 0 = No
-- operation. 1 = Select HIGH-active interrupt or enable falling edge
-- interrupt.
SETENAF : SIENF_SETENAF_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SIENF_Register use record
SETENAF at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype CIENF_CENAF_Field is HAL.UInt8;
-- Pin interrupt active level or falling edge interrupt clear register
type CIENF_Register is record
-- Write-only. Ones written to this address clears bits in the IENF,
-- thus disabling interrupts. Bit n clears bit n in the IENF register. 0
-- = No operation. 1 = LOW-active interrupt selected or falling edge
-- interrupt disabled.
CENAF : CIENF_CENAF_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIENF_Register use record
CENAF at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype RISE_RDET_Field is HAL.UInt8;
-- Pin interrupt rising edge register
type RISE_Register is record
-- Rising edge detect. Bit n detects the rising edge of the pin selected
-- in PINTSELn. Read 0: No rising edge has been detected on this pin
-- since Reset or the last time a one was written to this bit. Write 0:
-- no operation. Read 1: a rising edge has been detected since Reset or
-- the last time a one was written to this bit. Write 1: clear rising
-- edge detection for this pin.
RDET : RISE_RDET_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RISE_Register use record
RDET at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype FALL_FDET_Field is HAL.UInt8;
-- Pin interrupt falling edge register
type FALL_Register is record
-- Falling edge detect. Bit n detects the falling edge of the pin
-- selected in PINTSELn. Read 0: No falling edge has been detected on
-- this pin since Reset or the last time a one was written to this bit.
-- Write 0: no operation. Read 1: a falling edge has been detected since
-- Reset or the last time a one was written to this bit. Write 1: clear
-- falling edge detection for this pin.
FDET : FALL_FDET_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FALL_Register use record
FDET at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype IST_PSTAT_Field is HAL.UInt8;
-- Pin interrupt status register
type IST_Register is record
-- Pin interrupt status. Bit n returns the status, clears the edge
-- interrupt, or inverts the active level of the pin selected in
-- PINTSELn. Read 0: interrupt is not being requested for this interrupt
-- pin. Write 0: no operation. Read 1: interrupt is being requested for
-- this interrupt pin. Write 1 (edge-sensitive): clear rising- and
-- falling-edge detection for this pin. Write 1 (level-sensitive):
-- switch the active level for this pin (in the IENF register).
PSTAT : IST_PSTAT_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IST_Register use record
PSTAT at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Specifies whether the 8 pin interrupts are controlled by the pin
-- interrupt function or by the pattern match function.
type PMCTRL_SEL_PMATCH_Field is
(
-- Pin interrupt. Interrupts are driven in response to the standard pin
-- interrupt function.
Pin_Interrupt,
-- Pattern match. Interrupts are driven in response to pattern matches.
Pattern_Match)
with Size => 1;
for PMCTRL_SEL_PMATCH_Field use
(Pin_Interrupt => 0,
Pattern_Match => 1);
-- Enables the RXEV output to the CPU and/or to a GPIO output when the
-- specified boolean expression evaluates to true.
type PMCTRL_ENA_RXEV_Field is
(
-- Disabled. RXEV output to the CPU is disabled.
Disabled,
-- Enabled. RXEV output to the CPU is enabled.
Enabled)
with Size => 1;
for PMCTRL_ENA_RXEV_Field use
(Disabled => 0,
Enabled => 1);
subtype PMCTRL_PMAT_Field is HAL.UInt8;
-- Pattern match interrupt control register
type PMCTRL_Register is record
-- Specifies whether the 8 pin interrupts are controlled by the pin
-- interrupt function or by the pattern match function.
SEL_PMATCH : PMCTRL_SEL_PMATCH_Field := NXP_SVD.PINT.Pin_Interrupt;
-- Enables the RXEV output to the CPU and/or to a GPIO output when the
-- specified boolean expression evaluates to true.
ENA_RXEV : PMCTRL_ENA_RXEV_Field := NXP_SVD.PINT.Disabled;
-- unspecified
Reserved_2_23 : HAL.UInt22 := 16#0#;
-- This field displays the current state of pattern matches. A 1 in any
-- bit of this field indicates that the corresponding product term is
-- matched by the current state of the appropriate inputs.
PMAT : PMCTRL_PMAT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMCTRL_Register use record
SEL_PMATCH at 0 range 0 .. 0;
ENA_RXEV at 0 range 1 .. 1;
Reserved_2_23 at 0 range 2 .. 23;
PMAT at 0 range 24 .. 31;
end record;
-- Selects the input source for bit slice 0
type PMSRC_SRC0_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 0.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 0.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 0.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 0.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 0.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 0.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 0.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 0.
Input7)
with Size => 3;
for PMSRC_SRC0_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 1
type PMSRC_SRC1_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 1.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 1.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 1.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 1.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 1.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 1.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 1.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 1.
Input7)
with Size => 3;
for PMSRC_SRC1_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 2
type PMSRC_SRC2_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 2.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 2.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 2.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 2.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 2.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 2.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 2.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 2.
Input7)
with Size => 3;
for PMSRC_SRC2_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 3
type PMSRC_SRC3_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 3.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 3.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 3.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 3.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 3.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 3.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 3.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 3.
Input7)
with Size => 3;
for PMSRC_SRC3_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 4
type PMSRC_SRC4_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 4.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 4.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 4.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 4.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 4.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 4.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 4.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 4.
Input7)
with Size => 3;
for PMSRC_SRC4_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 5
type PMSRC_SRC5_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 5.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 5.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 5.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 5.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 5.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 5.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 5.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 5.
Input7)
with Size => 3;
for PMSRC_SRC5_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 6
type PMSRC_SRC6_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 6.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 6.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 6.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 6.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 6.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 6.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 6.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 6.
Input7)
with Size => 3;
for PMSRC_SRC6_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Selects the input source for bit slice 7
type PMSRC_SRC7_Field is
(
-- Input 0. Selects the pin selected in the PINTSEL0 register as the
-- source to bit slice 7.
Input0,
-- Input 1. Selects the pin selected in the PINTSEL1 register as the
-- source to bit slice 7.
Input1,
-- Input 2. Selects the pin selected in the PINTSEL2 register as the
-- source to bit slice 7.
Input2,
-- Input 3. Selects the pin selected in the PINTSEL3 register as the
-- source to bit slice 7.
Input3,
-- Input 4. Selects the pin selected in the PINTSEL4 register as the
-- source to bit slice 7.
Input4,
-- Input 5. Selects the pin selected in the PINTSEL5 register as the
-- source to bit slice 7.
Input5,
-- Input 6. Selects the pin selected in the PINTSEL6 register as the
-- source to bit slice 7.
Input6,
-- Input 7. Selects the pin selected in the PINTSEL7 register as the
-- source to bit slice 7.
Input7)
with Size => 3;
for PMSRC_SRC7_Field use
(Input0 => 0,
Input1 => 1,
Input2 => 2,
Input3 => 3,
Input4 => 4,
Input5 => 5,
Input6 => 6,
Input7 => 7);
-- Pattern match interrupt bit-slice source register
type PMSRC_Register is record
-- unspecified
Reserved_0_7 : HAL.UInt8 := 16#0#;
-- Selects the input source for bit slice 0
SRC0 : PMSRC_SRC0_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 1
SRC1 : PMSRC_SRC1_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 2
SRC2 : PMSRC_SRC2_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 3
SRC3 : PMSRC_SRC3_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 4
SRC4 : PMSRC_SRC4_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 5
SRC5 : PMSRC_SRC5_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 6
SRC6 : PMSRC_SRC6_Field := NXP_SVD.PINT.Input0;
-- Selects the input source for bit slice 7
SRC7 : PMSRC_SRC7_Field := NXP_SVD.PINT.Input0;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMSRC_Register use record
Reserved_0_7 at 0 range 0 .. 7;
SRC0 at 0 range 8 .. 10;
SRC1 at 0 range 11 .. 13;
SRC2 at 0 range 14 .. 16;
SRC3 at 0 range 17 .. 19;
SRC4 at 0 range 20 .. 22;
SRC5 at 0 range 23 .. 25;
SRC6 at 0 range 26 .. 28;
SRC7 at 0 range 29 .. 31;
end record;
-- Determines whether slice 0 is an endpoint.
type PMCFG_PROD_ENDPTS0_Field is
(
-- No effect. Slice 0 is not an endpoint.
No_Effect,
-- endpoint. Slice 0 is the endpoint of a product term (minterm). Pin
-- interrupt 0 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS0_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 1 is an endpoint.
type PMCFG_PROD_ENDPTS1_Field is
(
-- No effect. Slice 1 is not an endpoint.
No_Effect,
-- endpoint. Slice 1 is the endpoint of a product term (minterm). Pin
-- interrupt 1 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS1_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 2 is an endpoint.
type PMCFG_PROD_ENDPTS2_Field is
(
-- No effect. Slice 2 is not an endpoint.
No_Effect,
-- endpoint. Slice 2 is the endpoint of a product term (minterm). Pin
-- interrupt 2 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS2_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 3 is an endpoint.
type PMCFG_PROD_ENDPTS3_Field is
(
-- No effect. Slice 3 is not an endpoint.
No_Effect,
-- endpoint. Slice 3 is the endpoint of a product term (minterm). Pin
-- interrupt 3 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS3_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 4 is an endpoint.
type PMCFG_PROD_ENDPTS4_Field is
(
-- No effect. Slice 4 is not an endpoint.
No_Effect,
-- endpoint. Slice 4 is the endpoint of a product term (minterm). Pin
-- interrupt 4 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS4_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 5 is an endpoint.
type PMCFG_PROD_ENDPTS5_Field is
(
-- No effect. Slice 5 is not an endpoint.
No_Effect,
-- endpoint. Slice 5 is the endpoint of a product term (minterm). Pin
-- interrupt 5 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS5_Field use
(No_Effect => 0,
Endpoint => 1);
-- Determines whether slice 6 is an endpoint.
type PMCFG_PROD_ENDPTS6_Field is
(
-- No effect. Slice 6 is not an endpoint.
No_Effect,
-- endpoint. Slice 6 is the endpoint of a product term (minterm). Pin
-- interrupt 6 in the NVIC is raised if the minterm evaluates as true.
Endpoint)
with Size => 1;
for PMCFG_PROD_ENDPTS6_Field use
(No_Effect => 0,
Endpoint => 1);
-- Specifies the match contribution condition for bit slice 0.
type PMCFG_CFG0_Field is
(
-- Constant HIGH. This bit slice always contributes to a product term
-- match.
Constant_High,
-- Sticky rising edge. Match occurs if a rising edge on the specified
-- input has occurred since the last time the edge detection for this
-- bit slice was cleared. This bit is only cleared when the PMCFG or the
-- PMSRC registers are written to.
Sticky_Rising_Edge,
-- Sticky falling edge. Match occurs if a falling edge on the specified
-- input has occurred since the last time the edge detection for this
-- bit slice was cleared. This bit is only cleared when the PMCFG or the
-- PMSRC registers are written to.
Sticky_Falling_Edge,
-- Sticky rising or falling edge. Match occurs if either a rising or
-- falling edge on the specified input has occurred since the last time
-- the edge detection for this bit slice was cleared. This bit is only
-- cleared when the PMCFG or the PMSRC registers are written to.
Sticky_Rising_Falling_Edge,
-- High level. Match (for this bit slice) occurs when there is a high
-- level on the input specified for this bit slice in the PMSRC
-- register.
High_Level,
-- Low level. Match occurs when there is a low level on the specified
-- input.
Low_Level,
-- Constant 0. This bit slice never contributes to a match (should be
-- used to disable any unused bit slices).
Constant_Zero,
-- Event. Non-sticky rising or falling edge. Match occurs on an event -
-- i.e. when either a rising or falling edge is first detected on the
-- specified input (this is a non-sticky version of value 0x3) . This
-- bit is cleared after one clock cycle.
Event)
with Size => 3;
for PMCFG_CFG0_Field use
(Constant_High => 0,
Sticky_Rising_Edge => 1,
Sticky_Falling_Edge => 2,
Sticky_Rising_Falling_Edge => 3,
High_Level => 4,
Low_Level => 5,
Constant_Zero => 6,
Event => 7);
-- PMCFG_CFG array
type PMCFG_CFG_Field_Array is array (0 .. 7) of PMCFG_CFG0_Field
with Component_Size => 3, Size => 24;
-- Type definition for PMCFG_CFG
type PMCFG_CFG_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CFG as a value
Val : HAL.UInt24;
when True =>
-- CFG as an array
Arr : PMCFG_CFG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 24;
for PMCFG_CFG_Field use record
Val at 0 range 0 .. 23;
Arr at 0 range 0 .. 23;
end record;
-- Pattern match interrupt bit slice configuration register
type PMCFG_Register is record
-- Determines whether slice 0 is an endpoint.
PROD_ENDPTS0 : PMCFG_PROD_ENDPTS0_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 1 is an endpoint.
PROD_ENDPTS1 : PMCFG_PROD_ENDPTS1_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 2 is an endpoint.
PROD_ENDPTS2 : PMCFG_PROD_ENDPTS2_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 3 is an endpoint.
PROD_ENDPTS3 : PMCFG_PROD_ENDPTS3_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 4 is an endpoint.
PROD_ENDPTS4 : PMCFG_PROD_ENDPTS4_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 5 is an endpoint.
PROD_ENDPTS5 : PMCFG_PROD_ENDPTS5_Field := NXP_SVD.PINT.No_Effect;
-- Determines whether slice 6 is an endpoint.
PROD_ENDPTS6 : PMCFG_PROD_ENDPTS6_Field := NXP_SVD.PINT.No_Effect;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Specifies the match contribution condition for bit slice 0.
CFG : PMCFG_CFG_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMCFG_Register use record
PROD_ENDPTS0 at 0 range 0 .. 0;
PROD_ENDPTS1 at 0 range 1 .. 1;
PROD_ENDPTS2 at 0 range 2 .. 2;
PROD_ENDPTS3 at 0 range 3 .. 3;
PROD_ENDPTS4 at 0 range 4 .. 4;
PROD_ENDPTS5 at 0 range 5 .. 5;
PROD_ENDPTS6 at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
CFG at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Pin interrupt and pattern match (PINT)
type PINT_Peripheral is record
-- Pin Interrupt Mode register
ISEL : aliased ISEL_Register;
-- Pin interrupt level or rising edge interrupt enable register
IENR : aliased IENR_Register;
-- Pin interrupt level or rising edge interrupt set register
SIENR : aliased SIENR_Register;
-- Pin interrupt level (rising edge interrupt) clear register
CIENR : aliased CIENR_Register;
-- Pin interrupt active level or falling edge interrupt enable register
IENF : aliased IENF_Register;
-- Pin interrupt active level or falling edge interrupt set register
SIENF : aliased SIENF_Register;
-- Pin interrupt active level or falling edge interrupt clear register
CIENF : aliased CIENF_Register;
-- Pin interrupt rising edge register
RISE : aliased RISE_Register;
-- Pin interrupt falling edge register
FALL : aliased FALL_Register;
-- Pin interrupt status register
IST : aliased IST_Register;
-- Pattern match interrupt control register
PMCTRL : aliased PMCTRL_Register;
-- Pattern match interrupt bit-slice source register
PMSRC : aliased PMSRC_Register;
-- Pattern match interrupt bit slice configuration register
PMCFG : aliased PMCFG_Register;
end record
with Volatile;
for PINT_Peripheral use record
ISEL at 16#0# range 0 .. 31;
IENR at 16#4# range 0 .. 31;
SIENR at 16#8# range 0 .. 31;
CIENR at 16#C# range 0 .. 31;
IENF at 16#10# range 0 .. 31;
SIENF at 16#14# range 0 .. 31;
CIENF at 16#18# range 0 .. 31;
RISE at 16#1C# range 0 .. 31;
FALL at 16#20# range 0 .. 31;
IST at 16#24# range 0 .. 31;
PMCTRL at 16#28# range 0 .. 31;
PMSRC at 16#2C# range 0 .. 31;
PMCFG at 16#30# range 0 .. 31;
end record;
-- Pin interrupt and pattern match (PINT)
PINT_Periph : aliased PINT_Peripheral
with Import, Address => System'To_Address (16#40004000#);
-- Pin interrupt and pattern match (PINT)
SECPINT_Periph : aliased PINT_Peripheral
with Import, Address => System'To_Address (16#40005000#);
end NXP_SVD.PINT;
|
-----------------------------------------------------------------------
-- AWA.Users.Models -- AWA.Users.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-spec.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with ADO.Sessions;
with ADO.Objects;
with ADO.Statements;
with ADO.SQL;
with ADO.Schemas;
with Ada.Calendar;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with Util.Beans.Objects;
with Util.Beans.Objects.Enums;
with Util.Beans.Basic.Lists;
pragma Warnings (On);
package AWA.Users.Models is
pragma Style_Checks ("-mr");
type Key_Type is (RESET_PASSWORD_KEY, SIGNUP_KEY, INVITATION_KEY);
for Key_Type use (RESET_PASSWORD_KEY => 0, SIGNUP_KEY => 1, INVITATION_KEY => 2);
package Key_Type_Objects is
new Util.Beans.Objects.Enums (Key_Type);
type MailDeliveryStatus is (UNKNOWN, VALID, SOFT_BOUNCE, HARD_BOUNCE);
for MailDeliveryStatus use (UNKNOWN => 0, VALID => 1, SOFT_BOUNCE => 2, HARD_BOUNCE => 3);
package MailDeliveryStatus_Objects is
new Util.Beans.Objects.Enums (MailDeliveryStatus);
-- --------------------
-- The Auth_Session is created when a user is authentified.
-- The Connect_Session is created each time the user establishes a session on
-- the application. The Connect_Session is always associated with an Auth_Session.
-- --------------------
type Session_Type is (CONNECT_SESSION, AUTH_SESSION, USED_SESSION);
for Session_Type use (CONNECT_SESSION => 0, AUTH_SESSION => 1, USED_SESSION => 2);
package Session_Type_Objects is
new Util.Beans.Objects.Enums (Session_Type);
type Email_Ref is new ADO.Objects.Object_Ref with null record;
type User_Ref is new ADO.Objects.Object_Ref with null record;
type Access_Key_Ref is new ADO.Objects.Object_Ref with null record;
type Session_Ref is new ADO.Objects.Object_Ref with null record;
-- --------------------
-- The Email entity defines the user email addresses.
-- The user has a primary email address that is obtained
-- from the registration process (either through a form
-- submission or through OpenID authentication).
-- --------------------
-- Create an object key for Email.
function Email_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Email from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Email_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Email : constant Email_Ref;
function "=" (Left, Right : Email_Ref'Class) return Boolean;
-- Set the email address.
procedure Set_Email (Object : in out Email_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Email (Object : in out Email_Ref;
Value : in String);
-- Get the email address.
function Get_Email (Object : in Email_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Email (Object : in Email_Ref)
return String;
-- Set the last mail delivery status (if known).
procedure Set_Status (Object : in out Email_Ref;
Value : in AWA.Users.Models.MailDeliveryStatus);
-- Get the last mail delivery status (if known).
function Get_Status (Object : in Email_Ref)
return AWA.Users.Models.MailDeliveryStatus;
-- Set the date when the last email error was detected.
procedure Set_Last_Error_Date (Object : in out Email_Ref;
Value : in Ada.Calendar.Time);
-- Get the date when the last email error was detected.
function Get_Last_Error_Date (Object : in Email_Ref)
return Ada.Calendar.Time;
--
function Get_Version (Object : in Email_Ref)
return Integer;
-- Set the email primary key.
procedure Set_Id (Object : in out Email_Ref;
Value : in ADO.Identifier);
-- Get the email primary key.
function Get_Id (Object : in Email_Ref)
return ADO.Identifier;
-- Set the user.
procedure Set_User_Id (Object : in out Email_Ref;
Value : in ADO.Identifier);
-- Get the user.
function Get_User_Id (Object : in Email_Ref)
return ADO.Identifier;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Email_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Email_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Email_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
EMAIL_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Email_Ref);
-- Copy of the object.
procedure Copy (Object : in Email_Ref;
Into : in out Email_Ref);
-- --------------------
-- The User entity represents a user that can access and use the application.
-- --------------------
-- Create an object key for User.
function User_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for User from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function User_Key (Id : in String) return ADO.Objects.Object_Key;
Null_User : constant User_Ref;
function "=" (Left, Right : User_Ref'Class) return Boolean;
-- Set the user first name.
procedure Set_First_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_First_Name (Object : in out User_Ref;
Value : in String);
-- Get the user first name.
function Get_First_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_First_Name (Object : in User_Ref)
return String;
-- Set the user last name.
procedure Set_Last_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Last_Name (Object : in out User_Ref;
Value : in String);
-- Get the user last name.
function Get_Last_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Last_Name (Object : in User_Ref)
return String;
-- Set the user password hash.
procedure Set_Password (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Password (Object : in out User_Ref;
Value : in String);
-- Get the user password hash.
function Get_Password (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Password (Object : in User_Ref)
return String;
-- Set the user OpenID identifier.
procedure Set_Open_Id (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Open_Id (Object : in out User_Ref;
Value : in String);
-- Get the user OpenID identifier.
function Get_Open_Id (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Open_Id (Object : in User_Ref)
return String;
-- Set the user country.
procedure Set_Country (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Country (Object : in out User_Ref;
Value : in String);
-- Get the user country.
function Get_Country (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Country (Object : in User_Ref)
return String;
-- Set the user display name.
procedure Set_Name (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Name (Object : in out User_Ref;
Value : in String);
-- Get the user display name.
function Get_Name (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Name (Object : in User_Ref)
return String;
-- Get version number.
function Get_Version (Object : in User_Ref)
return Integer;
-- Set the user identifier.
procedure Set_Id (Object : in out User_Ref;
Value : in ADO.Identifier);
-- Get the user identifier.
function Get_Id (Object : in User_Ref)
return ADO.Identifier;
-- Set the password salt.
procedure Set_Salt (Object : in out User_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Salt (Object : in out User_Ref;
Value : in String);
-- Get the password salt.
function Get_Salt (Object : in User_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Salt (Object : in User_Ref)
return String;
--
procedure Set_Email (Object : in out User_Ref;
Value : in AWA.Users.Models.Email_Ref'Class);
--
function Get_Email (Object : in User_Ref)
return AWA.Users.Models.Email_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out User_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out User_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out User_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in User_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
USER_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out User_Ref);
-- Copy of the object.
procedure Copy (Object : in User_Ref;
Into : in out User_Ref);
-- Create an object key for Access_Key.
function Access_Key_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Access_Key from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Access_Key_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Access_Key : constant Access_Key_Ref;
function "=" (Left, Right : Access_Key_Ref'Class) return Boolean;
-- Set the secure access key.
procedure Set_Access_Key (Object : in out Access_Key_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Access_Key (Object : in out Access_Key_Ref;
Value : in String);
-- Get the secure access key.
function Get_Access_Key (Object : in Access_Key_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Access_Key (Object : in Access_Key_Ref)
return String;
-- Set the access key expiration date.
procedure Set_Expire_Date (Object : in out Access_Key_Ref;
Value : in Ada.Calendar.Time);
-- Get the access key expiration date.
function Get_Expire_Date (Object : in Access_Key_Ref)
return Ada.Calendar.Time;
-- Set the access key identifier.
procedure Set_Id (Object : in out Access_Key_Ref;
Value : in ADO.Identifier);
-- Get the access key identifier.
function Get_Id (Object : in Access_Key_Ref)
return ADO.Identifier;
--
function Get_Version (Object : in Access_Key_Ref)
return Integer;
-- Set the access key type.
procedure Set_Kind (Object : in out Access_Key_Ref;
Value : in AWA.Users.Models.Key_Type);
-- Get the access key type.
function Get_Kind (Object : in Access_Key_Ref)
return AWA.Users.Models.Key_Type;
--
procedure Set_User (Object : in out Access_Key_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_User (Object : in Access_Key_Ref)
return AWA.Users.Models.User_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Access_Key_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Access_Key_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
ACCESS_KEY_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Access_Key_Ref);
-- Copy of the object.
procedure Copy (Object : in Access_Key_Ref;
Into : in out Access_Key_Ref);
-- Create an object key for Session.
function Session_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key;
-- Create an object key for Session from a string.
-- Raises Constraint_Error if the string cannot be converted into the object key.
function Session_Key (Id : in String) return ADO.Objects.Object_Key;
Null_Session : constant Session_Ref;
function "=" (Left, Right : Session_Ref'Class) return Boolean;
--
procedure Set_Start_Date (Object : in out Session_Ref;
Value : in Ada.Calendar.Time);
--
function Get_Start_Date (Object : in Session_Ref)
return Ada.Calendar.Time;
--
procedure Set_End_Date (Object : in out Session_Ref;
Value : in ADO.Nullable_Time);
--
function Get_End_Date (Object : in Session_Ref)
return ADO.Nullable_Time;
--
procedure Set_Ip_Address (Object : in out Session_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Ip_Address (Object : in out Session_Ref;
Value : in String);
--
function Get_Ip_Address (Object : in Session_Ref)
return Ada.Strings.Unbounded.Unbounded_String;
function Get_Ip_Address (Object : in Session_Ref)
return String;
--
procedure Set_Stype (Object : in out Session_Ref;
Value : in AWA.Users.Models.Session_Type);
--
function Get_Stype (Object : in Session_Ref)
return AWA.Users.Models.Session_Type;
--
function Get_Version (Object : in Session_Ref)
return Integer;
--
procedure Set_Server_Id (Object : in out Session_Ref;
Value : in Integer);
--
function Get_Server_Id (Object : in Session_Ref)
return Integer;
--
procedure Set_Id (Object : in out Session_Ref;
Value : in ADO.Identifier);
--
function Get_Id (Object : in Session_Ref)
return ADO.Identifier;
--
procedure Set_Auth (Object : in out Session_Ref;
Value : in AWA.Users.Models.Session_Ref'Class);
--
function Get_Auth (Object : in Session_Ref)
return AWA.Users.Models.Session_Ref'Class;
--
procedure Set_User (Object : in out Session_Ref;
Value : in AWA.Users.Models.User_Ref'Class);
--
function Get_User (Object : in Session_Ref)
return AWA.Users.Models.User_Ref'Class;
-- Load the entity identified by 'Id'.
-- Raises the NOT_FOUND exception if it does not exist.
procedure Load (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier);
-- Load the entity identified by 'Id'.
-- Returns True in <b>Found</b> if the object was found and False if it does not exist.
procedure Load (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean);
-- Find and load the entity.
overriding
procedure Find (Object : in out Session_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
-- Save the entity. If the entity does not have an identifier, an identifier is allocated
-- and it is inserted in the table. Otherwise, only data fields which have been changed
-- are updated.
overriding
procedure Save (Object : in out Session_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
-- Delete the entity.
overriding
procedure Delete (Object : in out Session_Ref;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
function Get_Value (From : in Session_Ref;
Name : in String) return Util.Beans.Objects.Object;
-- Table definition
SESSION_TABLE : constant ADO.Schemas.Class_Mapping_Access;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Session_Ref);
-- Copy of the object.
procedure Copy (Object : in Session_Ref;
Into : in out Session_Ref);
private
EMAIL_NAME : aliased constant String := "awa_email";
COL_0_1_NAME : aliased constant String := "email";
COL_1_1_NAME : aliased constant String := "status";
COL_2_1_NAME : aliased constant String := "last_error_date";
COL_3_1_NAME : aliased constant String := "version";
COL_4_1_NAME : aliased constant String := "id";
COL_5_1_NAME : aliased constant String := "user_id";
EMAIL_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 6,
Table => EMAIL_NAME'Access,
Members => (
1 => COL_0_1_NAME'Access,
2 => COL_1_1_NAME'Access,
3 => COL_2_1_NAME'Access,
4 => COL_3_1_NAME'Access,
5 => COL_4_1_NAME'Access,
6 => COL_5_1_NAME'Access
)
);
EMAIL_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= EMAIL_DEF'Access;
Null_Email : constant Email_Ref
:= Email_Ref'(ADO.Objects.Object_Ref with null record);
type Email_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => EMAIL_DEF'Access)
with record
Email : Ada.Strings.Unbounded.Unbounded_String;
Status : AWA.Users.Models.MailDeliveryStatus;
Last_Error_Date : Ada.Calendar.Time;
Version : Integer;
User_Id : ADO.Identifier;
end record;
type Email_Access is access all Email_Impl;
overriding
procedure Destroy (Object : access Email_Impl);
overriding
procedure Find (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Email_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Email_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Email_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Email_Ref'Class;
Impl : out Email_Access);
USER_NAME : aliased constant String := "awa_user";
COL_0_2_NAME : aliased constant String := "first_name";
COL_1_2_NAME : aliased constant String := "last_name";
COL_2_2_NAME : aliased constant String := "password";
COL_3_2_NAME : aliased constant String := "open_id";
COL_4_2_NAME : aliased constant String := "country";
COL_5_2_NAME : aliased constant String := "name";
COL_6_2_NAME : aliased constant String := "version";
COL_7_2_NAME : aliased constant String := "id";
COL_8_2_NAME : aliased constant String := "salt";
COL_9_2_NAME : aliased constant String := "email_id";
USER_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 10,
Table => USER_NAME'Access,
Members => (
1 => COL_0_2_NAME'Access,
2 => COL_1_2_NAME'Access,
3 => COL_2_2_NAME'Access,
4 => COL_3_2_NAME'Access,
5 => COL_4_2_NAME'Access,
6 => COL_5_2_NAME'Access,
7 => COL_6_2_NAME'Access,
8 => COL_7_2_NAME'Access,
9 => COL_8_2_NAME'Access,
10 => COL_9_2_NAME'Access
)
);
USER_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= USER_DEF'Access;
Null_User : constant User_Ref
:= User_Ref'(ADO.Objects.Object_Ref with null record);
type User_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => USER_DEF'Access)
with record
First_Name : Ada.Strings.Unbounded.Unbounded_String;
Last_Name : Ada.Strings.Unbounded.Unbounded_String;
Password : Ada.Strings.Unbounded.Unbounded_String;
Open_Id : Ada.Strings.Unbounded.Unbounded_String;
Country : Ada.Strings.Unbounded.Unbounded_String;
Name : Ada.Strings.Unbounded.Unbounded_String;
Version : Integer;
Salt : Ada.Strings.Unbounded.Unbounded_String;
Email : AWA.Users.Models.Email_Ref;
end record;
type User_Access is access all User_Impl;
overriding
procedure Destroy (Object : access User_Impl);
overriding
procedure Find (Object : in out User_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out User_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out User_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out User_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out User_Ref'Class;
Impl : out User_Access);
ACCESS_KEY_NAME : aliased constant String := "awa_access_key";
COL_0_3_NAME : aliased constant String := "access_key";
COL_1_3_NAME : aliased constant String := "expire_date";
COL_2_3_NAME : aliased constant String := "id";
COL_3_3_NAME : aliased constant String := "version";
COL_4_3_NAME : aliased constant String := "kind";
COL_5_3_NAME : aliased constant String := "user_id";
ACCESS_KEY_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 6,
Table => ACCESS_KEY_NAME'Access,
Members => (
1 => COL_0_3_NAME'Access,
2 => COL_1_3_NAME'Access,
3 => COL_2_3_NAME'Access,
4 => COL_3_3_NAME'Access,
5 => COL_4_3_NAME'Access,
6 => COL_5_3_NAME'Access
)
);
ACCESS_KEY_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= ACCESS_KEY_DEF'Access;
Null_Access_Key : constant Access_Key_Ref
:= Access_Key_Ref'(ADO.Objects.Object_Ref with null record);
type Access_Key_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ACCESS_KEY_DEF'Access)
with record
Access_Key : Ada.Strings.Unbounded.Unbounded_String;
Expire_Date : Ada.Calendar.Time;
Version : Integer;
Kind : AWA.Users.Models.Key_Type;
User : AWA.Users.Models.User_Ref;
end record;
type Access_Key_Access is access all Access_Key_Impl;
overriding
procedure Destroy (Object : access Access_Key_Impl);
overriding
procedure Find (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Access_Key_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Access_Key_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Access_Key_Ref'Class;
Impl : out Access_Key_Access);
SESSION_NAME : aliased constant String := "awa_session";
COL_0_4_NAME : aliased constant String := "start_date";
COL_1_4_NAME : aliased constant String := "end_date";
COL_2_4_NAME : aliased constant String := "ip_address";
COL_3_4_NAME : aliased constant String := "stype";
COL_4_4_NAME : aliased constant String := "version";
COL_5_4_NAME : aliased constant String := "server_id";
COL_6_4_NAME : aliased constant String := "id";
COL_7_4_NAME : aliased constant String := "auth_id";
COL_8_4_NAME : aliased constant String := "user_id";
SESSION_DEF : aliased constant ADO.Schemas.Class_Mapping :=
(Count => 9,
Table => SESSION_NAME'Access,
Members => (
1 => COL_0_4_NAME'Access,
2 => COL_1_4_NAME'Access,
3 => COL_2_4_NAME'Access,
4 => COL_3_4_NAME'Access,
5 => COL_4_4_NAME'Access,
6 => COL_5_4_NAME'Access,
7 => COL_6_4_NAME'Access,
8 => COL_7_4_NAME'Access,
9 => COL_8_4_NAME'Access
)
);
SESSION_TABLE : constant ADO.Schemas.Class_Mapping_Access
:= SESSION_DEF'Access;
Null_Session : constant Session_Ref
:= Session_Ref'(ADO.Objects.Object_Ref with null record);
type Session_Impl is
new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER,
Of_Class => SESSION_DEF'Access)
with record
Start_Date : Ada.Calendar.Time;
End_Date : ADO.Nullable_Time;
Ip_Address : Ada.Strings.Unbounded.Unbounded_String;
Stype : AWA.Users.Models.Session_Type;
Version : Integer;
Server_Id : Integer;
Auth : AWA.Users.Models.Session_Ref;
User : AWA.Users.Models.User_Ref;
end record;
type Session_Access is access all Session_Impl;
overriding
procedure Destroy (Object : access Session_Impl);
overriding
procedure Find (Object : in out Session_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean);
overriding
procedure Load (Object : in out Session_Impl;
Session : in out ADO.Sessions.Session'Class);
procedure Load (Object : in out Session_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class);
overriding
procedure Save (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Create (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
overriding
procedure Delete (Object : in out Session_Impl;
Session : in out ADO.Sessions.Master_Session'Class);
procedure Set_Field (Object : in out Session_Ref'Class;
Impl : out Session_Access);
end AWA.Users.Models;
|
type Person (Gender : Gender_Type) is record
Name : Name_String;
Age : Natural;
Weight : Float;
Case Gender is
when Male =>
Beard_Length : Float;
when Female =>
null;
end case;
end record;
|
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Real_Time;
use Ada.Real_Time;
with Buffer;
use Buffer;
with Ada.Numerics.Discrete_Random;
procedure ProducerConsumer_prot is
N : constant Integer := 40; -- Number of produced and comsumed variables
-- Random Delays
subtype Delay_Interval is Integer range 50..250;
package Random_Delay is new Ada.Numerics.Discrete_Random (Delay_Interval);
use Random_Delay;
G : Generator;
data_box: CircularBuffer; --use protected object
task Producer;
task body Producer is
Next : Time;
begin
Next := Clock;
for I in 1..N loop
data_box.WriteBuf(I); --write to buffer
-- Next 'Release' in 50..250ms
Next := Next + Milliseconds(Random(G));
delay until Next;
end loop;
end;
task type Consumer(ID: Integer);
task body Consumer is
X: INTEGER;
begin
for I in 1..N loop
data_box.ReadBuf(X); --read from buffer
Put(Integer'Image(ID)); --display consumer ID
Put(" ");
Put_Line(Integer'Image(X)); --display data
end loop;
end;
Consumer1: Consumer(1);
Consumer2: Consumer(2);
begin -- main task
null;
end ProducerConsumer_prot;
|
-- { dg-do run }
with Ada.Text_IO; use Ada.Text_IO;
with System.Storage_Elements; use System.Storage_Elements;
procedure Task_Stack_Align is
type Align_Me is record
Value : Integer;
end record;
for Align_Me'Alignment use Standard'Maximum_Alignment;
procedure Check_Local_Alignment_From (Context : String) is
Object : Align_Me;
begin
if To_Integer (Object'Address) mod Object'Alignment /= 0 then
Put_Line ("alignment check failed in " & Context);
end if;
end;
task type T;
task body T is
begin
Check_Local_Alignment_From ("task T");
end;
Tasks : array (1 .. 50) of T;
begin
Check_Local_Alignment_From ("environment");
end;
|
with Tables;
procedure Table_Test is
My_Table : Tables.Table;
begin
... -- insert stuff in table
Sort (My_Table); -- use default sorting
Sort (My_Table, Psionic, 5, True); -- use psionic sorting by 5th column in reverse order
Sort (It => My_Table, Reverse_Ordering => True); -- use default sorting in reverse order
... -- other stuff
end Table_Test;
|
-----------------------------------------------------------------------
-- upload_servlet -- Servlet example to upload files on the server
-- Copyright (C) 2012, 2015, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Util.Streams.Pipes;
with Util.Strings;
with Servlet.Parts;
package body Upload_Servlet is
-- ------------------------------
-- Write the upload form page with an optional response message.
-- ------------------------------
procedure Write (Response : in out Responses.Response'Class;
Message : in String) is
Output : Streams.Print_Stream := Response.Get_Output_Stream;
begin
Output.Write ("<html><head><title>Upload servlet example</title></head>"
& "<style></style>"
& "<body>"
& "<h1>Upload files to identify them</h1>");
-- Display the response or some error.
if Message /= "" then
Output.Write ("<h2>" & Message & "</h2>");
end if;
-- Render the form. If we have some existing Radius or Height
-- use them to set the initial values.
Output.Write ("<p>Identifies images, PDF, tar, tar.gz, zip</p>"
& "<form method='post' enctype='multipart/form-data'>"
& "<table>"
& "<tr><td>File 1</td>"
& "<td><input type='file' size='50' name='file1' maxlength='100000'/></td>"
& "</tr><tr><td>File 2</td>"
& "<td><input type='file' size='50' name='file2' maxlength='100000'/></td>"
& "</tr><tr><td>File 3</td>"
& "<td><input type='file' size='50' name='file3' maxlength='100000'/></td>"
& "</tr>"
& "<tr><td></td><td><input type='submit' value='Identify'></input></td></tr>"
& "</table></form>"
& "</body></html>");
Response.Set_Status (Responses.SC_OK);
end Write;
-- ------------------------------
-- Called by the servlet container when a GET request is received.
-- Display the volume form page.
-- ------------------------------
procedure Do_Get (Server : in Servlet;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class) is
pragma Unreferenced (Server, Request);
begin
Write (Response, "");
end Do_Get;
-- ------------------------------
-- Execute a command and write the result to the output stream.
-- ------------------------------
procedure Execute (Command : in String;
Output : in out Streams.Print_Stream) is
use type Ada.Streams.Stream_Element_Offset;
Proc : Util.Streams.Pipes.Pipe_Stream;
Content : Ada.Streams.Stream_Element_Array (0 .. 1024);
Pos : Ada.Streams.Stream_Element_Offset;
begin
Proc.Open (Command);
loop
Proc.Read (Into => Content,
Last => Pos);
exit when Pos < 0;
Output.Write (Content (0 .. Pos));
end loop;
Proc.Close;
if Proc.Get_Exit_Status /= 0 then
Output.Write ("Command '" & Command & "' exited with code "
& Integer'Image (Proc.Get_Exit_Status));
end if;
end Execute;
-- ------------------------------
-- Guess a file type depending on a content type or a file name.
-- ------------------------------
function Get_File_Type (Content_Type : in String;
Name : in String) return File_Type is
begin
if Content_Type = "application/pdf" then
return PDF;
elsif Content_Type = "image/png" or Content_Type = "image/jpeg" then
return IMAGE;
elsif Content_Type = "image/gif" then
return IMAGE;
elsif Content_Type = "application/zip" then
return ZIP;
end if;
declare
Ext_Pos : constant Natural := Util.Strings.Rindex (Name, '.');
begin
if Ext_Pos > 0 then
if Name (Ext_Pos .. Name'Last) = ".gz" or Name (Ext_Pos .. Name'Last) = ".tgz" then
return TAR_GZ;
elsif Name (Ext_Pos .. Name'Last) = ".tar" then
return TAR;
elsif Name (Ext_Pos .. Name'Last) = ".jpg"
or Name (Ext_Pos .. Name'Last) = ".gif"
or Name (Ext_Pos .. Name'Last) = ".xbm"
or Name (Ext_Pos .. Name'Last) = ".png"
then
return IMAGE;
elsif Name (Ext_Pos .. Name'Last) = ".zip"
or Name (Ext_Pos .. Name'Last) = ".jar"
then
return ZIP;
elsif Name (Ext_Pos .. Name'Last) = ".pdf" then
return PDF;
end if;
end if;
return UNKNOWN;
end;
end Get_File_Type;
-- ------------------------------
-- Called by the servlet container when a POST request is received.
-- Receives the uploaded files and identify them using some external command.
-- ------------------------------
procedure Do_Post (Server : in Servlet;
Request : in out Requests.Request'Class;
Response : in out Responses.Response'Class) is
pragma Unreferenced (Server);
procedure Process_Part (Part : in Parts.Part'Class);
Output : Streams.Print_Stream := Response.Get_Output_Stream;
procedure Process_Part (Part : in Parts.Part'Class) is
Name : constant String := Part.Get_Name;
Content_Type : constant String := Part.Get_Content_Type;
Path : constant String := Part.Get_Local_Filename;
Kind : constant File_Type := Get_File_Type (Content_Type, Name);
begin
Output.Write ("<tr><td>Name: " & Name);
Output.Write ("</td><td>Content_Type: " & Content_Type & "</td>");
Output.Write ("<td>Path: " & Path & "</td>");
Output.Write ("<td>Length: " & Natural'Image (Part.Get_Size) & "</td>");
Output.Write ("</tr><tr><td></td><td colspan='3'><pre>");
case Kind is
when TAR_GZ =>
Execute ("tar tvzf " & Path, Output);
when TAR =>
Execute ("tar tvf " & Path, Output);
when IMAGE =>
Execute ("identify " & Path, Output);
when ZIP =>
Execute ("zipinfo " & Path, Output);
when PDF =>
Execute ("pdfinfo " & Path, Output);
when others =>
Output.Write ("Unknown file type");
end case;
Output.Write ("</pre></td></tr>");
end Process_Part;
begin
Response.Set_Content_Type ("text/html");
Output.Write ("<html><body>");
Output.Write ("<table style='width: 100%;'>");
for I in 1 .. Request.Get_Part_Count loop
Request.Process_Part (I, Process_Part'Access);
end loop;
Output.Write ("<tr><td colspan='5'><a href='upload.html'>Upload new files</a></td></tr>");
Output.Write ("</table>");
Output.Write ("</body></html>");
end Do_Post;
end Upload_Servlet;
|
with GESTE;
package Game is
procedure Game_Loop;
procedure Set_Screen_Pos (Pt : GESTE.Pix_Point);
end Game;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package umingw_secapi_h is
--*
-- * This file has no copyright assigned and is placed in the Public Domain.
-- * This file is part of the mingw-w64 runtime package.
-- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
--
-- http://msdn.microsoft.com/en-us/library/ms175759%28v=VS.100%29.aspx
-- Templates won't work in C, will break if secure API is not enabled, disabled
-- The macro _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT requires that _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
-- is also defined as 1. If _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT is defined as 1 and
-- _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES is defined as 0, the application will not perform any template overloads.
--
-- Fallback on insecure mode if not possible to know destination size at compile time, NULL is appended for strncpy
-- For *_l locale types
-- https://blogs.msdn.com/b/sdl/archive/2010/02/16/vc-2010-and-memcpy.aspx?Redirected=true
-- fallback on default implementation if we can't know the size of the destination
end umingw_secapi_h;
|
with Ada.Calendar; use Ada.Calendar;
with Ada.Containers.Generic_Array_Sort;
with Ada.Containers.Vectors;
with Ada.Exceptions;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Wide_Wide_Unbounded;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with GNAT.Traceback.Symbolic;
with GNATCOLL.JSON;
with GNATCOLL.Opt_Parse;
with GNATCOLL.VFS; use GNATCOLL.VFS;
with Langkit_Support.Adalog.Debug; use Langkit_Support.Adalog.Debug;
with Langkit_Support.Slocs; use Langkit_Support.Slocs;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Helpers; use Libadalang.Helpers;
with Libadalang.Iterators; use Libadalang.Iterators;
with Put_Title;
procedure Nameres is
package String_Vectors is new Ada.Containers.Vectors
(Positive, Unbounded_String);
package J renames GNATCOLL.JSON;
type Stats_Record is record
Nb_Files_Analyzed : Natural := 0;
Nb_Successes : Natural := 0;
Nb_Fails : Natural := 0;
Nb_Xfails : Natural := 0;
Nb_Exception_Fails : Natural := 0;
Max_Nb_Fails : Natural := 0;
File_With_Most_Fails : Unbounded_String;
end record;
procedure Merge (Stats : in out Stats_Record; Other : Stats_Record);
-- Merge data from Stats and Other into Stats
type Config_Record is record
Display_Slocs : Boolean := False;
-- Whether to display slocs for resolved names
Display_Short_Images : Boolean := False;
-- Whether to display short images for resolved names
end record;
type Reference_Kind is (Any, Subp_Call, Subp_Overriding, Type_Derivation);
-- Kind of reference for Find_All_References pragmas. Each kind leads to a
-- specific find-all-references property: see Process_Refs below for
-- associations.
type Refs_Request is record
Kind : Reference_Kind;
Target : Basic_Decl;
Imprecise_Fallback : Boolean;
Show_Slocs : Boolean;
From_Pragma : Pragma_Node;
end record;
package Refs_Request_Vectors is new Ada.Containers.Vectors
(Positive, Refs_Request);
type Job_Data_Record is record
Stats : Stats_Record;
Config : Config_Record;
Refs_Requests : Refs_Request_Vectors.Vector;
end record;
type Job_Data_Array is array (Job_ID range <>) of Job_Data_Record;
type Job_Data_Array_Access is access all Job_Data_Array;
procedure Free is new Ada.Unchecked_Deallocation
(Job_Data_Array, Job_Data_Array_Access);
Job_Data : Job_Data_Array_Access;
procedure App_Setup (Context : App_Context; Jobs : App_Job_Context_Array);
procedure Job_Setup (Context : App_Job_Context);
procedure Process_Unit (Context : App_Job_Context; Unit : Analysis_Unit);
procedure Job_Post_Process (Context : App_Job_Context);
procedure App_Post_Process
(Context : App_Context; Jobs : App_Job_Context_Array);
package App is new Libadalang.Helpers.App
(Name => "nameres",
Description =>
"Run Libadalang's name resolution on a file, set of files or project",
Enable_Parallelism => True,
App_Setup => App_Setup,
Job_Setup => Job_Setup,
Process_Unit => Process_Unit,
Job_Post_Process => Job_Post_Process,
App_Post_Process => App_Post_Process);
package Args is
use GNATCOLL.Opt_Parse;
package File_Limit is new Parse_Option
(App.Args.Parser, "-l", "--file-limit", "Stop program after N files",
Integer, Default_Val => -1);
package Discard_Errors_In_PLE is new Parse_Flag
(App.Args.Parser, "-D", "--discard-PLE-errors",
"Discard errors while constructing lexical envs");
package Quiet is new Parse_Flag
(App.Args.Parser, "-q", "--quiet", "Quiet mode (no output on stdout)");
package JSON is new Parse_Flag
(App.Args.Parser, "-J", "--json",
"JSON mode (Structured output on stdout)");
package Stats is new Parse_Flag
(App.Args.Parser, "-S", "--stats",
"Output stats at the end of analysis");
package Resolve_All is new Parse_Flag
(App.Args.Parser, "-A", "--all", "Resolve every cross reference");
package Solve_Line is new Parse_Option
(App.Args.Parser, "-L", "--solve-line", "Only analyze line N",
Natural, Default_Val => 0);
package Only_Show_Failures is new Parse_Flag
(App.Args.Parser, Long => "--only-show-failures",
Help => "Only output failures on stdout");
package Imprecise_Fallback is new Parse_Flag
(App.Args.Parser, Long => "--imprecise-fallback",
Help => "Activate fallback mechanism for name resolution");
package Disable_Operator_Resolution is new Parse_Flag
(App.Args.Parser, Long => "--disable-operator-resolution",
Help => "Do not resolve unary/binary operations");
package Dump_Envs is new Parse_Flag
(App.Args.Parser, "-E", "--dump-envs",
Help => "Dump lexical envs after populating them");
package Do_Reparse is new Parse_Flag
(App.Args.Parser,
Long => "--reparse",
Help => "Reparse units 10 times (hardening)");
package Time is new Parse_Flag
(App.Args.Parser,
Long => "--time",
Short => "-T",
Help => "Show the time it took to nameres each file. "
& "Implies --quiet so that you only have timing info");
package Timeout is new Parse_Option
(App.Args.Parser, "-t", "--timeout",
"Timeout equation solving after N steps",
Natural, Default_Val => 100_000);
package No_Lookup_Cache is new Parse_Flag
(App.Args.Parser,
Long => "--no-lookup-cache", Help => "Deactivate lookup cache");
package Trace is new Parse_Flag
(App.Args.Parser, "-T", "--trace",
Help => "Trace logic equation solving");
package Debug is new Parse_Flag
(App.Args.Parser, "-D", "--debug",
Help => "Debug logic equation solving");
end Args;
function Quiet return Boolean is
(Args.Quiet.Get or else Args.JSON.Get or else Args.Time.Get);
function Text (N : Ada_Node'Class) return String is (Image (Text (N)));
function "+" (S : String) return Unbounded_String
renames To_Unbounded_String;
function "+" (S : Unbounded_String) return String renames To_String;
function "+" (S : Unbounded_Text_Type) return Text_Type
renames To_Wide_Wide_String;
function "<" (Left, Right : Ada_Node) return Boolean is
(Sloc_Range (Left).Start_Line < Sloc_Range (Right).Start_Line);
procedure Sort is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive,
Element_Type => Ada_Node,
Array_Type => Ada_Node_Array,
"<" => "<");
function Decode_Boolean_Literal (T : Text_Type) return Boolean is
(Boolean'Wide_Wide_Value (T));
procedure Process_File
(Job_Data : in out Job_Data_Record;
Unit : Analysis_Unit;
Filename : String);
function Do_Pragma_Test (Arg : Expr) return Ada_Node_Array is
(P_Matching_Nodes (Arg));
-- Do the resolution associated to a Test pragma.
--
-- This function is here to provide a simple breakpoint location for
-- debugging sessions.
procedure New_Line;
procedure Put_Line (S : String);
procedure Put (S : String);
procedure Dump_Exception
(E : Ada.Exceptions.Exception_Occurrence;
Obj : in out J.JSON_Value);
-- Dump the exception ``E``, honoring the ``Args.No_Traceback`` flag (e.g.
-- don't show tracebacks when asked not to). If ``Obj`` is passed and
-- ``Args.JSON`` is set, also set fields in ``Obj``.
procedure Increment (Counter : in out Natural);
type Supported_Pragma is
(Ignored_Pragma, Error_In_Pragma, Pragma_Config, Pragma_Section,
Pragma_Test, Pragma_Test_Statement, Pragma_Test_Statement_UID,
Pragma_Test_Block, Pragma_Find_All_References);
type Decoded_Pragma (Kind : Supported_Pragma) is record
case Kind is
when Ignored_Pragma =>
-- Nameres does not handle this pragma
null;
when Error_In_Pragma =>
-- We had trouble decoding this pragma
Error_Sloc : Source_Location;
Error_Message : Unbounded_String;
when Pragma_Config =>
-- Tune nameres' settings
Config_Name : Unbounded_Text_Type;
Config_Expr : Expr;
when Pragma_Section =>
-- Output headlines
Section_Name : Unbounded_Text_Type;
when Pragma_Test =>
-- Run name resolution on the given expression
Test_Expr : Expr;
Test_Debug : Boolean;
when Pragma_Test_Statement
| Pragma_Test_Statement_UID
| Pragma_Test_Block
=>
-- Run name resolution on the statement that precedes this pragma.
--
-- For the UID version, but show the unique_identifying name of
-- the declarations instead of the node image. This is used in
-- case the node might change (for example in tests where we
-- resolve runtime things).
--
-- For the block version, run name resolution on all xref entry
-- points in the statement that precedes this pragma, or on the
-- whole compilation unit if top-level.
Test_Target : Ada_Node;
when Pragma_Find_All_References =>
-- Run the find-all-references property designated by Refs_Kind on
-- Refs_Target, for all loaded units. If Refs_Target is null, run
-- the find-all-reference property on all applicable nodes in this
-- unit.
Refs_Kind : Reference_Kind;
Refs_Target : Basic_Decl;
Refs_Imprecise_Fallback : Boolean;
Refs_Show_Slocs : Boolean;
end case;
end record;
function Decode_Pragma (Node : Pragma_Node) return Decoded_Pragma;
-----------
-- Merge --
-----------
procedure Merge (Stats : in out Stats_Record; Other : Stats_Record) is
begin
Stats.Nb_Files_Analyzed :=
Stats.Nb_Files_Analyzed + Other.Nb_Files_Analyzed;
Stats.Nb_Successes := Stats.Nb_Successes + Other.Nb_Successes;
Stats.Nb_Fails := Stats.Nb_Fails + Other.Nb_Fails;
Stats.Nb_Xfails := Stats.Nb_Xfails + Other.Nb_Xfails;
Stats.Nb_Exception_Fails :=
Stats.Nb_Exception_Fails + Other.Nb_Exception_Fails;
if Stats.Max_Nb_Fails < Other.Max_Nb_Fails then
Stats.Max_Nb_Fails := Other.Max_Nb_Fails;
Stats.File_With_Most_Fails := Other.File_With_Most_Fails;
end if;
end Merge;
--------------
-- New_Line --
--------------
procedure New_Line is
begin
if not Quiet then
Ada.Text_IO.New_Line;
end if;
end New_Line;
--------------
-- Put_Line --
--------------
procedure Put_Line (S : String) is begin
if not Quiet then
Ada.Text_IO.Put_Line (S);
end if;
end Put_Line;
---------
-- Put --
---------
procedure Put (S : String) is begin
if not Quiet then
Ada.Text_IO.Put (S);
end if;
end Put;
--------------------
-- Dump_Exception --
--------------------
procedure Dump_Exception
(E : Ada.Exceptions.Exception_Occurrence;
Obj : in out J.JSON_Value) is
begin
App.Dump_Exception (E);
if Args.JSON.Get then
Obj.Set_Field ("success", False);
Obj.Set_Field
("exception_message", Ada.Exceptions.Exception_Message (E));
if App.Args.Sym_Traceback.Get then
Obj.Set_Field
("exception_traceback",
GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
else
Obj.Set_Field
("exception_traceback",
Ada.Exceptions.Exception_Information (E));
end if;
Ada.Text_IO.Put_Line (Obj.Write);
end if;
end Dump_Exception;
---------------
-- Increment --
---------------
procedure Increment (Counter : in out Natural) is
begin
Counter := Counter + 1;
end Increment;
-------------------
-- Decode_Pragma --
-------------------
function Decode_Pragma (Node : Pragma_Node) return Decoded_Pragma is
Name : constant String := Text (Node.F_Id);
Untyped_Args : constant Ada_Node_Array := Node.F_Args.Children;
Args : array (Untyped_Args'Range) of Pragma_Argument_Assoc;
function Error (Message : String) return Decoded_Pragma
is ((Error_In_Pragma, Start_Sloc (Node.Sloc_Range), +Message));
-- Shortcut to build Error_In_Pragma records
function N_Args_Error (Expected : Natural) return Decoded_Pragma
is (Error ("expected " & Expected'Image & " pragma arguments, got"
& Args'Length'Image));
function N_Args_Error
(At_Least, At_Most : Natural) return Decoded_Pragma
is (Error ("expected between" & At_Least'Image & " and" & At_Most'Image
& " pragma arguments, got" & Args'Length'Image));
-- Return an Error_In_Pragma record for an unexpected number of pragma
-- arguments.
begin
for I in Untyped_Args'Range loop
Args (I) := Untyped_Args (I).As_Pragma_Argument_Assoc;
end loop;
if Name = "Config" then
if Args'Length /= 1 then
return N_Args_Error (1);
elsif Args (1).F_Id.Is_Null then
return Error ("Missing argument name");
elsif Args (1).F_Id.Kind /= Ada_Identifier then
return Error ("Argument name must be an identifier");
else
return (Pragma_Config,
To_Unbounded_Text (Args (1).F_Id.Text),
Args (1).F_Expr);
end if;
elsif Name = "Section" then
if Args'Length /= 1 then
return N_Args_Error (1);
elsif not Args (1).F_Id.Is_Null then
return Error ("No argument name allowed");
elsif Args (1).F_Expr.Kind /= Ada_String_Literal then
return Error ("Section name must be a string literal");
else
return (Pragma_Section,
To_Unbounded_Text (Args (1).F_Expr
.As_String_Literal.P_Denoted_Value));
end if;
elsif Name = "Test" then
if Args'Length not in 1 | 2 then
return N_Args_Error (1, 2);
end if;
declare
Result : Decoded_Pragma (Pragma_Test);
begin
if not Args (1).F_Id.Is_Null then
return Error ("No argument name allowed");
end if;
Result.Test_Expr := Args (1).F_Expr;
if Args'Length > 1 then
if not Args (2).F_Id.Is_Null then
return Error ("No argument name allowed");
elsif Args (2).F_Expr.Kind /= Ada_Identifier
or else Args (2).F_Expr.Text /= "Debug"
then
return Error ("When present, the second argument must be the"
& "Debug identifier");
end if;
Result.Test_Debug := True;
else
Result.Test_Debug := False;
end if;
return Result;
end;
elsif Name = "Test_Statement" then
if Args'Length /= 0 then
return N_Args_Error (0);
end if;
return (Pragma_Test_Statement, Node.Previous_Sibling);
elsif Name = "Test_Statement_UID" then
if Args'Length /= 0 then
return N_Args_Error (0);
end if;
return (Pragma_Test_Statement_UID, Node.Previous_Sibling);
elsif Name = "Test_Block" then
if Args'Length /= 0 then
return N_Args_Error (0);
end if;
declare
Parent : constant Ada_Node := Node.Parent.Parent;
Target : constant Ada_Node :=
(if Parent.Kind = Ada_Compilation_Unit
then Parent.As_Compilation_Unit.F_Body
else Node.Previous_Sibling);
begin
return (Pragma_Test_Block, Target);
end;
elsif Name = "Find_All_References" then
if Args'Length not in 1 .. 4 then
return N_Args_Error (1, 4);
end if;
declare
Result : Decoded_Pragma (Pragma_Find_All_References);
N : Positive := 1;
-- Logical index of the next positional argument to process
Target : Ada_Node := Node.Previous_Sibling;
-- Temporary to compute the find-all-refs target. By default,
-- target the declaration that precedes the pragma.
Imprecise_Fallback : Boolean renames
Result.Refs_Imprecise_Fallback;
Show_Slocs : Boolean renames Result.Refs_Show_Slocs;
begin
Imprecise_Fallback := False;
Show_Slocs := True;
for A of Args loop
if A.F_Id.Is_Null then
-- This is a positional pragma argument
case N is
when 1 =>
if A.F_Expr.Kind /= Ada_Identifier then
return Error ("Identifier expected");
end if;
declare
Name : constant Text_Type := A.F_Expr.Text;
begin
-- The first argument is the reference kind
if Name = "Any" then
Result.Refs_Kind := Any;
elsif Name = "Calls" then
Result.Refs_Kind := Subp_Call;
elsif Name = "Overrides" then
Result.Refs_Kind := Subp_Overriding;
elsif Name = "Derived" then
Result.Refs_Kind := Type_Derivation;
else
return Error
("Invalid reference kind: " & Image (Name));
end if;
end;
when 2 =>
-- The optional second argument is the find-all-refs
-- target.
case A.F_Expr.Kind is
when Ada_Identifier =>
-- Raw identifier: directive to locate the target
declare
Name : constant Text_Type := A.F_Expr.Text;
begin
if Name = "All_Decls" then
Target := No_Ada_Node;
elsif Name = "Previous_Decl" then
null;
elsif Name = "Previous_Referenced_Decl" then
-- Assume that the previous statement is a call:
-- the target is the callee.
Target := Target.As_Call_Stmt.F_Call.As_Ada_Node;
if Target.Kind = Ada_Call_Expr then
Target := Target.As_Call_Expr.F_Name
.P_Referenced_Decl.As_Ada_Node;
end if;
else
return Error ("Invalid target: " & Image (Name));
end if;
end;
when Ada_String_Literal =>
-- String literal: name of the target. Look for the
-- last declaration with this name that appears in
-- the source before this pragma.
declare
Name : constant Text_Type :=
A.F_Expr.As_String_Literal.P_Denoted_Value;
It : Traverse_Iterator'Class := Find
(Node.Unit.Root, Kind_In (Ada_Basic_Decl'First,
Ada_Basic_Decl'Last));
N : Ada_Node;
Pragma_Sloc : constant Source_Location :=
Start_Sloc (Node.Sloc_Range);
begin
Target := No_Ada_Node;
Decl_Loop : while It.Next (N)
and Start_Sloc (N.Sloc_Range) < Pragma_Sloc
loop
for DN of N.As_Basic_Decl.P_Defining_Names loop
if DN.Text = Name then
Target := N;
exit Decl_Loop;
end if;
end loop;
end loop Decl_Loop;
if Target.Is_Null then
return Error
("No declaration for " & Image (Name));
end if;
end;
when others =>
return Error ("Unexpected expression (identifier or"
& " string literal expected)");
end case;
when others =>
return Error ("Too many positional arguments");
end case;
N := N + 1;
else
-- This is a named argument. The grammar should make sure
-- that names for pragma arguments are identifiers.
declare
pragma Assert (A.F_Id.Kind = Ada_Identifier);
Name : constant Text_Type := A.F_Id.Text;
begin
if Name = "Imprecise_Fallback" then
Imprecise_Fallback := Decode_Boolean_Literal
(A.F_Expr.Text);
elsif Name = "Show_Slocs" then
Show_Slocs := Decode_Boolean_Literal
(A.F_Expr.Text);
else
return Error ("Unknown argument: " & Image (Name));
end if;
end;
end if;
end loop;
-- Make sure we received at least one positional argument
if N = 1 then
return Error ("Missing first positional argument");
end if;
Result.Refs_Target := Target.As_Basic_Decl;
return Result;
end;
else
return (Kind => Ignored_Pragma);
end if;
end Decode_Pragma;
---------------
-- App_Setup --
---------------
procedure App_Setup (Context : App_Context; Jobs : App_Job_Context_Array) is
pragma Unreferenced (Context);
begin
if Args.No_Lookup_Cache.Get then
Disable_Lookup_Cache (True);
end if;
if Args.Trace.Get then
Set_Debug_State (Trace);
elsif Args.Debug.Get then
Set_Debug_State (Step);
end if;
Job_Data := new Job_Data_Array'(Jobs'Range => (others => <>));
end App_Setup;
---------------
-- Job_Setup --
---------------
procedure Job_Setup (Context : App_Job_Context) is
Ctx : Analysis_Context renames Context.Analysis_Ctx;
begin
Ctx.Discard_Errors_In_Populate_Lexical_Env
(Args.Discard_Errors_In_PLE.Get);
Ctx.Set_Logic_Resolution_Timeout (Args.Timeout.Get);
end Job_Setup;
------------------
-- Process_Unit --
------------------
procedure Process_Unit (Context : App_Job_Context; Unit : Analysis_Unit) is
Job_Data : Job_Data_Record renames Nameres.Job_Data (Context.ID);
Basename : constant String := +Create (+Unit.Get_Filename).Base_Name;
Before, After : Time;
Time_Elapsed : Duration;
begin
if not Quiet then
Put_Title ('#', "Analyzing " & Basename);
end if;
Before := Clock;
begin
Process_File (Job_Data, Unit, Unit.Get_Filename);
exception
when E : others =>
Put_Line ("PLE failed with exception for file " & Basename);
App.Dump_Exception (E);
return;
end;
After := Clock;
Time_Elapsed := After - Before;
if Args.Time.Get then
Ada.Text_IO.Put_Line
("Time elapsed in process file for "
& Basename & ": " & Time_Elapsed'Image);
end if;
Increment (Job_Data.Stats.Nb_Files_Analyzed);
if Args.File_Limit.Get /= -1
and then Job_Data.Stats.Nb_Files_Analyzed
>= Args.File_Limit.Get
then
Abort_App ("Requested file limit reached: aborting");
end if;
end Process_Unit;
------------------
-- Process_File --
------------------
procedure Process_File
(Job_Data : in out Job_Data_Record;
Unit : Analysis_Unit;
Filename : String)
is
Nb_File_Fails : Natural := 0;
-- Number of name resolution failures not covered by XFAILs we had in
-- this file.
Config : Config_Record renames Job_Data.Config;
Empty : Boolean := True;
-- False if processing pragmas has output at least one line. True
-- otherwise.
function Is_Pragma_Node (N : Ada_Node) return Boolean is
(Kind (N) = Ada_Pragma_Node);
procedure Process_Pragma (Node : Ada_Node);
-- Decode a pragma node and run actions accordingly (trigger name
-- resolution, output a section name, ...).
procedure Resolve_Node (Node : Ada_Node; Show_Slocs : Boolean := True);
-- Run name resolution testing on Node.
--
-- This involves running P_Resolve_Names on Node, displaying resolved
-- references, updating statistics, creating a JSON report if requested,
-- etc.
function Is_Xref_Entry_Point (N : Ada_Node) return Boolean
is (P_Xref_Entry_Point (N)
and then
(Args.Solve_Line.Get = 0
or else
Natural (Sloc_Range (N).Start_Line) = Args.Solve_Line.Get));
-- Return whether we should use N as an entry point for name resolution
-- testing.
procedure Resolve_Block (Block : Ada_Node);
-- Call Resolve_Node on all xref entry points (according to
-- Is_Xref_Entry_Point) in Block except for Block itself.
--------------------
-- Process_Pragma --
--------------------
procedure Process_Pragma (Node : Ada_Node) is
P : constant Decoded_Pragma := Decode_Pragma (Node.As_Pragma_Node);
begin
case P.Kind is
when Ignored_Pragma =>
null;
when Error_In_Pragma =>
Put_Line (Image (P.Error_Sloc) & ": " & (+P.Error_Message));
Empty := False;
when Pragma_Config =>
declare
Value : constant Text_Type := Text (P.Config_Expr);
begin
if P.Config_Name = "Display_Slocs" then
Config.Display_Slocs := Decode_Boolean_Literal (Value);
elsif P.Config_Name = "Display_Short_Images" then
Config.Display_Short_Images :=
Decode_Boolean_Literal (Value);
else
raise Program_Error with
"Invalid configuration: " & Image (+P.Config_Name);
end if;
end;
when Pragma_Section =>
if not Quiet then
Put_Title ('-', Image (To_Wide_Wide_String (P.Section_Name)));
end if;
Empty := True;
when Pragma_Test =>
Trigger_Envs_Debug (P.Test_Debug);
declare
Entities : Ada_Node_Array := Do_Pragma_Test (P.Test_Expr);
begin
Put_Line (Text (P.Test_Expr) & " resolves to:");
Sort (Entities);
for E of Entities loop
Put (" " & (if Config.Display_Short_Images
then E.Short_Image
else E.Debug_Text));
if Config.Display_Slocs then
Put_Line (" at " & Image (Start_Sloc (E.Sloc_Range)));
else
New_Line;
end if;
end loop;
if Entities'Length = 0 then
Put_Line (" <none>");
end if;
end;
Empty := False;
Trigger_Envs_Debug (False);
when Pragma_Test_Statement | Pragma_Test_Statement_UID =>
Resolve_Node (Node => P.Test_Target,
Show_Slocs => P.Kind /= Pragma_Test_Statement_UID);
Empty := False;
when Pragma_Test_Block =>
Resolve_Block (P.Test_Target);
Empty := False;
when Pragma_Find_All_References =>
Job_Data.Refs_Requests.Append
((P.Refs_Kind,
P.Refs_Target,
P.Refs_Imprecise_Fallback,
P.Refs_Show_Slocs,
Node.As_Pragma_Node));
end case;
end Process_Pragma;
-------------------
-- Resolve_Block --
-------------------
procedure Resolve_Block (Block : Ada_Node) is
procedure Resolve_Entry_Point (Node : Ada_Node);
-- Callback for tree traversal in Block
-------------------------
-- Resolve_Entry_Point --
-------------------------
procedure Resolve_Entry_Point (Node : Ada_Node) is
begin
if Node /= Block then
Resolve_Node (Node);
end if;
end Resolve_Entry_Point;
It : Ada_Node_Iterators.Iterator'Class :=
Find (Block, Is_Xref_Entry_Point'Access);
begin
It.Iterate (Resolve_Entry_Point'Access);
end Resolve_Block;
------------------
-- Resolve_Node --
------------------
procedure Resolve_Node (Node : Ada_Node; Show_Slocs : Boolean := True) is
function XFAIL return Boolean;
-- If there is an XFAIL pragma for the node being resolved, show the
-- message, and return True.
function Print_Node (N : Ada_Node'Class) return Visit_Status;
-- Callback for the tree traversal in Node. Print xref info for N.
----------------
-- Print_Node --
----------------
function Print_Node (N : Ada_Node'Class) return Visit_Status is
begin
if not Quiet
and then Kind (N) in Ada_Expr
and then (Kind (N) not in Ada_Name
or else not N.As_Name.P_Is_Defining)
then
Put_Line ("Expr: " & N.Short_Image);
if Kind (N) in Ada_Name
and then
(not Args.Disable_Operator_Resolution.Get
or else not (Kind (N) in Ada_Op))
then
declare
Decl_Name : constant Defining_Name :=
N.As_Name.P_Referenced_Defining_Name
(Args.Imprecise_Fallback.Get);
Referenced_Decl_Image : constant String :=
(if Show_Slocs or else Decl_Name.Is_Null
then Image (Decl_Name)
else Image
(Decl_Name.P_Basic_Decl
.P_Unique_Identifying_Name));
begin
Put_Line (" references: " & Referenced_Decl_Image);
end;
end if;
declare
Decl : constant Base_Type_Decl :=
P_Expression_Type (As_Expr (N));
Decl_Image : constant String :=
(if Show_Slocs or else Decl.Is_Null
then Image (Decl)
else Image (Decl.P_Unique_Identifying_Name));
begin
Put_Line (" type: " & Decl_Image);
end;
end if;
return
(if (P_Xref_Entry_Point (N) and then As_Ada_Node (N) /= Node)
or else (Kind (N) in Ada_Defining_Name
and then not P_Xref_Entry_Point (N))
then Over
else Into);
end Print_Node;
-----------
-- XFAIL --
-----------
function XFAIL return Boolean is
N : constant Ada_Node := Next_Sibling (Node);
begin
if not Is_Null (N) and then Kind (N) = Ada_Pragma_Node then
if Child (N, 1).Text = "XFAIL_Nameres" then
declare
Arg : constant String_Literal :=
N.As_Pragma_Node.F_Args.Child (1)
.As_Base_Assoc.P_Assoc_Expr.As_String_Literal;
begin
if Arg.Is_Null then
raise Program_Error
with "Invalid arg for " & N.Short_Image;
end if;
Put_Line ("XFAIL: " & Image (Arg.P_Denoted_Value, False));
Put_Line ("");
end;
end if;
return True;
end if;
return False;
end XFAIL;
Verbose : constant Boolean :=
not (Quiet or else Args.Only_Show_Failures.Get);
Output_JSON : constant Boolean := Args.JSON.Get;
Dummy : Visit_Status;
Obj : aliased J.JSON_Value;
begin
-- Pre-processing output
if Output_JSON then
Obj := J.Create_Object;
Obj.Set_Field ("kind", "node_resolution");
Obj.Set_Field ("file", Filename);
Obj.Set_Field ("sloc", Image (Node.Sloc_Range));
end if;
if Verbose then
Put_Title ('*', "Resolving xrefs for node " & Node.Short_Image);
end if;
if Langkit_Support.Adalog.Debug.Debug then
Assign_Names_To_Logic_Vars (Node);
end if;
-- Perform name resolution
if P_Resolve_Names (Node) or else Args.Imprecise_Fallback.Get then
if not Args.Only_Show_Failures.Get then
Dummy := Traverse (Node, Print_Node'Access);
end if;
Increment (Job_Data.Stats.Nb_Successes);
if Output_JSON then
Obj.Set_Field ("success", True);
end if;
else
Put_Line ("Resolution failed for node " & Node.Short_Image);
if XFAIL then
Increment (Job_Data.Stats.Nb_Xfails);
else
Increment (Nb_File_Fails);
end if;
if Output_JSON then
Obj.Set_Field ("success", False);
end if;
end if;
-- Post-processing output
if Verbose then
Put_Line ("");
end if;
if Output_JSON then
Ada.Text_IO.Put_Line (Obj.Write);
end if;
exception
when E : others =>
Put_Line
("Resolution failed with exception for node "
& Node.Short_Image);
Dump_Exception (E, Obj);
if XFAIL then
Increment (Job_Data.Stats.Nb_Xfails);
else
Increment (Job_Data.Stats.Nb_Exception_Fails);
Increment (Nb_File_Fails);
end if;
end Resolve_Node;
begin
-- Make sure there is no diagnostic for this unit. If there are, print
-- them and do nothing else.
if Has_Diagnostics (Unit) then
for D of Diagnostics (Unit) loop
Put_Line (Format_GNU_Diagnostic (Unit, D));
end loop;
return;
end if;
-- Manually trigger PLE first, and if requested reparse the unit, to
-- make sure that rebuilding lexical envs works correctly.
Populate_Lexical_Env (Unit);
if Args.Do_Reparse.Get then
for I in 1 .. 10 loop
Reparse (Unit);
Populate_Lexical_Env (Unit);
end loop;
end if;
Job_Data.Config := (others => <>);
if Args.Dump_Envs.Get then
Put_Title ('-', "Dumping envs for " & Filename);
Dump_Lexical_Env (Unit);
end if;
if Args.Resolve_All.Get or Args.Solve_Line.Get /= 0 then
Resolve_Block (Root (Unit));
end if;
-- Run through all pragmas and execute the associated actions
declare
It : Traverse_Iterator'Class :=
Find (Unit.Root, Is_Pragma_Node'Access);
begin
It.Iterate (Process_Pragma'Access);
end;
if not Empty then
New_Line;
end if;
-- Update statistics
Job_Data.Stats.Nb_Fails := Job_Data.Stats.Nb_Fails + Nb_File_Fails;
if Job_Data.Stats.Max_Nb_Fails < Nb_File_Fails then
Job_Data.Stats.File_With_Most_Fails := +Filename;
Job_Data.Stats.Max_Nb_Fails := Nb_File_Fails;
end if;
end Process_File;
----------------------
-- Job_Post_Process --
----------------------
procedure Job_Post_Process (Context : App_Job_Context) is
Job_Data : Job_Data_Record renames Nameres.Job_Data (Context.ID);
Units : Analysis_Unit_Array
(1 .. Natural (Context.Units_Processed.Length));
function Is_Refs_Target
(Decl : Basic_Decl;
Kind : Reference_Kind) return Boolean
is (case Kind is
when Any => True,
when Subp_Call | Subp_Overriding => Decl.P_Is_Subprogram,
when Type_Derivation => Decl.Kind = Ada_Type_Decl);
-- Return whether Decl is a valid target for the given Kind request
procedure Process_Refs
(Target : Basic_Decl;
Kind : Reference_Kind;
Imprecise_Fallback : Boolean;
Show_Slocs : Boolean);
-- Call the find-all-reference property corresponding to Kind on Target
------------------
-- Process_Refs --
------------------
procedure Process_Refs
(Target : Basic_Decl;
Kind : Reference_Kind;
Imprecise_Fallback : Boolean;
Show_Slocs : Boolean)
is
Empty : Boolean := True;
What : constant String :=
(case Kind is
when Any => "References to ",
when Subp_Call => "Calls to ",
when Subp_Overriding => "Overridings for ",
when Type_Derivation => "Derivations for ");
function Locator (Node : Ada_Node'Class) return String;
-- Return a location string for Node suitable for test output
procedure Print_Ref (Ref : Ada_Node'Class);
-------------
-- Locator --
-------------
function Locator (Node : Ada_Node'Class) return String is
File : constant String :=
+Create (+Node.Unit.Get_Filename).Base_Name;
Sloc : constant String := Image (Node.Sloc_Range);
begin
return
"(" & File & (if Show_Slocs
then ", " & Sloc
else "") & ")";
end Locator;
---------------
-- Print_Ref --
---------------
procedure Print_Ref (Ref : Ada_Node'Class) is
Ref_Decl : Ada_Node := Ref.As_Ada_Node;
begin
-- Follow Ref's parents chain until we have an xref entry point,
-- to get meaningful references.
while not Ref_Decl.Is_Null
and then not Ref_Decl.Parent.Is_Null
and then not Ref_Decl.P_Xref_Entry_Point
loop
Ref_Decl := Ref_Decl.Parent;
end loop;
declare
Text : constant Text_Type := Ref_Decl.Text;
Text_Last : Natural := Text'Last;
begin
-- Look for the first line break in Text
for I in Text'Range loop
if Text (I) in Chars.CR | Chars.LF then
Text_Last := I - 1;
exit;
end if;
end loop;
Put_Line (" " & Image (Text (Text'First .. Text_Last)) & " "
& Locator (Ref_Decl));
end;
Empty := False;
end Print_Ref;
begin
for DN of Target.P_Defining_Names loop
Put_Line (What & DN.Debug_Text & " " & Locator (DN));
case Kind is
when Any =>
for R of DN.P_Find_All_References (Units, Imprecise_Fallback)
loop
Print_Ref (Ref (R));
end loop;
when Subp_Call =>
for R of DN.P_Find_All_Calls (Units, Imprecise_Fallback)
loop
Print_Ref (Ref (R));
end loop;
when Subp_Overriding =>
for R of DN.P_Semantic_Parent.As_Basic_Decl.P_Find_All_Overrides
(Units, Imprecise_Fallback)
loop
Print_Ref (R);
end loop;
when Type_Derivation =>
for R of DN.P_Semantic_Parent.As_Type_Decl
.P_Find_All_Derived_Types (Units, Imprecise_Fallback)
loop
Print_Ref (R);
end loop;
end case;
end loop;
if Empty then
Put_Line (" <none>");
end if;
end Process_Refs;
begin
-- Compute the list of units
for I in Units'Range loop
Units (I) := Context.Units_Processed (I);
end loop;
-- Process all Find_All_References requests
for R of Job_Data.Refs_Requests loop
if R.Target.Is_Null then
-- If there is no target, run the request on all valid targets in
-- the unit that contains the pragma.
declare
It : Traverse_Iterator'Class := Find
(R.From_Pragma.Unit.Root,
Kind_In (Ada_Basic_Decl'First, Ada_Basic_Decl'Last));
Target : Ada_Node;
T : Basic_Decl;
begin
while It.Next (Target) loop
T := Target.As_Basic_Decl;
if Is_Refs_Target (T, R.Kind) then
Process_Refs
(T, R.Kind, R.Imprecise_Fallback, R.Show_Slocs);
end if;
end loop;
end;
else
Process_Refs
(R.Target, R.Kind, R.Imprecise_Fallback, R.Show_Slocs);
end if;
end loop;
end Job_Post_Process;
----------------------
-- App_Post_Process --
----------------------
procedure App_Post_Process
(Context : App_Context; Jobs : App_Job_Context_Array)
is
pragma Unreferenced (Context);
Stats : Stats_Record;
Total : Natural;
begin
-- Aggregate statistics from all jobs
Stats := Job_Data (Jobs'First).Stats;
for I in Jobs'First + 1 .. Jobs'Last loop
Merge (Stats, Job_Data (I).Stats);
end loop;
Total := Stats.Nb_Successes + Stats.Nb_Fails + Stats.Nb_Xfails;
if Args.Stats.Get and then Total > 0 then
declare
type Percentage is delta 0.01 range 0.0 .. 0.01 * 2.0**32;
Percent_Successes : constant Percentage := Percentage
(Float (Stats.Nb_Successes) / Float (Total) * 100.0);
Percent_Failures : constant Percentage :=
Percentage (Float (Stats.Nb_Fails) / Float (Total) * 100.0);
Percent_XFAIL : constant Percentage :=
Percentage (Float (Stats.Nb_Xfails) / Float (Total) * 100.0);
begin
Put_Line ("Resolved " & Total'Image & " nodes");
Put_Line ("Of which" & Stats.Nb_Successes'Image
& " successes - " & Percent_Successes'Image & "%");
Put_Line ("Of which" & Stats.Nb_Fails'Image
& " failures - " & Percent_Failures'Image & "%");
Put_Line ("Of which" & Stats.Nb_Xfails'Image
& " XFAILS - " & Percent_XFAIL'Image & "%");
Put_Line ("File with most failures ("
& Stats.Max_Nb_Fails'Image
& "):" & (+Stats.File_With_Most_Fails));
end;
end if;
Free (Job_Data);
Put_Line ("Done.");
end App_Post_Process;
begin
App.Run;
end Nameres; |
pragma Profile (Ravenscar);
with GNAT.Command_Line;
with App;
procedure Main
is
function Run_Remote_Node
return Boolean
is
begin
loop
case GNAT.Command_Line.Getopt ("r") is
when 'r' =>
return True;
when others =>
exit;
end case;
end loop;
return False;
end Run_Remote_Node;
begin
if Run_Remote_Node then
App.Run_Remote;
else
App.Run_Local;
end if;
end Main;
|
with Text_IO;
procedure Hello_World is
begin
Text_IO.Put_line("Hello World!");
end Hello_World;
|
package Rejuvenation.Node_Locations is
type Node_Location is (No_Trivia, Trivia_On_Same_Line, All_Trivia);
-- Between two adjacent nodes in the AST, trivia
-- (i.e. white space and comment) can occur.
-- This raises the question: Where does a Node start / end?
-- No_Trivia : Trivia before / after the node is
-- not considered part of that node
-- Trivia_On_Same_Line : Trivia before / after the node
-- on the same line is considered part
-- of that node
-- All_Trivia : Trivia before / after the node is
-- considered part of that node
-- TODO: Investigate (suggestion of Arjan) is there a need
-- for the following?
-- Trivia_Until_Empty_Line: Trivia before / after the node
-- until an empty line is considered
-- part of that node
-- TODO: Investigate is there a need for the following?
-- All_Trivia_When_Keyword : when each node has all trivia
-- before and after him,
-- we will duplicate trivia.
-- E.g. "Node1; -- comment Node2;"
-- when we limit trivia to one direction (before / after node),
-- we still miss trivia (before/after) keywords e.g.
-- (if -- missed_after Condition -- missed_before then ...)
function Start_Offset (Node : Ada_Node'Class;
Before : Node_Location := No_Trivia)
return Positive;
function End_Offset (Node : Ada_Node'Class;
After : Node_Location := No_Trivia)
return Natural;
end Rejuvenation.Node_Locations;
|
-- Test program. Read bytes on the standard input as a TOML document.
--
-- If it's a valid TOML document, parse it and emit on the standard output a
-- JSON representation of it.
--
-- If it's not a valid TOML document, print an error message on the standard
-- output.
with Ada.Command_Line;
with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Interfaces;
with TOML;
with TOML.Generic_Parse;
procedure Ada_TOML_Decode is
use type TOML.Any_Value_Kind;
package Cmd renames Ada.Command_Line;
package IO renames Ada.Text_IO;
type Stdin_Stream is null record;
procedure Get
(Stream : in out Stdin_Stream; EOF : out Boolean; Byte : out Character);
-- Callback for TOML.Generic_Parse
subtype Wrapped_Kind is TOML.Any_Value_Kind
with Static_Predicate =>
Wrapped_Kind in TOML.TOML_Array .. TOML.TOML_Boolean
| TOML.TOML_Offset_Datetime | TOML.TOML_Local_Datetime
| TOML.TOML_Local_Date | TOML.TOML_Local_Time
| TOML.TOML_Float;
function Kind_Name (Kind : Wrapped_Kind) return String;
-- Return the name expected in the JSON output for the given kind
function Strip_Number (Image : String) return String;
-- If the first character in Image is a space, return the rest of Image
function Pad_Number (Image : String; Digit_Count : Positive) return String;
-- Return Strip_Number (Image) left-padded with 0 so that the result is
-- Digit_Count long.
procedure Dump_String (Value : TOML.Unbounded_UTF8_String);
-- Dump the given string as a JSON string literal
procedure Dump_Array (Value : TOML.TOML_Value)
with Pre => TOML."=" (Value.Kind, TOML.TOML_Array);
-- Dump the given TOML array as a JSON array
procedure Dump (Value : TOML.TOML_Value);
-- Dump the given TOML value using the expected JSON output format.
-- Toplevel must be true for the root table, root table children and table
-- arrays.
---------------
-- Kind_Name --
---------------
function Kind_Name (Kind : Wrapped_Kind) return String is
begin
return (case Kind is
when TOML.TOML_Array => "array",
when TOML.TOML_String => "string",
when TOML.TOML_Integer => "integer",
when TOML.TOML_Float => "float",
when TOML.TOML_Boolean => "bool",
when TOML.TOML_Offset_Datetime => "datetime",
when TOML.TOML_Local_Datetime => "datetime-local",
when TOML.TOML_Local_Date => "date-local",
when TOML.TOML_Local_Time => "time-local");
end Kind_Name;
------------------
-- Strip_Number --
------------------
function Strip_Number (Image : String) return String is
begin
if Image'Length > 0 and then Image (Image'First) = ' ' then
return Image (Image'First + 1 .. Image'Last);
else
return Image;
end if;
end Strip_Number;
----------------
-- Pad_Number --
----------------
function Pad_Number (Image : String; Digit_Count : Positive) return String
is
Result : constant String := Strip_Number (Image);
begin
pragma Assert (Result'Length <= Digit_Count);
return (Result'Length + 1 .. Digit_Count => '0') & Result;
end Pad_Number;
-----------------
-- Dump_String --
-----------------
procedure Dump_String (Value : TOML.Unbounded_UTF8_String) is
use Ada.Strings.Unbounded;
begin
IO.Put ("""");
declare
S : constant Wide_Wide_String :=
Ada.Strings.UTF_Encoding.Wide_Wide_Strings.Decode
(To_String (Value));
begin
for C of S loop
if C in '"' | '\' then
IO.Put ("\" & Character'Val (Wide_Wide_Character'Pos (C)));
elsif C in ' ' .. '~' then
IO.Put ((1 => Character'Val (Wide_Wide_Character'Pos (C))));
else
declare
use type Interfaces.Unsigned_32;
Codepoint : Interfaces.Unsigned_32 :=
Wide_Wide_Character'Pos (C);
Digits_Count : constant Positive :=
(if Codepoint <= 16#FFFF# then 4 else 8);
CP_Digits : String (1 .. Digits_Count);
begin
if Digits_Count = 4 then
IO.Put ("\u");
else
IO.Put ("\U");
end if;
for D of reverse CP_Digits loop
declare
subtype Hex_Digit is
Interfaces.Unsigned_32 range 0 .. 15;
Digit : constant Hex_Digit := Codepoint mod 16;
begin
case Digit is
when 0 .. 9 =>
D := Character'Val (Character'Pos ('0') + Digit);
when 10 .. 15 =>
D := Character'Val
(Character'Pos ('A') + Digit - 10);
end case;
Codepoint := Codepoint / 16;
end;
end loop;
IO.Put (CP_Digits);
end;
end if;
end loop;
end;
IO.Put ("""");
end Dump_String;
----------------
-- Dump_Array --
----------------
procedure Dump_Array (Value : TOML.TOML_Value) is
begin
IO.Put_Line ("[");
for I in 1 .. Value.Length loop
if I > 1 then
IO.Put_Line (",");
end if;
Dump (Value.Item (I));
end loop;
IO.Put_Line ("]");
end Dump_Array;
----------
-- Dump --
----------
procedure Dump (Value : TOML.TOML_Value) is
use all type TOML.Any_Value_Kind;
procedure Put (Datetime : TOML.Any_Local_Datetime);
procedure Put (Date : TOML.Any_Local_Date);
procedure Put (Time : TOML.Any_Local_Time);
---------
-- Put --
---------
procedure Put (Datetime : TOML.Any_Local_Datetime) is
begin
Put (Datetime.Date);
IO.Put ("T");
Put (Datetime.Time);
end Put;
procedure Put (Date : TOML.Any_Local_Date) is
begin
IO.Put (Pad_Number (Date.Year'Image, 4)
& "-" & Pad_Number (Date.Month'Image, 2)
& "-" & Pad_Number (Date.Day'Image, 2));
end Put;
procedure Put (Time : TOML.Any_Local_Time) is
use type TOML.Any_Millisecond;
begin
IO.Put (Pad_Number (Time.Hour'Image, 2)
& ":" & Pad_Number (Time.Minute'Image, 2)
& ":" & Pad_Number (Time.Second'Image, 2));
if Time.Millisecond /= 0 then
IO.Put ("." & Pad_Number (Time.Millisecond'Image, 3));
end if;
end Put;
begin
if Value.Kind = TOML_Table then
IO.Put_Line ("{");
declare
Keys : constant TOML.Key_Array := Value.Keys;
begin
for I in Keys'Range loop
if I > Keys'First then
IO.Put_Line (",");
end if;
Dump_String (Keys (I));
IO.Put_Line (":");
Dump (Value.Get (Keys (I)));
end loop;
end;
IO.Put_Line ("}");
elsif Value.Kind = TOML.TOML_Array
and then (for all I in 1 .. Value.Length =>
Value.Item (I).Kind = TOML_Table)
then
Dump_Array (Value);
else
IO.Put_Line
("{""type"": """ & Kind_Name (Value.Kind) & """, ""value"":");
case Wrapped_Kind (Value.Kind) is
when TOML_Array =>
Dump_Array (Value);
when TOML_String =>
Dump_String (Value.As_Unbounded_String);
IO.New_Line;
when TOML_Integer =>
IO.Put_Line ("""" & Strip_Number (Value.As_Integer'Image)
& """");
when TOML_Float =>
declare
V : constant TOML.Any_Float := Value.As_Float;
begin
IO.Put ("""");
case V.Kind is
when TOML.Regular =>
IO.Put (Strip_Number (V.Value'Image));
when TOML.NaN =>
IO.Put (if V.Positive then "+" else "-");
IO.Put ("nan");
when TOML.Infinity =>
IO.Put (if V.Positive then "+" else "-");
IO.Put ("inf");
end case;
IO.Put_Line ("""");
end;
when TOML_Boolean =>
if Value.As_Boolean then
IO.Put_Line ("""true""");
else
IO.Put_Line ("""false""");
end if;
when TOML_Offset_Datetime =>
declare
use type TOML.Any_Local_Offset;
V : constant TOML.Any_Offset_Datetime :=
Value.As_Offset_Datetime;
Absolute_Offset : constant TOML.Any_Local_Offset :=
(if V.Offset < 0
then -V.Offset
else V.Offset);
Hour_Offset : constant TOML.Any_Local_Offset :=
Absolute_Offset / 60;
Minute_Offset : constant TOML.Any_Local_Offset :=
Absolute_Offset mod 60;
begin
IO.Put ("""");
Put (V.Datetime);
if V.Offset = 0 and then not V.Unknown_Offset then
IO.Put ("Z");
else
if V.Offset <= 0 then
IO.Put ("-");
else
IO.Put ("+");
end if;
IO.Put (Pad_Number (Hour_Offset'Image, 2)
& ":" & Pad_Number (Minute_Offset'Image, 2));
end if;
IO.Put_Line ("""");
end;
when TOML_Local_Datetime =>
IO.Put ("""");
Put (Value.As_Local_Datetime);
IO.Put_Line ("""");
when TOML_Local_Date =>
IO.Put ("""");
Put (Value.As_Local_Date);
IO.Put_Line ("""");
when TOML_Local_Time =>
IO.Put ("""");
Put (Value.As_Local_Time);
IO.Put_Line ("""");
end case;
IO.Put_Line ("}");
end if;
end Dump;
---------
-- Get --
---------
procedure Get
(Stream : in out Stdin_Stream; EOF : out Boolean; Byte : out Character)
is
pragma Unreferenced (Stream);
Available : Boolean;
begin
IO.Get_Immediate (Byte, Available);
EOF := not Available;
exception
when IO.End_Error =>
EOF := True;
end Get;
function Parse_File is new TOML.Generic_Parse (Stdin_Stream, Get);
Stdin : Stdin_Stream := (null record);
Result : constant TOML.Read_Result := Parse_File (Stdin);
begin
if Result.Success then
Dump (Result.Value);
else
IO.Put_Line (TOML.Format_Error (Result));
Cmd.Set_Exit_Status (Cmd.Failure);
end if;
end Ada_TOML_Decode;
|
-- { dg-do run }
with System;
with Ada.Unchecked_Conversion;
with Ada.Streams; use Ada.Streams;
with Ada.Text_IO;
procedure SSO1 is
type Unsigned_Integer_4 is mod 2 ** 32;
for Unsigned_Integer_4'Size use 32;
Default_Bit_Order_Pos : constant Natural := System.Bit_Order'Pos (System.Default_Bit_Order);
Opposite_Bit_Order_Pos : constant Natural := 1 - Default_Bit_Order_Pos;
Opposite_Bit_Order : constant System.Bit_Order := System.Bit_Order'Val (Opposite_Bit_Order_Pos);
type Rec is
record
X, Y : Unsigned_Integer_4;
end record;
for Rec'Bit_Order use System.Default_Bit_Order;
for Rec'Scalar_Storage_Order use System.Default_Bit_Order;
for Rec use
record
X at 0 * 4 range 0 .. 31;
Y at 1 * 4 range 0 .. 31;
end record;
type Nested_Rec is
record
I : Unsigned_Integer_4;
R : Rec;
J : Unsigned_Integer_4;
end record;
for Nested_Rec use
record
I at 0 * 4 range 0 .. 31;
R at 1 * 4 range 0 .. 63;
J at 3 * 4 range 0 .. 31;
end record;
for Nested_Rec'Bit_Order use Opposite_Bit_Order;
for Nested_Rec'Scalar_Storage_Order use Opposite_Bit_Order;
Nr : Nested_Rec
:= (I => 1,
R => (X => 1,
Y => 1),
J => 1);
subtype Nested_Rec_As_Stream is Ada.Streams.Stream_Element_Array (1 ..16);
function To_Stream is
new Ada.Unchecked_Conversion (Nested_Rec, Nested_Rec_As_Stream);
Nr_Stream : constant Nested_Rec_As_Stream := To_Stream (Nr);
Expected : constant array (System.Bit_Order) of Nested_Rec_As_Stream :=
(System.Low_Order_First =>
(0, 0, 0, 1,
1, 0, 0, 0,
1, 0, 0, 0,
0, 0, 0, 1),
System.High_Order_First =>
(1, 0, 0, 0,
0, 0, 0, 1,
0, 0, 0, 1,
1, 0, 0, 0));
begin
if Nr_Stream /= Expected (System.Default_Bit_Order) then
raise Program_Error;
end if;
end;
|
package Callbacks is
procedure On_Change (Value : in Integer);
end Callbacks;
|
-- This spec has been automatically generated from STM32F0xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.RTC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype TR_SU_Field is STM32_SVD.UInt4;
subtype TR_ST_Field is STM32_SVD.UInt3;
subtype TR_MNU_Field is STM32_SVD.UInt4;
subtype TR_MNT_Field is STM32_SVD.UInt3;
subtype TR_HU_Field is STM32_SVD.UInt4;
subtype TR_HT_Field is STM32_SVD.UInt2;
subtype TR_PM_Field is STM32_SVD.Bit;
-- time register
type TR_Register is record
-- Second units in BCD format
SU : TR_SU_Field := 16#0#;
-- Second tens in BCD format
ST : TR_ST_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Minute units in BCD format
MNU : TR_MNU_Field := 16#0#;
-- Minute tens in BCD format
MNT : TR_MNT_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- Hour units in BCD format
HU : TR_HU_Field := 16#0#;
-- Hour tens in BCD format
HT : TR_HT_Field := 16#0#;
-- AM/PM notation
PM : TR_PM_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TR_Register use record
SU at 0 range 0 .. 3;
ST at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MNU at 0 range 8 .. 11;
MNT at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
HU at 0 range 16 .. 19;
HT at 0 range 20 .. 21;
PM at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype DR_DU_Field is STM32_SVD.UInt4;
subtype DR_DT_Field is STM32_SVD.UInt2;
subtype DR_MU_Field is STM32_SVD.UInt4;
subtype DR_MT_Field is STM32_SVD.Bit;
subtype DR_WDU_Field is STM32_SVD.UInt3;
subtype DR_YU_Field is STM32_SVD.UInt4;
subtype DR_YT_Field is STM32_SVD.UInt4;
-- date register
type DR_Register is record
-- Date units in BCD format
DU : DR_DU_Field := 16#1#;
-- Date tens in BCD format
DT : DR_DT_Field := 16#0#;
-- unspecified
Reserved_6_7 : STM32_SVD.UInt2 := 16#0#;
-- Month units in BCD format
MU : DR_MU_Field := 16#1#;
-- Month tens in BCD format
MT : DR_MT_Field := 16#0#;
-- Week day units
WDU : DR_WDU_Field := 16#1#;
-- Year units in BCD format
YU : DR_YU_Field := 16#0#;
-- Year tens in BCD format
YT : DR_YT_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DU at 0 range 0 .. 3;
DT at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
MU at 0 range 8 .. 11;
MT at 0 range 12 .. 12;
WDU at 0 range 13 .. 15;
YU at 0 range 16 .. 19;
YT at 0 range 20 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype CR_TSEDGE_Field is STM32_SVD.Bit;
subtype CR_REFCKON_Field is STM32_SVD.Bit;
subtype CR_BYPSHAD_Field is STM32_SVD.Bit;
subtype CR_FMT_Field is STM32_SVD.Bit;
subtype CR_ALRAE_Field is STM32_SVD.Bit;
subtype CR_TSE_Field is STM32_SVD.Bit;
subtype CR_ALRAIE_Field is STM32_SVD.Bit;
subtype CR_TSIE_Field is STM32_SVD.Bit;
subtype CR_ADD1H_Field is STM32_SVD.Bit;
subtype CR_SUB1H_Field is STM32_SVD.Bit;
subtype CR_BKP_Field is STM32_SVD.Bit;
subtype CR_COSEL_Field is STM32_SVD.Bit;
subtype CR_POL_Field is STM32_SVD.Bit;
subtype CR_OSEL_Field is STM32_SVD.UInt2;
subtype CR_COE_Field is STM32_SVD.Bit;
-- control register
type CR_Register is record
-- unspecified
Reserved_0_2 : STM32_SVD.UInt3 := 16#0#;
-- Time-stamp event active edge
TSEDGE : CR_TSEDGE_Field := 16#0#;
-- RTC_REFIN reference clock detection enable (50 or 60 Hz)
REFCKON : CR_REFCKON_Field := 16#0#;
-- Bypass the shadow registers
BYPSHAD : CR_BYPSHAD_Field := 16#0#;
-- Hour format
FMT : CR_FMT_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Alarm A enable
ALRAE : CR_ALRAE_Field := 16#0#;
-- unspecified
Reserved_9_10 : STM32_SVD.UInt2 := 16#0#;
-- timestamp enable
TSE : CR_TSE_Field := 16#0#;
-- Alarm A interrupt enable
ALRAIE : CR_ALRAIE_Field := 16#0#;
-- unspecified
Reserved_13_14 : STM32_SVD.UInt2 := 16#0#;
-- Time-stamp interrupt enable
TSIE : CR_TSIE_Field := 16#0#;
-- Write-only. Add 1 hour (summer time change)
ADD1H : CR_ADD1H_Field := 16#0#;
-- Write-only. Subtract 1 hour (winter time change)
SUB1H : CR_SUB1H_Field := 16#0#;
-- Backup
BKP : CR_BKP_Field := 16#0#;
-- Calibration output selection
COSEL : CR_COSEL_Field := 16#0#;
-- Output polarity
POL : CR_POL_Field := 16#0#;
-- Output selection
OSEL : CR_OSEL_Field := 16#0#;
-- Calibration output enable
COE : CR_COE_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
Reserved_0_2 at 0 range 0 .. 2;
TSEDGE at 0 range 3 .. 3;
REFCKON at 0 range 4 .. 4;
BYPSHAD at 0 range 5 .. 5;
FMT at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
ALRAE at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
TSE at 0 range 11 .. 11;
ALRAIE at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
TSIE at 0 range 15 .. 15;
ADD1H at 0 range 16 .. 16;
SUB1H at 0 range 17 .. 17;
BKP at 0 range 18 .. 18;
COSEL at 0 range 19 .. 19;
POL at 0 range 20 .. 20;
OSEL at 0 range 21 .. 22;
COE at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype ISR_ALRAWF_Field is STM32_SVD.Bit;
subtype ISR_SHPF_Field is STM32_SVD.Bit;
subtype ISR_INITS_Field is STM32_SVD.Bit;
subtype ISR_RSF_Field is STM32_SVD.Bit;
subtype ISR_INITF_Field is STM32_SVD.Bit;
subtype ISR_INIT_Field is STM32_SVD.Bit;
subtype ISR_ALRAF_Field is STM32_SVD.Bit;
subtype ISR_TSF_Field is STM32_SVD.Bit;
subtype ISR_TSOVF_Field is STM32_SVD.Bit;
subtype ISR_TAMP1F_Field is STM32_SVD.Bit;
subtype ISR_TAMP2F_Field is STM32_SVD.Bit;
subtype ISR_RECALPF_Field is STM32_SVD.Bit;
-- initialization and status register
type ISR_Register is record
-- Read-only. Alarm A write flag
ALRAWF : ISR_ALRAWF_Field := 16#1#;
-- unspecified
Reserved_1_2 : STM32_SVD.UInt2 := 16#3#;
-- Shift operation pending
SHPF : ISR_SHPF_Field := 16#0#;
-- Read-only. Initialization status flag
INITS : ISR_INITS_Field := 16#0#;
-- Registers synchronization flag
RSF : ISR_RSF_Field := 16#0#;
-- Read-only. Initialization flag
INITF : ISR_INITF_Field := 16#0#;
-- Initialization mode
INIT : ISR_INIT_Field := 16#0#;
-- Alarm A flag
ALRAF : ISR_ALRAF_Field := 16#0#;
-- unspecified
Reserved_9_10 : STM32_SVD.UInt2 := 16#0#;
-- Time-stamp flag
TSF : ISR_TSF_Field := 16#0#;
-- Time-stamp overflow flag
TSOVF : ISR_TSOVF_Field := 16#0#;
-- RTC_TAMP1 detection flag
TAMP1F : ISR_TAMP1F_Field := 16#0#;
-- RTC_TAMP2 detection flag
TAMP2F : ISR_TAMP2F_Field := 16#0#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- Read-only. Recalibration pending Flag
RECALPF : ISR_RECALPF_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
ALRAWF at 0 range 0 .. 0;
Reserved_1_2 at 0 range 1 .. 2;
SHPF at 0 range 3 .. 3;
INITS at 0 range 4 .. 4;
RSF at 0 range 5 .. 5;
INITF at 0 range 6 .. 6;
INIT at 0 range 7 .. 7;
ALRAF at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
TSF at 0 range 11 .. 11;
TSOVF at 0 range 12 .. 12;
TAMP1F at 0 range 13 .. 13;
TAMP2F at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
RECALPF at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype PRER_PREDIV_S_Field is STM32_SVD.UInt15;
subtype PRER_PREDIV_A_Field is STM32_SVD.UInt7;
-- prescaler register
type PRER_Register is record
-- Synchronous prescaler factor
PREDIV_S : PRER_PREDIV_S_Field := 16#FF#;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit := 16#0#;
-- Asynchronous prescaler factor
PREDIV_A : PRER_PREDIV_A_Field := 16#7F#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PRER_Register use record
PREDIV_S at 0 range 0 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
PREDIV_A at 0 range 16 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype ALRMAR_SU_Field is STM32_SVD.UInt4;
subtype ALRMAR_ST_Field is STM32_SVD.UInt3;
subtype ALRMAR_MSK1_Field is STM32_SVD.Bit;
subtype ALRMAR_MNU_Field is STM32_SVD.UInt4;
subtype ALRMAR_MNT_Field is STM32_SVD.UInt3;
subtype ALRMAR_MSK2_Field is STM32_SVD.Bit;
subtype ALRMAR_HU_Field is STM32_SVD.UInt4;
subtype ALRMAR_HT_Field is STM32_SVD.UInt2;
subtype ALRMAR_PM_Field is STM32_SVD.Bit;
subtype ALRMAR_MSK3_Field is STM32_SVD.Bit;
subtype ALRMAR_DU_Field is STM32_SVD.UInt4;
subtype ALRMAR_DT_Field is STM32_SVD.UInt2;
subtype ALRMAR_WDSEL_Field is STM32_SVD.Bit;
subtype ALRMAR_MSK4_Field is STM32_SVD.Bit;
-- alarm A register
type ALRMAR_Register is record
-- Second units in BCD format.
SU : ALRMAR_SU_Field := 16#0#;
-- Second tens in BCD format.
ST : ALRMAR_ST_Field := 16#0#;
-- Alarm A seconds mask
MSK1 : ALRMAR_MSK1_Field := 16#0#;
-- Minute units in BCD format.
MNU : ALRMAR_MNU_Field := 16#0#;
-- Minute tens in BCD format.
MNT : ALRMAR_MNT_Field := 16#0#;
-- Alarm A minutes mask
MSK2 : ALRMAR_MSK2_Field := 16#0#;
-- Hour units in BCD format.
HU : ALRMAR_HU_Field := 16#0#;
-- Hour tens in BCD format.
HT : ALRMAR_HT_Field := 16#0#;
-- AM/PM notation
PM : ALRMAR_PM_Field := 16#0#;
-- Alarm A hours mask
MSK3 : ALRMAR_MSK3_Field := 16#0#;
-- Date units or day in BCD format.
DU : ALRMAR_DU_Field := 16#0#;
-- Date tens in BCD format.
DT : ALRMAR_DT_Field := 16#0#;
-- Week day selection
WDSEL : ALRMAR_WDSEL_Field := 16#0#;
-- Alarm A date mask
MSK4 : ALRMAR_MSK4_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ALRMAR_Register use record
SU at 0 range 0 .. 3;
ST at 0 range 4 .. 6;
MSK1 at 0 range 7 .. 7;
MNU at 0 range 8 .. 11;
MNT at 0 range 12 .. 14;
MSK2 at 0 range 15 .. 15;
HU at 0 range 16 .. 19;
HT at 0 range 20 .. 21;
PM at 0 range 22 .. 22;
MSK3 at 0 range 23 .. 23;
DU at 0 range 24 .. 27;
DT at 0 range 28 .. 29;
WDSEL at 0 range 30 .. 30;
MSK4 at 0 range 31 .. 31;
end record;
subtype WPR_KEY_Field is STM32_SVD.Byte;
-- write protection register
type WPR_Register is record
-- Write-only. Write protection key
KEY : WPR_KEY_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for WPR_Register use record
KEY at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype SSR_SS_Field is STM32_SVD.UInt16;
-- sub second register
type SSR_Register is record
-- Read-only. Sub second value
SS : SSR_SS_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SSR_Register use record
SS at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype SHIFTR_SUBFS_Field is STM32_SVD.UInt15;
subtype SHIFTR_ADD1S_Field is STM32_SVD.Bit;
-- shift control register
type SHIFTR_Register is record
-- Write-only. Subtract a fraction of a second
SUBFS : SHIFTR_SUBFS_Field := 16#0#;
-- unspecified
Reserved_15_30 : STM32_SVD.UInt16 := 16#0#;
-- Write-only. Reserved
ADD1S : SHIFTR_ADD1S_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SHIFTR_Register use record
SUBFS at 0 range 0 .. 14;
Reserved_15_30 at 0 range 15 .. 30;
ADD1S at 0 range 31 .. 31;
end record;
subtype TSTR_SU_Field is STM32_SVD.UInt4;
subtype TSTR_ST_Field is STM32_SVD.UInt3;
subtype TSTR_MNU_Field is STM32_SVD.UInt4;
subtype TSTR_MNT_Field is STM32_SVD.UInt3;
subtype TSTR_HU_Field is STM32_SVD.UInt4;
subtype TSTR_HT_Field is STM32_SVD.UInt2;
subtype TSTR_PM_Field is STM32_SVD.Bit;
-- timestamp time register
type TSTR_Register is record
-- Read-only. Second units in BCD format.
SU : TSTR_SU_Field;
-- Read-only. Second tens in BCD format.
ST : TSTR_ST_Field;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit;
-- Read-only. Minute units in BCD format.
MNU : TSTR_MNU_Field;
-- Read-only. Minute tens in BCD format.
MNT : TSTR_MNT_Field;
-- unspecified
Reserved_15_15 : STM32_SVD.Bit;
-- Read-only. Hour units in BCD format.
HU : TSTR_HU_Field;
-- Read-only. Hour tens in BCD format.
HT : TSTR_HT_Field;
-- Read-only. AM/PM notation
PM : TSTR_PM_Field;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TSTR_Register use record
SU at 0 range 0 .. 3;
ST at 0 range 4 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MNU at 0 range 8 .. 11;
MNT at 0 range 12 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
HU at 0 range 16 .. 19;
HT at 0 range 20 .. 21;
PM at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype TSDR_DU_Field is STM32_SVD.UInt4;
subtype TSDR_DT_Field is STM32_SVD.UInt2;
subtype TSDR_MU_Field is STM32_SVD.UInt4;
subtype TSDR_MT_Field is STM32_SVD.Bit;
subtype TSDR_WDU_Field is STM32_SVD.UInt3;
-- timestamp date register
type TSDR_Register is record
-- Read-only. Date units in BCD format
DU : TSDR_DU_Field;
-- Read-only. Date tens in BCD format
DT : TSDR_DT_Field;
-- unspecified
Reserved_6_7 : STM32_SVD.UInt2;
-- Read-only. Month units in BCD format
MU : TSDR_MU_Field;
-- Read-only. Month tens in BCD format
MT : TSDR_MT_Field;
-- Read-only. Week day units
WDU : TSDR_WDU_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TSDR_Register use record
DU at 0 range 0 .. 3;
DT at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
MU at 0 range 8 .. 11;
MT at 0 range 12 .. 12;
WDU at 0 range 13 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype TSSSR_SS_Field is STM32_SVD.UInt16;
-- time-stamp sub second register
type TSSSR_Register is record
-- Read-only. Sub second value
SS : TSSSR_SS_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TSSSR_Register use record
SS at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CALR_CALM_Field is STM32_SVD.UInt9;
subtype CALR_CALW16_Field is STM32_SVD.Bit;
subtype CALR_CALW8_Field is STM32_SVD.Bit;
subtype CALR_CALP_Field is STM32_SVD.Bit;
-- calibration register
type CALR_Register is record
-- Calibration minus
CALM : CALR_CALM_Field := 16#0#;
-- unspecified
Reserved_9_12 : STM32_SVD.UInt4 := 16#0#;
-- Reserved
CALW16 : CALR_CALW16_Field := 16#0#;
-- Use a 16-second calibration cycle period
CALW8 : CALR_CALW8_Field := 16#0#;
-- Use an 8-second calibration cycle period
CALP : CALR_CALP_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CALR_Register use record
CALM at 0 range 0 .. 8;
Reserved_9_12 at 0 range 9 .. 12;
CALW16 at 0 range 13 .. 13;
CALW8 at 0 range 14 .. 14;
CALP at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype TAFCR_TAMP1E_Field is STM32_SVD.Bit;
subtype TAFCR_TAMP1TRG_Field is STM32_SVD.Bit;
subtype TAFCR_TAMPIE_Field is STM32_SVD.Bit;
subtype TAFCR_TAMP2E_Field is STM32_SVD.Bit;
subtype TAFCR_TAMP2_TRG_Field is STM32_SVD.Bit;
subtype TAFCR_TAMPTS_Field is STM32_SVD.Bit;
subtype TAFCR_TAMPFREQ_Field is STM32_SVD.UInt3;
subtype TAFCR_TAMPFLT_Field is STM32_SVD.UInt2;
subtype TAFCR_TAMP_PRCH_Field is STM32_SVD.UInt2;
subtype TAFCR_TAMP_PUDIS_Field is STM32_SVD.Bit;
subtype TAFCR_PC13VALUE_Field is STM32_SVD.Bit;
subtype TAFCR_PC13MODE_Field is STM32_SVD.Bit;
subtype TAFCR_PC14VALUE_Field is STM32_SVD.Bit;
subtype TAFCR_PC14MODE_Field is STM32_SVD.Bit;
subtype TAFCR_PC15VALUE_Field is STM32_SVD.Bit;
subtype TAFCR_PC15MODE_Field is STM32_SVD.Bit;
-- tamper and alternate function configuration register
type TAFCR_Register is record
-- RTC_TAMP1 input detection enable
TAMP1E : TAFCR_TAMP1E_Field := 16#0#;
-- Active level for RTC_TAMP1 input
TAMP1TRG : TAFCR_TAMP1TRG_Field := 16#0#;
-- Tamper interrupt enable
TAMPIE : TAFCR_TAMPIE_Field := 16#0#;
-- RTC_TAMP2 input detection enable
TAMP2E : TAFCR_TAMP2E_Field := 16#0#;
-- Active level for RTC_TAMP2 input
TAMP2_TRG : TAFCR_TAMP2_TRG_Field := 16#0#;
-- unspecified
Reserved_5_6 : STM32_SVD.UInt2 := 16#0#;
-- Activate timestamp on tamper detection event
TAMPTS : TAFCR_TAMPTS_Field := 16#0#;
-- Tamper sampling frequency
TAMPFREQ : TAFCR_TAMPFREQ_Field := 16#0#;
-- RTC_TAMPx filter count
TAMPFLT : TAFCR_TAMPFLT_Field := 16#0#;
-- RTC_TAMPx precharge duration
TAMP_PRCH : TAFCR_TAMP_PRCH_Field := 16#0#;
-- RTC_TAMPx pull-up disable
TAMP_PUDIS : TAFCR_TAMP_PUDIS_Field := 16#0#;
-- unspecified
Reserved_16_17 : STM32_SVD.UInt2 := 16#0#;
-- RTC_ALARM output type/PC13 value
PC13VALUE : TAFCR_PC13VALUE_Field := 16#0#;
-- PC13 mode
PC13MODE : TAFCR_PC13MODE_Field := 16#0#;
-- PC14 value
PC14VALUE : TAFCR_PC14VALUE_Field := 16#0#;
-- PC14 mode
PC14MODE : TAFCR_PC14MODE_Field := 16#0#;
-- PC15 value
PC15VALUE : TAFCR_PC15VALUE_Field := 16#0#;
-- PC15 mode
PC15MODE : TAFCR_PC15MODE_Field := 16#0#;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TAFCR_Register use record
TAMP1E at 0 range 0 .. 0;
TAMP1TRG at 0 range 1 .. 1;
TAMPIE at 0 range 2 .. 2;
TAMP2E at 0 range 3 .. 3;
TAMP2_TRG at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
TAMPTS at 0 range 7 .. 7;
TAMPFREQ at 0 range 8 .. 10;
TAMPFLT at 0 range 11 .. 12;
TAMP_PRCH at 0 range 13 .. 14;
TAMP_PUDIS at 0 range 15 .. 15;
Reserved_16_17 at 0 range 16 .. 17;
PC13VALUE at 0 range 18 .. 18;
PC13MODE at 0 range 19 .. 19;
PC14VALUE at 0 range 20 .. 20;
PC14MODE at 0 range 21 .. 21;
PC15VALUE at 0 range 22 .. 22;
PC15MODE at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype ALRMASSR_SS_Field is STM32_SVD.UInt15;
subtype ALRMASSR_MASKSS_Field is STM32_SVD.UInt4;
-- alarm A sub second register
type ALRMASSR_Register is record
-- Sub seconds value
SS : ALRMASSR_SS_Field := 16#0#;
-- unspecified
Reserved_15_23 : STM32_SVD.UInt9 := 16#0#;
-- Mask the most-significant bits starting at this bit
MASKSS : ALRMASSR_MASKSS_Field := 16#0#;
-- unspecified
Reserved_28_31 : STM32_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ALRMASSR_Register use record
SS at 0 range 0 .. 14;
Reserved_15_23 at 0 range 15 .. 23;
MASKSS at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Real-time clock
type RTC_Peripheral is record
-- time register
TR : aliased TR_Register;
-- date register
DR : aliased DR_Register;
-- control register
CR : aliased CR_Register;
-- initialization and status register
ISR : aliased ISR_Register;
-- prescaler register
PRER : aliased PRER_Register;
-- alarm A register
ALRMAR : aliased ALRMAR_Register;
-- write protection register
WPR : aliased WPR_Register;
-- sub second register
SSR : aliased SSR_Register;
-- shift control register
SHIFTR : aliased SHIFTR_Register;
-- timestamp time register
TSTR : aliased TSTR_Register;
-- timestamp date register
TSDR : aliased TSDR_Register;
-- time-stamp sub second register
TSSSR : aliased TSSSR_Register;
-- calibration register
CALR : aliased CALR_Register;
-- tamper and alternate function configuration register
TAFCR : aliased TAFCR_Register;
-- alarm A sub second register
ALRMASSR : aliased ALRMASSR_Register;
-- backup register
BKP0R : aliased STM32_SVD.UInt32;
-- backup register
BKP1R : aliased STM32_SVD.UInt32;
-- backup register
BKP2R : aliased STM32_SVD.UInt32;
-- backup register
BKP3R : aliased STM32_SVD.UInt32;
-- backup register
BKP4R : aliased STM32_SVD.UInt32;
end record
with Volatile;
for RTC_Peripheral use record
TR at 16#0# range 0 .. 31;
DR at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
ISR at 16#C# range 0 .. 31;
PRER at 16#10# range 0 .. 31;
ALRMAR at 16#1C# range 0 .. 31;
WPR at 16#24# range 0 .. 31;
SSR at 16#28# range 0 .. 31;
SHIFTR at 16#2C# range 0 .. 31;
TSTR at 16#30# range 0 .. 31;
TSDR at 16#34# range 0 .. 31;
TSSSR at 16#38# range 0 .. 31;
CALR at 16#3C# range 0 .. 31;
TAFCR at 16#40# range 0 .. 31;
ALRMASSR at 16#44# range 0 .. 31;
BKP0R at 16#50# range 0 .. 31;
BKP1R at 16#54# range 0 .. 31;
BKP2R at 16#58# range 0 .. 31;
BKP3R at 16#5C# range 0 .. 31;
BKP4R at 16#60# range 0 .. 31;
end record;
-- Real-time clock
RTC_Periph : aliased RTC_Peripheral
with Import, Address => System'To_Address (16#40002800#);
end STM32_SVD.RTC;
|
package Important_Dates with
SPARK_Mode => On
is
type Date_T is record
Year : Positive := Positive'First;
Month : Positive := Positive'First;
Day : Positive := Positive'First;
end record;
type Calendar_T is private;
procedure Add_Event
(Calendar : in out Calendar_T;
Description : String;
Date : Date_T);
procedure Remove_Event
(Calendar : in out Calendar_T;
Description : String;
Date : Date_T);
procedure Print_Events
(Calendar : Calendar_T;
Number_Of_Events : Positive;
Date : Date_T);
private
type Calendar_T is null record;
end Important_Dates;
|
with Suma_Divisores_Propios;
function Es_Primo(N: Integer) return Boolean is
begin
if Suma_Divisores_Propios(N) = 1 then
return True;
end if;
return False;
end Es_Primo; |
package Complex is
type Complex is
record
Re : Float := 0.0;
Im : Float := 0.0;
end record;
I : constant Complex := (0.0, 1.0);
function II return Complex;
end Complex;
|
pragma SPARK_Mode (On);
with Bounded_Dynamic_Arrays;
package Bounded_Dynamic_Strings is new Bounded_Dynamic_Arrays
(Component => Character,
List_Index => Positive,
List => String,
Default_Value => ' ');
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . I N T E R R U P T S . N A M E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This package version is specific to the x86-64
pragma Restrictions (No_Elaboration_Code);
package Ada.Interrupts.Names is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
-- On x86-64 the interrupt vector number encodes the priority of the
-- interrupt. There are 16 interrupt priority classes, each containing 16
-- interrupt vectors. The interrupt priority of the protected object
-- containing the protected handler must match the priority class of the
-- interrupt.
-- Note: Interrupt vectors used for the runtime are commented and marked as
-- such.
-- Note: Interrupt Priorties 240 and 242 are missing as they map to
-- CPU exception vectors.
IRQ_32_47_Interrupt_Priority : constant System.Interrupt_Priority := 242;
-- IRQ_32 -> Runtime: Spurious interrupt
IRQ_33 : constant Interrupt_ID := 33;
IRQ_34 : constant Interrupt_ID := 34;
IRQ_35 : constant Interrupt_ID := 35;
IRQ_36 : constant Interrupt_ID := 36;
IRQ_37 : constant Interrupt_ID := 37;
IRQ_38 : constant Interrupt_ID := 38;
IRQ_39 : constant Interrupt_ID := 39;
IRQ_40 : constant Interrupt_ID := 40;
IRQ_41 : constant Interrupt_ID := 41;
IRQ_42 : constant Interrupt_ID := 42;
IRQ_43 : constant Interrupt_ID := 43;
IRQ_44 : constant Interrupt_ID := 44;
IRQ_45 : constant Interrupt_ID := 45;
IRQ_46 : constant Interrupt_ID := 46;
IRQ_47 : constant Interrupt_ID := 47;
IRQ_48_63_Interrupt_Priority : constant System.Interrupt_Priority := 243;
IRQ_48 : constant Interrupt_ID := 48;
IRQ_49 : constant Interrupt_ID := 49;
IRQ_50 : constant Interrupt_ID := 50;
IRQ_51 : constant Interrupt_ID := 51;
IRQ_52 : constant Interrupt_ID := 52;
IRQ_53 : constant Interrupt_ID := 53;
IRQ_54 : constant Interrupt_ID := 54;
IRQ_55 : constant Interrupt_ID := 55;
IRQ_56 : constant Interrupt_ID := 56;
IRQ_57 : constant Interrupt_ID := 57;
IRQ_58 : constant Interrupt_ID := 58;
IRQ_59 : constant Interrupt_ID := 59;
IRQ_60 : constant Interrupt_ID := 60;
IRQ_61 : constant Interrupt_ID := 61;
IRQ_62 : constant Interrupt_ID := 62;
IRQ_63 : constant Interrupt_ID := 63;
IRQ_64_79_Interrupt_Priority : constant System.Interrupt_Priority := 244;
IRQ_64 : constant Interrupt_ID := 64;
IRQ_65 : constant Interrupt_ID := 65;
IRQ_66 : constant Interrupt_ID := 66;
IRQ_67 : constant Interrupt_ID := 67;
IRQ_68 : constant Interrupt_ID := 68;
IRQ_69 : constant Interrupt_ID := 69;
IRQ_70 : constant Interrupt_ID := 70;
IRQ_71 : constant Interrupt_ID := 71;
IRQ_72 : constant Interrupt_ID := 72;
IRQ_73 : constant Interrupt_ID := 73;
IRQ_74 : constant Interrupt_ID := 74;
IRQ_75 : constant Interrupt_ID := 75;
IRQ_76 : constant Interrupt_ID := 76;
IRQ_77 : constant Interrupt_ID := 77;
IRQ_78 : constant Interrupt_ID := 78;
IRQ_79 : constant Interrupt_ID := 79;
IRQ_80_95_Interrupt_Priority : constant System.Interrupt_Priority := 245;
IRQ_80 : constant Interrupt_ID := 80;
IRQ_81 : constant Interrupt_ID := 81;
IRQ_82 : constant Interrupt_ID := 82;
IRQ_83 : constant Interrupt_ID := 83;
IRQ_84 : constant Interrupt_ID := 84;
IRQ_85 : constant Interrupt_ID := 85;
IRQ_86 : constant Interrupt_ID := 86;
IRQ_87 : constant Interrupt_ID := 87;
IRQ_88 : constant Interrupt_ID := 88;
IRQ_89 : constant Interrupt_ID := 89;
IRQ_90 : constant Interrupt_ID := 90;
IRQ_91 : constant Interrupt_ID := 91;
IRQ_92 : constant Interrupt_ID := 92;
IRQ_93 : constant Interrupt_ID := 93;
IRQ_94 : constant Interrupt_ID := 94;
IRQ_95 : constant Interrupt_ID := 95;
IRQ_96_111_Interrupt_Priority : constant System.Interrupt_Priority := 246;
IRQ_96 : constant Interrupt_ID := 96;
IRQ_97 : constant Interrupt_ID := 97;
IRQ_98 : constant Interrupt_ID := 98;
IRQ_99 : constant Interrupt_ID := 99;
IRQ_100 : constant Interrupt_ID := 100;
IRQ_101 : constant Interrupt_ID := 101;
IRQ_102 : constant Interrupt_ID := 102;
IRQ_103 : constant Interrupt_ID := 103;
IRQ_104 : constant Interrupt_ID := 104;
IRQ_105 : constant Interrupt_ID := 105;
IRQ_106 : constant Interrupt_ID := 106;
IRQ_107 : constant Interrupt_ID := 107;
IRQ_108 : constant Interrupt_ID := 108;
IRQ_109 : constant Interrupt_ID := 109;
IRQ_110 : constant Interrupt_ID := 110;
IRQ_111 : constant Interrupt_ID := 111;
IRQ_112_127_Interrupt_Priority : constant System.Interrupt_Priority := 247;
IRQ_112 : constant Interrupt_ID := 112;
IRQ_113 : constant Interrupt_ID := 113;
IRQ_114 : constant Interrupt_ID := 114;
IRQ_115 : constant Interrupt_ID := 115;
IRQ_116 : constant Interrupt_ID := 116;
IRQ_117 : constant Interrupt_ID := 117;
IRQ_118 : constant Interrupt_ID := 118;
IRQ_119 : constant Interrupt_ID := 119;
IRQ_120 : constant Interrupt_ID := 120;
IRQ_121 : constant Interrupt_ID := 121;
IRQ_122 : constant Interrupt_ID := 122;
IRQ_123 : constant Interrupt_ID := 123;
IRQ_124 : constant Interrupt_ID := 124;
IRQ_125 : constant Interrupt_ID := 125;
IRQ_126 : constant Interrupt_ID := 126;
IRQ_127 : constant Interrupt_ID := 127;
IRQ_128_143_Interrupt_Priority : constant System.Interrupt_Priority := 248;
IRQ_128 : constant Interrupt_ID := 128;
IRQ_129 : constant Interrupt_ID := 129;
IRQ_130 : constant Interrupt_ID := 130;
IRQ_131 : constant Interrupt_ID := 131;
IRQ_132 : constant Interrupt_ID := 132;
IRQ_133 : constant Interrupt_ID := 133;
IRQ_134 : constant Interrupt_ID := 134;
IRQ_135 : constant Interrupt_ID := 135;
IRQ_136 : constant Interrupt_ID := 136;
IRQ_137 : constant Interrupt_ID := 137;
IRQ_138 : constant Interrupt_ID := 138;
IRQ_139 : constant Interrupt_ID := 139;
IRQ_140 : constant Interrupt_ID := 140;
IRQ_141 : constant Interrupt_ID := 141;
IRQ_142 : constant Interrupt_ID := 142;
IRQ_143 : constant Interrupt_ID := 143;
IRQ_144_159_Interrupt_Priority : constant System.Interrupt_Priority := 249;
IRQ_144 : constant Interrupt_ID := 144;
IRQ_145 : constant Interrupt_ID := 145;
IRQ_146 : constant Interrupt_ID := 146;
IRQ_147 : constant Interrupt_ID := 147;
IRQ_148 : constant Interrupt_ID := 148;
IRQ_149 : constant Interrupt_ID := 149;
IRQ_150 : constant Interrupt_ID := 150;
IRQ_151 : constant Interrupt_ID := 151;
IRQ_152 : constant Interrupt_ID := 152;
IRQ_153 : constant Interrupt_ID := 153;
IRQ_154 : constant Interrupt_ID := 154;
IRQ_155 : constant Interrupt_ID := 155;
IRQ_156 : constant Interrupt_ID := 156;
IRQ_157 : constant Interrupt_ID := 157;
IRQ_158 : constant Interrupt_ID := 158;
IRQ_159 : constant Interrupt_ID := 159;
IRQ_160_175_Interrupt_Priority : constant System.Interrupt_Priority := 250;
IRQ_160 : constant Interrupt_ID := 160;
IRQ_161 : constant Interrupt_ID := 161;
IRQ_162 : constant Interrupt_ID := 162;
IRQ_163 : constant Interrupt_ID := 163;
IRQ_164 : constant Interrupt_ID := 164;
IRQ_165 : constant Interrupt_ID := 165;
IRQ_166 : constant Interrupt_ID := 166;
IRQ_167 : constant Interrupt_ID := 167;
IRQ_168 : constant Interrupt_ID := 168;
IRQ_169 : constant Interrupt_ID := 169;
IRQ_170 : constant Interrupt_ID := 170;
IRQ_171 : constant Interrupt_ID := 171;
IRQ_172 : constant Interrupt_ID := 172;
IRQ_173 : constant Interrupt_ID := 173;
IRQ_174 : constant Interrupt_ID := 174;
IRQ_175 : constant Interrupt_ID := 175;
IRQ_176_191_Interrupt_Priority : constant System.Interrupt_Priority := 251;
IRQ_176 : constant Interrupt_ID := 176;
IRQ_177 : constant Interrupt_ID := 177;
IRQ_178 : constant Interrupt_ID := 178;
IRQ_179 : constant Interrupt_ID := 179;
IRQ_180 : constant Interrupt_ID := 180;
IRQ_181 : constant Interrupt_ID := 181;
IRQ_182 : constant Interrupt_ID := 182;
IRQ_183 : constant Interrupt_ID := 183;
IRQ_184 : constant Interrupt_ID := 184;
IRQ_185 : constant Interrupt_ID := 185;
IRQ_186 : constant Interrupt_ID := 186;
IRQ_187 : constant Interrupt_ID := 187;
IRQ_188 : constant Interrupt_ID := 188;
IRQ_189 : constant Interrupt_ID := 189;
IRQ_190 : constant Interrupt_ID := 190;
IRQ_191 : constant Interrupt_ID := 191;
IRQ_192_207_Interrupt_Priority : constant System.Interrupt_Priority := 252;
IRQ_192 : constant Interrupt_ID := 192;
IRQ_193 : constant Interrupt_ID := 193;
IRQ_194 : constant Interrupt_ID := 194;
IRQ_195 : constant Interrupt_ID := 195;
IRQ_196 : constant Interrupt_ID := 196;
IRQ_197 : constant Interrupt_ID := 197;
IRQ_198 : constant Interrupt_ID := 198;
IRQ_199 : constant Interrupt_ID := 199;
IRQ_200 : constant Interrupt_ID := 200;
IRQ_201 : constant Interrupt_ID := 201;
IRQ_202 : constant Interrupt_ID := 202;
IRQ_203 : constant Interrupt_ID := 203;
IRQ_204 : constant Interrupt_ID := 204;
IRQ_205 : constant Interrupt_ID := 205;
IRQ_206 : constant Interrupt_ID := 206;
IRQ_207 : constant Interrupt_ID := 207;
IRQ_208_223_Interrupt_Priority : constant System.Interrupt_Priority := 253;
IRQ_208 : constant Interrupt_ID := 208;
IRQ_209 : constant Interrupt_ID := 209;
IRQ_210 : constant Interrupt_ID := 210;
IRQ_211 : constant Interrupt_ID := 211;
IRQ_212 : constant Interrupt_ID := 212;
IRQ_213 : constant Interrupt_ID := 213;
IRQ_214 : constant Interrupt_ID := 214;
IRQ_215 : constant Interrupt_ID := 215;
IRQ_216 : constant Interrupt_ID := 216;
IRQ_217 : constant Interrupt_ID := 217;
IRQ_218 : constant Interrupt_ID := 218;
IRQ_219 : constant Interrupt_ID := 219;
IRQ_220 : constant Interrupt_ID := 220;
IRQ_221 : constant Interrupt_ID := 221;
IRQ_222 : constant Interrupt_ID := 222;
IRQ_223 : constant Interrupt_ID := 223;
IRQ_224_239_Interrupt_Priority : constant System.Interrupt_Priority := 254;
IRQ_224 : constant Interrupt_ID := 224;
IRQ_225 : constant Interrupt_ID := 225;
IRQ_226 : constant Interrupt_ID := 226;
IRQ_227 : constant Interrupt_ID := 227;
IRQ_228 : constant Interrupt_ID := 228;
IRQ_229 : constant Interrupt_ID := 229;
IRQ_230 : constant Interrupt_ID := 230;
IRQ_231 : constant Interrupt_ID := 231;
IRQ_232 : constant Interrupt_ID := 232;
IRQ_233 : constant Interrupt_ID := 233;
IRQ_234 : constant Interrupt_ID := 234;
IRQ_235 : constant Interrupt_ID := 235;
IRQ_236 : constant Interrupt_ID := 236;
IRQ_237 : constant Interrupt_ID := 237;
IRQ_238 : constant Interrupt_ID := 238;
IRQ_239 : constant Interrupt_ID := 239;
IRQ_240_255_Interrupt_Priority : constant System.Interrupt_Priority := 255;
IRQ_240 : constant Interrupt_ID := 240;
IRQ_241 : constant Interrupt_ID := 241;
IRQ_242 : constant Interrupt_ID := 242;
IRQ_243 : constant Interrupt_ID := 243;
IRQ_244 : constant Interrupt_ID := 244;
IRQ_245 : constant Interrupt_ID := 245;
IRQ_246 : constant Interrupt_ID := 246;
IRQ_247 : constant Interrupt_ID := 247;
IRQ_248 : constant Interrupt_ID := 248;
IRQ_249 : constant Interrupt_ID := 249;
IRQ_250 : constant Interrupt_ID := 250;
IRQ_251 : constant Interrupt_ID := 251;
IRQ_252 : constant Interrupt_ID := 252;
IRQ_253 : constant Interrupt_ID := 253;
IRQ_254 : constant Interrupt_ID := 254;
-- IRQ_255 -> Runtime: APIC Timer
end Ada.Interrupts.Names;
|
-- Generated by gperfhash
with Util.Strings.Transforms;
with Interfaces; use Interfaces;
package body Mysql.Perfect_Hash is
C : constant array (Character) of Unsigned_8 :=
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 2, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 31,
0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
P : constant array (0 .. 8) of Natural :=
(1, 2, 3, 4, 5, 6, 7, 9, 13);
T1 : constant array (0 .. 8, Unsigned_8 range 0 .. 31) of Unsigned_16 :=
((54, 398, 393, 33, 16, 243, 125, 331, 154, 49, 229, 271, 138, 252, 32,
107, 282, 38, 401, 127, 287, 15, 47, 386, 77, 164, 48, 268, 67, 373,
106, 405),
(277, 121, 284, 221, 268, 319, 52, 298, 446, 6, 375, 363, 158, 332,
427, 288, 289, 374, 293, 164, 170, 16, 117, 197, 140, 165, 334, 22,
430, 34, 237, 263),
(201, 445, 317, 37, 452, 376, 94, 398, 117, 318, 58, 353, 43, 164, 267,
82, 150, 175, 305, 304, 328, 430, 353, 272, 99, 440, 288, 82, 274,
416, 309, 176),
(228, 167, 432, 313, 192, 170, 88, 229, 88, 178, 242, 354, 207, 410,
220, 17, 390, 157, 15, 398, 16, 340, 227, 202, 381, 313, 249, 398, 57,
101, 212, 156),
(276, 430, 314, 22, 188, 328, 26, 57, 338, 78, 405, 270, 2, 10, 442,
395, 277, 17, 1, 19, 81, 368, 452, 61, 282, 400, 410, 78, 413, 291,
236, 395),
(113, 448, 115, 47, 40, 169, 431, 368, 200, 106, 190, 20, 279, 184,
376, 448, 11, 261, 172, 300, 209, 368, 123, 132, 323, 299, 222, 154,
94, 176, 447, 396),
(38, 1, 198, 36, 413, 4, 55, 295, 408, 305, 15, 383, 330, 179, 130,
187, 386, 35, 119, 137, 338, 375, 26, 225, 339, 139, 401, 185, 254,
41, 211, 377),
(193, 364, 266, 418, 82, 399, 22, 249, 15, 371, 367, 29, 402, 431, 56,
326, 400, 109, 68, 169, 339, 416, 317, 301, 209, 135, 179, 324, 257,
248, 94, 352),
(113, 96, 296, 112, 370, 267, 317, 417, 381, 274, 161, 178, 248, 361,
89, 417, 319, 441, 125, 289, 419, 44, 418, 215, 88, 37, 228, 432, 132,
115, 283, 100));
T2 : constant array (0 .. 8, Unsigned_8 range 0 .. 31) of Unsigned_16 :=
((70, 80, 89, 274, 219, 201, 194, 400, 360, 38, 232, 55, 311, 252, 351,
362, 252, 45, 435, 302, 189, 4, 96, 274, 133, 426, 43, 196, 277, 211,
185, 115),
(193, 51, 164, 375, 252, 260, 50, 445, 15, 38, 66, 11, 240, 101, 24,
28, 378, 221, 82, 62, 145, 163, 444, 363, 410, 183, 189, 372, 2, 2, 7,
319),
(343, 412, 189, 308, 3, 273, 11, 334, 85, 395, 445, 46, 317, 420, 150,
271, 185, 34, 276, 390, 258, 40, 140, 61, 350, 451, 12, 364, 261, 85,
359, 227),
(94, 151, 144, 347, 451, 162, 150, 36, 57, 403, 326, 355, 165, 314,
244, 61, 136, 80, 99, 106, 101, 66, 149, 250, 366, 392, 104, 98, 78,
303, 321, 271),
(277, 93, 103, 166, 213, 63, 41, 430, 407, 356, 119, 332, 226, 197, 2,
429, 294, 101, 247, 324, 64, 189, 298, 301, 128, 280, 369, 447, 11,
220, 436, 206),
(134, 227, 252, 331, 189, 37, 326, 275, 410, 39, 406, 45, 74, 276, 184,
436, 265, 135, 9, 21, 12, 49, 93, 329, 322, 192, 431, 434, 33, 109,
296, 80),
(446, 178, 48, 92, 128, 211, 48, 201, 310, 49, 144, 402, 421, 313, 244,
280, 195, 101, 153, 53, 73, 24, 273, 64, 138, 267, 176, 43, 258, 404,
217, 341),
(412, 188, 96, 226, 110, 202, 41, 366, 417, 255, 41, 82, 132, 68, 11,
240, 52, 122, 119, 445, 211, 329, 248, 222, 146, 219, 57, 286, 380,
293, 255, 122),
(375, 57, 255, 427, 372, 157, 390, 409, 40, 144, 118, 345, 378, 359,
316, 97, 146, 341, 447, 60, 428, 319, 284, 75, 288, 107, 194, 142,
108, 237, 275, 242));
G : constant array (0 .. 452) of Unsigned_8 :=
(10, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 187, 0, 0, 0, 0, 11, 0, 0, 0, 53,
0, 0, 0, 0, 0, 185, 0, 0, 0, 0, 0, 211, 136, 80, 0, 216, 86, 137, 0, 0,
0, 83, 0, 0, 0, 35, 0, 0, 0, 0, 107, 0, 140, 0, 0, 116, 0, 0, 220, 0,
0, 0, 0, 191, 199, 23, 0, 0, 0, 0, 0, 215, 139, 0, 122, 118, 0, 0, 0,
0, 117, 0, 0, 0, 0, 0, 0, 0, 0, 6, 140, 164, 0, 171, 0, 61, 125, 0, 0,
0, 0, 49, 206, 0, 0, 154, 0, 23, 0, 0, 71, 0, 0, 59, 137, 0, 107, 46,
0, 210, 44, 0, 0, 59, 214, 0, 0, 156, 0, 0, 38, 0, 0, 201, 0, 0, 37,
173, 0, 0, 33, 125, 206, 0, 0, 0, 54, 0, 0, 0, 212, 0, 40, 0, 75, 0,
25, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 181, 177, 0, 0, 143, 193, 0, 0,
8, 0, 21, 42, 216, 0, 132, 8, 122, 20, 165, 0, 158, 81, 0, 0, 0, 197,
134, 15, 73, 0, 117, 0, 76, 0, 0, 0, 0, 12, 0, 191, 38, 52, 166, 0,
128, 0, 65, 8, 0, 47, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 28, 91, 0, 0,
162, 0, 0, 0, 0, 9, 215, 63, 184, 187, 167, 0, 178, 100, 0, 0, 0, 182,
112, 0, 0, 74, 31, 169, 141, 159, 0, 61, 0, 151, 132, 0, 194, 20, 0,
61, 0, 0, 0, 79, 200, 88, 0, 33, 151, 42, 0, 210, 179, 77, 120, 0, 0,
35, 0, 0, 66, 0, 0, 201, 178, 0, 0, 0, 0, 0, 117, 0, 0, 0, 186, 224,
218, 0, 121, 0, 0, 2, 165, 6, 0, 167, 0, 184, 115, 131, 0, 0, 10, 215,
0, 0, 72, 58, 23, 45, 0, 192, 196, 0, 146, 58, 0, 99, 88, 0, 115, 0, 0,
0, 57, 44, 200, 0, 58, 0, 19, 4, 114, 1, 84, 3, 0, 225, 0, 211, 0, 0,
0, 0, 0, 50, 149, 205, 5, 188, 0, 0, 208, 17, 0, 143, 110, 76, 0, 187,
85, 0, 93, 96, 62, 0, 60, 25, 158, 108, 0, 51, 0, 0, 194, 154, 128,
214, 101, 0, 0, 0, 0, 0, 61, 43, 190, 180, 85, 0, 217, 96, 0, 161, 56,
68, 0, 0, 217, 92, 76, 65, 0, 173, 0, 0, 30, 0, 0, 66, 13, 151, 0, 31,
95, 0, 0, 78, 21, 34, 161, 34, 220, 191, 0, 7, 109, 0, 217, 68, 65, 0,
139);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Unsigned_8;
begin
for K in P'Range loop
exit when L < P (K);
J := C (S (P (K) + F));
F1 := (F1 + Natural (T1 (K, J))) mod 453;
F2 := (F2 + Natural (T2 (K, J))) mod 453;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 226;
end Hash;
-- Returns true if the string <b>S</b> is a keyword.
function Is_Keyword (S : in String) return Boolean is
H : constant Natural := Hash (S);
begin
return Keywords (H).all = Util.Strings.Transforms.To_Upper_Case (S);
end Is_Keyword;
end Mysql.Perfect_Hash;
|
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- GNAT.Sockets.Connection_State_Machine. Luebeck --
-- HTTP_Server Winter, 2013 --
-- Implementation --
-- Last revision : 20:46 27 Aug 2020 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Tags; use Ada.Tags;
with GNAT.SHA1; use GNAT.SHA1;
with Interfaces; use Interfaces;
with Strings_Edit; use Strings_Edit;
with Strings_Edit.Base64; use Strings_Edit.Base64;
with Strings_Edit.Floats; use Strings_Edit.Floats;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Strings_Edit.Quoted; use Strings_Edit.Quoted;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with GNAT.Sockets.Connection_State_Machine.Big_Endian.Unsigneds;
with Strings_Edit.UTF8;
package body GNAT.Sockets.Connection_State_Machine.HTTP_Server is
use CGI_Keys;
use Content_Ranges;
use GNAT.Sockets.Server.Stream_Element_Offset_Edit;
Block_Size : constant := 1024;
Default_Response : constant String := "Not implemented";
Bad_Request_Response : constant String := "Bad request";
function From_Digest (Data : Message_Digest) return String is
Result : String (1..Data'Length / 2);
Pointer : Integer := Data'First;
begin
for Index in Result'Range loop
Result (Index) :=
Character'Val
( Strings_Edit.Integers.Value
( Source => Data (Pointer..Pointer + 1),
Base => 16
) );
Pointer := Pointer + 2;
end loop;
return Result;
end From_Digest;
function To_String (Data : Stream_Element_Array) return String is
Result : String (1..Data'Length);
begin
for Index in Data'Range loop
Result (Integer (Index - Data'First + 1)) :=
Character'Val (Data (Index));
end loop;
return Result;
end To_String;
function Accumulated_Body_Length (Client : HTTP_Client)
return Stream_Element_Count is
begin
if Client.Body_Content.First = null then
return 0;
else
return Client.Body_Content.Length;
end if;
end Accumulated_Body_Length;
procedure Accumulate_Body
( Client : in out HTTP_Client;
Content : String
) is
begin
Accumulate_Body (Client, From_String (Content));
end Accumulate_Body;
procedure Accumulate_Body
( Client : in out HTTP_Client'Class;
Content : Content_Item_Ptr
) is
begin
if Client.Body_Content.First = null then
Client.Body_Content.First := Content;
Client.Body_Content.Length := Content.Length;
else
if Client.Body_Content.Last /= null then
Client.Body_Content.Last.Next := Content;
end if;
Client.Body_Content.Length :=
Client.Body_Content.Length + Content.Length;
end if;
Client.Body_Content.Last := Content;
end Accumulate_Body;
procedure Accumulate_Body
( Client : in out HTTP_Client;
Content : access Stream_Element_Array
) is
type Content_Item_Ptr is access Content_Item;
for Content_Item_Ptr'Storage_Pool use Client.Pool;
Ptr : Content_Item_Ptr;
begin
Ptr := new Content_Item'
( Kind => Stream_Elements_Pointer,
Length => Content'Length,
Next => null,
First => Content'First,
Data_Ptr => Content.all'Unchecked_Access
);
Accumulate_Body (Client, Ptr.all'Unchecked_Access);
end Accumulate_Body;
procedure Accumulate_Body
( Client : in out HTTP_Client;
Content : access String
) is
type Content_Item_Ptr is access Content_Item;
for Content_Item_Ptr'Storage_Pool use Client.Pool;
Ptr : Content_Item_Ptr;
begin
Ptr := new Content_Item'
( Kind => String_Pointer,
Length => Content'Length,
Next => null,
First => Stream_Element_Offset (Content'First),
Text_Ptr => Content.all'Unchecked_Access
);
Accumulate_Body (Client, Ptr.all'Unchecked_Access);
end Accumulate_Body;
procedure Accumulate_Body
( Client : in out HTTP_Client;
Content : Stream_Element_Array
) is
type Content_Item_Ptr is access Content_Item;
for Content_Item_Ptr'Storage_Pool use Client.Pool;
Ptr : Content_Item_Ptr;
begin
if Content'Length > 0 then
Ptr := new Content_Item'
( Kind => Literal_Value,
Length => Content'Length,
Next => null,
First => 1,
Data => Content
);
Accumulate_Body (Client, Ptr.all'Unchecked_Access);
end if;
end Accumulate_Body;
procedure Body_Error
( Client : in out HTTP_Client;
Stream : in out Root_Stream_Type'Class;
Error : Exception_Occurrence
) is
begin
Raise_Exception (Data_Error'Identity, Exception_Message (Error));
end Body_Error;
procedure Body_Error
( Client : in out HTTP_Client;
Content : in out Content_Destination'Class;
Error : Exception_Occurrence
) is
begin
Raise_Exception (Data_Error'Identity, Exception_Message (Error));
end Body_Error;
procedure Body_Received
( Client : in out HTTP_Client;
Stream : in out Root_Stream_Type'Class
) is
begin
null;
end Body_Received;
procedure Body_Received
( Client : in out HTTP_Client;
Content : in out Content_Destination'Class
) is
begin
null;
end Body_Received;
procedure Body_Sent
( Client : in out HTTP_Client;
Stream : in out Root_Stream_Type'Class;
Get : Boolean
) is
begin
null;
end Body_Sent;
procedure Body_Error
( Client : in out HTTP_Client;
Content : in out CGI_Keys.Table'Class;
Error : Exception_Occurrence
) is
begin
Raise_Exception (Data_Error'Identity, Exception_Message (Error));
end Body_Error;
procedure Body_Received
( Client : in out HTTP_Client;
Content : in out CGI_Keys.Table'Class
) is
begin
null;
end Body_Received;
function Check_WebSocket
( Client : access HTTP_Client
) return Boolean is
This : HTTP_Client renames Client.all;
begin
if 0 = (This.Connection and Connection_Upgrade) then
Reply_Text
( Client.all,
400,
Bad_Request_Response,
"Connection field is not 'upgrade'"
);
return False;
end if;
begin
case Integer'
( Value (Get_Header (This, Sec_WebSocket_Version_Header))
) is
when 13 =>
null;
when others =>
Send_Status_Line (This, 426, "Upgrade required");
Send_Date (This);
Send_Content_Type (This, "text/plain");
Send (This, "Sec-WebSocket-Version: 13" & CRLF);
Send_Connection (This, False);
Send_Body (This, "Unsupported WebSocket version");
return False;
end case;
exception
when Error : others =>
Reply_Text
( This,
400,
Bad_Request_Response,
"WebSocket version error: " & Exception_Message (Error)
);
return False;
end;
case Get_Header (This, Sec_WebSocket_Key_Header)'Length is
when 16 =>
null;
when 0 =>
Reply_Text
( This,
400,
Bad_Request_Response,
"Missing WebSocket key"
);
return False;
when others =>
Reply_Text
( This,
400,
Bad_Request_Response,
"Broken WebSocket key, must be 16-bytes long"
);
return False;
end case;
-- declare -- Origin checks
-- Host : String := Get_Header (This, Host_Header);
-- Checked : Boolean := False;
-- begin
-- if Host /= "localhost" then
-- declare
-- Server : Host_Entry_Type := Get_Host_By_Name (Host_Name);
-- Origin : Host_Entry_Type := Get_Host_By_Name (Host);
-- begin
-- Verify : for I in 1..Addresses_Length (Origin) loop
-- declare
-- Address : Inet_Addr_Type := Addresses (Origin, I);
-- begin
-- for J in 1..Addresses_Length (Server) loop
-- if Addresses (Server, J) = Address then
-- Checked := True;
-- exit Verify;
-- end if;
-- end loop;
-- end;
-- end loop Verify;
-- if not Checked then
-- Reply_Text
-- ( This,
-- 400,
-- Bad_Request_Response,
-- "Host does not contain server's name"
-- );
-- return False;
-- end if;
-- end;
-- end if;
-- exception
-- when others =>
-- if not Checked then
-- Reply_Text
-- ( This,
-- 400,
-- Bad_Request_Response,
-- "Host does not contain server's name"
-- );
-- return False;
-- end if;
-- end;
return True;
end Check_WebSocket;
procedure Cleanup_Body_Part (Client : in out HTTP_Client'Class) is
begin
if Client.Part_Mark /= null then
declare
type Part_Ptr is access String;
for Part_Ptr'Storage_Pool use Client.Pool;
function To_Part_Ptr is
new Ada.Unchecked_Conversion (Text_Ptr, Part_Ptr);
procedure Free is
new Ada.Unchecked_Deallocation (String, Part_Ptr);
Ptr : Part_Ptr := To_Part_Ptr (Client.Part_Mark);
begin
Free (Ptr);
Client.Multipart := (others => null);
Client.Part_Mark := null;
end;
end if;
end Cleanup_Body_Part;
procedure Commit (Destination : in out Content_Destination) is
begin
null;
end Commit;
procedure Commit (Destination : in out CGI_Content) is
Client : HTTP_Client'Class renames Destination.Client.all;
type Value_Ptr is access String;
for Value_Ptr'Storage_Pool use Client.Pool;
Ptr : Value_Ptr;
begin
case Destination.State is
when CGI_Value =>
if Destination.Offset /= 0 then
Ptr :=
new String'
( From_Escaped
( Client.Line.Value
( Client.Line.Value'First
.. Client.Line.Last
),
True
) );
Replace
( Destination.Keys.all,
Destination.Offset,
Ptr.all'Unchecked_Access
);
if Destination.Client.Trace_Body then
Trace
( Client,
( "CGI "
& Quote
( GetName
( Destination.Keys.all,
Destination.Offset
),
'''
)
& '='
& Quote
( GetTag
( Destination.Keys.all,
Destination.Offset
) .all,
'''
) ) );
end if;
end if;
when CGI_Key =>
null;
end case;
end Commit;
function Compare (Left, Right : String) return Boolean is
begin
if Left'Length /= Right'Length then
return False;
end if;
for Index in Left'Range loop
if ( To_Lower (Left (Index))
/= Right (Index + (Right'First - Left'First))
)
then
return False;
end if;
end loop;
return True;
end Compare;
procedure Continue (Client : in out HTTP_Client; Chain : Action) is
begin
Client.Chain := Chain;
end Continue;
procedure Content_Chunk (Client : in out HTTP_Client'Class) is
begin
if Client.Source /= null then
declare
Chunk : constant String := Get (Client.Source);
begin
if Client.Chunked then -- Chunked transfer
Send (Client, Integers.Image (Chunk'Length, 16) & CRLF);
if Chunk'Length = 0 then
Client.Source := null;
Send (Client, CRLF);
else
Send (Client, Chunk);
Send (Client, CRLF);
Continue (Client, Content_Chunk'Access);
end if;
else -- Fixed length transfer
if Chunk'Length = 0 then -- End of data
Client.Source := null;
if Client.Data_Length > 0 then
Raise_Exception
( Data_Error'Identity,
( "Missing "
& Image (Client.Data_Length)
& " contents data to transfer"
) );
end if;
Send (Client, CRLF);
else -- A chunk of data obtained
if Chunk'Length < Client.Data_Length then
Send (Client, Chunk);
Client.Data_Length :=
Client.Data_Length - Chunk'Length;
Continue (Client, Content_Chunk'Access);
else
Client.Source := null;
Send
( Client,
Chunk
( Chunk'First
.. ( Chunk'First
+ Natural (Client.Data_Length)
- 1
) ) );
Client.Data_Length := 0;
Send (Client, CRLF);
end if;
end if;
end if;
end;
else
if Client.Chunked then -- Chunked transfer completed
Send (Client, "0" & CRLF & CRLF);
else -- Fixed length transfer completed
Send (Client, CRLF);
end if;
end if;
exception
when Content_Not_Ready =>
Continue (Client, Content_Chunk'Access);
when Error : others =>
Trace_Error
( Client.Listener.Factory.all,
"Sending content chunk",
Error
);
Client.Source := null;
Client.Data_Length := 0;
if Client.Chunked then -- Chunked transfer completed
Send (Client, "0" & CRLF & CRLF);
else -- Fixed length transfer completed
Send (Client, CRLF);
end if;
end Content_Chunk;
procedure Do_Body (Client : in out HTTP_Client) is
begin
null;
end Do_Body;
procedure Do_Connect (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Connect;
procedure Do_Delete (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Delete;
procedure Do_Head (Client : in out HTTP_Client) is
begin
Send_Status_Line (Client, 200, "OK");
Send_Date (Client, Clock);
Send_Server (Client);
Send_Length (Client, Natural'(Default_Response'Length));
Send_Connection (Client, False);
Send_Content_Type (Client);
end Do_Head;
procedure Do_Get (Client : in out HTTP_Client) is
begin
Send_Status_Line (Client, 200, "OK");
Send_Date (Client, Clock);
Send_Server (Client);
Send_Length (Client, Natural'(Default_Response'Length));
Send_Connection (Client, False);
Send_Content_Type (Client);
Send (Client, CRLF);
Send (Client, Default_Response);
end Do_Get;
procedure Do_Options (Client : in out HTTP_Client) is
Response : constant String := "";
begin
Send_Status_Line (Client, 200, "OK");
Send_Date (Client, Clock);
Send_Server (Client);
Send_Length (Client, Natural'(Response'Length));
Send_Connection (Client, False);
Send_Allow (Client, Client.Allowed);
Send (Client, CRLF);
Send (Client, Response);
end Do_Options;
procedure Do_Patch (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Patch;
procedure Do_Post (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Post;
procedure Do_Put (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Put;
procedure Do_Trace (Client : in out HTTP_Client) is
begin
Reply_Text (Client, 501, Default_Response, Default_Response);
end Do_Trace;
procedure Do_WebSocket (Client : in out HTTP_Client) is
begin
if not Check_WebSocket (Client'Access) then
return;
end if;
declare
Result : constant WebSocket_Accept :=
WebSocket_Open (HTTP_Client'Class (Client)'Access);
Socket : WebSocket_Data renames Client.WebSocket;
begin
if Result.Accepted then
declare
type Message_Ptr is access WebSocket_Message;
for Message_Ptr'Storage_Pool use Client.Pool;
Ptr : constant Message_Ptr :=
new WebSocket_Message (Result.Size);
begin
Socket.Data := Ptr.all'Unchecked_Access;
end;
Socket.Max_Length := Result.Size;
Socket.Chunked := Result.Chunked;
Client.Expecting := WebSocket_Header;
if Result.Duplex then -- Allow full-duplex operation
Set_Overlapped_Size (Client, Client.Output_Size);
end if;
Socket.Duplex := Result.Duplex;
Socket.State := Open_Socket;
if Client.Trace_Body then
Trace (Client, "WebSocket connection accepted");
end if;
--
-- Responding with connection acknowledge
--
Send_Status_Line (Client, 101, "Switching Protocols");
Send (Client, "Upgrade: websocket" & CRLF);
Send (Client, "Connection: Upgrade" & CRLF);
Send
( Client,
( "Sec-WebSocket-Accept: "
& To_Base64
( From_Digest
( Digest
( To_Base64
( Get_Header
( Client,
Sec_WebSocket_Key_Header
) )
& "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
) ) )
& CRLF
) );
if Result.Protocols = "" then
if Client.Headers (Sec_WebSocket_Protocol_Header) /= null
then
Send -- Copy protocols
( Client,
( "Sec-WebSocket-Protocol: "
& Get_Header
( Client,
Sec_WebSocket_Protocol_Header
)
& CRLF
) );
end if;
else
Send
( Client,
"Sec-WebSocket-Protocol: " & Result.Protocols & CRLF
);
end if;
Send (Client, CRLF);
if Result.Duplex then -- Allow full-duplex operation
if Queued_To_Send (Client) > 0 then
Client.Mutex.Set (Server_Sending);
else
Client.Mutex.Set (Idle);
end if;
end if;
begin
WebSocket_Initialize (HTTP_Client'Class (Client));
exception
when Error : others =>
Trace
( Client,
( "WebSocket initialization callback fault: "
& Exception_Information (Error)
) );
raise;
end;
else
Reply_Text
( Client,
Result.Code,
Result.Reason,
Result.Reason
);
end if;
end;
exception
when others =>
WebSocket_Cleanup (Client);
raise;
end Do_WebSocket;
procedure Finalize (Client : in out HTTP_Client) is
begin
WebSocket_Cleanup (Client);
Finalize (State_Machine (Client));
Deallocate_All (Client.Pool);
Client.Expecting := Request_Line;
Client.Data_Length := 0;
Client.Status := null;
Client.Part_Mark := null;
Client.Chain := null;
Client.Boundary := null;
Client.Destination := null;
Client.Source := null;
end Finalize;
function From_Escaped
( Name : String;
Translate_Plus : Boolean := False
) return String is
Length : Natural := 0;
Pointer : Integer := Name'First;
begin
while Pointer <= Name'Last loop
if Name (Pointer) = '%' then
Pointer := Pointer + 3;
else
Pointer := Pointer + 1;
end if;
Length := Length + 1;
end loop;
declare
Pointer : Integer := Name'First;
Result : String (1..Length);
begin
for Index in Result'Range loop
if Name (Pointer) = '%' then
Result (Index) :=
Character'Val
( Integer'
( Value
( Name (Pointer + 1..Pointer + 2),
16
) ) );
Pointer := Pointer + 3;
elsif Name (Pointer) = '+' and then Translate_Plus then
Result (Index) := ' ';
Pointer := Pointer + 1;
else
Result (Index) := Name (Pointer);
Pointer := Pointer + 1;
end if;
end loop;
return Result;
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Illegal escape sequence"
);
end;
end From_Escaped;
function Get_Allowed (Client : HTTP_Client) return HTTP_Allowed is
begin
return Client.Allowed;
end Get_Allowed;
function Get_CGI_Key (Client : HTTP_Client; Index : Positive)
return String is
begin
if ( Client.CGI.Keys /= null
and then
Index <= GetSize (Client.CGI.Keys.all)
)
then
return GetName (Client.CGI.Keys.all, Index);
end if;
Raise_Exception (Constraint_Error'Identity, "Invalid key index");
end Get_CGI_Key;
function Get_CGI_Size (Client : HTTP_Client) return Natural is
begin
if Client.CGI.Keys = null then
return 0;
else
return GetSize (Client.CGI.Keys.all);
end if;
end Get_CGI_Size;
function Get_CGI_Value (Client : HTTP_Client; Index : Positive)
return String is
begin
if ( Client.CGI.Keys /= null
and then
Index <= GetSize (Client.CGI.Keys.all)
)
then
declare
Value : constant String_Ptr :=
GetTag (Client.CGI.Keys.all, Index);
begin
if Value = null then
return "";
else
return Value.all;
end if;
end;
end if;
Raise_Exception (Constraint_Error'Identity, "Invalid key index");
end Get_CGI_Value;
function Get_CGI_Value (Client : HTTP_Client; Key : String)
return String is
begin
if Client.CGI.Keys /= null then
declare
Offset : constant Natural :=
Locate (Client.CGI.Keys.all, Key);
Value : String_Ptr;
begin
if Offset > 0 then
Value := GetTag (Client.CGI.Keys.all, Offset);
if Value /= null then
return Value.all;
end if;
end if;
end;
end if;
return "";
end Get_CGI_Value;
function Get_Closing (Client : HTTP_Client) return Boolean is
begin
return 0 /= (Client.Connection and Connection_Close);
end Get_Closing;
function Get_Date (Client : HTTP_Client) return Time is
begin
if Client.Specific (Date_Header) then
return Client.Date;
else
raise Time_Error;
end if;
end Get_Date;
function Get_Header
( Client : HTTP_Client;
Header : Text_Header
) return String is
begin
if Client.Headers (Header) = null then
return "";
else
return Client.Headers (Header).all;
end if;
end Get_Header;
function Get_If_Modified_Since (Client : HTTP_Client) return Time is
begin
if Client.Specific (If_Modified_Since_Header) then
return Client.If_Modified_Since;
else
raise Time_Error;
end if;
end Get_If_Modified_Since;
function Get_If_Unmodified_Since (Client : HTTP_Client) return Time is
begin
if Client.Specific (If_Unmodified_Since_Header) then
return Client.If_Unmodified_Since;
else
raise Time_Error;
end if;
end Get_If_Unmodified_Since;
function Get_Last_Modified (Client : HTTP_Client) return Time is
begin
if Client.Specific (Last_Modified_Header) then
return Client.Last_Modified;
else
raise Time_Error;
end if;
end Get_Last_Modified;
function Get_Method (Client : HTTP_Client) return HTTP_Method is
begin
return Client.Method;
end Get_Method;
function Get_Multipart_Header
( Client : HTTP_Client;
Header : Multipart_Header
) return String is
begin
if Client.Multipart (Header) = null then
return "";
else
return Client.Multipart (Header).all;
end if;
end Get_Multipart_Header;
function Get_Name (Client : HTTP_Client) return String is
begin
return "Simple_Components_HTTP_Server/1.0";
end Get_Name;
function Get_Prefix
( Client : access Connection'Class;
Data : Stream_Element_Array;
End_Of_Stream : Boolean
) return String is
begin
return Image (Stream_Element_Count'(Data'Length), 16) & CRLF;
end Get_Prefix;
function Get_Ranges (Client : HTTP_Client) return Ranges_Set is
begin
if Client.Suffix = Stream_Element_Offset'First then -- No suffix
return (Explicit_Range, Client.Ranges);
else
return (Suffix_Range, Client.Ranges, Client.Suffix);
end if;
end Get_Ranges;
function Get_Status_Line (Client : HTTP_Client) return Status_Line is
begin
if Client.Status = null then
return (None, 0, 0, 0, "");
else
return Client.Status.all;
end if;
end Get_Status_Line;
function Get_Suffix
( Client : access Connection'Class;
Data : Stream_Element_Array;
End_Of_Stream : Boolean
) return String is
begin
if End_Of_Stream then
if Data'Length = 0 then
return CRLF & CRLF; -- Last empty chunk
else
return CRLF & '0' & CRLF & CRLF; -- Last not empty chunk
end if;
else
return CRLF;
end if;
end Get_Suffix;
function Get_Version (Client : HTTP_Client) return HTTP_Version is
begin
return Client.Version;
end Get_Version;
procedure Header_Received
( Client : in out HTTP_Client;
Header : Request_Header;
Value : String
) is
procedure Get_Text is
pragma Inline (Get_Text);
type Header_Ptr is access String;
for Header_Ptr'Storage_Pool use Client.Pool;
Ptr : Header_Ptr;
begin
if Client.Headers (Header) /= null then
return; -- The value is already set
end if;
if Header = Sec_WebSocket_Key_Header then
declare
Key : constant String := From_Base64 (Value);
begin
Ptr := new String'(Key);
Client.Headers (Header) := Ptr.all'Unchecked_Access;
end;
else
Ptr := new String'(Value);
Client.Headers (Header) := Ptr.all'Unchecked_Access;
if Header = Content_Type_Header then
if Is_Prefix ("multipart", Value, Lower) then
declare
type Boundary_Ptr is access String;
for Boundary_Ptr'Storage_Pool use Client.Pool;
Pointer : aliased Integer := Value'First + 9;
Boundary : Boundary_Ptr;
begin
while Pointer <= Value'Last loop
if Is_Prefix
( "boundary=",
Value,
Pointer,
Lower
)
then
Boundary :=
new String'
( CRLF
& "--"
& Value (Pointer + 9.. Value'Last)
);
Client.Boundary :=
Boundary.all'Unchecked_Access;
Client.Position := Client.Boundary'First;
exit;
end if;
Pointer := Pointer + 1;
end loop;
end;
if Client.Boundary = null then
Raise_Exception
( Data_Error'Identity,
"Missing multipart boundary specification"
);
end if;
end if;
end if;
end if;
end Get_Text;
begin
case Header is
when Text_Header =>
Get_Text;
when Date_Header =>
Client.Date := To_Time (Value);
Client.Specific (Date_Header) := True;
when Content_Length_Header =>
Client.Data_Length :=
Stream_Element_Offset_Edit.Value (Value);
when Last_Modified_Header =>
Client.If_Modified_Since := To_Time (Value);
Client.Specific (Last_Modified_Header) := True;
when If_Modified_Since_Header =>
Client.If_Modified_Since := To_Time (Value);
Client.Specific (If_Modified_Since_Header) := True;
when If_Unmodified_Since_Header =>
Client.If_Unmodified_Since := To_Time (Value);
Client.Specific (If_Unmodified_Since_Header) := True;
when Connection_Header =>
Client.Connection := To_Flags (Value);
when Range_Header =>
declare
Pointer : Integer := Value'First;
From : Stream_Element_Offset;
To : Stream_Element_Offset;
begin
if not Is_Prefix ("bytes=", Value, Pointer, Lower) then
Raise_Exception
( Data_Error'Identity,
"Illegal or missing range units specification"
);
end if;
Pointer := Pointer + 6;
loop
begin
Get (Value, Pointer, From);
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Missing or wrong lower range bound " &
"specification"
);
end;
if From < 0 then
exit when Pointer > Value'Last;
Raise_Exception
( Data_Error'Identity,
"Suffix range is not the last on of " &
"the range specification"
);
end if;
if not Is_Prefix ("-", Value, Pointer) then
Raise_Exception
( Data_Error'Identity,
"Missing minus in the range specification"
);
end if;
Pointer := Pointer + 1;
if Pointer <= Value'Last then
begin
Get (Value, Pointer, To);
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Missing or wrong upper range bound " &
"specification"
);
end;
begin
for I in From .. To loop
Client.Ranges.Include (New_Item => I);
end loop;
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Illegal range specification"
);
end;
else
Client.Suffix := From;
exit;
end if;
exit when Pointer > Value'Last;
if Value (Pointer) /= ',' then
Raise_Exception
( Data_Error'Identity,
"Missing comma in the ranges specification"
);
end if;
Pointer := Pointer + 1;
end loop;
end;
end case;
end Header_Received;
function Image (Scheme : Scheme_Type) return String is
begin
if Scheme_Type'Pos (Scheme) < GetSize (Schemes) then
return GetName (Schemes, Scheme_Type'Pos (Scheme) + 1);
else
return "unknown";
end if;
end Image;
function Image (Header : Request_Header) return String is
Result : String := Request_Header'Image (Header);
Capitalize : Boolean := True;
begin
for Index in Result'First..Result'Last - 7 loop
if Result (Index) = '_' then
Result (Index) := '-';
Capitalize := True;
elsif Capitalize then
Result (Index) := To_Upper (Result (Index));
Capitalize := False;
else
Result (Index) := To_Lower (Result (Index));
end if;
end loop;
return Result (Result'First..Result'Last - 7);
end Image;
procedure Initialize (Client : in out HTTP_Client) is
begin
Client.LF.Value (1) := 10;
Client.Line.Terminator := Character'Val (13);
Set_Maximum_Size (Client.Line, Client.Request_Length);
Initialize (State_Machine (Client));
end Initialize;
function Is_Empty (Stream : Content_Stream) return Boolean is
begin
return Stream.First = null;
end Is_Empty;
procedure Message_Chunk (Client : in out HTTP_Client'Class) is
Done : Boolean;
begin
Send
( Client => Client,
Stream => Client.Body_Content,
End_Of_Stream => Done
);
if Done then
if Client.Stub /= null then
declare
type Stub_Ptr is access Content_Item;
for Stub_Ptr'Storage_Pool use Client.Pool;
function To_Ptr is
new Ada.Unchecked_Conversion
( Content_Item_Ptr,
Stub_Ptr
);
procedure Free is
new Ada.Unchecked_Deallocation
( Content_Item,
Stub_Ptr
);
Ptr : Stub_Ptr := To_Ptr (Client.Stub);
begin
Free (Ptr);
end;
Client.Stub := null;
end if;
if Client.WebSocket.State = Closing_Socket then
WebSocket_Cleanup (Client);
end if;
else
Continue (Client, Message_Chunk'Access);
end if;
end Message_Chunk;
procedure Multipart_Header_Received
( Client : in out HTTP_Client;
Header : Request_Header;
Value : String
) is
type Header_Ptr is access String;
for Header_Ptr'Storage_Pool use Client.Pool;
Ptr : Header_Ptr;
begin
case Header is
when Multipart_Header =>
if Client.Multipart (Header) = null then
Ptr := new String'(Value);
Client.Multipart (Header) := Ptr.all'Unchecked_Access;
if Client.Part_Mark = null then
Client.Part_Mark := Client.Multipart (Header);
end if;
end if;
when others =>
Trace
( Client,
"Unsupported multipart header " & Quote (Value, ''')
);
end case;
end Multipart_Header_Received;
procedure Queue_Content
( Client : in out HTTP_Client;
Data : Stream_Element_Array
) is
type Content_Item_Ptr is access Content_Item;
for Content_Item_Ptr'Storage_Pool use Client.Pool;
Ptr : Content_Item_Ptr;
begin
Ptr := new Content_Item'
( Kind => Literal_Value,
Length => Data'Length,
Next => null,
First => 1,
Data => Data
);
if Client.Stub = null then
Client.Stub := Ptr.all'Unchecked_Access;
end if;
Accumulate_Body (Client, Ptr.all'Unchecked_Access);
Continue (Client, Message_Chunk'Access);
end Queue_Content;
procedure Queue_Content
( Client : in out HTTP_Client;
Data : String
) is
type Content_Item_Ptr is access Content_Item;
for Content_Item_Ptr'Storage_Pool use Client.Pool;
Ptr : Content_Item_Ptr;
begin
Ptr := new Content_Item
( Kind => Literal_Value,
Length => Data'Length
);
declare
Message : Stream_Element_Array renames Ptr.Data;
Pointer : Stream_Element_Offset := Message'First;
begin
for Index in Data'Range loop
Message (Pointer) := Character'Pos (Data (Index));
Pointer := Pointer + 1;
end loop;
end;
if Client.Stub = null then
Client.Stub := Ptr.all'Unchecked_Access;
end if;
Accumulate_Body (Client, Ptr.all'Unchecked_Access);
Continue (Client, Message_Chunk'Access);
end Queue_Content;
procedure Process_Body_Tail (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Pointer : constant Integer := Request'First;
begin
if Request = "--" then
Client.Expecting := Multipart_Epilogue;
elsif Pointer > Request'Last then
Client.Expecting := Multipart_Header_Line;
else
Trace
( Client,
"Malformed ending of a multipart body: " & Request
);
end if;
end Process_Body_Tail;
procedure Process_Chunk_Line (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Pointer : Integer := Request'First;
begin
Get
( Source => Request,
Pointer => Pointer,
Value => Client.Data_Length,
Base => 16,
First => 0
);
Client.Expecting := Client.Chunk_Type; -- Restore expected type
if Client.Data_Length = 0 then
Client.Chunked := False; -- End of chunked receive
if Client.Stream /= null then
Body_Received (Client, Client.Stream.all);
Client.Stream := null;
elsif Client.Destination /= null then
Commit (Client.Destination.all);
if Client.Destination = Client.CGI'Unchecked_Access then
Body_Received (Client, Client.CGI.Keys.all);
else
Body_Received (Client, Client.Destination.all);
end if;
Client.Destination := null;
end if;
end if;
exception
when Data_Error | Constraint_Error | End_Error =>
Raise_Exception
( Data_Error'Identity,
"Malformed data chunk header line"
);
end Process_Chunk_Line;
procedure Process_Epilogue (Client : in out HTTP_Client'Class) is
begin
null;
end Process_Epilogue;
procedure Process_Header_Line (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Pointer : Integer := Request'First;
begin
if Pointer > Request'Last then
if Client.Trace_Header then
Trace (Client, "Header:");
for Index in Client.Headers'Range loop
if Client.Headers (Index) /= null then
Trace
( Client,
( " "
& Text_Header'Image (Index)
& '='
& Quote (Client.Headers (Index).all, ''')
) );
end if;
end loop;
end if;
if Client.Boundary /= null then -- Multipart body
Client.Expecting := Multipart_Preamble;
Client.Multipart := (others => null);
Client.Part_Mark := null;
elsif Client.Chunked then -- Chunked transfer-encoded body
Do_Body (Client);
Client.Chunk_Type := Body_Data;
Client.Expecting := Chunk_Line;
elsif Client.Data_Length > 0 then -- Fixed-length body
Do_Body (Client);
Client.Expecting := Body_Data;
else
Process_Request (Client);
end if;
else
while Pointer <= Request'Last loop
if Request (Pointer) = ':' then
declare
Index : constant Integer :=
Locate
( Request_Headers,
Request (Request'First..Pointer - 1)
);
begin
if Index > 0 then
Pointer := Pointer + 1;
if Pointer <= Request'Last and then
Request (Pointer) = ' '
then
Pointer := Pointer + 1;
end if;
Header_Received
( Client,
GetTag (Request_Headers, Index),
Request (Pointer..Request'Last)
);
else
Trace
( Client,
( "Unsupported header "
& Quote
( Request (Request'First..Pointer - 1),
'''
) ) );
end if;
end;
return;
end if;
Pointer := Pointer + 1;
end loop;
Trace (Client, "Malformed header " & Request);
end if;
end Process_Header_Line;
procedure Process_Part_Header (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Pointer : Integer := Request'First;
begin
if Pointer > Request'Last then
if Client.Trace_Header then
Trace (Client, "Multipart header:");
for Index in Client.Multipart'Range loop
if Client.Multipart (Index) /= null then
Trace
( Client,
( " "
& Multipart_Header'Image (Index)
& '='
& Quote (Client.Multipart (Index).all, ''')
) );
end if;
end loop;
end if;
Do_Body (Client);
Client.Expecting := Multipart_Body_Data;
else
while Pointer <= Request'Last loop
if Request (Pointer) = ':' then
declare
Index : constant Integer :=
Locate
( Request_Headers,
Request (Request'First..Pointer - 1)
);
begin
if Index > 0 then
Pointer := Pointer + 1;
if Pointer <= Request'Last and then
Request (Pointer) = ' '
then
Pointer := Pointer + 1;
end if;
Multipart_Header_Received
( Client,
GetTag (Request_Headers, Index),
Request (Pointer..Request'Last)
);
else
Trace
( Client,
( "Unsupported header "
& Quote
( Request (Request'First..Pointer - 1),
'''
) ) );
end if;
end;
return;
end if;
Pointer := Pointer + 1;
end loop;
Trace (Client, "Malformed multipart header " & Request);
end if;
end Process_Part_Header;
procedure Process_Preamble (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Boundary : String renames Client.Boundary.all;
begin
if Is_Prefix -- Matching boundary without forward CRLF
( Boundary (Boundary'First + 2..Boundary'Last),
Request
)
then -- Boundary is here
if Is_Prefix
( "--",
Request,
Request'First + Boundary'Length
)
then -- Last boundary
Client.Expecting := Multipart_Epilogue;
else
Client.Expecting := Multipart_Header_Line;
end if;
end if;
end Process_Preamble;
procedure Process_Request (Client : in out HTTP_Client'Class) is
begin
Client.Expecting := Request_Line;
case Client.Method is
when HTTP_GET =>
if Compare
( Get_Header (Client, Upgrade_Header),
"websocket"
)
then
Do_WebSocket (Client);
else -- This is a normal GET request
Do_Get (Client);
end if;
when HTTP_HEAD =>
Do_Head (Client);
when HTTP_POST =>
Do_Post (Client);
when HTTP_PUT =>
Do_Put (Client);
when HTTP_DELETE =>
Do_Delete (Client);
when HTTP_TRACE =>
Do_Trace (Client);
when HTTP_OPTIONS =>
Do_Options (Client);
when HTTP_CONNECT =>
Do_Connect (Client);
when HTTP_PATCH =>
Do_Patch (Client);
end case;
end Process_Request;
procedure Process_Request_Line (Client : in out HTTP_Client'Class) is
Request : String renames Client.Line.Value (1..Client.Line.Last);
Pointer : Integer := Request'First;
function Get_Version return HTTP_Version is
Version : Float;
begin
Get (Request, Pointer);
if not Is_Prefix ("http/", Request, Pointer, Lower) then
Trace (Client, "No HTTP version specified (1.1 assumed)");
return 1.1;
end if;
Pointer := Pointer + 5;
begin
Get (Request, Pointer, Version);
exception
when others =>
raise Constraint_Error;
end;
if Pointer <= Request'Last then
Trace
( Client,
"Unrecognized text follows HTTP version (1.1 assumed)"
);
return 1.1;
else
return HTTP_Version (Version);
end if;
exception
when Constraint_Error =>
Trace (Client, "Illegal HTTP version (1.1 assumed)");
return 1.1;
end Get_Version;
begin
Skip (Request, Pointer);
begin
Client.Method :=
Find (Commands, Request (Request'First..Pointer - 1));
exception
when End_Error =>
Raise_Exception
( Data_Error'Identity,
( "Method "
& Request (Request'First..Pointer - 1)
& " is not supported"
) );
end;
Pointer := Pointer + 1;
if Pointer > Request'Last then
Raise_Exception (Data_Error'Identity, "Missing request-URI");
end if;
Client.Expecting := Header_Line;
Client.Chunked := False;
Client.Connection := 0;
Client.Status := null;
Client.Stream := null;
Client.Source := null;
Client.Destination := null;
Client.Boundary := null;
Client.Data_Length := 0;
Client.Body_Content.First := null;
Client.Headers := (others => null);
Client.Multipart := (others => null);
Client.Specific := (others => False);
Client.Suffix := Stream_Element_Count'First;
Client.CGI.Keys := null;
Client.Ranges.Clear;
if Request (Pointer) = '*' then
Pointer := Pointer + 1;
Status_Line_Received (Client, Client.Method, Get_Version);
elsif Request (Pointer) = '/' then
Pointer := Pointer + 1;
declare
Path : constant Integer := Pointer;
Query : Integer := Request'Last + 1;
begin
while Pointer <= Request'Last loop
case Request (Pointer) is
when ' ' =>
exit;
when '?' =>
Query := Integer'Min (Query, Pointer);
Pointer := Pointer + 1;
when others =>
Pointer := Pointer + 1;
end case;
end loop;
Query := Integer'Min (Query, Pointer);
Status_Line_Received
( Client => Client,
Method => Client.Method,
Path => From_Escaped (Request (Path..Query - 1)),
Query => From_Escaped (Request (Query + 1..Pointer - 1)),
Version => Get_Version
);
end;
else
declare
Host_First : Integer := Request'First;
Host_Next : Integer := Request'First;
Path_First : Integer := Request'First;
Path_Next : Integer := Request'First;
Query_First : Integer := Request'First;
Query_Next : Integer := Request'First;
Port : Integer := 80;
Scheme : Scheme_Type;
begin
loop
if Pointer > Request'Last then
Raise_Exception
( Data_Error'Identity,
"URI does not contain scheme followed by colon ':'"
);
end if;
if Request (Pointer) = ':' then
declare
Offset : constant Integer :=
Locate (Schemes, Request (1..Pointer - 1));
begin
if Offset > 0 then
Scheme := GetTag (Schemes, Offset);
else
Scheme := Unknown_Scheme;
end if;
end;
if Client.Trace_Header then
Trace (Client, "Scheme: " & Image (Scheme));
end if;
Pointer := Pointer + 1;
exit;
end if;
Pointer := Pointer + 1;
end loop;
if Is_Prefix ("//", Request, Pointer) then
Pointer := Pointer + 2;
Host_First := Pointer;
Host_Next := Pointer;
while Pointer <= Request'Last loop
case Request (Pointer) is
when ' ' | '/' =>
exit;
when ':' =>
Pointer := Pointer + 1;
begin
Get
( Source => Request,
Pointer => Pointer,
Value => Port,
First => 1,
Last => 2**16-1
);
exception
when Constraint_Error =>
Raise_Exception
( Data_Error'Identity,
"Port number is not in range"
);
when others =>
Raise_Exception
( Data_Error'Identity,
"No port number after colon ':' in URI"
);
end;
exit;
when others =>
Pointer := Pointer + 1;
Host_Next := Pointer;
end case;
end loop;
if Host_First >= Host_Next then
Raise_Exception
( Data_Error'Identity,
"Empty host address in URI"
);
end if;
if Request (Pointer) = '/' then
Pointer := Pointer + 1;
Path_First := Pointer;
Path_Next := Pointer;
while Pointer <= Request'Last loop
case Request (Pointer) is
when ' ' =>
exit;
when '?' =>
Pointer := Pointer + 1;
Query_First := Pointer;
Skip (Request, Pointer);
Query_Next := Pointer;
exit;
when others =>
Pointer := Pointer + 1;
Path_Next := Pointer;
end case;
end loop;
end if;
Status_Line_Received
( Client => Client,
Scheme => Scheme,
Method => Client.Method,
Port => Port_Type (Port),
Version => Get_Version,
Host => From_Escaped
( Request (Host_First..Host_Next - 1)
),
Path => From_Escaped
( Request (Path_First..Path_Next - 1)
),
Query => From_Escaped
( Request (Query_First..Query_Next - 1)
) );
else
Path_First := Pointer;
Path_Next := Pointer;
while Pointer <= Request'Last loop
case Request (Pointer) is
when ' ' =>
exit;
when '?' =>
Pointer := Pointer + 1;
Query_First := Pointer;
Skip (Request, Pointer);
Query_Next := Pointer;
exit;
when others =>
Pointer := Pointer + 1;
Path_Next := Pointer;
end case;
end loop;
Status_Line_Received
( Client => Client,
Scheme => Scheme,
Method => Client.Method,
Port => 0, -- No port
Version => Get_Version,
Host => "", -- No host
Path => From_Escaped
( Request (Path_First..Path_Next - 1)
),
Query => From_Escaped
( Request (Query_First..Query_Next -1)
) );
end if;
end;
end if;
end Process_Request_Line;
procedure Put
( Destination : in out CGI_Content;
Data : String
) is
type Value_Ptr is access String;
for Value_Ptr'Storage_Pool use Destination.Client.Pool;
Value : String renames Destination.Client.Line.Value.all;
Last : Natural renames Destination.Client.Line.Last;
begin
for Index in Data'Range loop
case Destination.State is
when CGI_Value =>
if Data (Index) = '&' then
if Destination.Offset /= 0 then
declare
Ptr : Value_Ptr;
begin
Ptr :=
new String'
( From_Escaped
( Value (Value'First..Last),
True
) );
Last := 0;
Replace
( Destination.Keys.all,
Destination.Offset,
Ptr.all'Unchecked_Access
);
if Destination.Client.Trace_Body then
Trace
( Destination.Client.all,
( "CGI "
& Quote
( GetName
( Destination.Keys.all,
Destination.Offset
),
'''
)
& '='
& Quote
( GetTag
( Destination.Keys.all,
Destination.Offset
) .all,
'''
) ) );
end if;
end;
end if;
Destination.State := CGI_Key;
else
if Last < Value'Last then
Last := Last + 1;
Value (Last) := Data (Index);
else
Raise_Exception
( Data_Error'Identity,
( "CGI value is longer than "
& Image (Destination.Client.Request_Length)
& " bytes"
) );
end if;
end if;
when CGI_Key =>
if Data (Index) = '=' then
begin
declare
Key : constant String :=
From_Escaped
( Value (Value'First..Last),
True
);
begin
Destination.Offset :=
Locate (Destination.Keys.all, Key);
if Destination.Offset > 0 then
if ( GetTag
( Destination.Keys.all,
Destination.Offset
)
/= null
)
then
Destination.Offset := 0;
end if;
elsif ( Destination.Client.Validate_CGI
and then
Validate_Key
( Destination.Client.all,
Key
) ) then
Add
( Destination.Keys.all,
Key,
null,
Destination.Offset
);
end if;
end;
exception
when others =>
Destination.Offset := 0;
end;
Last := 0;
Destination.State := CGI_Value;
else
if Last < Value'Last then
Last := Last + 1;
Value (Last) := Data (Index);
end if;
end if;
end case;
end loop;
end Put;
procedure Read
( Stream : in out Content_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset
) is
Count : Stream_Element_Count := Item'Length;
procedure Add
( Data : Stream_Element_Array;
First : in out Stream_Element_Offset;
Next : Content_Item_Ptr
) is
pragma Inline (Add);
Size : constant Stream_Element_Count := Data'Last + 1 - First;
begin
if Size > Count then
Last := Last + Count;
Item (Last - Count + 1..Last) :=
Data (First..First + Count - 1);
First := First + Count;
Stream.Length := Stream.Length - Count;
Count := 0;
else
Last := Last + Size;
Count := Count - Size;
Item (Last - Size + 1..Last) := Data (First..Data'Last);
Stream.Length := Stream.Length - Size;
Stream.First := Next;
end if;
end Add;
procedure Add
( Data : String;
First : in out Stream_Element_Offset;
Next : Content_Item_Ptr
) is
pragma Inline (Add);
Size : constant Stream_Element_Count :=
Stream_Element_Offset (Data'Last) + 1 - First;
begin
if Size > Count then
Last := Last + Count;
Item (Last - Count + 1..Last) :=
From_String
( Data
( Integer (First)
.. Integer (First + Count - 1)
) );
First := First + Count;
Stream.Length := Stream.Length - Count;
Count := 0;
else
Last := Last + Size;
Count := Count - Size;
Item (Last - Size + 1..Last) :=
From_String
( Data
( Integer (First)
.. Integer (Data'Last)
) );
Stream.Length := Stream.Length - Size;
Stream.First := Next;
end if;
end Add;
begin
Last := Item'First - 1;
while Count > 0 and then Stream.First /= null loop
declare
This : Content_Item renames Stream.First.all;
begin
case This.Kind is
when Literal_Value =>
Add (This.Data, This.First, This.Next);
when Stream_Elements_Pointer =>
Add (This.Data_Ptr.all, This.First, This.Next);
when String_Pointer =>
Add (This.Text_Ptr.all, This.First, This.Next);
end case;
end;
end loop;
end Read;
procedure Receive_Body
( Client : in out HTTP_Client;
Stream : access Root_Stream_Type'Class
) is
begin
Client.Stream := Stream.all'Unchecked_Access;
end Receive_Body;
procedure Receive_Body
( Client : in out HTTP_Client;
Content : access Content_Destination'Class
) is
begin
Client.Destination := Content.all'Unchecked_Access;
end Receive_Body;
procedure Receive_Body
( Client : in out HTTP_Client;
Content : access CGI_Keys.Table'Class
) is
begin
for Offset in 1..GetSize (Content.all) loop
Replace (Content.all, Offset, null);
end loop;
Client.Destination := Client.CGI'Unchecked_Access;
Client.CGI.Keys := Content.all'Unchecked_Access;
Client.CGI.State := CGI_Key;
Client.CGI.Offset := 0;
Client.Line.Last := 0;
Client.Validate_CGI := False;
end Receive_Body;
procedure Receive_Body
( Client : in out HTTP_Client;
Content : String;
Delimiter : Character := ','
) is
Start : Integer := Content'First;
begin
Erase (Client.CGI.Map);
for Index in Content'Range loop
if Content (Index) = Delimiter then
Replace (Client.CGI.Map, Content (Start..Index - 1), null);
Start := Index + 1;
elsif Index = Content'Last then
Replace (Client.CGI.Map, Content (Start..Index), null);
end if;
end loop;
Client.Destination := Client.CGI'Unchecked_Access;
Client.CGI.Keys := Client.CGI.Map'Unchecked_Access;
Client.CGI.State := CGI_Key;
Client.CGI.Offset := 0;
Client.Line.Last := 0;
Client.Validate_CGI := False;
end Receive_Body;
procedure Receive_Body (Client : in out HTTP_Client) is
begin
Erase (Client.CGI.Map);
Client.Destination := Client.CGI'Unchecked_Access;
Client.CGI.Keys := Client.CGI.Map'Unchecked_Access;
Client.CGI.State := CGI_Key;
Client.CGI.Offset := 0;
Client.Line.Last := 0;
Client.Validate_CGI := True;
end Receive_Body;
procedure Received
( Client : in out HTTP_Client;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset
) is
function Done (Data : Stream_Element_Array) return String is
begin
return (1..Data'Length => '.');
end Done;
function Left (Data : Stream_Element_Array) return String is
begin
return (1..Data'Length => 'x');
end Left;
procedure Store (Data : Stream_Element_Array) is
pragma Inline (Store);
begin
if Data'Length > 0 then
if Client.Stream /= null then
begin
Write (Client.Stream.all, Data);
exception
when Error : others =>
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.Stream.all,
Error
);
Client.Stream := null;
Cleanup_Body_Part (Client);
end;
elsif Client.Destination /= null then
begin
Put (Client.Destination.all, To_String (Data));
exception
when Error : others =>
if ( Client.Destination
= Client.CGI'Unchecked_Access
)
then
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.CGI.Keys.all,
Error
);
else
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.Destination.all,
Error
);
end if;
Client.Destination := null;
Cleanup_Body_Part (Client);
end;
end if;
end if;
end Store;
procedure Store (Data : String) is
pragma Inline (Store);
begin
if Data'Length > 0 then
if Client.Stream /= null then
begin
Write (Client.Stream.all, From_String (Data));
exception
when Error : others =>
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.Stream.all,
Error
);
Client.Stream := null;
Cleanup_Body_Part (Client);
end;
elsif Client.Destination /= null then
begin
Put (Client.Destination.all, Data);
exception
when Error : others =>
if ( Client.Destination
= Client.CGI'Unchecked_Access
)
then
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.CGI.Keys.all,
Error
);
else
Body_Error -- Dispatching call
( HTTP_Client'Class (Client),
Client.Destination.all,
Error
);
end if;
Client.Destination := null;
Cleanup_Body_Part (Client);
end;
end if;
end if;
end Store;
procedure Multipart_Body (Last : Stream_Element_Offset) is
pragma Inline (Multipart_Body);
--
-- |<- Boundary ->| |<- Data ----------------------->|
-- |***+++++ | |xxxxxx|+++++////////////////////|
-- | | | | |
-- | Position Pointer From Last
-- Client.Position
--
-- + - Matched so far as boundary prefix
-- * - Matched as boundary prefix earlier (not in Data buffer)
-- x - Stored as the body
-- / - Data to process
--
Boundary : String renames Client.Boundary.all;
Position : Integer := Client.Position;
Start : constant Stream_Element_Offset := Pointer;
From : Stream_Element_Offset := Pointer;
begin
loop
if Position > Boundary'Last then -- All boundary matched
declare
Tail : Stream_Element_Array renames
Data (Pointer..From - 1 - Boundary'Length);
begin
if Tail'Length > 0 then
if Client.Trace_Body then
Trace
( Client,
( "Multipart body |"
& Image (Tail)
& "| "
& Image (Pointer)
& ".."
& Image (Last)
& " "
& Image (Client.Data_Length - From + Start)
& " more expected"
) );
end if;
Store (Tail);
end if;
end;
Pointer := From;
Client.Data_Length :=
Client.Data_Length - Pointer + Start;
Client.Position := Boundary'First;
Client.Expecting := Multipart_Body_Tail;
if Client.Stream /= null then
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.Stream.all
);
Client.Stream := null;
elsif Client.Destination /= null then
Commit (Client.Destination.all);
if ( Client.Destination
= Client.CGI'Unchecked_Access
)
then
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.CGI.Keys.all
);
else
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.Destination.all
);
end if;
Client.Destination := null;
end if;
Cleanup_Body_Part (Client);
return;
elsif From > Last then -- Everything matched the boundary,
declare -- so far
Tail : Stream_Element_Array renames
Data
( Pointer
.. ( From
- 1
- Stream_Element_Offset
( Position
- Boundary'First
) ) );
begin
if Tail'Length > 0 then
if Client.Trace_Body then
Trace
( Client,
( "Multipart body |"
& Image (Tail)
& "| "
& Image (Pointer)
& ".."
& Image (Last)
& " "
& Image (Client.Data_Length - From + Start)
& " more expected"
) );
end if;
Store (Tail);
end if;
end;
Pointer := From;
Client.Position := Position;
Client.Data_Length :=
Client.Data_Length - Pointer + Start;
return;
elsif Character'Pos (Boundary (Position)) = Data (From) then
Position := Position + 1;
From := From + 1;
elsif Client.Position > Boundary'First then -- Some out of
declare -- buffer data
From : Integer := Boundary'First + 1;
To : constant Integer := Client.Position;
begin
while From < To loop
exit when
Is_Prefix (Boundary (From..To), Boundary);
From := From + 1;
end loop;
if Client.Trace_Body then
Trace
( Client,
( "Multipart body "
& "|"
& Image
( From_String
( Boundary (Boundary'First..From - 1)
) )
& "| "
& Image (Pointer)
& ".."
& Image (Last)
) );
end if;
Store (Boundary (Boundary'First..From - 1));
Position := Boundary'First + To - From;
Client.Position := Position;
end;
elsif Position > Boundary'First then -- Boundary prefix was
From := -- matched, retreating
( From
+ 1
- Stream_Element_Offset (Position - Boundary'First)
);
Position := Boundary'First;
else
From := From + 1;
end if;
end loop;
end Multipart_Body;
procedure WebSocket_Message_End is
Socket : WebSocket_Data renames Client.WebSocket;
Frame : WebSocket_Message renames Socket.Frame.all;
function Status return WebSocket_Status is
begin
if Frame.Pointer > 2 then
return ( WebSocket_Status (Frame.Data (1)) * 256
+ WebSocket_Status (Frame.Data (2))
);
else
return 1000;
end if;
end Status;
function Message return String is
begin
if Frame.Pointer > 2 then
return To_String (Frame.Data (3..Frame.Pointer - 1));
else
return "";
end if;
end Message;
begin
case Frame.Type_Of is
when WebSocket_Binary_Type => -- Binary data frame ended
if Socket.State = Open_Socket then
if Socket.Duplex then
Socket.Context := Current_Task;
end if;
if Client.Trace_Body then
Trace
( Client,
( "WebSocket received binary message ["
& Image (Frame.Data (1..Frame.Pointer - 1))
& "]"
) );
end if;
WebSocket_Received
( HTTP_Client'Class (Client),
Frame.Data (1..Frame.Pointer - 1)
);
end if;
when WebSocket_Text_Type => -- Text data frame ended
if Socket.State = Open_Socket then
if Socket.Duplex then
Socket.Context := Current_Task;
end if;
if Client.Trace_Body then
Trace
( Client,
( "WebSocket received text message ["
& To_String (Frame.Data (1..Frame.Pointer - 1))
& "]"
) );
end if;
WebSocket_Received
( HTTP_Client'Class (Client),
To_String (Frame.Data (1..Frame.Pointer - 1))
);
end if;
when WebSocket_Close_Type =>
if Socket.State = Open_Socket then
if Socket.Duplex then
Socket.Context := Current_Task;
end if;
begin
WebSocket_Closed
( HTTP_Client'Class (Client),
Status,
Message
);
exception
when Error : others =>
Trace
( Client,
( "WebSocket closing callback fault: "
& Exception_Information (Error)
) );
end;
if Socket.State = Open_Socket then
WebSocket_Close (Client, Status, Message);
end if;
end if;
if Socket.State = Closing_Socket then
if Queued_To_Send (Client) = 0 then
WebSocket_Cleanup (Client);
end if;
end if;
when WebSocket_Ping_Type =>
if Socket.State = Open_Socket then
WebSocket_Send
( Client, -- Pong frame
( ( 2#1000_0000# or WebSocket_Pong_Type,
Stream_Element (Frame.Length)
)
& Frame.Data (1..Frame.Length)
) );
end if;
when others => -- Ignore unsupported frames
Trace
( Client,
( "Message of an unsupported type "
& Image (Integer (Frame.Type_Of))
& " ignored"
) );
end case;
end WebSocket_Message_End;
begin
Pointer := Data'First;
while Pointer <= Data'Last loop
case Client.Expecting is
when Body_Data => -- Single body receipt
if Client.Data_Length > 0 then -- Receiving the body
if Client.Data_Length > Data'Last - Pointer + 1 then
Client.Data_Length :=
Client.Data_Length - Data'Last + Pointer - 1;
if Client.Trace_Body then
Trace
( Client,
( "Append body "
& Done (Data (Data'First..Pointer - 1))
& "|"
& Image (Data (Pointer..Data'Last))
& "| "
& Image (Client.Data_Length)
& " more expected"
) );
end if;
Store (Data (Pointer..Data'Last));
Pointer := Data'Last + 1;
else
if Client.Trace_Body then
Trace
( Client,
( "Append body "
& Done (Data (Data'First..Pointer - 1))
& "|"
& Image
( Data
( Pointer
.. Pointer + Client.Data_Length - 1
) )
& "|"
& Left
( Data
( Pointer + Client.Data_Length
.. Data'Last
) )
& " No more expected"
) );
end if;
Store
( Data
( Pointer
.. Pointer + Client.Data_Length - 1
) );
Pointer := Pointer + Client.Data_Length;
Client.Data_Length := 0;
end if;
end if;
if Client.Data_Length = 0 then -- End of chunk
if Client.Chunked then -- Chunked receipt
Client.Chunk_Type := Body_Data;
Client.Expecting := Chunk_Line;
else -- Explicit length body
if Client.Stream /= null then
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.Stream.all
);
Client.Stream := null;
elsif Client.Destination /= null then
Commit (Client.Destination.all);
if ( Client.Destination
= Client.CGI'Unchecked_Access
)
then
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.CGI.Keys.all
);
else
Body_Received -- Dispatching call
( HTTP_Client'Class (Client),
Client.Destination.all
);
end if;
Client.Destination := null;
end if;
Cleanup_Body_Part (Client);
Process_Request (Client);
end if;
end if;
when Multipart_Body_Data => -- Receiving multipart body
if Client.Data_Length > 0 then -- Receiving a body part
if Client.Data_Length > Data'Last - Pointer + 1 then
Multipart_Body (Data'Last);
else
Multipart_Body (Pointer + Client.Data_Length - 1);
end if;
end if;
if Client.Data_Length = 0 then -- End of chunk
if Client.Chunked then -- Chunked receipt
Client.Chunk_Type := Multipart_Body_Data;
Client.Expecting := Chunk_Line;
else -- Explicit length
if Client.Expecting = Multipart_Epilogue then
Process_Request (Client);
else
Raise_Exception
( Data_Error'Identity,
"Malformed multipart body"
);
end if;
end if;
end if;
when Multipart_Body_Tail =>
Receive_Multipart_Line
( Client,
Data,
Pointer,
Process_Body_Tail'Access
);
when Multipart_Preamble => -- Multipart lines and headers
Receive_Multipart_Line
( Client,
Data,
Pointer,
Process_Preamble'Access
);
when Multipart_Header_Line =>
Receive_Multipart_Line
( Client,
Data,
Pointer,
Process_Part_Header'Access
);
when Multipart_Epilogue =>
Receive_Multipart_Line
( Client,
Data,
Pointer,
Process_Epilogue'Access
);
when Request_Line =>
Receive_Header_Line
( Client,
Data,
Pointer,
Process_Request_Line'Access
);
when Header_Line =>
Receive_Header_Line
( Client,
Data,
Pointer,
Process_Header_Line'Access
);
when Chunk_Line =>
Receive_Header_Line
( Client,
Data,
Pointer,
Process_Chunk_Line'Access
);
when WebSocket_Header =>
declare
Octet : constant Stream_Element := Data (Pointer);
Socket : WebSocket_Data renames Client.WebSocket;
begin
Socket.Final := 0 /= (Octet and 2#1000_0000#);
if 0 /= (Octet and 2#0111_0000#) then
Raise_Exception
( Data_Error'Identity,
"RSV bits must be cleared"
);
end if;
Socket.Frame_Type := Octet and 2#1111#;
Client.Expecting := WebSocket_Length;
Pointer := Pointer + 1;
end;
when WebSocket_Length =>
declare
Octet : constant Stream_Element := Data (Pointer);
Socket : WebSocket_Data renames Client.WebSocket;
begin
if 0 = (Octet and 2#1000_0000#) then
Raise_Exception
( Data_Error'Identity,
"Mask bit must be set"
);
end if;
Socket.Frame_Length :=
Stream_Element_Count (Octet and 2#0111_1111#);
if Socket.Frame_Type >= 8 then -- A control frame
if Socket.Frame_Length > 125 then
Raise_Exception
( Data_Error'Identity,
"Control frame length is greater than 125"
);
end if;
Socket.Frame := Socket.Control'Unchecked_Access;
declare
Frame : WebSocket_Message renames
Socket.Frame.all;
begin
Frame.Type_Of := Socket.Frame_Type;
Frame.Length := Socket.Frame_Length;
Frame.Pointer := 1;
Socket.Mask_Index := 0;
Client.Expecting := WebSocket_Mask;
end;
else -- A data frame
Socket.Frame := Socket.Data;
declare
Frame : WebSocket_Message renames
Socket.Frame.all;
begin
if Socket.Pending then -- A message is pending
if ( Socket.Frame_Type
/= WebSocket_Continunation_Type
)
then
Raise_Exception
( Data_Error'Identity,
"Missing message continuation frame"
);
end if;
else -- A new frame
Frame.Type_Of := Socket.Frame_Type;
Frame.Length := 0;
Frame.Pointer := 1;
if ( Socket.Frame_Type
= WebSocket_Continunation_Type
)
then
Raise_Exception
( Data_Error'Identity,
"Unsolicited continuation frame"
);
end if;
end if;
Socket.Pending := not Socket.Final;
if Socket.Frame_Length < 126 then
Frame.Length :=
Frame.Length + Socket.Frame_Length;
Socket.Mask_Index := 0;
Client.Expecting := WebSocket_Mask;
else
if Socket.Frame_Length = 126 then
Socket.Length_Count := 2; -- Two more
else
Socket.Length_Count := 8; -- Eight more
end if;
Socket.Frame_Length := 0;
Client.Expecting := WebSocket_Length_Ex;
end if;
end;
end if;
Pointer := Pointer + 1;
end;
when WebSocket_Length_Ex =>
declare
Socket : WebSocket_Data renames Client.WebSocket;
Frame : WebSocket_Message renames Socket.Frame.all;
begin
Socket.Frame_Length :=
( Socket.Frame_Length * 256
+ Stream_Element_Count (Data (Pointer))
);
if ( not Socket.Chunked
and then
Socket.Frame_Length > Socket.Max_Length
)
then
Raise_Exception
( Status_Error'Identity,
"Data message length exceeds the limit set"
);
end if;
if Socket.Length_Count = 1 then
Frame.Length := Frame.Length + Socket.Frame_Length;
if ( not Socket.Chunked
and then
Frame.Length > Socket.Max_Length
)
then
Raise_Exception
( Status_Error'Identity,
"Data message length exceeds the limit set"
);
end if;
Socket.Mask_Index := 0;
Client.Expecting := WebSocket_Mask;
else
Socket.Length_Count := Socket.Length_Count - 1;
end if;
Pointer := Pointer + 1;
end;
when WebSocket_Mask =>
declare
Socket : WebSocket_Data renames Client.WebSocket;
begin
Socket.Mask (Socket.Mask_Index) := Data (Pointer);
Socket.Mask_Index := Socket.Mask_Index + 1;
Pointer := Pointer + 1;
if Socket.Mask_Index = 0 then
if Socket.Frame.Length > 0 then
Client.Expecting := WebSocket_Payload_Data;
else -- No payload data
Client.Expecting := WebSocket_Header;
if Socket.Final then
WebSocket_Message_End;
end if;
end if;
end if;
end;
when WebSocket_Payload_Data =>
declare
Socket : WebSocket_Data renames Client.WebSocket;
Frame : WebSocket_Message renames Socket.Frame.all;
begin
while Pointer <= Data'Last loop
exit when Frame.Pointer > Frame.Length;
if Socket.Chunked then
if Frame.Pointer > Frame.Data'Last then
if Socket.Duplex then
Socket.Context := Current_Task;
end if;
if Socket.Frame_Type = WebSocket_Binary_Type then
if Client.Trace_Body then
Trace
( Client,
( "WebSocket received binary "
& "message part ["
& Image (Frame.Data)
& "]"
) );
end if;
WebSocket_Received_Part
( HTTP_Client'Class (Client),
Frame.Data (1..Frame.Pointer - 1)
);
else
if Client.Trace_Body then
Trace
( Client,
( "WebSocket received text "
& "message part ["
& To_String (Frame.Data)
& "]"
) );
end if;
WebSocket_Received_Part
( HTTP_Client'Class (Client),
To_String (Frame.Data)
);
end if;
Frame.Pointer := Frame.Data'First;
Frame.Length :=
Frame.Length - Frame.Data'Length;
end if;
end if;
Frame.Data (Frame.Pointer) :=
( Data (Pointer)
xor
Socket.Mask (Socket.Mask_Index)
);
Socket.Mask_Index := Socket.Mask_Index + 1;
Frame.Pointer := Frame.Pointer + 1;
Pointer := Pointer + 1;
end loop;
if Frame.Pointer > Frame.Length then
Client.Expecting := WebSocket_Header;
if Socket.Final then
WebSocket_Message_End;
end if;
end if;
end;
end case;
end loop;
exception
when Error : others =>
if Client.WebSocket.State /= Closed_Socket then
if Client.Trace_Body then
Trace
( Client,
"WebSocket error " & Exception_Message (Error)
);
end if;
begin
WebSocket_Error (HTTP_Client'Class (Client), Error);
exception
when Error : others =>
Trace
( Client,
( "WebSocket error callback fault: "
& Exception_Information (Error)
) );
end;
WebSocket_Cleanup (Client);
end if;
raise;
end Received;
procedure Receive_Body_Tracing
( Client : in out HTTP_Client;
Enable : Boolean
) is
begin
Client.Trace_Body := Enable;
end Receive_Body_Tracing;
procedure Receive_Header_Tracing
( Client : in out HTTP_Client;
Enable : Boolean
) is
begin
Client.Trace_Header := Enable;
end Receive_Header_Tracing;
procedure Receive_Header_Line
( Client : in out HTTP_Client'Class;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Handler : Completion
) is
begin
Get_Header_Line : loop
Client.Start := Pointer;
Feed
( Client.Data.List (Client.Data.Current).all,
Data,
Pointer,
Client,
Client.State
);
Client.Fed :=
Client.Fed + Unsigned_64 (Pointer - Client.Start);
if Client.State = 0 then -- Done with this item
Client.Data.Current := Client.Data.Current + 1;
while Client.Data.Current > Client.Data.Length loop
if Client.Data.Caller = null then
Client.Data.Current := 1;
Handler (Client);
exit Get_Header_Line;
end if;
Client.State := Client.Data.State; -- Restore state
Client.Data := Client.Data.Caller;
if Client.State /= 0 then
End_Of_Subsequence
( Client.Data.List (Client.Data.Current).all,
Data,
Pointer,
Client,
Client.State
);
exit when Client.State /= 0;
end if;
Client.Data.Current := Client.Data.Current + 1;
end loop;
else
exit when Pointer > Data'Last; -- All data consumed
Raise_Exception
( Status_Error'Identity,
( "Unprocessed data left when after return from "
& Expanded_Name
( Client.Data.List (Client.Data.Current).all'Tag
) ) );
end if;
end loop Get_Header_Line;
end Receive_Header_Line;
procedure Receive_Multipart_Line
( Client : in out HTTP_Client'Class;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Handler : Completion
) is
begin
Get_Header_Line : while Client.Data_Length > 0 loop
if Client.Data_Length > Data'Last - Pointer + 1 then
declare
Start : constant Stream_Element_Offset := Pointer;
Slice : Stream_Element_Array renames
Data (Pointer..Data'Last);
begin
exit when Slice'Length = 0;
Feed
( Client.Data.List (Client.Data.Current).all,
Slice,
Pointer,
Client,
Client.State
);
Client.Fed := Client.Fed + Unsigned_64 (Pointer - Start);
Client.Data_Length :=
Client.Data_Length - Pointer + Start;
end;
else
declare
Start : constant Stream_Element_Offset := Pointer;
Slice : Stream_Element_Array renames
Data (Pointer..Pointer + Client.Data_Length - 1);
begin
exit when Slice'Length = 0;
Feed
( Client.Data.List (Client.Data.Current).all,
Slice,
Pointer,
Client,
Client.State
);
Client.Fed := Client.Fed + Unsigned_64 (Pointer - Start);
Client.Data_Length :=
Client.Data_Length - Pointer + Start;
end;
end if;
if Client.State = 0 then -- Done with this item
Client.Data.Current := Client.Data.Current + 1;
while Client.Data.Current > Client.Data.Length loop
if Client.Data.Caller = null then
Client.Data.Current := 1;
Handler (Client);
exit Get_Header_Line;
end if;
Client.Data := Client.Data.Caller;
Client.Data.Current := Client.Data.Current + 1;
end loop;
else
exit when Pointer > Data'Last;
Raise_Exception
( Status_Error'Identity,
( "Unprocessed data left when after return from "
& Expanded_Name
( Client.Data.List (Client.Data.Current).all'Tag
) ) );
end if;
end loop Get_Header_Line;
if Client.Data_Length = 0 then -- End of chunk
if Client.Chunked then -- Chunked receipt
Client.Chunk_Type := Client.Expecting;
Client.Expecting := Chunk_Line;
else -- Explicit length
if Client.Expecting = Multipart_Epilogue then
Client.Expecting := Header_Line;
Process_Request (Client);
else
Raise_Exception
( Data_Error'Identity,
"Malformed multipart body"
);
end if;
end if;
end if;
end Receive_Multipart_Line;
procedure Reply_HTML
( Client : in out HTTP_Client;
Code : Positive;
Reason : String;
Message : String;
Get : Boolean := True
) is
begin
Send_Status_Line (Client, Code, Reason);
Send_Date (Client);
Send_Content_Type (Client, "text/html");
Send_Connection (Client, False);
if Get then
Send_Body (Client, Message);
end if;
end Reply_HTML;
procedure Reply_Text
( Client : in out HTTP_Client;
Code : Positive;
Reason : String;
Message : String;
Get : Boolean := True
) is
begin
Send_Status_Line (Client, Code, Reason);
Send_Date (Client);
Send_Content_Type (Client, "text/plain");
Send_Connection (Client, False);
if Get then
Send_Body (Client, Message);
end if;
end Reply_Text;
procedure Send
( Client : in out HTTP_Client;
Message : String
) is
Pointer : Integer := Message'First;
begin
Send (Client, Message, Pointer);
if Pointer <= Message'Last then
Raise_Exception
( Data_Error'Identity,
( "Output buffer overrun, "
& Image (Queued_To_Send (Client))
& " elements queued, space for at least more "
& Image (Message'Last - Pointer + 1)
& " requred (available "
& Image (Available_To_Send (Client))
& ")"
) );
end if;
end Send;
procedure Send
( Client : in out HTTP_Client;
Message : Stream_Element_Array
) is
Pointer : Stream_Element_Offset := Message'First;
begin
Send (Client, Message, Pointer);
if Pointer <= Message'Last then
Raise_Exception
( Data_Error'Identity,
( "Output buffer overrun, "
& Image (Queued_To_Send (Client))
& " elements queued, space for at least more "
& Image (Message'Last - Pointer + 1)
& " requred (available "
& Image (Available_To_Send (Client))
& ")"
) );
end if;
end Send;
procedure Send_Accept_Ranges
( Client : in out HTTP_Client;
Accept_Ranges : Boolean
) is
begin
if Accept_Ranges then
Send (Client, "Accept-Ranges: bytes" & CRLF);
else
Send (Client, "Accept-Ranges: none" & CRLF);
end if;
end Send_Accept_Ranges;
procedure Send_Age (Client : in out HTTP_Client; Age : Duration) is
Value : Unsigned_32;
begin
if Age = Duration'Last then
Send (Client, "Age: 2147483648" & CRLF);
elsif Age <= 0.0 then
Send (Client, "Age: 0" & CRLF);
else
Value := Unsigned_32 (Age);
Send (Client, "Age:" & Unsigned_32'Image (Value) & CRLF);
end if;
exception
when Constraint_Error =>
Send (Client, "Age: 2147483648" & CRLF);
end Send_Age;
procedure Send_Allow
( Client : in out HTTP_Client;
Allowed : HTTP_Allowed
) is
First : Boolean := True;
Text : String (1..120);
Pointer : Integer := Text'First;
begin
Put (Text, Pointer, "Allow:");
for Index in 1..GetSize (Commands) loop
if Allowed (GetTag (Commands, Index)) then
if First then
First := False;
else
Put (Text, Pointer, ", ");
end if;
Put (Text, Pointer, GetName (Commands, Index));
end if;
end loop;
Put (Text, Pointer, CRLF);
Send (Client, Text (Text'First..Pointer - 1));
end Send_Allow;
procedure Send_Body
( Client : in out HTTP_Client;
Stream : access Root_Stream_Type'Class;
Get : Boolean := True
) is
begin
Client.Stream := Stream.all'Unchecked_Access;
Send (Client, "Transfer-Encoding: chunked" & CRLF);
if Get then
Send (Client, CRLF);
Client.Chunked := True;
Continue (Client, Stream_Chunk'Access);
else
Body_Sent (Client, Client.Stream.all, Get);
end if;
end Send_Body;
procedure Send_Body
( Client : in out HTTP_Client;
Stream : access Root_Stream_Type'Class;
Length : Stream_Element_Count;
Get : Boolean := True
) is
begin
Client.Stream := Stream.all'Unchecked_Access;
Send (Client, "Content-Length: " & Image (Length) & CRLF);
Client.Data_Length := Length;
if Get then
Send (Client, CRLF);
Client.Chunked := False;
Continue (Client, Stream_Chunk'Access);
else
Body_Sent (Client, Client.Stream.all, Get);
end if;
end Send_Body;
procedure Send_Body
( Client : in out HTTP_Client;
Content : access Content_Source'Class;
Get : Boolean := True
) is
begin
Client.Source := Content.all'Unchecked_Access;
Send (Client, "Transfer-Encoding: chunked" & CRLF);
if Get then
Send (Client, CRLF);
Client.Chunked := True;
Continue (Client, Content_Chunk'Access);
end if;
end Send_Body;
procedure Send_Body
( Client : in out HTTP_Client;
Content : access Content_Source'Class;
Length : Stream_Element_Count;
Get : Boolean := True
) is
begin
Client.Source := Content.all'Unchecked_Access;
Send (Client, "Content-Length: " & Image (Length) & CRLF);
Client.Data_Length := Length;
if Get then
Send (Client, CRLF);
Client.Chunked := False;
Continue (Client, Content_Chunk'Access);
end if;
end Send_Body;
procedure Send_Body
( Client : in out HTTP_Client;
Get : Boolean := True
) is
begin
Send_Body
( Client => Client,
Stream => Client.Body_Content'Unchecked_Access,
Length => Accumulated_Body_Length (Client),
Get => Get
);
end Send_Body;
procedure Send_Body
( Client : in out HTTP_Client;
Content : String;
Get : Boolean := True
) is
begin
Send_Length (Client, Natural'(Content'Length));
Send (Client, CRLF);
if Get then
Send (Client, Content);
Send (Client, CRLF);
end if;
end Send_Body;
procedure Send_Connection
( Client : in out HTTP_Client;
Persistent : Boolean := True
) is
begin
if ( 0 = (Client.Connection and Connection_Close)
and
Persistent
) then
Send (Client, "Connection: keep-alive" & CRLF);
else
Client.Connection := Client.Connection or Connection_Close;
Send (Client, "Connection: close" & CRLF);
end if;
end Send_Connection;
procedure Send_Content_Range
( Client : in out HTTP_Client;
Content_Range : String := "none"
) is
begin
Send (Client, "Content-Range: " & Content_Range & CRLF);
end Send_Content_Range;
procedure Send_Content_Range
( Client : in out HTTP_Client;
From : Stream_Element_Count;
To : Stream_Element_Count;
Length : Stream_Element_Count
) is
begin
Send
( Client,
( "Content-Range: "
& Image (From)
& '-'
& Image (To)
& '/'
& Image (Length)
& CRLF
) );
end Send_Content_Range;
procedure Send_Content_Type
( Client : in out HTTP_Client;
Media : String := "text/plain";
Charset : String := "UTF-8"
) is
begin
Send
( Client,
"Content-Type: " & Media & "; charset=" & Charset & CRLF
);
end Send_Content_Type;
procedure Send_Date
( Client : in out HTTP_Client;
Date : Time := Clock
) is
begin
Send (Client, "Date: " & To_HTTP (Date) & CRLF);
end Send_Date;
procedure Send_If_Modified_Since
( Client : in out HTTP_Client;
Date : Time
) is
begin
Send (Client, "If-Modified-Since: " & To_HTTP (Date) & CRLF);
end Send_If_Modified_Since;
procedure Send_If_Unmodified_Since
( Client : in out HTTP_Client;
Date : Time
) is
begin
Send (Client, "If-Unmodified-Since: " & To_HTTP (Date) & CRLF);
end Send_If_Unmodified_Since;
procedure Send_Last_Modified
( Client : in out HTTP_Client;
Date : Time
) is
begin
Send (Client, "Last-Modified: " & To_HTTP (Date) & CRLF);
end Send_Last_Modified;
procedure Send_Length
( Client : in out HTTP_Client;
Length : Natural
) is
begin
Send (Client, "Content-Length: " & Image (Length) & CRLF);
end Send_Length;
procedure Send_Length
( Client : in out HTTP_Client;
Length : Stream_Element_Count
) is
begin
Send (Client, "Content-Length: " & Image (Length) & CRLF);
end Send_Length;
procedure Send_Server (Client : in out HTTP_Client) is
begin
Send
( Client,
"Server: " & Get_Name (HTTP_Client'Class (Client)) & CRLF
);
end Send_Server;
procedure Send_Status_Line
( Client : in out HTTP_Client;
Code : Positive;
Text : String;
Version : String := "HTTP/1.1"
) is
begin
Send (Client, Version & " " & Image (Code) & ' ');
Send (Client, Text);
Send (Client, CRLF);
end Send_Status_Line;
procedure Sent (Client : in out HTTP_Client) is
Chain : Action;
begin
if Queued_To_Send (Client) = 0 then
Chain := Client.Chain;
Client.Chain := null;
if Chain /= null then
Chain (Client);
elsif 0 /= (Client.Connection and Connection_Close) then
raise Connection_Error; -- I am done
else
case Client.WebSocket.State is
when Open_Socket | Closed_Socket =>
null;
when Closing_Socket =>
WebSocket_Cleanup (Client);
end case;
end if;
end if;
exception
when Error : others =>
if Client.WebSocket.State /= Closed_Socket then
if Client.Trace_Body then
Trace
( Client,
"WebSocket error " & Exception_Message (Error)
);
end if;
begin
WebSocket_Error (HTTP_Client'Class (Client), Error);
exception
when Error : others =>
Trace
( Client,
( "WebSocket error callback fault: "
& Exception_Information (Error)
) );
end;
WebSocket_Cleanup (Client);
end if;
raise;
end Sent;
procedure Send_Content
( Client : in out HTTP_Client;
Data : Stream_Element_Array
) is
Length : constant Stream_Element_Count :=
Available_To_Send (Client);
begin
if Data'Length = 0 then
return;
end if;
if Client.Stub = null and then Length >= Data'Length then
Send (Client, Data); -- Send all at once
else -- Send as much as we can
Send (Client, Data (Data'First..Data'First + Length - 1));
Queue_Content (Client, Data (Data'First + Length..Data'Last));
end if;
end Send_Content;
procedure Send_Content
( Client : in out HTTP_Client;
Data : String
) is
Length : constant Stream_Element_Count :=
Available_To_Send (Client);
begin
if Data'Length = 0 then
return;
end if;
if Client.Stub = null and then Length >= Data'Length then
Send (Client, Data);
else -- Send as much as we can
Send
( Client,
Data (Data'First..Data'First + Integer (Length) - 1)
);
Queue_Content
( Client,
Data (Data'First + Integer (Length)..Data'Last)
);
end if;
end Send_Content;
procedure Set_Allowed
( Client : in out HTTP_Client;
Allowed : HTTP_Allowed
) is
begin
Client.Allowed := Allowed;
end Set_Allowed;
procedure Set_Failed
( Client : in out HTTP_Client;
Error : Exception_Occurrence
) is
begin
Client.Mutex.Failed (Error);
end Set_Failed;
procedure Skip (Source : String; Pointer : in out Integer) is
begin
while Pointer <= Source'Last loop
case Source (Pointer) is
when ' ' | Character'Val (9) =>
exit;
when others =>
Pointer := Pointer + 1;
end case;
end loop;
end Skip;
procedure Status_Line_Received
( Client : in out HTTP_Client;
Method : HTTP_Method;
Version : HTTP_Version
) is
begin
Client.Method := Method;
Client.Version := Version;
end Status_Line_Received;
procedure Status_Line_Received
( Client : in out HTTP_Client;
Method : HTTP_Method;
Path : String;
Query : String;
Version : HTTP_Version
) is
type Status_Ptr is access Status_Line;
for Status_Ptr'Storage_Pool use Client.Pool;
Ptr : constant Status_Ptr :=
new Status_Line'
( Kind => File,
Path_Length => Path'Length,
Host_Length => 0,
Query_Length => Query'Length,
File => Path,
Query => Query
);
begin
Client.Method := Method;
Client.Version := Version;
Client.Status := Ptr.all'Unchecked_Access;
end Status_Line_Received;
procedure Status_Line_Received
( Client : in out HTTP_Client;
Scheme : Scheme_Type;
Method : HTTP_Method;
Host : String;
Port : Port_Type;
Path : String;
Query : String;
Version : HTTP_Version
) is
type Status_Ptr is access Status_Line;
for Status_Ptr'Storage_Pool use Client.Pool;
Ptr : constant Status_Ptr :=
new Status_Line'
( Kind => URI,
Scheme => Scheme,
Path_Length => Path'Length,
Host_Length => Host'Length,
Query_Length => Query'Length,
Host => Host,
Port => Port,
Path => Path,
Query => Query
);
begin
Client.Method := Method;
Client.Version := Version;
Client.Status := Ptr.all'Unchecked_Access;
end Status_Line_Received;
procedure Stream_Chunk (Client : in out HTTP_Client'Class) is
Done : Boolean;
begin
if Client.Stream /= null then
if Client.Chunked then -- Chunked transfer
Send
( Client => Client,
Stream => Client.Stream.all,
Reserve => 18,
Get_Prefix => Get_Prefix'Access,
Get_Suffix => Get_Suffix'Access,
End_Of_Stream => Done
);
if Done then
Body_Sent (Client, Client.Stream.all, True);
Client.Stream := null;
else
Continue (Client, Stream_Chunk'Access);
end if;
else
Send
( Client => Client,
Stream => Client.Stream.all,
Count => Client.Data_Length,
End_Of_Stream => Done
);
if Done then
if Client.Data_Length > 0 then
Raise_Exception
( Data_Error'Identity,
( "Missing "
& Image (Client.Data_Length)
& " streamed data to transfer"
) );
end if;
Body_Sent (Client, Client.Stream.all, True);
Client.Stream := null;
else
if Client.Data_Length = 0 then
Body_Sent (Client, Client.Stream.all, True);
Client.Stream := null;
else
Continue (Client, Stream_Chunk'Access);
end if;
end if;
end if;
end if;
end Stream_Chunk;
function To_Escaped (Name : String) return String is
Length : Natural := 0;
begin
for Index in Name'Range loop
case Name (Index) is
when 'A'..'Z' | 'a'..'z' | '0'..'9' |
'-' | '_' | '.' | '!' | '~' | '*' | ''' | '(' | ')' =>
Length := Length + 1;
when others =>
Length := Length + 3;
end case;
end loop;
declare
Pointer : Integer := 1;
Result : String (1..Length);
begin
for Index in Name'Range loop
case Name (Index) is
when 'A'..'Z' | 'a'..'z' | '0'..'9' |
'-' | '_' | '.' | '!' | '~' | '*' |
''' | '(' | ')' =>
Result (Pointer) := Name (Index);
Pointer := Pointer + 1;
when others =>
Result (Pointer) := '%';
Pointer := Pointer + 1;
Strings_Edit.Integers.Put
( Destination => Result,
Pointer => Pointer,
Value => Character'Pos (Name (Index)),
Base => 16,
Field => 2,
Justify => Right,
Fill => '0'
);
end case;
end loop;
return Result;
end;
end To_Escaped;
function To_Flags (Value : String) return Connection_Flags is
Result : Connection_Flags := 0;
Start : Integer := Value'First;
procedure Add (Field : String) is
Index : constant Integer := Locate (Connections, Trim (Field));
begin
if Index > 0 then
Result := Result or GetTag (Connections, Index);
end if;
end Add;
begin
for Pointer in Value'Range loop
if Value (Pointer) = ',' then
if Start <= Pointer - 1 then
Add (Value (Start..Pointer - 1));
end if;
Start := Pointer + 1;
end if;
end loop;
if Start <= Value'Last then
Add (Value (Start..Value'Last));
end if;
return Result;
end To_Flags;
function To_HTML (Text : String) return String is
use Strings_Edit.UTF8;
Length : Natural := 0;
Pointer : Integer := Text'First;
Code : UTF8_Code_Point;
begin
while Pointer <= Text'Last loop
Get (Text, Pointer, Code);
case Code is
when Character'Pos ('<') | Character'Pos ('>') =>
Length := Length + 4;
when Character'Pos ('&') =>
Length := Length + 5;
when Character'Pos ('"') =>
Length := Length + 6;
when 32..33 | 35..37 | 39..59 | 61 | 63..126 =>
Length := Length + 1;
when others =>
if Code <= 16#F# then
Length := Length + 5;
elsif Code <= 16#FF# then
Length := Length + 6;
elsif Code <= 16#FFF# then
Length := Length + 7;
elsif Code <= 16#FFFF# then
Length := Length + 8;
elsif Code <= 16#FFFFF# then
Length := Length + 9;
else
Length := Length + 10;
end if;
end case;
end loop;
Pointer := Text'First;
declare
Result : String (1..Length);
Index : Integer := 1;
begin
while Pointer <= Text'Last loop
Get (Text, Pointer, Code);
case Code is
when Character'Pos ('<') =>
Put (Result, Index, "<");
when Character'Pos ('>') =>
Put (Result, Index, ">");
when Character'Pos ('&') =>
Put (Result, Index, "&");
when Character'Pos ('"') =>
Put (Result, Index, """);
when 32..33 | 35..37 | 39..59 | 61 | 63..126 =>
Result (Index) := Character'Val (Code);
Index := Index + 1;
when others =>
Put (Result, Index, "&#x");
Put (Result, Index, Integer (Code), Base => 16);
Put (Result, Index, ";");
end case;
end loop;
return Result (1..Index - 1);
end;
end To_HTML;
procedure Trace
( Client : in out HTTP_Client;
Message : String
) is
begin
Trace
( Client.Listener.Factory.all,
( Get_Client_Name (Client.Listener.Factory.all, Client)
& ' '
& Message
) );
end Trace;
function Validate_Key
( Client : HTTP_Client;
Key : String
) return Boolean is
begin
return True;
end Validate_Key;
function Value (Text : String) return Header_Value is
Index : constant Integer := Locate (Request_Headers, Text);
begin
if Index > 0 then
return
( None => False,
Header => GetTag (Request_Headers, Index)
);
else
return (None => True);
end if;
end Value;
procedure WebSocket_Blocking_Send
( Client : in out HTTP_Client'Class;
Data : Stream_Element_Array;
First : Boolean;
Last : Boolean
) is
Pointer : Stream_Element_Offset := Data'First;
Next : Stream_Element_Offset;
begin
if First then
Client.Mutex.Seize;
end if;
begin
if Data'Length > 0 then
while Pointer <= Data'Last loop
Push (Client, Data (Pointer..Data'Last), Next);
if Next < Pointer then
raise Connection_Error;
end if;
if Client.Trace_Body then
Trace
( Client,
( "WebSocket message part sent ["
& Image (Data (Pointer..Next))
& "] "
& Image (Pointer)
& ".."
& Image (Next)
& "/"
& Image (Data'Last)
) );
end if;
Pointer := Next + 1;
end loop;
if Last then
Client.Mutex.Set (Idle);
end if;
end if;
exception
when Error : Connection_Error =>
Set_Failed (Client, Error);
Raise_Exception
( End_Error'Identity,
"Connection closed by peer"
);
when Error : others =>
Set_Failed (Client, Error);
raise;
end;
end WebSocket_Blocking_Send;
procedure WebSocket_Finalize (Client : in out HTTP_Client) is
begin
null;
end WebSocket_Finalize;
procedure WebSocket_Cleanup (Client : in out HTTP_Client'Class) is
Socket : WebSocket_Data renames Client.WebSocket;
begin
if Socket.State /= Closed_Socket then
if Client.Trace_Body then
Trace (Client, "WebSocket closing connection ...");
end if;
if Socket.Duplex then
Client.Mutex.Set (Disabled);
end if;
begin
if Client.Trace_Body then
Trace (Client, "WebSocket finalizing ...");
end if;
WebSocket_Finalize (Client);
exception
when Error : others =>
Trace
( Client,
( "WebSocket finalization callback fault: "
& Exception_Information (Error)
) );
end;
Set_Overlapped_Size (Client, 0); -- Disabe full-duplex mode
Client.Stub := null;
if Socket.Data /= null then
declare
type Message_Ptr is access WebSocket_Message;
for Message_Ptr'Storage_Pool use Client.Pool;
function To_Message_Ptr is
new Ada.Unchecked_Conversion
( WebSocket_Message_Ptr,
Message_Ptr
);
procedure Free is
new Ada.Unchecked_Deallocation
( WebSocket_Message,
Message_Ptr
);
Ptr : Message_Ptr := To_Message_Ptr (Socket.Data);
begin
Free (Ptr);
Socket.Data := null;
end;
end if;
Socket.State := Closed_Socket;
Socket.Pending := False;
Socket.Duplex := False;
Client.Expecting := Request_Line;
end if;
end WebSocket_Cleanup;
procedure WebSocket_Close
( Client : in out HTTP_Client;
Status : WebSocket_Status := WebSocket_Normal_Closure;
Message : String := ""
) is
begin
if Message'Length > 123 then
Raise_Exception
( Constraint_Error'Identity,
"WebSocket closing message is longer than 123 bytes"
);
elsif Client.WebSocket.State = Open_Socket then
declare
Header : constant Stream_Element_Array :=
( 2#1000_0000# or WebSocket_Close_Type,
Stream_Element (Message'Length + 2),
Stream_Element (Status / 256),
Stream_Element (Status mod 256)
);
begin
if Client.WebSocket.Duplex then
WebSocket_Send (Client, Header & From_String (Message));
Client.Mutex.Set (Closing);
Client.WebSocket.State := Closing_Socket;
else
Send_Content (Client, Header);
Send_Content (Client, Message);
if Queued_To_Send (Client) = 0 then
WebSocket_Cleanup (Client);
else
Client.WebSocket.State := Closing_Socket;
end if;
end if;
end;
else
Raise_Exception (End_Error'Identity, "No WebSocket open");
end if;
end WebSocket_Close;
procedure WebSocket_Closed
( Client : in out HTTP_Client;
Status : WebSocket_Status;
Message : String
) is
begin
null;
end WebSocket_Closed;
procedure WebSocket_Error
( Client : in out HTTP_Client;
Error : Exception_Occurrence
) is
begin
null;
end WebSocket_Error;
procedure WebSocket_Initialize (Client : in out HTTP_Client) is
begin
null;
end WebSocket_Initialize;
function WebSocket_Header
( Length : Stream_Element_Count;
Frame : WebSocket_Frame_Type
) return Stream_Element_Array is
begin
if Length < 126 then
return
( 1 => 2#1000_0000# or Frame,
2 => Stream_Element (Length)
);
elsif Length < 2**16 then
return
( 1 => 2#1000_0000# or Frame,
2 => 126,
3 => Stream_Element (Length / 256),
4 => Stream_Element (Length mod 256)
);
else
declare
use Big_Endian.Unsigneds;
Header : Stream_Element_Array (1..10);
Pointer : Stream_Element_Offset := 3;
begin
Header (1) := 2#1000_0000# or Frame;
Header (2) := 127;
Put (Header, Pointer, Unsigned_64 (Length));
return Header;
end;
end if;
end WebSocket_Header;
function WebSocket_Open
( Client : access HTTP_Client
) return WebSocket_Accept is
begin
return
( Accepted => False,
Code => 501,
Length => Default_Response'Length,
Reason => Default_Response
);
end WebSocket_Open;
procedure WebSocket_Received
( Client : in out HTTP_Client;
Message : Stream_Element_Array
) is
begin
null;
end WebSocket_Received;
procedure WebSocket_Received
( Client : in out HTTP_Client;
Message : String
) is
begin
null;
end WebSocket_Received;
procedure WebSocket_Received_Part
( Client : in out HTTP_Client;
Message : Stream_Element_Array
) is
begin
null;
end WebSocket_Received_Part;
procedure WebSocket_Received_Part
( Client : in out HTTP_Client;
Message : String
) is
begin
null;
end WebSocket_Received_Part;
procedure WebSocket_Send
( Client : in out HTTP_Client;
Message : Stream_Element_Array
) is
Header : constant Stream_Element_Array :=
WebSocket_Header (Message'Length, WebSocket_Binary_Type);
begin
if Client.WebSocket.Duplex then
if Client.WebSocket.Context = Current_Task then
if Client.WebSocket.State = Open_Socket then
declare
Seized : Boolean;
begin
Client.Mutex.Grab (Seized);
if Seized then
begin
Send_Content (Client, Header);
Send_Content (Client, Message);
exception
when others =>
Client.Mutex.Release;
raise;
end;
else
Queue_Content (Client, Header);
Queue_Content (Client, Message);
end if;
end;
else
Raise_Exception
( End_Error'Identity,
"No WebSocket open"
);
end if;
else
WebSocket_Blocking_Send (Client, Header, True, False);
WebSocket_Blocking_Send (Client, Message, False, True);
end if;
else
if Client.WebSocket.State = Open_Socket then
Send_Content (Client, Header);
Send_Content (Client, Message);
else
Raise_Exception (End_Error'Identity, "No WebSocket open");
end if;
end if;
end WebSocket_Send;
procedure WebSocket_Send
( Client : in out HTTP_Client;
Message : String
) is
Header : constant Stream_Element_Array :=
WebSocket_Header (Message'Length, WebSocket_Text_Type);
begin
if Client.WebSocket.Duplex then
if Client.WebSocket.Context = Current_Task then
if Client.WebSocket.State = Open_Socket then
declare
Seized : Boolean;
begin
Client.Mutex.Grab (Seized);
if Seized then
begin
Send_Content (Client, Header);
Send_Content (Client, Message);
exception
when others =>
Client.Mutex.Release;
raise;
end;
else
Queue_Content (Client, Header);
Queue_Content (Client, Message);
end if;
end;
else
Raise_Exception
( End_Error'Identity,
"No WebSocket open"
);
end if;
else
WebSocket_Blocking_Send (Client, Header, True, False);
declare
Pointer : Integer := Message'First;
begin
while Message'Last + 1 - Pointer > Block_Size loop
WebSocket_Blocking_Send
( Client,
From_String
( Message (Pointer..Pointer + Block_Size - 1)
),
False,
False
);
Pointer := Pointer + Block_Size;
end loop;
WebSocket_Blocking_Send
( Client,
From_String (Message (Pointer..Message'Last)),
False,
True
);
end;
end if;
else
if Client.WebSocket.State = Open_Socket then
Send_Content (Client, Header);
Send_Content (Client, Message);
else
Raise_Exception (End_Error'Identity, "No WebSocket open");
end if;
end if;
end WebSocket_Send;
procedure Write
( Client : in out HTTP_Client;
Factory : in out Connections_Factory'Class;
Blocked : out Boolean
) is
begin
if Client.WebSocket.Duplex then
declare
Seized : Boolean;
begin
Client.Mutex.Grab (Seized);
if Seized then
begin
Write (Connection (Client), Factory, Blocked);
if Blocked or else Queued_To_Send (Client) = 0 then
Client.Mutex.Release;
end if;
exception
when others =>
Client.Mutex.Release;
raise;
end;
else
Blocked := False; -- Try later
end if;
end;
else
Write (Connection (Client), Factory, Blocked);
end if;
end Write;
procedure Write
( Stream : in out Content_Stream;
Item : Stream_Element_Array
) is
begin
null;
end Write;
procedure Write
( Stream : access Root_Stream_Type'Class;
Item : Content_Stream
) is
begin
null;
end Write;
procedure Write
( Stream : access Root_Stream_Type'Class;
Item : Data_Pool
) is
begin
null;
end Write;
procedure Write
( Stream : access Root_Stream_Type'Class;
Item : Content_Destination
) is
begin
null;
end Write;
procedure Write
( Stream : access Root_Stream_Type'Class;
Item : WebSocket_Data
) is
begin
null;
end Write;
procedure Write
( Stream : access Root_Stream_Type'Class;
Item : Send_Mutex
) is
begin
null;
end Write;
protected body Send_Mutex is
procedure Failed (Error : Exception_Occurrence) is
begin
Set_Failed (State_Machine (Client.all), Error);
if State in Idle..Task_Sending then
State := Server_Sending;
end if;
end Failed;
function Get_Status return Duplex_Status is
begin
return State;
end Get_Status;
procedure Grab (Seized : out Boolean) is
begin
case State is
when Disabled | Closing | Server_Sending =>
Seized := True;
when Idle =>
State := Server_Sending;
Seized := True;
when Task_Sending =>
Seized := False;
end case;
end Grab;
procedure Release is
begin
case State is
when Disabled | Closing | Idle =>
null;
when Task_Sending | Server_Sending =>
State := Idle;
end case;
end Release;
entry Seize when State in Disabled..Idle is
begin
case State is
when Idle =>
State := Task_Sending;
when Closing =>
Raise_Exception
( End_Error'Identity,
"WebSocket is being closed"
);
when others =>
Raise_Exception
( End_Error'Identity,
"No WebSocket open"
);
end case;
end Seize;
procedure Set (New_State : Duplex_Status) is
begin
State := New_State;
end Set;
end Send_Mutex;
begin
Add (Commands, "CONNECT", HTTP_CONNECT);
Add (Commands, "DELETE", HTTP_DELETE);
Add (Commands, "GET", HTTP_GET);
Add (Commands, "HEAD", HTTP_HEAD);
Add (Commands, "OPTIONS", HTTP_OPTIONS);
Add (Commands, "PATCH", HTTP_PATCH);
Add (Commands, "POST", HTTP_POST);
Add (Commands, "PUT", HTTP_PUT);
Add (Commands, "TRACE", HTTP_TRACE);
Add (Request_Headers, "Accept", Accept_Header);
Add (Request_Headers, "Accept-Charset", Accept_Charset_Header);
Add (Request_Headers, "Accept-Encoding", Accept_Encoding_Header);
Add (Request_Headers, "Accept-Language", Accept_Language_Header);
Add (Request_Headers, "Accept-Datetime", Accept_Datetime_Header);
Add (Request_Headers, "Allow", Allow_Header);
Add (Request_Headers, "Authorization", Authorization_Header);
Add (Request_Headers, "Cache-Control", Cache_Control_Header);
Add (Request_Headers, "Cookie", Cookie_Header);
Add (Request_Headers, "Connection", Connection_Header);
Add (Request_Headers, "Content-Disposition",
Content_Disposition_Header);
Add (Request_Headers, "Content-Encoding", Content_Encoding_Header);
Add (Request_Headers, "Content-Language", Content_Language_Header);
Add (Request_Headers, "Content-Length", Content_Length_Header);
Add (Request_Headers, "Content-Location", Content_Location_Header);
Add (Request_Headers, "Content-MD5", Content_MD5_Header);
Add (Request_Headers, "Content-Type", Content_Type_Header);
Add (Request_Headers, "Date", Date_Header);
Add (Request_Headers, "Expect", Expect_Header);
Add (Request_Headers, "Expires", Expires_Header);
Add (Request_Headers, "From", From_Header);
Add (Request_Headers, "Host", Host_Header);
Add (Request_Headers, "If-Match", If_Match_Header);
Add (Request_Headers, "If-Modified-Since", If_Modified_Since_Header);
Add (Request_Headers, "If-None-Match", If_None_Match_Header);
Add (Request_Headers, "If-Range", If_Range_Header);
Add (Request_Headers, "If-Unmodified-Since",
If_Unmodified_Since_Header);
Add (Request_Headers, "Last-Modified", Last_Modified_Header);
Add (Request_Headers, "Max-Forwards", Max_Forwards_Header);
Add (Request_Headers, "Origin", Origin_Header);
Add (Request_Headers, "Pragma", Pragma_Header);
Add (Request_Headers, "Proxy-Authorization",
Proxy_Authorization_Header);
Add (Request_Headers, "Range", Range_Header);
Add (Request_Headers, "Referer", Referer_Header);
Add (Request_Headers, "Sec-WebSocket-Extensions",
Sec_WebSocket_Extensions_Header);
Add (Request_Headers, "Sec-WebSocket-Key", Sec_WebSocket_Key_Header);
Add (Request_Headers, "Sec-WebSocket-Protocol",
Sec_WebSocket_Protocol_Header);
Add (Request_Headers, "Sec-WebSocket-Version",
Sec_WebSocket_Version_Header);
Add (Request_Headers, "TE", TE_Header);
Add (Request_Headers, "Trailer", Trailer_Header);
Add (Request_Headers, "Transfer-Encoding", Transfer_Encoding_Header);
Add (Request_Headers, "Upgrade", Upgrade_Header);
Add (Request_Headers, "Upgrade-Insecure-Requests",
Upgrade_Insecure_Requests);
Add (Request_Headers, "User-Agent", User_Agent_Header);
Add (Request_Headers, "Via", Via_Header);
Add (Request_Headers, "Warning", Warning_Header);
Add (Request_Headers, "X-CSRF-TOKEN", X_CSRF_Token_Header);
Add (Request_Headers, "X-Requested-By", X_Requested_By_Header);
Add (Request_Headers, "X-Requested-With", X_Requested_With_Header);
Add (Request_Headers, "X-XSRF-TOKEN", X_XSRF_Token_Header);
Add (Connections, "close", Connection_Close);
Add (Connections, "keep-alive", Connection_Persistent);
Add (Connections, "upgrade", Connection_Upgrade);
Add (Schemes, "aaa", Aaa_Scheme);
Add (Schemes, "aaas", Aaas_Scheme);
Add (Schemes, "about", About_Scheme);
Add (Schemes, "acap", Acap_Scheme);
Add (Schemes, "acct", Acct_Scheme);
Add (Schemes, "acr", Acr_Scheme);
Add (Schemes, "adiumxtra", Adiumxtra_Scheme);
Add (Schemes, "afp", AFP_Scheme);
Add (Schemes, "afs", AFS_Scheme);
Add (Schemes, "aim", Aim_Scheme);
Add (Schemes, "appdata", Appdata_Scheme);
Add (Schemes, "apt", APT_Scheme);
Add (Schemes, "attachment", Attachment_Scheme);
Add (Schemes, "aw", Aw_Scheme);
Add (Schemes, "barion", Barion_Scheme);
Add (Schemes, "beshare", Beshare_Scheme);
Add (Schemes, "bitcoin", Bitcoin_Scheme);
Add (Schemes, "blob", Blob_Scheme);
Add (Schemes, "bolo", Bolo_Scheme);
Add (Schemes, "browserext", Browserext_Scheme);
Add (Schemes, "callto", Callto_Scheme);
Add (Schemes, "cap", Cap_Scheme);
Add (Schemes, "chrome", Chrome_Scheme);
Add (Schemes, "chrome-extension", Chrome_Extension_Scheme);
Add (Schemes, "cid", Cid_Scheme);
Add (Schemes, "coap", Coap_Scheme);
Add (Schemes, "coap+tcp", Coap_Tcp_Scheme);
Add (Schemes, "coaps", Coaps_Scheme);
Add (Schemes, "coaps+tcp", Coaps_Tcp_Scheme);
Add (Schemes, "com-eventbrite-attendee",
Com_Eventbrite_Attendee_Scheme);
Add (Schemes, "content", Content_Scheme);
Add (Schemes, "crid", Crid_Scheme);
Add (Schemes, "cvs", CVS_Scheme);
Add (Schemes, "data", Data_Scheme);
Add (Schemes, "dav", Dav_Scheme);
Add (Schemes, "diaspora", Diaspora_Scheme);
Add (Schemes, "dict", Dict_Scheme);
Add (Schemes, "dis", DIS_Scheme);
Add (Schemes, "dlna-playcontainer", DLNA_Playcontainer_Scheme);
Add (Schemes, "dlna-playsingle", DLNA_Playsingle_Scheme);
Add (Schemes, "dns", DNS_Scheme);
Add (Schemes, "dntp", DNTP_Scheme);
Add (Schemes, "dtn", DTN_Scheme);
Add (Schemes, "dvb", DVB_Scheme);
Add (Schemes, "ed2k", Ed2k_Scheme);
Add (Schemes, "example", Example_Scheme);
Add (Schemes, "facetime", Facetime_Scheme);
Add (Schemes, "fax", Fax_Scheme);
Add (Schemes, "feed", Feed_Scheme);
Add (Schemes, "feedready", Feedready_Scheme);
Add (Schemes, "file", File_Scheme);
Add (Schemes, "filesystem", Filesystem_Scheme);
Add (Schemes, "finger", Finger_Scheme);
Add (Schemes, "fish", Fish_Scheme);
Add (Schemes, "ftp", FTP_Scheme);
Add (Schemes, "geo", Geo_Scheme);
Add (Schemes, "gg", Gg_Scheme);
Add (Schemes, "git", Git_Scheme);
Add (Schemes, "gizmoproject", Gizmoproject_Scheme);
Add (Schemes, "go", Go_Scheme);
Add (Schemes, "gopher", Gopher_Scheme);
Add (Schemes, "graph", Graph_Scheme);
Add (Schemes, "gtalk", Gtalk_Scheme);
Add (Schemes, "h323", H323_Scheme);
Add (Schemes, "ham", Ham_Scheme);
Add (Schemes, "hcp", HCP_Scheme);
Add (Schemes, "http", HTTP_Scheme);
Add (Schemes, "https", HTTPS_Scheme);
Add (Schemes, "hxxp", HXXP_Scheme);
Add (Schemes, "hxxps", HXXPS_Scheme);
Add (Schemes, "hydrazone", Hydrazone_Scheme);
Add (Schemes, "iax", Iax_Scheme);
Add (Schemes, "icap", Icap_Scheme);
Add (Schemes, "icon", Icon_Scheme);
Add (Schemes, "im", Im_Scheme);
Add (Schemes, "imap", Imap_Scheme);
Add (Schemes, "info", Info_Scheme);
Add (Schemes, "iotdisco", Iotdisco_Scheme);
Add (Schemes, "ipn", IPN_Scheme);
Add (Schemes, "ipp", IPP_Scheme);
Add (Schemes, "ipps", IPPS_Scheme);
Add (Schemes, "irc", IRC_Scheme);
Add (Schemes, "irc6", IRC6_Scheme);
Add (Schemes, "ircs", IRCS_Scheme);
Add (Schemes, "iris", Iris_Scheme);
Add (Schemes, "iris.beep", Iris_Beep_Scheme);
Add (Schemes, "iris.lwz", Iris_LWZ_Scheme);
Add (Schemes, "iris.xpc", Iris_XPC_Scheme);
Add (Schemes, "iris.xpcs", Iris_XPCS_Scheme);
Add (Schemes, "isostore", Isostore_Scheme);
Add (Schemes, "itms", ITMS_Scheme);
Add (Schemes, "jabber", Jabber_Scheme);
Add (Schemes, "jar", Jar_Scheme);
Add (Schemes, "jms", Jms_Scheme);
Add (Schemes, "keyparc", Keyparc_Scheme);
Add (Schemes, "lastfm", Lastfm_Scheme);
Add (Schemes, "ldap", LDAP_Scheme);
Add (Schemes, "ldaps", LDAPS_Scheme);
Add (Schemes, "lvlt", LVLT_Scheme);
Add (Schemes, "magnet", Magnet_Scheme);
Add (Schemes, "mailserver", Mailserver_Scheme);
Add (Schemes, "mailto", Mailto_Scheme);
Add (Schemes, "maps", Maps_Scheme);
Add (Schemes, "market", Market_Scheme);
Add (Schemes, "message", Message_Scheme);
Add (Schemes, "mid", Mid_Scheme);
Add (Schemes, "mms", MMS_Scheme);
Add (Schemes, "modem", Modem_Scheme);
Add (Schemes, "mongodb", Mongodb_Scheme);
Add (Schemes, "moz", Moz_Scheme);
Add (Schemes, "ms-access", MS_Access_Scheme);
Add (Schemes, "ms-browser-extension", MS_Browser_Extension_Scheme);
Add (Schemes, "ms-drive-to", MS_Drive_To_Scheme);
Add (Schemes, "ms-enrollment", MS_Enrollment_Scheme);
Add (Schemes, "ms-excel", MS_Excel_Scheme);
Add (Schemes, "ms-gamebarservices", MS_Gamebarservices_Scheme);
Add (Schemes, "ms-getoffice", MS_Getoffice_Scheme);
Add (Schemes, "ms-help", MS_Help_Scheme);
Add (Schemes, "ms-infopath", MS_Infopath_Scheme);
Add (Schemes, "ms-inputapp", MS_Inputapp_Scheme);
Add (Schemes, "ms-media-stream-id", MS_Media_Stream_ID_Scheme);
Add (Schemes, "ms-officeapp", MS_Officeapp_Scheme);
Add (Schemes, "ms-people", MS_People_Scheme);
Add (Schemes, "ms-project", MS_Project_Scheme);
Add (Schemes, "ms-powerpoint", MS_Powerpoint_Scheme);
Add (Schemes, "ms-publisher", MS_Publisher_Scheme);
Add (Schemes, "ms-search-repair", MS_Search_Repair_Scheme);
Add (Schemes, "ms-secondary-screen-controller",
MS_Secondary_Screen_Controller_Scheme);
Add (Schemes, "ms-secondary-screen-setup",
MS_Secondary_Screen_Setup_Scheme);
Add (Schemes, "ms-settings", MS_Settings_Scheme);
Add (Schemes, "ms-settings-airplanemode",
MS_Settings_Airplanemode_Scheme);
Add (Schemes, "ms-settings-bluetooth", MS_Settings_Bluetooth_Scheme);
Add (Schemes, "ms-settings-camera", MS_Settings_Camera_Scheme);
Add (Schemes, "ms-settings-cellular", MS_Settings_Cellular_Scheme);
Add (Schemes, "ms-settings-cloudstorage",
MS_Settings_Cloudstorage_Scheme);
Add (Schemes, "ms-settings-connectabledevices",
MS_Settings_Connectabledevices_Scheme);
Add (Schemes, "ms-settings-displays-topology",
MS_Settings_Displays_Topology_Scheme);
Add (Schemes, "ms-settings-emailandaccounts",
MS_Settings_Emailandaccounts_Scheme);
Add (Schemes, "ms-settings-language",
MS_Settings_Language_Scheme);
Add (Schemes, "ms-settings-location",
MS_Settings_Location_Scheme);
Add (Schemes, "ms-settings-lock", MS_Settings_Lock_Scheme);
Add (Schemes, "ms-settings-nfctransactions",
MS_Settings_Nfctransactions_Scheme);
Add (Schemes, "ms-settings-notifications",
MS_Settings_Notifications_Scheme);
Add (Schemes, "ms-settings-power", MS_Settings_Power_Scheme);
Add (Schemes, "ms-settings-privacy", MS_Settings_Privacy_Scheme);
Add (Schemes, "ms-settings-proximity", MS_Settings_Proximity_Scheme);
Add (Schemes, "ms-settings-screenrotation",
MS_Settings_Screenrotation_Scheme);
Add (Schemes, "ms-settings-wifi", MS_Settings_WiFi_Scheme);
Add (Schemes, "ms-settings-workplace", MS_Settings_Workplace_Scheme);
Add (Schemes, "ms-spd", MS_SPD_Scheme);
Add (Schemes, "ms-sttoverlay", MS_Sttoverlay_Scheme);
Add (Schemes, "ms-transit-to", MS_Transit_To_Scheme);
Add (Schemes, "ms-virtualtouchpad", MS_Virtualtouchpad_Scheme);
Add (Schemes, "ms-visio", MS_Visio_Scheme);
Add (Schemes, "ms-walk-to", MS_Walk_To_Scheme);
Add (Schemes, "ms-whiteboard", MS_Whiteboard_Scheme);
Add (Schemes, "ms-whiteboard-cmd", MS_Whiteboard_CMD_Scheme);
Add (Schemes, "ms-word", MS_Word_Scheme);
Add (Schemes, "msnim", MSnim_Scheme);
Add (Schemes, "msrp", MSRP_Scheme);
Add (Schemes, "msrps", MSRPS_Scheme);
Add (Schemes, "mtqp", MTQP_Scheme);
Add (Schemes, "mumble", Mumble_Scheme);
Add (Schemes, "mupdate", Mupdate_Scheme);
Add (Schemes, "mvn", MVN_Scheme);
Add (Schemes, "news", News_Scheme);
Add (Schemes, "nfs", NFS_Scheme);
Add (Schemes, "ni", NI_Scheme);
Add (Schemes, "nih", NIH_Scheme);
Add (Schemes, "nntp", NNTP_Scheme);
Add (Schemes, "notes", Notes_Scheme);
Add (Schemes, "ocf", OCF_Scheme);
Add (Schemes, "oid", OID_Scheme);
Add (Schemes, "onenote", Onenote_Scheme);
Add (Schemes, "onenote-cmd", Onenote_CMD_Scheme);
Add (Schemes, "opaquelocktoken", Opaquelocktoken_Scheme);
Add (Schemes, "pack", Pack_Scheme);
Add (Schemes, "palm", Palm_Scheme);
Add (Schemes, "paparazzi", Paparazzi_Scheme);
Add (Schemes, "pkcs11", Pkcs11_Scheme);
Add (Schemes, "platform", Platform_Scheme);
Add (Schemes, "pop", POP_Scheme);
Add (Schemes, "pres", Pres_Scheme);
Add (Schemes, "prospero", Prospero_Scheme);
Add (Schemes, "proxy", Proxy_Scheme);
Add (Schemes, "pwid", Pwid_Scheme);
Add (Schemes, "psyc", Psyc_Scheme);
Add (Schemes, "qb", QB_Scheme);
Add (Schemes, "query", Query_Scheme);
Add (Schemes, "redis", Redis_Scheme);
Add (Schemes, "rediss", Rediss_Scheme);
Add (Schemes, "reload", Reload_Scheme);
Add (Schemes, "res", Res_Scheme);
Add (Schemes, "resource", Resource_Scheme);
Add (Schemes, "rmi", RMI_Scheme);
Add (Schemes, "rsync", Rsync_Scheme);
Add (Schemes, "rtmfp", RTMFP_Scheme);
Add (Schemes, "rtmp", RTMP_Scheme);
Add (Schemes, "rtsp", RTSP_Scheme);
Add (Schemes, "rtsps", RTSPS_Scheme);
Add (Schemes, "rtspu", RTSPU_Scheme);
Add (Schemes, "secondlife", Secondlife_Scheme);
Add (Schemes, "service", Service_Scheme);
Add (Schemes, "session", Session_Scheme);
Add (Schemes, "sftp", SFTP_Scheme);
Add (Schemes, "sgn", SGN_Scheme);
Add (Schemes, "shttp", SHTTP_Scheme);
Add (Schemes, "sieve", Sieve_Scheme);
Add (Schemes, "sip", Sip_Scheme);
Add (Schemes, "sips", Sips_Scheme);
Add (Schemes, "skype", Skype_Scheme);
Add (Schemes, "smb", SMB_Scheme);
Add (Schemes, "sms", SMS_Scheme);
Add (Schemes, "smtp", SMTP_Scheme);
Add (Schemes, "snews", SNews_Scheme);
Add (Schemes, "snmp", SNTP_Scheme);
Add (Schemes, "soap.beep", Soap_Beep_Scheme);
Add (Schemes, "soap.beeps", Soap_Beeps_Scheme);
Add (Schemes, "soldat", Soldat_Scheme);
Add (Schemes, "spotify", Spotify_Scheme);
Add (Schemes, "ssh", SSH_Scheme);
Add (Schemes, "steam", Steam_Scheme);
Add (Schemes, "stun", Stun_Scheme);
Add (Schemes, "stuns", Stuns_Scheme);
Add (Schemes, "submit", Submit_Scheme);
Add (Schemes, "svn", SVN_Scheme);
Add (Schemes, "tag", Tag_Scheme);
Add (Schemes, "teamspeak", Teamspeak_Scheme);
Add (Schemes, "tel", Tel_Scheme);
Add (Schemes, "teliaeid", Teliaeid_Scheme);
Add (Schemes, "telnet", Telnet_Scheme);
Add (Schemes, "tftp", TFTP_Scheme);
Add (Schemes, "things", Things_Scheme);
Add (Schemes, "thismessage", Thismessage_Scheme);
Add (Schemes, "tip", Tip_Scheme);
Add (Schemes, "tn3270", Tn3270_Scheme);
Add (Schemes, "tool", Tool_Scheme);
Add (Schemes, "turn", Turn_Scheme);
Add (Schemes, "turns", Turns_Scheme);
Add (Schemes, "tv", TV_Scheme);
Add (Schemes, "udp", UDP_Scheme);
Add (Schemes, "unreal", Unreal_Scheme);
Add (Schemes, "urn", URN_Scheme);
Add (Schemes, "ut2004", UT2004_Scheme);
Add (Schemes, "v-event", V_Event_Scheme);
Add (Schemes, "vemmi", VEMMI_Scheme);
Add (Schemes, "ventrilo", Ventrilo_Scheme);
Add (Schemes, "videotex", Videotex_Scheme);
Add (Schemes, "vnc", VNC_Scheme);
Add (Schemes, "view-source", View_Source_Scheme);
Add (Schemes, "wais", Wais_Scheme);
Add (Schemes, "webcal", Webcal_Scheme);
Add (Schemes, "wpid", Wpid_Scheme);
Add (Schemes, "ws", WS_Scheme);
Add (Schemes, "wss", WSS_Scheme);
Add (Schemes, "wtai", WTAI_Scheme);
Add (Schemes, "wyciwyg", Wyciwyg_Scheme);
Add (Schemes, "xcon", Xcon_Scheme);
Add (Schemes, "xcon-userid", Xcon_Userid_Scheme);
Add (Schemes, "xfire", Xfire_Scheme);
Add (Schemes, "xmlrpc.beep", XMLRPC_Beep_Scheme);
Add (Schemes, "xmlrpc.beeps", XMLRPC_Beeps_Scheme);
Add (Schemes, "xmpp", XMPP_Scheme);
Add (Schemes, "xri", XRI_Scheme);
Add (Schemes, "ymsgr", YMSGR_Scheme);
Add (Schemes, "z39.50", Z39_50_Scheme);
Add (Schemes, "z39.50r", Z39_50r_Scheme);
Add (Schemes, "z39.50s", Z39_50s_Scheme);
end GNAT.Sockets.Connection_State_Machine.HTTP_Server;
|
package GESTE_Fonts.FreeSerif6pt7b is
Font : constant Bitmap_Font_Ref;
private
FreeSerif6pt7bBitmaps : aliased constant Font_Bitmap := (
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#40#, 16#08#,
16#01#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#05#, 16#00#,
16#A0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#02#, 16#80#, 16#50#, 16#3F#, 16#02#, 16#40#, 16#FC#, 16#0A#, 16#01#,
16#40#, 16#28#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#07#, 16#00#, 16#D0#, 16#18#, 16#03#, 16#00#, 16#18#,
16#05#, 16#01#, 16#A0#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#9C#, 16#13#, 16#02#,
16#AC#, 16#6A#, 16#82#, 16#D0#, 16#52#, 16#11#, 16#80#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#02#, 16#40#, 16#48#,
16#06#, 16#E0#, 16#88#, 16#7A#, 16#09#, 16#81#, 16#10#, 16#3D#, 16#C0#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#,
16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#C0#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#,
16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#80#, 16#08#, 16#01#, 16#00#,
16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#04#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#D0#, 16#0C#,
16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#04#, 16#00#, 16#80#, 16#FC#, 16#02#, 16#00#, 16#40#, 16#08#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#40#,
16#08#, 16#02#, 16#00#, 16#40#, 16#08#, 16#02#, 16#00#, 16#40#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#,
16#80#, 16#90#, 16#21#, 16#04#, 16#20#, 16#84#, 16#09#, 16#01#, 16#20#,
16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#08#, 16#03#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#,
16#00#, 16#40#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#07#, 16#01#, 16#10#, 16#02#, 16#00#, 16#40#,
16#10#, 16#04#, 16#01#, 16#10#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#10#, 16#04#,
16#01#, 16#C0#, 16#08#, 16#01#, 16#00#, 16#20#, 16#38#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#00#,
16#20#, 16#1C#, 16#02#, 16#80#, 16#90#, 16#1F#, 16#80#, 16#40#, 16#08#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#03#, 16#80#, 16#80#, 16#1C#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#,
16#20#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#0C#, 16#03#, 16#00#, 16#C0#, 16#1E#, 16#06#, 16#40#, 16#CC#,
16#08#, 16#81#, 16#20#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#81#, 16#10#, 16#02#, 16#00#,
16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#80#, 16#90#,
16#1C#, 16#01#, 16#80#, 16#48#, 16#09#, 16#01#, 16#20#, 16#18#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#04#,
16#81#, 16#10#, 16#33#, 16#02#, 16#40#, 16#78#, 16#01#, 16#00#, 16#60#,
16#18#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#,
16#01#, 16#C0#, 16#C0#, 16#0C#, 16#00#, 16#60#, 16#02#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#00#, 16#03#, 16#F0#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#10#, 16#01#, 16#80#, 16#0C#, 16#00#, 16#C0#,
16#60#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#38#, 16#04#, 16#80#, 16#10#, 16#02#, 16#00#, 16#80#, 16#10#,
16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#0F#, 16#03#, 16#18#, 16#CB#, 16#12#, 16#A2#,
16#94#, 16#52#, 16#8D#, 16#E0#, 16#C0#, 16#0F#, 16#80#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#30#,
16#07#, 16#01#, 16#20#, 16#26#, 16#07#, 16#C1#, 16#0C#, 16#73#, 16#80#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#,
16#C0#, 16#CC#, 16#19#, 16#83#, 16#C0#, 16#66#, 16#0C#, 16#41#, 16#98#,
16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#0E#, 16#02#, 16#20#, 16#84#, 16#10#, 16#46#, 16#00#, 16#C0#, 16#08#,
16#01#, 16#80#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#8C#, 16#10#, 16#42#, 16#08#,
16#41#, 16#08#, 16#21#, 16#08#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#, 16#84#, 16#11#,
16#03#, 16#E0#, 16#44#, 16#08#, 16#01#, 16#08#, 16#7F#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#E0#,
16#84#, 16#11#, 16#03#, 16#E0#, 16#44#, 16#08#, 16#01#, 16#00#, 16#78#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#,
16#82#, 16#30#, 16#80#, 16#10#, 16#06#, 16#3C#, 16#C1#, 16#08#, 16#21#,
16#84#, 16#1F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#0F#, 16#70#, 16#84#, 16#10#, 16#83#, 16#F0#, 16#42#,
16#08#, 16#41#, 16#08#, 16#7B#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#C0#, 16#18#, 16#03#,
16#00#, 16#60#, 16#0C#, 16#01#, 16#80#, 16#78#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#40#,
16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#70#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#,
16#70#, 16#C8#, 16#12#, 16#02#, 16#80#, 16#78#, 16#09#, 16#81#, 16#98#,
16#7B#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#0F#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#,
16#01#, 16#08#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#0E#, 16#0C#, 16#C3#, 16#1C#, 16#62#, 16#94#,
16#5A#, 16#89#, 16#91#, 16#32#, 16#74#, 16#E0#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#38#, 16#E4#, 16#1C#,
16#82#, 16#D0#, 16#4E#, 16#08#, 16#C1#, 16#08#, 16#71#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#06#, 16#20#,
16#82#, 16#30#, 16#46#, 16#08#, 16#C1#, 16#08#, 16#21#, 16#88#, 16#1E#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#0F#, 16#80#, 16#88#, 16#11#, 16#02#, 16#20#, 16#78#, 16#08#, 16#01#,
16#00#, 16#78#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#1E#, 16#06#, 16#20#, 16#82#, 16#30#, 16#46#, 16#08#, 16#41#,
16#08#, 16#20#, 16#88#, 16#0E#, 16#00#, 16#40#, 16#06#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#88#, 16#11#, 16#82#,
16#20#, 16#78#, 16#09#, 16#01#, 16#18#, 16#7B#, 16#80#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#, 16#80#, 16#80#,
16#18#, 16#01#, 16#C0#, 16#0C#, 16#10#, 16#81#, 16#30#, 16#1C#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#,
16#E1#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#,
16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#0F#, 16#30#, 16#C4#, 16#10#, 16#82#, 16#10#, 16#42#, 16#0C#,
16#40#, 16#88#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#0E#, 16#30#, 16#84#, 16#08#, 16#81#, 16#10#,
16#14#, 16#02#, 16#80#, 16#20#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#E6#, 16#88#, 16#99#,
16#91#, 16#32#, 16#3A#, 16#83#, 16#30#, 16#44#, 16#08#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#70#,
16#44#, 16#0D#, 16#00#, 16#C0#, 16#1C#, 16#04#, 16#81#, 16#08#, 16#73#,
16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#0E#, 16#30#, 16#C4#, 16#09#, 16#00#, 16#C0#, 16#08#, 16#01#, 16#00#,
16#20#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#07#, 16#E1#, 16#08#, 16#02#, 16#00#, 16#80#, 16#10#,
16#04#, 16#01#, 16#08#, 16#7F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#80#, 16#10#, 16#02#,
16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#E0#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#01#, 16#00#,
16#10#, 16#02#, 16#00#, 16#40#, 16#04#, 16#00#, 16#80#, 16#10#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#,
16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#,
16#10#, 16#02#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#02#, 16#00#, 16#60#, 16#14#, 16#02#, 16#40#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F8#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#80#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#1C#, 16#00#, 16#80#, 16#10#, 16#0E#, 16#02#, 16#40#, 16#3C#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#,
16#0C#, 16#00#, 16#80#, 16#1E#, 16#02#, 16#60#, 16#44#, 16#08#, 16#81#,
16#20#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#02#, 16#00#, 16#80#,
16#10#, 16#03#, 16#20#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#10#, 16#1E#, 16#02#,
16#40#, 16#88#, 16#11#, 16#03#, 16#20#, 16#3C#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#1C#, 16#04#, 16#C0#, 16#F8#, 16#10#, 16#03#, 16#20#, 16#38#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#04#,
16#00#, 16#80#, 16#3C#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#,
16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#02#, 16#40#, 16#48#, 16#06#,
16#03#, 16#00#, 16#3C#, 16#08#, 16#81#, 16#10#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#1E#, 16#02#, 16#40#,
16#48#, 16#09#, 16#01#, 16#20#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#10#,
16#06#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#,
16#00#, 16#08#, 16#03#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#,
16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#0C#, 16#00#, 16#80#, 16#17#, 16#02#, 16#80#, 16#60#, 16#0A#, 16#01#,
16#20#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#0C#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#, 16#40#,
16#08#, 16#01#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#36#, 16#C3#,
16#68#, 16#49#, 16#09#, 16#21#, 16#24#, 16#7E#, 16#C0#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#36#, 16#03#, 16#40#, 16#48#, 16#09#, 16#01#, 16#20#, 16#7E#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#1E#, 16#02#, 16#40#, 16#8C#, 16#18#, 16#81#, 16#20#,
16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#36#, 16#03#, 16#60#, 16#44#, 16#08#,
16#81#, 16#20#, 16#3C#, 16#04#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1C#, 16#02#, 16#40#,
16#88#, 16#11#, 16#03#, 16#20#, 16#3C#, 16#00#, 16#80#, 16#10#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#14#,
16#03#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#70#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#1C#, 16#04#, 16#80#, 16#40#, 16#06#, 16#02#, 16#40#, 16#70#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#80#, 16#38#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#,
16#00#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#36#, 16#02#, 16#40#, 16#48#,
16#09#, 16#01#, 16#20#, 16#3E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#33#, 16#02#,
16#40#, 16#48#, 16#06#, 16#00#, 16#C0#, 16#10#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#36#, 16#42#, 16#48#, 16#4A#, 16#0B#, 16#40#, 16#90#, 16#12#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#3E#, 16#02#, 16#80#, 16#20#, 16#0A#, 16#01#, 16#20#,
16#6E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#3B#, 16#02#, 16#40#, 16#48#, 16#06#,
16#00#, 16#C0#, 16#08#, 16#02#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#04#, 16#80#,
16#20#, 16#08#, 16#01#, 16#20#, 16#7C#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#02#, 16#00#, 16#40#, 16#08#,
16#01#, 16#00#, 16#40#, 16#04#, 16#00#, 16#80#, 16#10#, 16#02#, 16#00#,
16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#,
16#80#, 16#10#, 16#02#, 16#00#, 16#40#, 16#08#, 16#01#, 16#00#, 16#20#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#02#, 16#00#, 16#20#, 16#04#, 16#00#, 16#80#, 16#10#, 16#01#, 16#00#,
16#40#, 16#08#, 16#01#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#,
16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#);
Font_D : aliased constant Bitmap_Font :=
(
Bytes_Per_Glyph => 19,
Glyph_Width => 11,
Glyph_Height => 14,
Data => FreeSerif6pt7bBitmaps'Access);
Font : constant Bitmap_Font_Ref := Font_D'Access;
end GESTE_Fonts.FreeSerif6pt7b;
|
with parse_tokens, parse_goto, parse_shift_reduce, text_io, scanner;
with nfa, ccl, misc, misc_defs, sym, ecs, aflex_scanner;
with tstring, int_io, main_body, text_io, external_file_manager;
use aflex_scanner, external_file_manager;
package parser is
procedure build_eof_action;
procedure yyerror(msg: string);
procedure YYParse;
def_rule:integer;
end parser;
|
-- auto_counters_tests_config.ads
-- Configuration for Unit tests for Auto_Counters
-- Configuration for optimized builds
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
package Auto_Counters_Tests_Config is
pragma Pure;
Assertions_Enabled : constant Boolean := False;
-- Some unit tests are checking that appropriate preconditions and assertions
-- are in place. In optimized builds where assertions are disabled these
-- tests will cause incorrect failure notifications or segfaults. The
-- Assertions_Enabled flag indicates whether these tests should be run.
end Auto_Counters_Tests_Config;
|
pragma License (Unrestricted);
-- Ada 2012
with Ada.Characters.Conversions;
with Ada.Strings.UTF_Encoding.Generic_Strings;
package Ada.Strings.UTF_Encoding.Strings is
new Strings.UTF_Encoding.Generic_Strings (
Character,
String,
Expanding_From_8 =>
Characters.Conversions.Expanding_From_UTF_8_To_String,
Expanding_From_16 =>
Characters.Conversions.Expanding_From_UTF_16_To_String,
Expanding_From_32 =>
Characters.Conversions.Expanding_From_UTF_32_To_String,
Expanding_To_8 =>
Characters.Conversions.Expanding_From_String_To_UTF_8,
Expanding_To_16 =>
Characters.Conversions.Expanding_From_String_To_UTF_16,
Expanding_To_32 =>
Characters.Conversions.Expanding_From_String_To_UTF_32,
Get => Characters.Conversions.Get,
Put => Characters.Conversions.Put);
pragma Pure (Ada.Strings.UTF_Encoding.Strings);
|
pragma License (Unrestricted);
-- implementation unit specialized for FreeBSD
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 Fast_Log (X : Complex) return Complex;
pragma Inline (Fast_Log);
function Fast_Exp (X : Complex) return Complex;
function Fast_Exp (X : Imaginary) return Complex;
pragma Inline (Fast_Exp);
function Fast_Pow (Left, Right : Complex) return Complex;
pragma Inline (Fast_Pow);
function Fast_Sin (X : Complex) return Complex;
pragma Inline (Fast_Sin);
function Fast_Cos (X : Complex) return Complex;
pragma Inline (Fast_Cos);
function Fast_Tan (X : Complex) return Complex;
pragma Inline (Fast_Tan);
function Fast_Arcsin (X : Complex) return Complex;
pragma Inline (Fast_Arcsin);
function Fast_Arccos (X : Complex) return Complex;
pragma Inline (Fast_Arccos);
function Fast_Arctan (X : Complex) return Complex;
pragma Inline (Fast_Arctan);
function Fast_Sinh (X : Complex) return Complex;
pragma Inline (Fast_Sinh);
function Fast_Cosh (X : Complex) return Complex;
pragma Inline (Fast_Cosh);
function Fast_Tanh (X : Complex) return Complex;
pragma Inline (Fast_Tanh);
function Fast_Arcsinh (X : Complex) return Complex;
pragma Inline (Fast_Arcsinh);
function Fast_Arccosh (X : Complex) return Complex;
pragma Inline (Fast_Arccosh);
function Fast_Arctanh (X : Complex) return Complex;
pragma Inline (Fast_Arctanh);
-- Long_Complex
subtype Long_Imaginary is Long_Long_Complex_Types.Long_Imaginary;
subtype Long_Complex is Long_Long_Complex_Types.Long_Complex;
function Fast_Log (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Log);
function Fast_Exp (X : Long_Complex) return Long_Complex;
function Fast_Exp (X : Long_Imaginary) return Long_Complex;
pragma Inline (Fast_Exp);
function Fast_Pow (Left, Right : Long_Complex) return Long_Complex;
pragma Inline (Fast_Pow);
function Fast_Sin (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Sin);
function Fast_Cos (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Cos);
function Fast_Tan (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Tan);
function Fast_Arcsin (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arcsin);
function Fast_Arccos (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arccos);
function Fast_Arctan (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arctan);
function Fast_Sinh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Sinh);
function Fast_Cosh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Cosh);
function Fast_Tanh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Tanh);
function Fast_Arcsinh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arcsinh);
function Fast_Arccosh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arccosh);
function Fast_Arctanh (X : Long_Complex) return Long_Complex;
pragma Inline (Fast_Arctanh);
-- 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 csqrtl (x : Long_Long_Complex) return Long_Long_Complex
with Import,
Convention => Intrinsic, External_Name => "__builtin_csqrtl";
function Fast_Sqrt (X : Long_Long_Complex) return Long_Long_Complex
renames csqrtl;
function Fast_Log (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Exp (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Exp (X : Long_Long_Imaginary) return Long_Long_Complex;
function Fast_Pow (Left, Right : Long_Long_Complex)
return Long_Long_Complex;
function Fast_Sin (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Cos (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Tan (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arcsin (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arccos (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arctan (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Sinh (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Cosh (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Tanh (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arcsinh (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arccosh (X : Long_Long_Complex) return Long_Long_Complex;
function Fast_Arctanh (X : Long_Long_Complex) return Long_Long_Complex;
end System.Long_Long_Complex_Elementary_Functions;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, 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.
------------------------------------------------------------------------------
package AMF.Internals.Tables.UMLDI_Metamodel.Objects is
procedure Initialize;
private
procedure Initialize_1 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_2 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_3 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_4 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_5 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_6 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_7 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_8 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_9 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_10 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_11 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_12 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_13 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_14 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_15 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_16 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_17 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_18 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_19 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_20 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_21 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_22 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_23 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_24 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_25 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_26 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_27 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_28 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_29 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_30 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_31 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_32 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_33 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_34 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_35 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_36 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_37 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_38 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_39 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_40 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_41 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_42 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_43 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_44 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_45 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_46 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_47 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_48 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_49 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_50 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_51 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_52 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_53 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_54 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_55 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_56 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_57 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_58 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_59 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_60 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_61 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_62 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_63 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_64 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_65 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_66 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_67 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_68 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_69 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_70 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_71 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_72 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_73 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_74 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_75 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_76 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_77 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_78 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_79 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_80 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_81 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_82 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_83 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_84 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_85 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_86 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_87 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_88 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_89 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_90 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_91 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_92 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_93 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_94 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_95 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_96 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_97 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_98 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_99 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_100 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_101 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_102 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_103 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_104 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_105 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_106 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_107 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_108 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_109 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_110 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_111 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_112 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_113 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_114 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_115 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_116 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_117 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_118 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_119 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_120 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_121 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_122 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_123 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_124 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_125 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_126 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_127 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_128 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_129 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_130 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_131 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_132 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_133 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_134 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_135 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_136 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_137 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_138 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_139 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_140 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_141 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_142 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_143 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_144 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_145 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_146 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_147 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_148 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_149 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_150 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_151 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_152 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_153 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_154 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_155 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_156 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_157 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_158 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_159 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_160 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_161 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_162 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_163 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_164 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_165 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_166 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_167 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_168 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_169 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_170 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_171 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_172 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_173 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_174 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_175 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_176 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_177 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_178 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_179 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_180 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_181 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_182 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_183 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_184 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_185 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_186 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_187 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_188 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_189 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_190 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_191 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_192 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_193 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_194 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_195 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_196 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_197 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_198 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_199 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_200 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_201 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_202 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_203 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_204 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_205 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_206 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_207 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_208 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_209 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_210 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_211 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_212 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_213 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_214 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_215 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_216 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_217 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_218 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_219 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_220 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_221 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_222 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_223 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_224 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_225 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_226 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_227 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_228 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_229 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_230 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_231 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_232 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_233 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_234 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_235 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_236 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_237 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_238 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_239 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_240 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_241 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_242 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_243 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_244 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_245 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_246 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_247 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_248 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_249 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_250 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_251 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_252 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_253 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_254 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_255 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_256 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_257 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_258 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_259 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_260 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_261 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_262 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_263 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_264 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_265 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_266 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_267 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_268 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_269 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_270 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_271 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_272 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_273 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_274 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_275 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_276 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_277 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_278 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_279 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_280 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_281 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_282 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_283 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_284 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_285 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_286 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_287 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_288 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_289 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_290 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_291 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_292 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_293 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_294 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_295 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_296 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_297 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_298 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_299 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_300 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_301 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_302 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_303 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_304 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_305 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_306 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_307 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_308 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_309 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_310 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_311 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_312 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_313 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_314 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_315 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_316 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_317 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_318 (Extent : AMF.Internals.AMF_Extent);
procedure Initialize_319 (Extent : AMF.Internals.AMF_Extent);
end AMF.Internals.Tables.UMLDI_Metamodel.Objects;
|
with
lace.Event.Logger,
lace.Event.utility,
ada.unchecked_Deallocation;
package body lace.make_Observer.deferred
is
procedure free is new ada.unchecked_Deallocation (String, String_view);
overriding
procedure destroy (Self : in out Item)
is
begin
make_Observer.destroy (make_Observer.item (Self)); -- Destroy base class.
Self.pending_Events.free;
end destroy;
overriding
procedure receive (Self : access Item; the_Event : in Event.item'Class := event.null_Event;
from_Subject : in Event.subject_Name)
is
begin
Self.pending_Events.add (the_Event, from_Subject);
end receive;
overriding
procedure respond (Self : access Item)
is
use Event_Vectors;
my_Name : constant String := Observer.item'Class (Self.all).Name;
procedure actuate (the_Responses : in event_response_Map;
the_Events : in Event_Vector;
from_subject_Name : in Event.subject_Name)
is
Cursor : Event_Vectors.Cursor := the_Events.First;
begin
while has_Element (Cursor)
loop
declare
use event_response_Maps,
Event.utility,
ada.Containers;
use type Observer.view;
the_Event : constant Event.item'Class := Element (Cursor);
Response : constant event_response_Maps.Cursor := the_Responses.find (to_Kind (the_Event'Tag));
begin
if has_Element (Response)
then
Element (Response).respond (the_Event);
if observer.Logger /= null
then
observer.Logger.log_Response (Element (Response),
Observer.view (Self),
the_Event,
from_subject_Name);
end if;
elsif Self.Responses.relay_Target /= null
then
-- Self.relay_Target.notify (the_Event, from_Subject_Name); -- todo: Re-enable relayed events.
if observer.Logger /= null
then
observer.Logger.log ("[Warning] ~ Relayed events are currently disabled.");
else
raise program_Error with "Event relaying is currently disabled.";
end if;
else
if observer.Logger /= null
then
observer.Logger.log ("[Warning] ~ Observer "
& my_Name
& " has no response to " & Name_of (the_Event)
& " from " & from_subject_Name & ".");
observer.Logger.log (" Count of responses =>"
& Count_type'Image (the_Responses.Length));
else
raise program_Error with "Observer " & my_Name & " has no response to " & Name_of (the_Event)
& " from " & from_subject_Name & ".";
end if;
end if;
end;
next (Cursor);
end loop;
end actuate;
the_subject_Events : subject_events_Pairs (1 .. 5_000);
Count : Natural;
begin
Self.pending_Events.fetch (the_subject_Events, Count);
for i in 1 .. Count
loop
declare
subject_Name : String_view := the_subject_Events (i).Subject;
the_Events : Event_vector renames the_subject_Events (i).Events;
begin
if Self.Responses.Contains (subject_Name.all)
then
actuate (Self.Responses.Element (subject_Name.all),
the_Events,
subject_Name.all);
else
if observer.Logger /= null
then
observer.Logger.log (my_Name & " has no responses for events from " & subject_Name.all & ".");
else
raise program_Error with my_Name & " has no responses for events from '" & subject_Name.all & "'.";
end if;
end if;
free (subject_Name);
end;
end loop;
end respond;
protected
body safe_Events
is
procedure add (the_Event : in Event.item'Class)
is
begin
the_Events.append (the_Event);
end add;
procedure fetch (all_Events : out Event_Vector)
is
begin
all_Events := the_Events;
the_Events.clear;
end fetch;
end safe_Events;
protected
body safe_subject_Map_of_safe_events
is
procedure add (the_Event : in Event.item'Class;
from_Subject : in String)
is
begin
if not the_Map.contains (from_Subject)
then
the_Map.insert (from_Subject,
new safe_Events);
end if;
the_Map.Element (from_Subject).add (the_Event);
end add;
procedure fetch (all_Events : out subject_events_Pairs;
Count : out Natural)
is
use subject_Maps_of_safe_events;
Cursor : subject_Maps_of_safe_events.Cursor := the_Map.First;
Index : Natural := 0;
begin
while has_Element (Cursor)
loop
declare
the_Events : Event_vector;
begin
Element (Cursor).fetch (the_Events);
Index := Index + 1;
all_Events (Index) := (subject => new String' (Key (Cursor)),
events => the_Events);
end;
next (Cursor);
end loop;
Count := Index;
end fetch;
procedure free
is
use subject_Maps_of_safe_events;
procedure deallocate is new ada.unchecked_Deallocation (safe_Events,
safe_Events_view);
Cursor : subject_Maps_of_safe_events.Cursor := the_Map.First;
the_Events : safe_Events_view;
begin
while has_Element (Cursor)
loop
the_Events := Element (Cursor);
deallocate (the_Events);
next (Cursor);
end loop;
end free;
end safe_subject_Map_of_safe_events;
end lace.make_Observer.deferred;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
private with Ada.Containers.Indefinite_Holders;
with GL.Buffers;
with GL.Objects.Framebuffers;
with GL.Objects.Textures;
with GL.Types.Colors;
with Orka.Contexts;
with Orka.Rendering.Buffers;
with Orka.Rendering.Textures;
with Orka.Windows;
package Orka.Rendering.Framebuffers is
pragma Preelaborate;
use GL.Types;
package FB renames GL.Objects.Framebuffers;
package Textures renames GL.Objects.Textures;
subtype Color_Attachment_Point is FB.Attachment_Point
range FB.Color_Attachment_0 .. FB.Color_Attachment_15;
type Use_Point_Array is array (Rendering.Framebuffers.Color_Attachment_Point) of Boolean;
-- TODO Use as formal parameter in procedure Invalidate
type Buffer_Values is record
Color : Colors.Color := (0.0, 0.0, 0.0, 0.0);
Depth : GL.Buffers.Depth := 1.0;
Stencil : GL.Buffers.Stencil_Index := 0;
end record;
type Framebuffer (Default : Boolean) is tagged private;
function Create_Framebuffer
(Width, Height, Samples : Size;
Context : Contexts.Context'Class) return Framebuffer
with Pre => (if Samples > 0 then Context.Enabled (Contexts.Multisample)),
Post => not Create_Framebuffer'Result.Default;
function Create_Framebuffer (Width, Height : Size) return Framebuffer
with Post => not Create_Framebuffer'Result.Default;
-----------------------------------------------------------------------------
function Create_Default_Framebuffer
(Width, Height : Natural) return Framebuffer
with Post => Create_Default_Framebuffer'Result.Default;
-----------------------------------------------------------------------------
function Width (Object : Framebuffer) return Size;
function Height (Object : Framebuffer) return Size;
function Samples (Object : Framebuffer) return Size;
function Image (Object : Framebuffer) return String;
-- Return a description of the given framebuffer
procedure Use_Framebuffer (Object : Framebuffer);
-- Use the framebuffer during rendering
--
-- The viewport is adjusted to the size of the framebuffer.
procedure Set_Default_Values (Object : in out Framebuffer; Values : Buffer_Values);
-- Set the default values for the color buffers and depth and stencil
-- buffers
function Default_Values (Object : Framebuffer) return Buffer_Values;
-- Return the current default values used when clearing the attached
-- textures
procedure Set_Read_Buffer
(Object : Framebuffer;
Buffer : GL.Buffers.Color_Buffer_Selector);
-- Set the buffer to use when blitting to another framebuffer with
-- procedure Resolve_To
procedure Set_Draw_Buffers
(Object : in out Framebuffer;
Buffers : GL.Buffers.Color_Buffer_List);
-- Set the buffers to use when drawing to output variables in a fragment
-- shader, when calling procedure Clear, or when another framebuffer
-- blits its read buffer to this framebuffer with procedure Resolve_To
procedure Clear
(Object : Framebuffer;
Mask : GL.Buffers.Buffer_Bits := (others => True));
-- Clear the attached textures for which the mask is True using
-- the default values set with Set_Default_Values
--
-- For clearing to be effective, the following conditions must apply:
--
-- - Write mask off
-- - Rasterizer discard disabled
-- - Scissor test off or scissor rectangle set to the desired region
-- - Called procedure Set_Draw_Buffers with a list of attachments
--
-- If a combined depth/stencil texture has been attached, the depth
-- and stencil components can be cleared separately, but it may be
-- faster to clear both components.
procedure Invalidate
(Object : Framebuffer;
Mask : GL.Buffers.Buffer_Bits);
-- Invalidate the attached textures for which the mask is True
procedure Resolve_To
(Object, Subject : Framebuffer;
Mask : GL.Buffers.Buffer_Bits := (Color => True, others => False))
with Pre => Object /= Subject and
(Mask.Color or Mask.Depth or Mask.Stencil) and
(if Object.Samples > 0 and Subject.Samples > 0 then
Object.Samples = Subject.Samples);
-- Copy one or more buffers, resolving multiple samples and scaling
-- if necessary, from the source to the destination framebuffer
--
-- If a buffer is specified in the mask, then the buffer should exist
-- in both framebuffers, otherwise the buffer is not copied. Call
-- Set_Read_Buffer and Set_Draw_Buffers to control which buffer is read
-- from and which buffers are written to.
--
-- Format of color buffers may differ and will be converted (if
-- supported). Formats of depth and stencil buffers must match.
--
-- Note: simultaneously resolving multiple samples and scaling
-- requires GL_EXT_framebuffer_multisample_blit_scaled.
procedure Attach
(Object : in out Framebuffer;
Attachment : FB.Attachment_Point;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level := 0)
with Pre => (not Object.Default and Texture.Allocated and
(if Attachment in Color_Attachment_Point then
(Object.Width = Texture.Width (Level) and
Object.Height = Texture.Height (Level))))
or else raise Constraint_Error with
"Cannot attach " & Rendering.Textures.Image (Texture, Level) &
" to " & Object.Image,
Post => Object.Has_Attachment (Attachment);
-- Attach the texture to the attachment point
--
-- The internal format of the texture must be valid for the given
-- attachment point.
--
-- If one of the attached textures is layered (3D, 1D/2D array, cube
-- map [array], or 2D multisampled array), then all attachments must
-- have the same kind.
--
-- All attachments of the framebuffer must have the same amount of
-- samples and they must all have fixed sample locations, or none of
-- them must have them.
procedure Attach
(Object : in out Framebuffer;
Texture : Textures.Texture;
Level : Textures.Mipmap_Level := 0);
-- Attach the texture to an attachment point based on the internal
-- format of the texture
--
-- Internally calls the procedure Attach above.
--
-- If the texture is color renderable, it will always be attached to
-- Color_Attachment_0. If you need to attach a texture to a different
-- color attachment point then use the other procedure Attach directly.
--
-- If the texture is layered and you want to attach a specific layer,
-- then you must call the procedure Attach_Layer below instead.
procedure Attach_Layer
(Object : in out Framebuffer;
Attachment : FB.Attachment_Point;
Texture : Textures.Texture;
Layer : Natural;
Level : Textures.Mipmap_Level := 0)
with Pre => (not Object.Default and Texture.Allocated and
Texture.Layered and
(if Attachment in Color_Attachment_Point then
(Object.Width = Texture.Width (Level) and
Object.Height = Texture.Height (Level))))
or else raise Constraint_Error with
"Cannot attach layer of " & Rendering.Textures.Image (Texture, Level) &
" to " & Object.Image,
Post => Object.Has_Attachment (Attachment);
-- Attach the selected 1D/2D layer of the texture to the attachment point
--
-- The internal format of the texture must be valid for the given
-- attachment point.
--
-- The texture must be layered (3D, 1D/2D array, cube
-- map [array], or 2D multisampled array).
procedure Detach
(Object : in out Framebuffer;
Attachment : FB.Attachment_Point)
with Pre => not Object.Default,
Post => not Object.Has_Attachment (Attachment);
-- Detach any texture currently attached to the given attachment point
function Has_Attachment
(Object : Framebuffer;
Attachment : FB.Attachment_Point) return Boolean;
Framebuffer_Incomplete_Error : exception;
private
package Attachment_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => Textures.Texture, "=" => Textures."=");
package Color_Buffer_List_Holder is new Ada.Containers.Indefinite_Holders
(Element_Type => GL.Buffers.Color_Buffer_List, "=" => GL.Buffers."=");
type Attachment_Array is array (FB.Attachment_Point)
of Attachment_Holder.Holder;
type Framebuffer (Default : Boolean) is tagged record
GL_Framebuffer : FB.Framebuffer;
Attachments : Attachment_Array;
Defaults : Buffer_Values;
Draw_Buffers : Color_Buffer_List_Holder.Holder;
Width, Height, Samples : Size;
end record;
end Orka.Rendering.Framebuffers;
|
with Memory.Transform.Shift; use Memory.Transform.Shift;
with Memory.Join; use Memory.Join;
package body Test.Shift is
procedure Test_Positive is
mem : constant Monitor_Pointer := Create_Monitor(0);
bank : constant Monitor_Pointer := Create_Monitor(1, False);
shift : Shift_Pointer := Create_Shift;
join : constant Join_Pointer := Create_Join(shift, 0);
begin
Set_Memory(bank.all, join);
Set_Bank(shift.all, bank);
Set_Memory(shift.all, mem);
Set_Value(shift.all, 1);
Check(Get_Time(shift.all) = 0);
Check(Get_Writes(shift.all) = 0);
Check(Get_Cost(shift.all) = 0);
Read(shift.all, 0, 8);
Check(mem.last_addr = 0);
Check(mem.last_size = 8);
Check(bank.last_addr = 0);
Check(bank.last_size = 8);
Check(Get_Time(shift.all) = 2);
Check(Get_Writes(shift.all) = 0);
Read(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 4);
Check(Get_Writes(shift.all) = 0);
Write(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 6);
Check(Get_Writes(shift.all) = 1);
Read(shift.all, 16, 8);
Check(mem.last_addr = 16);
Check(mem.last_size = 8);
Check(bank.last_addr = 32);
Check(bank.last_size = 8);
Check(Get_Time(shift.all) = 8);
Read(shift.all, 2 ** 31, 4);
Check(mem.last_addr = 2 ** 31);
Check(mem.last_size = 4);
Check(bank.last_addr = 8);
Check(bank.last_size = 4);
Check(Get_Time(shift.all) = 10);
Read(shift.all, 105, 2);
Check(mem.last_addr = 105);
Check(mem.last_size = 2);
Check(bank.last_addr = 209);
Check(bank.last_size = 2);
Check(Get_Time(shift.all) = 12);
Idle(shift.all, 4);
Check(Get_Time(shift.all) = 16);
Read(shift.all, 0, 1);
Check(Get_Time(shift.all) = 18);
Destroy(Memory_Pointer(shift));
end Test_Positive;
procedure Test_Negative is
mem : constant Monitor_Pointer := Create_Monitor(0, True);
bank : constant Monitor_Pointer := Create_Monitor(0, False);
shift : Shift_Pointer := Create_Shift;
join : constant Join_Pointer := Create_Join(shift, 0);
begin
Set_Memory(bank.all, join);
Set_Bank(shift.all, bank);
Set_Memory(shift.all, mem);
Set_Value(shift.all, -2);
Check(Get_Time(shift.all) = 0);
Check(Get_Writes(shift.all) = 0);
Read(shift.all, 0, 8);
Check(mem.last_addr = 0);
Check(mem.last_size = 8);
Check(bank.last_addr = 0);
Check(bank.last_size = 8);
Check(Get_Time(shift.all) = 1);
Check(Get_Writes(shift.all) = 0);
Read(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 2);
Check(Get_Writes(shift.all) = 0);
Write(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 3);
Check(Get_Writes(shift.all) = 1);
Write(shift.all, 9, 4);
Check(mem.last_addr = 9);
Check(mem.last_size = 4);
Check(bank.last_addr = ((Address_Type(2) ** 30) or 1));
Check(bank.last_size = 4);
Check(Get_Time(shift.all) = 4);
Check(Get_Writes(shift.all) = 2);
Destroy(Memory_Pointer(shift));
end Test_Negative;
procedure Test_Zero is
mem : constant Monitor_Pointer := Create_Monitor(0, True);
bank : constant Monitor_Pointer := Create_Monitor(0, False);
shift : Shift_Pointer := Create_Shift;
join : constant Join_Pointer := Create_Join(shift, 0);
begin
Set_Memory(bank.all, join);
Set_Bank(shift.all, bank);
Set_Memory(shift.all, mem);
Set_Value(shift.all, 0);
Read(shift.all, 0, 8);
Check(mem.last_addr = 0);
Check(mem.last_size = 8);
Check(bank.last_addr = 0);
Check(bank.last_size = 8);
Check(Get_Time(shift.all) = 1);
Check(Get_Writes(shift.all) = 0);
Read(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 2);
Check(Get_Writes(shift.all) = 0);
Write(shift.all, 1, 1);
Check(mem.last_addr = 1);
Check(mem.last_size = 1);
Check(bank.last_addr = 1);
Check(bank.last_size = 1);
Check(Get_Time(shift.all) = 3);
Check(Get_Writes(shift.all) = 1);
Write(shift.all, 9, 4);
Check(mem.last_addr = 9);
Check(mem.last_size = 4);
Check(bank.last_addr = 9);
Check(bank.last_size = 4);
Check(Get_Time(shift.all) = 4);
Check(Get_Writes(shift.all) = 2);
Read(shift.all, 100, 16);
Check(mem.last_addr = 100);
Check(mem.last_size = 16);
Check(bank.last_addr = 100);
Check(bank.last_size = 16);
Check(Get_Time(shift.all) = 7);
Check(Get_Writes(shift.all) = 2);
Read(shift.all, 16, 4);
Check(mem.last_addr = 16);
Check(mem.last_size = 4);
Check(bank.last_addr = 16);
Check(bank.last_size = 4);
Check(Get_Time(shift.all) = 8);
Check(Get_Writes(shift.all) = 2);
Destroy(Memory_Pointer(shift));
end Test_Zero;
procedure Run_Tests is
begin
Test_Positive;
Test_Negative;
Test_Zero;
end Run_Tests;
end Test.Shift;
|
--Helen: added this file to implement wide_text_io.editing
package Ada.Wide_Text_IO.Editing is
type Picture is private;
function Valid (Pic_String : in String;
Blank_When_Zero : in Boolean := False) return Boolean;
function To_Picture (Pic_String : in String;
Blank_When_Zero : in Boolean := False)
return Picture;
function Pic_String (Pic : in Picture) return String;
function Blank_When_Zero (Pic : in Picture) return Boolean;
Max_Picture_Length : constant := 100000;
Picture_Error : exception;
Default_Currency : constant Wide_String := "$";
Default_Fill : constant Wide_Character := '*';
Default_Separator : constant Wide_Character := ',';
Default_Radix_Mark : constant Wide_Character := '.';
generic
type Num is delta <> digits <>;
Default_Currency : in Wide_String := Wide_Text_IO.Editing.Default_Currency;
Default_Fill : in Wide_Character := Wide_Text_IO.Editing.Default_Fill;
Default_Separator : in Wide_Character := Wide_Text_IO.Editing.Default_Separator;
Default_Radix_Mark : in Wide_Character := Wide_Text_IO.Editing.Default_Radix_Mark;
package Decimal_Output is
function Length (Pic : in Picture;
Currency : in Wide_String := Default_Currency)
return Natural;
function Valid (Item : in Num;
Pic : in Picture;
Currency : in Wide_String := Default_Currency)
return Boolean;
function Image (Item : in Num;
Pic : in Picture;
Currency : in Wide_String := Default_Currency;
Fill : in Wide_Character := Default_Fill;
Separator : in Wide_Character := Default_Separator;
Radix_Mark : in Wide_Character := Default_Radix_Mark)
return Wide_String;
procedure Put (File : in File_Type;
Item : in Num;
Pic : in Picture;
Currency : in Wide_String := Default_Currency;
Fill : in Wide_Character := Default_Fill;
Separator : in Wide_Character := Default_Separator;
Radix_Mark : in Wide_Character := Default_Radix_Mark);
procedure Put (Item : in Num;
Pic : in Picture;
Currency : in Wide_String := Default_Currency;
Fill : in Wide_Character := Default_Fill;
Separator : in Wide_Character := Default_Separator;
Radix_Mark : in Wide_Character := Default_Radix_Mark);
procedure Put (To : out Wide_String;
Item : in Num;
Pic : in Picture;
Currency : in Wide_String := Default_Currency;
Fill : in Wide_Character := Default_Fill;
Separator : in Wide_Character := Default_Separator;
Radix_Mark : in Wide_Character := Default_Radix_Mark);
end Decimal_Output;
private
type picture is array(1..1000, 1..1000) of integer;
end Ada.Wide_Text_IO.Editing;
|
with Ada.Text_IO; use Ada.Text_IO;
with GL.Types;
with Maths;
-- with Utilities;
with Blade_Types;
with E3GA;
with GA_Maths;
with GA_Utilities;
with Multivector_Utilities;
with Metric;
with Multivector_Type;
package body Multivector_Analyze_C3GA is
function Analyze_Flat (Analysis_In : MV_Analysis;
MV_X : Multivectors.Multivector;
Probe : Multivectors.Normalized_Point)
return MV_Analysis;
function Analyze_Free (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis;
function Analyze_Round (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis;
function Analyze_Tangent (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis;
procedure Init_Analysis_Type (Analysis_In : MV_Analysis;
theAnalysis : in out MV_Analysis);
-- -------------------------------------------------------------------------
function Analyze (MV : Multivectors.Multivector;
Probe : Multivectors.Normalized_Point := C3GA.no;
Flags : Flag_Type := (Flag_Invalid, false);
Epsilon : float := Default_Epsilon)
return MV_Analysis is
use Multivector_Type;
MV_X : Multivectors.Multivector := MV;
MV_Info : Multivector_Type.MV_Type_Record;
theAnalysis : MV_Analysis;
procedure Classify is
use Multivectors;
OP_NiX_Val : Float := 0.0;
IP_NiX_Val : Float := 0.0;
-- Xsq_Val : Float := 0.0;
Product : Multivectors.Multivector;
Xsq_Val : constant Float := Norm_Esq (MV_X);
OP_NiX : Boolean;
IP_NiX : Boolean;
Xsq : constant Boolean := Abs (Xsq_Val) > Epsilon;
begin
Product := Outer_Product (C3GA.ni, MV_X);
OP_NiX := not Multivectors.Is_Null (Product);
if OP_NiX then
OP_NiX_Val := Norm_E (Product);
OP_NiX := Abs (OP_Nix_Val) > Epsilon;
end if;
Product := Left_Contraction (C3GA.ni, MV_X, Metric.C3_Metric);
IP_NiX := not Multivectors.Is_Null (Product);
if IP_NiX then
IP_NiX_Val := Norm_E (Product);
IP_NiX := Abs (IP_Nix_Val) > Epsilon;
end if;
-- Xsq_Val := Norm_Esq (MV_X); -- norm_r
if (not OP_NiX) and (not IP_NiX) then -- OP_NiX and IP_NiX approx 0.0
Put_Line ("Multivector_Analyze_C3GA.Classify, classification: Free.");
theAnalysis := Analyze_Free (theAnalysis, MV_X);
elsif (not OP_NiX) and IP_NiX then -- OP_NiX approx 0.0
Put_Line ("Multivector_Analyze_C3GA.Classify, classification: Flat.");
theAnalysis := Analyze_Flat (theAnalysis, MV_X, Probe);
elsif OP_Nix and (not IP_NiX) then -- IP_NiX approx 0.0
Put_Line ("Multivector_Analyze_C3GA.Classify, classification: Dual.");
theAnalysis.M_Flags.Dual := not theAnalysis.M_Flags.Dual;
theAnalysis := Analyze_Flat (theAnalysis, Dual (MV_X, Metric.C3_Metric), Probe);
elsif OP_NiX and IP_NiX then
if not Xsq then
Put_Line ("Multivector_Analyze_C3GA.Classify, classification: Tangent.");
theAnalysis := Analyze_Tangent (theAnalysis, MV_X);
else
Put_Line ("Multivector_Analyze_C3GA.Classify, classification: Round.");
theAnalysis := Analyze_Round (theAnalysis, MV_X);
end if;
end if;
end Classify;
begin
-- GA_Utilities.Print_Multivector ("Multivector_Analyze_C3GA.Analyze MV_X:", MV_X);
-- New_Line;
theAnalysis.M_Flags.Valid := True;
theAnalysis.Epsilon := Epsilon;
theAnalysis.M_Type.Model_Kind := Multivector_Analyze.Conformal_Model;
if Flags.Dual then
Put_Line ("Multivector_Analyze_C3GA.Analyze Is Dual.");
theAnalysis.M_Flags.Dual := True;
MV_X := Multivectors.Dual (MV_X, Metric.C3_Metric);
GA_Utilities.Print_Multivector_String
("Multivector_Analyze_C3GA.Analyze Dual MV_X", MV_X,
Blade_Types.Basis_Names_C3GA);
end if;
MV_Info := Init (MV_X, Metric.C3_Metric);
theAnalysis.M_MV_Type := MV_Info;
-- Check for zero blade
if Zero (theAnalysis.M_MV_Type) then
Put_Line ("Multivector_Analyze_C3GA.Analyze Zero_Blade.");
theAnalysis.M_Type.Blade_Class := Zero_Blade;
theAnalysis.Weight := 0.0;
elsif MV_Kind (theAnalysis.M_MV_Type) = Versor_MV then
Put_Line ("Multivector_Analyze_C3GA.Analyze Versor_Object 2.");
theAnalysis.M_Type.Versor_Subclass := Even_Versor;
theAnalysis.M_Vectors (1) := C3GA.To_VectorE3GA (E3GA.e1);
else
Put_Line ("Multivector_Analyze_C3GA.Analyze case Grade_Use: " &
GA_Maths.Grade_Usage'Image (Grade_Use (theAnalysis.M_MV_Type)));
case Grade_Use (theAnalysis.M_MV_Type) is
when 0 => -- Grade 0 Scalar
Put_Line ("Multivector_Analyze_C3GA.Analyze Grade_Use = 1.");
theAnalysis.M_Type.Blade_Class := Scalar_Blade;
theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
theAnalysis.M_Type.M_Grade := 1;
theAnalysis.Weight := Multivectors.Scalar_Part (MV_X);
when 5 => -- Grade 5 Pseudo scalar
Put_Line ("Multivector_Analyze_C3GA.Analyze Grade_Use = 6.");
theAnalysis.M_Type.Blade_Class := Pseudo_Scalar_Blade;
theAnalysis.M_Type.Blade_Subclass := Pseudo_Scalar_Subclass;
theAnalysis.M_Type.M_Grade := 6;
theAnalysis.Weight := C3GA.NO_E1_E2_E3_NI (MV_X);
when others => Classify;
end case;
end if;
New_Line;
return theAnalysis;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze_C3GA.Analyze.");
raise;
end Analyze;
-- ----------------------------------------------------------------------------
-- format of flat
-- theAnalysis.M_Vectors (1) m_pt[0] = location
-- theAnalysis.M_Vectors (2) m_vc[0] .. m_vc[1]
-- unit 3D vector basis for attitude (direction)
-- theAnalysis.M_Vectors (3) m_sc[0] = weight
function Analyze_Flat (Analysis_In : MV_Analysis;
MV_X : Multivectors.Multivector;
Probe : Multivectors.Normalized_Point)
return MV_Analysis is
use Multivectors;
Met : constant Metric.Metric_Record := Metric.C3_Metric;
Grade : Integer :=
Multivector_Type.MV_Grade (Analysis_In.M_MV_Type);
-- Attitude is a free N-vector
Attitude : constant Multivector :=
Negate (Left_Contraction (C3GA.ni, MV_X, Metric.C3_Metric));
MV_Inverse : Multivector;
MV_Location : Multivector;
Location : Multivectors.Normalized_Point;
Blade_Factors : Multivectors.Multivector_List;
SP : Float;
Scale : Float;
Weight : Float;
theAnalysis : MV_Analysis (Flat_Analysis);
begin
Init_Analysis_Type (Analysis_In, theAnalysis);
theAnalysis.M_Type.Blade_Class := Flat_Blade;
if theAnalysis.M_Flags.Dual then
Grade := 5 - Grade;
end if;
MV_Inverse := General_Inverse (MV_X, Met);
-- MV_Location is a normalized dual sphere
MV_Location := Left_Contraction (Probe, MV_X, Met);
MV_Location := Left_Contraction (MV_Location, MV_Inverse, Met);
SP := Scalar_Product (C3GA.ni, MV_Location, Met);
if SP = 0.0 then
Location := C3GA.Set_Normalized_Point (E1 => 0.0, E2 => 0.0, E3 => 0.0);
else
MV_Location := Geometric_Product (MV_Location, -New_Scalar (1.0 / SP), Met);
Location := C3GA.Set_Normalized_Point (C3GA.To_VectorE3GA (MV_Location));
end if;
if Grade = 1 then
Weight := -Scalar_Product (MV_X, C3GA.no, Met);
else
Weight := Abs (Norm_Esq (MV_X)); -- Norm_Esq is norm_r
end if;
-- ************* format of flat ***************
-- theAnalysis.Points m_pt[0] = location
-- theAnalysis.M_Vectors m_vc[0] .. m_vc[1] = unit 3D vector basis
-- for attitude (direction)
-- theAnalysis.Scalars m_sc[0] = weight
-- ************* END format of flat ***************
theAnalysis.Points (1) := C3GA.NP_To_VectorE3GA (Location);
theAnalysis.Weight := Weight;
-- Grade indications are taken from Geometric Algebra and its
-- Application to Computer Graphics by Hildenbrand, Fontijne,
-- Perwass and Dorst, Eurographics 2004.
-- "the representation of a point is simply a sphere of radius zero".
-- factor attitude:
case Grade is
when 1 => theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
Put_Line ("Multivector_Analyze_C3GA.Analyze_Flat, Scalar_Subclass.");
theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
when 2 => theAnalysis.M_Type.Blade_Subclass := Point_Subclass;
Put_Line ("Multivector_Analyze_C3GA.Analyze_Flat, Point_Subclass.");
theAnalysis.M_Type.Blade_Subclass := Point_Subclass;
when 3 => -- Line
Put_Line ("Multivector_Analyze_C3GA.Analyze_Flat, Line_Subclass.");
theAnalysis.M_Type.Blade_Subclass := Line_Subclass;
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Unit_E (Left_Contraction (C3GA.no, Attitude, Met)));
when 4 => -- Plane
Put_Line ("Multivector_Analyze_C3GA.Analyze_Flat, Plane_Subclass.");
theAnalysis.M_Type.Blade_Subclass := Plane_Subclass;
-- GA_Utilities.Print_Multivector_String
-- ("Multivector_Analyze_C3GA.Analyze_Flat, " &
-- "Plane Subclass Reverse_MV (LC (C3GA.no, Reverse_MV (Attitude)",
-- Reverse_MV (Left_Contraction (C3GA.no, Reverse_MV (Attitude), Met)),
-- Blade_Types.Basis_Names_C3GA);
Blade_Factors := Multivector_Utilities.Factorize_Blades
(Reverse_MV (Left_Contraction (C3GA.no, Reverse_MV (Attitude), Met)),
Scale);
-- Blade_Factors agrees with C++: -1.00E+00 * e1 -1.00E+00 * e3
-- GA_Utilities.Print_Multivector_List_String
-- ("Multivector_Analyze_C3GA.Analyze_Flat, " &
-- "Plane Subclass Blade_Factors", Blade_Factors, Blade_Types.Basis_Names_C3GA);
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (-Dual (Outer_Product (Get_Multivector (Blade_Factors, 1),
Get_Multivector (Blade_Factors, 2)), Metric.C3_Metric));
-- M_Vectors agrees with C++: -1.00E+00 * e1 -1.00E+00 * e2 1.00E+00 * e3
when others => null;
end case;
return theAnalysis;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze_C3GA.Analyze_Flat.");
raise;
end Analyze_Flat;
-- ----------------------------------------------------------------------------
-- format of free
-- m_pt[0] = no (or probe?)
-- m_vc[0] .. m_vc[2] = unit 3D vector basis for attitude (direction)
-- m_sc[0] = weight
function Analyze_Free (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis is
use Metric;
use Multivectors;
Grade : constant Integer :=
Multivector_Type.MV_Grade (Analysis_In.M_MV_Type);
Weight : constant Float := Norm_E (MV);
-- Attitude : constant Multivector := MV;
Blade_Factors : Multivectors.Multivector_List;
Scale : Float := 1.0;
theAnalysis : MV_Analysis (Free_Analysis);
begin
Init_Analysis_Type (Analysis_In, theAnalysis);
theAnalysis.M_Type.Blade_Class := Free_Blade;
theAnalysis.Points (1) := (0.0, 0.0, 0.0);
theAnalysis.Weight := Weight;
case Grade is
when 1 => theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
Put_Line ("Multivector_Analyze_C3GA.Analyze_Free Grade 1.");
when 2 => -- F Vector
Put_Line ("Multivector_Analyze_C3GA.Analyze_Free Grade 2.");
theAnalysis.M_Type.Blade_Subclass := Vector_Subclass;
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Unit_E (Left_Contraction
(C3GA.no, MV, C3_Metric)));
when 3 => -- F Bivector
Put_Line ("Multivector_Analyze_C3GA.Analyze_Free Grade 3.");
theAnalysis.M_Type.Blade_Subclass := Bivector_Subclass;
Blade_Factors :=
Multivector_Utilities.Factorize_Blades (MV, Scale);
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (-Dual (Outer_Product (Get_Multivector (Blade_Factors, 1),
Get_Multivector (Blade_Factors, 2)), C3_Metric));
when 4 => -- F Trivector
Put_Line ("Multivector_Analyze_C3GA.Analyze_Free Grade 4.");
theAnalysis.M_Type.Blade_Subclass := Trivector_Subclass;
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e3));
when others =>
Put_Line ("Multivector_Analyze_C3GA.Analyze_Free Grade others.");
end case;
return theAnalysis;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze_C3GA.Analyze_Free.");
raise;
end Analyze_Free;
-- ----------------------------------------------------------------------------
-- Format of round
-- m_pt[0] = location
-- m_sc[0] = signed radius
-- m_sc[1] = signed weight
-- m_vc[0] .. m_vc[2] = unit 3D vector basis for attitude (direction)
function Analyze_Round (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis is
use Maths.Single_Math_Functions;
use Multivectors;
Met : constant Metric.Metric_Record := Metric.C3_Metric;
MV_X : Multivector := MV;
Grade : constant Integer :=
Multivector_Type.MV_Grade (Analysis_In.M_MV_Type);
MV_Factors : Multivector_List;
LC : Multivector;
LC_NI_MV : Multivector;
LC_NI_MV_Inverse : Multivector;
SCP_Inverse : Float;
Attitude : Multivector;
Location : Multivector;
Point_Location : Multivectors.Normalized_Point;
NI_Xsq : Float;
Radius : Float;
Radius_Sq : Float;
Weight : Float;
Scale : Float := 1.0;
theAnalysis : MV_Analysis (Round_Analysis);
begin
-- Put_Line ("Multivector_Analyze_C3GA.Analyze_Round, Grade:" &
-- Integer'Image (Grade));
Init_Analysis_Type (Analysis_In, theAnalysis);
if Grade = 0 then
theAnalysis.M_Type.Blade_Class := Scalar_Blade;
theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
theAnalysis.Weight := Scalar_Part (MV_X); -- signed weight
else
theAnalysis.M_Type.Blade_Class := Round_Blade;
if Grade = 1 then
MV_X := Dual (MV_X, Metric.C3_Metric);
-- m_flags = m_flags xor FLAG_DUAL?
theAnalysis.M_Flags.Dual := not theAnalysis.M_Flags.Dual;
end if;
-- MV_X checked OK against C++ version
LC_NI_MV := Left_Contraction (C3GA.ni, MV_X, Metric.C3_Metric);
-- GA_Utilities.Print_Multivector_String
-- ("Multivector_Analyze_C3GA.Analyze_Round LC_NI_MV", LC_NI_MV,
-- Blade_Types.Basis_Names_C3GA);
Attitude :=
Negate (Outer_Product (LC_NI_MV, C3GA.ni));
LC_NI_MV_Inverse := General_Inverse (LC_NI_MV, Met);
-- location is normalized dual sphere
Location := Geometric_Product (MV_X, LC_NI_MV_Inverse, Met); -- _location
-- Put_Line ("Multivector_Analyze_C3GA.Analyze_Round calling Geometric_Product 2");
SCP_Inverse := -1.0 / Scalar_Product (C3GA.ni, Location, Met);
Location := Geometric_Product (Location, SCP_Inverse);
-- normalizedPoint location = c3gaPoint(_vectorE3GA(_location));
Point_Location := To_Normalized_Point (Location);
NI_Xsq := Scalar_Product (LC_NI_MV, LC_NI_MV, Met);
-- Grade_Inversion is eqivalent to Grade_Involution
Radius_Sq := Scalar_Part
(Geometric_Product (MV_X, Grade_Inversion (MV_X), Met)) / NI_Xsq;
if Radius_Sq < 0.0 then
Radius_Sq := -Radius_Sq;
end if;
Radius := Float (Sqrt (GL.Types.Single (Abs (Radius_Sq))));
Weight := Norm_E (Left_Contraction (C3GA.no, Attitude, Met));
theAnalysis.Points (1) := C3GA.NP_To_VectorE3GA (Point_Location);
theAnalysis.Radius := Radius;
theAnalysis.Weight := Weight;
-- Factor attitude (direction):
case Grade is
when 1 => -- (dual) sphere
theAnalysis.M_Type.Blade_Subclass := Sphere_Subclass;
theAnalysis.M_Flags.Dual := not theAnalysis.M_Flags.Dual;
-- direction
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e3));
when 2 => -- point pair
theAnalysis.M_Type.Blade_Subclass := Point_Pair_Subclass;
LC := Left_Contraction (C3GA.no, Attitude, Met);
if GA_Utilities.Multivector_Size (LC) > 0 then
theAnalysis.M_Vectors (1) := C3GA.To_VectorE3GA (Unit_E (LC));
else
raise Analyze_C3GA_Exception with
"Multivector_Analyze_C3GA.Analyze_Round, " &
"Grade 2 Left Contraction is zero.";
end if;
when 3 =>
-- circle explicit factorization required:
theAnalysis.M_Type.Blade_Subclass := Circle_Subclass;
MV_X := Reverse_MV (Left_Contraction (C3GA.no,
Reverse_MV (Attitude), Met));
-- GA_Utilities.Print_Multivector_String
-- ("Multivector_Analyze_C3GA.Analyze_Round grade 3 MV_X",
-- MV_X, Blade_Types.Basis_Names_C3GA);
-- Returned scale not used
MV_Factors :=
Multivector_Utilities.Factorize_Blades (MV_X, Scale);
-- GA_Utilities.Print_Multivector_List_String
-- ("Multivector_Analyze_C3GA.Analyze_Round MV_Factors",
-- MV_Factors, Blade_Types.Basis_Names_C3GA);
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Get_Multivector (MV_Factors, 1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Get_Multivector (MV_Factors, 2));
if E3GA.Is_Zero (theAnalysis.M_Vectors (1)) or
E3GA.Is_Zero (theAnalysis.M_Vectors (2)) then
theAnalysis.M_Vectors (3) := (0.0, 0.0, 1.0);
else
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA
(Dual (Outer_Product (Get_Multivector (MV_Factors, 1),
Get_Multivector (MV_Factors, 2)), Met));
end if;
when 4 =>
theAnalysis.M_Type.Blade_Subclass := Sphere_Subclass;
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e3));
when others =>
Put_Line
("Multivector_Analyze_C3GA.Analyze_Round, unprocessed Grade: " &
Integer'Image (Grade));
end case;
-- Print_Analysis ("Multivector_Analyze_C3GA.Analyze_Round,",
-- theAnalysis);
-- Print_E3_Vector_Array
-- ("Multivector_Analyze_C3GA.Analyze_Round direction M_Vectors",
-- theAnalysis.M_Vectors);
end if;
return theAnalysis;
exception
when others =>
Put_Line ("An exception occurred in Multivector_Analyze_C3GA.Analyze_Round.");
raise;
end Analyze_Round;
-- ----------------------------------------------------------------------------
-- format of tangent
-- m_pt[0] = location
-- m_vc[0] .. m_vc[2] = unit 3D vector basis for attitude
-- m_sc[0] = weight
function Analyze_Tangent (Analysis_In : MV_Analysis;
MV : Multivectors.Multivector)
return MV_Analysis is
use Multivectors;
Met : constant Metric.Metric_Record := Metric.C3_Metric;
Grade : constant Integer :=
Multivector_Type.MV_Grade (Analysis_In.M_MV_Type);
LC_NI_MV : Multivector;
LC_NI_MV_Inv : Multivector;
Attitude : constant Multivector :=
Negate (Outer_Product (LC_NI_MV, C3GA.ni));
Blade_Factors : Multivectors.Multivector_List;
Location : Multivector;
Point_Location : Multivectors.Normalized_Point;
Scale : Float;
Weight : Float;
theAnalysis : MV_Analysis (Tangent_Analysis);
begin
Init_Analysis_Type (Analysis_In, theAnalysis);
theAnalysis.M_Type.Blade_Class := Tangent_Blade;
LC_NI_MV := Left_Contraction (C3GA.ni, MV, Met);
LC_NI_MV_Inv := General_Inverse (LC_NI_MV, Met);
Location :=
Geometric_Product (MV, LC_NI_MV_Inv, Met);
Location := Geometric_Product
(Location, -1.0 / Scalar_Product (C3GA.ni, Location, Met));
Point_Location := C3GA.Set_Normalized_Point (C3GA.To_VectorE3GA (Location));
Weight := Norm_E (Left_Contraction (C3GA.no, Attitude, Met));
theAnalysis.Points (1) := C3GA.NP_To_VectorE3GA (Point_Location);
theAnalysis.Weight := Weight;
case Grade is
when 1 =>
theAnalysis.M_Type.Blade_Subclass := Scalar_Subclass;
theAnalysis.M_Flags.Dual := not theAnalysis.M_Flags.Dual;
when 2 =>
theAnalysis.M_Type.Blade_Subclass := Vector_Subclass;
theAnalysis.M_Vectors (1) := C3GA.To_VectorE3GA
(Unit_E (Left_Contraction (C3GA.no, Attitude, Met)));
when 3 =>
theAnalysis.M_Type.Blade_Subclass := Bivector_Subclass;
Blade_Factors :=
Multivector_Utilities.Factorize_Blades (MV, Scale);
theAnalysis.M_Vectors (1) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 1));
theAnalysis.M_Vectors (2) :=
C3GA.To_VectorE3GA (Get_Multivector (Blade_Factors, 2));
theAnalysis.M_Vectors (3) :=
C3GA.To_VectorE3GA (-Dual (Outer_Product (Get_Multivector (Blade_Factors, 1),
Get_Multivector (Blade_Factors, 2)), Metric.C3_Metric));
when 4 =>
theAnalysis.M_Type.Blade_Subclass := Trivector_Subclass;
theAnalysis.M_Vectors (1) := C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e1));
theAnalysis.M_Vectors (2) := C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e2));
theAnalysis.M_Vectors (3) := C3GA.To_VectorE3GA (Basis_Vector (Blade_Types.E3_e3));
when others => null;
end case;
return theAnalysis;
end Analyze_Tangent;
-- ----------------------------------------------------------------------------
procedure Init_Analysis_Type (Analysis_In : MV_Analysis;
theAnalysis : in out MV_Analysis) is
begin
theAnalysis.Epsilon := Analysis_In.Epsilon;
theAnalysis.M_Type := Analysis_In.M_Type;
theAnalysis.M_Flags := Analysis_In.M_Flags;
end Init_Analysis_Type;
-- ----------------------------------------------------------------------------
end Multivector_Analyze_C3GA;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
package body Program.Relative_Access_Types is
package Conversions is new System.Address_To_Access_Conversions (Object);
use System.Storage_Elements;
---------
-- "+" --
---------
function "+" (Value : Object_Access) return Relative_Access is
begin
return Result : Relative_Access do
if Value = null then
Result := Relative_Access'First;
else
declare
Value_Address : constant Integer_Address :=
To_Integer (Value.all'Address);
Result_Address : constant Integer_Address :=
To_Integer (Result'Address);
begin
if Value_Address > Result_Address then
Result := Relative_Access (Value_Address - Result_Address);
else
Result := -Relative_Access (Result_Address - Value_Address);
end if;
end;
end if;
end return;
end "+";
---------
-- "-" --
---------
function "-" (Value : Relative_Access) return Object_Access is
Self : constant Integer_Address := To_Integer (Value'Address);
begin
if Value = Relative_Access'First then
return null;
elsif Value > 0 then
return Object_Access
(Conversions.To_Pointer
(To_Address (Self + Integer_Address (Value))));
else
return Object_Access
(Conversions.To_Pointer
(To_Address (Self - Integer_Address (abs Value))));
end if;
end "-";
end Program.Relative_Access_Types;
|
------------------------------------------------------------------------------
-- --
-- Standard Peripheral Library for STM32 Targets --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with STM32_SVD.I2C; use STM32_SVD.I2C;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32.RCC;
with HAL.I2C; use HAL.I2C;
package body STM32.I2C is
type I2C_Transfer_Mode is
(Reload_Mode, -- Enable reload mode
Autoend_Mode, -- Enable automatic end mode
Softend_Mode); -- Enable software end mode
type I2C_Request is
(No_Start_Stop, -- Don't generate start or stop
Generate_Stop, -- Generate a stop condition
Generate_Start_Read, -- Generate a start read request
Generate_Start_Write); -- Generate a start write request
procedure Config_Transfer
(Port : in out I2C_Port;
Addr : I2C_Address;
Size : Byte;
Mode : I2C_Transfer_Mode;
Request : I2C_Request);
procedure Reset_Config (Port : in out I2C_Port);
procedure Check_Nack
(Port : in out I2C_Port;
Timeout : Natural;
Status : out HAL.I2C.I2C_Status);
procedure Wait_Tx_Interrupt_Status
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status);
procedure Wait_Transfer_Complete_Reset_Flag
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status);
procedure Wait_Stop_Flag
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status);
------------------
-- Port_Enabled --
------------------
function Port_Enabled (Port : I2C_Port) return Boolean
is
begin
return Port.Periph.CR1.PE;
end Port_Enabled;
---------------
-- Configure --
---------------
procedure Configure
(Port : in out I2C_Port;
Configuration : I2C_Configuration)
is
begin
if Port.State /= Reset then
return;
end if;
Port.Config := Configuration;
STM32.RCC.Enable_Clock (STM32_SVD.I2C.I2C_Peripheral (Port.Periph.all));
STM32.RCC.Reset (STM32_SVD.I2C.I2C_Peripheral (Port.Periph.all));
-- Disable the I2C port
Port.Periph.CR1.PE := False;
-- Reset the timing register to 100_000 Hz
Port.Periph.TIMINGR :=
(SCLL => 50,
SCLH => 39,
SDADEL => 1,
SCLDEL => 9,
PRESC => 4,
others => <>);
-- I2C Own Address Register configuration
if Configuration.Own_Address /= 0 then
Port.Periph.OAR1 :=
(OA1 => Configuration.Own_Address,
OA1EN => True,
OA1MODE => Configuration.Addressing_Mode = Addressing_Mode_10bit,
others => <>);
end if;
-- CR2 configuration
-- Enable AUTOEND by default, set NACK (should be disabled only in
-- slave mode
Port.Periph.CR2 :=
(AUTOEND => True,
NACK => True,
ADD10 => Configuration.Addressing_Mode = Addressing_Mode_10bit,
others => <>);
-- OAR2 configuration
-- ??? Add support for dual addressing
Port.Periph.OAR2 := (others => <>);
-- CR1 configuration
Port.Periph.CR1 :=
(GCEN => Configuration.General_Call_Enabled,
NOSTRETCH => Configuration.Clock_Stretching_Enabled,
others => <>);
Port.State := Ready;
-- Enable the port
Port.Periph.CR1.PE := True;
end Configure;
-------------------
-- Is_Configured --
-------------------
function Is_Configured (Port : I2C_Port) return Boolean
is
begin
return Port.State /= Reset;
end Is_Configured;
---------------------
-- Config_Transfer --
---------------------
procedure Config_Transfer
(Port : in out I2C_Port;
Addr : I2C_Address;
Size : Byte;
Mode : I2C_Transfer_Mode;
Request : I2C_Request)
is
CR2 : CR2_Register := Port.Periph.CR2;
begin
CR2.SADD := UInt10 (Addr);
CR2.NBYTES := Size;
CR2.RELOAD := Mode = Reload_Mode;
CR2.AUTOEND := Mode = Autoend_Mode;
CR2.RD_WRN := False;
CR2.START := False;
CR2.STOP := False;
case Request is
when No_Start_Stop =>
null;
when Generate_Stop =>
CR2.STOP := True;
when Generate_Start_Read =>
CR2.RD_WRN := True;
CR2.START := True;
when Generate_Start_Write =>
CR2.START := True;
end case;
Port.Periph.CR2 := CR2;
end Config_Transfer;
------------------
-- Reset_Config --
------------------
procedure Reset_Config (Port : in out I2C_Port)
is
CR2 : CR2_Register := Port.Periph.CR2;
begin
CR2.SADD := 0;
CR2.HEAD10R := False;
CR2.NBYTES := 0;
CR2.RELOAD := False;
CR2.RD_WRN := False;
Port.Periph.CR2 := CR2;
end Reset_Config;
----------------
-- Check_Nack --
----------------
procedure Check_Nack
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status)
is
Start : constant Time := Clock;
begin
if Port.Periph.ISR.NACKF then
if Port.State = Master_Busy_Tx
or else Port.State = Mem_Busy_Tx
or else Port.State = Mem_Busy_Rx
then
-- We generate a STOP condition if SOFTEND mode is enabled
if not Port.Periph.CR2.AUTOEND then
Port.Periph.CR2.STOP := True;
end if;
end if;
while not Port.Periph.ISR.STOPF loop
if Timeout > 0
and then Start + Milliseconds (Timeout) < Clock
then
Port.State := Ready;
Status := Err_Timeout;
return;
end if;
end loop;
-- Clear the MACL amd STOP flags
Port.Periph.ICR.NACKCF := True;
Port.Periph.ICR.STOPCF := True;
-- Clear CR2
Reset_Config (Port);
Port.State := Ready;
Status := Err_Error;
else
Status := Ok;
end if;
end Check_Nack;
------------------------------
-- Wait_Tx_Interrupt_Status --
------------------------------
procedure Wait_Tx_Interrupt_Status
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status)
is
Start : constant Time := Clock;
begin
while not Port.Periph.ISR.TXIS loop
Check_Nack (Port, Timeout, Status);
if Status /= Ok then
Port.State := Ready;
Status := Err_Error;
return;
end if;
if Timeout > 0
and then Start + Milliseconds (Timeout) < Clock
then
Reset_Config (Port);
Port.State := Ready;
Status := Err_Timeout;
return;
end if;
end loop;
Status := Ok;
end Wait_Tx_Interrupt_Status;
---------------------------------------
-- Wait_Transfer_Complete_Reset_Flag --
---------------------------------------
procedure Wait_Transfer_Complete_Reset_Flag
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status)
is
Start : constant Time := Clock;
begin
while not Port.Periph.ISR.TCR loop
if Timeout > 0
and then Start + Milliseconds (Timeout) < Clock
then
Reset_Config (Port);
Status := Err_Timeout;
Port.State := Ready;
return;
end if;
end loop;
Status := Ok;
end Wait_Transfer_Complete_Reset_Flag;
--------------------
-- Wait_Stop_Flag --
--------------------
procedure Wait_Stop_Flag
(Port : in out I2C_Port;
Timeout : Natural;
Status : out I2C_Status)
is
Start : constant Time := Clock;
begin
while not Port.Periph.ISR.STOPF loop
Check_Nack (Port, Timeout, Status);
if Status /= Ok then
Port.State := Ready;
Status := Err_Error;
return;
end if;
if Timeout > 0
and then Start + Milliseconds (Timeout) < Clock
then
Reset_Config (Port);
Status := Err_Timeout;
Port.State := Ready;
return;
end if;
end loop;
-- Clear the stop flag
Port.Periph.ICR.STOPCF := True;
Status := Ok;
end Wait_Stop_Flag;
---------------------
-- Master_Transmit --
---------------------
overriding
procedure Master_Transmit
(Port : in out I2C_Port;
Addr : I2C_Address;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
Size_Temp : Natural := 0;
Transmitted : Natural := 0;
begin
if Port.Periph.ISR.BUSY then
Status := Busy;
return;
end if;
if Data'Length = 0 then
Status := Err_Error;
return;
end if;
if Port.State /= Ready then
Status := Busy;
return;
end if;
Port.State := Master_Busy_Tx;
-- Initiate the transfer
if Data'Length > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, Generate_Start_Write);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Data'Length, Autoend_Mode, Generate_Start_Write);
Size_Temp := Data'Length;
end if;
-- Transfer the data
while Transmitted <= Data'Length loop
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
Port.Periph.TXDR.TXDATA := Data (Data'First + Transmitted);
Transmitted := Transmitted + 1;
if Transmitted = Size_Temp
and then Transmitted < Data'Length
then
-- Wait for the Transfer complete reload flag
Wait_Transfer_Complete_Reset_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
if Data'Length - Transmitted > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, No_Start_Stop);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Byte (Data'Length - Transmitted), Autoend_Mode,
No_Start_Stop);
Size_Temp := Data'Length - Transmitted;
end if;
end if;
end loop;
Wait_Stop_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
-- Reset CR2
Reset_Config (Port);
Port.State := Ready;
Status := Ok;
end Master_Transmit;
--------------------
-- Master_Receive --
--------------------
overriding
procedure Master_Receive
(Port : in out I2C_Port;
Addr : I2C_Address;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
Size_Temp : Natural := 0;
Transmitted : Natural := 0;
begin
if Port.Periph.ISR.BUSY then
Status := Busy;
return;
end if;
if Port.State /= Ready then
Status := Busy;
return;
end if;
Port.State := Master_Busy_Rx;
if Data'Length = 0 then
Status := Err_Error;
return;
end if;
-- Initiate the transfer
if Data'Length > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, Generate_Start_Read);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Data'Length, Autoend_Mode, Generate_Start_Read);
Size_Temp := Data'Length;
end if;
-- Transfer the data
while Transmitted < Data'Length loop
while not Port.Periph.ISR.RXNE loop
null;
end loop;
Data (Data'First + Transmitted) := Port.Periph.RXDR.RXDATA;
Transmitted := Transmitted + 1;
Size_Temp := Size_Temp - 1;
if Size_Temp = 0
and then Transmitted < Data'Length
then
-- Wait for the Transfer complete reload flag
while Port.Periph.ISR.TCR loop
null;
end loop;
if Data'Length - Transmitted > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, No_Start_Stop);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Byte (Data'Length - Transmitted), Autoend_Mode,
No_Start_Stop);
Size_Temp := Data'Length - Transmitted;
end if;
end if;
end loop;
Wait_Stop_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
-- Reset CR2
Reset_Config (Port);
Port.State := Ready;
Status := Ok;
end Master_Receive;
---------------
-- Mem_Write --
---------------
overriding
procedure Mem_Write
(Port : in out I2C_Port;
Addr : I2C_Address;
Mem_Addr : Short;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
Size_Temp : Natural := 0;
Transmitted : Natural := 0;
begin
if Port.Periph.ISR.BUSY then
Status := Busy;
return;
end if;
if Data'Length = 0 then
Status := Err_Error;
return;
end if;
if Port.State /= Ready then
Status := Busy;
return;
end if;
Port.State := Mem_Busy_Tx;
-- Configure the memory transfer
Config_Transfer
(Port,
Addr,
(case Mem_Addr_Size is
when Memory_Size_8b => 1,
when Memory_Size_16b => 2),
Reload_Mode,
Generate_Start_Write);
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
Port.State := Ready;
return;
end if;
case Mem_Addr_Size is
when Memory_Size_8b =>
Port.Periph.TXDR.TXDATA := Byte (Mem_Addr);
when Memory_Size_16b =>
declare
MSB : constant Byte := Byte (Shift_Right (Mem_Addr, 8));
LSB : constant Byte := Byte (Mem_Addr and 16#FF#);
begin
Port.Periph.TXDR.TXDATA := MSB;
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
Port.Periph.TXDR.TXDATA := LSB;
end;
end case;
Wait_Transfer_Complete_Reset_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
-- Initiate the transfer
if Data'Length > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, No_Start_Stop);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Data'Length, Autoend_Mode, No_Start_Stop);
Size_Temp := Data'Length;
end if;
-- Transfer the data
while Transmitted < Data'Length loop
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
Port.Periph.TXDR.TXDATA := Data (Data'First + Transmitted);
Transmitted := Transmitted + 1;
if Transmitted = Size_Temp
and then Transmitted < Data'Length
then
-- Wait for the Transfer complete reload flag
Wait_Transfer_Complete_Reset_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
if Data'Length - Transmitted > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, No_Start_Stop);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr,
Byte (Data'Length - Transmitted),
Autoend_Mode,
No_Start_Stop);
Size_Temp := Data'Length - Transmitted;
end if;
end if;
end loop;
Wait_Stop_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
-- Reset CR2
Reset_Config (Port);
Port.State := Ready;
Status := Ok;
end Mem_Write;
--------------
-- Mem_Read --
--------------
overriding
procedure Mem_Read
(Port : in out I2C_Port;
Addr : I2C_Address;
Mem_Addr : Short;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
Size_Temp : Natural := 0;
Transmitted : Natural := 0;
begin
if Port.Periph.ISR.BUSY then
Status := Busy;
return;
end if;
if Data'Length = 0 then
Status := Err_Error;
return;
end if;
if Port.State /= Ready then
Status := Busy;
return;
end if;
Port.State := Mem_Busy_Rx;
-- Configure the memory transfer
Config_Transfer
(Port,
Addr,
(case Mem_Addr_Size is
when Memory_Size_8b => 1,
when Memory_Size_16b => 2),
Softend_Mode,
Generate_Start_Write);
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
case Mem_Addr_Size is
when Memory_Size_8b =>
Port.Periph.TXDR.TXDATA := Byte (Mem_Addr);
when Memory_Size_16b =>
declare
MSB : constant Byte := Byte (Shift_Right (Mem_Addr, 8));
LSB : constant Byte := Byte (Mem_Addr and 16#FF#);
begin
Port.Periph.TXDR.TXDATA := MSB;
Wait_Tx_Interrupt_Status (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
Port.Periph.TXDR.TXDATA := LSB;
end;
end case;
-- Wait for transfer complete
while not Port.Periph.ISR.TC loop
null;
end loop;
-- Initiate the transfer
if Data'Length > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, Generate_Start_Read);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr, Data'Length, Autoend_Mode, Generate_Start_Read);
Size_Temp := Data'Length;
end if;
-- Transfer the data
while Transmitted < Data'Length loop
while not Port.Periph.ISR.RXNE loop
null;
end loop;
Data (Data'First + Transmitted) := Port.Periph.RXDR.RXDATA;
Transmitted := Transmitted + 1;
Size_Temp := Size_Temp - 1;
if Size_Temp = 0
and then Transmitted < Data'Length
then
-- Wait for the Transfer complete reload flag
while not Port.Periph.ISR.TCR loop
null;
end loop;
if Data'Length - Transmitted > 255 then
Config_Transfer
(Port, Addr, 255, Reload_Mode, No_Start_Stop);
Size_Temp := 255;
else
Config_Transfer
(Port, Addr,
Byte (Data'Length - Transmitted),
Autoend_Mode,
No_Start_Stop);
Size_Temp := Data'Length - Transmitted;
end if;
end if;
end loop;
Wait_Stop_Flag (Port, Timeout, Status);
if Status /= Ok then
return;
end if;
-- Reset CR2
Reset_Config (Port);
Port.State := Ready;
Status := Ok;
end Mem_Read;
end STM32.I2C;
|
with Ada.Unchecked_Deallocation;
package body Google_Naive is
procedure Initialiser(Google: out T_Google) is
begin
for I in 0..Taille-1 loop
for J in 0..Taille-1 loop
Google.G(I,J) := 0.0;
end loop;
end loop;
end Initialiser;
procedure Creer(Google: in out T_Google; Liens: in LC_Integer_Integer.T_LC) is
L: array(0..Taille-1) of Integer;
procedure Incrementer(Gauche: Integer; Droit: Integer) is
begin
if Google.G(Gauche, Droit) = 0.0 then -- Verifier si il n'existe pas plusieurs liaisons identiques.
L(Gauche) := L(Gauche) + 1;
Google.G(Gauche, Droit) := 1.0;
end if;
end Incrementer;
procedure Calculer_Sortants is
new LC_Integer_Integer.Pour_Chaque(Incrementer);
procedure Populer(Gauche: Integer; Droit: Integer) is
begin
Google.G(Gauche, Droit) := 1.0/T_Precision(L(Gauche));
end Populer;
procedure Populer_Liste is
new LC_Integer_Integer.Pour_Chaque(Populer);
begin
for J in 0..Taille-1 loop
L(J) := 0;
end loop;
Calculer_Sortants(Liens);
Populer_Liste(Liens);
for I in 0..Taille-1 loop
for J in 0..Taille-1 loop
if L(I) = 0 then
Google.G(I,J) := 1.0/T_Precision(Taille);
end if;
Google.G(I,J) := Google.G(I,J)*Alpha + (1.0-Alpha)/T_Precision(Taille);
end loop;
end loop;
end Creer;
procedure Calculer_Rangs(Google: in T_Google; Rangs: out Vecteur_Poids.T_Vecteur) is
Poids: Vecteur_Precision.T_Vecteur;
Poids_Original: Vecteur_Precision.T_Vecteur;
Temp: T_Precision;
begin
Vecteur_Precision.Initialiser(Poids, Taille);
for I in 0..Taille-1 loop
Vecteur_Precision.Ajouter(Poids, 1.0/T_Precision(Taille));
end loop;
for tmp in 1..MaxIterations loop
Vecteur_Precision.Copier(Poids_Original, Poids);
for I in 0..Taille-1 loop
Temp := 0.0;
for J in 0..Taille-1 loop
Temp := Temp + Vecteur_Precision.Valeur(Poids_Original, J)*Google.G(J,I);
end loop;
Vecteur_Precision.Modifier(Poids, I, Temp);
end loop;
Vecteur_Precision.Vider(Poids_Original);
end loop;
Vecteur_Poids.Initialiser(Rangs, Taille);
for I in 0..Taille-1 loop
Vecteur_Poids.Ajouter(Rangs, (Rang => I, Poid => T_Digits(Vecteur_Precision.Valeur(Poids, I))));
end loop;
Vecteur_Precision.Vider(Poids);
end Calculer_Rangs;
end Google_Naive;
|
with Ayacc_File_Names, Text_IO, Source_File, Str_pack;
use Ayacc_File_Names, Text_IO;
package body Error_Report_File is
--
-- TITLE: package body Error_Report_File
-- Output the code which allows users to see what the error token was.
-- This is for non-correctable errors.
-- Also in this package: The declaration of user actions for correctable
-- (continuable) errors.
--
-- LANGUAGE:
-- Ada
--
-- PERSONNEL:
-- AUTHOR: Benjamin Hurwitz
-- DATE: Jul 27 1990
--
-- OVERVIEW:
-- Parse the last section of the .y file, looking for
-- %report_continuable_error and the related procedures. From these,
-- generate procedure bodies which will be called from yyparse when
-- there is an error which has been corrected. Since the errors get
-- corrected, yyerror does not get called.
--
max_line_length : constant integer := 370;
The_File : File_Type; -- Where the error report goes
Text : String(1..max_line_length); -- Current line from source file
Length : Natural := 1; -- and its length
-- types of lines found in the continuable error report section
type user_defined_thing is (with_thing,
use_thing,
init_thing,
report_thing,
finish_thing,
line_thing,
eof_thing);
--
-- TITLE:
-- Get Next Thing : Classify a line of text from the user defined error
-- report section of the .y file
--
-- OVERVIEW:
-- Read one line of the .y file, classifying it.
-- In the case of a %use or %with line, set the global variables Text and
-- Length to the tail of the line after the %use or %with.
-- ...................................................
procedure get_next_thing(thing : in out user_defined_thing) is
use str_pack;
with_string : constant string := "%WITH";
use_string : constant string := "%USE";
init_string : constant string := "%INITIALIZE_ERROR_REPORT";
finish_string: constant string:= "%TERMINATE_ERROR_REPORT";
report_string: constant string:= "%REPORT_ERROR";
temp : STR(max_line_length);
begin
if thing = eof_thing or else Source_File.is_end_of_file then
thing := eof_thing;
return;
end if;
Source_File.Read_Line(Text, Length);
if length >= use_string'length then
assign(text(1..use_string'length), temp);
if value_of(upper_case(temp)) = use_string then
thing := use_thing;
length := length - use_string'length;
text(1..length) := text((use_string'length + 1)..
length + use_string'length);
return;
end if;
end if;
if length >= with_string'length then
assign(text(1..with_string'length), temp);
if Value_of(upper_case(temp)) = with_string then
thing := with_thing;
length := length - with_string'length;
text(1..length) := text((with_string'length + 1)..
length + with_string'length);
return;
end if;
end if;
if length >= init_string'length then
assign(text(1..init_string'length), temp);
if Value_of(str_pack.upper_case(temp)) = init_string then
thing := init_thing;
return;
end if;
end if;
if length >= finish_string'length then
assign(text(1..finish_string'length), temp);
if value_of(str_pack.upper_case(temp)) = finish_string then
thing := finish_thing;
return;
end if;
end if;
if length >= report_string'length then
assign(text(1..report_string'length), temp);
if value_of(str_pack.upper_case(temp)) = report_string then
thing := report_thing;
return;
end if;
end if;
thing := line_thing;
end get_next_thing;
--
-- TITLE: procedure Write_Line
-- Write out a line to the Error Report generated ada file.
--
-- OVERVIEW:
--
-- ...................................................
procedure Write_Line(S: in String) is
begin
Put_Line(The_File, S);
end Write_Line;
--
-- TITLE:
-- Write the body of one of the user-defined procedures
--
-- OVERVIEW:
-- If User is True it means the user is defining the procedure body. So
-- copy it from the source file. Otherwise provide a null body.
-- ...................................................
procedure write_thing(user : in boolean;
thing : in out user_defined_thing) is
begin
if user then
loop
get_next_thing(thing);
exit when thing /= line_thing;
Write_Line(Text(1..length));
end loop;
else
Write_Line("begin");
Write_Line(" null;");
Write_Line("end;");
end if;
Write_Line("");
end write_thing;
--
-- TITLE:
-- Write the error report initialization function
--
-- OVERVIEW:
-- Write the header & then then body
-- ...................................................
procedure write_init(user : in boolean;
thing : in out user_defined_thing) is
begin
Write_Line("procedure Initialize_User_Error_Report is");
write_thing(user, thing);
end write_init;
--
-- TITLE:
-- Write the error report completion function
--
-- OVERVIEW:
-- Write the header & then then body
-- ...................................................
procedure write_finish(user : in boolean;
thing : in out user_defined_thing) is
begin
Write_Line("procedure Terminate_User_Error_Report is");
write_thing(user, thing);
end write_finish;
--
-- TITLE:
-- Write the error report function
--
-- OVERVIEW:
-- Write out the header with signature and then the body.
-- ...................................................
procedure write_report(user : in boolean;
thing : in out user_defined_thing) is
begin
Write_Line("procedure Report_Continuable_Error ");
Write_Line(" (Line_Number : in Natural;");
Write_Line(" Offset : in Natural;");
Write_Line(" Finish : in Natural;");
Write_Line(" Message : in String;");
Write_Line(" Error : in Boolean) is");
write_thing(user, thing);
end write_report;
--
-- TITLE: procedure Write_File
-- Create & open the Error_Report file, dump its contents.
--
-- PERSONNEL:
-- AUTHOR: Benjamin Hurwitz
-- DATE: Mar 11 1990
--
-- OVERVIEW:
-- The file being created will be used to report errors which yyparse
-- encounters. Some of them it can correct, and some it cannot.
-- There are different mechanisms for reporting each of these. There
-- is default reporting of corrected errors; messages are written
-- into the .lis file (Put, Put_Line). Also,
-- the user can define his/her own error reporting of correctable errors
-- in the last section of the .y file. If so, we here construct the
-- error report file so as to use these procedures.
-- Also in this package are variables and routines to
-- manipulate error information which the user can call from yyerror,
-- the procedure called when a non-correctable error is encountered.
-- The things generated which vary with runs of Ayacc is the names
-- of the Ada units, the packages With'ed and Used by the generated
-- error report package body and the bodies of the user-defined error report
-- routines for continuable errors.
--
-- NOTES:
-- This procedure is exported from the package.
--
-- SUBPROGRAM BODY:
--
procedure Write_File is
current_thing : user_defined_thing := line_thing;
wrote_init : boolean := false;
wrote_finish : boolean := false;
wrote_report : boolean := false;
begin
Create(The_File, Out_File, Get_Error_Report_File_Name);
Write_Line("package " & Error_Report_Unit_Name & " is");
Write_Line("");
Write_Line(" Syntax_Error : Exception;");
Write_Line(" Syntax_Warning : Exception;");
Write_Line(" Total_Errors : Natural := 0; -- number of syntax errors found." );
Write_Line(" Total_Warnings : Natural := 0; -- number of syntax warnings found." );
Write_Line(" ");
Write_Line(" procedure Report_Continuable_Error(Line_Number : in Natural;");
Write_Line(" Offset : in Natural;");
Write_Line(" Finish : in Natural;");
Write_Line(" Message : in String;");
Write_Line(" Error : in Boolean);");
Write_Line("");
Write_Line(" procedure Initialize_Output;");
Write_Line("");
Write_Line(" procedure Finish_Output;");
Write_Line("");
Write_Line(" procedure Put(S: in String);");
Write_Line("");
Write_Line(" procedure Put(C: in Character);");
Write_Line("");
Write_Line(" procedure Put_Line(S: in String);");
Write_Line("");
Write_Line("end " & Error_Report_Unit_Name & ";");
Write_Line("");
Write_Line("");
Write_Line("with Text_IO;");
-- Get %with's & %use's from source file
loop
get_next_thing(current_thing);
if current_thing = with_thing then
Write_Line("With " & text(1..length));
elsif current_thing = use_thing then
Write_Line("Use " & text(1..length));
elsif current_thing = line_thing then
null;
else
exit;
end if;
end loop;
Write_Line("");
Write_Line("package body " & Error_Report_Unit_Name & " is");
Write_Line("");
Write_Line(" The_File : Text_io.File_Type;");
Write_Line("");
-- Get user declarations of error reporting procedures from source file
while(current_thing /= eof_thing) loop
if current_thing = init_thing then
Write_init(true, current_thing);
wrote_init := true;
elsif current_thing = finish_thing then
Write_finish(true, current_thing);
wrote_finish := true;
elsif current_thing = report_thing then
Write_report(true, current_thing);
wrote_report := true;
else
get_next_thing(current_thing);
end if;
end loop;
if not wrote_init then
Write_init(false, current_thing);
end if;
if not wrote_finish then
Write_finish(false, current_thing);
end if;
if not wrote_report then
Write_report(false, current_thing);
end if;
Write_Line("");
Write_Line(" procedure Initialize_Output is");
Write_Line(" begin");
Write_Line(" Text_io.Create(The_File, Text_io.Out_File, " &
'"' & Get_Listing_File_Name & '"' & ");");
Write_Line(" initialize_user_error_report;");
Write_Line(" end Initialize_Output;");
Write_Line("");
Write_Line(" procedure Finish_Output is");
Write_Line(" begin");
Write_Line(" Text_io.Close(The_File);");
Write_Line(" terminate_user_error_report;");
Write_Line(" end Finish_Output;");
Write_Line("");
Write_Line(" procedure Put(S: in String) is");
Write_Line(" begin");
Write_Line(" Text_io.put(The_File, S);");
Write_Line(" end Put;");
Write_Line("");
Write_Line(" procedure Put(C: in Character) is");
Write_Line(" begin");
Write_Line(" Text_io.put(The_File, C);");
Write_Line(" end Put;");
Write_Line("");
Write_Line(" procedure Put_Line(S: in String) is");
Write_Line(" begin");
Write_Line(" Text_io.put_Line(The_File, S);");
Write_Line(" end Put_Line;");
Write_Line("");
Write_Line("");
Write_Line("end " & Error_Report_Unit_Name & ";");
Close(The_File);
end Write_File;
-- ...................................................
begin
null;
end Error_Report_File;
|
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
procedure Program is
type WorldData is array(0..499, 0..499) of Integer;
InputFile: file_type;
sline : unbounded_string;
fname : unbounded_string;
xp, yp : Integer;
size, expansion : Integer;
line : unbounded_string;
cost : Integer;
smallWorld : WorldData;
largeWorld : WorldData;
function FindPath (data : in WorldData; size : in Integer) return Integer is
world: array(0..249999) of Integer;
previous: array(0..249999) of Integer;
distances: array(0..249999) of Integer;
included: array(0..249999) of Boolean;
nodeCount, processed, minDistance, u, cost : Integer;
procedure FindDistance (v : in Integer) is
alt: Integer;
begin
if included(v) then
return;
end if;
alt := distances(u) + world (v);
if alt < distances(v) then
distances(v) := alt;
previous(v) := u;
end if;
end FindDistance;
begin
for x in 0 .. size - 1 loop
for y in 0 .. size - 1 loop
world( x + y * size ) := data(x, y);
end loop;
end loop;
nodeCount := size * size;
for i in 0 .. nodeCount - 1 loop
distances(i) := 999999;
previous(i) := -1;
included(i) := false;
end loop;
distances(0) := 0;
processed := 0;
while processed < nodeCount loop
minDistance := 999999;
u := -1;
-- this is horribly slow!
for i in 0 .. nodeCount - 1 loop
if not included(i) and minDistance > distances(i) then
minDistance := distances(i);
u := i;
end if;
end loop;
if u = nodeCount - 1 then
processed := nodeCount;
else
included(u) := true;
processed := processed + 1;
if u mod size > 0 then
FindDistance(u - 1);
end if;
if u mod size < size - 1 then
FindDistance(u + 1);
end if;
if u > size then
FindDistance(u - size);
end if;
if u < nodeCount - size then
FindDistance(u + size);
end if;
end if;
end loop;
u := nodeCount - 1;
cost := 0;
while u > 0 loop
cost := cost + world(u);
u := previous(u);
end loop;
return cost;
end FindPath;
begin
Open(File => InputFile, Mode => In_File, Name => "input.txt");
expansion := 5;
yp := 0;
while not End_Of_File (InputFile) loop
line := To_Unbounded_String(Get_Line(InputFile));
size := Length(line);
xp := 0;
for i in 1 .. size loop
smallWorld(xp, yp) := Integer'Value(To_String(line)(i..i));
xp := xp + 1;
end loop;
yp := yp + 1;
end loop;
Close(InputFile);
for yp in 0 .. size * expansion - 1 loop
for xp in 0 .. size * expansion - 1 loop
largeWorld(xp, yp) := ((smallWorld(xp mod size, yp mod size) + xp / size + yp / size + 8) mod 9) + 1;
end loop;
end loop;
cost := FindPath(smallWorld, size);
Put_Line("Part 1: " & Integer'Image(cost));
cost := FindPath(largeWorld, size * expansion);
Put_Line("Part 2: " & Integer'Image(cost));
end Program;
|
GENERIC
TYPE ValueType IS PRIVATE;
WITH FUNCTION "+"(L, R: ValueType) RETURN ValueType;
PACKAGE Matrices IS
TYPE Matrix IS ARRAY(Integer RANGE <>, Integer RANGE <>) OF ValueType;
FUNCTION "+" (K : IN ValueType; M : IN Matrix) RETURN Matrix;
end Matrices;
PACKAGE BODY Matrices IS
FUNCTION "+" (K : IN ValueType; M : IN Matrix) RETURN Matrix IS
BEGIN
RETURN M;
END "+";
END Matrices;
WITH Matrices;
PROCEDURE UseMatrices IS
PACKAGE Float_Matrices IS NEW Matrices(ValueType => Float, "+" => "+");
BEGIN
NULL;
END UseMatrices;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Glfw.API;
with Glfw.Enums;
package body Glfw.Windows.Context is
procedure Make_Current (Window : access Glfw.Windows.Window'Class) is
begin
if not Window.Initialized then
-- null is accepted to detach the current context, but an uninitialized
-- window *should* lead to an exception instead of detaching the
-- context, so we handle this here
raise Operation_Exception with "Window not initialized";
end if;
if Window = null then
API.Make_Context_Current (System.Null_Address);
else
API.Make_Context_Current (Window.Handle);
end if;
end Make_Current;
function Current return access Glfw.Windows.Window'Class is
use type System.Address;
Raw : constant System.Address := API.Get_Current_Context;
begin
if Raw = System.Null_Address then
return null;
else
return Window_Ptr (Raw);
end if;
end Current;
procedure Swap_Buffers (Window : not null access Glfw.Windows.Window'Class) is
begin
API.Swap_Buffers (Window.Handle);
end Swap_Buffers;
procedure Set_Swap_Interval (Value : Swap_Interval) renames
API.Swap_Interval;
function Client_API (Window : not null access Glfw.Windows.Window'Class)
return API_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.Client_API);
end Client_API;
function Profile (Window : not null access Glfw.Windows.Window'Class)
return OpenGL_Profile_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.OpenGL_Profile);
end Profile;
procedure Get_Context_Version
(Window : not null access Glfw.Windows.Window'Class;
Major : out Positive;
Minor, Revision : out Natural) is
begin
Major := Positive (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Major))));
Minor := Natural (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Minor))));
Revision := Natural (Interfaces.C.int'(
(API.Get_Window_Attrib (Window.Handle, Enums.Context_Revision))));
end Get_Context_Version;
function Is_Forward_Compat
(Window : not null access Glfw.Windows.Window'Class) return Boolean is
begin
return Boolean (Bool'(API.Get_Window_Attrib
(Window.Handle, Enums.OpenGL_Forward_Compat)));
end Is_Forward_Compat;
function Is_Debug_Context
(Window : not null access Glfw.Windows.Window'Class) return Boolean is
begin
return Boolean (Bool'(API.Get_Window_Attrib
(Window.Handle, Enums.OpenGL_Debug_Context)));
end Is_Debug_Context;
function Robustness (Window : not null access Glfw.Windows.Window'Class)
return Robustness_Kind is
begin
return API.Get_Window_Attrib (Window.Handle, Enums.Context_Robustness);
end Robustness;
end Glfw.Windows.Context;
|
-- Syntax Highlighting test file for Ada
-- Some Comments about this file
pragma Name (Parameter_List);
with Ada.Text_IO;
procedure Hello is
begin
Ada.Text_IO.Put_Line("Hello, world!");
Ada.Text_IO.Put_Line("Unclosed string);
end Hello;
My_Number := 1;
_Ilegal_Identifier := 'a';
|
-----------------------------------------------------------------------
-- akt-commands-edit -- Edit content in keystore
-- Copyright (C) 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.Directories;
with Ada.Environment_Variables;
with Ada.Command_Line;
with Interfaces.C.Strings;
with Util.Files;
with Util.Processes;
with Util.Systems.Os;
with Util.Systems.Types;
with Util.Streams.Raw;
with Keystore.Random;
package body AKT.Commands.Edit is
use GNAT.Strings;
procedure Export_Value (Context : in out Context_Type;
Name : in String;
Path : in String);
procedure Import_Value (Context : in out Context_Type;
Name : in String;
Path : in String);
procedure Make_Directory (Path : in String);
-- ------------------------------
-- Export the named value from the wallet to the external file.
-- The file is created and given read-write access to the current user only.
-- ------------------------------
procedure Export_Value (Context : in out Context_Type;
Name : in String;
Path : in String) is
use Util.Systems.Os;
use type Interfaces.C.int;
use type Util.Systems.Types.File_Type;
Fd : Util.Systems.Os.File_Type;
File : Util.Streams.Raw.Raw_Stream;
P : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (Path);
begin
Fd := Util.Systems.Os.Sys_Open (Path => P,
Flags => O_CREAT + O_WRONLY + O_TRUNC,
Mode => 8#600#);
Interfaces.C.Strings.Free (P);
if Fd < 0 then
AKT.Commands.Log.Error (-("Cannot create file for the editor"));
raise Error;
end if;
File.Initialize (Fd);
if Context.Wallet.Contains (Name) then
Context.Wallet.Get (Name, File);
end if;
end Export_Value;
procedure Import_Value (Context : in out Context_Type;
Name : in String;
Path : in String) is
use Util.Systems.Os;
use type Util.Systems.Types.File_Type;
Fd : Util.Systems.Os.File_Type;
File : Util.Streams.Raw.Raw_Stream;
P : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String (Path);
begin
Fd := Util.Systems.Os.Sys_Open (Path => P,
Flags => O_RDONLY,
Mode => 0);
Interfaces.C.Strings.Free (P);
if Fd < 0 then
AKT.Commands.Log.Error (-("Cannot read the editor's output"));
raise Error;
end if;
File.Initialize (Fd);
Context.Wallet.Set (Name, Keystore.T_STRING, File);
end Import_Value;
-- ------------------------------
-- Get the editor command to launch.
-- ------------------------------
function Get_Editor (Command : in Command_Type) return String is
begin
if Command.Editor /= null and then Command.Editor'Length > 0 then
return Command.Editor.all;
end if;
-- Use the $EDITOR if the environment variable defines it.
if Ada.Environment_Variables.Exists ("EDITOR") then
return Ada.Environment_Variables.Value ("EDITOR");
end if;
-- Use the editor which links to the default system-wide editor
-- that can be configured on Ubuntu through /etc/alternatives.
return "editor";
end Get_Editor;
-- ------------------------------
-- Get the directory where the editor's file can be created.
-- ------------------------------
function Get_Directory (Command : in Command_Type;
Context : in out Context_Type) return String is
pragma Unreferenced (Command, Context);
Rand : Keystore.Random.Generator;
Name : constant String := "akt-" & Rand.Generate (Bits => 32);
begin
return "/tmp/" & Name;
end Get_Directory;
procedure Make_Directory (Path : in String) is
P : Interfaces.C.Strings.chars_ptr;
Result : Integer;
begin
Ada.Directories.Create_Path (Path);
P := Interfaces.C.Strings.New_String (Path);
Result := Util.Systems.Os.Sys_Chmod (P, 8#0700#);
Interfaces.C.Strings.Free (P);
if Result /= 0 then
AKT.Commands.Log.Error (-("Cannot set the permission of {0}"), Path);
raise Error;
end if;
end Make_Directory;
-- ------------------------------
-- Edit a value from the keystore by using an external editor.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
begin
Context.Open_Keystore (Args);
if Args.Get_Count /= Context.First_Arg then
AKT.Commands.Usage (Args, Context, Name);
else
declare
Dir : constant String := Command.Get_Directory (Context);
Path : constant String := Util.Files.Compose (Dir, "VALUE.txt");
Editor : constant String := Command.Get_Editor;
Proc : Util.Processes.Process;
procedure Cleanup;
procedure Cleanup is
begin
if Ada.Directories.Exists (Path) then
Ada.Directories.Delete_File (Path);
end if;
if Ada.Directories.Exists (Dir) then
Ada.Directories.Delete_Tree (Dir);
end if;
end Cleanup;
begin
Make_Directory (Dir);
Export_Value (Context, Args.Get_Argument (Context.First_Arg), Path);
Util.Processes.Spawn (Proc, Editor & " " & Path);
Util.Processes.Wait (Proc);
if Util.Processes.Get_Exit_Status (Proc) /= 0 then
AKT.Commands.Log.Error (-("Editor exited with status{0}"),
Natural'Image (Util.Processes.Get_Exit_Status (Proc)));
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
else
Import_Value (Context, Args.Get_Argument (Context.First_Arg), Path);
end if;
Cleanup;
exception
when Util.Processes.Process_Error =>
AKT.Commands.Log.Error (-("Cannot execute editor '{0}'"), Editor);
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
Cleanup;
when others =>
Cleanup;
raise;
end;
end if;
end Execute;
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
package GC renames GNAT.Command_Line;
begin
Drivers.Command_Type (Command).Setup (Config, Context);
GC.Define_Switch (Config => Config,
Output => Command.Editor'Access,
Switch => "-e:",
Long_Switch => "--editor=",
Argument => "EDITOR",
Help => -("Define the editor command to use"));
end Setup;
end AKT.Commands.Edit;
|
--
-- 3.3.1 Object Declarations
--
-- object_declaration ::=
-- defining_identifier_list : [aliased] [constant] subtype_indication [:= expression];
-- | defining_identifier_list : [aliased] [constant] array_type_definition [:= expression];
-- | single_task_declaration
-- | single_protected_declaration
--
-- defining_identifier_list ::=
-- defining_identifier {, defining_identifier}
--
-- NOTE: This module is not compilation is used only for testing purposes
--
procedure Object_Declaration is
-- Example of a multiple object declaration:
-- the multiple object declaration
John, Paul : Person_Name := new Person(Sex => M); -- see 3.10.1
-- is equivalent to the two single object declarations in the order given
John2 : Person_Name := new Person(Sex => M);
Paul2 : Person_Name := new Person(Sex => M);
-- Examples of variable declarations:
Count, Sum : Integer;
Size : Integer range 0 .. 10_000 := 0;
Sorted : Boolean := False;
Color_Table : array(1 .. Max) of Color;
Option : Bit_Vector(1 .. 10) := (others => True);
Hello : constant String := "Hi, world.";
-- Examples of constant declarations:
Limit : constant Integer := 10_000;
Low_Limit : constant Integer := Limit/10;
Tolerance : constant Real := Dispersion(1.15);
begin
null;
end Object_Declaration; |
-- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2022 POK team
package body Compute is
procedure Printf (String : in Interfaces.C.char_array);
pragma Import (C, Printf, "printf");
procedure Compute is
begin
Printf ("beep ");
end Compute;
end Compute;
|
------------------------------------------------------------------------------
-- --
-- Copyright (c) 2016-2021 Vitalii Bondarenko <vibondare@gmail.com> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and/or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Characters.Handling; use Ada.Characters.Handling;
package body Formatted_Output.Decimal_Output is
package Item_Type_IO is new Ada.Text_IO.Decimal_IO (Item_Type);
use Item_Type_IO;
function Format
(Value : Item_Type;
Initial_Width : Integer;
Initial_Width_After : Integer;
Strip_Trailing_Zeroes : Boolean;
Leading_Zero : Boolean;
Width_Exp : Integer;
Justification : Alignment;
Force_Sign : Boolean;
Digit_Groups : Digit_Grouping) return String;
function Set_Float_Leading_Zero
(Text_Value : String;
Separator : String;
Dec_Point : String;
Group_Size : Integer) return String;
function Separate_Float_Digit_Groups
(Text_Value : String;
Separator : String;
Dec_Point : String;
Group_Size : Integer) return String;
----------------------------
-- Set_Float_Leading_Zero --
----------------------------
function Set_Float_Leading_Zero
(Text_Value : String;
Separator : String;
Dec_Point : String;
Group_Size : Integer) return String
is
DP : Natural := 0;
begin
DP := Index (Text_Value, Dec_Point, Text_Value'First);
if DP > 0 then
return
Set_Leading_Zero
(Text_Value (Text_Value'First .. DP - 1), Separator, Group_Size)
& Text_Value (DP .. Text_Value'Last);
else
return Set_Leading_Zero (Text_Value, Separator, Group_Size);
end if;
end Set_Float_Leading_Zero;
---------------------------------
-- Separate_Float_Digit_Groups --
---------------------------------
function Separate_Float_Digit_Groups
(Text_Value : String;
Separator : String;
Dec_Point : String;
Group_Size : Integer) return String
is
FD : Natural := Index_Non_Blank (Text_Value, Forward);
LD : Natural := Index_Non_Blank (Text_Value, Backward);
SP : Natural := 0;
DP : Natural := 0;
EP : Natural := 0;
EL : Natural := Index (Text_Value, "e", Text_Value'Last, Backward);
EU : Natural := Index (Text_Value, "E", Text_Value'Last, Backward);
Res : Unbounded_String := Null_Unbounded_String;
begin
if Separator'Length = 0 then
return Text_Value;
end if;
if Text_Value (FD) = '-' or else Text_Value (FD) = '+' then
SP := FD;
FD := FD + 1;
end if;
if SP > 0 then
Res := To_Unbounded_String (Text_Value (Text_Value'First .. SP));
else
Res := To_Unbounded_String (Text_Value (Text_Value'First .. FD - 1));
end if;
if EL > 0 then
EP := EL;
elsif EU > 0 then
EP := EU;
else
EP := LD;
end if;
DP := Index (Text_Value, Dec_Point, FD);
declare
E : String :=
(if EL + EU > 0 then Text_Value (EP .. LD) else "");
I : String :=
(if DP > 0 then Text_Value (FD .. DP - 1)
else Text_Value (FD .. EP));
F : String :=
(if DP > 0 then
(if EL + EU > 0 then Text_Value (DP + 1 .. EP - 1)
else Text_Value (DP + 1 .. EP))
else "");
FS : String :=
(if Separator /= Ada_Sep_Character then "" else Separator);
begin
Res := Res
& Separate_Digit_Groups (I, Separator, Group_Size)
& (if DP > 0 then
Dec_Point & Separate_Digit_Groups (F, FS, Group_Size)
else "")
& E;
end;
return To_String (Res);
end Separate_Float_Digit_Groups;
------------
-- Format --
------------
function Format
(Value : Item_Type;
Initial_Width : Integer;
Initial_Width_After : Integer;
Strip_Trailing_Zeroes : Boolean;
Leading_Zero : Boolean;
Width_Exp : Integer;
Justification : Alignment;
Force_Sign : Boolean;
Digit_Groups : Digit_Grouping) return String
is
Img : String (1 .. Maximal_Item_Length);
Width : Integer;
Width_After : Integer;
Real_Width : Integer;
Pre_First : Natural := Maximal_Item_Length;
Last : Natural := Maximal_Item_Length;
begin
if Initial_Width_After = 0 then
Width_After := Default_Aft;
else
Width_After := Initial_Width_After;
end if;
Put (Img, Value, Aft => Field (Width_After), Exp => Field (Width_Exp));
while Img (Pre_First) /= ' ' loop
Pre_First := Pre_First - 1;
end loop;
if Strip_Trailing_Zeroes then
while Img (Last) = '0' loop
Last := Last - 1;
end loop;
if Img (Last) = '.' then
Last := Last - 1;
end if;
end if;
if Value > 0.0 and then Force_Sign then
Img (Pre_First) := '+';
Pre_First := Pre_First - 1;
end if;
Real_Width := Last - Pre_First;
if Initial_Width < Real_Width then
Width := Real_Width;
else
Width := Initial_Width;
end if;
declare
S : String (1 .. Width);
V : String := Img (Pre_First + 1 .. Last);
T : Unbounded_String;
L : String :=
(if Digit_Groups = NLS_Grouping_Style then Thousands_Sep_Character
elsif Digit_Groups = Ada_Grouping_Style then Ada_Sep_Character
else "");
P : String :=
(if Digit_Groups = NLS_Grouping_Style then Decimal_Point_Character
else Ada_Dec_Point_Character);
G : Integer := 3;
-- (if Digit_Groups = NLS_Style or Base = 10 then 3 else 4);
begin
case Digit_Groups is
when None =>
T := To_Unbounded_String (V);
when Ada_Grouping_Style
| NLS_Grouping_Style =>
T := To_Unbounded_String
(Separate_Float_Digit_Groups (V, L, P, G));
end case;
if Length (T) > Width then
return To_String (T);
else
Move
(To_String (T),
S,
Justify => Justification,
Pad => Filler);
if Leading_Zero then
S := Set_Float_Leading_Zero (S, L, P, G);
end if;
return S;
end if;
end;
end Format;
---------
-- "&" --
---------
function "&" (Fmt : Format_Type; Value : Item_Type) return Format_Type is
Command_Start : constant Integer := Scan_To_Percent_Sign (Fmt);
Leading_Zero : Boolean := False;
After_Point : Boolean := False;
Width : Integer := 0;
Width_After : Integer := 0;
Digit_Occured : Boolean := False;
Justification_Changed : Boolean := False;
Justification : Alignment := Right;
Force_Sign : Boolean := False;
Digit_Groups : Digit_Grouping := None;
Fmt_Copy : Unbounded_String;
begin
if Command_Start /= 0 then
Fmt_Copy := Unbounded_String (Fmt);
for I in Command_Start + 1 .. Length (Fmt_Copy) loop
case Element (Fmt_Copy, I) is
when 'e' =>
Replace_Slice
(Fmt_Copy,
Command_Start,
I,
To_Lower
(Format
(Value, Width, Width_After, False, Leading_Zero,
Default_Exp, Justification, Force_Sign, Digit_Groups)));
return Format_Type (Fmt_Copy);
when 'E' =>
Replace_Slice
(Fmt_Copy, Command_Start, I,
Format
(Value, Width, Width_After, False, Leading_Zero,
Default_Exp, Justification, Force_Sign, Digit_Groups));
return Format_Type (Fmt_Copy);
when 'f' =>
Replace_Slice
(Fmt_Copy, Command_Start, I,
Format
(Value, Width, Width_After, False, Leading_Zero,
0, Justification, Force_Sign, Digit_Groups));
return Format_Type (Fmt_Copy);
when 'g' =>
Replace_Slice
(Fmt_Copy, Command_Start, I,
Format
(Value, Width, Width_After, True, Leading_Zero,
0, Justification, Force_Sign, Digit_Groups));
return Format_Type (Fmt_Copy);
when '_' =>
Digit_Groups := Ada_Grouping_Style;
when ''' =>
Digit_Groups := NLS_Grouping_Style;
when '+' =>
Force_Sign := True;
when '-' | '*' =>
if Justification_Changed or else Digit_Occured then
raise Format_Error;
end if;
Justification_Changed := True;
case Element (Fmt_Copy, I) is
when '-' =>
Justification := Left;
when '*' =>
Justification := Center;
when others =>
null;
end case;
when '.' =>
Digit_Occured := True;
if After_Point then
raise Format_Error;
else
After_Point := True;
end if;
when '0' .. '9' =>
Digit_Occured := True;
if After_Point then
Width_After := Width_After * 10
+ Character'Pos (Element (Fmt_Copy, I))
- Character'Pos ('0');
else
if Width = 0 and then Element (Fmt_Copy, I) = '0' then
Leading_Zero := True;
else
Width := Width * 10
+ Character'Pos (Element (Fmt_Copy, I))
- Character'Pos ('0');
end if;
end if;
when others =>
raise Format_Error;
end case;
end loop;
end if;
raise Format_Error;
end "&";
end Formatted_Output.Decimal_Output;
|
-----------------------------------------------------------------------
-- awa-workspaces-tests -- Unit tests for workspaces and invitations
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with ASF.Requests.Mockup;
with ASF.Responses.Mockup;
with ASF.Helpers.Beans;
with ASF.Tests;
with AWA.Users.Models;
with AWA.Tests.Helpers.Users;
with AWA.Workspaces.Beans;
package body AWA.Workspaces.Tests is
use Ada.Strings.Unbounded;
use AWA.Tests;
function Get_Invitation_Bean is
new ASF.Helpers.Beans.Get_Request_Bean (Element_Type => Beans.Invitation_Bean,
Element_Access => Beans.Invitation_Bean_Access);
package Caller is new Util.Test_Caller (Test, "Workspaces.Beans");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Workspaces.Beans.Send",
Test_Invite_User'Access);
Caller.Add_Test (Suite, "Test AWA.Workspaces.Beans.Delete",
Test_Delete_Member'Access);
Caller.Add_Test (Suite, "Test AWA.Workspaces.Beans.Accept",
Test_Accept_Invitation'Access);
Caller.Add_Test (Suite, "Test AWA.Workspaces.Beans.Member_List",
Test_List_Members'Access);
end Add_Tests;
-- ------------------------------
-- Verify the anonymous access for the invitation page.
-- ------------------------------
procedure Verify_Anonymous (T : in out Test;
Key : in String) is
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
ASF.Tests.Do_Get (Request, Reply, "/auth/invitation.html", "invitation-view.html");
ASF.Tests.Assert_Contains (T, "Bad or invalid invitation", Reply,
"This invitation is invalid");
ASF.Tests.Do_Get (Request, Reply, "/auth/invitation.html?key=test", "invitation-bad.html");
ASF.Tests.Assert_Contains (T, "This invitation is invalid or has expired", Reply,
"This invitation is invalid (key)");
ASF.Tests.Do_Get (Request, Reply, "/auth/invitation.html?key=x" & key,
"invitation-bad2.html");
ASF.Tests.Assert_Contains (T, "This invitation is invalid or has expired",
Reply, "This invitation is invalid (key)");
if Key = "" then
return;
end if;
ASF.Tests.Do_Get (Request, Reply, "/auth/invitation.html?key=" & Key, "invitation-ok.html");
ASF.Tests.Assert_Contains (T, "Accept invitation", Reply,
"Accept invitation page is invalid");
end Verify_Anonymous;
-- ------------------------------
-- Test sending an invitation.
-- ------------------------------
procedure Test_Invite_User (T : in out Test) is
use type ADO.Identifier;
use type AWA.Workspaces.Beans.Invitation_Bean_Access;
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
Invite : AWA.Workspaces.Beans.Invitation_Bean_Access;
begin
AWA.Tests.Helpers.Users.Login ("test-invite@test.com", Request);
Request.Set_Parameter ("email", "invited-user@test.com");
Request.Set_Parameter ("message", "I invite you to this application");
Request.Set_Parameter ("send", "1");
Request.Set_Parameter ("invite", "1");
ASF.Tests.Do_Post (Request, Reply, "/workspaces/invite.html", "invite.html");
T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY,
"Invalid response after invitation creation");
-- Verify the invitation by looking at the inviteUser bean.
Invite := Get_Invitation_Bean (Request, "inviteUser");
T.Assert (Invite /= null, "Null inviteUser bean");
T.Assert (Invite.Get_Id /= ADO.NO_IDENTIFIER, "The invite ID is invalid");
T.Assert (not Invite.Get_Access_Key.Is_Null, "The invite access key is null");
T.Assert (Invite.Get_Member.Is_Inserted, "The invitation has a workspace member");
T.Key := Invite.Get_Access_Key.Get_Access_Key;
T.Verify_Anonymous (Invite.Get_Access_Key.Get_Access_Key);
T.Member_ID := Invite.Get_Member.Get_Id;
end Test_Invite_User;
-- ------------------------------
-- Test deleting the member.
-- ------------------------------
procedure Test_Delete_Member (T : in out Test) is
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
T.Test_Invite_User;
AWA.Tests.Helpers.Users.Login ("test-invite@test.com", Request);
declare
Id : constant String := ADO.Identifier'Image (T.Member_Id);
begin
Request.Set_Parameter ("member-id", Id);
Request.Set_Parameter ("delete", "1");
Request.Set_Parameter ("delete-member-form", "1");
ASF.Tests.Do_Post (Request, Reply, "/workspaces/forms/delete-member.html",
"delete-member.html");
T.Assert (Reply.Get_Status = ASF.Responses.SC_OK,
"Invalid response after delete member operation");
ASF.Tests.Assert_Contains (T, "deleteDialog_" & Id (Id'First + 1 .. Id'Last), Reply,
"Delete member dialog operation response is invalid");
end;
end Test_Delete_Member;
-- ------------------------------
-- Test accepting the invitation.
-- ------------------------------
procedure Test_Accept_Invitation (T : in out Test) is
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
T.Test_Invite_User;
AWA.Tests.Helpers.Users.Recover_Password ("invited-user@test.com");
AWA.Tests.Helpers.Users.Login ("invited-user@test.com", Request);
ASF.Tests.Do_Get (Request, Reply, "/workspaces/accept-invitation.html?key="
& To_String (T.Key),
"accept-member.html");
T.Assert (Reply.Get_Status = ASF.Responses.SC_MOVED_TEMPORARILY,
"Accept invitation page failed");
Util.Tests.Assert_Equals (T, "/asfunit/workspaces/main.html", Reply.Get_Header ("Location"),
"The accept invitation page must redirect to the workspace");
end Test_Accept_Invitation;
-- ------------------------------
-- Test listing the members of the workspace.
-- ------------------------------
procedure Test_List_Members (T : in out Test) is
Request : ASF.Requests.Mockup.Request;
Reply : ASF.Responses.Mockup.Response;
begin
T.Test_Invite_User;
AWA.Tests.Helpers.Users.Login ("test-invite@test.com", Request);
ASF.Tests.Do_Get (Request, Reply, "/workspaces/members.html",
"member-list.html");
ASF.Tests.Assert_Contains (T, "invited-user@test.com", Reply,
"The invited user is listed in the members page");
ASF.Tests.Assert_Contains (T, "test-invite@test.com", Reply,
"The invite user (owner) is listed in the members page");
end Test_List_Members;
end AWA.Workspaces.Tests;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32H743x.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package STM32_SVD.SDMMC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype POWER_PWRCTRL_Field is HAL.UInt2;
-- SDMMC power control register
type POWER_Register is record
-- SDMMC state control bits. These bits can only be written when the
-- SDMMC is not in the power-on state (PWRCTRL?11). These bits are used
-- to define the functional state of the SDMMC signals: Any further
-- write will be ignored, PWRCTRL value will keep 11.
PWRCTRL : POWER_PWRCTRL_Field := 16#0#;
-- Voltage switch sequence start. This bit is used to start the timing
-- critical section of the voltage switch sequence:
VSWITCH : Boolean := False;
-- Voltage switch procedure enable. This bit can only be written by
-- firmware when CPSM is disabled (CPSMEN = 0). This bit is used to stop
-- the SDMMC_CK after the voltage switch command response:
VSWITCHEN : Boolean := False;
-- Data and command direction signals polarity selection. This bit can
-- only be written when the SDMMC is in the power-off state (PWRCTRL =
-- 00).
DIRPOL : Boolean := False;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
PWRCTRL at 0 range 0 .. 1;
VSWITCH at 0 range 2 .. 2;
VSWITCHEN at 0 range 3 .. 3;
DIRPOL at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype CLKCR_CLKDIV_Field is HAL.UInt10;
subtype CLKCR_WIDBUS_Field is HAL.UInt2;
subtype CLKCR_SELCLKRX_Field is HAL.UInt2;
-- The SDMMC_CLKCR register controls the SDMMC_CK output clock, the
-- SDMMC_RX_CLK receive clock, and the bus width.
type CLKCR_Register is record
-- Clock divide factor This bit can only be written when the CPSM and
-- DPSM are not active (CPSMACT = 0 and DPSMACT = 0). This field defines
-- the divide factor between the input clock (SDMMCCLK) and the output
-- clock (SDMMC_CK): SDMMC_CK frequency = SDMMCCLK / [2 * CLKDIV]. 0xx:
-- etc.. xxx: etc..
CLKDIV : CLKCR_CLKDIV_Field := 16#0#;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- Power saving configuration bit This bit can only be written when the
-- CPSM and DPSM are not active (CPSMACT = 0 and DPSMACT = 0) For power
-- saving, the SDMMC_CK clock output can be disabled when the bus is
-- idle by setting PWRSAV:
PWRSAV : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Wide bus mode enable bit This bit can only be written when the CPSM
-- and DPSM are not active (CPSMACT = 0 and DPSMACT = 0)
WIDBUS : CLKCR_WIDBUS_Field := 16#0#;
-- SDMMC_CK dephasing selection bit for data and Command. This bit can
-- only be written when the CPSM and DPSM are not active (CPSMACT = 0
-- and DPSMACT = 0). When clock division = 1 (CLKDIV = 0), this bit has
-- no effect. Data and Command change on SDMMC_CK falling edge. When
-- clock division >1 (CLKDIV > 0) & DDR = 0: - SDMMC_CK edge
-- occurs on SDMMCCLK rising edge. When clock division >1 (CLKDIV > 0) &
-- DDR = 1: - Data changed on the SDMMCCLK falling edge succeeding a
-- SDMMC_CK edge. - SDMMC_CK edge occurs on SDMMCCLK rising edge. - Data
-- changed on the SDMMC_CK falling edge succeeding a SDMMC_CK edge. -
-- SDMMC_CK edge occurs on SDMMCCLK rising edge.
NEGEDGE : Boolean := False;
-- Hardware flow control enable This bit can only be written when the
-- CPSM and DPSM are not active (CPSMACT = 0 and DPSMACT = 0) When
-- Hardware flow control is enabled, the meaning of the TXFIFOE and
-- RXFIFOF flags change, please see SDMMC status register definition in
-- Section56.8.11.
HWFC_EN : Boolean := False;
-- Data rate signaling selection This bit can only be written when the
-- CPSM and DPSM are not active (CPSMACT = 0 and DPSMACT = 0) DDR rate
-- shall only be selected with 4-bit or 8-bit wide bus mode. (WIDBUS
-- > 00). DDR = 1 has no effect when WIDBUS = 00 (1-bit wide bus).
-- DDR rate shall only be selected with clock division >1. (CLKDIV
-- > 0)
DDR : Boolean := False;
-- Bus speed mode selection between DS, HS, SDR12, SDR25 and SDR50,
-- DDR50, SDR104. This bit can only be written when the CPSM and DPSM
-- are not active (CPSMACT = 0 and DPSMACT = 0)
BUSSPEED : Boolean := False;
-- Receive clock selection. These bits can only be written when the CPSM
-- and DPSM are not active (CPSMACT = 0 and DPSMACT = 0)
SELCLKRX : CLKCR_SELCLKRX_Field := 16#0#;
-- unspecified
Reserved_22_31 : HAL.UInt10 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CLKCR_Register use record
CLKDIV at 0 range 0 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
PWRSAV at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
WIDBUS at 0 range 14 .. 15;
NEGEDGE at 0 range 16 .. 16;
HWFC_EN at 0 range 17 .. 17;
DDR at 0 range 18 .. 18;
BUSSPEED at 0 range 19 .. 19;
SELCLKRX at 0 range 20 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype CMDR_CMDINDEX_Field is HAL.UInt6;
subtype CMDR_WAITRESP_Field is HAL.UInt2;
-- The SDMMC_CMDR register contains the command index and command type
-- bits. The command index is sent to a card as part of a command message.
-- The command type bits control the command path state machine (CPSM).
type CMDR_Register is record
-- Command index. This bit can only be written by firmware when CPSM is
-- disabled (CPSMEN = 0). The command index is sent to the card as part
-- of a command message.
CMDINDEX : CMDR_CMDINDEX_Field := 16#0#;
-- The CPSM treats the command as a data transfer command, stops the
-- interrupt period, and signals DataEnable to the DPSM This bit can
-- only be written by firmware when CPSM is disabled (CPSMEN = 0). If
-- this bit is set, the CPSM issues an end of interrupt period and
-- issues DataEnable signal to the DPSM when the command is sent.
CMDTRANS : Boolean := False;
-- The CPSM treats the command as a Stop Transmission command and
-- signals Abort to the DPSM. This bit can only be written by firmware
-- when CPSM is disabled (CPSMEN = 0). If this bit is set, the CPSM
-- issues the Abort signal to the DPSM when the command is sent.
CMDSTOP : Boolean := False;
-- Wait for response bits. This bit can only be written by firmware when
-- CPSM is disabled (CPSMEN = 0). They are used to configure whether the
-- CPSM is to wait for a response, and if yes, which kind of response.
WAITRESP : CMDR_WAITRESP_Field := 16#0#;
-- CPSM waits for interrupt request. If this bit is set, the CPSM
-- disables command timeout and waits for an card interrupt request
-- (Response). If this bit is cleared in the CPSM Wait state, will cause
-- the abort of the interrupt mode.
WAITINT : Boolean := False;
-- CPSM Waits for end of data transfer (CmdPend internal signal) from
-- DPSM. This bit when set, the CPSM waits for the end of data transfer
-- trigger before it starts sending a command. WAITPEND is only taken
-- into account when DTMODE = MMC stream data transfer, WIDBUS = 1-bit
-- wide bus mode, DPSMACT = 1 and DTDIR = from host to card.
WAITPEND : Boolean := False;
-- Command path state machine (CPSM) Enable bit This bit is written 1 by
-- firmware, and cleared by hardware when the CPSM enters the Idle
-- state. If this bit is set, the CPSM is enabled. When DTEN = 1, no
-- command will be transfered nor boot procedure will be started. CPSMEN
-- is cleared to 0.
CPSMEN : Boolean := False;
-- Hold new data block transmission and reception in the DPSM. If this
-- bit is set, the DPSM will not move from the Wait_S state to the Send
-- state or from the Wait_R state to the Receive state.
DTHOLD : Boolean := False;
-- Select the boot mode procedure to be used. This bit can only be
-- written by firmware when CPSM is disabled (CPSMEN = 0)
BOOTMODE : Boolean := False;
-- Enable boot mode procedure.
BOOTEN : Boolean := False;
-- The CPSM treats the command as a Suspend or Resume command and
-- signals interrupt period start/end. This bit can only be written by
-- firmware when CPSM is disabled (CPSMEN = 0). CMDSUSPEND = 1 and
-- CMDTRANS = 0 Suspend command, start interrupt period when response
-- bit BS=0. CMDSUSPEND = 1 and CMDTRANS = 1 Resume command with data,
-- end interrupt period when response bit DF=1.
CMDSUSPEND : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CMDR_Register use record
CMDINDEX at 0 range 0 .. 5;
CMDTRANS at 0 range 6 .. 6;
CMDSTOP at 0 range 7 .. 7;
WAITRESP at 0 range 8 .. 9;
WAITINT at 0 range 10 .. 10;
WAITPEND at 0 range 11 .. 11;
CPSMEN at 0 range 12 .. 12;
DTHOLD at 0 range 13 .. 13;
BOOTMODE at 0 range 14 .. 14;
BOOTEN at 0 range 15 .. 15;
CMDSUSPEND at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype RESPCMDR_RESPCMD_Field is HAL.UInt6;
-- SDMMC command response register
type RESPCMDR_Register is record
-- Read-only. Response command index
RESPCMD : RESPCMDR_RESPCMD_Field;
-- unspecified
Reserved_6_31 : HAL.UInt26;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RESPCMDR_Register use record
RESPCMD at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
subtype DLENR_DATALENGTH_Field is HAL.UInt25;
-- The SDMMC_DLENR register contains the number of data bytes to be
-- transferred. The value is loaded into the data counter when data
-- transfer starts.
type DLENR_Register is record
-- Data length value This register can only be written by firmware when
-- DPSM is inactive (DPSMACT = 0). Number of data bytes to be
-- transferred. When DDR = 1 DATALENGTH is truncated to a multiple of 2.
-- (The last odd byte is not transfered) When DATALENGTH = 0 no data
-- will be transfered, when requested by a CPSMEN and CMDTRANS = 1 also
-- no command will be transfered. DTEN and CPSMEN are cleared to 0.
DATALENGTH : DLENR_DATALENGTH_Field := 16#0#;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DLENR_Register use record
DATALENGTH at 0 range 0 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype DCTRL_DTMODE_Field is HAL.UInt2;
subtype DCTRL_DBLOCKSIZE_Field is HAL.UInt4;
-- The SDMMC_DCTRL register control the data path state machine (DPSM).
type DCTRL_Register is record
-- Data transfer enable bit This bit can only be written by firmware
-- when DPSM is inactive (DPSMACT = 0). This bit is cleared by Hardware
-- when data transfer completes. This bit shall only be used to transfer
-- data when no associated data transfer command is used, i.e. shall not
-- be used with SD or eMMC cards.
DTEN : Boolean := False;
-- Data transfer direction selection This bit can only be written by
-- firmware when DPSM is inactive (DPSMACT = 0).
DTDIR : Boolean := False;
-- Data transfer mode selection. This bit can only be written by
-- firmware when DPSM is inactive (DPSMACT = 0).
DTMODE : DCTRL_DTMODE_Field := 16#0#;
-- Data block size This bit can only be written by firmware when DPSM is
-- inactive (DPSMACT = 0). Define the data block length when the block
-- data transfer mode is selected: When DATALENGTH is not a multiple of
-- DBLOCKSIZE, the transfered data is truncated at a multiple of
-- DBLOCKSIZE. (Any remain data will not be transfered.) When DDR = 1,
-- DBLOCKSIZE = 0000 shall not be used. (No data will be transfered)
DBLOCKSIZE : DCTRL_DBLOCKSIZE_Field := 16#0#;
-- Read wait start. If this bit is set, read wait operation starts.
RWSTART : Boolean := False;
-- Read wait stop This bit is written by firmware and auto cleared by
-- hardware when the DPSM moves from the READ_WAIT state to the WAIT_R
-- or IDLE state.
RWSTOP : Boolean := False;
-- Read wait mode. This bit can only be written by firmware when DPSM is
-- inactive (DPSMACT = 0).
RWMOD : Boolean := False;
-- SD I/O interrupt enable functions This bit can only be written by
-- firmware when DPSM is inactive (DPSMACT = 0). If this bit is set, the
-- DPSM enables the SD I/O card specific interrupt operation.
SDIOEN : Boolean := False;
-- Enable the reception of the boot acknowledgment. This bit can only be
-- written by firmware when DPSM is inactive (DPSMACT = 0).
BOOTACKEN : Boolean := False;
-- FIFO reset, will flush any remaining data. This bit can only be
-- written by firmware when IDMAEN= 0 and DPSM is active (DPSMACT = 1).
-- This bit will only take effect when a transfer error or transfer hold
-- occurs.
FIFORST : Boolean := False;
-- unspecified
Reserved_14_31 : HAL.UInt18 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DCTRL_Register use record
DTEN at 0 range 0 .. 0;
DTDIR at 0 range 1 .. 1;
DTMODE at 0 range 2 .. 3;
DBLOCKSIZE at 0 range 4 .. 7;
RWSTART at 0 range 8 .. 8;
RWSTOP at 0 range 9 .. 9;
RWMOD at 0 range 10 .. 10;
SDIOEN at 0 range 11 .. 11;
BOOTACKEN at 0 range 12 .. 12;
FIFORST at 0 range 13 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
subtype DCNTR_DATACOUNT_Field is HAL.UInt25;
-- The SDMMC_DCNTR register loads the value from the data length register
-- (see SDMMC_DLENR) when the DPSM moves from the Idle state to the Wait_R
-- or Wait_S state. As data is transferred, the counter decrements the
-- value until it reaches 0. The DPSM then moves to the Idle state and when
-- there has been no error, the data status end flag (DATAEND) is set.
type DCNTR_Register is record
-- Read-only. Data count value When read, the number of remaining data
-- bytes to be transferred is returned. Write has no effect.
DATACOUNT : DCNTR_DATACOUNT_Field;
-- unspecified
Reserved_25_31 : HAL.UInt7;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DCNTR_Register use record
DATACOUNT at 0 range 0 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- The SDMMC_STAR register is a read-only register. It contains two types
-- of flag:Static flags (bits [29,21,11:0]): these bits remain asserted
-- until they are cleared by writing to the SDMMC interrupt Clear register
-- (see SDMMC_ICR)Dynamic flags (bits [20:12]): these bits change state
-- depending on the state of the underlying logic (for example, FIFO full
-- and empty flags are asserted and de-asserted as data while written to
-- the FIFO)
type STAR_Register is record
-- Read-only. Command response received (CRC check failed). Interrupt
-- flag is cleared by writing corresponding interrupt clear bit in
-- SDMMC_ICR.
CCRCFAIL : Boolean;
-- Read-only. Data block sent/received (CRC check failed). Interrupt
-- flag is cleared by writing corresponding interrupt clear bit in
-- SDMMC_ICR.
DCRCFAIL : Boolean;
-- Read-only. Command response timeout. Interrupt flag is cleared by
-- writing corresponding interrupt clear bit in SDMMC_ICR. The Command
-- Timeout period has a fixed value of 64 SDMMC_CK clock periods.
CTIMEOUT : Boolean;
-- Read-only. Data timeout. Interrupt flag is cleared by writing
-- corresponding interrupt clear bit in SDMMC_ICR.
DTIMEOUT : Boolean;
-- Read-only. Transmit FIFO underrun error or IDMA read transfer error.
-- Interrupt flag is cleared by writing corresponding interrupt clear
-- bit in SDMMC_ICR.
TXUNDERR : Boolean;
-- Read-only. Received FIFO overrun error or IDMA write transfer error.
-- Interrupt flag is cleared by writing corresponding interrupt clear
-- bit in SDMMC_ICR.
RXOVERR : Boolean;
-- Read-only. Command response received (CRC check passed, or no CRC).
-- Interrupt flag is cleared by writing corresponding interrupt clear
-- bit in SDMMC_ICR.
CMDREND : Boolean;
-- Read-only. Command sent (no response required). Interrupt flag is
-- cleared by writing corresponding interrupt clear bit in SDMMC_ICR.
CMDSENT : Boolean;
-- Read-only. Data transfer ended correctly. (data counter, DATACOUNT is
-- zero and no errors occur). Interrupt flag is cleared by writing
-- corresponding interrupt clear bit in SDMMC_ICR.
DATAEND : Boolean;
-- Read-only. Data transfer Hold. Interrupt flag is cleared by writing
-- corresponding interrupt clear bit in SDMMC_ICR.
DHOLD : Boolean;
-- Read-only. Data block sent/received. (CRC check passed) and DPSM
-- moves to the READWAIT state. Interrupt flag is cleared by writing
-- corresponding interrupt clear bit in SDMMC_ICR.
DBCKEND : Boolean;
-- Read-only. Data transfer aborted by CMD12. Interrupt flag is cleared
-- by writing corresponding interrupt clear bit in SDMMC_ICR.
DABORT : Boolean;
-- Read-only. Data path state machine active, i.e. not in Idle state.
-- This is a hardware status flag only, does not generate an interrupt.
DPSMACT : Boolean;
-- Read-only. Command path state machine active, i.e. not in Idle state.
-- This is a hardware status flag only, does not generate an interrupt.
CPSMACT : Boolean;
-- Read-only. Transmit FIFO half empty At least half the number of words
-- can be written into the FIFO. This bit is cleared when the FIFO
-- becomes half+1 full.
TXFIFOHE : Boolean;
-- Read-only. Receive FIFO half full There are at least half the number
-- of words in the FIFO. This bit is cleared when the FIFO becomes
-- half+1 empty.
RXFIFOHF : Boolean;
-- Read-only. Transmit FIFO full This is a hardware status flag only,
-- does not generate an interrupt. This bit is cleared when one FIFO
-- location becomes empty.
TXFIFOF : Boolean;
-- Read-only. Receive FIFO full This bit is cleared when one FIFO
-- location becomes empty.
RXFIFOF : Boolean;
-- Read-only. Transmit FIFO empty This bit is cleared when one FIFO
-- location becomes full.
TXFIFOE : Boolean;
-- Read-only. Receive FIFO empty This is a hardware status flag only,
-- does not generate an interrupt. This bit is cleared when one FIFO
-- location becomes full.
RXFIFOE : Boolean;
-- Read-only. Inverted value of SDMMC_D0 line (Busy), sampled at the end
-- of a CMD response and a second time 2 SDMMC_CK cycles after the CMD
-- response. This bit is reset to not busy when the SDMMCD0 line changes
-- from busy to not busy. This bit does not signal busy due to data
-- transfer. This is a hardware status flag only, it does not generate
-- an interrupt.
BUSYD0 : Boolean;
-- Read-only. end of SDMMC_D0 Busy following a CMD response detected.
-- This indicates only end of busy following a CMD response. This bit
-- does not signal busy due to data transfer. Interrupt flag is cleared
-- by writing corresponding interrupt clear bit in SDMMC_ICR.
BUSYD0END : Boolean;
-- Read-only. SDIO interrupt received. Interrupt flag is cleared by
-- writing corresponding interrupt clear bit in SDMMC_ICR.
SDIOIT : Boolean;
-- Read-only. Boot acknowledgment received (boot acknowledgment check
-- fail). Interrupt flag is cleared by writing corresponding interrupt
-- clear bit in SDMMC_ICR.
ACKFAIL : Boolean;
-- Read-only. Boot acknowledgment timeout. Interrupt flag is cleared by
-- writing corresponding interrupt clear bit in SDMMC_ICR.
ACKTIMEOUT : Boolean;
-- Read-only. Voltage switch critical timing section completion.
-- Interrupt flag is cleared by writing corresponding interrupt clear
-- bit in SDMMC_ICR.
VSWEND : Boolean;
-- Read-only. SDMMC_CK stopped in Voltage switch procedure. Interrupt
-- flag is cleared by writing corresponding interrupt clear bit in
-- SDMMC_ICR.
CKSTOP : Boolean;
-- Read-only. IDMA transfer error. Interrupt flag is cleared by writing
-- corresponding interrupt clear bit in SDMMC_ICR.
IDMATE : Boolean;
-- Read-only. IDMA buffer transfer complete. interrupt flag is cleared
-- by writing corresponding interrupt clear bit in SDMMC_ICR.
IDMABTC : Boolean;
-- unspecified
Reserved_29_31 : HAL.UInt3;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for STAR_Register use record
CCRCFAIL at 0 range 0 .. 0;
DCRCFAIL at 0 range 1 .. 1;
CTIMEOUT at 0 range 2 .. 2;
DTIMEOUT at 0 range 3 .. 3;
TXUNDERR at 0 range 4 .. 4;
RXOVERR at 0 range 5 .. 5;
CMDREND at 0 range 6 .. 6;
CMDSENT at 0 range 7 .. 7;
DATAEND at 0 range 8 .. 8;
DHOLD at 0 range 9 .. 9;
DBCKEND at 0 range 10 .. 10;
DABORT at 0 range 11 .. 11;
DPSMACT at 0 range 12 .. 12;
CPSMACT at 0 range 13 .. 13;
TXFIFOHE at 0 range 14 .. 14;
RXFIFOHF at 0 range 15 .. 15;
TXFIFOF at 0 range 16 .. 16;
RXFIFOF at 0 range 17 .. 17;
TXFIFOE at 0 range 18 .. 18;
RXFIFOE at 0 range 19 .. 19;
BUSYD0 at 0 range 20 .. 20;
BUSYD0END at 0 range 21 .. 21;
SDIOIT at 0 range 22 .. 22;
ACKFAIL at 0 range 23 .. 23;
ACKTIMEOUT at 0 range 24 .. 24;
VSWEND at 0 range 25 .. 25;
CKSTOP at 0 range 26 .. 26;
IDMATE at 0 range 27 .. 27;
IDMABTC at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-- The SDMMC_ICR register is a write-only register. Writing a bit with 1
-- clears the corresponding bit in the SDMMC_STAR status register.
type ICR_Register is record
-- CCRCFAIL flag clear bit Set by software to clear the CCRCFAIL flag.
CCRCFAILC : Boolean := False;
-- DCRCFAIL flag clear bit Set by software to clear the DCRCFAIL flag.
DCRCFAILC : Boolean := False;
-- CTIMEOUT flag clear bit Set by software to clear the CTIMEOUT flag.
CTIMEOUTC : Boolean := False;
-- DTIMEOUT flag clear bit Set by software to clear the DTIMEOUT flag.
DTIMEOUTC : Boolean := False;
-- TXUNDERR flag clear bit Set by software to clear TXUNDERR flag.
TXUNDERRC : Boolean := False;
-- RXOVERR flag clear bit Set by software to clear the RXOVERR flag.
RXOVERRC : Boolean := False;
-- CMDREND flag clear bit Set by software to clear the CMDREND flag.
CMDRENDC : Boolean := False;
-- CMDSENT flag clear bit Set by software to clear the CMDSENT flag.
CMDSENTC : Boolean := False;
-- DATAEND flag clear bit Set by software to clear the DATAEND flag.
DATAENDC : Boolean := False;
-- DHOLD flag clear bit Set by software to clear the DHOLD flag.
DHOLDC : Boolean := False;
-- DBCKEND flag clear bit Set by software to clear the DBCKEND flag.
DBCKENDC : Boolean := False;
-- DABORT flag clear bit Set by software to clear the DABORT flag.
DABORTC : Boolean := False;
-- unspecified
Reserved_12_20 : HAL.UInt9 := 16#0#;
-- BUSYD0END flag clear bit Set by software to clear the BUSYD0END flag.
BUSYD0ENDC : Boolean := False;
-- SDIOIT flag clear bit Set by software to clear the SDIOIT flag.
SDIOITC : Boolean := False;
-- ACKFAIL flag clear bit Set by software to clear the ACKFAIL flag.
ACKFAILC : Boolean := False;
-- ACKTIMEOUT flag clear bit Set by software to clear the ACKTIMEOUT
-- flag.
ACKTIMEOUTC : Boolean := False;
-- VSWEND flag clear bit Set by software to clear the VSWEND flag.
VSWENDC : Boolean := False;
-- CKSTOP flag clear bit Set by software to clear the CKSTOP flag.
CKSTOPC : Boolean := False;
-- IDMA transfer error clear bit Set by software to clear the IDMATE
-- flag.
IDMATEC : Boolean := False;
-- IDMA buffer transfer complete clear bit Set by software to clear the
-- IDMABTC flag.
IDMABTCC : Boolean := False;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
CCRCFAILC at 0 range 0 .. 0;
DCRCFAILC at 0 range 1 .. 1;
CTIMEOUTC at 0 range 2 .. 2;
DTIMEOUTC at 0 range 3 .. 3;
TXUNDERRC at 0 range 4 .. 4;
RXOVERRC at 0 range 5 .. 5;
CMDRENDC at 0 range 6 .. 6;
CMDSENTC at 0 range 7 .. 7;
DATAENDC at 0 range 8 .. 8;
DHOLDC at 0 range 9 .. 9;
DBCKENDC at 0 range 10 .. 10;
DABORTC at 0 range 11 .. 11;
Reserved_12_20 at 0 range 12 .. 20;
BUSYD0ENDC at 0 range 21 .. 21;
SDIOITC at 0 range 22 .. 22;
ACKFAILC at 0 range 23 .. 23;
ACKTIMEOUTC at 0 range 24 .. 24;
VSWENDC at 0 range 25 .. 25;
CKSTOPC at 0 range 26 .. 26;
IDMATEC at 0 range 27 .. 27;
IDMABTCC at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-- The interrupt mask register determines which status flags generate an
-- interrupt request by setting the corresponding bit to 1.
type MASKR_Register is record
-- Command CRC fail interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by command CRC failure.
CCRCFAILIE : Boolean := False;
-- Data CRC fail interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by data CRC failure.
DCRCFAILIE : Boolean := False;
-- Command timeout interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by command timeout.
CTIMEOUTIE : Boolean := False;
-- Data timeout interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by data timeout.
DTIMEOUTIE : Boolean := False;
-- Tx FIFO underrun error interrupt enable Set and cleared by software
-- to enable/disable interrupt caused by Tx FIFO underrun error.
TXUNDERRIE : Boolean := False;
-- Rx FIFO overrun error interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by Rx FIFO overrun error.
RXOVERRIE : Boolean := False;
-- Command response received interrupt enable Set and cleared by
-- software to enable/disable interrupt caused by receiving command
-- response.
CMDRENDIE : Boolean := False;
-- Command sent interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by sending command.
CMDSENTIE : Boolean := False;
-- Data end interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by data end.
DATAENDIE : Boolean := False;
-- Data hold interrupt enable Set and cleared by software to
-- enable/disable the interrupt generated when sending new data is hold
-- in the DPSM Wait_S state.
DHOLDIE : Boolean := False;
-- Data block end interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by data block end.
DBCKENDIE : Boolean := False;
-- Data transfer aborted interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by a data transfer being aborted.
DABORTIE : Boolean := False;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- Tx FIFO half empty interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by Tx FIFO half empty.
TXFIFOHEIE : Boolean := False;
-- Rx FIFO half full interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by Rx FIFO half full.
RXFIFOHFIE : Boolean := False;
-- unspecified
Reserved_16_16 : HAL.Bit := 16#0#;
-- Rx FIFO full interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by Rx FIFO full.
RXFIFOFIE : Boolean := False;
-- Tx FIFO empty interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by Tx FIFO empty.
TXFIFOEIE : Boolean := False;
-- unspecified
Reserved_19_20 : HAL.UInt2 := 16#0#;
-- BUSYD0END interrupt enable Set and cleared by software to
-- enable/disable the interrupt generated when SDMMC_D0 signal changes
-- from busy to NOT busy following a CMD response.
BUSYD0ENDIE : Boolean := False;
-- SDIO mode interrupt received interrupt enable Set and cleared by
-- software to enable/disable the interrupt generated when receiving the
-- SDIO mode interrupt.
SDIOITIE : Boolean := False;
-- Acknowledgment Fail interrupt enable Set and cleared by software to
-- enable/disable interrupt caused by acknowledgment Fail.
ACKFAILIE : Boolean := False;
-- Acknowledgment timeout interrupt enable Set and cleared by software
-- to enable/disable interrupt caused by acknowledgment timeout.
ACKTIMEOUTIE : Boolean := False;
-- Voltage switch critical timing section completion interrupt enable
-- Set and cleared by software to enable/disable the interrupt generated
-- when voltage switch critical timing section completion.
VSWENDIE : Boolean := False;
-- Voltage Switch clock stopped interrupt enable Set and cleared by
-- software to enable/disable interrupt caused by Voltage Switch clock
-- stopped.
CKSTOPIE : Boolean := False;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- IDMA buffer transfer complete interrupt enable Set and cleared by
-- software to enable/disable the interrupt generated when the IDMA has
-- transferred all data belonging to a memory buffer.
IDMABTCIE : Boolean := False;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MASKR_Register use record
CCRCFAILIE at 0 range 0 .. 0;
DCRCFAILIE at 0 range 1 .. 1;
CTIMEOUTIE at 0 range 2 .. 2;
DTIMEOUTIE at 0 range 3 .. 3;
TXUNDERRIE at 0 range 4 .. 4;
RXOVERRIE at 0 range 5 .. 5;
CMDRENDIE at 0 range 6 .. 6;
CMDSENTIE at 0 range 7 .. 7;
DATAENDIE at 0 range 8 .. 8;
DHOLDIE at 0 range 9 .. 9;
DBCKENDIE at 0 range 10 .. 10;
DABORTIE at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
TXFIFOHEIE at 0 range 14 .. 14;
RXFIFOHFIE at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
RXFIFOFIE at 0 range 17 .. 17;
TXFIFOEIE at 0 range 18 .. 18;
Reserved_19_20 at 0 range 19 .. 20;
BUSYD0ENDIE at 0 range 21 .. 21;
SDIOITIE at 0 range 22 .. 22;
ACKFAILIE at 0 range 23 .. 23;
ACKTIMEOUTIE at 0 range 24 .. 24;
VSWENDIE at 0 range 25 .. 25;
CKSTOPIE at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
IDMABTCIE at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype ACKTIMER_ACKTIME_Field is HAL.UInt25;
-- The SDMMC_ACKTIMER register contains the acknowledgment timeout period,
-- in SDMMC_CK bus clock periods. A counter loads the value from the
-- SDMMC_ACKTIMER register, and starts decrementing when the data path
-- state machine (DPSM) enters the Wait_Ack state. If the timer reaches 0
-- while the DPSM is in this states, the acknowledgment timeout status flag
-- is set.
type ACKTIMER_Register is record
-- Boot acknowledgment timeout period This bit can only be written by
-- firmware when CPSM is disabled (CPSMEN = 0). Boot acknowledgment
-- timeout period expressed in card bus clock periods.
ACKTIME : ACKTIMER_ACKTIME_Field := 16#0#;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ACKTIMER_Register use record
ACKTIME at 0 range 0 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- The receive and transmit FIFOs can be read or written as 32-bit wide
-- registers. The FIFOs contain 32 entries on 32 sequential addresses. This
-- allows the CPU to use its load and store multiple operands to read
-- from/write to the FIFO.
type IDMACTRLR_Register is record
-- IDMA enable This bit can only be written by firmware when DPSM is
-- inactive (DPSMACT = 0).
IDMAEN : Boolean := False;
-- Buffer mode selection. This bit can only be written by firmware when
-- DPSM is inactive (DPSMACT = 0).
IDMABMODE : Boolean := False;
-- Double buffer mode active buffer indication This bit can only be
-- written by firmware when DPSM is inactive (DPSMACT = 0). When IDMA is
-- enabled this bit is toggled by hardware.
IDMABACT : Boolean := False;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IDMACTRLR_Register use record
IDMAEN at 0 range 0 .. 0;
IDMABMODE at 0 range 1 .. 1;
IDMABACT at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype IDMABSIZER_IDMABNDT_Field is HAL.UInt8;
-- The SDMMC_IDMABSIZER register contains the buffers size when in double
-- buffer configuration.
type IDMABSIZER_Register is record
-- unspecified
Reserved_0_4 : HAL.UInt5 := 16#0#;
-- Number of transfers per buffer. This 8-bit value shall be multiplied
-- by 8 to get the size of the buffer in 32-bit words and by 32 to get
-- the size of the buffer in bytes. Example: IDMABNDT = 0x01: buffer
-- size = 8 words = 32 bytes. These bits can only be written by firmware
-- when DPSM is inactive (DPSMACT = 0).
IDMABNDT : IDMABSIZER_IDMABNDT_Field := 16#0#;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IDMABSIZER_Register use record
Reserved_0_4 at 0 range 0 .. 4;
IDMABNDT at 0 range 5 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
subtype VER_MINREV_Field is HAL.UInt4;
subtype VER_MAJREV_Field is HAL.UInt4;
-- SDMMC IP version register
type VER_Register is record
-- Read-only. IP minor revision number.
MINREV : VER_MINREV_Field;
-- Read-only. IP major revision number.
MAJREV : VER_MAJREV_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for VER_Register use record
MINREV at 0 range 0 .. 3;
MAJREV at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- SDMMC1
type SDMMC_Peripheral is record
-- SDMMC power control register
POWER : aliased POWER_Register;
-- The SDMMC_CLKCR register controls the SDMMC_CK output clock, the
-- SDMMC_RX_CLK receive clock, and the bus width.
CLKCR : aliased CLKCR_Register;
-- The SDMMC_ARGR register contains a 32-bit command argument, which is
-- sent to a card as part of a command message.
ARGR : aliased HAL.UInt32;
-- The SDMMC_CMDR register contains the command index and command type
-- bits. The command index is sent to a card as part of a command
-- message. The command type bits control the command path state machine
-- (CPSM).
CMDR : aliased CMDR_Register;
-- SDMMC command response register
RESPCMDR : aliased RESPCMDR_Register;
-- The SDMMC_RESP1/2/3/4R registers contain the status of a card, which
-- is part of the received response.
RESP1R : aliased HAL.UInt32;
-- The SDMMC_RESP1/2/3/4R registers contain the status of a card, which
-- is part of the received response.
RESP2R : aliased HAL.UInt32;
-- The SDMMC_RESP1/2/3/4R registers contain the status of a card, which
-- is part of the received response.
RESP3R : aliased HAL.UInt32;
-- The SDMMC_RESP1/2/3/4R registers contain the status of a card, which
-- is part of the received response.
RESP4R : aliased HAL.UInt32;
-- The SDMMC_DTIMER register contains the data timeout period, in card
-- bus clock periods. A counter loads the value from the SDMMC_DTIMER
-- register, and starts decrementing when the data path state machine
-- (DPSM) enters the Wait_R or Busy state. If the timer reaches 0 while
-- the DPSM is in either of these states, the timeout status flag is
-- set.
DTIMER : aliased HAL.UInt32;
-- The SDMMC_DLENR register contains the number of data bytes to be
-- transferred. The value is loaded into the data counter when data
-- transfer starts.
DLENR : aliased DLENR_Register;
-- The SDMMC_DCTRL register control the data path state machine (DPSM).
DCTRL : aliased DCTRL_Register;
-- The SDMMC_DCNTR register loads the value from the data length
-- register (see SDMMC_DLENR) when the DPSM moves from the Idle state to
-- the Wait_R or Wait_S state. As data is transferred, the counter
-- decrements the value until it reaches 0. The DPSM then moves to the
-- Idle state and when there has been no error, the data status end flag
-- (DATAEND) is set.
DCNTR : aliased DCNTR_Register;
-- The SDMMC_STAR register is a read-only register. It contains two
-- types of flag:Static flags (bits [29,21,11:0]): these bits remain
-- asserted until they are cleared by writing to the SDMMC interrupt
-- Clear register (see SDMMC_ICR)Dynamic flags (bits [20:12]): these
-- bits change state depending on the state of the underlying logic (for
-- example, FIFO full and empty flags are asserted and de-asserted as
-- data while written to the FIFO)
STAR : aliased STAR_Register;
-- The SDMMC_ICR register is a write-only register. Writing a bit with 1
-- clears the corresponding bit in the SDMMC_STAR status register.
ICR : aliased ICR_Register;
-- The interrupt mask register determines which status flags generate an
-- interrupt request by setting the corresponding bit to 1.
MASKR : aliased MASKR_Register;
-- The SDMMC_ACKTIMER register contains the acknowledgment timeout
-- period, in SDMMC_CK bus clock periods. A counter loads the value from
-- the SDMMC_ACKTIMER register, and starts decrementing when the data
-- path state machine (DPSM) enters the Wait_Ack state. If the timer
-- reaches 0 while the DPSM is in this states, the acknowledgment
-- timeout status flag is set.
ACKTIMER : aliased ACKTIMER_Register;
-- The receive and transmit FIFOs can be read or written as 32-bit wide
-- registers. The FIFOs contain 32 entries on 32 sequential addresses.
-- This allows the CPU to use its load and store multiple operands to
-- read from/write to the FIFO.
IDMACTRLR : aliased IDMACTRLR_Register;
-- The SDMMC_IDMABSIZER register contains the buffers size when in
-- double buffer configuration.
IDMABSIZER : aliased IDMABSIZER_Register;
-- The SDMMC_IDMABASE0R register contains the memory buffer base address
-- in single buffer configuration and the buffer 0 base address in
-- double buffer configuration.
IDMABASE0R : aliased HAL.UInt32;
-- The SDMMC_IDMABASE1R register contains the double buffer
-- configuration second buffer memory base address.
IDMABASE1R : aliased HAL.UInt32;
-- The receive and transmit FIFOs can be only read or written as word
-- (32-bit) wide registers. The FIFOs contain 16 entries on sequential
-- addresses. This allows the CPU to use its load and store multiple
-- operands to read from/write to the FIFO.When accessing SDMMC_FIFOR
-- with half word or byte access an AHB bus fault is generated.
FIFOR : aliased HAL.UInt32;
-- SDMMC IP version register
VER : aliased VER_Register;
-- SDMMC IP identification register
ID : aliased HAL.UInt32;
end record
with Volatile;
for SDMMC_Peripheral use record
POWER at 16#0# range 0 .. 31;
CLKCR at 16#4# range 0 .. 31;
ARGR at 16#8# range 0 .. 31;
CMDR at 16#C# range 0 .. 31;
RESPCMDR at 16#10# range 0 .. 31;
RESP1R at 16#14# range 0 .. 31;
RESP2R at 16#18# range 0 .. 31;
RESP3R at 16#1C# range 0 .. 31;
RESP4R at 16#20# range 0 .. 31;
DTIMER at 16#24# range 0 .. 31;
DLENR at 16#28# range 0 .. 31;
DCTRL at 16#2C# range 0 .. 31;
DCNTR at 16#30# range 0 .. 31;
STAR at 16#34# range 0 .. 31;
ICR at 16#38# range 0 .. 31;
MASKR at 16#3C# range 0 .. 31;
ACKTIMER at 16#40# range 0 .. 31;
IDMACTRLR at 16#50# range 0 .. 31;
IDMABSIZER at 16#54# range 0 .. 31;
IDMABASE0R at 16#58# range 0 .. 31;
IDMABASE1R at 16#5C# range 0 .. 31;
FIFOR at 16#80# range 0 .. 31;
VER at 16#3F4# range 0 .. 31;
ID at 16#3F8# range 0 .. 31;
end record;
-- SDMMC1
SDMMC1_Periph : aliased SDMMC_Peripheral
with Import, Address => SDMMC1_Base;
-- SDMMC1
SDMMC2_Periph : aliased SDMMC_Peripheral
with Import, Address => SDMMC2_Base;
end STM32_SVD.SDMMC;
|
-----------------------------------------------------------------------
-- are-installer-merges -- Web file merge
-- Copyright (C) 2020, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Streams.Stream_IO;
with Ada.Exceptions;
with Ada.IO_Exceptions;
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects;
with Util.Log.Loggers;
with Util.Files;
with Util.Strings;
with Util.Streams.Files;
with Util.Streams.Texts;
with Util.Streams.Buffered;
with EL.Expressions;
with Are.Utils;
package body Are.Installer.Merges is
use Util.Log;
use Ada.Strings.Fixed;
use Util.Beans.Objects;
use Ada.Strings.Unbounded;
use type Ada.Calendar.Time;
procedure Process_Property (Rule : in out Merge_Rule;
Node : in DOM.Core.Node);
procedure Process_Replace (Rule : in out Merge_Rule;
Node : in DOM.Core.Node);
Log : constant Loggers.Logger := Loggers.Create ("Are.Installer.Merges");
-- ------------------------------
-- Extract the <property name='{name}'>{value}</property> to setup the
-- EL context to evaluate the source and target links for the merge.
-- ------------------------------
procedure Process_Property (Rule : in out Merge_Rule;
Node : in DOM.Core.Node) is
use Util.Beans.Objects.Maps;
Name : constant String := Are.Utils.Get_Attribute (Node, "name");
Value : constant String := Are.Utils.Get_Data_Content (Node);
Pos : constant Natural := Util.Strings.Index (Name, '.');
begin
if Pos = 0 then
Rule.Variables.Bind (Name, To_Object (Value));
return;
end if;
-- A composed name such as 'jquery.path' must be split so that we store
-- the 'path' value within a 'jquery' Map_Bean object. We handle only
-- one such composition.
declare
Param : constant String := Name (Name'First .. Pos - 1);
Tag : constant Unbounded_String := To_Unbounded_String (Param);
Var : constant EL.Expressions.Expression := Rule.Variables.Get_Variable (Tag);
Val : Object := Rule.Params.Get_Value (Param);
Child : Map_Bean_Access;
begin
if Is_Null (Val) then
Child := new Map_Bean;
Val := To_Object (Child);
Rule.Params.Set_Value (Param, Val);
else
Child := Map_Bean_Access (To_Bean (Val));
end if;
Child.Set_Value (Name (Pos + 1 .. Name'Last), To_Object (Value));
if Var.Is_Null then
Rule.Variables.Bind (Param, Val);
end if;
end;
end Process_Property;
procedure Process_Replace (Rule : in out Merge_Rule;
Node : in DOM.Core.Node) is
From : constant String := Are.Utils.Get_Data_Content (Node, "from");
To : constant String := Are.Utils.Get_Data_Content (Node, "to");
begin
Rule.Replace.Include (From, To);
end Process_Replace;
procedure Iterate_Properties is
new Are.Utils.Iterate_Nodes (Merge_Rule, Process_Property);
procedure Iterate_Replace is
new Are.Utils.Iterate_Nodes (Merge_Rule, Process_Replace);
-- ------------------------------
-- Create a distribution rule to copy a set of files or directories.
-- ------------------------------
function Create_Rule (Node : in DOM.Core.Node) return Distrib_Rule_Access is
Result : constant Merge_Rule_Access := new Merge_Rule;
begin
Iterate_Properties (Result.all, Node, "property", False);
Iterate_Replace (Result.all, Node, "replace", False);
Result.Context.Set_Variable_Mapper (Result.Variables'Access);
Result.Start_Mark := Are.Utils.Get_Attribute (Node, "merge-start", DEFAULT_MERGE_START);
Result.End_Mark := Are.Utils.Get_Attribute (Node, "merge-end", DEFAULT_MERGE_END);
return Result.all'Access;
end Create_Rule;
-- ------------------------------
-- Get a name to qualify the installation rule (used for logs).
-- ------------------------------
overriding
function Get_Install_Name (Rule : in Merge_Rule) return String is
pragma Unreferenced (Rule);
begin
return "merge";
end Get_Install_Name;
overriding
procedure Install (Rule : in Merge_Rule;
Path : in String;
Files : in File_Vector;
Context : in out Context_Type'Class) is
use Ada.Streams;
type Mode_Type is (MERGE_NONE, MERGE_LINK, MERGE_SCRIPT);
procedure Error (Message : in String;
Arg1 : in String := "");
function Get_Target_Name (Link : in String) return String;
function Get_Target_Path (Link : in String) return String;
function Get_Filename (Line : in String) return String;
function Get_Source (Line : in String;
Tag : in String) return String;
function Find_Match (Buffer : in Stream_Element_Array) return Stream_Element_Offset;
procedure Prepare_Merge (Line : in String);
procedure Include (Line : in String;
Pattern : in String);
procedure Process (Line : in String);
Root_Dir : constant String := Context.Get_Generation_Path (To_String (Rule.Dir));
Source : constant String := Get_Source_Path (Files, False);
Target : constant String := Context.Get_Generation_Path (Path);
Dir : constant String := Ada.Directories.Containing_Directory (Target);
Build : constant String := "23"; -- Context.Get_Parameter ("dynamo.build");
Start_Mark : constant String := "<!-- " & To_String (Rule.Start_Mark) & " ";
End_Mark : constant String := "<!-- " & To_String (Rule.End_Mark) & " ";
File_Time : constant Ada.Calendar.Time := Ada.Directories.Modification_Time (Source);
Modtime : Ada.Calendar.Time := File_Time;
Output : aliased Util.Streams.Files.File_Stream;
Merge : aliased Util.Streams.Files.File_Stream;
Merge_Path : UString;
Merge_Name : UString;
Text : Util.Streams.Texts.Print_Stream;
Mode : Mode_Type := MERGE_NONE;
Line_Num : Natural := 0;
Inc_Error : Natural := 0;
procedure Error (Message : in String;
Arg1 : in String := "") is
Line : constant String := Util.Strings.Image (Line_Num);
begin
Context.Error (Source & ":" & Line & ": " & Message, Arg1);
end Error;
function Get_Target_Name (Link : in String) return String is
Expr : EL.Expressions.Expression;
File : Util.Beans.Objects.Object;
begin
Expr := EL.Expressions.Create_Expression (Link, Rule.Context);
File := Expr.Get_Value (Rule.Context);
declare
Name : constant String := To_String (File);
begin
-- Drop the first '/' if there is one.
if Name'Length > 0 and then Name (Name'First) = '/' then
return Name (Name'First + 1 .. Name'Last);
else
return Name;
end if;
end;
end Get_Target_Name;
function Get_Target_Path (Link : in String) return String is
Name : constant String := Get_Target_Name (Link);
begin
return Util.Files.Compose (Root_Dir, Name);
end Get_Target_Path;
function Get_Filename (Line : in String) return String is
Pos : Natural := Index (Line, "link=");
Last : Natural;
begin
if Pos > 0 then
Mode := MERGE_LINK;
else
Pos := Index (Line, "script=");
if Pos > 0 then
Mode := MERGE_SCRIPT;
end if;
if Pos = 0 then
return "";
end if;
end if;
Pos := Index (Line, "=");
Last := Util.Strings.Index (Line, ' ', Pos + 1);
if Last = 0 then
return "";
end if;
return Line (Pos + 1 .. Last - 1);
end Get_Filename;
function Get_Source (Line : in String;
Tag : in String) return String is
Pos : Natural := Index (Line, Tag);
Last : Natural;
begin
if Pos = 0 then
return "";
end if;
Pos := Pos + Tag'Length;
if Pos > Line'Last or else (Line (Pos) /= '"' and Line (Pos) /= ''') then
return "";
end if;
Last := Util.Strings.Index (Line, Line (Pos), Pos + 1);
if Last = 0 then
return "";
end if;
return Line (Pos + 1 .. Last - 1);
end Get_Source;
procedure Prepare_Merge (Line : in String) is
Link : constant String := Get_Filename (Line);
Path : constant String := Get_Target_Name (Link);
Target_Path : constant String := Util.Files.Compose (Root_Dir, Path);
Parent_Dir : constant String := Ada.Directories.Containing_Directory (Target_Path);
begin
if Link'Length = 0 then
Error ("invalid empty file name");
return;
end if;
case Mode is
when MERGE_LINK =>
Text.Write ("<link media='screen' type='text/css' rel='stylesheet'"
& " href='");
Text.Write (Link);
Text.Write ("?build=");
Text.Write (Build);
Text.Write ("'/>" & ASCII.LF);
when MERGE_SCRIPT =>
Text.Write ("<script type='text/javascript' src='");
Text.Write (Link);
Text.Write ("?build=");
Text.Write (Build);
Text.Write ("'></script>" & ASCII.LF);
when MERGE_NONE =>
null;
end case;
if Rule.Level >= Util.Log.INFO_LEVEL then
Log.Info (" create {0}", Path);
end if;
if not Ada.Directories.Exists (Parent_Dir) then
Ada.Directories.Create_Path (Parent_Dir);
end if;
Modtime := File_Time;
Merge_Path := To_Unbounded_String (Target_Path);
Merge_Name := To_Unbounded_String (Path);
Merge.Create (Mode => Ada.Streams.Stream_IO.Out_File,
Name => Target_Path);
end Prepare_Merge;
Current_Match : Util.Strings.Maps.Cursor;
function Find_Match (Buffer : in Stream_Element_Array) return Stream_Element_Offset is
Iter : Util.Strings.Maps.Cursor := Rule.Replace.First;
First : Stream_Element_Offset := Buffer'Last + 1;
begin
while Util.Strings.Maps.Has_Element (Iter) loop
declare
Value : constant String := Util.Strings.Maps.Key (Iter);
Match : Stream_Element_Array (1 .. Value'Length);
for Match'Address use Value'Address;
Pos : Stream_Element_Offset;
begin
Pos := Buffer'First;
while Pos + Match'Length < Buffer'Last loop
if Buffer (Pos .. Pos + Match'Length - 1) = Match then
if First > Pos then
First := Pos;
Current_Match := Iter;
end if;
exit;
end if;
Pos := Pos + 1;
end loop;
end;
Util.Strings.Maps.Next (Iter);
end loop;
return First;
end Find_Match;
procedure Free is
new Ada.Unchecked_Deallocation (Object => Ada.Streams.Stream_Element_Array,
Name => Util.Streams.Buffered.Buffer_Access);
procedure Include (Line : in String;
Pattern : in String) is
Source : constant String := Get_Source (Line, Pattern);
Target : constant String := Get_Target_Path (Source);
Input : Util.Streams.Files.File_Stream;
Size : Stream_Element_Offset;
Last : Stream_Element_Offset;
Pos : Stream_Element_Offset;
Next : Stream_Element_Offset;
Buffer : Util.Streams.Buffered.Buffer_Access;
Time : Ada.Calendar.Time;
begin
if Source'Length = 0 then
Inc_Error := Inc_Error + 1;
if Inc_Error > 5 then
return;
end if;
Error ("expecting a '{0}' in the line to identify the file to include", Pattern);
if Inc_Error = 5 then
Error ("may be the end marker '{0}' was not correct?", To_String (Rule.End_Mark));
end if;
return;
end if;
if Rule.Level >= Util.Log.INFO_LEVEL then
Log.Info (" include {0}", Target);
end if;
Time := Ada.Directories.Modification_Time (Target);
if Time > Modtime then
Modtime := Time;
end if;
Input.Open (Name => Target, Mode => Ada.Streams.Stream_IO.In_File);
Size := Stream_Element_Offset (Ada.Directories.Size (Target));
Buffer := new Stream_Element_Array (1 .. Size);
Input.Read (Buffer.all, Last);
Input.Close;
Pos := 1;
while Pos < Last loop
Next := Find_Match (Buffer (Pos .. Last));
if Next > Pos then
Merge.Write (Buffer (Pos .. Next - 1));
end if;
exit when Next >= Last;
declare
Value : constant String := Util.Strings.Maps.Key (Current_Match);
Replace : constant String := Util.Strings.Maps.Element (Current_Match);
Content : Stream_Element_Array (1 .. Replace'Length);
for Content'Address use Replace'Address;
begin
Merge.Write (Content);
Pos := Next + Value'Length;
end;
end loop;
Free (Buffer);
exception
when Ex : Ada.IO_Exceptions.Name_Error =>
Error ("cannot read {0}", Ada.Exceptions.Exception_Message (Ex));
end Include;
procedure Process (Line : in String) is
Pos : Natural;
begin
Line_Num := Line_Num + 1;
case Mode is
when MERGE_NONE =>
Pos := Index (Line, Start_Mark);
if Pos = 0 then
Text.Write (Line);
Text.Write (ASCII.LF);
return;
end if;
Text.Write (Line (Line'First .. Pos - 1));
Prepare_Merge (Line (Pos + 10 .. Line'Last));
when MERGE_LINK =>
Pos := Index (Line, End_Mark);
if Pos > 0 then
Merge.Close;
if not Rule.Source_Timestamp then
Modtime := Ada.Directories.Modification_Time (To_String (Merge_Path));
end if;
Rule.Add_File (Name => To_String (Merge_Name),
Path => To_String (Merge_Path),
Modtime => Modtime,
Override => True);
Mode := MERGE_NONE;
return;
end if;
Include (Line, "href=");
when MERGE_SCRIPT =>
Pos := Index (Line, End_Mark);
if Pos > 0 then
Merge.Close;
if not Rule.Source_Timestamp then
Modtime := Ada.Directories.Modification_Time (To_String (Merge_Path));
end if;
Rule.Add_File (Name => To_String (Merge_Name),
Path => To_String (Merge_Path),
Modtime => Modtime,
Override => True);
Mode := MERGE_NONE;
return;
end if;
Include (Line, "src=");
end case;
end Process;
begin
if Rule.Level >= Util.Log.INFO_LEVEL then
Log.Info ("webmerge {0}", Path);
end if;
Ada.Directories.Create_Path (Dir);
Output.Create (Name => Target, Mode => Ada.Streams.Stream_IO.Out_File);
Text.Initialize (Output'Unchecked_Access, 16 * 1024);
Util.Files.Read_File (Source, Process'Access);
Text.Flush;
Output.Close;
Rule.Add_File (Path, Target, File_Time);
end Install;
end Are.Installer.Merges;
|
-- Test_Input_Lengths
-- Ensure that headers and trailers of different lengths are accepted
-- and messages of different lengths correctly decrypted (to check padding)
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
with NORX;
with System.Storage_Elements;
use System.Storage_Elements;
generic
with package NORX_Package is new NORX(<>);
Max_Size : System.Storage_Elements.Storage_Offset := 2000;
Other_Size : System.Storage_Elements.Storage_Offset := 73;
procedure Test_Input_Lengths;
|
-- 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 Ada.Text_IO;
with Latin_Utils.Config;
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 Latin_Utils.General;
procedure Makedict_Main (Porting : Boolean) is
package Integer_IO is new Ada.Text_IO.Integer_IO (Integer);
use Ada.Text_IO;
use Stem_Key_Type_IO;
use Dictionary_Entry_IO;
use Part_Entry_IO;
use Age_Type_IO;
use Area_Type_IO;
use Geo_Type_IO;
use Frequency_Type_IO;
use Source_Type_IO;
use Dict_IO;
Be_Ve : constant Verb_Entry := (Con => (5, 1), Kind => To_Be);
D_K : Dictionary_Kind := Xxx; -- ######################
Start_Stem_1 : constant := 1;
Start_Stem_2 : constant := Start_Stem_1 + Max_Stem_Size + 1;
Start_Stem_3 : constant := Start_Stem_2 + Max_Stem_Size + 1;
Start_Stem_4 : constant := Start_Stem_3 + Max_Stem_Size + 1;
Start_Part : constant := Start_Stem_4 + Max_Stem_Size + 1;
Dictfile : Dict_IO.File_Type;
Input, Stemlist : Ada.Text_IO.File_Type;
De : Dictionary_Entry;
Blank_Line : constant String (1 .. 400) := (others => ' ');
S, Line : String (1 .. 400) := (others => ' ');
L, Last : Integer := 0;
J : Dict_IO.Count := 0;
Mean_To_Be : constant Meaning_Type :=
Head ("be; exist; (also used to form verb perfect passive tenses)" &
" with NOM PERF PPL", Max_Meaning_Size);
begin
Put_Line
("Takes a DICTLINE.D_K and produces a STEMLIST.D_K and DICTFILE.D_K");
Put_Line ("This version inserts ESSE when D_K = GEN");
Latin_Utils.General.Load_Dictionary (Line, Last, D_K);
Open (Input, In_File,
Latin_Utils.Config.Path (Dict_Line_Name & '.' & Ext (D_K)));
if not Porting then
Create (Stemlist, Out_File, Stem_List_Name & '.' & Ext (D_K));
end if;
Create (Dictfile, Out_File, Dict_File_Name & '.' & Ext (D_K));
Over_Lines :
while not End_Of_File (Input) loop
S := Blank_Line;
Get_Line (Input, S, Last);
if Trim (S (1 .. Last)) /= "" then
L := 0;
Form_De :
begin
De.Stems (1) := S (Start_Stem_1 .. Max_Stem_Size);
De.Stems (2) := S (Start_Stem_2 .. Start_Stem_2 +
Max_Stem_Size - 1);
De.Stems (3) := S (Start_Stem_3 .. Start_Stem_3 +
Max_Stem_Size - 1);
De.Stems (4) := S (Start_Stem_4 .. Start_Stem_4 +
Max_Stem_Size - 1);
Get (S (Start_Part .. Last), De.Part, L);
-- FIXME: Why not Translation_Record_IO.Get ?
Get (S (L + 1 .. Last), De.Tran.Age, L);
Get (S (L + 1 .. Last), De.Tran.Area, L);
Get (S (L + 1 .. Last), De.Tran.Geo, L);
Get (S (L + 1 .. Last), De.Tran.Freq, L);
Get (S (L + 1 .. Last), De.Tran.Source, L);
De.Mean := Head (S (L + 2 .. Last), Max_Meaning_Size);
-- Note that this allows initial blanks
-- L+2 skips over the SPACER, required because this is
-- STRING, not ENUM
exception
when others =>
New_Line;
Put_Line ("Exception");
Put_Line (S (1 .. Last));
Integer_IO.Put (Integer (J)); New_Line;
Put (De); New_Line;
end Form_De;
J := J + 1;
Write (Dictfile, De, J);
if not Porting then
if De.Part.Pofs = N and then
De.Stems (1) = De.Stems (2) and then
De.Stems (1) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 0, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Adj and then
De.Stems (1) = De.Stems (2) and then
De.Stems (1) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 0, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
if De.Stems (3) /= Null_Stem_Type
and De.Stems (3) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (3)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 3, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6);
New_Line (Stemlist);
end if;
if De.Stems (4) /= Null_Stem_Type
and De.Stems (4) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (4)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 4, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6);
New_Line (Stemlist);
end if;
elsif De.Part.Pofs = Adj and then
-- POS taken care of by position
De.Part.Adj.Co = Comp
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 3, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Adj and then
De.Part.Adj.Co = Super
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 4, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Adv and then
-- POS taken care of by position
De.Part.Adv.Co = Comp
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 2, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Adv and then
De.Part.Adv.Co = Super
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 3, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = V and then
De.Stems (1) = De.Stems (2) and then
De.Stems (1) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 0, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
if De.Stems (3) /= Null_Stem_Type
and De.Stems (3) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (3)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 3, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6);
New_Line (Stemlist);
end if;
if De.Stems (4) /= Null_Stem_Type
and De.Stems (4) /= ZZZ_Stem
then
Put (Stemlist, De.Stems (4)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 4, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6);
New_Line (Stemlist);
end if;
elsif De.Part.Pofs = Num and then
De.Part.Num.Sort = Card
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 1, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Num and then
De.Part.Num.Sort = Ord
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 2, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Num and then
De.Part.Num.Sort = Dist
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 3, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
elsif De.Part.Pofs = Num and then
De.Part.Num.Sort = Adverb
then
Put (Stemlist, De.Stems (1)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Integer_IO.Put (Stemlist, 4, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
else
for I in Stem_Key_Type range 1 .. 4 loop
if De.Stems (I) /= ZZZ_Stem and
De.Stems (I) /= Null_Stem_Type
then
Put (Stemlist, De.Stems (I)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Put (Stemlist, I, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6);
New_Line (Stemlist);
end if;
end loop;
end if;
end if; -- PORTING
end if;
end loop Over_Lines;
if D_K = General then
J := J + 1;
-- First construct ESSE
De.Stems (1) := "s ";
De.Stems (2) := " ";
De.Stems (3) := "fu ";
De.Stems (4) := "fut ";
--DE.PART := (PART => V, CON => (5, 10));
--DE.PART := (V, ((5, 1)));
De.Part := (V, Be_Ve);
--DE.KIND := (V, TO_BE);
De.Tran := (X, X, X, A, X);
De.Mean := Mean_To_Be;
if not Porting then
-- Load ESSE
for I in Stem_Key_Type range 1 .. 4 loop
Put (Stemlist, De.Stems (I)); Put (Stemlist, ' ');
Put (Stemlist, De.Part); Put (Stemlist, ' ');
Set_Col (Stemlist, 45);
Put (Stemlist, I, 2); Put (Stemlist, ' ');
Set_Col (Stemlist, 50);
Integer_IO.Put (Stemlist, Integer (J), 6); New_Line (Stemlist);
end loop;
end if;
Write (Dictfile, De, J);
end if;
if not Porting then
Close (Stemlist);
end if;
exception
when Ada.Text_IO.Data_Error =>
null;
when others =>
Put_Line (S (1 .. Last));
Integer_IO.Put (Integer (J)); New_Line;
Close (Stemlist);
end Makedict_Main;
|
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro>
--
-- 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.Unchecked_Deallocation;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Streams; use Ada.Streams;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with DNSCatcher.Types; use DNSCatcher.Types;
-- @summary
-- Generic utility functions used throughout DNSCatcher are collected here.
--
-- @description
-- Some functionality is either very generic (such as ntohs), or otherwise is
-- a standalone subprogram that is used throughout the code, and this package
-- provides a home and organization pointer for them
--
-- Wrapper functions are provided for network byte order conversion as in
-- certain places, the values must be flipped on the fly, and GNAT.Sockets
-- doesn't provide an easy interface for this
--
package DNSCatcher.Utils is
-- Network Byteorder to Host Short
--
-- @value Network_Short
-- An unsigned 16-bit integer
--
-- @returns
-- Local machine byte order 16-bit integer
--
function Ntohs
(Network_Short : Unsigned_16)
return Unsigned_16;
-- Network Byteorder to Host Long
--
-- @value Network_Long
-- An unsigned 32-bit integer
--
-- @returns
-- Local machine byte order 32-bit integer
--
function Ntohl
(Network_Long : Unsigned_32)
return Unsigned_32;
-- Host Short to Network Byteorder
--
-- @value Host_Short
-- An unsigned 16-bit integer
--
-- @returns
-- Network byte order 16-bit integer
--
function Htons
(Host_Short : Unsigned_16)
return Unsigned_16;
-- Host Long to Network Byteorder
--
-- @value Host_Long
-- An unsigned 32-bit integer
--
-- @returns
-- Network byte order 32-bit integer
--
function Htonl
(Host_Long : Unsigned_32)
return Unsigned_32;
-- Reads a 16-bit integer from a network stream and converts it to an
-- Unsigned_16 for further evaluation
--
-- @value Raw_Data
-- Pointer to a Stream_Element Array
--
-- @value Offset
-- Location which to read the uint16 from
--
-- @returns
-- Unsigned_16
--
function Read_Unsigned_16
(Raw_Data : Stream_Element_Array_Ptr;
Offset : in out Stream_Element_Offset)
return Unsigned_16;
-- Reads a 32-bit integer from a network stream and converts it to an
-- Unsigned_32 for further evaluation
--
-- @value Raw_Data
-- Pointer to a Stream_Element Array
--
-- @value Offset
-- Location which to read the uint32 from
--
-- @returns
-- Unsigned_32
--
function Read_Unsigned_32
(Raw_Data : Stream_Element_Array_Ptr;
Offset : in out Stream_Element_Offset)
return Unsigned_32;
-- IP_Addr_Family
--
-- This is a wrapper for Inet_Ntop that abstracts the values of AF_INET and
-- AF_INET6 from the C preprocessor; allowing it to work across platforms
-- without concern for varying preprocessor types
--
type IP_Addr_Family is
(IPv4, -- IPv4 input address
IPv6 -- IPv6 input address
);
for IP_Addr_Family use (IPv4 => 1, IPv6 => 2);
-- Converts binary IPs to text form
--
-- @value Family
-- IP_Addr_Family on if we're reading an IPv4 or IPv6 address
--
-- @value Raw_Data
-- The raw data stored in Unbounded_String format
--
-- @returns
-- Unbounded String with the IP address formatted in conventional style by
-- the underlying inet_ntop() C function
--
function Inet_Ntop
(Family : IP_Addr_Family;
Raw_Data : Unbounded_String)
return Unbounded_String;
-- Deallocators
-- Helper function to free Stream_Element_Arrays
procedure Free_Stream_Element_Array_Ptr is new Ada.Unchecked_Deallocation
(Object => Stream_Element_Array, Name => Stream_Element_Array_Ptr);
end DNSCatcher.Utils;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.