content
stringlengths
23
1.05M
-- This spec has been automatically generated from STM32F105xx.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with System; package STM32.ADC is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- SR_Register -- ----------------- subtype SR_AWD_Field is STM32.Bit; subtype SR_EOC_Field is STM32.Bit; subtype SR_JEOC_Field is STM32.Bit; subtype SR_JSTRT_Field is STM32.Bit; subtype SR_STRT_Field is STM32.Bit; -- status register type SR_Register is record -- Analog watchdog flag AWD : SR_AWD_Field := 16#0#; -- Regular channel end of conversion EOC : SR_EOC_Field := 16#0#; -- Injected channel end of conversion JEOC : SR_JEOC_Field := 16#0#; -- Injected channel start flag JSTRT : SR_JSTRT_Field := 16#0#; -- Regular channel start flag STRT : SR_STRT_Field := 16#0#; -- unspecified Reserved_5_31 : STM32.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record AWD at 0 range 0 .. 0; EOC at 0 range 1 .. 1; JEOC at 0 range 2 .. 2; JSTRT at 0 range 3 .. 3; STRT at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ------------------ -- CR1_Register -- ------------------ subtype CR1_AWDCH_Field is STM32.UInt5; subtype CR1_EOCIE_Field is STM32.Bit; subtype CR1_AWDIE_Field is STM32.Bit; subtype CR1_JEOCIE_Field is STM32.Bit; subtype CR1_SCAN_Field is STM32.Bit; subtype CR1_AWDSGL_Field is STM32.Bit; subtype CR1_JAUTO_Field is STM32.Bit; subtype CR1_DISCEN_Field is STM32.Bit; subtype CR1_JDISCEN_Field is STM32.Bit; subtype CR1_DISCNUM_Field is STM32.UInt3; subtype CR1_DUALMOD_Field is STM32.UInt4; subtype CR1_JAWDEN_Field is STM32.Bit; subtype CR1_AWDEN_Field is STM32.Bit; -- control register 1 type CR1_Register is record -- Analog watchdog channel select bits AWDCH : CR1_AWDCH_Field := 16#0#; -- Interrupt enable for EOC EOCIE : CR1_EOCIE_Field := 16#0#; -- Analog watchdog interrupt enable AWDIE : CR1_AWDIE_Field := 16#0#; -- Interrupt enable for injected channels JEOCIE : CR1_JEOCIE_Field := 16#0#; -- Scan mode SCAN : CR1_SCAN_Field := 16#0#; -- Enable the watchdog on a single channel in scan mode AWDSGL : CR1_AWDSGL_Field := 16#0#; -- Automatic injected group conversion JAUTO : CR1_JAUTO_Field := 16#0#; -- Discontinuous mode on regular channels DISCEN : CR1_DISCEN_Field := 16#0#; -- Discontinuous mode on injected channels JDISCEN : CR1_JDISCEN_Field := 16#0#; -- Discontinuous mode channel count DISCNUM : CR1_DISCNUM_Field := 16#0#; -- Dual mode selection DUALMOD : CR1_DUALMOD_Field := 16#0#; -- unspecified Reserved_20_21 : STM32.UInt2 := 16#0#; -- Analog watchdog enable on injected channels JAWDEN : CR1_JAWDEN_Field := 16#0#; -- Analog watchdog enable on regular channels AWDEN : CR1_AWDEN_Field := 16#0#; -- unspecified Reserved_24_31 : STM32.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record AWDCH at 0 range 0 .. 4; EOCIE at 0 range 5 .. 5; AWDIE at 0 range 6 .. 6; JEOCIE at 0 range 7 .. 7; SCAN at 0 range 8 .. 8; AWDSGL at 0 range 9 .. 9; JAUTO at 0 range 10 .. 10; DISCEN at 0 range 11 .. 11; JDISCEN at 0 range 12 .. 12; DISCNUM at 0 range 13 .. 15; DUALMOD at 0 range 16 .. 19; Reserved_20_21 at 0 range 20 .. 21; JAWDEN at 0 range 22 .. 22; AWDEN at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------ -- CR2_Register -- ------------------ subtype CR2_ADON_Field is STM32.Bit; subtype CR2_CONT_Field is STM32.Bit; subtype CR2_CAL_Field is STM32.Bit; subtype CR2_RSTCAL_Field is STM32.Bit; subtype CR2_DMA_Field is STM32.Bit; subtype CR2_ALIGN_Field is STM32.Bit; subtype CR2_JEXTSEL_Field is STM32.UInt3; subtype CR2_JEXTTRIG_Field is STM32.Bit; subtype CR2_EXTSEL_Field is STM32.UInt3; subtype CR2_EXTTRIG_Field is STM32.Bit; subtype CR2_JSWSTART_Field is STM32.Bit; subtype CR2_SWSTART_Field is STM32.Bit; subtype CR2_TSVREFE_Field is STM32.Bit; -- control register 2 type CR2_Register is record -- A/D converter ON / OFF ADON : CR2_ADON_Field := 16#0#; -- Continuous conversion CONT : CR2_CONT_Field := 16#0#; -- A/D calibration CAL : CR2_CAL_Field := 16#0#; -- Reset calibration RSTCAL : CR2_RSTCAL_Field := 16#0#; -- unspecified Reserved_4_7 : STM32.UInt4 := 16#0#; -- Direct memory access mode DMA : CR2_DMA_Field := 16#0#; -- unspecified Reserved_9_10 : STM32.UInt2 := 16#0#; -- Data alignment ALIGN : CR2_ALIGN_Field := 16#0#; -- External event select for injected group JEXTSEL : CR2_JEXTSEL_Field := 16#0#; -- External trigger conversion mode for injected channels JEXTTRIG : CR2_JEXTTRIG_Field := 16#0#; -- unspecified Reserved_16_16 : STM32.Bit := 16#0#; -- External event select for regular group EXTSEL : CR2_EXTSEL_Field := 16#0#; -- External trigger conversion mode for regular channels EXTTRIG : CR2_EXTTRIG_Field := 16#0#; -- Start conversion of injected channels JSWSTART : CR2_JSWSTART_Field := 16#0#; -- Start conversion of regular channels SWSTART : CR2_SWSTART_Field := 16#0#; -- Temperature sensor and VREFINT enable TSVREFE : CR2_TSVREFE_Field := 16#0#; -- unspecified Reserved_24_31 : STM32.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record ADON at 0 range 0 .. 0; CONT at 0 range 1 .. 1; CAL at 0 range 2 .. 2; RSTCAL at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; DMA at 0 range 8 .. 8; Reserved_9_10 at 0 range 9 .. 10; ALIGN at 0 range 11 .. 11; JEXTSEL at 0 range 12 .. 14; JEXTTRIG at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; EXTSEL at 0 range 17 .. 19; EXTTRIG at 0 range 20 .. 20; JSWSTART at 0 range 21 .. 21; SWSTART at 0 range 22 .. 22; TSVREFE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -------------------- -- SMPR1_Register -- -------------------- --------------- -- SMPR1.SMP -- --------------- -- SMPR1_SMP array element subtype SMPR1_SMP_Element is STM32.UInt3; -- SMPR1_SMP array type SMPR1_SMP_Field_Array is array (10 .. 18) of SMPR1_SMP_Element with Component_Size => 3, Size => 27; -- Type definition for SMPR1_SMP type SMPR1_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : STM32.UInt27; when True => -- SMP as an array Arr : SMPR1_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 27; for SMPR1_SMP_Field use record Val at 0 range 0 .. 26; Arr at 0 range 0 .. 26; end record; -- sample time register 1 type SMPR1_Register is record -- Channel 10 sampling time selection SMP : SMPR1_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_27_31 : STM32.UInt5 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR1_Register use record SMP at 0 range 0 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -------------------- -- SMPR2_Register -- -------------------- --------------- -- SMPR2.SMP -- --------------- -- SMPR2_SMP array element subtype SMPR2_SMP_Element is STM32.UInt3; -- SMPR2_SMP array type SMPR2_SMP_Field_Array is array (0 .. 9) of SMPR2_SMP_Element with Component_Size => 3, Size => 30; -- Type definition for SMPR2_SMP type SMPR2_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : STM32.UInt30; when True => -- SMP as an array Arr : SMPR2_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SMPR2_SMP_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- sample time register 2 type SMPR2_Register is record -- Channel 0 sampling time selection SMP : SMPR2_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : STM32.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR2_Register use record SMP at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; -------------------- -- JOFR1_Register -- -------------------- subtype JOFR1_JOFFSET1_Field is STM32.UInt12; -- injected channel data offset register x type JOFR1_Register is record -- Data offset for injected channel x JOFFSET1 : JOFR1_JOFFSET1_Field := 16#0#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR1_Register use record JOFFSET1 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR2_Register -- -------------------- subtype JOFR2_JOFFSET2_Field is STM32.UInt12; -- injected channel data offset register x type JOFR2_Register is record -- Data offset for injected channel x JOFFSET2 : JOFR2_JOFFSET2_Field := 16#0#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR2_Register use record JOFFSET2 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR3_Register -- -------------------- subtype JOFR3_JOFFSET3_Field is STM32.UInt12; -- injected channel data offset register x type JOFR3_Register is record -- Data offset for injected channel x JOFFSET3 : JOFR3_JOFFSET3_Field := 16#0#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR3_Register use record JOFFSET3 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR4_Register -- -------------------- subtype JOFR4_JOFFSET4_Field is STM32.UInt12; -- injected channel data offset register x type JOFR4_Register is record -- Data offset for injected channel x JOFFSET4 : JOFR4_JOFFSET4_Field := 16#0#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR4_Register use record JOFFSET4 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- HTR_Register -- ------------------ subtype HTR_HT_Field is STM32.UInt12; -- watchdog higher threshold register type HTR_Register is record -- Analog watchdog higher threshold HT : HTR_HT_Field := 16#FFF#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HTR_Register use record HT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- LTR_Register -- ------------------ subtype LTR_LT_Field is STM32.UInt12; -- watchdog lower threshold register type LTR_Register is record -- Analog watchdog lower threshold LT : LTR_LT_Field := 16#0#; -- unspecified Reserved_12_31 : STM32.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LTR_Register use record LT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------- -- SQR1_Register -- ------------------- ------------- -- SQR1.SQ -- ------------- -- SQR1_SQ array element subtype SQR1_SQ_Element is STM32.UInt5; -- SQR1_SQ array type SQR1_SQ_Field_Array is array (13 .. 16) of SQR1_SQ_Element with Component_Size => 5, Size => 20; -- Type definition for SQR1_SQ type SQR1_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : STM32.UInt20; when True => -- SQ as an array Arr : SQR1_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for SQR1_SQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype SQR1_L_Field is STM32.UInt4; -- regular sequence register 1 type SQR1_Register is record -- 13th conversion in regular sequence SQ : SQR1_SQ_Field := (As_Array => False, Val => 16#0#); -- Regular channel sequence length L : SQR1_L_Field := 16#0#; -- unspecified Reserved_24_31 : STM32.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR1_Register use record SQ at 0 range 0 .. 19; L at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------- -- SQR2_Register -- ------------------- ------------- -- SQR2.SQ -- ------------- -- SQR2_SQ array element subtype SQR2_SQ_Element is STM32.UInt5; -- SQR2_SQ array type SQR2_SQ_Field_Array is array (7 .. 12) of SQR2_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR2_SQ type SQR2_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : STM32.UInt30; when True => -- SQ as an array Arr : SQR2_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR2_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 2 type SQR2_Register is record -- 7th conversion in regular sequence SQ : SQR2_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : STM32.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR2_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- SQR3_Register -- ------------------- ------------- -- SQR3.SQ -- ------------- -- SQR3_SQ array element subtype SQR3_SQ_Element is STM32.UInt5; -- SQR3_SQ array type SQR3_SQ_Field_Array is array (1 .. 6) of SQR3_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR3_SQ type SQR3_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : STM32.UInt30; when True => -- SQ as an array Arr : SQR3_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR3_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 3 type SQR3_Register is record -- 1st conversion in regular sequence SQ : SQR3_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : STM32.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR3_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- JSQR_Register -- ------------------- -------------- -- JSQR.JSQ -- -------------- -- JSQR_JSQ array element subtype JSQR_JSQ_Element is STM32.UInt5; -- JSQR_JSQ array type JSQR_JSQ_Field_Array is array (1 .. 4) of JSQR_JSQ_Element with Component_Size => 5, Size => 20; -- Type definition for JSQR_JSQ type JSQR_JSQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- JSQ as a value Val : STM32.UInt20; when True => -- JSQ as an array Arr : JSQR_JSQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for JSQR_JSQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype JSQR_JL_Field is STM32.UInt2; -- injected sequence register type JSQR_Register is record -- 1st conversion in injected sequence JSQ : JSQR_JSQ_Field := (As_Array => False, Val => 16#0#); -- Injected sequence length JL : JSQR_JL_Field := 16#0#; -- unspecified Reserved_22_31 : STM32.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JSQR_Register use record JSQ at 0 range 0 .. 19; JL at 0 range 20 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------ -- JDR_Register -- ------------------ subtype JDR1_JDATA_Field is STM32.Short; -- injected data register x type JDR_Register is record -- Read-only. Injected data JDATA : JDR1_JDATA_Field; -- unspecified Reserved_16_31 : STM32.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JDR_Register use record JDATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- DR_Register -- ----------------- subtype DR_DATA_Field is STM32.Short; subtype DR_ADC2DATA_Field is STM32.Short; -- regular data register type DR_Register is record -- Read-only. Regular data DATA : DR_DATA_Field; -- Read-only. ADC2 data ADC2DATA : DR_ADC2DATA_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DATA at 0 range 0 .. 15; ADC2DATA at 0 range 16 .. 31; end record; ------------------ -- CR1_Register -- ------------------ -- control register 1 type CR1_Register_1 is record -- Analog watchdog channel select bits AWDCH : CR1_AWDCH_Field := 16#0#; -- Interrupt enable for EOC EOCIE : CR1_EOCIE_Field := 16#0#; -- Analog watchdog interrupt enable AWDIE : CR1_AWDIE_Field := 16#0#; -- Interrupt enable for injected channels JEOCIE : CR1_JEOCIE_Field := 16#0#; -- Scan mode SCAN : CR1_SCAN_Field := 16#0#; -- Enable the watchdog on a single channel in scan mode AWDSGL : CR1_AWDSGL_Field := 16#0#; -- Automatic injected group conversion JAUTO : CR1_JAUTO_Field := 16#0#; -- Discontinuous mode on regular channels DISCEN : CR1_DISCEN_Field := 16#0#; -- Discontinuous mode on injected channels JDISCEN : CR1_JDISCEN_Field := 16#0#; -- Discontinuous mode channel count DISCNUM : CR1_DISCNUM_Field := 16#0#; -- unspecified Reserved_16_21 : STM32.UInt6 := 16#0#; -- Analog watchdog enable on injected channels JAWDEN : CR1_JAWDEN_Field := 16#0#; -- Analog watchdog enable on regular channels AWDEN : CR1_AWDEN_Field := 16#0#; -- unspecified Reserved_24_31 : STM32.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register_1 use record AWDCH at 0 range 0 .. 4; EOCIE at 0 range 5 .. 5; AWDIE at 0 range 6 .. 6; JEOCIE at 0 range 7 .. 7; SCAN at 0 range 8 .. 8; AWDSGL at 0 range 9 .. 9; JAUTO at 0 range 10 .. 10; DISCEN at 0 range 11 .. 11; JDISCEN at 0 range 12 .. 12; DISCNUM at 0 range 13 .. 15; Reserved_16_21 at 0 range 16 .. 21; JAWDEN at 0 range 22 .. 22; AWDEN at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ----------------- -- DR_Register -- ----------------- -- regular data register type DR_Register_1 is record -- Read-only. Regular data DATA : DR_DATA_Field; -- unspecified Reserved_16_31 : STM32.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register_1 use record DATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Analog to digital converter type ADC1_Peripheral is record -- status register SR : SR_Register; -- control register 1 CR1 : CR1_Register; -- control register 2 CR2 : CR2_Register; -- sample time register 1 SMPR1 : SMPR1_Register; -- sample time register 2 SMPR2 : SMPR2_Register; -- injected channel data offset register x JOFR1 : JOFR1_Register; -- injected channel data offset register x JOFR2 : JOFR2_Register; -- injected channel data offset register x JOFR3 : JOFR3_Register; -- injected channel data offset register x JOFR4 : JOFR4_Register; -- watchdog higher threshold register HTR : HTR_Register; -- watchdog lower threshold register LTR : LTR_Register; -- regular sequence register 1 SQR1 : SQR1_Register; -- regular sequence register 2 SQR2 : SQR2_Register; -- regular sequence register 3 SQR3 : SQR3_Register; -- injected sequence register JSQR : JSQR_Register; -- injected data register x JDR1 : JDR_Register; -- injected data register x JDR2 : JDR_Register; -- injected data register x JDR3 : JDR_Register; -- injected data register x JDR4 : JDR_Register; -- regular data register DR : DR_Register; end record with Volatile; for ADC1_Peripheral use record SR at 0 range 0 .. 31; CR1 at 4 range 0 .. 31; CR2 at 8 range 0 .. 31; SMPR1 at 12 range 0 .. 31; SMPR2 at 16 range 0 .. 31; JOFR1 at 20 range 0 .. 31; JOFR2 at 24 range 0 .. 31; JOFR3 at 28 range 0 .. 31; JOFR4 at 32 range 0 .. 31; HTR at 36 range 0 .. 31; LTR at 40 range 0 .. 31; SQR1 at 44 range 0 .. 31; SQR2 at 48 range 0 .. 31; SQR3 at 52 range 0 .. 31; JSQR at 56 range 0 .. 31; JDR1 at 60 range 0 .. 31; JDR2 at 64 range 0 .. 31; JDR3 at 68 range 0 .. 31; JDR4 at 72 range 0 .. 31; DR at 76 range 0 .. 31; end record; -- Analog to digital converter ADC1_Periph : aliased ADC1_Peripheral with Import, Address => ADC1_Base; -- Analog to digital converter type ADC2_Peripheral is record -- status register SR : SR_Register; -- control register 1 CR1 : CR1_Register_1; -- control register 2 CR2 : CR2_Register; -- sample time register 1 SMPR1 : SMPR1_Register; -- sample time register 2 SMPR2 : SMPR2_Register; -- injected channel data offset register x JOFR1 : JOFR1_Register; -- injected channel data offset register x JOFR2 : JOFR2_Register; -- injected channel data offset register x JOFR3 : JOFR3_Register; -- injected channel data offset register x JOFR4 : JOFR4_Register; -- watchdog higher threshold register HTR : HTR_Register; -- watchdog lower threshold register LTR : LTR_Register; -- regular sequence register 1 SQR1 : SQR1_Register; -- regular sequence register 2 SQR2 : SQR2_Register; -- regular sequence register 3 SQR3 : SQR3_Register; -- injected sequence register JSQR : JSQR_Register; -- injected data register x JDR1 : JDR_Register; -- injected data register x JDR2 : JDR_Register; -- injected data register x JDR3 : JDR_Register; -- injected data register x JDR4 : JDR_Register; -- regular data register DR : DR_Register_1; end record with Volatile; for ADC2_Peripheral use record SR at 0 range 0 .. 31; CR1 at 4 range 0 .. 31; CR2 at 8 range 0 .. 31; SMPR1 at 12 range 0 .. 31; SMPR2 at 16 range 0 .. 31; JOFR1 at 20 range 0 .. 31; JOFR2 at 24 range 0 .. 31; JOFR3 at 28 range 0 .. 31; JOFR4 at 32 range 0 .. 31; HTR at 36 range 0 .. 31; LTR at 40 range 0 .. 31; SQR1 at 44 range 0 .. 31; SQR2 at 48 range 0 .. 31; SQR3 at 52 range 0 .. 31; JSQR at 56 range 0 .. 31; JDR1 at 60 range 0 .. 31; JDR2 at 64 range 0 .. 31; JDR3 at 68 range 0 .. 31; JDR4 at 72 range 0 .. 31; DR at 76 range 0 .. 31; end record; -- Analog to digital converter ADC2_Periph : aliased ADC2_Peripheral with Import, Address => ADC2_Base; end STM32.ADC;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 1 2 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Inline; use Inline; with Types; use Types; package Sem_Ch12 is procedure Analyze_Generic_Package_Declaration (N : Node_Id); procedure Analyze_Generic_Subprogram_Declaration (N : Node_Id); procedure Analyze_Package_Instantiation (N : Node_Id); procedure Analyze_Procedure_Instantiation (N : Node_Id); procedure Analyze_Function_Instantiation (N : Node_Id); procedure Analyze_Formal_Object_Declaration (N : Node_Id); procedure Analyze_Formal_Type_Declaration (N : Node_Id); procedure Analyze_Formal_Subprogram_Declaration (N : Node_Id); procedure Analyze_Formal_Package_Declaration (N : Node_Id); procedure Add_Pending_Instantiation (Inst : Node_Id; Act_Decl : Node_Id); -- Add an entry in the table of instance bodies that must be analyzed -- when inlining requires its body or the body of a nested instance. function Build_Function_Wrapper (Formal_Subp : Entity_Id; Actual_Subp : Entity_Id) return Node_Id; -- In GNATprove mode, create a wrapper function for actuals that are -- functions with any number of formal parameters, in order to propagate -- their contract to the renaming declarations generated for them. This -- is called after the renaming declaration created for the formal in the -- instance has been analyzed, and the actual is known. function Build_Operator_Wrapper (Formal_Subp : Entity_Id; Actual_Subp : Entity_Id) return Node_Id; -- In GNATprove mode, create a wrapper function for actuals that are -- operators, in order to propagate their contract to the renaming -- declarations generated for them. The types are (the instances of) -- the types of the formal subprogram. procedure Start_Generic; -- Must be invoked before starting to process a generic spec or body procedure End_Generic; -- Must be invoked just at the end of the end of the processing of a -- generic spec or body. procedure Check_Generic_Child_Unit (Gen_Id : Node_Id; Parent_Installed : in out Boolean); -- If the name of the generic unit in an instantiation or a renaming is a -- selected component, then the prefix may be an instance and the selector -- may designate a child unit. Retrieve the parent generic and search for -- the child unit that must be declared within. Similarly, if this is the -- name of a generic child unit within an instantiation of its own parent, -- retrieve the parent generic. If the parent is installed as a result of -- this call, then Parent_Installed is set True, otherwise Parent_Installed -- is unchanged by the call. function Copy_Generic_Node (N : Node_Id; Parent_Id : Node_Id; Instantiating : Boolean) return Node_Id; -- Copy the tree for a generic unit or its body. The unit is copied -- repeatedly: once to produce a copy on which semantic analysis of -- the generic is performed, and once for each instantiation. The tree -- being copied is not semantically analyzed, except that references to -- global entities are marked on terminal nodes. Note that this function -- copies any aspect specifications from the input node N to the returned -- node, as well as the setting of the Has_Aspects flag. function Get_Instance_Of (A : Entity_Id) return Entity_Id; -- Retrieve actual associated with given generic parameter. -- If A is uninstantiated or not a generic parameter, return A. function Get_Package_Instantiation_Node (A : Entity_Id) return Node_Id; -- Given the entity of a unit that is an instantiation, retrieve the -- original instance node. This is used when loading the instantiations -- of the ancestors of a child generic that is being instantiated. procedure Instantiate_Package_Body (Body_Info : Pending_Body_Info; Inlined_Body : Boolean := False; Body_Optional : Boolean := False); -- Called after semantic analysis, to complete the instantiation of -- package instances. The flag Inlined_Body is set if the body is -- being instantiated on the fly for inlining purposes. -- -- The flag Body_Optional indicates that the call is for an instance -- that precedes the current instance in the same declarative part. -- This call is needed when instantiating a nested generic whose body -- is to be found in the body of an instance. Normally we instantiate -- package bodies only when they appear in the main unit, or when their -- contents are needed for a nested generic G. If unit U contains several -- instances I1, I2, etc. and I2 contains a nested generic, then when U -- appears in the context of some other unit P that contains an instance -- of G, we compile the body of I2, but not that of I1. However, when we -- compile U as the main unit, we compile both bodies. This will lead to -- link-time errors if the compilation of I1 generates public symbols, -- because those in I2 will receive different names in both cases. This -- forces us to analyze the body of I1 even when U is not the main unit. -- We don't want this additional mechanism to generate an error when the -- body of the generic for I1 is not present, and this is the reason for -- the presence of the flag Body_Optional, which is exchanged between the -- current procedure and Load_Parent_Of_Generic. procedure Instantiate_Subprogram_Body (Body_Info : Pending_Body_Info; Body_Optional : Boolean := False); -- Called after semantic analysis, to complete the instantiation of -- function and procedure instances. The flag Body_Optional has the -- same purpose as described for Instantiate_Package_Body. function Need_Subprogram_Instance_Body (N : Node_Id; Subp : Entity_Id) return Boolean; -- If a subprogram instance is inlined, indicate that the body of it -- must be created, to be used in inlined calls by the back-end. The -- subprogram may be inlined because the generic itself carries the -- pragma, or because a pragma appears for the instance in the scope. -- of the instance. procedure Save_Global_References (Templ : Node_Id); -- Traverse the original generic unit, and capture all references to -- entities that are defined outside of the generic in the analyzed tree -- for the template. These references are copied into the original tree, -- so that they appear automatically in every instantiation. A critical -- invariant in this approach is that if an id in the generic resolves to -- a local entity, the corresponding id in the instance will resolve to -- the homologous entity in the instance, even though the enclosing context -- for resolution is different, as long as the global references have been -- captured as described here. -- Because instantiations can be nested, the environment of the instance, -- involving the actuals and other data-structures, must be saved and -- restored in stack-like fashion. Front-end inlining also uses these -- structures for the management of private/full views. procedure Save_Global_References_In_Aspects (N : Node_Id); -- Save all global references found within the expressions of all aspects -- that appear on node N. procedure Set_Copied_Sloc_For_Inlined_Body (N : Node_Id; E : Entity_Id); -- This procedure is used when a subprogram body is inlined. This process -- shares the same circuitry as the creation of an instantiated copy of -- a generic template. The call to this procedure establishes a new source -- file entry representing the inlined body as an instantiation, marked as -- an inlined body (so that errout can distinguish cases for generating -- error messages, otherwise the treatment is identical). In this call -- N is the subprogram body and E is the defining identifier of the -- subprogram in question. The resulting Sloc adjustment factor is -- saved as part of the internal state of the Sem_Ch12 package for use -- in subsequent calls to copy nodes. procedure Set_Copied_Sloc_For_Inherited_Pragma (N : Node_Id; E : Entity_Id); -- This procedure is used when a class-wide pre- or postcondition is -- inherited. This process shares the same circuitry as the creation of -- an instantiated copy of a generic template. The call to this procedure -- establishes a new source file entry representing the inherited pragma -- as an instantiation, marked as an inherited pragma (so that errout can -- distinguish cases for generating error messages, otherwise the treatment -- is identical). In this call, N is the subprogram declaration from -- which the pragma is inherited and E is the defining identifier of -- the overriding subprogram (when the subprogram is redefined) or the -- defining identifier of the extension type (when the subprogram is -- inherited). The resulting Sloc adjustment factor is saved as part of the -- internal state of the Sem_Ch12 package for use in subsequent calls to -- copy nodes. procedure Adjust_Inherited_Pragma_Sloc (N : Node_Id); -- This procedure is used when a class-wide pre- or postcondition -- is inherited. It is called on each node of the pragma expression -- to adjust its sloc. These call should be preceded by a call to -- Set_Copied_Sloc_For_Inherited_Pragma that sets the required sloc -- adjustment. This is done directly, instead of using Copy_Generic_Node -- to copy nodes and adjust slocs, as Copy_Generic_Node expects a specific -- structure to be in place, which is not the case for inherited pragmas. procedure Save_Env (Gen_Unit : Entity_Id; Act_Unit : Entity_Id); -- Because instantiations can be nested, the compiler maintains a stack -- of environments that holds variables relevant to the current instance: -- most importanty Instantiated_Parent, Exchanged_Views, Hidden_Entities, -- and others (see full list in Instance_Env). procedure Restore_Env; -- After processing an instantiation, or aborting one because of semantic -- errors, remove the current Instantiation_Env from Instantation_Envs. procedure Initialize; -- Initializes internal data structures procedure Check_Private_View (N : Node_Id); -- Check whether the type of a generic entity has a different view between -- the point of generic analysis and the point of instantiation. If the -- view has changed, then at the point of instantiation we restore the -- correct view to perform semantic analysis of the instance, and reset -- the current view after instantiation. The processing is driven by the -- current private status of the type of the node, and Has_Private_View, -- a flag that is set at the point of generic compilation. If view and -- flag are inconsistent then the type is updated appropriately. -- -- This subprogram is used in Check_Generic_Actuals and Copy_Generic_Node, -- and is exported here for the purpose of front-end inlining (see Exp_Ch6. -- Expand_Inlined_Call.Process_Formals). end Sem_Ch12;
-- Institution: Technische Universität München -- Department: Real-Time Computer Systems (RCS) -- Project: StratoX -- Authors: Martin Becker (becker@rcs.ei.tum.de) with Ada.Real_Time; use Ada.Real_Time; with HIL; use HIL; -- @summary -- SPI protocol to CYPRESS FM25v0x series (ferroelectric RAM, non-volatile) generic MEMSIZE_BYTES : Positive; -- FIXME: introduce datatype to constrain to 65kByte, beause we have 16bit addresses. package FM25v0x with SPARK_Mode -- Abstract_State => State is --MEMSIZE_BYTES : constant := Memory_Size; type Address is new Integer range 0 .. MEMSIZE_BYTES - 1; procedure Init; -- initialize the communication to the FRAM procedure Self_Check (Status : out Boolean); -- run a self-check. -- @return true on success -- @req Subsystem/Init/Selfcheck procedure Read_Byte (addr : Address; byte : out HIL.Byte); -- read a single byte -- @req Subsystem/InvalidRequirement procedure Write_Byte (addr : Address; byte : HIL.Byte); -- with Pre => Is_Init; -- write a single byte private Is_Init : Boolean := False;-- with Part_Of => State; FM25v0x_STARTUP_TIME_MS : constant Time := Time_First + Milliseconds (1); -- datasheet: ~400 usec @3.3V end FM25v0x;
------------------------------------------------------------------------------ -- -- -- J E W L . M E S S A G E _ H A N D L I N G -- -- -- -- This is a private package which defines the message-handling task -- -- required by JEWL.Windows, the protected record used to communicate -- -- with it, and related operations. -- -- -- -- 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-message_handling.ads 1.7 2007/01/08 17:00:00 JE Exp $ ------------------------------------------------------------------------------ -- -- $Log: jewl-message_handling.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.Win32_Interface; use JEWL.Win32_Interface; with JEWL.Window_Implementation; use JEWL.Window_Implementation; with Ada.Exceptions; with System; private package JEWL.Message_Handling is ---------------------------------------------------------------------------- -- -- M E S S A G E _ L O O P -- -- This task is responsible for pumping the Windows message loop. -- Windows requires that all windows are created and destroyed by -- the same task that will handle their messages, so task entries -- are used to ask the message task to create and destroy windows. -- The entries are: -- -- Create_Window : create a top-level window, given the name of the -- window class, the window title, extended and normal -- window styles, and whether the window should be -- made visible. -- Create_Child : create a child window, given the parent window's -- handle, the name of the window class, the window -- title, style, and coordinates. -- Show_Dialog : show a common dialog and return its result. -- Destroy_Window : destroy a window (specified by its handle). -- ---------------------------------------------------------------------------- task Message_Loop is entry Create_Child (Window : in Window_Ptr; Parent : in Container_Ptr; Class : in Win32_String; Title : in Win32_String; XStyle : in Win32_DWORD; Style : in Win32_DWORD; Top : in Integer; Left : in Integer; Width : in Integer; Height : in Integer); entry Create_Window (Window : in Main_Window_Ptr; Class : in Win32_String; Title : in Win32_String; XStyle : in Win32_DWORD; Style : in Win32_DWORD; Show : in Boolean); entry Show_Dialog (Dialog : in Common_Dialog_Ptr; Result : out Boolean); entry Set_Focus (Window : in Win32_HWND); entry Destroy_Window (Handle : in Win32_HWND); end Message_Loop; ---------------------------------------------------------------------------- -- -- W I N D O W _ I N F O -- -- This protected record is used for global communication between the -- message loop task and the main task. The private data this contains -- is as follows: -- -- Command : the current command code (0 if no command available) -- Dialog : the current active dialog (null if no dialog active) -- Task_Failed : True if the message loop task has failed -- Failure_Info : the exception that caused the message loop to fail -- -- The operations provide are as follows: -- -- Get_Command : wait for a command and then return its code -- Test_Command : test if there is a command pending -- Set_Command : set the current command -- Get_Dialog : get the handle of the current dialog (null if none) -- Active_Window : set the handle of the active dialog window and get -- the old value of the handle -- Record_Error : record an exception that caused the message loop -- to fail -- ---------------------------------------------------------------------------- protected Window_Info is entry Get_Command (Cmd : out Natural); function Test_Command return Boolean; procedure Set_Command (Cmd : in Natural); procedure Get_Dialog (Dlg : in out Win32_HWND); function Active_Window return Win32_HWND; procedure Record_Error (Err : in Ada.Exceptions.Exception_Occurrence); private Command : Natural := 0; Dialog : Win32_HWND := System.Null_Address; Task_Failed : Boolean := False; Failure_Info : Ada.Exceptions.Exception_Occurrence; end Window_Info; ---------------------------------------------------------------------------- -- -- M E S S A G E H A N D L E R S -- -- These functions are associated with the window classes for frames, -- dialogs and canvases when the window classes are registered (in the -- initialisation section at the end of the body of JEWL.Windows). -- Windows will call the appropriate function when a message is sent -- to a window belonging to the corresponding class, specifying the -- window handle, message code and any additional parameters. -- ---------------------------------------------------------------------------- function Frame_Proc (hwnd : Win32_HWND; msg : Win32_UINT; wParam : Win32_WPARAM; lParam : Win32_LPARAM) return Win32_LONG; pragma Convention(StdCall, Frame_Proc); function Dialog_Proc (hwnd : Win32_HWND; msg : Win32_UINT; wParam : Win32_WPARAM; lParam : Win32_LPARAM) return Win32_LONG; pragma Convention(StdCall, Dialog_Proc); function Canvas_Proc (hwnd : Win32_HWND; msg : Win32_UINT; wParam : Win32_WPARAM; lParam : Win32_LPARAM) return Win32_LONG; pragma Convention(StdCall, Canvas_Proc); function Panel_Proc (hwnd : Win32_HWND; msg : Win32_UINT; wParam : Win32_WPARAM; lParam : Win32_LPARAM) return Win32_LONG; pragma Convention(StdCall, Panel_Proc); function Memo_Proc (hwnd : Win32_HWND; msg : Win32_UINT; wParam : Win32_WPARAM; lParam : Win32_LPARAM) return Win32_LONG; pragma Convention(StdCall, Memo_Proc); ---------------------------------------------------------------------------- -- -- U T I L I T Y P R O C E D U R E S -- -- Get_Actual_Bounds : test if a set of window dimensions is relative to -- the dimensions of the parent. If they are, set the -- Resize parameter True and set the dimensions to -- the corresponding absolute (parent-based) values. -- ---------------------------------------------------------------------------- procedure Get_Actual_Bounds (Parent : in Win32_HWND; Top : in out Integer; Left : in out Integer; Width : in out Integer; Height : in out Integer; Resize : out Boolean); end JEWL.Message_Handling;
----------------------------------------------------------------------- -- util-beans-ranges-tests -- Unit tests for bean range definitions -- Copyright (C) 2011 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; package body Util.Beans.Ranges.Tests is use Util.Tests; package Caller is new Util.Test_Caller (Test, "Objects.Records"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Beans.Ranges.Create", Test_Range'Access); Caller.Add_Test (Suite, "Test Util.Beans.Ranges.Iterate", Test_Iterate_Range'Access); end Add_Tests; -- ------------------------------ -- Test the creation and range definition. -- ------------------------------ procedure Test_Range (T : in out Test) is C : Integer_Ranges.Range_Bean := Integer_Ranges.Create (1, 10); begin Assert_Equals (T, 1, C.Get_First, "Invalid first range value"); Assert_Equals (T, 10, C.Get_Last, "Invalid first range value"); Assert_Equals (T, 10, C.Get_Count, "Invalid range count"); C := Integer_Ranges.Create (10, 10); Assert_Equals (T, 10, C.Get_First, "Invalid first range value"); Assert_Equals (T, 10, C.Get_Last, "Invalid first range value"); Assert_Equals (T, 1, C.Get_Count, "Invalid range count"); end Test_Range; -- ------------------------------ -- Test iterating over a range definition. -- ------------------------------ procedure Test_Iterate_Range (T : in out Test) is use Util.Beans.Objects; C : aliased Integer_Ranges.Range_Bean := Integer_Ranges.Create (-3, 10); List : constant Basic.List_Bean_Access := C'Unchecked_Access; Value : Util.Beans.Objects.Object; begin for I in 1 .. List.Get_Count loop List.Set_Row_Index (I); Value := List.Get_Row; Assert (T, not Util.Beans.Objects.Is_Null (Value), "Null row returned"); Assert (T, Util.Beans.Objects.Get_Type (Value) = Util.Beans.Objects.TYPE_INTEGER, "Invalid value type"); Assert_Equals (T, -3 + Integer (I - 1), To_Integer (Value), "Invalid value"); end loop; end Test_Iterate_Range; end Util.Beans.Ranges.Tests;
----------------------------------------------------------------------- -- util-streams-raw -- Raw streams for Unix based systems -- Copyright (C) 2011, 2013, 2016, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; package body Util.Streams.Pipes is -- ----------------------- -- Set the shell executable path to use to launch a command. The default on Unix is -- the /bin/sh command. Argument splitting is done by the /bin/sh -c command. -- When setting an empty shell command, the argument splitting is done by the -- <tt>Spawn</tt> procedure. -- ----------------------- procedure Set_Shell (Stream : in out Pipe_Stream; Shell : in String) is begin Util.Processes.Set_Shell (Stream.Proc, Shell); end Set_Shell; -- ----------------------- -- Before launching the process, redirect the input stream of the process -- to the specified file. -- Raises <b>Invalid_State</b> if the process is running. -- ----------------------- procedure Set_Input_Stream (Stream : in out Pipe_Stream; File : in String) is begin Util.Processes.Set_Input_Stream (Stream.Proc, File); end Set_Input_Stream; -- ----------------------- -- Set the output stream of the process. -- Raises <b>Invalid_State</b> if the process is running. -- ----------------------- procedure Set_Output_Stream (Stream : in out Pipe_Stream; File : in String; Append : in Boolean := False) is begin Util.Processes.Set_Output_Stream (Stream.Proc, File, Append); end Set_Output_Stream; -- ----------------------- -- Set the error stream of the process. -- Raises <b>Invalid_State</b> if the process is running. -- ----------------------- procedure Set_Error_Stream (Stream : in out Pipe_Stream; File : in String; Append : in Boolean := False) is begin Util.Processes.Set_Error_Stream (Stream.Proc, File, Append); end Set_Error_Stream; -- ----------------------- -- Closes the given file descriptor in the child process before executing the command. -- ----------------------- procedure Add_Close (Stream : in out Pipe_Stream; Fd : in Util.Processes.File_Type) is begin Util.Processes.Add_Close (Stream.Proc, Fd); end Add_Close; -- ----------------------- -- Set the working directory that the process will use once it is created. -- The directory must exist or the <b>Invalid_Directory</b> exception will be raised. -- ----------------------- procedure Set_Working_Directory (Stream : in out Pipe_Stream; Path : in String) is begin Util.Processes.Set_Working_Directory (Stream.Proc, Path); end Set_Working_Directory; -- ----------------------- -- Open a pipe to read or write to an external process. The pipe is created and the -- command is executed with the input and output streams redirected through the pipe. -- ----------------------- procedure Open (Stream : in out Pipe_Stream; Command : in String; Mode : in Pipe_Mode := READ) is begin Util.Processes.Spawn (Stream.Proc, Command, Mode); end Open; -- ----------------------- -- Close the pipe and wait for the external process to terminate. -- ----------------------- overriding procedure Close (Stream : in out Pipe_Stream) is begin Util.Processes.Wait (Stream.Proc); end Close; -- ----------------------- -- Get the process exit status. -- ----------------------- function Get_Exit_Status (Stream : in Pipe_Stream) return Integer is begin return Util.Processes.Get_Exit_Status (Stream.Proc); end Get_Exit_Status; -- ----------------------- -- Returns True if the process is running. -- ----------------------- function Is_Running (Stream : in Pipe_Stream) return Boolean is begin return Util.Processes.Is_Running (Stream.Proc); end Is_Running; -- ----------------------- -- Write the buffer array to the output stream. -- ----------------------- overriding procedure Write (Stream : in out Pipe_Stream; Buffer : in Ada.Streams.Stream_Element_Array) is Output : constant Streams.Output_Stream_Access := Processes.Get_Input_Stream (Stream.Proc); begin if Output = null then raise Ada.IO_Exceptions.Status_Error with "Process is not launched"; end if; Output.Write (Buffer); end Write; -- ----------------------- -- Read into the buffer as many bytes as possible and return in -- <b>last</b> the position of the last byte read. -- ----------------------- overriding procedure Read (Stream : in out Pipe_Stream; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Input : constant Streams.Input_Stream_Access := Processes.Get_Output_Stream (Stream.Proc); begin if Input = null then raise Ada.IO_Exceptions.Status_Error with "Process is not launched"; end if; Input.Read (Into, Last); end Read; -- ----------------------- -- Flush the stream and release the buffer. -- ----------------------- overriding procedure Finalize (Object : in out Pipe_Stream) is begin null; end Finalize; end Util.Streams.Pipes;
------------------------------------------------------------------------------ -- -- -- ASIS APPLICATION TEMPLATE COMPONENTS -- -- -- -- C O N T E X T _ P R O C E S S I N G -- -- -- -- S p e c -- -- -- -- Copyright (c) 2000, Free Software Foundation, Inc. -- -- -- -- ASIS Application Templates are free software; you can redistribute it -- -- and/or modify it under terms of the GNU General Public License as -- -- published by the Free Software Foundation; either version 2, or (at your -- -- option) any later version. ASIS Application Templates are distributed in -- -- the hope that they will be useful, but WITHOUT ANY WARRANTY; without -- -- even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- -- PURPOSE. See the GNU General Public License for more details. You should -- -- have received a copy of the GNU General Public License distributed with -- -- distributed with GNAT; see file COPYING. If not, write to the Free -- -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -- -- USA. -- -- -- -- ASIS Application Templates were developed and are now maintained by Ada -- -- Core Technologies Inc (http://www.gnat.com). -- -- -- ------------------------------------------------------------------------------ -- This package contains routines for high-level processing of -- (terating through) an ASIS Context with Asis; package Context_Processing is procedure Process_Context (The_Context : Asis.Context; Trace : Boolean := False; Output_Path : String); -- This procedure iterates through the whole content of its argument -- Context and it calls a unit processing routine for those ASIS -- Compilation Units which are of An_Application_Unit origin (that is, -- user-defined units). If Trace parameter is set ON, it generate the -- simple trace of the unit processing (consisting of the names of the -- units in the Context being processed or skipped). end Context_Processing;
-- Copyright (c) 2015-2017 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Matreshka.Internals.Unicode; generic with function To_Class (Value : Matreshka.Internals.Unicode.Code_Point) return Character_Class; with function Switch (S : State; Class : Character_Class) return State; with function Rule (S : State) return Rule_Index; First_Final : State; Last_Looping : State; Error_State : State; package Incr.Lexers.Batch_Lexers.Generic_Lexers is -- @summary -- Generic Batch Lexer -- -- @description -- This is an implementation of batch lexical analyser. It gets functions -- generated by uaflex as tables subunut. type Batch_Lexer is new Batch_Lexers.Batch_Lexer with null record; overriding procedure Get_Token (Self : access Batch_Lexer; Result : out Rule_Index); end Incr.Lexers.Batch_Lexers.Generic_Lexers;
-- RUN: %llvmgcc -c %s procedure Array_Ref is type A is array (Natural range <>, Natural range <>) of Boolean; type A_Access is access A; function Get (X : A_Access) return Boolean is begin return X (0, 0); end; begin null; end;
with vole_lex_dfa; use vole_lex_dfa; with text_io; use text_io; package vole_lex_io is user_input_file : file_type; user_output_file : file_type; NULL_IN_INPUT : exception; AFLEX_INTERNAL_ERROR : exception; UNEXPECTED_LAST_MATCH : exception; PUSHBACK_OVERFLOW : exception; AFLEX_SCANNER_JAMMED : exception; type eob_action_type is ( EOB_ACT_RESTART_SCAN, EOB_ACT_END_OF_FILE, EOB_ACT_LAST_MATCH ); YY_END_OF_BUFFER_CHAR : constant character:= ASCII.NUL; yy_n_chars : integer; -- number of characters read into yy_ch_buf -- true when we've seen an EOF for the current input file yy_eof_has_been_seen : boolean; procedure YY_INPUT(buf: out unbounded_character_array; result: out integer; max_size: in integer); function yy_get_next_buffer return eob_action_type; procedure yyunput( c : character; yy_bp: in out integer ); procedure unput(c : character); function input return character; procedure output(c : character); function yywrap return boolean; procedure Open_Input(fname : in String); procedure Close_Input; procedure Create_Output(fname : in String := ""); procedure Close_Output; end vole_lex_io;
-- Project: StratoX -- Authors: Emanuel Regnath (emanuel.regnath@tum.de) -- Martin Becker (becker@rcs.ei.tum.de) -- -- Description: -- allows logging of structured messages at several logging levels. -- -- Usage: -- Logger.init -- initializes the Logger -- Logger.log_console (Logger.INFO, "Program started.") -- writes log on info level to console -- Logger.log_sd (Logger.INFO, gps_msg) -- writes GPS record to SD card with ULog; -- @summary Simultaneously writes to UART, and SD card. -- Write to SD card is done via a queue and a background task, -- becauuse it can be slow. package Logger with SPARK_Mode, Abstract_State => (LogState with External) -- we need a state here because log() needs Global aspect -- since protected object is part of the state, and p.o. is -- by definition synchronous and synchronous objects are -- by definition external, we need to mark it as such is type Log_Level is (SENSOR, ERROR, WARN, INFO, DEBUG, TRACE); type Init_Error_Code is (SUCCESS, ERROR); subtype Message_Type is String; procedure Init (status : out Init_Error_Code); procedure log_console (msg_level : Log_Level; message : Message_Type); -- write a new text log message (shown on console, logged to SD) procedure log_sd (msg_level : Log_Level; message : ULog.Message); -- write a new ulog message (not shown on console, logged to SD) procedure Set_Log_Level (level : Log_Level); procedure Start_SDLog; -- start a new logfile on the SD card LOG_QUEUE_LENGTH : constant := 20; private -- FIXME: documentation required package Adapter is procedure init (status : out Init_Error_Code); procedure write (message : Message_Type); end Adapter; end Logger;
----------------------------------------------------------------------- -- asf.servlets.ajax -- AJAX servlet -- Copyright (C) 2011 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.Strings; with EL.Expressions; with EL.Variables; -- -- URI format -- -- /<bean-name>/<method-name>[/<param-name>/<value>] -- -- package body ASF.Servlets.Ajax is -- ------------------------------ -- Ajax Servlet -- ------------------------------ -- Called by the servlet container to indicate to a servlet that the servlet -- is being placed into service. -- ------------------------------ overriding procedure Initialize (Server : in out Ajax_Servlet; Context : in Servlet_Registry'Class) is pragma Unreferenced (Context); Ctx : constant Servlet_Registry_Access := Server.Get_Servlet_Context; begin if Ctx.all in ASF.Applications.Main.Application'Class then Server.App := ASF.Applications.Main.Application'Class (Ctx.all)'Unchecked_Access; end if; end Initialize; -- ------------------------------ -- Called by the server (via the service method) to allow a servlet to handle -- a GET request. -- -- GET requests are not permitted. -- -- Returns 403 error. -- ------------------------------ procedure Do_Get (Server : in Ajax_Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is pragma Unreferenced (Server, Request); begin Response.Send_Error (Error => Responses.SC_FORBIDDEN, Message => "not allowed"); end Do_Get; -- ------------------------------ -- Called by the server (via the service method) to allow a servlet to handle -- a POST request. The HTTP POST method allows the client to send data of unlimited -- length to the Web server a single time and is useful when posting information -- such as credit card numbers. -- -- 1. Split the URI into a bean name, an action method name and a list of parameters. -- 2. Find the bean object in the application (create it if necessary). -- 3. For each parameter, invoke the <b>Set_Value</b> bean method. -- 4. Invoke the bean action method (specified in the second URI component). -- 5. Navigate to the result view according to the action outcome result. -- 6. Execute the navigation (render page, redirect, ... -- -- If an error is found, return SC_NOT_FOUND if an object or method cannot be found. -- ------------------------------ procedure Do_Post (Server : in Ajax_Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is URI : constant String := Request.Get_Path_Info; Pos : constant Natural := Util.Strings.Index (URI, '/', URI'First + 1); Last : Natural; begin if Pos <= URI'First + 1 or else Pos = URI'Last or else URI (URI'First) /= '/' then Response.Send_Error (ASF.Responses.SC_NOT_FOUND, "Invalid URI format"); return; end if; Last := Util.Strings.Index (URI, '/', Pos + 1); if Last = 0 then Last := URI'Last + 1; end if; Server.App.Dispatch (Name => URI (URI'First + 1 .. Pos - 1), Operation => URI (Pos + 1 .. Last - 1), Request => Request, Response => Response, Prepare => null); exception when EL.Expressions.Invalid_Method => Response.Send_Error (ASF.Responses.SC_NOT_FOUND, "Invalid request"); return; when EL.Variables.No_Variable | EL.Expressions.Invalid_Variable => Response.Send_Error (ASF.Responses.SC_NOT_FOUND, "Invalid request"); return; -- -- when others => -- Response.Send_Error (ASF.Responses.SC_INTERNAL_SERVER_ERROR, "Server error"); -- return; end Do_Post; end ASF.Servlets.Ajax;
IDH_network_lights NetPerSec IDH_connection_tab Connection Tab IDH_connection_tab Connection Tab IDH_options_tab Options Tab IDH_stats_tab Stats Tab IDH_colors_tab Colors Tab IDH_glossary Glossary IDH_requirements_and_limitations Requirements and Limitations IDH_configuration Configuration IDH_netpersec_icon NetPerSec's Icon IDH_bits__bytes__and_the_metric_prefixes Bits, Bytes, and the Metric Prefixes
package PolyPaver.Interval is --# function Hull(Low,High : Float) return Float; --# function Contained_In(Object,Subject : Float) return Boolean; end PolyPaver.Interval;
with Libadalang.Analysis; use Libadalang.Analysis; with Rejuvenation.Find_And_Replacer; use Rejuvenation.Find_And_Replacer; with Rejuvenation.Navigation; use Rejuvenation.Navigation; with Rejuvenation.Patterns; use Rejuvenation.Patterns; with Rewriters; use Rewriters; with Rewriters_Sequence; use Rewriters_Sequence; package Rewriters_Find_And_Replace is type Rewriter_Find_And_Replace is new Rewriter with private; overriding function Rewrite (RFR : Rewriter_Find_And_Replace; Node : Ada_Node'Class; Top_Level : Boolean := True) return String; overriding function Rewrite_Context (RFR : Rewriter_Find_And_Replace; Node : Ada_Node'Class) return Ada_Node with Post => Is_Reflexive_Ancestor (Rewrite_Context'Result, Node); function Find_Pattern (RFR : Rewriter_Find_And_Replace) return Pattern; function Replace_Pattern (RFR : Rewriter_Find_And_Replace) return Pattern; function Accept_Match (RFR : Rewriter_Find_And_Replace) return Match_Accepter; -- Note: When rewriting all instances of a particular warning -- detected by your favorite linter, such as GNATcheck and CodePeer, -- you don't have to reimplement the semantic check of that warning -- to accept a match, since -- you can just check whether the location of the found instance occurs -- in the list of reported locations by the linter. function Make_Rewriter_Find_And_Replace (Find_Pattern, Replace_Pattern : Pattern; Accept_Match : Match_Accepter := Accept_All_Matches'Access; Rewriters : Rewriters_Sequence.Vector := Rewriters_Sequence.Empty_Vector) return Rewriter_Find_And_Replace; -- TODO: Enforce compatibility between find and replace pattern private type Rewriter_Find_And_Replace is new Rewriter with record F_Find_Pattern : Pattern; F_Replace_Pattern : Pattern; F_Match_Accepter : Match_Accepter; F_Rewriters : Rewriters_Sequence.Vector; end record; function Find_Pattern (RFR : Rewriter_Find_And_Replace) return Pattern is (RFR.F_Find_Pattern); function Replace_Pattern (RFR : Rewriter_Find_And_Replace) return Pattern is (RFR.F_Replace_Pattern); function Accept_Match (RFR : Rewriter_Find_And_Replace) return Match_Accepter is (RFR.F_Match_Accepter); function Make_Rewriter_Find_And_Replace (Find_Pattern, Replace_Pattern : Pattern; Accept_Match : Match_Accepter := Accept_All_Matches'Access; Rewriters : Rewriters_Sequence.Vector := Rewriters_Sequence.Empty_Vector) return Rewriter_Find_And_Replace is (Rewriter with Find_Pattern, Replace_Pattern, Accept_Match, Rewriters); end Rewriters_Find_And_Replace;
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package RP_SVD.SYSINFO is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CHIP_ID_MANUFACTURER_Field is HAL.UInt12; subtype CHIP_ID_PART_Field is HAL.UInt16; subtype CHIP_ID_REVISION_Field is HAL.UInt4; -- JEDEC JEP-106 compliant chip identifier. type CHIP_ID_Register is record -- Read-only. MANUFACTURER : CHIP_ID_MANUFACTURER_Field; -- Read-only. PART : CHIP_ID_PART_Field; -- Read-only. REVISION : CHIP_ID_REVISION_Field; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CHIP_ID_Register use record MANUFACTURER at 0 range 0 .. 11; PART at 0 range 12 .. 27; REVISION at 0 range 28 .. 31; end record; -- Platform register. Allows software to know what environment it is -- running in. type PLATFORM_Register is record -- Read-only. FPGA : Boolean; -- Read-only. ASIC : Boolean; -- unspecified Reserved_2_31 : HAL.UInt30; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PLATFORM_Register use record FPGA at 0 range 0 .. 0; ASIC at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- type SYSINFO_Peripheral is record -- JEDEC JEP-106 compliant chip identifier. CHIP_ID : aliased CHIP_ID_Register; -- Platform register. Allows software to know what environment it is -- running in. PLATFORM : aliased PLATFORM_Register; -- Git hash of the chip source. Used to identify chip version. GITREF_RP2040 : aliased HAL.UInt32; end record with Volatile; for SYSINFO_Peripheral use record CHIP_ID at 16#0# range 0 .. 31; PLATFORM at 16#4# range 0 .. 31; GITREF_RP2040 at 16#40# range 0 .. 31; end record; SYSINFO_Periph : aliased SYSINFO_Peripheral with Import, Address => SYSINFO_Base; end RP_SVD.SYSINFO;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . C G I . C O O K I E -- -- -- -- B o d y -- -- -- -- Copyright (C) 2000-2005, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; with Ada.Strings.Maps; with Ada.Text_IO; with Ada.Integer_Text_IO; with GNAT.Table; package body GNAT.CGI.Cookie is use Ada; Valid_Environment : Boolean := False; -- This boolean will be set to True if the initialization was fine Header_Sent : Boolean := False; -- Will be set to True when the header will be sent -- Cookie data that has been added type String_Access is access String; type Cookie_Data is record Key : String_Access; Value : String_Access; Comment : String_Access; Domain : String_Access; Max_Age : Natural; Path : String_Access; Secure : Boolean := False; end record; type Key_Value is record Key, Value : String_Access; end record; package Cookie_Table is new Table (Cookie_Data, Positive, 1, 5, 50); -- This is the table to keep all cookies to be sent back to the server package Key_Value_Table is new Table (Key_Value, Positive, 1, 1, 50); -- This is the table to keep all cookies received from the server procedure Check_Environment; pragma Inline (Check_Environment); -- This procedure will raise Data_Error if Valid_Environment is False procedure Initialize; -- Initialize CGI package by reading the runtime environment. This -- procedure is called during elaboration. All exceptions raised during -- this procedure are deferred. ----------------------- -- Check_Environment -- ----------------------- procedure Check_Environment is begin if not Valid_Environment then raise Data_Error; end if; end Check_Environment; ----------- -- Count -- ----------- function Count return Natural is begin return Key_Value_Table.Last; end Count; ------------ -- Exists -- ------------ function Exists (Key : String) return Boolean is begin Check_Environment; for K in 1 .. Key_Value_Table.Last loop if Key_Value_Table.Table (K).Key.all = Key then return True; end if; end loop; return False; end Exists; ---------------------- -- For_Every_Cookie -- ---------------------- procedure For_Every_Cookie is Quit : Boolean; begin Check_Environment; for K in 1 .. Key_Value_Table.Last loop Quit := False; Action (Key_Value_Table.Table (K).Key.all, Key_Value_Table.Table (K).Value.all, K, Quit); exit when Quit; end loop; end For_Every_Cookie; ---------------- -- Initialize -- ---------------- procedure Initialize is HTTP_COOKIE : constant String := Metavariable (CGI.HTTP_Cookie); procedure Set_Parameter_Table (Data : String); -- Parse Data and insert information in Key_Value_Table ------------------------- -- Set_Parameter_Table -- ------------------------- procedure Set_Parameter_Table (Data : String) is procedure Add_Parameter (K : Positive; P : String); -- Add a single parameter into the table at index K. The parameter -- format is "key=value". Count : constant Positive := 1 + Strings.Fixed.Count (Data, Strings.Maps.To_Set (";")); -- Count is the number of parameters in the string. Parameters are -- separated by ampersand character. Index : Positive := Data'First; Sep : Natural; ------------------- -- Add_Parameter -- ------------------- procedure Add_Parameter (K : Positive; P : String) is Equal : constant Natural := Strings.Fixed.Index (P, "="); begin if Equal = 0 then raise Data_Error; else Key_Value_Table.Table (K) := Key_Value'(new String'(Decode (P (P'First .. Equal - 1))), new String'(Decode (P (Equal + 1 .. P'Last)))); end if; end Add_Parameter; -- Start of processing for Set_Parameter_Table begin Key_Value_Table.Set_Last (Count); for K in 1 .. Count - 1 loop Sep := Strings.Fixed.Index (Data (Index .. Data'Last), ";"); Add_Parameter (K, Data (Index .. Sep - 1)); Index := Sep + 2; end loop; -- Add last parameter Add_Parameter (Count, Data (Index .. Data'Last)); end Set_Parameter_Table; -- Start of processing for Initialize begin if HTTP_COOKIE /= "" then Set_Parameter_Table (HTTP_COOKIE); end if; Valid_Environment := True; exception when others => Valid_Environment := False; end Initialize; --------- -- Key -- --------- function Key (Position : Positive) return String is begin Check_Environment; if Position <= Key_Value_Table.Last then return Key_Value_Table.Table (Position).Key.all; else raise Cookie_Not_Found; end if; end Key; -------- -- Ok -- -------- function Ok return Boolean is begin return Valid_Environment; end Ok; ---------------- -- Put_Header -- ---------------- procedure Put_Header (Header : String := Default_Header; Force : Boolean := False) is procedure Output_Cookies; -- Iterate through the list of cookies to be sent to the server -- and output them. -------------------- -- Output_Cookies -- -------------------- procedure Output_Cookies is procedure Output_One_Cookie (Key : String; Value : String; Comment : String; Domain : String; Max_Age : Natural; Path : String; Secure : Boolean); -- Output one cookie in the CGI header ----------------------- -- Output_One_Cookie -- ----------------------- procedure Output_One_Cookie (Key : String; Value : String; Comment : String; Domain : String; Max_Age : Natural; Path : String; Secure : Boolean) is begin Text_IO.Put ("Set-Cookie: "); Text_IO.Put (Key & '=' & Value); if Comment /= "" then Text_IO.Put ("; Comment=" & Comment); end if; if Domain /= "" then Text_IO.Put ("; Domain=" & Domain); end if; if Max_Age /= Natural'Last then Text_IO.Put ("; Max-Age="); Integer_Text_IO.Put (Max_Age, Width => 0); end if; if Path /= "" then Text_IO.Put ("; Path=" & Path); end if; if Secure then Text_IO.Put ("; Secure"); end if; Text_IO.New_Line; end Output_One_Cookie; -- Start of processing for Output_Cookies begin for C in 1 .. Cookie_Table.Last loop Output_One_Cookie (Cookie_Table.Table (C).Key.all, Cookie_Table.Table (C).Value.all, Cookie_Table.Table (C).Comment.all, Cookie_Table.Table (C).Domain.all, Cookie_Table.Table (C).Max_Age, Cookie_Table.Table (C).Path.all, Cookie_Table.Table (C).Secure); end loop; end Output_Cookies; -- Start of processing for Put_Header begin if Header_Sent = False or else Force then Check_Environment; Text_IO.Put_Line (Header); Output_Cookies; Text_IO.New_Line; Header_Sent := True; end if; end Put_Header; --------- -- Set -- --------- procedure Set (Key : String; Value : String; Comment : String := ""; Domain : String := ""; Max_Age : Natural := Natural'Last; Path : String := "/"; Secure : Boolean := False) is begin Cookie_Table.Increment_Last; Cookie_Table.Table (Cookie_Table.Last) := Cookie_Data'(new String'(Key), new String'(Value), new String'(Comment), new String'(Domain), Max_Age, new String'(Path), Secure); end Set; ----------- -- Value -- ----------- function Value (Key : String; Required : Boolean := False) return String is begin Check_Environment; for K in 1 .. Key_Value_Table.Last loop if Key_Value_Table.Table (K).Key.all = Key then return Key_Value_Table.Table (K).Value.all; end if; end loop; if Required then raise Cookie_Not_Found; else return ""; end if; end Value; function Value (Position : Positive) return String is begin Check_Environment; if Position <= Key_Value_Table.Last then return Key_Value_Table.Table (Position).Value.all; else raise Cookie_Not_Found; end if; end Value; -- Elaboration code for package begin -- Initialize unit by reading the HTTP_COOKIE metavariable and fill -- Key_Value_Table structure. Initialize; end GNAT.CGI.Cookie;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Message is -- pragma Pure (Message); Version : constant String := "0.0.1"; UserLoggedIn : Boolean := False; UserLoggedName : Unbounded_String; UserLoggedFullName : Unbounded_String; end Message;
-- Lumen.Image -- Load and save image data -- -- Chip Richards, NiEstu, Phoenix AZ, Spring 2010 -- This code is covered by the ISC License: -- -- Copyright © 2010, NiEstu -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- The software is provided "as is" and the author disclaims all warranties -- with regard to this software including all implied warranties of -- merchantability and fitness. In no event shall the author be liable for any -- special, direct, indirect, or consequential damages or any damages -- whatsoever resulting from loss of use, data or profits, whether in an -- action of contract, negligence or other tortious action, arising out of or -- in connection with the use or performance of this software. -- Environment with Lumen.Binary; package Lumen.Image is --------------------------------------------------------------------------- -- Exceptions added by this package Unknown_Format : exception; -- can't recognize the file's data Invalid_Format : exception; -- thought we did, but encountered bad values --------------------------------------------------------------------------- -- Lumen.Image uses 8-bit RGBA, thank you. -- (red, green, blue, alpha (transparency)). -- One RGBA pixel, an array of them, and some pointers to pixels type Pixel is record R : Binary.Byte; G : Binary.Byte; B : Binary.Byte; A : Binary.Byte; end record; type Pixels is array (Natural range <>) of Pixel; type Pixel_Ptr is access Pixel; type Pixels_Ptr is access Pixels; -- A matrix of RGBA pixels, and a pointer to it type Pixel_Matrix is array (Natural range <>, Natural range <>) of Pixel; type Pixel_Matrix_Ptr is access Pixel_Matrix; -- Two types of image data info records pragma Warnings (Off); -- yes, we know it might be big if declared wrong type Data (Width, Height : Natural := 0) is record Complete : Boolean := False; Values : Pixel_Matrix (1 .. Width, 1 .. Height); end record; pragma Warnings (On); type Descriptor is record Complete : Boolean := False; Width : Natural := 0; Height : Natural := 0; Values : Pixel_Matrix_Ptr := null; end record; --------------------------------------------------------------------------- -- Three fairly useful pixel values Black_Pixel : constant Pixel := (R => Binary.Byte'First, G => Binary.Byte'First, B => Binary.Byte'First, A => Binary.Byte'Last); White_Pixel : constant Pixel := (R => Binary.Byte'Last, G => Binary.Byte'Last, B => Binary.Byte'Last, A => Binary.Byte'Last); Transparent_Pixel : constant Pixel := (R => Binary.Byte'First, G => Binary.Byte'First, B => Binary.Byte'First, A => Binary.Byte'First); --------------------------------------------------------------------------- -- Read image data from a file function From_File (Pathname : String) return Descriptor; --------------------------------------------------------------------------- end Lumen.Image;
----------------------------------------------------------------------- -- awa-permissions -- Permissions module -- Copyright (C) 2011, 2012, 2013, 2014, 2016, 2017, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log.Loggers; with Util.Serialize.Mappers.Record_Mapper; with ADO.Schemas.Entities; with ADO.Sessions.Entities; with Security.Contexts; with AWA.Services.Contexts; with AWA.Permissions.Controllers; package body AWA.Permissions is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Permissions"); -- ------------------------------ -- Verify that the permission represented by <b>Permission</b> is granted. -- ------------------------------ procedure Check (Permission : in Security.Permissions.Permission_Index) is begin if not (Security.Contexts.Has_Permission (Permission)) then raise NO_PERMISSION; end if; end Check; -- ------------------------------ -- Verify that the permission represented by <b>Permission</b> is granted to access the -- database entity represented by <b>Entity</b>. -- ------------------------------ procedure Check (Permission : in Security.Permissions.Permission_Index; Entity : in ADO.Identifier) is use type Security.Contexts.Security_Context_Access; Context : constant Security.Contexts.Security_Context_Access := Security.Contexts.Current; Perm : Entity_Permission (Permission); begin if Context = null then Log.Debug ("Permission is refused because there is no security context"); raise NO_PERMISSION; end if; Perm.Entity := Entity; if not Context.Has_Permission (Perm) then Log.Debug ("Permission is refused by the security controller"); raise NO_PERMISSION; end if; end Check; -- ------------------------------ -- Verify that the permission represented by <b>Permission</b> is granted to access the -- database entity represented by <b>Entity</b>. -- ------------------------------ procedure Check (Permission : in Security.Permissions.Permission_Index; Entity : in ADO.Objects.Object_Ref'Class) is begin if Entity.Is_Null then Log.Debug ("Permission is refused because the entity is null."); raise NO_PERMISSION; end if; Check (Permission, ADO.Objects.Get_Value (Entity.Get_Key)); end Check; type Config_Fields is (FIELD_NAME, FIELD_ENTITY_TYPE, FIELD_ENTITY_PERMISSION, FIELD_SQL, FIELD_GRANT); type Controller_Config_Access is access all Controller_Config; procedure Set_Member (Into : in out Controller_Config; Field : in Config_Fields; Value : in Util.Beans.Objects.Object); -- ------------------------------ -- Called while parsing the XML policy file when the <name>, <entity-type>, <sql> and -- <entity-permission> XML entities are found. Create the new permission when the complete -- permission definition has been parsed and save the permission in the security manager. -- ------------------------------ procedure Set_Member (Into : in out Controller_Config; Field : in Config_Fields; Value : in Util.Beans.Objects.Object) is use AWA.Permissions.Controllers; begin case Field is when FIELD_NAME => Into.Name := Value; when FIELD_SQL => Into.SQL := Value; when FIELD_GRANT => Into.Grant := Value; when FIELD_ENTITY_TYPE => declare Name : constant String := Util.Beans.Objects.To_String (Value); begin if Into.Count = MAX_ENTITY_TYPES then raise Util.Serialize.Mappers.Field_Error with "Too many entity types."; end if; Into.Count := Into.Count + 1; Into.Entities (Into.Count) := ADO.Sessions.Entities.Find_Entity_Type (Into.Session, Name); exception when ADO.Schemas.Entities.No_Entity_Type => raise Util.Serialize.Mappers.Field_Error with "Invalid entity type: " & Name; end; when FIELD_ENTITY_PERMISSION => declare Name : constant String := Util.Beans.Objects.To_String (Into.Name); begin if Into.Count = 0 then raise Util.Serialize.Mappers.Field_Error with "Permission '" & Name & "' ignored: missing entity type"; end if; declare SQL : constant String := Util.Beans.Objects.To_String (Into.SQL); Perm : constant Entity_Controller_Access := new Entity_Controller '(Len => SQL'Length, SQL => SQL, Entities => Into.Entities); begin Into.Manager.Add_Permission (Name, Perm.all'Access); Into.Count := 0; Into.Entities := (others => ADO.NO_ENTITY_TYPE); end; end; end case; end Set_Member; package Config_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => Controller_Config, Element_Type_Access => Controller_Config_Access, Fields => Config_Fields, Set_Member => Set_Member); Perm_Mapper : aliased Config_Mapper.Mapper; -- ------------------------------ -- Setup the XML parser to read the <b>entity-permission</b> description. For example: -- -- <entity-permission> -- <name>create-workspace</name> -- <entity-type>WORKSPACE</entity-type> -- <sql>select acl.id from acl where ...</sql> -- </entity-permission> -- -- This defines a permission <b>create-workspace</b> that will be granted if the -- SQL statement returns a non empty list. -- ------------------------------ -- ------------------------------ -- Get the policy name. -- ------------------------------ overriding function Get_Name (From : in Entity_Policy) return String is pragma Unreferenced (From); begin return NAME; end Get_Name; -- ------------------------------ -- Setup the XML parser to read the <b>policy</b> description. -- ------------------------------ overriding procedure Prepare_Config (Policy : in out Entity_Policy; Mapper : in out Util.Serialize.Mappers.Processing) is Config : constant Controller_Config_Access := Policy.Config'Unchecked_Access; begin Mapper.Add_Mapping ("policy-rules", Perm_Mapper'Access); Mapper.Add_Mapping ("module", Perm_Mapper'Access); Config.Manager := Policy'Unchecked_Access; Config.Session := AWA.Services.Contexts.Get_Session (AWA.Services.Contexts.Current); Config_Mapper.Set_Context (Mapper, Config); end Prepare_Config; begin Perm_Mapper.Add_Mapping ("entity-permission", FIELD_ENTITY_PERMISSION); Perm_Mapper.Add_Mapping ("entity-permission/name", FIELD_NAME); Perm_Mapper.Add_Mapping ("entity-permission/entity-type", FIELD_ENTITY_TYPE); Perm_Mapper.Add_Mapping ("entity-permission/sql", FIELD_SQL); Perm_Mapper.Add_Mapping ("entity-permission/grant", FIELD_GRANT); end AWA.Permissions;
-- (c) Copyright, Real-Time Innovations, $Date:: 2012-02-16 #$ -- All rights reserved. -- -- No duplications, whole or partial, manual or electronic, may be made -- without express written permission. Any such copies, or -- revisions thereof, must display this notice unaltered. -- This code contains trade secrets of Real-Time Innovations, Inc. pragma Ada_05; with RTIDDS.Obj_Impl; with DDS.DomainParticipant; with DDS.DomainParticipantListener; private with RTIDDS.Low_Level.ndds_reda_reda_worker_impl_h; -- <module name="DDSDomainModule" actualName="Domain Module">domain</module> -- <dref>DomainParticipantFactory</dref> package DDS.DomainParticipantFactory is type Ref is new RTIDDS.Obj_Impl.Ref with private; type Ref_Access is access all Ref'Class; PARTICIPANT_QOS_DEFAULT : aliased DDS.DomainParticipantQos; -- <dref>PARTICIPANT_QOS_DEFAULT</dref> function Get_Instance return Ref_Access; -- <dref>DomainParticipantFactory_get_instance</dref> function Create_Participant (Self : not null access Ref; Domain_Id : in DDS.DomainId_T := Default_Domain; Qos : in DDS.DomainParticipantQos := PARTICIPANT_QOS_DEFAULT; A_Listener : in DDS.DomainParticipantListener.Ref_Access := null; Mask : in DDS.StatusMask := DDS.STATUS_MASK_NONE) return DDS.DomainParticipant.Ref_Access; -- <dref>DomainParticipantFactory_create_participant</dref> function Create_Participant_With_Profile (Self : not null access Ref; Domain_Id : in DDS.DomainId_T := Default_Domain; library_name : in DDS.String; profile_name : in DDS.String; A_Listener : in DDS.DomainParticipantListener.Ref_Access := null; Mask : in DDS.StatusMask := DDS.STATUS_MASK_NONE) return DDS.DomainParticipant.Ref_Access; function Create_Participant_With_Profile (Self : not null access Ref; Domain_Id : in DDS.DomainId_T := Default_Domain; library_name : in Standard.String; profile_name : in Standard.String; A_Listener : in DDS.DomainParticipantListener.Ref_Access := null; Mask : in DDS.StatusMask := DDS.STATUS_MASK_NONE) return DDS.DomainParticipant.Ref_Access; -- <dref>DomainParticipantFactory_create_participant_with_profile</dref> function Get_Or_Create_Participant (Self : not null access Ref; Domain_Id : in DDS.DomainId_T := Default_Domain; Qos : in DDS.DomainParticipantQos := DDS.DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT; A_Listener : in DDS.DomainParticipantListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE)return DDS.DomainParticipant.Ref_Access; function Get_Or_Create_Participant_With_Profile (Self : not null access Ref; Domain_Id : in DDS.DomainId_T := Default_Domain; Library_Name : in DDS.String; Profile_Name : in DDS.String; A_Listener : in DDS.DomainParticipantListener.Ref_Access := null; Mask : in DDS.StatusMask := STATUS_MASK_NONE) return DDS.DomainParticipant.Ref_Access; procedure Delete_Participant (Self : not null access Ref; A_Participant : in out DDS.DomainParticipant.Ref_Access); -- <dref>DomainParticipantFactory_delete_participant</dref> function Lookup_Participant (Self : not null access Ref; Domain_Id : in DDS.DomainId_T) return DDS.DomainParticipant.Ref_Access; -- <dref>DomainParticipantFactory_lookup_participant</dref> procedure Set_Default_Participant_Qos (Self : not null access Ref; Qos : in DDS.DomainParticipantQos); -- <dref>DomainParticipantFactory_set_default_participant_qos</dref> procedure Set_Default_Participant_Qos_with_Profile (Self : not null access Ref; libraryName : in DDS.String; profile_name : in DDS.String); -- <dref>DomainParticipantFactory_set_default_participant_qos_with_profile</dref> procedure Get_Default_Participant_Qos (Self : not null access Ref; Qos : in out DDS.DomainParticipantQos); -- <dref>DomainParticipantFactory_get_default_participant_qos</dref> procedure Set_Qos (Self : not null access Ref; Qos : in DDS.DomainParticipantFactoryQos); -- <dref>DomainParticipantFactory_set_qos</dref> -- <internal> -- Sets the value for a participant factory QoS. -- The DDS_DomainParticipantFactoryQos::entity_factory can be changed. The other policies are immutable. -- Note that despite having QoS, the DDS_DomainParticipantFactory is not an DDS_Entity. -- Parameters: -- self <<in>> Cannot be NULL. -- qos <<in>> Set of policies to be applied to DDS_DomainParticipantFactory. Policies must be consistent. -- Immutable Policies Can Only Be Changed Before Calling Any Other -- Data Distribution Service Functions Except for DDS_DomainParticipantFactory_Get_Qos. -- Raises: -- One of the Standard Return Codes, DDS_RETCODE_IMMUTABLE_POLICY if immutable policy is changed, -- or DDS_RETCODE_INCONSISTENT_POLICY if Policies Are Inconsistent -- See also: -- DDS_DomainParticipantFactoryQos for rules on consistency among QoS -- </internal> procedure Load_Profiles (Self : not null access Ref); -- <dref>DomainParticipantFactory_load_profiles</dref> procedure Reload_Profiles (Self : not null access Ref); -- <dref>DomainParticipantFactory_reload_profiles</dref> procedure Unload_Profiles (Self : not null access Ref); -- <dref>DomainParticipantFactory_unload_profiles</dref> procedure Set_Default_Profile (Self : not null access Ref; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_set_default_profile</dref> procedure set_default_library (Self : not null access Ref; library_name : DDS.String); -- <dref>DomainParticipantFactory_set_default_library</dref> function get_default_library (Self : not null access Ref) return DDS.String; -- <dref>DomainParticipantFactory_get_default_library</dref> function get_default_Profile (Self : not null access Ref) return DDS.String; -- <dref>DomainParticipantFactory_get_default_profile</dref> function get_default_profile_library (Self : not null access Ref) return DDS.String; -- <dref>DomainParticipantFactory_get_default_profile_library</dref> procedure get_qos_profile_libraries (Self : not null access Ref; libSeq : not null access DDS.String_Seq.Sequence); function get_qos_profile_libraries (Self : not null access Ref) return DDS.String_Seq.Sequence; -- <dref>DomainParticipantFactory_get_qos_profile_libraries</dref> procedure get_qos_profiles (Self : not null access Ref; profSeq : not null access DDS.String_Seq.Sequence; libName : in DDS.String); function get_qos_profiles (Self : not null access Ref; libName : in DDS.String) return DDS.String_Seq.Sequence; -- <dref>DomainParticipantFactory_get_qos_profiles</dref> ----------------------------------------------------------- procedure get_participant_qos_from_profile (Self : not null access Ref; QoS : in out DDS.DomainParticipantQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_participant_qos_from_profile</dref> ------------------------------------------------------ procedure get_publisher_qos_from_profile (Self : not null access Ref; QoS : in out DDS.PublisherQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_publisher_qos_from_profile</dref> ------------------------------------------------------ procedure get_subscriber_qos_from_profile (Self : not null access Ref; QoS : in out DDS.SubscriberQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_subscriber_qos_from_profile</dref> ------------------------------------------------------ procedure get_datareader_qos_from_profile (Self : not null access Ref; QoS : in out DDS.DataReaderQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_datareader_qos_from_profile</dref> ------------------------------------------------------ procedure get_datareader_qos_from_profile_w_topic_name (Self : not null access Ref; QoS : in out DDS.DataReaderQos; library_name : DDS.String; profile_name : DDS.String; topic_name : DDS.String); -- <dref>DomainParticipantFactory_get_datareader_qos_from_profile_w_topic_name</dref> ------------------------------------------------------ procedure get_datawriter_qos_from_profile (Self : not null access Ref; QoS : in out DDS.DataWriterQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_datawriter_qos_from_profile</dref> ------------------------------------------------------ procedure get_datawriter_qos_from_profile_w_topic_name (Self : not null access Ref; QoS : in out DDS.DataWriterQos; library_name : DDS.String; profile_name : DDS.String; topic_name : DDS.String); -- <dref>DomainParticipantFactory_get_datawriter_qos_from_profile_w_topic_name</dref> ------------------------------------------------------ procedure get_topic_qos_from_profile (Self : not null access Ref; QoS : in out DDS.TopicQos; library_name : DDS.String; profile_name : DDS.String); -- <dref>DomainParticipantFactory_get_topic_qos_from_profile</dref> ------------------------------------------------------ procedure get_topic_qos_from_profile_w_topic_name (Self : not null access Ref; QoS : in out DDS.TopicQos; library_name : DDS.String; profile_name : DDS.String; topic_name : DDS.String); -- <dref>DomainParticipantFactory_get_topic_qos_from_profile_w_topic_name</dref> procedure Get_Qos (Self : not null access Ref; Qos : in out DDS.DomainParticipantFactoryQos); -- <dref>DomainParticipantFactory_get_qos</dref> procedure Finalize_Instance (Self : not null access Ref); -- <dref>DomainParticipantFactory_finalize_instance</dref> procedure Unregister_Thread (Self : not null access Ref); -- <dref>DomainParticipantFactory_unregister_thread</dref> private type Ref is new RTIDDS.Obj_Impl.Ref with null record; protected Initializeer is procedure Initialize; end Initializeer; procedure On_Thread_Started_Callback (OnStartedParam : System.Address; Worker : access RTIDDS.Low_Level.ndds_reda_reda_worker_impl_h.REDAWorker); pragma Convention (C, On_Thread_Started_Callback); procedure On_Thread_Stopped_Callback (OnStartedParam : System.Address; Worker : access RTIDDS.Low_Level.ndds_reda_reda_worker_impl_h.REDAWorker); pragma Convention (C, On_Thread_Stopped_Callback); end DDS.DomainParticipantFactory;
with Ada.Text_IO; use Ada; function Get_Line return String is Line : String (1 .. 256); Last : Natural; I : Positive := 1; Old_Last : Natural; function Is_Legal (C : in Character) return Boolean is begin -- Is_Legal return C in 'A' .. 'Z' or C in 'a' .. 'z' or C in '1' .. '9'; end Is_Legal; begin -- Get_Line Text_IO.Get_Line (Item => Line, Last => Last); Old_Last := Last; Remove_Illegal_Characters : loop exit Remove_Illegal_Characters when I > Last; if Is_Legal (Line (I) ) then I := I + 1; else Last := Last - 1; Line (I .. Last) := Line (I + 1 .. Last + 1); end if; end loop Remove_Illegal_Characters; if Old_Last < Line'Last then return Line (1 .. Last); else return Line (1 .. Last) & Get_Line; end if; end Get_Line;
with Ada.Command_line; use Ada.Command_line; with Ada.Text_IO; use Ada.Text_IO; procedure Yes is begin if Argument_Count >= 1 then while (True) loop Put_Line(Argument(1)); end loop; else while (True) loop Put_Line("y"); end loop; end if; end Yes;
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl> -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with GNAT.Directory_Operations; use GNAT.Directory_Operations; with CArgv; use CArgv; with Tcl; use Tcl; with Tcl.Ada; use Tcl.Ada; with Tcl.Tk.Ada; use Tcl.Tk.Ada; with Tcl.Tk.Ada.Grid; with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets; with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas; with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu; with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow; use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow; with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox; with Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox; use Tcl.Tk.Ada.Widgets.TtkEntry.TtkSpinBox; with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame; with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel; with Tcl.Tk.Ada.Widgets.TtkPanedWindow; use Tcl.Tk.Ada.Widgets.TtkPanedWindow; with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar; with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo; with Bases.Cargo; use Bases.Cargo; with BasesTypes; use BasesTypes; with Config; use Config; with CoreUI; use CoreUI; with Dialogs; use Dialogs; with Events; use Events; with Maps; use Maps; with Maps.UI; use Maps.UI; with Messages; use Messages; with Ships.Cargo; use Ships.Cargo; with Table; use Table; with Utils.UI; use Utils.UI; package body Bases.LootUI is -- ****iv* LUI/LUI.LootTable -- FUNCTION -- Table with info about the available items to loot -- SOURCE LootTable: Table_Widget (5); -- **** -- ****iv* LUI/LUI.Items_Indexes -- FUNCTION -- Indexes of the items for loot -- SOURCE Items_Indexes: Natural_Container.Vector; -- **** -- ****it* LUI/LUI.Items_Sort_Orders -- FUNCTION -- Sorting orders for the looting list -- OPTIONS -- NAMEASC - Sort items by name ascending -- NAMEDESC - Sort items by name descending -- TYPEASC - Sort items by type ascending -- TYPEDESC - Sort items by type descending -- DURABILITYASC - Sort items by durability ascending -- DURABILITYDESC - Sort items by durability descending -- OWNEDASC - Sort items by owned amount ascending -- OWNEDDESC - Sort items by owned amount descending -- AVAILABLEASC - Sort items by available amount ascending -- AVAILABLEDESC - Sort items by available amount descending -- NONE - No sorting modules (default) -- HISTORY -- 6.4 - Added -- SOURCE type Items_Sort_Orders is (NAMEASC, NAMEDESC, TYPEASC, TYPEDESC, DURABILITYASC, DURABILITYDESC, OWNEDASC, OWNEDDESC, AVAILABLEASC, AVAILABLEDESC, NONE) with Default_Value => NONE; -- **** -- ****id* LUI/LUI.Default_Items_Sort_Order -- FUNCTION -- Default sorting order for the looting list -- HISTORY -- 6.4 - Added -- SOURCE Default_Items_Sort_Order: constant Items_Sort_Orders := NONE; -- **** -- ****iv* LUI/LUI.Items_Sort_Order -- FUNCTION -- The current sorting order for the looting list -- HISTORY -- 6.4 - Added -- SOURCE Items_Sort_Order: Items_Sort_Orders := Default_Items_Sort_Order; -- **** -- ****o* LUI/LUI.Show_Loot_Command -- FUNCTION -- Show information about looting -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- ShowLoot -- SOURCE function Show_Loot_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Loot_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData); LootFrame: Ttk_Frame := Get_Widget(Main_Paned & ".lootframe", Interp); LootCanvas: constant Tk_Canvas := Get_Widget(LootFrame & ".canvas", Interp); Label: constant Ttk_Label := Get_Widget(LootCanvas & ".loot.options.typelabel", Interp); ItemDurability, ItemType, ProtoIndex, ItemName: Unbounded_String; ItemsTypes: Unbounded_String := To_Unbounded_String("All"); ComboBox: Ttk_ComboBox; BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; BaseCargo: BaseCargo_Container.Vector; BaseCargoIndex, BaseAmount: Natural; IndexesList: Positive_Container.Vector; Page: constant Positive := (if Argc = 3 then Positive'Value(CArgv.Arg(Argv, 2)) else 1); Start_Row: constant Positive := ((Page - 1) * Game_Settings.Lists_Limit) + 1; Current_Row: Positive := 1; Arguments: constant String := (if Argc > 1 then "{" & CArgv.Arg(Argv, 1) & "}" else "All"); Current_Item_Index: Positive := 1; begin if Winfo_Get(Label, "exists") = "0" then Tcl_EvalFile (Get_Context, To_String(Data_Directory) & "ui" & Dir_Separator & "loot.tcl"); Bind(LootFrame, "<Configure>", "{ResizeCanvas %W.canvas %w %h}"); LootFrame := Get_Widget(LootCanvas & ".loot"); LootTable := CreateTable (Widget_Image(LootFrame), (To_Unbounded_String("Name"), To_Unbounded_String("Type"), To_Unbounded_String("Durability"), To_Unbounded_String("Owned"), To_Unbounded_String("Available")), Get_Widget(".gameframe.paned.lootframe.scrolly", Interp), "SortLootItems", "Press mouse button to sort the items."); elsif Winfo_Get(Label, "ismapped") = "1" and Argc = 1 then Tcl.Tk.Ada.Grid.Grid_Remove(Close_Button); Entry_Configure(GameMenu, "Help", "-command {ShowHelp general}"); ShowSkyMap(True); return TCL_OK; end if; Entry_Configure(GameMenu, "Help", "-command {ShowHelp trade}"); LootFrame.Name := New_String(LootCanvas & ".loot"); ComboBox := Get_Widget(LootFrame & ".options.type", Interp); BaseCargo := Sky_Bases(BaseIndex).Cargo; if Items_Sort_Order = Default_Items_Sort_Order then Items_Indexes.Clear; for I in Player_Ship.Cargo.Iterate loop Items_Indexes.Append(Inventory_Container.To_Index(I)); end loop; Items_Indexes.Append(0); for I in BaseCargo.Iterate loop Items_Indexes.Append(BaseCargo_Container.To_Index(I)); end loop; end if; ClearTable(LootTable); Add_Player_Cargo_Loop : for I of Items_Indexes loop Current_Item_Index := Current_Item_Index + 1; exit Add_Player_Cargo_Loop when I = 0; ProtoIndex := Player_Ship.Cargo(I).ProtoIndex; BaseCargoIndex := Find_Base_Cargo(ProtoIndex, Player_Ship.Cargo(I).Durability); if BaseCargoIndex > 0 then IndexesList.Append(New_Item => BaseCargoIndex); end if; ItemType := (if Items_List(ProtoIndex).ShowType = Null_Unbounded_String then Items_List(ProtoIndex).IType else Items_List(ProtoIndex).ShowType); if Index(ItemsTypes, To_String("{" & ItemType & "}")) = 0 then Append(ItemsTypes, " {" & ItemType & "}"); end if; if Argc > 1 and then CArgv.Arg(Argv, 1) /= "All" and then To_String(ItemType) /= CArgv.Arg(Argv, 1) then goto End_Of_Cargo_Loop; end if; if Current_Row < Start_Row then Current_Row := Current_Row + 1; goto End_Of_Cargo_Loop; end if; ItemName := To_Unbounded_String (GetItemName(Player_Ship.Cargo(I), False, False)); AddButton (LootTable, To_String(ItemName), "Show available options for item", "ShowLootItemMenu" & Positive'Image(I), 1); AddButton (LootTable, To_String(ItemType), "Show available options for item", "ShowLootItemMenu" & Positive'Image(I), 2); ItemDurability := (if Player_Ship.Cargo(I).Durability < 100 then To_Unbounded_String (GetItemDamage(Player_Ship.Cargo(I).Durability)) else To_Unbounded_String("Unused")); AddProgressBar (LootTable, Player_Ship.Cargo(I).Durability, Default_Item_Durability, To_String(ItemDurability), "ShowLootItemMenu" & Positive'Image(I), 3); AddButton (LootTable, Natural'Image(Player_Ship.Cargo(I).Amount), "Show available options for item", "ShowLootItemMenu" & Positive'Image(I), 4); BaseAmount := (if BaseCargoIndex > 0 then Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Amount else 0); AddButton (LootTable, Natural'Image(BaseAmount), "Show available options for item", "ShowLootItemMenu" & Positive'Image(I), 5, True); exit Add_Player_Cargo_Loop when LootTable.Row = Game_Settings.Lists_Limit + 1; <<End_Of_Cargo_Loop>> end loop Add_Player_Cargo_Loop; Add_Base_Cargo_Loop : for I in Current_Item_Index .. Items_Indexes.Last_Index loop exit Add_Base_Cargo_Loop when LootTable.Row = Game_Settings.Lists_Limit + 1; if IndexesList.Find_Index(Item => Items_Indexes(I)) > 0 then goto End_Of_Base_Cargo_Loop; end if; ProtoIndex := BaseCargo(Items_Indexes(I)).Proto_Index; ItemType := (if Items_List(ProtoIndex).ShowType = Null_Unbounded_String then Items_List(ProtoIndex).IType else Items_List(ProtoIndex).ShowType); if Index(ItemsTypes, To_String("{" & ItemType & "}")) = 0 then Append(ItemsTypes, " {" & ItemType & "}"); end if; if Argc = 2 and then CArgv.Arg(Argv, 1) /= "All" and then To_String(ItemType) /= CArgv.Arg(Argv, 1) then goto End_Of_Base_Cargo_Loop; end if; if Current_Row < Start_Row then Current_Row := Current_Row + 1; goto End_Of_Base_Cargo_Loop; end if; ItemName := Items_List(ProtoIndex).Name; AddButton (LootTable, To_String(ItemName), "Show available options for item", "ShowLootItemMenu -" & Trim(Positive'Image(Items_Indexes(I)), Left), 1); AddButton (LootTable, To_String(ItemType), "Show available options for item", "ShowLootItemMenu -" & Trim(Positive'Image(Items_Indexes(I)), Left), 2); ItemDurability := (if BaseCargo(Items_Indexes(I)).Durability < 100 then To_Unbounded_String(GetItemDamage(BaseCargo(I).Durability)) else To_Unbounded_String("Unused")); AddProgressBar (LootTable, BaseCargo(Items_Indexes(I)).Durability, Default_Item_Durability, To_String(ItemDurability), "ShowLootItemMenu -" & Trim(Positive'Image(Items_Indexes(I)), Left), 3); AddButton (LootTable, "0", "Show available options for item", "ShowLootItemMenu -" & Trim(Positive'Image(Items_Indexes(I)), Left), 4); BaseAmount := Sky_Bases(BaseIndex).Cargo(Items_Indexes(I)).Amount; AddButton (LootTable, Natural'Image(BaseAmount), "Show available options for item", "ShowLootItemMenu -" & Trim(Positive'Image(Items_Indexes(I)), Left), 5, True); <<End_Of_Base_Cargo_Loop>> end loop Add_Base_Cargo_Loop; if Page > 1 then if LootTable.Row < Game_Settings.Lists_Limit + 1 then AddPagination (LootTable, "ShowLoot " & Arguments & Positive'Image(Page - 1), ""); else AddPagination (LootTable, "ShowLoot " & Arguments & Positive'Image(Page - 1), "ShowLoot " & Arguments & Positive'Image(Page + 1)); end if; elsif LootTable.Row = Game_Settings.Lists_Limit + 1 then AddPagination (LootTable, "", "ShowLoot " & Arguments & Positive'Image(Page + 1)); end if; UpdateTable(LootTable); Tcl_Eval(Get_Context, "update"); configure (LootTable.Canvas, "-scrollregion [list " & BBox(LootTable.Canvas, "all") & "]"); configure(ComboBox, "-values [list " & To_String(ItemsTypes) & "]"); if Argc = 1 then Current(ComboBox, "0"); end if; Tcl.Tk.Ada.Grid.Grid(Close_Button, "-row 0 -column 1"); configure (LootCanvas, "-height [expr " & SashPos(Main_Paned, "0") & " - 20] -width " & cget(Main_Paned, "-width")); Tcl_Eval(Get_Context, "update"); Canvas_Create (LootCanvas, "window", "0 0 -anchor nw -window " & LootFrame); Tcl_Eval(Get_Context, "update"); configure (LootCanvas, "-scrollregion [list " & BBox(LootCanvas, "all") & "]"); Xview_Move_To(LootCanvas, "0.0"); Yview_Move_To(LootCanvas, "0.0"); Show_Screen("lootframe"); Tcl_SetResult(Interp, "1"); return TCL_OK; end Show_Loot_Command; -- ****if* LUI/LUI.ItemIndex -- FUNCTION -- Index of the currently selected item -- SOURCE ItemIndex: Integer; -- **** -- ****o* LUI/LUI.Show_Trade_Loot_Info_Command -- FUNCTION -- Show information about the selected item -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. Unused -- RESULT -- This function always return TCL_OK -- COMMANDS -- ShowLootItemInfo -- SOURCE function Show_Loot_Item_Info_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Loot_Item_Info_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc, Argv); use Tiny_String; ItemInfo, ProtoIndex: Unbounded_String; CargoIndex, BaseCargoIndex: Natural := 0; BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; ItemTypes: constant array(1 .. 6) of Unbounded_String := (Weapon_Type, Chest_Armor, Head_Armor, Arms_Armor, Legs_Armor, Shield_Type); begin if ItemIndex < 0 then BaseCargoIndex := abs (ItemIndex); else CargoIndex := ItemIndex; end if; if CargoIndex > Natural(Player_Ship.Cargo.Length) or BaseCargoIndex > Natural(Sky_Bases(BaseIndex).Cargo.Length) then return TCL_OK; end if; ProtoIndex := (if CargoIndex > 0 then Player_Ship.Cargo(CargoIndex).ProtoIndex else Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Proto_Index); Append (ItemInfo, "Weight:" & Integer'Image(Items_List(ProtoIndex).Weight) & " kg"); if Items_List(ProtoIndex).IType = Weapon_Type then Append (ItemInfo, LF & "Skill: " & To_String (SkillsData_Container.Element (Skills_List, Items_List(ProtoIndex).Value(3)) .Name) & "/" & To_String (AttributesData_Container.Element (Attributes_List, SkillsData_Container.Element (Skills_List, Items_List(ProtoIndex).Value(3)) .Attribute) .Name)); if Items_List(ProtoIndex).Value(4) = 1 then Append(ItemInfo, LF & "Can be used with shield."); else Append (ItemInfo, LF & "Can't be used with shield (two-handed weapon)."); end if; Append(ItemInfo, LF & "Damage type: "); case Items_List(ProtoIndex).Value(5) is when 1 => Append(ItemInfo, "cutting"); when 2 => Append(ItemInfo, "impaling"); when 3 => Append(ItemInfo, "blunt"); when others => null; end case; end if; Show_Weapon_Info_Loop : for ItemType of ItemTypes loop if Items_List(ProtoIndex).IType = ItemType then Append (ItemInfo, LF & "Damage chance: " & GetItemChanceToDamage(Items_List(ProtoIndex).Value(1))); Append (ItemInfo, LF & "Strength:" & Integer'Image(Items_List(ProtoIndex).Value(2))); exit Show_Weapon_Info_Loop; end if; end loop Show_Weapon_Info_Loop; if Tools_List.Contains(Items_List(ProtoIndex).IType) then Append (ItemInfo, LF & "Damage chance: " & GetItemChanceToDamage(Items_List(ProtoIndex).Value(1))); end if; if Length(Items_List(ProtoIndex).IType) > 4 and then (Slice(Items_List(ProtoIndex).IType, 1, 4) = "Ammo" or Items_List(ProtoIndex).IType = To_Unbounded_String("Harpoon")) then Append (ItemInfo, LF & "Strength:" & Integer'Image(Items_List(ProtoIndex).Value(1))); end if; if Items_List(ProtoIndex).Description /= Null_Unbounded_String then Append (ItemInfo, LF & LF & To_String(Items_List(ProtoIndex).Description)); end if; ShowInfo (Text => To_String(ItemInfo), Title => To_String(Items_List(ProtoIndex).Name)); return TCL_OK; end Show_Loot_Item_Info_Command; -- ****o* LUI/LUI.Loot_Item_Command -- FUNCTION -- Take or drop the selected item -- PARAMETERS -- ClientData - Custom data send to the command. -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- LootItem actiontype -- actiontype can be: drop, dropall, take, takeall -- SOURCE function Loot_Item_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Loot_Item_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Argc); BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; BaseCargoIndex, CargoIndex: Natural := 0; Amount: Natural; ProtoIndex: Unbounded_String; AmountBox: constant Ttk_SpinBox := Get_Widget(".itemdialog.amount", Interp); TypeBox: constant Ttk_ComboBox := Get_Widget(Main_Paned & ".lootframe.canvas.loot.options.type", Interp); begin if ItemIndex < 0 then BaseCargoIndex := abs (ItemIndex); else CargoIndex := ItemIndex; end if; if CargoIndex > 0 then ProtoIndex := Player_Ship.Cargo(CargoIndex).ProtoIndex; if BaseCargoIndex = 0 then BaseCargoIndex := Find_Base_Cargo(ProtoIndex); end if; else ProtoIndex := Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Proto_Index; end if; if CArgv.Arg(Argv, 1) in "drop" | "dropall" then Amount := (if CArgv.Arg(Argv, 1) = "drop" then Positive'Value(Get(AmountBox)) else Player_Ship.Cargo(CargoIndex).Amount); if BaseCargoIndex > 0 then Update_Base_Cargo (Cargo_Index => BaseCargoIndex, Amount => Amount, Durability => Player_Ship.Cargo.Element(CargoIndex).Durability); else Update_Base_Cargo (ProtoIndex, Amount, Player_Ship.Cargo.Element(CargoIndex).Durability); end if; UpdateCargo (Ship => Player_Ship, CargoIndex => CargoIndex, Amount => (0 - Amount), Durability => Player_Ship.Cargo.Element(CargoIndex).Durability); AddMessage ("You drop" & Positive'Image(Amount) & " " & To_String(Items_List(ProtoIndex).Name) & ".", OrderMessage); else Amount := (if CArgv.Arg(Argv, 1) = "take" then Positive'Value(Get(AmountBox)) else Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Amount); if FreeCargo(0 - (Amount * Items_List(ProtoIndex).Weight)) < 0 then ShowMessage (Text => "You can't take that much " & To_String(Items_List(ProtoIndex).Name) & ".", Title => "Too much taken"); return TCL_OK; end if; if CargoIndex > 0 then UpdateCargo (Ship => Player_Ship, CargoIndex => CargoIndex, Amount => Amount, Durability => Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Durability); else UpdateCargo (Player_Ship, ProtoIndex, Amount, Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Durability); end if; Update_Base_Cargo (Cargo_Index => BaseCargoIndex, Amount => (0 - Amount), Durability => Sky_Bases(BaseIndex).Cargo.Element(BaseCargoIndex).Durability); AddMessage ("You took" & Positive'Image(Amount) & " " & To_String(Items_List(ProtoIndex).Name) & ".", OrderMessage); end if; if CArgv.Arg(Argv, 1) in "take" | "drop" then if Close_Dialog_Command (ClientData, Interp, 2, CArgv.Empty & "CloseDialog" & ".itemdialog") = TCL_ERROR then return TCL_ERROR; end if; end if; UpdateHeader; Update_Messages; return Show_Loot_Command (ClientData, Interp, 2, CArgv.Empty & "ShowLoot" & Get(TypeBox)); end Loot_Item_Command; -- ****o* LUI/LUI.Show_Module_Menu_Command -- FUNCTION -- Show menu with actions for the selected item -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- ShowLootItemMenu itemindex -- ItemIndex is a index of the item which menu will be shown. -- SOURCE function Show_Item_Menu_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Show_Item_Menu_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Argc); ItemMenu: Tk_Menu := Get_Widget(".itemmenu", Interp); BaseCargoIndex, CargoIndex: Natural := 0; BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; begin ItemIndex := Integer'Value(CArgv.Arg(Argv, 1)); if ItemIndex < 0 then BaseCargoIndex := abs (ItemIndex); else CargoIndex := ItemIndex; end if; if CargoIndex > 0 and then BaseCargoIndex = 0 then BaseCargoIndex := Find_Base_Cargo(Player_Ship.Cargo(CargoIndex).ProtoIndex); end if; if Winfo_Get(ItemMenu, "exists") = "0" then ItemMenu := Create(".itemmenu", "-tearoff false"); end if; Delete(ItemMenu, "0", "end"); if BaseCargoIndex > 0 then Menu.Add (ItemMenu, "command", "-label {Take selected amount} -command {LootAmount take" & Natural'Image(Sky_Bases(BaseIndex).Cargo(BaseCargoIndex).Amount) & "}"); Menu.Add (ItemMenu, "command", "-label {Take all available} -command {LootItem takeall}"); end if; if CargoIndex > 0 then Menu.Add (ItemMenu, "command", "-label {Drop selected amount} -command {LootAmount drop" & Natural'Image(Player_Ship.Cargo(CargoIndex).Amount) & "}"); Menu.Add (ItemMenu, "command", "-label {Drop all owned} -command {LootItem dropall}"); end if; Menu.Add (ItemMenu, "command", "-label {Show item details} -command {ShowLootItemInfo}"); Tk_Popup (ItemMenu, Winfo_Get(Get_Main_Window(Interp), "pointerx"), Winfo_Get(Get_Main_Window(Interp), "pointery")); return TCL_OK; end Show_Item_Menu_Command; -- ****o* LUI/LUI.Loot_Amount_Command -- FUNCTION -- Show dialog to enter amount of items to drop or take -- PARAMETERS -- ClientData - Custom data send to the command. Unused -- Interp - Tcl interpreter in which command was executed. Unused -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. Unused -- RESULT -- This function always return TCL_OK -- COMMANDS -- LootAmount action baseindex -- Action which will be taken. Can be take or drop. BaseIndex is the index -- of the base from which item will be take. -- SOURCE function Loot_Amount_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Loot_Amount_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(ClientData, Interp, Argc); BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; begin if CArgv.Arg(Argv, 1) = "drop" then ShowManipulateItem ("Drop " & GetItemName(Player_Ship.Cargo(ItemIndex)), "LootItem drop", "drop", ItemIndex); else if ItemIndex > 0 then ShowManipulateItem ("Take " & GetItemName(Player_Ship.Cargo(ItemIndex)), "LootItem take", "take", ItemIndex, Natural'Value(CArgv.Arg(Argv, 2))); else ShowManipulateItem ("Take " & To_String (Items_List (Sky_Bases(BaseIndex).Cargo(abs (ItemIndex)).Proto_Index) .Name), "LootItem take", "take", abs (ItemIndex), Natural'Value(CArgv.Arg(Argv, 2))); end if; end if; return TCL_OK; end Loot_Amount_Command; -- ****o* LUI/LUI.Sort_Items_Command -- FUNCTION -- Sort the looting list -- PARAMETERS -- ClientData - Custom data send to the command. -- Interp - Tcl interpreter in which command was executed. -- Argc - Number of arguments passed to the command. Unused -- Argv - Values of arguments passed to the command. -- RESULT -- This function always return TCL_OK -- COMMANDS -- SortLootItems x -- X is X axis coordinate where the player clicked the mouse button -- SOURCE function Sort_Items_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with Convention => C; -- **** function Sort_Items_Command (ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int; Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is pragma Unreferenced(Argc); Column: constant Positive := Get_Column_Number(LootTable, Natural'Value(CArgv.Arg(Argv, 1))); type Local_Item_Data is record Name: Unbounded_String; IType: Unbounded_String; Damage: Float; Owned: Natural; Available: Natural; Id: Positive; end record; BaseIndex: constant Natural := SkyMap(Player_Ship.Sky_X, Player_Ship.Sky_Y).BaseIndex; Indexes_List: Positive_Container.Vector; BaseCargo: constant BaseCargo_Container.Vector := Sky_Bases(BaseIndex).Cargo; BaseCargoIndex: Natural; ProtoIndex: Unbounded_String; package Items_Container is new Vectors (Index_Type => Positive, Element_Type => Local_Item_Data); Local_Items: Items_Container.Vector; function "<"(Left, Right: Local_Item_Data) return Boolean is begin if Items_Sort_Order = NAMEASC and then Left.Name < Right.Name then return True; end if; if Items_Sort_Order = NAMEDESC and then Left.Name > Right.Name then return True; end if; if Items_Sort_Order = TYPEASC and then Left.IType < Right.IType then return True; end if; if Items_Sort_Order = TYPEDESC and then Left.IType > Right.IType then return True; end if; if Items_Sort_Order = DURABILITYASC and then Left.Damage < Right.Damage then return True; end if; if Items_Sort_Order = DURABILITYDESC and then Left.Damage > Right.Damage then return True; end if; if Items_Sort_Order = OWNEDASC and then Left.Owned < Right.Owned then return True; end if; if Items_Sort_Order = OWNEDDESC and then Left.Owned > Right.Owned then return True; end if; if Items_Sort_Order = AVAILABLEASC and then Left.Available < Right.Available then return True; end if; if Items_Sort_Order = AVAILABLEDESC and then Left.Available > Right.Available then return True; end if; return False; end "<"; package Sort_Items is new Items_Container.Generic_Sorting; begin case Column is when 1 => if Items_Sort_Order = NAMEASC then Items_Sort_Order := NAMEDESC; else Items_Sort_Order := NAMEASC; end if; when 2 => if Items_Sort_Order = TYPEASC then Items_Sort_Order := TYPEDESC; else Items_Sort_Order := TYPEASC; end if; when 3 => if Items_Sort_Order = DURABILITYASC then Items_Sort_Order := DURABILITYDESC; else Items_Sort_Order := DURABILITYASC; end if; when 4 => if Items_Sort_Order = OWNEDASC then Items_Sort_Order := OWNEDDESC; else Items_Sort_Order := OWNEDASC; end if; when 5 => if Items_Sort_Order = AVAILABLEASC then Items_Sort_Order := AVAILABLEDESC; else Items_Sort_Order := AVAILABLEASC; end if; when others => null; end case; if Items_Sort_Order = Default_Items_Sort_Order then return TCL_OK; end if; for I in Player_Ship.Cargo.Iterate loop ProtoIndex := Player_Ship.Cargo(I).ProtoIndex; BaseCargoIndex := Find_Base_Cargo(ProtoIndex, Player_Ship.Cargo(I).Durability); if BaseCargoIndex > 0 then Indexes_List.Append(New_Item => BaseCargoIndex); end if; Local_Items.Append (New_Item => (Name => To_Unbounded_String(GetItemName(Player_Ship.Cargo(I))), IType => (if Items_List(ProtoIndex).ShowType = Null_Unbounded_String then Items_List(ProtoIndex).IType else Items_List(ProtoIndex).ShowType), Damage => Float(Player_Ship.Cargo(I).Durability) / Float(Default_Item_Durability), Owned => Player_Ship.Cargo(I).Amount, Available => (if BaseCargoIndex > 0 then BaseCargo(BaseCargoIndex).Amount else 0), Id => Inventory_Container.To_Index(I))); end loop; Sort_Items.Sort(Local_Items); Items_Indexes.Clear; for Item of Local_Items loop Items_Indexes.Append(Item.Id); end loop; Items_Indexes.Append(0); Local_Items.Clear; for I in BaseCargo.First_Index .. BaseCargo.Last_Index loop if Indexes_List.Find_Index(Item => I) = 0 then ProtoIndex := BaseCargo(I).Proto_Index; Local_Items.Append (New_Item => (Name => Items_List(ProtoIndex).Name, IType => (if Items_List(ProtoIndex).ShowType = Null_Unbounded_String then Items_List(ProtoIndex).IType else Items_List(ProtoIndex).ShowType), Damage => Float(BaseCargo(I).Durability) / Float(Default_Item_Durability), Owned => 0, Available => BaseCargo(I).Amount, Id => I)); end if; end loop; Sort_Items.Sort(Local_Items); for Item of Local_Items loop Items_Indexes.Append(Item.Id); end loop; return Show_Loot_Command (ClientData, Interp, 2, CArgv.Empty & "ShowLoot" & "All"); end Sort_Items_Command; procedure AddCommands is begin Add_Command("ShowLoot", Show_Loot_Command'Access); Add_Command("ShowLootItemInfo", Show_Loot_Item_Info_Command'Access); Add_Command("LootItem", Loot_Item_Command'Access); Add_Command("ShowLootItemMenu", Show_Item_Menu_Command'Access); Add_Command("LootAmount", Loot_Amount_Command'Access); Add_Command("SortLootItems", Sort_Items_Command'Access); end AddCommands; end Bases.LootUI;
------------------------------------------------------------------------------- -- Copyright 2021, The Trendy Terminal Developers (see AUTHORS file) -- 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 Trendy_Terminal.Lines.Line_Vectors; with Trendy_Terminal.String_Vectors; -- Stores user line history. -- -- The goal here is to have a history type which can be loaded from file, -- but also completed like a line. -- -- This gets used as a form of completion for line editing. package Trendy_Terminal.Histories is -- A record of the history of user inputs. type History is private; type History_Access is access all History; -- Adds a line to the history. This makes it the most recent line in the -- history. procedure Add (H : in out History; Input : String); -- Some histories only store a limited number of entries. procedure Set_Max_Entries(H : in out History; Count : Positive); function Num_Entries (H : History) return Natural; -- History starting with 1 being the least recent, with the most recent -- command having a higher index. function Get_Entry (H : History; Index : Positive) return String with Pre => Index < Positive (Num_Entries (H)); -- Returns a list of completions which could match the given line. function Completions_Matching (H : History; Incomplete : String) return Lines.Line_Vectors.Vector; private type History is record Entries : String_Vectors.Vector; Max_Entries : Positive := Positive'Last; end record; end Trendy_Terminal.Histories;
-- 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 DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet; -- @description -- -- RData processor for A records -- -- @summary -- -- Processes an A record into a IPv4 string -- package DNSCatcher.DNS.Processor.RData.A_Parser is -- Parsed A RData Representation type Parsed_A_RData is new DNSCatcher.DNS.Processor.RData.Parsed_RData with private; type Parsed_A_RData_Access is access all Parsed_A_RData; -- Converts a RR record to logicial representation -- -- @value This -- Class object -- -- @value DNS_Header -- DNS Packet Header -- -- @value Parsed_RR -- A parsed Resource Record from Processor.Packet -- procedure From_Parsed_RR (This : in out Parsed_A_RData; DNS_Header : DNS_Packet_Header; Parsed_RR : Parsed_DNS_Resource_Record); -- Represents RData as a String for debug logging -- -- @value This -- Class object -- -- @returns -- An IPv4 String -- function RData_To_String (This : in Parsed_A_RData) return String; -- Represents the resource record packet as a whole as a string -- -- @value This -- Class object -- -- @returns -- String in the format of "A *IPv4 String* -- function Print_Packet (This : in Parsed_A_RData) return String; -- Frees and deallocates the class object -- -- @value This -- Class object to deallocate -- procedure Delete (This : in out Parsed_A_RData); private type Parsed_A_RData is new DNSCatcher.DNS.Processor.RData.Parsed_RData with record A_Record : Unbounded_String; end record; end DNSCatcher.DNS.Processor.RData.A_Parser;
with Ada.Text_IO; use Ada.Text_IO; procedure Test is type R is record A: Integer; end record; procedure F(X: in out Integer) is begin X := 0; end; procedure G(X: in R) is begin F(X.A); end; X: R; begin G(X); end Test;
-- -- Copyright (C) 2021 Jeremy Grosser <jeremy@synack.me> -- -- SPDX-License-Identifier: BSD-3-Clause -- package body Seven is procedure Set_Digit (This : in out Device; Pos : Position; Val : Digit) is begin case Pos is when 1 => This.Buffer (1) := Numbers (Val); when 2 => This.Buffer (3) := Numbers (Val); when 3 => This.Buffer (7) := Numbers (Val); when 4 => This.Buffer (9) := Numbers (Val); end case; end Set_Digit; procedure Set_Colon (This : in out Device; On : Boolean) is begin if On then This.Set (33); else This.Clear (33); end if; end Set_Colon; procedure Set_Point (This : in out Device; Num : Point_Number; On : Boolean) is begin if On then This.Set (Points (Num)); else This.Clear (Points (Num)); end if; end Set_Point; end Seven;
with Ada.Text_IO; package body AdaM is procedure put (the_Lines : in text_Lines) is use Ada.Text_IO; begin for i in 1 .. Integer (the_Lines.Length) loop put_Line (+the_Lines.Element (i)); end loop; end put; end AdaM;
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with Glfw.Display; with Glfw.Events.Keys; package body GL_Test.Display_Backend is procedure Init renames Glfw.Init; procedure Open_Window (Width, Height : Natural; Depth_Bits : Natural := 0) is begin Glfw.Display.Open (Width, Height, Mode => Glfw.Display.Window, Depth_Bits => Depth_Bits); end Open_Window; procedure Poll_Events renames Glfw.Events.Poll_Events; procedure Wait_For_Events renames Glfw.Events.Wait_For_Events; procedure Swap_Buffers renames Glfw.Display.Swap_Buffers; procedure Set_Window_Title (Value : String) renames Glfw.Display.Set_Title; function Escape_Pressed return Boolean is begin return Glfw.Events.Keys.Pressed (Glfw.Events.Keys.Esc); end Escape_Pressed; function Window_Opened return Boolean renames Glfw.Display.Opened; procedure Close_Window renames Glfw.Display.Close; procedure Shutdown renames Glfw.Terminate_Glfw; procedure Configure_Minimum_OpenGL_Version (Major, Minor : Natural) is begin Glfw.Display.Hint_Minimum_OpenGL_Version (Major, Minor); end Configure_Minimum_OpenGL_Version; end GL_Test.Display_Backend;
with Listas_Ordenadas_Gen, Envios; package Lista_Envios is new Listas_Ordenadas_Gen ( MAX => 1000, Componente => Envios.Envio, Precede => Envios.Precede, Copiar => Envios.Copiar, Igual => Envios.Igual );
-- menu2.adb -- -- rosetta.org menu example -- GPS 4.3-5 (Debian) -- note: the use of Unbounded strings is somewhat overkill, except that -- it allows Ada to handle variable length string data easily -- ie: differing length menu items text with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Strings.Unbounded, Ada.Strings.Unbounded.Text_IO; procedure menu2 is package tio renames Ada.Integer_Text_IO; -- rename package to use a shorter name, tio, as integer get prefix menu_item : array (1..4) of Unbounded_String; -- 4 menu items of any length choice : integer := 0; -- user selection entry value procedure show_menu is -- display the menu options and collect the users input -- into locally global variable 'choice' begin for pntr in menu_item'first .. menu_item'last loop put (pntr ); put(" "); put( menu_item(pntr)); new_line; end loop; put("chose (0 to exit) #:"); tio.get(choice); end show_menu; -- main program -- begin menu_item(1) := to_unbounded_string("Fee Fie"); menu_item(2) := to_unbounded_string("Huff & Puff"); menu_item(3) := to_unbounded_string("mirror mirror"); menu_item(4) := to_unbounded_string("tick tock"); -- setup menu selection strings in an array show_menu; loop if choice in menu_item'range then put("you chose #:"); case choice is -- in a real menu, each case would execute appropriate user procedures when 1 => put ( menu_item(choice)); new_line; when 2 => put ( menu_item(choice)); new_line; when 3 => put ( menu_item(choice)); new_line; when 4 => put ( menu_item(choice)); new_line; when others => null; end case; show_menu; else put("Menu selection out of range"); new_line; if choice = 0 then exit; end if; -- need a exit option ! show_menu; end if; end loop; end menu2;
-- Unit.ads with Interfaces.C; use Interfaces; package Unit is function Add (A, B : Integer) return Integer; pragma Export (C, Add, "add"); end Unit;
package body Variance is procedure Reset(v : in out Variance_Type) is begin v.sample_count := 0; v.sum := 0.0; v.sum_squares := 0.0; end Reset; procedure Update(v : in out Variance_Type; value : in T) is begin v.sample_count := v.sample_count + 1; v.sum := v.sum + value; v.sum_squares := v.sum_squares + value * value; end Update; function Get_Variance(v : Variance_Type) return T is count : constant T := T(v.sample_count); mean : constant T := v.sum / count; begin if v.sample_count > 0 then return v.sum_squares / count - mean * mean; else return 0.0; end if; end Get_Variance; end Variance;
with Ada.Exceptions; procedure exception_save is S : Ada.Exceptions.Exception_Occurrence; begin -- Save_Exception Ada.Exceptions.Save_Exception (S, Constraint_Error'Identity, Message => "save!"); Ada.Debug.Put ("(1)"); begin Ada.Exceptions.Reraise_Occurrence (S); raise Program_Error; exception when X : Constraint_Error => Ada.Debug.Put (Ada.Exceptions.Exception_Information (X)); pragma Assert (Ada.Exceptions.Exception_Message (X) = "save!"); null; end; -- Save_Exception_From_Here Ada.Exceptions.Save_Exception_From_Here (S, Tasking_Error'Identity); -- line 18 Ada.Debug.Put ("(2)"); begin Ada.Exceptions.Reraise_Occurrence (S); raise Program_Error; exception when X : Tasking_Error => Ada.Debug.Put (Ada.Exceptions.Exception_Information (X)); pragma Assert (Ada.Exceptions.Exception_Message (X) = "exception_save.adb:18 explicit raise"); null; end; pragma Debug (Ada.Debug.Put ("OK")); end exception_save;
with Ada.Text_IO; with Ada.Integer_Text_IO; with Math_Pkg; use Ada; package body Interface_Pkg is procedure find_prime is number : Integer :=0; yes : Boolean :=false; begin Text_IO.put("Enter positives integers below 1000, negative to end"); ada.text_iO.New_Line; while true loop text_iO.New_Line; Integer_Text_IO.get(number); exit when not (number >= 0 and number <= 1000); Math_Pkg.Is_prime(Number,Yes); if yes = true then Integer_Text_IO.put(Number); Text_IO.Put(" is Prime!"); elsif yes = false then Integer_Text_IO.put(Number); Text_IO.Put(" is not Prime"); end if; end loop; text_iO.New_Line; Text_IO.Put("Thanks for using the PrimeTime..."); end Find_Prime; end Interface_Pkg;
-- C43205A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT THE BOUNDS OF A POSITIONAL AGGREGATE ARE DETERMINED -- CORRECTLY. IN PARTICULAR, CHECK THAT THE LOWER BOUND IS GIVEN BY -- 'FIRST OF THE INDEX SUBTYPE WHEN THE POSITIONAL AGGREGATE IS USED AS: -- A) AN ACTUAL PARAMETER IN A SUBPROGRAM OR ENTRY CALL, AND THE -- FORMAL PARAMETER IS UNCONSTRAINED. -- EG 01/26/84 WITH REPORT; PROCEDURE C43205A IS USE REPORT; BEGIN TEST("C43205A", "CASE A1 : SUBPROGRAM WITH UNCONSTRAINED " & "ONE-DIMENSIONAL ARRAY FORMAL PARAMETER"); BEGIN CASE_A : BEGIN CASE_A1 : DECLARE SUBTYPE STA IS INTEGER RANGE 11 .. 15; TYPE TA IS ARRAY (STA RANGE <>) OF INTEGER; PROCEDURE PROC1 (A : TA) IS BEGIN IF A'FIRST /= IDENT_INT(11) THEN FAILED ("CASE A1 : LOWER BOUND " & "INCORRECTLY GIVEN BY 'FIRST"); ELSIF A'LAST /= 15 THEN FAILED ("CASE A1 : UPPER BOUND " & "INCORRECTLY GIVEN BY 'LAST"); ELSIF A /= (6, 7, 8, 9, 10) THEN FAILED ("CASE A1 : ARRAY DOES NOT " & "CONTAIN THE CORRECT VALUES"); END IF; END; BEGIN PROC1 ((6, 7, 8, 9, IDENT_INT(10))); END CASE_A1; COMMENT ("CASE A2 : SUBPROGRAM WITH UNCONSTRAINED " & "TWO-DIMENSIONAL ARRAY FORMAL PARAMETER"); CASE_A2 : DECLARE SUBTYPE STA1 IS INTEGER RANGE 11 .. IDENT_INT(12); SUBTYPE STA2 IS INTEGER RANGE 10 .. 11; TYPE TA IS ARRAY (STA1 RANGE <>, STA2 RANGE <>) OF INTEGER; PROCEDURE PROC1 (A : TA) IS BEGIN IF A'FIRST(1) /= 11 OR A'FIRST(2) /= 10 THEN FAILED ("CASE A2 : LOWER BOUND " & "INCORRECTLY GIVEN BY 'FIRST"); ELSIF A'LAST(1) /= 12 OR A'LAST(2) /= IDENT_INT(11) THEN FAILED ("CASE A2 : UPPER BOUND " & "INCORRECTLY GIVEN BY 'LAST"); ELSIF A /= ((1, 2), (3, 4)) THEN FAILED ("CASE A2 : ARRAY DOES NOT " & "CONTAIN THE CORRECT VALUES"); END IF; END; BEGIN PROC1 (((1, 2), (IDENT_INT(3), 4))); END CASE_A2; END CASE_A; END; RESULT; END C43205A;
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ package Ada.Numerics.Float_Random is -- Basic facilities type Generator is limited private; subtype Uniformly_Distributed is Float range 0.0 .. 1.0; function Random (Gen : Generator) return Uniformly_Distributed; procedure Reset (Gen : in Generator; Initiator : in Integer); procedure Reset (Gen : in Generator); -- Advanced facilities type State is private; procedure Save (Gen : in Generator; To_State : out State); procedure Reset (Gen : in Generator; From_State : in State); Max_Image_Width : constant := implementation-defined; function Image (Of_State : State) return String; function Value (Coded_State : String) return State; private pragma Import (Ada, State); pragma Import (Ada, Generator); end Ada.Numerics.Float_Random;
%TITLE% ADS 010507/0000 LEVEL HGHT TEMP DWPT WDIR WSPD ------------------------------------------------------------------- %RAW% 991.75, 158.79, 26.61, 22.35, 164.08, 8.53 975.00, 309.81, 25.49, 20.91, 165.43, 12.62 950.00, 538.20, 23.78, 18.97, 168.45, 17.43 925.00, 771.20, 21.79, 17.56, 178.42, 18.51 900.00, 1008.89, 19.96, 15.94, 195.98, 18.10 875.00, 1251.44, 18.13, 13.83, 212.56, 17.74 850.00, 1499.58, 16.63, 8.81, 222.94, 18.37 825.00, 1753.28, 15.29, 2.35, 230.21, 19.49 800.00, 2013.28, 13.35, 0.37, 235.84, 20.20 775.00, 2279.13, 11.71, -7.51, 239.46, 19.64 750.00, 2551.82, 9.20, -8.87, 244.10, 19.01 725.00, 2831.37, 7.08, -8.03, 252.75, 19.96 700.00, 3118.97, 5.10, -9.16, 258.32, 20.69 675.00, 3414.87, 2.93, -11.45, 262.14, 21.58 650.00, 3718.57, 0.79, -14.69, 264.65, 22.67 625.00, 4031.71, -1.28, -18.82, 265.59, 23.55 600.00, 4356.07, -3.37, -22.64, 263.54, 24.61 575.00, 4690.66, -5.61, -25.40, 259.82, 26.43 550.00, 5037.26, -8.17, -26.90, 255.42, 28.56 525.00, 5396.26, -10.97, -27.95, 251.38, 31.03 500.00, 5768.71, -13.74, -30.05, 247.76, 34.17 475.00, 6156.17, -16.26, -35.04, 244.28, 37.81 450.00, 6560.67, -19.13, -40.46, 243.32, 42.55 425.00, 6983.12, -22.26, -43.30, 243.42, 46.13 400.00, 7425.12, -25.40, -41.51, 243.91, 49.54 375.00, 7891.02, -28.87, -43.30, 244.60, 53.03 350.00, 8379.71, -32.61, -45.68, 245.24, 56.78 325.00, 8898.31, -36.04, -46.14, 245.51, 61.53 300.00, 9449.91, -39.28, -47.05, 245.58, 66.99 275.00, 10041.15, -42.66, -51.97, 244.69, 76.03 250.00, 10678.75, -46.61, -55.24, 247.44, 78.58 225.00, 11371.10, -50.85, -59.44, 253.60, 67.31 200.00, 12131.35, -54.79, -63.81, 252.71, 58.83 175.00, 12978.15, -57.75, -68.75, 248.16, 56.59 150.00, 13949.36, -58.31, -69.22, 244.20, 50.52 125.00, 15105.81, -61.13, -71.56, 245.24, 39.69 100.00, 16459.81, -66.59, -76.99, 251.27, 27.16 75.00, 18205.42, -58.31, -69.22, 244.20, 50.52 50.00, 20665.71, -58.31, -69.22, 244.20, 50.52 %END% ----- Parcel Information----- *** 50mb MIXED LAYER PARCEL *** LPL: P=992 T=81F Td=67F CAPE: 2818 J/kg CINH: -33 J/kg LI: -10 C LI(300mb): -8 C 3km Cape: 163 J/kg NCAPE: 0.27 m/s2 LCL: 886mb 988m LFC: 850mb 1341m EL: 200mb 11973m MPL: 118mb 15297m All heights AGL ----- Moisture ----- Precip Water: 1.13 in Mean W: 14.4 g/Kg ----- Lapse Rates ----- 700-500mb 19 C 7.2 C/km 850-500mb 32 C 7.4 C/km ----- Note ----- Old Title: RUC 010507/0000F000 ads
----------------------------------------------------------------------- -- el-functions-namespaces -- Namespace function mapper -- Copyright (C) 2011, 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. ----------------------------------------------------------------------- private with Util.Strings.Maps; package EL.Functions.Namespaces is -- ------------------------------ -- Namespace Function mapper -- ------------------------------ -- The <b>NS_Function_Mapper</b> is a delegate function mapper which provides XML -- namespace support. The XML namespaces are registered with the <b>Set_Namespace</b> -- procedure which records a prefix and the associated URI namespace. When a function is -- searched, the <b>Namespace</b> is searched in the prefix map to find the corresponding -- URI namespace. Then, the delegated function mapper is invoked using that URI. type NS_Function_Mapper is new Function_Mapper with private; type Function_Mapper_Access is access all Function_Mapper'Class; -- Find the function knowing its name. overriding function Get_Function (Mapper : in NS_Function_Mapper; Namespace : in String; Name : in String) return Function_Access; -- Bind a name to a function in the given namespace. overriding procedure Set_Function (Mapper : in out NS_Function_Mapper; Namespace : in String; Name : in String; Func : in Function_Access); -- Associate the <b>Prefix</b> with the givien <b>URI</b> building a new namespace. procedure Set_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String; URI : in String); -- Remove the namespace prefix binding. procedure Remove_Namespace (Mapper : in out NS_Function_Mapper; Prefix : in String); -- Set the delegate function mapper. procedure Set_Function_Mapper (Mapper : in out NS_Function_Mapper; Delegate : in Function_Mapper_Access); private type NS_Function_Mapper is new Function_Mapper with record Mapping : Util.Strings.Maps.Map; Mapper : Function_Mapper_Access; end record; end EL.Functions.Namespaces;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S T O R A G E _ E L E M E N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2002-2020, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the implementation dependent sections of this file. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Warning: declarations in this package are ambiguous with respect to the -- extra declarations that can be introduced into System using Extend_System. -- It is a good idea to avoid use clauses for this package. pragma Compiler_Unit_Warning; package System.Storage_Elements is pragma Pure; -- Note that we take advantage of the implementation permission to make -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada 2005, -- this is Pure in any case (AI-362). -- We also add the pragma Pure_Function to the operations in this package, -- because otherwise functions with parameters derived from Address are -- treated as non-pure by the back-end (see exp_ch6.adb). This is because -- in many cases such a parameter is used to hide read/out access to -- objects, and it would be unsafe to treat such functions as pure. type Storage_Offset is range -(2 ** (Integer'(Standard'Address_Size) - 1)) .. +(2 ** (Integer'(Standard'Address_Size) - 1)) - Long_Long_Integer'(1); -- Note: the reason for the Long_Long_Integer qualification here is to -- avoid a bogus ambiguity when this unit is analyzed in an rtsfind -- context. It may be possible to remove this in the future, but it is -- certainly harmless in any case ??? subtype Storage_Count is Storage_Offset range 0 .. Storage_Offset'Last; type Storage_Element is mod 2 ** Storage_Unit; for Storage_Element'Size use Storage_Unit; pragma Universal_Aliasing (Storage_Element); -- This type is used by the expander to implement aggregate copy type Storage_Array is array (Storage_Offset range <>) of aliased Storage_Element; for Storage_Array'Component_Size use Storage_Unit; -- Address arithmetic function "+" (Left : Address; Right : Storage_Offset) return Address; pragma Convention (Intrinsic, "+"); pragma Inline_Always ("+"); pragma Pure_Function ("+"); function "+" (Left : Storage_Offset; Right : Address) return Address; pragma Convention (Intrinsic, "+"); pragma Inline_Always ("+"); pragma Pure_Function ("+"); function "-" (Left : Address; Right : Storage_Offset) return Address; pragma Convention (Intrinsic, "-"); pragma Inline_Always ("-"); pragma Pure_Function ("-"); function "-" (Left, Right : Address) return Storage_Offset; pragma Convention (Intrinsic, "-"); pragma Inline_Always ("-"); pragma Pure_Function ("-"); function "mod" (Left : Address; Right : Storage_Offset) return Storage_Offset; pragma Convention (Intrinsic, "mod"); pragma Inline_Always ("mod"); pragma Pure_Function ("mod"); -- Conversion to/from integers type Integer_Address is mod Memory_Size; function To_Address (Value : Integer_Address) return Address; pragma Convention (Intrinsic, To_Address); pragma Inline_Always (To_Address); pragma Pure_Function (To_Address); function To_Integer (Value : Address) return Integer_Address; pragma Convention (Intrinsic, To_Integer); pragma Inline_Always (To_Integer); pragma Pure_Function (To_Integer); end System.Storage_Elements;
with Ada.Text_IO; use Ada.Text_IO; generic type Element_Type is private; with function Less_Than( Left, Right : in Element_Type ) return Boolean; with function Greater_Than( Left, Right : in Element_Type ) return Boolean; with procedure Put( Item: in Element_Type ); package Generic_AVL_Tree is type T is limited private; function Is_In_Tree( Tree: in T; Element: in Element_Type ) return Boolean; procedure Insert( Tree: in out T; Element: in Element_Type ); procedure Remove( Tree: in out T; Element: in Element_Type ); procedure Print( Tree: in T ); procedure Debug_Print( Tree: in T ); procedure Check_Tree( Tree: in T ); AVL_Tree_Error : exception; private type Tree_Node; type Tree_Node_Ptr is access Tree_Node; type Branch_Type is ( Left, Right, Root ); type Pivot_Type is ( Pivot_Left, Left, Equal, Right, Pivot_Right ); subtype Ballance_Type is Pivot_Type range Left..Right; type Tree_Node is record Data : Element_Type; Left : Tree_Node_Ptr; Right : Tree_Node_Ptr; Parent : Tree_Node_Ptr; Ballance : Ballance_Type; Branch : Branch_Type; end record; type T is record Root : Tree_Node_Ptr; end record; end Generic_AVL_Tree;
package impact.d3.collision.Detector.discrete -- -- This interface is made to be used by an iterative approach to do TimeOfImpact calculations. -- -- This interface allows to query for closest points and penetration depth between two (convex) objects -- the closest point is on the second object (B), and the normal points from the surface on B towards A. -- distance is between closest points on B and closest point on A. So you can calculate closest point on A -- by taking closestPointInA = closestPointInB + m_distance * m_normalOnSurfaceB -- is use Math; --- Result -- type Result is abstract tagged null record; procedure destruct (Self : in out Result) is null; -- setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material combiner -- procedure setShapeIdentifiersA (Self : in out Result; partId0 : in Integer; index0 : in Integer) is null; -- abstract; procedure setShapeIdentifiersB (Self : in out Result; partId1 : in Integer; index1 : in Integer) is null; -- abstract; procedure addContactPoint (Self : in out Result; normalOnBInWorld : in math.Vector_3; pointInWorld : in math.Vector_3; depth : in math.Real ) is abstract; --- ClosestPointInput -- type ClosestPointInput is record m_transformA : aliased Transform_3d; m_transformB : aliased Transform_3d; m_maximumDistanceSquared : math.Real := math.Infinity; end record; --- impact.d3.collision.Detector.discrete -- type Item is abstract tagged null record; procedure destruct (Self : in out Item) is null; -- Give either closest points (distance > 0) or penetration (distance) -- the normal always points from B towards A -- procedure getClosestPoints (Self : in out Item; input : in ClosestPointInput; output : in out Result'Class; swapResults : in Boolean := False) is abstract; --- btStorageResult -- type btStorageResult is new Result with record m_normalOnSurfaceB : math.Vector_3; m_closestPointInB : math.Vector_3; m_distance : math.Real := math.Infinity; -- negative means penetration ! end record; overriding procedure addContactPoint (Self : in out btStorageResult; normalOnBInWorld : in math.Vector_3; pointInWorld : in math.Vector_3; depth : in math.Real ); end impact.d3.collision.Detector.discrete;
with GNAT.OS_Lib; private with System; package FSmaker.Sink.File is function Create (Path : String) return Sink.Class; function Create (FD : GNAT.OS_Lib.File_Descriptor) return Sink.Class; private type Instance is new Sink.Instance with record FD : GNAT.OS_Lib.File_Descriptor; Do_Not_Close : Boolean := False; end record; function Write (This : in out Instance; Addr : System.Address; Len : Natural) return Natural; procedure Close (This : in out Instance); end FSmaker.Sink.File;
----------------------------------------------------------------------- -- awa-applications -- Ada Web Application -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.IO_Exceptions; with ADO.Sessions.Sources; with ADO.Configs; with EL.Contexts.Default; with Util.Files; with Util.Log.Loggers; with Security.Policies; with ASF.Server; with ASF.Servlets; with AWA.Services.Contexts; with AWA.Components.Factory; with AWA.Applications.Factory; with AWA.Applications.Configs; with AWA.Helpers.Selectors; with AWA.Permissions.Services; with AWA.Permissions.Beans; package body AWA.Applications is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Applications"); -- ------------------------------ -- Initialize the application -- ------------------------------ overriding procedure Initialize (App : in out Application; Conf : in ASF.Applications.Config; Factory : in out ASF.Applications.Main.Application_Factory'Class) is Ctx : AWA.Services.Contexts.Service_Context; begin Log.Info ("Initializing application"); Ctx.Set_Context (App'Unchecked_Access, null); AWA.Applications.Factory.Set_Application (Factory, App'Unchecked_Access); ASF.Applications.Main.Application (App).Initialize (Conf, Factory); -- Load the application configuration before any module. Application'Class (App).Load_Configuration (App.Get_Config (P_Config_File.P)); -- Register the application modules and load their configuration. Application'Class (App).Initialize_Modules; -- Load the plugin application configuration after the module are configured. Application'Class (App).Load_Configuration (App.Get_Config (P_Plugin_Config_File.P)); end Initialize; -- ------------------------------ -- Initialize the application configuration properties. Properties defined in <b>Conf</b> -- are expanded by using the EL expression resolver. -- ------------------------------ overriding procedure Initialize_Config (App : in out Application; Conf : in out ASF.Applications.Config) is Connection : ADO.Sessions.Sources.Data_Source; begin Log.Info ("Initializing configuration"); if Conf.Get ("app.modules.dir", "") = "" then Conf.Set ("app.modules.dir", "#{fn:composePath(app_search_dirs,'config')}"); end if; if Conf.Get ("bundle.dir", "") = "" then Conf.Set ("bundle.dir", "#{fn:composePath(app_search_dirs,'bundles')}"); end if; if Conf.Get ("ado.queries.paths", "") = "" then Conf.Set ("ado.queries.paths", "#{fn:composePath(app_search_dirs,'db')}"); end if; ADO.Configs.Initialize (Conf); ASF.Applications.Main.Application (App).Initialize_Config (Conf); Connection.Set_Connection (Conf.Get (P_Database.P)); Connection.Set_Property ("ado.queries.paths", Conf.Get ("ado.queries.paths", "")); Connection.Set_Property ("ado.queries.load", Conf.Get ("ado.queries.load", "")); App.DB_Factory.Create (Connection); App.DB_Factory.Set_Audit_Manager (App.Audits'Unchecked_Access); App.Audits.Initialize (App'Unchecked_Access); App.Events.Initialize (App'Unchecked_Access); AWA.Modules.Initialize (App.Modules, Conf); -- Use a specific error message when the NO_PERMISSION exception is raised. App.Get_Exception_Handler.Set_Message ("AWA.PERMISSIONS.NO_PERMISSION", "layout.exception_no_permission"); App.Register_Class ("AWA.Helpers.Selectors.Select_List_Bean", AWA.Helpers.Selectors.Create_Select_List_Bean'Access); App.Register_Class ("AWA.Permissions.Beans.Permission_Bean", AWA.Permissions.Beans.Create_Permission_Bean'Access); end Initialize_Config; -- ------------------------------ -- Initialize the servlets provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application servlets. -- ------------------------------ overriding procedure Initialize_Servlets (App : in out Application) is begin Log.Info ("Initializing application servlets"); ASF.Applications.Main.Application (App).Initialize_Servlets; end Initialize_Servlets; -- ------------------------------ -- Initialize the filters provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application filters. -- ------------------------------ overriding procedure Initialize_Filters (App : in out Application) is begin Log.Info ("Initializing application filters"); ASF.Applications.Main.Application (App).Initialize_Filters; end Initialize_Filters; -- ------------------------------ -- Initialize the ASF components provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the component factories used by the application. -- ------------------------------ overriding procedure Initialize_Components (App : in out Application) is procedure Register_Functions is new ASF.Applications.Main.Register_Functions (AWA.Permissions.Services.Set_Functions); begin Log.Info ("Initializing application components"); ASF.Applications.Main.Application (App).Initialize_Components; App.Add_Components (AWA.Components.Factory.Definition); Register_Functions (App); end Initialize_Components; -- ------------------------------ -- Read the application configuration file <b>awa.xml</b>. This is called after the servlets -- and filters have been registered in the application but before the module registration. -- ------------------------------ procedure Load_Configuration (App : in out Application; Files : in String) is procedure Load_Config (File : in String; Done : out Boolean); Paths : constant String := App.Get_Config (P_Module_Dir.P); Ctx : aliased EL.Contexts.Default.Default_Context; procedure Load_Config (File : in String; Done : out Boolean) is Path : constant String := Util.Files.Find_File_Path (File, Paths); begin Done := False; AWA.Applications.Configs.Read_Configuration (App, Path, Ctx'Unchecked_Access, True); exception when Ada.IO_Exceptions.Name_Error => Log.Warn ("Application configuration file '{0}' does not exist", Path); end Load_Config; begin Util.Files.Iterate_Path (Files, Load_Config'Access); end Load_Configuration; -- ------------------------------ -- Initialize the AWA modules provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the modules used by the application. -- ------------------------------ procedure Initialize_Modules (App : in out Application) is begin null; end Initialize_Modules; -- ------------------------------ -- Start the application. This is called by the server container when the server is started. -- ------------------------------ overriding procedure Start (App : in out Application) is Manager : constant Security.Policies.Policy_Manager_Access := App.Get_Security_Manager; begin -- Start the security manager. AWA.Permissions.Services.Permission_Manager'Class (Manager.all).Start; -- Start the event service. App.Events.Start; -- Start the application. ASF.Applications.Main.Application (App).Start; -- Dump the route and filters to help in configuration issues. App.Dump_Routes (Util.Log.INFO_LEVEL); end Start; -- ------------------------------ -- Close the application. -- ------------------------------ overriding procedure Close (App : in out Application) is begin App.Events.Stop; ASF.Applications.Main.Application (App).Close; end Close; -- ------------------------------ -- Register the module in the application -- ------------------------------ procedure Register (App : in Application_Access; Module : access AWA.Modules.Module'Class; Name : in String; URI : in String := "") is begin App.Register (Module.all'Unchecked_Access, Name, URI); end Register; -- ------------------------------ -- Get the database connection for reading -- ------------------------------ function Get_Session (App : Application) return ADO.Sessions.Session is begin return App.DB_Factory.Get_Session; end Get_Session; -- ------------------------------ -- Get the database connection for writing -- ------------------------------ function Get_Master_Session (App : Application) return ADO.Sessions.Master_Session is begin return App.DB_Factory.Get_Master_Session; end Get_Master_Session; -- ------------------------------ -- Find the module with the given name -- ------------------------------ function Find_Module (App : in Application; Name : in String) return AWA.Modules.Module_Access is begin return AWA.Modules.Find_By_Name (App.Modules, Name); end Find_Module; -- ------------------------------ -- Register the module in the application -- ------------------------------ procedure Register (App : in out Application; Module : in AWA.Modules.Module_Access; Name : in String; URI : in String := "") is begin AWA.Modules.Register (App.Modules'Unchecked_Access, App'Unchecked_Access, Module, Name, URI); end Register; -- ------------------------------ -- Send the event in the application event queues. -- ------------------------------ procedure Send_Event (App : in Application; Event : in AWA.Events.Module_Event'Class) is begin App.Events.Send (Event); end Send_Event; -- ------------------------------ -- Execute the <tt>Process</tt> procedure with the event manager used by the application. -- ------------------------------ procedure Do_Event_Manager (App : in out Application; Process : access procedure (Events : in out AWA.Events.Services.Event_Manager)) is begin Process (App.Events); end Do_Event_Manager; -- ------------------------------ -- Initialize the parser represented by <b>Parser</b> to recognize the configuration -- that are specific to the plugins that have been registered so far. -- ------------------------------ procedure Initialize_Parser (App : in out Application'Class; Parser : in out Util.Serialize.IO.Parser'Class) is procedure Process (Module : in out AWA.Modules.Module'Class); procedure Process (Module : in out AWA.Modules.Module'Class) is begin Module.Initialize_Parser (Parser); end Process; begin AWA.Modules.Iterate (App.Modules, Process'Access); end Initialize_Parser; -- ------------------------------ -- Get the current application from the servlet context or service context. -- ------------------------------ function Current return Application_Access is use type AWA.Services.Contexts.Service_Context_Access; Ctx : constant AWA.Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current; begin if Ctx /= null then return Ctx.Get_Application; end if; -- If there is no service context, look in the servlet current context. declare use type ASF.Servlets.Servlet_Registry_Access; Ctx : constant ASF.Servlets.Servlet_Registry_Access := ASF.Server.Current; begin if Ctx = null then Log.Warn ("There is no service context"); return null; end if; if not (Ctx.all in AWA.Applications.Application'Class) then Log.Warn ("The servlet context is not an application"); return null; end if; return AWA.Applications.Application'Class (Ctx.all)'Access; end; end Current; end AWA.Applications;
with Ada.Command_Line, Ada.Text_IO; procedure Josephus is function Arg(Idx, Default: Positive) return Positive is -- read Argument(Idx) (if Ada.Command_Line.Argument_Count >= Index then Positive'Value(Ada.Command_Line.Argument(Index)) else Default); Prisoners: constant Positive := Arg(Idx => 1, Default => 41); Steps: constant Positive := Arg(Idx => 2, Default => 3); Survivors: constant Positive := Arg(Idx => 3, Default => 1); Print: Boolean := (Arg(Idx => 4, Default => 1) = 1); subtype Index_Type is Natural range 0 .. Prisoners-1; Next: array(Index_Type) of Index_Type; X: Index_Type := (Steps-2) mod Prisoners; begin Ada.Text_IO.Put_Line ("N =" & Positive'Image(Prisoners) & ", K =" & Positive'Image(Steps) & (if Survivors > 1 then ", #survivors =" & Positive'Image(Survivors) else "")); for Idx in Next'Range loop -- initialize Next Next(Idx) := (Idx+1) mod Prisoners; end loop; if Print then Ada.Text_IO.Put("Executed: "); end if; for Execution in reverse 1 .. Prisoners loop if Execution = Survivors then Ada.Text_IO.New_Line; Ada.Text_IO.Put("Surviving: "); Print := True; end if; if Print then Ada.Text_IO.Put(Positive'Image(Next(X))); end if; Next(X) := Next(Next(X)); -- "delete" a prisoner for Prisoner in 1 .. Steps-1 loop X := Next(X); end loop; end loop; end Josephus;
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.SERCOM is pragma Preelaborate; --------------- -- Registers -- --------------- ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ -- Operating Mode type CTRLA_MODESelect is (-- USART with external clock USART_EXT_CLK, -- USART with internal clock USART_INT_CLK, -- SPI in slave operation SPI_SLAVE, -- SPI in master operation SPI_MASTER, -- I2C slave operation I2C_SLAVE, -- I2C master operation I2C_MASTER) with Size => 3; for CTRLA_MODESelect use (USART_EXT_CLK => 0, USART_INT_CLK => 1, SPI_SLAVE => 2, SPI_MASTER => 3, I2C_SLAVE => 4, I2C_MASTER => 5); -- SDA Hold Time type CTRLA_SDAHOLDSelect is (-- Disabled DISABLE, -- 50-100ns hold time Val_75NS, -- 300-600ns hold time Val_450NS, -- 400-800ns hold time Val_600NS) with Size => 2; for CTRLA_SDAHOLDSelect use (DISABLE => 0, Val_75NS => 1, Val_450NS => 2, Val_600NS => 3); -- Transfer Speed type CTRLA_SPEEDSelect is (-- Standard Mode(Sm) Upto 100kHz and Fast Mode(Fm) Upto 400kHz STANDARD_AND_FAST_MODE, -- Fast-mode Plus Upto 1MHz FASTPLUS_MODE, -- High-speed mode Upto 3.4MHz HIGH_SPEED_MODE) with Size => 2; for CTRLA_SPEEDSelect use (STANDARD_AND_FAST_MODE => 0, FASTPLUS_MODE => 1, HIGH_SPEED_MODE => 2); -- Inactive Time-Out type CTRLA_INACTOUTSelect is (-- Disabled DISABLE, -- 5-6 SCL Time-Out(50-60us) Val_55US, -- 10-11 SCL Time-Out(100-110us) Val_105US, -- 20-21 SCL Time-Out(200-210us) Val_205US) with Size => 2; for CTRLA_INACTOUTSelect use (DISABLE => 0, Val_55US => 1, Val_105US => 2, Val_205US => 3); -- I2CM Control A type SERCOM_CTRLA_SERCOM_I2CM_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run in Standby RUNSTDBY : Boolean := False; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- Pin Usage PINOUT : Boolean := False; -- unspecified Reserved_17_19 : HAL.UInt3 := 16#0#; -- SDA Hold Time SDAHOLD : CTRLA_SDAHOLDSelect := SAM_SVD.SERCOM.DISABLE; -- Master SCL Low Extend Timeout MEXTTOEN : Boolean := False; -- Slave SCL Low Extend Timeout SEXTTOEN : Boolean := False; -- Transfer Speed SPEED : CTRLA_SPEEDSelect := SAM_SVD.SERCOM.STANDARD_AND_FAST_MODE; -- unspecified Reserved_26_26 : HAL.Bit := 16#0#; -- SCL Clock Stretch Mode SCLSM : Boolean := False; -- Inactive Time-Out INACTOUT : CTRLA_INACTOUTSelect := SAM_SVD.SERCOM.DISABLE; -- SCL Low Timeout Enable LOWTOUTEN : Boolean := False; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_I2CM_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; PINOUT at 0 range 16 .. 16; Reserved_17_19 at 0 range 17 .. 19; SDAHOLD at 0 range 20 .. 21; MEXTTOEN at 0 range 22 .. 22; SEXTTOEN at 0 range 23 .. 23; SPEED at 0 range 24 .. 25; Reserved_26_26 at 0 range 26 .. 26; SCLSM at 0 range 27 .. 27; INACTOUT at 0 range 28 .. 29; LOWTOUTEN at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype SERCOM_CTRLB_SERCOM_I2CM_CMD_Field is HAL.UInt2; -- I2CM Control B type SERCOM_CTRLB_SERCOM_I2CM_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Smart Mode Enable SMEN : Boolean := False; -- Quick Command Enable QCEN : Boolean := False; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- Command CMD : SERCOM_CTRLB_SERCOM_I2CM_CMD_Field := 16#0#; -- Acknowledge Action ACKACT : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_I2CM_Register use record Reserved_0_7 at 0 range 0 .. 7; SMEN at 0 range 8 .. 8; QCEN at 0 range 9 .. 9; Reserved_10_15 at 0 range 10 .. 15; CMD at 0 range 16 .. 17; ACKACT at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- Data 32 Bit type CTRLC_DATA32BSelect is (-- Data transaction from/to DATA register are 8-bit DATA_TRANS_8BIT, -- Data transaction from/to DATA register are 32-bit DATA_TRANS_32BIT) with Size => 1; for CTRLC_DATA32BSelect use (DATA_TRANS_8BIT => 0, DATA_TRANS_32BIT => 1); -- I2CM Control C type SERCOM_CTRLC_SERCOM_I2CM_Register is record -- unspecified Reserved_0_23 : HAL.UInt24 := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect := SAM_SVD.SERCOM.DATA_TRANS_8BIT; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_I2CM_Register use record Reserved_0_23 at 0 range 0 .. 23; DATA32B at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype SERCOM_BAUD_SERCOM_I2CM_BAUD_Field is HAL.UInt8; subtype SERCOM_BAUD_SERCOM_I2CM_BAUDLOW_Field is HAL.UInt8; subtype SERCOM_BAUD_SERCOM_I2CM_HSBAUD_Field is HAL.UInt8; subtype SERCOM_BAUD_SERCOM_I2CM_HSBAUDLOW_Field is HAL.UInt8; -- I2CM Baud Rate type SERCOM_BAUD_SERCOM_I2CM_Register is record -- Baud Rate Value BAUD : SERCOM_BAUD_SERCOM_I2CM_BAUD_Field := 16#0#; -- Baud Rate Value Low BAUDLOW : SERCOM_BAUD_SERCOM_I2CM_BAUDLOW_Field := 16#0#; -- High Speed Baud Rate Value HSBAUD : SERCOM_BAUD_SERCOM_I2CM_HSBAUD_Field := 16#0#; -- High Speed Baud Rate Value Low HSBAUDLOW : SERCOM_BAUD_SERCOM_I2CM_HSBAUDLOW_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_BAUD_SERCOM_I2CM_Register use record BAUD at 0 range 0 .. 7; BAUDLOW at 0 range 8 .. 15; HSBAUD at 0 range 16 .. 23; HSBAUDLOW at 0 range 24 .. 31; end record; -- I2CM Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_I2CM_Register is record -- Master On Bus Interrupt Disable MB : Boolean := False; -- Slave On Bus Interrupt Disable SB : Boolean := False; -- unspecified Reserved_2_6 : HAL.UInt5 := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_I2CM_Register use record MB at 0 range 0 .. 0; SB at 0 range 1 .. 1; Reserved_2_6 at 0 range 2 .. 6; ERROR at 0 range 7 .. 7; end record; -- I2CM Interrupt Enable Set type SERCOM_INTENSET_SERCOM_I2CM_Register is record -- Master On Bus Interrupt Enable MB : Boolean := False; -- Slave On Bus Interrupt Enable SB : Boolean := False; -- unspecified Reserved_2_6 : HAL.UInt5 := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_I2CM_Register use record MB at 0 range 0 .. 0; SB at 0 range 1 .. 1; Reserved_2_6 at 0 range 2 .. 6; ERROR at 0 range 7 .. 7; end record; -- I2CM Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_I2CM_Register is record -- Master On Bus Interrupt MB : Boolean := False; -- Slave On Bus Interrupt SB : Boolean := False; -- unspecified Reserved_2_6 : HAL.UInt5 := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_I2CM_Register use record MB at 0 range 0 .. 0; SB at 0 range 1 .. 1; Reserved_2_6 at 0 range 2 .. 6; ERROR at 0 range 7 .. 7; end record; subtype SERCOM_STATUS_SERCOM_I2CM_BUSSTATE_Field is HAL.UInt2; -- I2CM Status type SERCOM_STATUS_SERCOM_I2CM_Register is record -- Bus Error BUSERR : Boolean := False; -- Arbitration Lost ARBLOST : Boolean := False; -- Received Not Acknowledge RXNACK : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Bus State BUSSTATE : SERCOM_STATUS_SERCOM_I2CM_BUSSTATE_Field := 16#0#; -- SCL Low Timeout LOWTOUT : Boolean := False; -- Clock Hold CLKHOLD : Boolean := False; -- Master SCL Low Extend Timeout MEXTTOUT : Boolean := False; -- Slave SCL Low Extend Timeout SEXTTOUT : Boolean := False; -- Length Error LENERR : Boolean := False; -- unspecified Reserved_11_15 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_I2CM_Register use record BUSERR at 0 range 0 .. 0; ARBLOST at 0 range 1 .. 1; RXNACK at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; BUSSTATE at 0 range 4 .. 5; LOWTOUT at 0 range 6 .. 6; CLKHOLD at 0 range 7 .. 7; MEXTTOUT at 0 range 8 .. 8; SEXTTOUT at 0 range 9 .. 9; LENERR at 0 range 10 .. 10; Reserved_11_15 at 0 range 11 .. 15; end record; -- I2CM Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_I2CM_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- Read-only. System Operation Synchronization Busy SYSOP : Boolean; -- unspecified Reserved_3_3 : HAL.Bit; -- Read-only. Length Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_I2CM_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; SYSOP at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_ADDR_SERCOM_I2CM_ADDR_Field is HAL.UInt11; subtype SERCOM_ADDR_SERCOM_I2CM_LEN_Field is HAL.UInt8; -- I2CM Address type SERCOM_ADDR_SERCOM_I2CM_Register is record -- Address Value ADDR : SERCOM_ADDR_SERCOM_I2CM_ADDR_Field := 16#0#; -- unspecified Reserved_11_12 : HAL.UInt2 := 16#0#; -- Length Enable LENEN : Boolean := False; -- High Speed Mode HS : Boolean := False; -- Ten Bit Addressing Enable TENBITEN : Boolean := False; -- Length LEN : SERCOM_ADDR_SERCOM_I2CM_LEN_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_ADDR_SERCOM_I2CM_Register use record ADDR at 0 range 0 .. 10; Reserved_11_12 at 0 range 11 .. 12; LENEN at 0 range 13 .. 13; HS at 0 range 14 .. 14; TENBITEN at 0 range 15 .. 15; LEN at 0 range 16 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- I2CM Debug Control type SERCOM_DBGCTRL_SERCOM_I2CM_Register is record -- Debug Mode DBGSTOP : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_DBGCTRL_SERCOM_I2CM_Register use record DBGSTOP at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- I2C Master Mode type SercomI2cm_Cluster is record -- I2CM Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_I2CM_Register; -- I2CM Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_I2CM_Register; -- I2CM Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_I2CM_Register; -- I2CM Baud Rate BAUD : aliased SERCOM_BAUD_SERCOM_I2CM_Register; -- I2CM Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_I2CM_Register; -- I2CM Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_I2CM_Register; -- I2CM Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_I2CM_Register; -- I2CM Status STATUS : aliased SERCOM_STATUS_SERCOM_I2CM_Register; -- I2CM Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_I2CM_Register; -- I2CM Address ADDR : aliased SERCOM_ADDR_SERCOM_I2CM_Register; -- I2CM Data DATA : aliased HAL.UInt8; -- I2CM Debug Control DBGCTRL : aliased SERCOM_DBGCTRL_SERCOM_I2CM_Register; end record with Size => 416; for SercomI2cm_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; BAUD at 16#C# range 0 .. 31; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; ADDR at 16#24# range 0 .. 31; DATA at 16#28# range 0 .. 7; DBGCTRL at 16#30# range 0 .. 7; end record; ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ -- I2CS Control A type SERCOM_CTRLA_SERCOM_I2CS_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run during Standby RUNSTDBY : Boolean := False; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- Pin Usage PINOUT : Boolean := False; -- unspecified Reserved_17_19 : HAL.UInt3 := 16#0#; -- SDA Hold Time SDAHOLD : CTRLA_SDAHOLDSelect := SAM_SVD.SERCOM.DISABLE; -- unspecified Reserved_22_22 : HAL.Bit := 16#0#; -- Slave SCL Low Extend Timeout SEXTTOEN : Boolean := False; -- Transfer Speed SPEED : CTRLA_SPEEDSelect := SAM_SVD.SERCOM.STANDARD_AND_FAST_MODE; -- unspecified Reserved_26_26 : HAL.Bit := 16#0#; -- SCL Clock Stretch Mode SCLSM : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- SCL Low Timeout Enable LOWTOUTEN : Boolean := False; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_I2CS_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; PINOUT at 0 range 16 .. 16; Reserved_17_19 at 0 range 17 .. 19; SDAHOLD at 0 range 20 .. 21; Reserved_22_22 at 0 range 22 .. 22; SEXTTOEN at 0 range 23 .. 23; SPEED at 0 range 24 .. 25; Reserved_26_26 at 0 range 26 .. 26; SCLSM at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; LOWTOUTEN at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype SERCOM_CTRLB_SERCOM_I2CS_AMODE_Field is HAL.UInt2; subtype SERCOM_CTRLB_SERCOM_I2CS_CMD_Field is HAL.UInt2; -- I2CS Control B type SERCOM_CTRLB_SERCOM_I2CS_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Smart Mode Enable SMEN : Boolean := False; -- PMBus Group Command GCMD : Boolean := False; -- Automatic Address Acknowledge AACKEN : Boolean := False; -- unspecified Reserved_11_13 : HAL.UInt3 := 16#0#; -- Address Mode AMODE : SERCOM_CTRLB_SERCOM_I2CS_AMODE_Field := 16#0#; -- Command CMD : SERCOM_CTRLB_SERCOM_I2CS_CMD_Field := 16#0#; -- Acknowledge Action ACKACT : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_I2CS_Register use record Reserved_0_7 at 0 range 0 .. 7; SMEN at 0 range 8 .. 8; GCMD at 0 range 9 .. 9; AACKEN at 0 range 10 .. 10; Reserved_11_13 at 0 range 11 .. 13; AMODE at 0 range 14 .. 15; CMD at 0 range 16 .. 17; ACKACT at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype SERCOM_CTRLC_SERCOM_I2CS_SDASETUP_Field is HAL.UInt4; -- I2CS Control C type SERCOM_CTRLC_SERCOM_I2CS_Register is record -- SDA Setup Time SDASETUP : SERCOM_CTRLC_SERCOM_I2CS_SDASETUP_Field := 16#0#; -- unspecified Reserved_4_23 : HAL.UInt20 := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect := SAM_SVD.SERCOM.DATA_TRANS_8BIT; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_I2CS_Register use record SDASETUP at 0 range 0 .. 3; Reserved_4_23 at 0 range 4 .. 23; DATA32B at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; -- I2CS Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_I2CS_Register is record -- Stop Received Interrupt Disable PREC : Boolean := False; -- Address Match Interrupt Disable AMATCH : Boolean := False; -- Data Interrupt Disable DRDY : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_I2CS_Register use record PREC at 0 range 0 .. 0; AMATCH at 0 range 1 .. 1; DRDY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; ERROR at 0 range 7 .. 7; end record; -- I2CS Interrupt Enable Set type SERCOM_INTENSET_SERCOM_I2CS_Register is record -- Stop Received Interrupt Enable PREC : Boolean := False; -- Address Match Interrupt Enable AMATCH : Boolean := False; -- Data Interrupt Enable DRDY : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_I2CS_Register use record PREC at 0 range 0 .. 0; AMATCH at 0 range 1 .. 1; DRDY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; ERROR at 0 range 7 .. 7; end record; -- I2CS Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_I2CS_Register is record -- Stop Received Interrupt PREC : Boolean := False; -- Address Match Interrupt AMATCH : Boolean := False; -- Data Interrupt DRDY : Boolean := False; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_I2CS_Register use record PREC at 0 range 0 .. 0; AMATCH at 0 range 1 .. 1; DRDY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; ERROR at 0 range 7 .. 7; end record; -- I2CS Status type SERCOM_STATUS_SERCOM_I2CS_Register is record -- Bus Error BUSERR : Boolean := False; -- Transmit Collision COLL : Boolean := False; -- Received Not Acknowledge RXNACK : Boolean := False; -- Read/Write Direction DIR : Boolean := False; -- Repeated Start SR : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- SCL Low Timeout LOWTOUT : Boolean := False; -- Clock Hold CLKHOLD : Boolean := False; -- unspecified Reserved_8_8 : HAL.Bit := 16#0#; -- Slave SCL Low Extend Timeout SEXTTOUT : Boolean := False; -- High Speed HS : Boolean := False; -- Transaction Length Error LENERR : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_I2CS_Register use record BUSERR at 0 range 0 .. 0; COLL at 0 range 1 .. 1; RXNACK at 0 range 2 .. 2; DIR at 0 range 3 .. 3; SR at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; LOWTOUT at 0 range 6 .. 6; CLKHOLD at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; SEXTTOUT at 0 range 9 .. 9; HS at 0 range 10 .. 10; LENERR at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; end record; -- I2CS Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_I2CS_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- unspecified Reserved_2_3 : HAL.UInt2; -- Read-only. Length Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_I2CS_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_LENGTH_SERCOM_I2CS_LEN_Field is HAL.UInt8; -- I2CS Length type SERCOM_LENGTH_SERCOM_I2CS_Register is record -- Data Length LEN : SERCOM_LENGTH_SERCOM_I2CS_LEN_Field := 16#0#; -- Data Length Enable LENEN : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_LENGTH_SERCOM_I2CS_Register use record LEN at 0 range 0 .. 7; LENEN at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; end record; subtype SERCOM_ADDR_SERCOM_I2CS_ADDR_Field is HAL.UInt10; subtype SERCOM_ADDR_SERCOM_I2CS_ADDRMASK_Field is HAL.UInt10; -- I2CS Address type SERCOM_ADDR_SERCOM_I2CS_Register is record -- General Call Address Enable GENCEN : Boolean := False; -- Address Value ADDR : SERCOM_ADDR_SERCOM_I2CS_ADDR_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- Ten Bit Addressing Enable TENBITEN : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Address Mask ADDRMASK : SERCOM_ADDR_SERCOM_I2CS_ADDRMASK_Field := 16#0#; -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_ADDR_SERCOM_I2CS_Register use record GENCEN at 0 range 0 .. 0; ADDR at 0 range 1 .. 10; Reserved_11_14 at 0 range 11 .. 14; TENBITEN at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; ADDRMASK at 0 range 17 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -- I2C Slave Mode type SercomI2cs_Cluster is record -- I2CS Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_I2CS_Register; -- I2CS Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_I2CS_Register; -- I2CS Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_I2CS_Register; -- I2CS Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_I2CS_Register; -- I2CS Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_I2CS_Register; -- I2CS Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_I2CS_Register; -- I2CS Status STATUS : aliased SERCOM_STATUS_SERCOM_I2CS_Register; -- I2CS Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_I2CS_Register; -- I2CS Length LENGTH : aliased SERCOM_LENGTH_SERCOM_I2CS_Register; -- I2CS Address ADDR : aliased SERCOM_ADDR_SERCOM_I2CS_Register; -- I2CS Data DATA : aliased HAL.UInt32; end record with Size => 352; for SercomI2cs_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; LENGTH at 16#22# range 0 .. 15; ADDR at 16#24# range 0 .. 31; DATA at 16#28# range 0 .. 31; end record; ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ -- Data Out Pinout type CTRLA_DOPOSelect is (-- DO on PAD[0], SCK on PAD[1] and SS on PAD[2] PAD0, -- DO on PAD[3], SCK on PAD[1] and SS on PAD[2] PAD2) with Size => 2; for CTRLA_DOPOSelect use (PAD0 => 0, PAD2 => 2); -- Data In Pinout type CTRLA_DIPOSelect is (-- SERCOM PAD[0] is used as data input PAD0, -- SERCOM PAD[1] is used as data input PAD1, -- SERCOM PAD[2] is used as data input PAD2, -- SERCOM PAD[3] is used as data input PAD3) with Size => 2; for CTRLA_DIPOSelect use (PAD0 => 0, PAD1 => 1, PAD2 => 2, PAD3 => 3); -- Frame Format type CTRLA_FORMSelect is (-- SPI Frame SPI_FRAME, -- SPI Frame with Addr SPI_FRAME_WITH_ADDR) with Size => 4; for CTRLA_FORMSelect use (SPI_FRAME => 0, SPI_FRAME_WITH_ADDR => 2); -- Clock Phase type CTRLA_CPHASelect is (-- The data is sampled on a leading SCK edge and changed on a trailing SCK -- edge LEADING_EDGE, -- The data is sampled on a trailing SCK edge and changed on a leading SCK -- edge TRAILING_EDGE) with Size => 1; for CTRLA_CPHASelect use (LEADING_EDGE => 0, TRAILING_EDGE => 1); -- Clock Polarity type CTRLA_CPOLSelect is (-- SCK is low when idle IDLE_LOW, -- SCK is high when idle IDLE_HIGH) with Size => 1; for CTRLA_CPOLSelect use (IDLE_LOW => 0, IDLE_HIGH => 1); -- Data Order type CTRLA_DORDSelect is (-- MSB is transferred first MSB, -- LSB is transferred first LSB) with Size => 1; for CTRLA_DORDSelect use (MSB => 0, LSB => 1); -- SPIS Control A type SERCOM_CTRLA_SERCOM_SPIS_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run during Standby RUNSTDBY : Boolean := False; -- Immediate Buffer Overflow Notification IBON : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- Data Out Pinout DOPO : CTRLA_DOPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Data In Pinout DIPO : CTRLA_DIPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Frame Format FORM : CTRLA_FORMSelect := SAM_SVD.SERCOM.SPI_FRAME; -- Clock Phase CPHA : CTRLA_CPHASelect := SAM_SVD.SERCOM.LEADING_EDGE; -- Clock Polarity CPOL : CTRLA_CPOLSelect := SAM_SVD.SERCOM.IDLE_LOW; -- Data Order DORD : CTRLA_DORDSelect := SAM_SVD.SERCOM.MSB; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_SPIS_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; IBON at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; DOPO at 0 range 16 .. 17; Reserved_18_19 at 0 range 18 .. 19; DIPO at 0 range 20 .. 21; Reserved_22_23 at 0 range 22 .. 23; FORM at 0 range 24 .. 27; CPHA at 0 range 28 .. 28; CPOL at 0 range 29 .. 29; DORD at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- Character Size type CTRLB_CHSIZESelect is (-- 8 bits Val_8_BIT, -- 9 bits Val_9_BIT) with Size => 3; for CTRLB_CHSIZESelect use (Val_8_BIT => 0, Val_9_BIT => 1); -- Address Mode type CTRLB_AMODESelect is (-- SPI Address mask MASK, -- Two unique Addressess Val_2_ADDRESSES, -- Address Range RANGE_k) with Size => 2; for CTRLB_AMODESelect use (MASK => 0, Val_2_ADDRESSES => 1, RANGE_k => 2); -- SPIS Control B type SERCOM_CTRLB_SERCOM_SPIS_Register is record -- Character Size CHSIZE : CTRLB_CHSIZESelect := SAM_SVD.SERCOM.Val_8_BIT; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Data Preload Enable PLOADEN : Boolean := False; -- unspecified Reserved_7_8 : HAL.UInt2 := 16#0#; -- Slave Select Low Detect Enable SSDE : Boolean := False; -- unspecified Reserved_10_12 : HAL.UInt3 := 16#0#; -- Master Slave Select Enable MSSEN : Boolean := False; -- Address Mode AMODE : CTRLB_AMODESelect := SAM_SVD.SERCOM.MASK; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Receiver Enable RXEN : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_SPIS_Register use record CHSIZE at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PLOADEN at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; SSDE at 0 range 9 .. 9; Reserved_10_12 at 0 range 10 .. 12; MSSEN at 0 range 13 .. 13; AMODE at 0 range 14 .. 15; Reserved_16_16 at 0 range 16 .. 16; RXEN at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; subtype SERCOM_CTRLC_SERCOM_SPIS_ICSPACE_Field is HAL.UInt6; -- SPIS Control C type SERCOM_CTRLC_SERCOM_SPIS_Register is record -- Inter-Character Spacing ICSPACE : SERCOM_CTRLC_SERCOM_SPIS_ICSPACE_Field := 16#0#; -- unspecified Reserved_6_23 : HAL.UInt18 := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect := SAM_SVD.SERCOM.DATA_TRANS_8BIT; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_SPIS_Register use record ICSPACE at 0 range 0 .. 5; Reserved_6_23 at 0 range 6 .. 23; DATA32B at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; -- SPIS Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_SPIS_Register is record -- Data Register Empty Interrupt Disable DRE : Boolean := False; -- Transmit Complete Interrupt Disable TXC : Boolean := False; -- Receive Complete Interrupt Disable RXC : Boolean := False; -- Slave Select Low Interrupt Disable SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_SPIS_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIS Interrupt Enable Set type SERCOM_INTENSET_SERCOM_SPIS_Register is record -- Data Register Empty Interrupt Enable DRE : Boolean := False; -- Transmit Complete Interrupt Enable TXC : Boolean := False; -- Receive Complete Interrupt Enable RXC : Boolean := False; -- Slave Select Low Interrupt Enable SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_SPIS_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIS Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_SPIS_Register is record -- Data Register Empty Interrupt DRE : Boolean := False; -- Transmit Complete Interrupt TXC : Boolean := False; -- Receive Complete Interrupt RXC : Boolean := False; -- Slave Select Low Interrupt Flag SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_SPIS_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIS Status type SERCOM_STATUS_SERCOM_SPIS_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Buffer Overflow BUFOVF : Boolean := False; -- unspecified Reserved_3_10 : HAL.UInt8 := 16#0#; -- Transaction Length Error LENERR : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_SPIS_Register use record Reserved_0_1 at 0 range 0 .. 1; BUFOVF at 0 range 2 .. 2; Reserved_3_10 at 0 range 3 .. 10; LENERR at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; end record; -- SPIS Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_SPIS_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- Read-only. CTRLB Synchronization Busy CTRLB : Boolean; -- unspecified Reserved_3_3 : HAL.Bit; -- Read-only. LENGTH Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_SPIS_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CTRLB at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_LENGTH_SERCOM_SPIS_LEN_Field is HAL.UInt8; -- SPIS Length type SERCOM_LENGTH_SERCOM_SPIS_Register is record -- Data Length LEN : SERCOM_LENGTH_SERCOM_SPIS_LEN_Field := 16#0#; -- Data Length Enable LENEN : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_LENGTH_SERCOM_SPIS_Register use record LEN at 0 range 0 .. 7; LENEN at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; end record; subtype SERCOM_ADDR_SERCOM_SPIS_ADDR_Field is HAL.UInt8; subtype SERCOM_ADDR_SERCOM_SPIS_ADDRMASK_Field is HAL.UInt8; -- SPIS Address type SERCOM_ADDR_SERCOM_SPIS_Register is record -- Address Value ADDR : SERCOM_ADDR_SERCOM_SPIS_ADDR_Field := 16#0#; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- Address Mask ADDRMASK : SERCOM_ADDR_SERCOM_SPIS_ADDRMASK_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_ADDR_SERCOM_SPIS_Register use record ADDR at 0 range 0 .. 7; Reserved_8_15 at 0 range 8 .. 15; ADDRMASK at 0 range 16 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- SPIS Debug Control type SERCOM_DBGCTRL_SERCOM_SPIS_Register is record -- Debug Mode DBGSTOP : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_DBGCTRL_SERCOM_SPIS_Register use record DBGSTOP at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- SPI Slave Mode type SercomSpis_Cluster is record -- SPIS Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_SPIS_Register; -- SPIS Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_SPIS_Register; -- SPIS Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_SPIS_Register; -- SPIS Baud Rate BAUD : aliased HAL.UInt8; -- SPIS Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_SPIS_Register; -- SPIS Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_SPIS_Register; -- SPIS Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_SPIS_Register; -- SPIS Status STATUS : aliased SERCOM_STATUS_SERCOM_SPIS_Register; -- SPIS Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_SPIS_Register; -- SPIS Length LENGTH : aliased SERCOM_LENGTH_SERCOM_SPIS_Register; -- SPIS Address ADDR : aliased SERCOM_ADDR_SERCOM_SPIS_Register; -- SPIS Data DATA : aliased HAL.UInt32; -- SPIS Debug Control DBGCTRL : aliased SERCOM_DBGCTRL_SERCOM_SPIS_Register; end record with Size => 416; for SercomSpis_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; BAUD at 16#C# range 0 .. 7; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; LENGTH at 16#22# range 0 .. 15; ADDR at 16#24# range 0 .. 31; DATA at 16#28# range 0 .. 31; DBGCTRL at 16#30# range 0 .. 7; end record; ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ -- SPIM Control A type SERCOM_CTRLA_SERCOM_SPIM_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run during Standby RUNSTDBY : Boolean := False; -- Immediate Buffer Overflow Notification IBON : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; -- Data Out Pinout DOPO : CTRLA_DOPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Data In Pinout DIPO : CTRLA_DIPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_22_23 : HAL.UInt2 := 16#0#; -- Frame Format FORM : CTRLA_FORMSelect := SAM_SVD.SERCOM.SPI_FRAME; -- Clock Phase CPHA : CTRLA_CPHASelect := SAM_SVD.SERCOM.LEADING_EDGE; -- Clock Polarity CPOL : CTRLA_CPOLSelect := SAM_SVD.SERCOM.IDLE_LOW; -- Data Order DORD : CTRLA_DORDSelect := SAM_SVD.SERCOM.MSB; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_SPIM_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; IBON at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; DOPO at 0 range 16 .. 17; Reserved_18_19 at 0 range 18 .. 19; DIPO at 0 range 20 .. 21; Reserved_22_23 at 0 range 22 .. 23; FORM at 0 range 24 .. 27; CPHA at 0 range 28 .. 28; CPOL at 0 range 29 .. 29; DORD at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- SPIM Control B type SERCOM_CTRLB_SERCOM_SPIM_Register is record -- Character Size CHSIZE : CTRLB_CHSIZESelect := SAM_SVD.SERCOM.Val_8_BIT; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Data Preload Enable PLOADEN : Boolean := False; -- unspecified Reserved_7_8 : HAL.UInt2 := 16#0#; -- Slave Select Low Detect Enable SSDE : Boolean := False; -- unspecified Reserved_10_12 : HAL.UInt3 := 16#0#; -- Master Slave Select Enable MSSEN : Boolean := False; -- Address Mode AMODE : CTRLB_AMODESelect := SAM_SVD.SERCOM.MASK; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Receiver Enable RXEN : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_SPIM_Register use record CHSIZE at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PLOADEN at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; SSDE at 0 range 9 .. 9; Reserved_10_12 at 0 range 10 .. 12; MSSEN at 0 range 13 .. 13; AMODE at 0 range 14 .. 15; Reserved_16_16 at 0 range 16 .. 16; RXEN at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; subtype SERCOM_CTRLC_SERCOM_SPIM_ICSPACE_Field is HAL.UInt6; -- SPIM Control C type SERCOM_CTRLC_SERCOM_SPIM_Register is record -- Inter-Character Spacing ICSPACE : SERCOM_CTRLC_SERCOM_SPIM_ICSPACE_Field := 16#0#; -- unspecified Reserved_6_23 : HAL.UInt18 := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect := SAM_SVD.SERCOM.DATA_TRANS_8BIT; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_SPIM_Register use record ICSPACE at 0 range 0 .. 5; Reserved_6_23 at 0 range 6 .. 23; DATA32B at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; -- SPIM Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_SPIM_Register is record -- Data Register Empty Interrupt Disable DRE : Boolean := False; -- Transmit Complete Interrupt Disable TXC : Boolean := False; -- Receive Complete Interrupt Disable RXC : Boolean := False; -- Slave Select Low Interrupt Disable SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_SPIM_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIM Interrupt Enable Set type SERCOM_INTENSET_SERCOM_SPIM_Register is record -- Data Register Empty Interrupt Enable DRE : Boolean := False; -- Transmit Complete Interrupt Enable TXC : Boolean := False; -- Receive Complete Interrupt Enable RXC : Boolean := False; -- Slave Select Low Interrupt Enable SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_SPIM_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIM Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_SPIM_Register is record -- Data Register Empty Interrupt DRE : Boolean := False; -- Transmit Complete Interrupt TXC : Boolean := False; -- Receive Complete Interrupt RXC : Boolean := False; -- Slave Select Low Interrupt Flag SSL : Boolean := False; -- unspecified Reserved_4_6 : HAL.UInt3 := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_SPIM_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; SSL at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ERROR at 0 range 7 .. 7; end record; -- SPIM Status type SERCOM_STATUS_SERCOM_SPIM_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Buffer Overflow BUFOVF : Boolean := False; -- unspecified Reserved_3_10 : HAL.UInt8 := 16#0#; -- Transaction Length Error LENERR : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_SPIM_Register use record Reserved_0_1 at 0 range 0 .. 1; BUFOVF at 0 range 2 .. 2; Reserved_3_10 at 0 range 3 .. 10; LENERR at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; end record; -- SPIM Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_SPIM_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- Read-only. CTRLB Synchronization Busy CTRLB : Boolean; -- unspecified Reserved_3_3 : HAL.Bit; -- Read-only. LENGTH Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_SPIM_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CTRLB at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_LENGTH_SERCOM_SPIM_LEN_Field is HAL.UInt8; -- SPIM Length type SERCOM_LENGTH_SERCOM_SPIM_Register is record -- Data Length LEN : SERCOM_LENGTH_SERCOM_SPIM_LEN_Field := 16#0#; -- Data Length Enable LENEN : Boolean := False; -- unspecified Reserved_9_15 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_LENGTH_SERCOM_SPIM_Register use record LEN at 0 range 0 .. 7; LENEN at 0 range 8 .. 8; Reserved_9_15 at 0 range 9 .. 15; end record; subtype SERCOM_ADDR_SERCOM_SPIM_ADDR_Field is HAL.UInt8; subtype SERCOM_ADDR_SERCOM_SPIM_ADDRMASK_Field is HAL.UInt8; -- SPIM Address type SERCOM_ADDR_SERCOM_SPIM_Register is record -- Address Value ADDR : SERCOM_ADDR_SERCOM_SPIM_ADDR_Field := 16#0#; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; -- Address Mask ADDRMASK : SERCOM_ADDR_SERCOM_SPIM_ADDRMASK_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_ADDR_SERCOM_SPIM_Register use record ADDR at 0 range 0 .. 7; Reserved_8_15 at 0 range 8 .. 15; ADDRMASK at 0 range 16 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- SPIM Debug Control type SERCOM_DBGCTRL_SERCOM_SPIM_Register is record -- Debug Mode DBGSTOP : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_DBGCTRL_SERCOM_SPIM_Register use record DBGSTOP at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; -- SPI Master Mode type SercomSpim_Cluster is record -- SPIM Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_SPIM_Register; -- SPIM Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_SPIM_Register; -- SPIM Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_SPIM_Register; -- SPIM Baud Rate BAUD : aliased HAL.UInt8; -- SPIM Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_SPIM_Register; -- SPIM Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_SPIM_Register; -- SPIM Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_SPIM_Register; -- SPIM Status STATUS : aliased SERCOM_STATUS_SERCOM_SPIM_Register; -- SPIM Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_SPIM_Register; -- SPIM Length LENGTH : aliased SERCOM_LENGTH_SERCOM_SPIM_Register; -- SPIM Address ADDR : aliased SERCOM_ADDR_SERCOM_SPIM_Register; -- SPIM Data DATA : aliased HAL.UInt32; -- SPIM Debug Control DBGCTRL : aliased SERCOM_DBGCTRL_SERCOM_SPIM_Register; end record with Size => 416; for SercomSpim_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; BAUD at 16#C# range 0 .. 7; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; LENGTH at 16#22# range 0 .. 15; ADDR at 16#24# range 0 .. 31; DATA at 16#28# range 0 .. 31; DBGCTRL at 16#30# range 0 .. 7; end record; ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- -- Sample type CTRLA_SAMPRSelect is (-- 16x over-sampling using arithmetic baudrate generation Val_16X_ARITHMETIC, -- 16x over-sampling using fractional baudrate generation Val_16X_FRACTIONAL, -- 8x over-sampling using arithmetic baudrate generation Val_8X_ARITHMETIC, -- 8x over-sampling using fractional baudrate generation Val_8X_FRACTIONAL, -- 3x over-sampling using arithmetic baudrate generation Val_3X_ARITHMETIC) with Size => 3; for CTRLA_SAMPRSelect use (Val_16X_ARITHMETIC => 0, Val_16X_FRACTIONAL => 1, Val_8X_ARITHMETIC => 2, Val_8X_FRACTIONAL => 3, Val_3X_ARITHMETIC => 4); -- Transmit Data Pinout type CTRLA_TXPOSelect is (-- SERCOM PAD[0] is used for data transmission PAD0, -- SERCOM_PAD[0] is used for data transmission PAD3) with Size => 2; for CTRLA_TXPOSelect use (PAD0 => 0, PAD3 => 3); -- Receive Data Pinout type CTRLA_RXPOSelect is (-- SERCOM PAD[0] is used for data reception PAD0, -- SERCOM PAD[1] is used for data reception PAD1, -- SERCOM PAD[2] is used for data reception PAD2, -- SERCOM PAD[3] is used for data reception PAD3) with Size => 2; for CTRLA_RXPOSelect use (PAD0 => 0, PAD1 => 1, PAD2 => 2, PAD3 => 3); subtype SERCOM_CTRLA_SERCOM_USART_EXT_SAMPA_Field is HAL.UInt2; -- Frame Format type CTRLA_FORMSelect_1 is (-- USART frame USART_FRAME_NO_PARITY, -- USART frame with parity USART_FRAME_WITH_PARITY, -- LIN Master - Break and sync generation USART_FRAME_LIN_MASTER_MODE, -- Auto-baud - break detection and auto-baud USART_FRAME_AUTO_BAUD_NO_PARITY, -- Auto-baud - break detection and auto-baud with parity USART_FRAME_AUTO_BAUD_WITH_PARITY, -- ISO 7816 USART_FRAME_ISO_7816) with Size => 4; for CTRLA_FORMSelect_1 use (USART_FRAME_NO_PARITY => 0, USART_FRAME_WITH_PARITY => 1, USART_FRAME_LIN_MASTER_MODE => 2, USART_FRAME_AUTO_BAUD_NO_PARITY => 4, USART_FRAME_AUTO_BAUD_WITH_PARITY => 5, USART_FRAME_ISO_7816 => 7); -- Communication Mode type CTRLA_CMODESelect is (-- Asynchronous Communication ASYNC, -- Synchronous Communication SYNC) with Size => 1; for CTRLA_CMODESelect use (ASYNC => 0, SYNC => 1); -- USART_EXT Control A type SERCOM_CTRLA_SERCOM_USART_EXT_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run during Standby RUNSTDBY : Boolean := False; -- Immediate Buffer Overflow Notification IBON : Boolean := False; -- Transmit Data Invert TXINV : Boolean := False; -- Receive Data Invert RXINV : Boolean := False; -- unspecified Reserved_11_12 : HAL.UInt2 := 16#0#; -- Sample SAMPR : CTRLA_SAMPRSelect := SAM_SVD.SERCOM.Val_16X_ARITHMETIC; -- Transmit Data Pinout TXPO : CTRLA_TXPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Receive Data Pinout RXPO : CTRLA_RXPOSelect := SAM_SVD.SERCOM.PAD0; -- Sample Adjustment SAMPA : SERCOM_CTRLA_SERCOM_USART_EXT_SAMPA_Field := 16#0#; -- Frame Format FORM : CTRLA_FORMSelect_1 := SAM_SVD.SERCOM.USART_FRAME_NO_PARITY; -- Communication Mode CMODE : CTRLA_CMODESelect := SAM_SVD.SERCOM.ASYNC; -- Clock Polarity CPOL : CTRLA_CPOLSelect := SAM_SVD.SERCOM.IDLE_LOW; -- Data Order DORD : CTRLA_DORDSelect := SAM_SVD.SERCOM.MSB; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_USART_EXT_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; IBON at 0 range 8 .. 8; TXINV at 0 range 9 .. 9; RXINV at 0 range 10 .. 10; Reserved_11_12 at 0 range 11 .. 12; SAMPR at 0 range 13 .. 15; TXPO at 0 range 16 .. 17; Reserved_18_19 at 0 range 18 .. 19; RXPO at 0 range 20 .. 21; SAMPA at 0 range 22 .. 23; FORM at 0 range 24 .. 27; CMODE at 0 range 28 .. 28; CPOL at 0 range 29 .. 29; DORD at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- Character Size type CTRLB_CHSIZESelect_1 is (-- 8 Bits Val_8_BIT, -- 9 Bits Val_9_BIT, -- 5 Bits Val_5_BIT, -- 6 Bits Val_6_BIT, -- 7 Bits Val_7_BIT) with Size => 3; for CTRLB_CHSIZESelect_1 use (Val_8_BIT => 0, Val_9_BIT => 1, Val_5_BIT => 5, Val_6_BIT => 6, Val_7_BIT => 7); -- Stop Bit Mode type CTRLB_SBMODESelect is (-- One Stop Bit Val_1_BIT, -- Two Stop Bits Val_2_BIT) with Size => 1; for CTRLB_SBMODESelect use (Val_1_BIT => 0, Val_2_BIT => 1); -- Parity Mode type CTRLB_PMODESelect is (-- Even Parity EVEN, -- Odd Parity ODD) with Size => 1; for CTRLB_PMODESelect use (EVEN => 0, ODD => 1); subtype SERCOM_CTRLB_SERCOM_USART_EXT_LINCMD_Field is HAL.UInt2; -- USART_EXT Control B type SERCOM_CTRLB_SERCOM_USART_EXT_Register is record -- Character Size CHSIZE : CTRLB_CHSIZESelect_1 := SAM_SVD.SERCOM.Val_8_BIT; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Stop Bit Mode SBMODE : CTRLB_SBMODESelect := SAM_SVD.SERCOM.Val_1_BIT; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Collision Detection Enable COLDEN : Boolean := False; -- Start of Frame Detection Enable SFDE : Boolean := False; -- Encoding Format ENC : Boolean := False; -- unspecified Reserved_11_12 : HAL.UInt2 := 16#0#; -- Parity Mode PMODE : CTRLB_PMODESelect := SAM_SVD.SERCOM.EVEN; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- Transmitter Enable TXEN : Boolean := False; -- Receiver Enable RXEN : Boolean := False; -- unspecified Reserved_18_23 : HAL.UInt6 := 16#0#; -- LIN Command LINCMD : SERCOM_CTRLB_SERCOM_USART_EXT_LINCMD_Field := 16#0#; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_USART_EXT_Register use record CHSIZE at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; SBMODE at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; COLDEN at 0 range 8 .. 8; SFDE at 0 range 9 .. 9; ENC at 0 range 10 .. 10; Reserved_11_12 at 0 range 11 .. 12; PMODE at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; TXEN at 0 range 16 .. 16; RXEN at 0 range 17 .. 17; Reserved_18_23 at 0 range 18 .. 23; LINCMD at 0 range 24 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype SERCOM_CTRLC_SERCOM_USART_EXT_GTIME_Field is HAL.UInt3; subtype SERCOM_CTRLC_SERCOM_USART_EXT_BRKLEN_Field is HAL.UInt2; subtype SERCOM_CTRLC_SERCOM_USART_EXT_HDRDLY_Field is HAL.UInt2; subtype SERCOM_CTRLC_SERCOM_USART_EXT_MAXITER_Field is HAL.UInt3; -- Data 32 Bit type CTRLC_DATA32BSelect_1 is (-- Data reads and writes according CTRLB.CHSIZE DATA_READ_WRITE_CHSIZE, -- Data reads according CTRLB.CHSIZE and writes according 32-bit extension DATA_READ_CHSIZE_WRITE_32BIT, -- Data reads according 32-bit extension and writes according CTRLB.CHSIZE DATA_READ_32BIT_WRITE_CHSIZE, -- Data reads and writes according 32-bit extension DATA_READ_WRITE_32BIT) with Size => 2; for CTRLC_DATA32BSelect_1 use (DATA_READ_WRITE_CHSIZE => 0, DATA_READ_CHSIZE_WRITE_32BIT => 1, DATA_READ_32BIT_WRITE_CHSIZE => 2, DATA_READ_WRITE_32BIT => 3); -- USART_EXT Control C type SERCOM_CTRLC_SERCOM_USART_EXT_Register is record -- Guard Time GTIME : SERCOM_CTRLC_SERCOM_USART_EXT_GTIME_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- LIN Master Break Length BRKLEN : SERCOM_CTRLC_SERCOM_USART_EXT_BRKLEN_Field := 16#0#; -- LIN Master Header Delay HDRDLY : SERCOM_CTRLC_SERCOM_USART_EXT_HDRDLY_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Inhibit Not Acknowledge INACK : Boolean := False; -- Disable Successive NACK DSNACK : Boolean := False; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Maximum Iterations MAXITER : SERCOM_CTRLC_SERCOM_USART_EXT_MAXITER_Field := 16#0#; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect_1 := SAM_SVD.SERCOM.DATA_READ_WRITE_CHSIZE; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_USART_EXT_Register use record GTIME at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; BRKLEN at 0 range 8 .. 9; HDRDLY at 0 range 10 .. 11; Reserved_12_15 at 0 range 12 .. 15; INACK at 0 range 16 .. 16; DSNACK at 0 range 17 .. 17; Reserved_18_19 at 0 range 18 .. 19; MAXITER at 0 range 20 .. 22; Reserved_23_23 at 0 range 23 .. 23; DATA32B at 0 range 24 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_BAUD_Field is HAL.UInt13; subtype SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_FP_Field is HAL.UInt3; -- USART_EXT Baud Rate type SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_Register is record -- Baud Rate Value BAUD : SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_BAUD_Field := 16#0#; -- Fractional Part FP : SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_FP_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_Register use record BAUD at 0 range 0 .. 12; FP at 0 range 13 .. 15; end record; subtype SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_BAUD_Field is HAL.UInt13; subtype SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_FP_Field is HAL.UInt3; -- USART_EXT Baud Rate type SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_Register is record -- Baud Rate Value BAUD : SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_BAUD_Field := 16#0#; -- Fractional Part FP : SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_FP_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_Register use record BAUD at 0 range 0 .. 12; FP at 0 range 13 .. 15; end record; -- USART_EXT Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_USART_EXT_Register is record -- Data Register Empty Interrupt Disable DRE : Boolean := False; -- Transmit Complete Interrupt Disable TXC : Boolean := False; -- Receive Complete Interrupt Disable RXC : Boolean := False; -- Receive Start Interrupt Disable RXS : Boolean := False; -- Clear To Send Input Change Interrupt Disable CTSIC : Boolean := False; -- Break Received Interrupt Disable RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_USART_EXT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_EXT Interrupt Enable Set type SERCOM_INTENSET_SERCOM_USART_EXT_Register is record -- Data Register Empty Interrupt Enable DRE : Boolean := False; -- Transmit Complete Interrupt Enable TXC : Boolean := False; -- Receive Complete Interrupt Enable RXC : Boolean := False; -- Receive Start Interrupt Enable RXS : Boolean := False; -- Clear To Send Input Change Interrupt Enable CTSIC : Boolean := False; -- Break Received Interrupt Enable RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_USART_EXT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_EXT Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_USART_EXT_Register is record -- Data Register Empty Interrupt DRE : Boolean := False; -- Transmit Complete Interrupt TXC : Boolean := False; -- Receive Complete Interrupt RXC : Boolean := False; -- Receive Start Interrupt RXS : Boolean := False; -- Clear To Send Input Change Interrupt CTSIC : Boolean := False; -- Break Received Interrupt RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_USART_EXT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_EXT Status type SERCOM_STATUS_SERCOM_USART_EXT_Register is record -- Parity Error PERR : Boolean := False; -- Frame Error FERR : Boolean := False; -- Buffer Overflow BUFOVF : Boolean := False; -- Clear To Send CTS : Boolean := False; -- Inconsistent Sync Field ISF : Boolean := False; -- Collision Detected COLL : Boolean := False; -- Transmitter Empty TXE : Boolean := False; -- Maximum Number of Repetitions Reached ITER : Boolean := False; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_USART_EXT_Register use record PERR at 0 range 0 .. 0; FERR at 0 range 1 .. 1; BUFOVF at 0 range 2 .. 2; CTS at 0 range 3 .. 3; ISF at 0 range 4 .. 4; COLL at 0 range 5 .. 5; TXE at 0 range 6 .. 6; ITER at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; end record; -- USART_EXT Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_USART_EXT_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- Read-only. CTRLB Synchronization Busy CTRLB : Boolean; -- Read-only. RXERRCNT Synchronization Busy RXERRCNT : Boolean; -- Read-only. LENGTH Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_USART_EXT_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CTRLB at 0 range 2 .. 2; RXERRCNT at 0 range 3 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_LENGTH_SERCOM_USART_EXT_LEN_Field is HAL.UInt8; subtype SERCOM_LENGTH_SERCOM_USART_EXT_LENEN_Field is HAL.UInt2; -- USART_EXT Length type SERCOM_LENGTH_SERCOM_USART_EXT_Register is record -- Data Length LEN : SERCOM_LENGTH_SERCOM_USART_EXT_LEN_Field := 16#0#; -- Data Length Enable LENEN : SERCOM_LENGTH_SERCOM_USART_EXT_LENEN_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_LENGTH_SERCOM_USART_EXT_Register use record LEN at 0 range 0 .. 7; LENEN at 0 range 8 .. 9; Reserved_10_15 at 0 range 10 .. 15; end record; -- USART_EXT Debug Control type SERCOM_DBGCTRL_SERCOM_USART_EXT_Register is record -- Debug Mode DBGSTOP : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_DBGCTRL_SERCOM_USART_EXT_Register use record DBGSTOP at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; type SercomUsart_ext_Disc is (Default, FRAC_MODE, FRACFP_MODE, USARTFP_MODE); -- USART EXTERNAL CLOCK Mode type SercomUsart_ext_Cluster (Discriminent : SercomUsart_ext_Disc := Default) is record -- USART_EXT Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_USART_EXT_Register; -- USART_EXT Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_USART_EXT_Register; -- USART_EXT Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_USART_EXT_Register; -- USART_EXT Receive Pulse Length RXPL : aliased HAL.UInt8; -- USART_EXT Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_USART_EXT_Register; -- USART_EXT Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_USART_EXT_Register; -- USART_EXT Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_USART_EXT_Register; -- USART_EXT Status STATUS : aliased SERCOM_STATUS_SERCOM_USART_EXT_Register; -- USART_EXT Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_USART_EXT_Register; -- USART_EXT Receive Error Count RXERRCNT : aliased HAL.UInt8; -- USART_EXT Length LENGTH : aliased SERCOM_LENGTH_SERCOM_USART_EXT_Register; -- USART_EXT Data DATA : aliased HAL.UInt32; -- USART_EXT Debug Control DBGCTRL : aliased SERCOM_DBGCTRL_SERCOM_USART_EXT_Register; case Discriminent is when Default => -- USART_EXT Baud Rate BAUD : aliased HAL.UInt16; when FRAC_MODE => -- USART_EXT Baud Rate BAUD_FRAC_MODE : aliased SERCOM_BAUD_FRAC_MODE_SERCOM_USART_EXT_Register; when FRACFP_MODE => -- USART_EXT Baud Rate BAUD_FRACFP_MODE : aliased SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_EXT_Register; when USARTFP_MODE => -- USART_EXT Baud Rate BAUD_USARTFP_MODE : aliased HAL.UInt16; end case; end record with Unchecked_Union, Size => 416; for SercomUsart_ext_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; RXPL at 16#E# range 0 .. 7; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; RXERRCNT at 16#20# range 0 .. 7; LENGTH at 16#22# range 0 .. 15; DATA at 16#28# range 0 .. 31; DBGCTRL at 16#30# range 0 .. 7; BAUD at 16#C# range 0 .. 15; BAUD_FRAC_MODE at 16#C# range 0 .. 15; BAUD_FRACFP_MODE at 16#C# range 0 .. 15; BAUD_USARTFP_MODE at 16#C# range 0 .. 15; end record; ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- subtype SERCOM_CTRLA_SERCOM_USART_INT_SAMPA_Field is HAL.UInt2; -- USART_INT Control A type SERCOM_CTRLA_SERCOM_USART_INT_Register is record -- Software Reset SWRST : Boolean := False; -- Enable ENABLE : Boolean := False; -- Operating Mode MODE : CTRLA_MODESelect := SAM_SVD.SERCOM.USART_EXT_CLK; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- Run during Standby RUNSTDBY : Boolean := False; -- Immediate Buffer Overflow Notification IBON : Boolean := False; -- Transmit Data Invert TXINV : Boolean := False; -- Receive Data Invert RXINV : Boolean := False; -- unspecified Reserved_11_12 : HAL.UInt2 := 16#0#; -- Sample SAMPR : CTRLA_SAMPRSelect := SAM_SVD.SERCOM.Val_16X_ARITHMETIC; -- Transmit Data Pinout TXPO : CTRLA_TXPOSelect := SAM_SVD.SERCOM.PAD0; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Receive Data Pinout RXPO : CTRLA_RXPOSelect := SAM_SVD.SERCOM.PAD0; -- Sample Adjustment SAMPA : SERCOM_CTRLA_SERCOM_USART_INT_SAMPA_Field := 16#0#; -- Frame Format FORM : CTRLA_FORMSelect_1 := SAM_SVD.SERCOM.USART_FRAME_NO_PARITY; -- Communication Mode CMODE : CTRLA_CMODESelect := SAM_SVD.SERCOM.ASYNC; -- Clock Polarity CPOL : CTRLA_CPOLSelect := SAM_SVD.SERCOM.IDLE_LOW; -- Data Order DORD : CTRLA_DORDSelect := SAM_SVD.SERCOM.MSB; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLA_SERCOM_USART_INT_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; MODE at 0 range 2 .. 4; Reserved_5_6 at 0 range 5 .. 6; RUNSTDBY at 0 range 7 .. 7; IBON at 0 range 8 .. 8; TXINV at 0 range 9 .. 9; RXINV at 0 range 10 .. 10; Reserved_11_12 at 0 range 11 .. 12; SAMPR at 0 range 13 .. 15; TXPO at 0 range 16 .. 17; Reserved_18_19 at 0 range 18 .. 19; RXPO at 0 range 20 .. 21; SAMPA at 0 range 22 .. 23; FORM at 0 range 24 .. 27; CMODE at 0 range 28 .. 28; CPOL at 0 range 29 .. 29; DORD at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype SERCOM_CTRLB_SERCOM_USART_INT_LINCMD_Field is HAL.UInt2; -- USART_INT Control B type SERCOM_CTRLB_SERCOM_USART_INT_Register is record -- Character Size CHSIZE : CTRLB_CHSIZESelect_1 := SAM_SVD.SERCOM.Val_8_BIT; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Stop Bit Mode SBMODE : CTRLB_SBMODESelect := SAM_SVD.SERCOM.Val_1_BIT; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Collision Detection Enable COLDEN : Boolean := False; -- Start of Frame Detection Enable SFDE : Boolean := False; -- Encoding Format ENC : Boolean := False; -- unspecified Reserved_11_12 : HAL.UInt2 := 16#0#; -- Parity Mode PMODE : CTRLB_PMODESelect := SAM_SVD.SERCOM.EVEN; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- Transmitter Enable TXEN : Boolean := False; -- Receiver Enable RXEN : Boolean := False; -- unspecified Reserved_18_23 : HAL.UInt6 := 16#0#; -- LIN Command LINCMD : SERCOM_CTRLB_SERCOM_USART_INT_LINCMD_Field := 16#0#; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLB_SERCOM_USART_INT_Register use record CHSIZE at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; SBMODE at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; COLDEN at 0 range 8 .. 8; SFDE at 0 range 9 .. 9; ENC at 0 range 10 .. 10; Reserved_11_12 at 0 range 11 .. 12; PMODE at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; TXEN at 0 range 16 .. 16; RXEN at 0 range 17 .. 17; Reserved_18_23 at 0 range 18 .. 23; LINCMD at 0 range 24 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype SERCOM_CTRLC_SERCOM_USART_INT_GTIME_Field is HAL.UInt3; subtype SERCOM_CTRLC_SERCOM_USART_INT_BRKLEN_Field is HAL.UInt2; subtype SERCOM_CTRLC_SERCOM_USART_INT_HDRDLY_Field is HAL.UInt2; subtype SERCOM_CTRLC_SERCOM_USART_INT_MAXITER_Field is HAL.UInt3; -- USART_INT Control C type SERCOM_CTRLC_SERCOM_USART_INT_Register is record -- Guard Time GTIME : SERCOM_CTRLC_SERCOM_USART_INT_GTIME_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- LIN Master Break Length BRKLEN : SERCOM_CTRLC_SERCOM_USART_INT_BRKLEN_Field := 16#0#; -- LIN Master Header Delay HDRDLY : SERCOM_CTRLC_SERCOM_USART_INT_HDRDLY_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Inhibit Not Acknowledge INACK : Boolean := False; -- Disable Successive NACK DSNACK : Boolean := False; -- unspecified Reserved_18_19 : HAL.UInt2 := 16#0#; -- Maximum Iterations MAXITER : SERCOM_CTRLC_SERCOM_USART_INT_MAXITER_Field := 16#0#; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Data 32 Bit DATA32B : CTRLC_DATA32BSelect_1 := SAM_SVD.SERCOM.DATA_READ_WRITE_CHSIZE; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_CTRLC_SERCOM_USART_INT_Register use record GTIME at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; BRKLEN at 0 range 8 .. 9; HDRDLY at 0 range 10 .. 11; Reserved_12_15 at 0 range 12 .. 15; INACK at 0 range 16 .. 16; DSNACK at 0 range 17 .. 17; Reserved_18_19 at 0 range 18 .. 19; MAXITER at 0 range 20 .. 22; Reserved_23_23 at 0 range 23 .. 23; DATA32B at 0 range 24 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_BAUD_Field is HAL.UInt13; subtype SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_FP_Field is HAL.UInt3; -- USART_INT Baud Rate type SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_Register is record -- Baud Rate Value BAUD : SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_BAUD_Field := 16#0#; -- Fractional Part FP : SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_FP_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_Register use record BAUD at 0 range 0 .. 12; FP at 0 range 13 .. 15; end record; subtype SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_BAUD_Field is HAL.UInt13; subtype SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_FP_Field is HAL.UInt3; -- USART_INT Baud Rate type SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_Register is record -- Baud Rate Value BAUD : SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_BAUD_Field := 16#0#; -- Fractional Part FP : SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_FP_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_Register use record BAUD at 0 range 0 .. 12; FP at 0 range 13 .. 15; end record; -- USART_INT Interrupt Enable Clear type SERCOM_INTENCLR_SERCOM_USART_INT_Register is record -- Data Register Empty Interrupt Disable DRE : Boolean := False; -- Transmit Complete Interrupt Disable TXC : Boolean := False; -- Receive Complete Interrupt Disable RXC : Boolean := False; -- Receive Start Interrupt Disable RXS : Boolean := False; -- Clear To Send Input Change Interrupt Disable CTSIC : Boolean := False; -- Break Received Interrupt Disable RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt Disable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENCLR_SERCOM_USART_INT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_INT Interrupt Enable Set type SERCOM_INTENSET_SERCOM_USART_INT_Register is record -- Data Register Empty Interrupt Enable DRE : Boolean := False; -- Transmit Complete Interrupt Enable TXC : Boolean := False; -- Receive Complete Interrupt Enable RXC : Boolean := False; -- Receive Start Interrupt Enable RXS : Boolean := False; -- Clear To Send Input Change Interrupt Enable CTSIC : Boolean := False; -- Break Received Interrupt Enable RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt Enable ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTENSET_SERCOM_USART_INT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_INT Interrupt Flag Status and Clear type SERCOM_INTFLAG_SERCOM_USART_INT_Register is record -- Data Register Empty Interrupt DRE : Boolean := False; -- Transmit Complete Interrupt TXC : Boolean := False; -- Receive Complete Interrupt RXC : Boolean := False; -- Receive Start Interrupt RXS : Boolean := False; -- Clear To Send Input Change Interrupt CTSIC : Boolean := False; -- Break Received Interrupt RXBRK : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- Combined Error Interrupt ERROR : Boolean := False; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_INTFLAG_SERCOM_USART_INT_Register use record DRE at 0 range 0 .. 0; TXC at 0 range 1 .. 1; RXC at 0 range 2 .. 2; RXS at 0 range 3 .. 3; CTSIC at 0 range 4 .. 4; RXBRK at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; ERROR at 0 range 7 .. 7; end record; -- USART_INT Status type SERCOM_STATUS_SERCOM_USART_INT_Register is record -- Parity Error PERR : Boolean := False; -- Frame Error FERR : Boolean := False; -- Buffer Overflow BUFOVF : Boolean := False; -- Clear To Send CTS : Boolean := False; -- Inconsistent Sync Field ISF : Boolean := False; -- Collision Detected COLL : Boolean := False; -- Transmitter Empty TXE : Boolean := False; -- Maximum Number of Repetitions Reached ITER : Boolean := False; -- unspecified Reserved_8_15 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_STATUS_SERCOM_USART_INT_Register use record PERR at 0 range 0 .. 0; FERR at 0 range 1 .. 1; BUFOVF at 0 range 2 .. 2; CTS at 0 range 3 .. 3; ISF at 0 range 4 .. 4; COLL at 0 range 5 .. 5; TXE at 0 range 6 .. 6; ITER at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; end record; -- USART_INT Synchronization Busy type SERCOM_SYNCBUSY_SERCOM_USART_INT_Register is record -- Read-only. Software Reset Synchronization Busy SWRST : Boolean; -- Read-only. SERCOM Enable Synchronization Busy ENABLE : Boolean; -- Read-only. CTRLB Synchronization Busy CTRLB : Boolean; -- Read-only. RXERRCNT Synchronization Busy RXERRCNT : Boolean; -- Read-only. LENGTH Synchronization Busy LENGTH : Boolean; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SERCOM_SYNCBUSY_SERCOM_USART_INT_Register use record SWRST at 0 range 0 .. 0; ENABLE at 0 range 1 .. 1; CTRLB at 0 range 2 .. 2; RXERRCNT at 0 range 3 .. 3; LENGTH at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SERCOM_LENGTH_SERCOM_USART_INT_LEN_Field is HAL.UInt8; subtype SERCOM_LENGTH_SERCOM_USART_INT_LENEN_Field is HAL.UInt2; -- USART_INT Length type SERCOM_LENGTH_SERCOM_USART_INT_Register is record -- Data Length LEN : SERCOM_LENGTH_SERCOM_USART_INT_LEN_Field := 16#0#; -- Data Length Enable LENEN : SERCOM_LENGTH_SERCOM_USART_INT_LENEN_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Object_Size => 16, Bit_Order => System.Low_Order_First; for SERCOM_LENGTH_SERCOM_USART_INT_Register use record LEN at 0 range 0 .. 7; LENEN at 0 range 8 .. 9; Reserved_10_15 at 0 range 10 .. 15; end record; -- USART_INT Debug Control type SERCOM_DBGCTRL_SERCOM_USART_INT_Register is record -- Debug Mode DBGSTOP : Boolean := False; -- unspecified Reserved_1_7 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for SERCOM_DBGCTRL_SERCOM_USART_INT_Register use record DBGSTOP at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; end record; type SercomUsart_int_Disc is (Default, FRAC_MODE, FRACFP_MODE, USARTFP_MODE); -- USART INTERNAL CLOCK Mode type SercomUsart_int_Cluster (Discriminent : SercomUsart_int_Disc := Default) is record -- USART_INT Control A CTRLA : aliased SERCOM_CTRLA_SERCOM_USART_INT_Register; -- USART_INT Control B CTRLB : aliased SERCOM_CTRLB_SERCOM_USART_INT_Register; -- USART_INT Control C CTRLC : aliased SERCOM_CTRLC_SERCOM_USART_INT_Register; -- USART_INT Receive Pulse Length RXPL : aliased HAL.UInt8; -- USART_INT Interrupt Enable Clear INTENCLR : aliased SERCOM_INTENCLR_SERCOM_USART_INT_Register; -- USART_INT Interrupt Enable Set INTENSET : aliased SERCOM_INTENSET_SERCOM_USART_INT_Register; -- USART_INT Interrupt Flag Status and Clear INTFLAG : aliased SERCOM_INTFLAG_SERCOM_USART_INT_Register; -- USART_INT Status STATUS : aliased SERCOM_STATUS_SERCOM_USART_INT_Register; -- USART_INT Synchronization Busy SYNCBUSY : aliased SERCOM_SYNCBUSY_SERCOM_USART_INT_Register; -- USART_INT Receive Error Count RXERRCNT : aliased HAL.UInt8; -- USART_INT Length LENGTH : aliased SERCOM_LENGTH_SERCOM_USART_INT_Register; -- USART_INT Data DATA : aliased HAL.UInt32; -- USART_INT Debug Control DBGCTRL : aliased SERCOM_DBGCTRL_SERCOM_USART_INT_Register; case Discriminent is when Default => -- USART_INT Baud Rate BAUD : aliased HAL.UInt16; when FRAC_MODE => -- USART_INT Baud Rate BAUD_FRAC_MODE : aliased SERCOM_BAUD_FRAC_MODE_SERCOM_USART_INT_Register; when FRACFP_MODE => -- USART_INT Baud Rate BAUD_FRACFP_MODE : aliased SERCOM_BAUD_FRACFP_MODE_SERCOM_USART_INT_Register; when USARTFP_MODE => -- USART_INT Baud Rate BAUD_USARTFP_MODE : aliased HAL.UInt16; end case; end record with Unchecked_Union, Size => 416; for SercomUsart_int_Cluster use record CTRLA at 16#0# range 0 .. 31; CTRLB at 16#4# range 0 .. 31; CTRLC at 16#8# range 0 .. 31; RXPL at 16#E# range 0 .. 7; INTENCLR at 16#14# range 0 .. 7; INTENSET at 16#16# range 0 .. 7; INTFLAG at 16#18# range 0 .. 7; STATUS at 16#1A# range 0 .. 15; SYNCBUSY at 16#1C# range 0 .. 31; RXERRCNT at 16#20# range 0 .. 7; LENGTH at 16#22# range 0 .. 15; DATA at 16#28# range 0 .. 31; DBGCTRL at 16#30# range 0 .. 7; BAUD at 16#C# range 0 .. 15; BAUD_FRAC_MODE at 16#C# range 0 .. 15; BAUD_FRACFP_MODE at 16#C# range 0 .. 15; BAUD_USARTFP_MODE at 16#C# range 0 .. 15; end record; ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- ------------------------------------ -- SercomI2cm cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomI2cs cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpis cluster's Registers -- ------------------------------------ ------------------------------------ -- SercomSpim cluster's Registers -- ------------------------------------ ----------------------------------------- -- SercomUsart_ext cluster's Registers -- ----------------------------------------- ----------------------------------------- -- SercomUsart_int cluster's Registers -- ----------------------------------------- ----------------- -- Peripherals -- ----------------- type SERCOM0_Disc is (I2CM, I2CS, SPIS, SPIM, USART_EXT, USART_INT); -- Serial Communication Interface type SERCOM_Peripheral (Discriminent : SERCOM0_Disc := I2CM) is record case Discriminent is when I2CM => -- I2C Master Mode SERCOM_I2CM : aliased SercomI2cm_Cluster; when I2CS => -- I2C Slave Mode SERCOM_I2CS : aliased SercomI2cs_Cluster; when SPIS => -- SPI Slave Mode SERCOM_SPIS : aliased SercomSpis_Cluster; when SPIM => -- SPI Master Mode SERCOM_SPIM : aliased SercomSpim_Cluster; when USART_EXT => -- USART EXTERNAL CLOCK Mode SERCOM_USART_EXT : aliased SercomUsart_ext_Cluster; when USART_INT => -- USART INTERNAL CLOCK Mode SERCOM_USART_INT : aliased SercomUsart_int_Cluster; end case; end record with Unchecked_Union, Volatile; for SERCOM_Peripheral use record SERCOM_I2CM at 0 range 0 .. 415; SERCOM_I2CS at 0 range 0 .. 351; SERCOM_SPIS at 0 range 0 .. 415; SERCOM_SPIM at 0 range 0 .. 415; SERCOM_USART_EXT at 0 range 0 .. 415; SERCOM_USART_INT at 0 range 0 .. 415; end record; -- Serial Communication Interface SERCOM0_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM0_Base; -- Serial Communication Interface SERCOM1_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM1_Base; -- Serial Communication Interface SERCOM2_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM2_Base; -- Serial Communication Interface SERCOM3_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM3_Base; -- Serial Communication Interface SERCOM4_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM4_Base; -- Serial Communication Interface SERCOM5_Periph : aliased SERCOM_Peripheral with Import, Address => SERCOM5_Base; end SAM_SVD.SERCOM;
with Asis.Iterator, AdaM.Assist.Query.find_Entities.Actuals_for_traversing; package body AdaM.Assist.Query.find_Entities.element_Processing is procedure Recursive_Construct_Processing is new Asis.Iterator.Traverse_Element (State_Information => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Traversal_State, Pre_Operation => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Pre_Op, Post_Operation => AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Post_Op); procedure Process_Construct (The_Element : Asis.Element) is Process_Control : Asis.Traverse_Control := Asis.Continue; Process_State : AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Traversal_State := AdaM.Assist.Query.find_Entities.Actuals_for_traversing.Initial_Traversal_State; begin Recursive_Construct_Processing (Element => The_Element, Control => Process_Control, State => Process_State); end Process_Construct; end AdaM.Assist.Query.find_Entities.element_Processing;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting; with Ada.Text_IO; use Ada.Text_IO; procedure Yuletide is begin for Year in 2008..2121 loop if Day_Of_Week (Time_Of (Year, 12, 25)) = Sunday then Put_Line (Image (Time_Of (Year, 12, 25))); end if; end loop; end Yuletide;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S T Y L E G -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This generic package collects the routines used for style checking, as -- activated by the relevant command line option. These are gathered in -- a separate package so that they can more easily be customized. Calls -- to these subprograms are only made if Opt.Style_Check is set True. -- Styleg does not depends on the GNAT tree (Atree, Sinfo, ...). -- For the compiler, there is also a child package Styleg.C that depends -- on the GNAT tree. with Types; use Types; generic with procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr); -- Output a message at specified location with procedure Error_Msg_S (Msg : String); -- Output a message at current scan pointer location with procedure Error_Msg_SC (Msg : String); -- Output a message at the start of the current token with procedure Error_Msg_SP (Msg : String); -- Output a message at the start of the previous token package Styleg is procedure Check_Abs_Not; -- Called after scanning an ABS or NOT operator to check spacing procedure Check_Apostrophe; -- Called after scanning an apostrophe to check spacing procedure Check_Arrow; -- Called after scanning out an arrow to check spacing procedure Check_Attribute_Name (Reserved : Boolean); -- The current token is an attribute designator. Check that it -- is capitalized in an appropriate manner. Reserved is set if -- the attribute designator is a reserved word (access, digits, -- delta or range) to allow differing rules for the two cases. procedure Check_Box; -- Called after scanning out a box to check spacing procedure Check_Binary_Operator; -- Called after scanning out a binary operator other than a plus, minus -- or exponentiation operator. Intended for checking spacing rules. procedure Check_Exponentiation_Operator; -- Called after scanning out an exponentiation operator. Intended for -- checking spacing rules. procedure Check_Colon; -- Called after scanning out colon to check spacing procedure Check_Colon_Equal; -- Called after scanning out colon equal to check spacing procedure Check_Comma; -- Called after scanning out comma to check spacing procedure Check_Comment; -- Called with Scan_Ptr pointing to the first minus sign of a comment. -- Intended for checking any specific rules for comment placement/format. procedure Check_Dot_Dot; -- Called after scanning out dot dot to check spacing procedure Check_EOF; -- Called after scanning out EOF mark procedure Check_HT; -- Called with Scan_Ptr pointing to a horizontal tab character procedure Check_Indentation; -- Called at the start of a new statement or declaration, with Token_Ptr -- pointing to the first token of the statement or declaration. The check -- is that the starting column is appropriate to the indentation rules if -- Token_Ptr is the first token on the line. procedure Check_Left_Paren; -- Called after scanning out a left parenthesis to check spacing procedure Check_Line_Max_Length (Len : Int); -- Called with Scan_Ptr pointing to the first line terminator character -- terminating the current line. Used to check for appropriate line length. -- The parameter Len is the length of the current line. procedure Check_Line_Terminator (Len : Int); -- Called with Scan_Ptr pointing to the first line terminator terminating -- the current line, used to check for appropriate line terminator usage. -- The parameter Len is the length of the current line. procedure Check_Pragma_Name; -- The current token is a pragma identifier. Check that it is spelled -- properly (i.e. with an appropriate casing convention). procedure Check_Right_Paren; -- Called after scanning out a right parenthesis to check spacing procedure Check_Semicolon; -- Called after scanning out a semicolon to check spacing procedure Check_Then (If_Loc : Source_Ptr); -- Called to check that THEN and IF keywords are appropriately positioned. -- The parameters show the first characters of the two keywords. This -- procedure is called only if THEN appears at the start of a line with -- Token_Ptr pointing to the THEN keyword. procedure Check_Unary_Plus_Or_Minus; -- Called after scanning a unary plus or minus to check spacing procedure Check_Vertical_Bar; -- Called after scanning a vertical bar to check spacing procedure Check_Xtra_Parens (Loc : Source_Ptr); -- Called after scanning a conditional expression that has at least one -- level of parentheses around the entire expression. function Mode_In_Check return Boolean; pragma Inline (Mode_In_Check); -- Determines whether style checking is active and the Mode_In_Check is -- set, forbidding the explicit use of mode IN. procedure No_End_Name (Name : Node_Id); -- Called if an END is encountered where a name is allowed but not present. -- The parameter is the node whose name is the name that is permitted in -- the END line, and the scan pointer is positioned so that if an error -- message is to be generated in this situation, it should be generated -- using Error_Msg_SP. procedure No_Exit_Name (Name : Node_Id); -- Called when exiting a named loop, but a name is not present on the EXIT. -- The parameter is the node whose name should have followed EXIT, and the -- scan pointer is positioned so that if an error message is to be -- generated, it should be generated using Error_Msg_SP. procedure Non_Lower_Case_Keyword; -- Called if a reserved keyword is scanned which is not spelled in all -- lower case letters. On entry Token_Ptr points to the keyword token. -- This is not used for keywords appearing as attribute designators, -- where instead Check_Attribute_Name (True) is called. function RM_Column_Check return Boolean; pragma Inline (RM_Column_Check); -- Determines whether style checking is active and the RM column check -- mode is set requiring checking of RM format layout. end Styleg;
-- Databases - A simple database library for Ada applications -- (c) Kristian Klomsten Skordal 2019 <kristian.skordal@wafflemail.net> -- Report bugs and issues on <https://github.com/skordal/databases/issues> -- vim:ts=3:sw=3:et:si:sta with Databases; package Databases.Utilities is -- Directly executes a statement and returns only the status: function Execute (Database : in Databases.Database_Access; Statement : in String) return Databases.Statement_Execution_Status; end Databases.Utilities;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, 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. -- -- -- ------------------------------------------------------------------------------ -- This packages provide a low level driver for the FAT file system -- architecture. It is recommended to _not_ use this interface directly but to -- access the file system using the File_IO package. For more info, see the -- file system chapter of the documentation. with Ada.Unchecked_Conversion; with Filesystem.FAT.Directories; with Filesystem.FAT.Files; package body Filesystem.FAT is The_File_Handles : array (1 .. MAX_FILE_HANDLES) of aliased FAT_File_Handle; Last_File_Handle : Natural := 0; The_Dir_Handles : array (1 .. MAX_DIR_HANDLES) of aliased FAT_Directory_Handle; Last_Dir_Handle : Natural := 0; function Find_Free_Dir_Handle return FAT_Directory_Handle_Access; function Find_Free_File_Handle return FAT_File_Handle_Access; procedure Initialize_FS (FS : in out FAT_Filesystem; Status : out Status_Code); -------------------------- -- Find_Free_Dir_Handle -- -------------------------- function Find_Free_Dir_Handle return FAT_Directory_Handle_Access is Found : Boolean := False; begin for J in Last_Dir_Handle + 1 .. The_Dir_Handles'Last loop if The_Dir_Handles (J).Is_Free then The_Dir_Handles (J).Is_Free := False; Last_Dir_Handle := J; Found := True; exit; end if; end loop; if not Found then for J in The_Dir_Handles'First .. Last_Dir_Handle loop if The_Dir_Handles (J).Is_Free then The_Dir_Handles (J).Is_Free := False; Last_Dir_Handle := J; Found := True; exit; end if; end loop; end if; if not Found then return null; else return The_Dir_Handles (Last_Dir_Handle)'Access; end if; end Find_Free_Dir_Handle; --------------------------- -- Find_Free_File_Handle -- --------------------------- function Find_Free_File_Handle return FAT_File_Handle_Access is begin for J in Last_File_Handle + 1 .. The_File_Handles'Last loop if The_File_Handles (J).Is_Free then The_File_Handles (J).Is_Free := False; Last_File_Handle := J; return The_File_Handles (Last_File_Handle)'Access; end if; end loop; for J in The_File_Handles'First .. Last_File_Handle loop if The_File_Handles (J).Is_Free then The_File_Handles (J).Is_Free := False; Last_File_Handle := J; return The_File_Handles (Last_File_Handle)'Access; end if; end loop; return null; end Find_Free_File_Handle; --------- -- "-" -- --------- function "-" (Name : FAT_Name) return String is begin return Name.Name (1 .. Name.Len); end "-"; --------- -- "-" -- --------- function "-" (Name : String) return FAT_Name is Ret : FAT_Name; begin for J in Name'Range loop if Name (J) = '/' then raise Constraint_Error; end if; end loop; Ret.Len := Name'Length; Ret.Name (1 .. Name'Length) := Name; return Ret; end "-"; --------- -- "=" -- --------- overriding function "=" (Name1, Name2 : FAT_Name) return Boolean is function To_Upper (C : Character) return Character is (if C in 'a' .. 'z' then Character'Val (Character'Pos (C) - Character'Pos ('a') + Character'Pos ('A')) else C); begin if Name1.Len /= Name2.Len then return False; end if; for J in 1 .. Name1.Len loop if To_Upper (Name1.Name (J)) /= To_Upper (Name2.Name (J)) then return False; end if; end loop; return True; end "="; ------------- -- Is_Root -- ------------- function Is_Root (Path : String) return Boolean is begin return Path'Length = 0 or else (Path'Length = 1 and then Path (Path'First) = '/'); end Is_Root; -------------- -- Basename -- -------------- function Basename (Path : String) return String is Last : Natural := Path'Last; begin if Path'Length = 0 then return ""; end if; if Path (Last) = '/' then Last := Last - 1; end if; for J in reverse 1 .. Last loop if Path (J) = '/' then return Path (J + 1 .. Last); end if; end loop; return Path (Path'First .. Last); end Basename; ------------ -- Parent -- ------------ function Parent (Path : String) return String is Last : Natural; begin if Path'Length = 0 then return ""; end if; Last := (if Path (Path'Last) = '/' then Path'Last - 1 else Path'Last); for J in reverse Path'First .. Last loop if Path (J) = '/' then return Path (Path'First .. J); end if; end loop; return ""; end Parent; --------------- -- Normalize -- --------------- function Normalize (Path : String; Ensure_Dir : Boolean := False) return String is Idx : Integer; Prev : Natural; Token : FAT_Name; Last : Natural; Ret : String := Path; begin if Ret'Length = 0 then return "/"; end if; -- Preserve initial '/' if Ret (Ret'First) = '/' then Idx := Ret'First + 1; else Idx := Ret'First; end if; Last := Ret'Last; -- Below: Idx always points to the first character of a path element. while Idx <= Last loop Token.Len := 0; for J in Idx .. Last loop exit when Ret (J) = '/'; Token.Len := Token.Len + 1; Token.Name (Token.Len) := Ret (J); end loop; if -Token = "." then -- Skip if Idx + 2 > Last then -- Ret ends with just a '.' -- remove it: Last := Last - 1; else Ret (Idx .. Last - 2) := Ret (Idx + 2 .. Last); Last := Last - 2; end if; elsif -Token = ".." then if Idx - 1 <= Ret'First then -- We have "/../<subdirs>", or "../<subdirs>". -- invalid but we keep as-is Idx := Idx + 3; else Prev := 0; -- Find the parent directory separator for J in reverse Ret'First .. Idx - 2 loop if Ret (J) = '/' then Prev := J + 1; exit; else Prev := J; end if; end loop; Ret (Prev .. Last + Prev - Idx - 3) := Ret (Idx + 3 .. Last); Last := Last + Prev - Idx - 3; Idx := Prev; end if; elsif Token.Len = 0 then -- We have two consecutive slashes Ret (Idx .. Last - 1) := Ret (Idx + 1 .. Last); Last := Last - 1; else Idx := Idx + Token.Len + 1; end if; end loop; if Last = 0 then if Ensure_Dir then return "/"; else return ""; end if; else if Ret (Ret'First) /= '/' then if Ensure_Dir and then Ret (Last) /= '/' then return "/" & Ret (Ret'First .. Last) & "/"; else return "/" & Ret (Ret'First .. Last); end if; else if Ensure_Dir and then Ret (Last) /= '/' then return Ret (Ret'First .. Last) & "/"; else return Ret (Ret'First .. Last); end if; end if; end if; end Normalize; ---------- -- Trim -- ---------- function Trim (S : String) return String is begin for J in reverse S'Range loop if S (J) /= ' ' then return S (S'First .. J); end if; end loop; return ""; end Trim; ---------- -- Open -- ---------- function Open (Controller : HAL.Block_Drivers.Any_Block_Driver; LBA : Block_Number; FS : in out FAT_Filesystem) return Status_Code is Status : Status_Code; begin FS.Initialized := True; FS.Controller := Controller; FS.LBA := LBA; Initialize_FS (FS, Status); if Status /= OK then FS.Initialized := False; return Status; end if; return OK; end Open; ------------------- -- Initialize_FS -- ------------------- procedure Initialize_FS (FS : in out FAT_Filesystem; Status : out Status_Code) is subtype Disk_Parameter_Block is Block (0 .. 91); function To_Disk_Parameter is new Ada.Unchecked_Conversion (Disk_Parameter_Block, FAT_Disk_Parameter); subtype FSInfo_Block is Block (0 .. 11); function To_FSInfo is new Ada.Unchecked_Conversion (FSInfo_Block, FAT_FS_Info); begin FS.Window_Block := 16#FFFF_FFFF#; Status := FS.Ensure_Block (0); if Status /= OK then return; end if; if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then Status := No_Filesystem; return; end if; FS.Disk_Parameters := To_Disk_Parameter (FS.Window (0 .. 91)); if FS.Version = FAT32 then Status := FS.Ensure_Block (Block_Offset (FS.FSInfo_Block_Number)); if Status /= OK then return; end if; -- Check the generic FAT block signature if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then Status := No_Filesystem; return; end if; FS.FSInfo := To_FSInfo (FS.Window (16#1E4# .. 16#1EF#)); FS.FSInfo_Changed := False; end if; declare FAT_Size_In_Block : constant Unsigned_32 := FS.FAT_Table_Size_In_Blocks * Unsigned_32 (FS.Number_Of_FATs); Root_Dir_Size : Block_Offset; begin FS.FAT_Addr := Block_Offset (FS.Reserved_Blocks); FS.Data_Area := FS.FAT_Addr + Block_Offset (FAT_Size_In_Block); if FS.Version = FAT16 then -- Add space for the root directory FS.Root_Dir_Area := FS.Data_Area; Root_Dir_Size := (Block_Offset (FS.FAT16_Root_Dir_Num_Entries) * 32 + Block_Offset (FS.Block_Size) - 1) / Block_Offset (FS.Block_Size); -- Align on clusters Root_Dir_Size := ((Root_Dir_Size + FS.Blocks_Per_Cluster - 1) / FS.Blocks_Per_Cluster) * FS.Blocks_Per_Cluster; FS.Data_Area := FS.Data_Area + Root_Dir_Size; end if; FS.Num_Clusters := Cluster_Type ((FS.Total_Number_Of_Blocks - Unsigned_32 (FS.Data_Area)) / Unsigned_32 (FS.Blocks_Per_Cluster)); end; FS.Root_Entry := Directories.Root_Entry (FS); end Initialize_FS; ----------- -- Close -- ----------- overriding procedure Close (FS : in out FAT_Filesystem) is begin for J in The_File_Handles'Range loop if not The_File_Handles (J).Is_Free and then The_File_Handles (J).FS = FS'Unchecked_Access then The_File_Handles (J).Close; end if; end loop; for J in The_Dir_Handles'Range loop if not The_Dir_Handles (J).Is_Free and then The_Dir_Handles (J).FS = FS'Unchecked_Access then The_Dir_Handles (J).Close; end if; end loop; if FS.FSInfo_Changed then FS.Write_FSInfo; FS.FSInfo_Changed := False; end if; FS.Initialized := False; end Close; ------------------ -- Ensure_Block -- ------------------ function Ensure_Block (FS : in out FAT_Filesystem; Block : Block_Offset) return Status_Code is begin if Block = FS.Window_Block then return OK; end if; if not FS.Controller.Read (FS.LBA + Block, FS.Window) then FS.Window_Block := 16#FFFF_FFFF#; return Disk_Error; end if; FS.Window_Block := Block; return OK; end Ensure_Block; ---------------- -- Root_Entry -- ---------------- overriding function Root_Node (FS : in out FAT_Filesystem; As : String; Handle : out Any_Node_Handle) return Status_Code is begin FS.Root_Entry.L_Name := -As; Handle := FS.Root_Entry'Unchecked_Access; return OK; end Root_Node; ---------- -- Open -- ---------- overriding function Open (FS : in out FAT_Filesystem; Path : String; Handle : out Any_Directory_Handle) return Status_Code is begin return FAT_Open (FS, Path, FAT_Directory_Handle_Access (Handle)); end Open; -------------- -- FAT_Open -- -------------- function FAT_Open (FS : in out FAT_Filesystem; Path : String; Handle : out FAT_Directory_Handle_Access) return Status_Code is E : aliased FAT_Node; Full : constant String := Normalize (Path); Status : Status_Code; begin if not Is_Root (Full) then Status := Directories.Find (FS, Full, E); if Status /= OK then return Status; end if; else E := FS.Root_Entry; end if; Status := OK; return E.FAT_Open (Handle); end FAT_Open; ---------- -- Open -- ---------- function FAT_Open (D_Entry : FAT_Node; Handle : out FAT_Directory_Handle_Access) return Status_Code is begin Handle := null; if not Is_Subdirectory (D_Entry) then return No_Such_File; end if; Handle := Find_Free_Dir_Handle; if Handle = null then return Too_Many_Open_Files; end if; Handle.FS := D_Entry.FS; Handle.Current_Index := 0; if D_Entry.Is_Root then if D_Entry.FS.Version = FAT16 then Handle.Start_Cluster := 0; Handle.Current_Block := D_Entry.FS.Root_Dir_Area; else Handle.Start_Cluster := D_Entry.FS.Root_Dir_Cluster; Handle.Current_Block := D_Entry.FS.Cluster_To_Block (D_Entry.FS.Root_Dir_Cluster); end if; else Handle.Start_Cluster := D_Entry.Start_Cluster; Handle.Current_Block := D_Entry.FS.Cluster_To_Block (D_Entry.Start_Cluster); end if; Handle.Current_Cluster := Handle.Start_Cluster; return OK; end FAT_Open; ----------- -- Reset -- ----------- overriding procedure Reset (Dir : in out FAT_Directory_Handle) is begin Dir.Current_Block := Cluster_To_Block (Dir.FS.all, Dir.Start_Cluster); Dir.Current_Cluster := Dir.Start_Cluster; Dir.Current_Index := 0; end Reset; ---------- -- Read -- ---------- overriding function Read (Dir : in out FAT_Directory_Handle; Handle : out Any_Node_Handle) return Status_Code is Node : FAT_Node; Status : Status_Code; begin Status := Directories.Read (Dir, Node); Dir.Current_Node := Node; Handle := Dir.Current_Node'Unchecked_Access; return Status; end Read; ----------- -- Close -- ----------- overriding procedure Close (Dir : in out FAT_Directory_Handle) is begin Dir.FS := null; Dir.Current_Index := 0; Dir.Start_Cluster := 0; Dir.Current_Cluster := 0; Dir.Current_Block := 0; Dir.Is_Free := True; end Close; ----------------- -- Create_File -- ----------------- overriding function Create_File (This : in out FAT_Filesystem; Path : String) return Status_Code is Parent_E : FAT_Node; Node : FAT_Node; Ret : Status_Code; begin if Directories.Find (This, Parent (Path), Parent_E) /= OK then return No_Such_File; end if; Ret := Directories.Create_File_Node (Parent_E, -Basename (Path), Node); return Ret; end Create_File; ------------ -- Unlink -- ------------ overriding function Unlink (This : in out FAT_Filesystem; Path : String) return Status_Code is Parent_E : FAT_Node; Node : FAT_Node; begin if Is_Root (Path) then return No_Such_File; end if; if Directories.Find (This, Parent (Path), Parent_E) /= OK then return No_Such_File; end if; if Directories.Find (Parent_E, -Basename (Path), Node) /= OK then return No_Such_File; end if; return Directories.Delete_Entry (Dir => Parent_E, Ent => Node); end Unlink; ---------------------- -- Remove_Directory -- ---------------------- overriding function Remove_Directory (This : in out FAT_Filesystem; Path : String) return Status_Code is E : aliased FAT_Node; Full : constant String := Normalize (Path); Status : Status_Code; begin if not Is_Root (Full) then Status := Directories.Find (This, Full, E); if Status /= OK then return Status; end if; else return Invalid_Parameter; end if; return Directories.Delete_Subdir (E, False); end Remove_Directory; ---------- -- Open -- ---------- overriding function Open (FS : in out FAT_Filesystem; Path : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code is Parent_E : FAT_Node; begin Handle := null; if Is_Root (Path) then return No_Such_File; end if; if Directories.Find (FS, Parent (Path), Parent_E) /= OK then return No_Such_File; end if; return Open (Parent => Parent_E, Name => Basename (Path), Mode => Mode, Handle => Handle); end Open; ---------- -- Open -- ---------- overriding function Open (Parent : FAT_Node; Name : String; Mode : File_Mode; Handle : out Any_File_Handle) return Status_Code is FAT_Handle : FAT_File_Handle_Access; Ret : Status_Code; begin FAT_Handle := Find_Free_File_Handle; if FAT_Handle = null then return Too_Many_Open_Files; end if; Ret := Files.Open (Parent, -Name, Mode, FAT_Handle); Handle := Any_File_Handle (FAT_Handle); return Ret; end Open; ---------- -- Size -- ---------- overriding function Size (File : FAT_File_Handle) return File_Size is begin return File_Size (File.D_Entry.Size); end Size; ---------- -- Mode -- ---------- overriding function Mode (File : FAT_File_Handle) return File_Mode is begin return File.Mode; end Mode; ---------- -- Read -- ---------- overriding function Read (File : in out FAT_File_Handle; Addr : System.Address; Length : in out File_Size) return Status_Code is L : FAT_File_Size := FAT_File_Size (Length); Ret : Status_Code; begin Ret := Files.Read (File, Addr, L); Length := File_Size (L); return Ret; end Read; -- ---------- -- -- Read -- -- ---------- -- -- procedure Generic_Read -- (Handle : File_Handle; -- Value : out T) -- is -- Ret : File_Size with Unreferenced; -- begin -- Ret := Files.Read (Handle, Value'Address, T'Size / 8); -- end Generic_Read; ------------ -- Offset -- ------------ overriding function Offset (File : FAT_File_Handle) return File_Size is (File_Size (File.File_Index)); ---------------- -- File_Write -- ---------------- overriding function Write (File : in out FAT_File_Handle; Addr : System.Address; Length : File_Size) return Status_Code is begin return Files.Write (File, Addr, FAT_File_Size (Length)); end Write; ---------------- -- File_Flush -- ---------------- overriding function Flush (File : in out FAT_File_Handle) return Status_Code is begin return Files.Flush (File); end Flush; --------------- -- File_Seek -- --------------- overriding function Seek (File : in out FAT_File_Handle; Origin : Seek_Mode; Amount : in out File_Size) return Status_Code is Num : FAT_File_Size := FAT_File_Size (Amount); Ret : Status_Code; begin Ret := Files.Seek (File, Num, Origin); Amount := File_Size (Num); return Ret; end Seek; ---------------- -- File_Close -- ---------------- overriding procedure Close (File : in out FAT_File_Handle) is begin Files.Close (File); File.Is_Free := True; end Close; ------------- -- Get_FAT -- ------------- function Get_FAT (FS : in out FAT_Filesystem; Cluster : Cluster_Type) return Cluster_Type is Idx : Natural; Block_Num : Block_Offset; subtype B4 is Block (1 .. 4); subtype B2 is Block (1 .. 2); function To_Cluster is new Ada.Unchecked_Conversion (B4, Cluster_Type); function To_U16 is new Ada.Unchecked_Conversion (B2, Unsigned_16); begin if Cluster < 2 or else Cluster > FS.Num_Clusters + 2 then return 1; end if; if FS.Version = FAT32 then Block_Num := FS.FAT_Addr + Block_Offset (Cluster) * 4 / Block_Offset (FS.Block_Size); else Block_Num := FS.FAT_Addr + Block_Offset (Cluster) * 2 / Block_Offset (FS.Block_Size); end if; if Block_Num /= FS.FAT_Block then FS.FAT_Block := Block_Num; if not FS.Controller.Read (FS.LBA + FS.FAT_Block, FS.FAT_Window) then FS.FAT_Block := 16#FFFF_FFFF#; return INVALID_CLUSTER; end if; end if; if FS.Version = FAT32 then Idx := Natural (FAT_File_Size ((Cluster) * 4) mod FS.Block_Size); return To_Cluster (FS.FAT_Window (Idx .. Idx + 3)) and 16#0FFF_FFFF#; else Idx := Natural (FAT_File_Size ((Cluster) * 2) mod FS.Block_Size); return Cluster_Type (To_U16 (FS.FAT_Window (Idx .. Idx + 1))); end if; end Get_FAT; ------------- -- Set_FAT -- ------------- function Set_FAT (FS : in out FAT_Filesystem; Cluster : Cluster_Type; Value : Cluster_Type) return Status_Code is Idx : Natural; Block_Num : Block_Offset; Dead : Boolean with Unreferenced; subtype B4 is Block (1 .. 4); function From_Cluster is new Ada.Unchecked_Conversion (Cluster_Type, B4); begin if Cluster < Valid_Cluster'First or else Cluster > FS.Num_Clusters then return Internal_Error; end if; Block_Num := FS.FAT_Addr + Block_Offset (Cluster) * 4 / Block_Offset (FS.Block_Size); if Block_Num /= FS.FAT_Block then FS.FAT_Block := Block_Num; if not FS.Controller.Read (FS.LBA + FS.FAT_Block, FS.FAT_Window) then FS.FAT_Block := 16#FFFF_FFFF#; return Disk_Error; end if; end if; Idx := Natural (FAT_File_Size (Cluster * 4) mod FS.Block_Size); FS.FAT_Window (Idx .. Idx + 3) := From_Cluster (Value); if not FS.Controller.Write (FS.LBA + FS.FAT_Block, FS.FAT_Window) then return Disk_Error; end if; return OK; end Set_FAT; ------------------ -- Write_FSInfo -- ------------------ procedure Write_FSInfo (FS : in out FAT_Filesystem) is subtype FSInfo_Block is Block (0 .. 11); function From_FSInfo is new Ada.Unchecked_Conversion (FAT_FS_Info, FSInfo_Block); Status : Status_Code; FAT_Begin_LBA : constant Block_Offset := Block_Offset (FS.FSInfo_Block_Number); Ret : Status_Code with Unreferenced; begin Status := FS.Ensure_Block (FAT_Begin_LBA); if Status /= OK then return; end if; -- again, check the generic FAT block signature if FS.Window (510 .. 511) /= (16#55#, 16#AA#) then return; end if; -- good. now we got the entire FSinfo in our window. -- modify that part of the window and writeback. FS.Window (16#1E4# .. 16#1EF#) := From_FSInfo (FS.FSInfo); Ret := FS.Write_Window; end Write_FSInfo; ---------------------- -- Get_Free_Cluster -- ---------------------- function Get_Free_Cluster (FS : in out FAT_Filesystem; Previous : Cluster_Type := INVALID_CLUSTER) return Cluster_Type is Candidate : Cluster_Type := Previous; begin -- First check for a cluster that is just after the previous one -- allocated for the entry if Candidate in Valid_Cluster'Range and then Candidate < FS.Num_Clusters then Candidate := Candidate + 1; if FS.Is_Free_Cluster (FS.Get_FAT (Candidate)) then return Candidate; end if; end if; -- Next check the most recently allocated cluster Candidate := FS.Most_Recently_Allocated_Cluster + 1; if Candidate not in Valid_Cluster'Range then Candidate := Valid_Cluster'First; end if; while Candidate in Valid_Cluster'Range and then Candidate < FS.Num_Clusters loop if FS.Is_Free_Cluster (FS.Get_FAT (Candidate)) then return Candidate; end if; Candidate := Candidate + 1; end loop; Candidate := Valid_Cluster'First; while Candidate <= FS.Most_Recently_Allocated_Cluster loop if FS.Is_Free_Cluster (FS.Get_FAT (Candidate)) then return Candidate; end if; Candidate := Candidate + 1; end loop; return INVALID_CLUSTER; end Get_Free_Cluster; ----------------- -- New_Cluster -- ----------------- function New_Cluster (FS : in out FAT_Filesystem) return Cluster_Type is begin return FS.New_Cluster (INVALID_CLUSTER); end New_Cluster; ----------------- -- New_Cluster -- ----------------- function New_Cluster (FS : in out FAT_Filesystem; Previous : Cluster_Type) return Cluster_Type is Ret : Cluster_Type; begin pragma Assert (FS.Version = FAT32, "FS write only supported on FAT32 for now"); Ret := FS.Get_Free_Cluster (Previous); if Ret = INVALID_CLUSTER then return Ret; end if; if Previous /= INVALID_CLUSTER then if FS.Set_FAT (Previous, Ret) /= OK then return INVALID_CLUSTER; end if; end if; if FS.Set_FAT (Ret, LAST_CLUSTER_VALUE) /= OK then return INVALID_CLUSTER; end if; FS.FSInfo.Free_Clusters := FS.FSInfo.Free_Clusters - 1; FS.FSInfo.Last_Allocated_Cluster := Ret; FS.FSInfo_Changed := True; return Ret; end New_Cluster; ------------------ -- Write_Window -- ------------------ function Write_Window (FS : in out FAT_Filesystem) return Status_Code is begin if FS.Controller.Write (FS.LBA + FS.Window_Block, FS.Window) then return OK; else return Disk_Error; end if; end Write_Window; ----------- -- Close -- ----------- overriding procedure Close (E : in out FAT_Node) is begin null; end Close; ---------- -- Size -- ---------- overriding function Size (E : FAT_Node) return File_Size is (File_Size (E.Size)); end Filesystem.FAT;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure puissance_mieux is x, res : Float; n, p : Integer; begin -- Ask number who we will calculate it power with a exponent power. Put ("Enter your x : "); Get (x); res := Float(1); -- Ask the exponent of the number. Put ("Enter your exponent : "); Get (n); -- Display the power. for i in 1..abs(n) loop if n mod 2 = 0 then p := n / 2; if n >= 0 then -- If the exponent is greater than 0. res := (x ** 2) ** p ; else res := res * (Float(1) / (x ** 2) ** p); end if; else p := n / 2; if n >= 0 then -- If the exponent is greater than 0. res := ((x ** 2) ** p) * x; else res := (res / (((x ** 2) ** p) * x)); end if; end if; end loop; Put_Line (Float'Image(res)); end puissance_mieux;
with UxAS.Comms.Transport.ZeroMQ_Fabric; use UxAS.Comms.Transport; with String_Utils; use String_Utils; package body UxAS.Comms.Transport.Receiver.ZeroMQ is ---------------- -- Initialize -- ---------------- procedure Initialize (This : in out ZeroMq_Receiver_Base; Entity_Id : UInt32; Service_Id : UInt32; Socket_Configuration : ZeroMq_Socket_Configuration) is begin -- m_entityId = entityId; This.Entity_Id := Entity_Id; -- m_serviceId = serviceId; This.Service_Id := Service_Id; -- m_entityIdString = std::to_string(entityId); Copy (To_String (Entity_Id), To => This.Entity_Id_String); -- m_serviceIdString = std::to_string(serviceId); Copy (To_String (Service_Id), To => This.Service_Id_String); -- m_zeroMqSocketConfiguration = static_cast<ZeroMqSocketConfiguration&> (zeroMqSocketConfiguration); This.Socket_Configuration := Initialize.Socket_Configuration; -- m_zmqSocket = ZeroMqFabric::getInstance().createSocket(m_zeroMqSocketConfiguration); ZeroMQ_Fabric.Create_Socket (ZeroMQ_Fabric.Instance, Config => This.Socket_Configuration, Result => This.Zmq_Socket); end Initialize; ---------------------------------------- -- Add_Subscription_Address_To_Socket -- ---------------------------------------- overriding procedure Add_Subscription_Address_To_Socket (This : in out ZeroMq_Receiver_Base; Address : String; Result : out Boolean) is begin -- bool isAdded(false); -- if (m_zeroMqSocketConfiguration.m_zmqSocketType == ZMQ_SUB) -- { -- m_zmqSocket->setsockopt(ZMQ_SUBSCRIBE, address.c_str(), address.size()); -- isAdded = true; -- } -- return (isAdded); if This.Socket_Configuration.Zmq_Socket_Type = ZMQ.Sockets.SUB then This.Zmq_Socket.Establish_Message_Filter (Value => Address); Result := True; else Result := False; end if; end Add_Subscription_Address_To_Socket; --------------------------------------------- -- Remove_Subscription_Address_From_Socket -- --------------------------------------------- overriding procedure Remove_Subscription_Address_From_Socket (This : in out ZeroMq_Receiver_Base; Address : String; Result : out Boolean) is begin -- bool isRemoved(false); -- if (m_zeroMqSocketConfiguration.m_zmqSocketType == ZMQ_SUB) -- { -- m_zmqSocket->setsockopt(ZMQ_UNSUBSCRIBE, address.c_str(), address.size()); -- isRemoved = true; -- } -- return (isRemoved); if This.Socket_Configuration.Zmq_Socket_Type = ZMQ.Sockets.SUB then This.Zmq_Socket.Remove_Message_Filter (Value => Address); Result := True; else Result := False; end if; end Remove_Subscription_Address_From_Socket; end UxAS.Comms.Transport.Receiver.ZeroMQ;
package body Kafka.Consumer is procedure Poll_Set_Consumer(Handle : Handle_Type) is Response : Kafka_Response_Error_Type; begin Response := rd_kafka_poll_set_consumer(Handle); if Response /= RD_KAFKA_RESP_ERR_NO_ERROR then raise Kafka_Error with "Error returned by rd_kafka_poll_set_consumer: " & Kafka.Get_Error_Name(Response); end if; end Poll_Set_Consumer; function Poll(Handle : Handle_Type; Timeout : Duration) return access Message_Type is begin return rd_kafka_consumer_poll(Handle, int(Timeout * 1000)); end Poll; procedure Close(Handle : Handle_Type) is Response : Kafka_Response_Error_Type; begin Response := rd_kafka_consumer_close(Handle); if Response /= RD_KAFKA_RESP_ERR_NO_ERROR then raise Kafka_Error with "Error returned by rd_kafka_consumer_close: " & Kafka.Get_Error_Name(Response); end if; end Close; end Kafka.Consumer;
-- PQ (10/12) ; PM (10/14) with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; -- Version radicale : exclusion mutuelle de tous -- fournit une ossature pour l'approche "automate" -- fournit un exemple de tâche proposant des entrées différentes de Demander_Lecture, ... package body LR.Synchro.Exclusion2 is function Nom_Strategie return String is begin return "Simple et Stupide, par exclusion mutuelle"; end Nom_Strategie; task LectRedTask is entry Demander; entry Terminer; end LectRedTask; task body LectRedTask is begin loop accept Demander; accept Terminer; -- Comme promis : simple et stupide end loop; exception when Error: others => Put_Line("**** LectRedTask: exception: " & Ada.Exceptions.Exception_Information(Error)); end LectRedTask; procedure Demander_Lecture is begin LectRedTask.Demander; end Demander_Lecture; procedure Demander_Ecriture is begin LectRedTask.Demander; end Demander_Ecriture; procedure Terminer_Lecture is begin LectRedTask.Terminer; end Terminer_Lecture; procedure Terminer_Ecriture is begin LectRedTask.Terminer; end Terminer_Ecriture; end LR.Synchro.Exclusion2;
----------------------------------------------------------------------- -- Util.Concurrent -- Concurrent Counters -- Copyright (C) 2009, 2010, 2015 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. ----------------------------------------------------------------------- -- The <b>Counters</b> package defines the <b>Counter</b> type which provides -- atomic increment and decrement operations. It is intended to be used to -- implement reference counting in a multi-threaded environment. -- -- type Ref is record -- Cnt : Counter; -- Data : ...; -- end record; -- -- Object : access Ref; -- Is_Last : Boolean; -- begin -- Decrement (Object.Cnt, Is_Last); -- Multi-task safe operation -- if Is_Last then -- Free (Object); -- end if; -- -- Unlike the Ada portable implementation based on protected type, this implementation -- does not require that <b>Counter</b> be a limited type. private with Interfaces; package Util.Concurrent.Counters is pragma Preelaborate; -- ------------------------------ -- Atomic Counter -- ------------------------------ -- The atomic <b>Counter</b> implements a simple counter that can be -- incremented or decremented atomically. type Counter is private; type Counter_Access is access all Counter; -- Increment the counter atomically. procedure Increment (C : in out Counter); pragma Inline_Always (Increment); -- Increment the counter atomically and return the value before increment. procedure Increment (C : in out Counter; Value : out Integer); pragma Inline_Always (Increment); -- Decrement the counter atomically. procedure Decrement (C : in out Counter); pragma Inline_Always (Decrement); -- Decrement the counter atomically and return a status. procedure Decrement (C : in out Counter; Is_Zero : out Boolean); pragma Inline_Always (Decrement); -- Get the counter value function Value (C : in Counter) return Integer; pragma Inline_Always (Value); ONE : constant Counter; private -- This implementation works without an Ada protected type: -- o The size of the target object is 10 times smaller. -- o Increment and Decrement operations are 5 times faster. -- o It works by using special instructions -- o The counter is Atomic to make sure the compiler will use atomic read/write instructions -- and it prevents optimization (Atomic implies Volatile). The Atomic does not mean -- that atomic instructions are used. type Counter is record Value : Interfaces.Unsigned_32 := 0; pragma Atomic (Value); end record; ONE : constant Counter := Counter '(Value => 1); end Util.Concurrent.Counters;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package Latex_Writer is type Style_Spec (<>) is private; type Table_Handler (<>) is tagged private; type Length_Unit is (Pt, Cm, Mm, Inch); type Latex_Length is private; subtype Em_Length is Float; Zero : constant Latex_Length; function "+" (X, Y : Latex_Length) return Latex_Length; function "-" (X, Y : Latex_Length) return Latex_Length; function "*" (X : Float; Y : Latex_Length) return Latex_Length; -- function "*" (X : Em_Length; Y : Latex_Length) return Latex_Length; function Value (X : Latex_Length; Unit : Length_Unit) return Float; function Image (X : Latex_Length; Unit : Length_Unit := Pt; Full : Boolean := True) return String; function "/" (X : Latex_Length; Y : Latex_Length) return Float; function Inch return Latex_Length; function Pt return Latex_Length; function Cm return Latex_Length; function Mm return Latex_Length; type Parameter_List (<>) is private; function "and" (X, Y : String) return Parameter_List; function "and" (X : Parameter_List; Y : String) return Parameter_List; procedure Within (Output : File_Access; Env_Name : String; Callback : access procedure (Output : File_Access); Parameter : String := ""); procedure Within_Table_Like (Output : File_Access; Env_Name : String; Callback : access procedure (Output : File_Access; Table : in out Table_Handler)); procedure Within_Table_Like (Output : File_Access; Env_Name : String; Callback : access procedure (Output : File_Access; Table : in out Table_Handler); Parameter : String); procedure Within_Table_Like (Output : File_Access; Env_Name : String; Callback : access procedure (Output : File_Access; Table : in out Table_Handler); Parameters : Parameter_List); procedure Within_Table (Output : File_Access; Table_Spec : String; Callback : access procedure (Output : File_Access; Table : in out Table_Handler); Default_Style : String := ""; Default_Head : String := ""; Caption : String := ""; Width : String := "\textwidth"); procedure Put (Table : in out Table_Handler; Content : String; Style : String := ""); type Bar_Position is (Default, Left, Right, Both, None); procedure Head (Table : in out Table_Handler; Content : String; Bar : Bar_Position := Default; Style : String := ""); procedure New_Row (Table : in out Table_Handler); procedure Hline (Table : in out Table_Handler; Full : Boolean := True); procedure Cline (Table : in out Table_Handler; From, To : Positive); procedure Multicolumn (Table : in out Table_Handler; Span : Positive; Spec : String; Content : String); procedure Print_Default_Macro (Output : File_Access; Command_Name : String; Definition : String; N_Parameters : Natural); type Align_Type is (Center, Left, Right); function Hbox (Content : String; Size : Latex_Length := Zero; Align : Align_Type := Center) return String; private -- 1 Cm ~ 30 Pt, 10_000 Pt ~ 3m type Basic_Latex_Length_Pt is delta 2.0 ** (-16) range -10_000.0 .. 10_000.0; type Latex_Length is new Basic_Latex_Length_Pt; Zero : constant Latex_Length := 0.0; pragma Warnings (Off, "static fixed-point value is not a multiple of Small"); Point_Per_Unit : constant array (Length_Unit) of Basic_Latex_Length_Pt := (Pt => 1.0, Mm => 2.84, Cm => 28.4, Inch => 72.27); subtype Unit_Name is String (1 .. 2); Unit_Image : constant array (Length_Unit) of Unit_Name := (Pt => "pt", Mm => "mm", Cm => "cm", Inch => "in"); function "+" (X, Y : Latex_Length) return Latex_Length is (Latex_Length (Basic_Latex_Length_Pt (X)+Basic_Latex_Length_Pt (Y))); function "-" (X, Y : Latex_Length) return Latex_Length is (Latex_Length (Basic_Latex_Length_Pt (X)-Basic_Latex_Length_Pt (Y))); function "*" (X : Float; Y : Latex_Length) return Latex_Length is (Latex_Length (X * Float (Y))); -- function "*" (X : Em_Length; Y : Latex_Length) return Latex_Length -- is (Float (X) * Y); function "/" (X : Latex_Length; Y : Latex_Length) return Float is (Float (X) / Float (Y)); function Value (X : Latex_Length; Unit : Length_Unit) return Float is (Float (X) / Float (Point_Per_Unit (Unit))); function Image (X : Latex_Length; Unit : Length_Unit := Pt; Full : Boolean := True) return String is (Basic_Latex_Length_Pt'Image (Basic_Latex_Length_Pt (X) / Point_Per_Unit (Unit)) & (if Full then Unit_Image (Unit) else "")); function Inch return Latex_Length is (Latex_Length (Point_Per_Unit (Inch))); function Pt return Latex_Length is (Latex_Length (Point_Per_Unit (Pt))); function Cm return Latex_Length is (Latex_Length (Point_Per_Unit (Cm))); function Mm return Latex_Length is (Latex_Length (Point_Per_Unit (Mm))); type Style_Spec is new String; type Table_State is (Begin_Row, Middle_Row); type Table_Handler is tagged record State : Table_State; Output : File_Access; Default_Style : Unbounded_String; Default_Head : Unbounded_String; end record; type Parameter_List is array (Positive range <>) of Unbounded_String; function "and" (X, Y : String) return Parameter_List is (Parameter_List'(1 => To_Unbounded_String (X), 2 => To_Unbounded_String (Y))); function "and" (X : Parameter_List; Y : String) return Parameter_List is (X & Parameter_List'(1 => To_Unbounded_String (Y))); end Latex_Writer;
with Ada.Strings.Unbounded; with Ada.Text_IO; with TOML; procedure Main is package TIO renames Ada.Text_IO; Value : constant TOML.TOML_Value := TOML.Load_File ("example.toml").Value; begin for E of Value.Iterate_On_Table loop TIO.Put_Line (Ada.Strings.Unbounded.To_String (E.Key) & " is a " & E.Value.Kind'Image); end loop; end Main;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2014, 2017 - 2019 All Rights Reserved. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with Ada.Command_Line; with Ada.Directories; with Emacs_Wisi_Common_Parse; use Emacs_Wisi_Common_Parse; with WisiToken.Text_IO_Trace; procedure Gen_Emacs_Wisi_LR_Text_Rep_Parse is use WisiToken; -- "+", "-" Unbounded_string Trace : aliased WisiToken.Text_IO_Trace.Trace (Descriptor'Unrestricted_Access); Parser : WisiToken.Parse.LR.Parser.Parser; Parse_Data : aliased Parse_Data_Type (Parser.Line_Begin_Token'Access); Params : constant Process_Start_Params := Get_Process_Start_Params; begin Create_Parser (Parser, Language_Fixes, Language_Matching_Begin_Tokens, Language_String_ID_Set, Trace'Unrestricted_Access, Parse_Data'Unchecked_Access, Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name) & "/" & Text_Rep_File_Name); Process_Stream (Name, Language_Protocol_Version, Partial_Parse_Active, Params, Parser, Parse_Data, Descriptor); end Gen_Emacs_Wisi_LR_Text_Rep_Parse;
pragma License (Unrestricted); with Ada.Numerics.Generic_Complex_Types; package Ada.Numerics.Long_Long_Complex_Types is new Generic_Complex_Types (Long_Long_Float); pragma Pure (Ada.Numerics.Long_Long_Complex_Types);
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with system.machine_code; with ewok.tasks; use ewok.tasks; with ewok.devices_shared; use ewok.devices_shared; with ewok.sleep; with ewok.alarm; with ewok.syscalls.handler; with ewok.memory; with ewok.interrupts; with soc.interrupts; with soc.dwt; with m4.scb; with m4.systick; package body ewok.sched with spark_mode => off is package TSK renames ewok.tasks; ----------------------------------------------- -- SPARK/ghost specific functions & procedures ----------------------------------------------- function current_task_is_valid return boolean is begin return (current_task_id /= ID_UNUSED); end current_task_is_valid; ---------------------------------------------- -- sched functions ---------------------------------------------- procedure request_schedule is begin m4.scb.SCB.ICSR.PENDSVSET := 1; end request_schedule; function task_elect return t_task_id is elected : t_task_id; begin -- -- Execute pending user ISRs first -- for id in config.applications.list'range loop if TSK.tasks_list(id).mode = TASK_MODE_ISRTHREAD and then ewok.tasks.get_state (id, TASK_MODE_ISRTHREAD) = TASK_STATE_RUNNABLE and then ewok.tasks.get_state (id, TASK_MODE_MAINTHREAD) /= TASK_STATE_LOCKED then elected := id; goto ok_return; end if; end loop; -- -- Execute tasks in critical sections -- for id in config.applications.list'range loop if TSK.tasks_list(id).state = TASK_STATE_LOCKED then elected := id; if TSK.tasks_list(id).mode = TASK_MODE_MAINTHREAD then last_main_user_task_id := elected; end if; goto ok_return; end if; end loop; -- -- Updating finished ISRs state -- for id in config.applications.list'range loop if TSK.tasks_list(id).mode = TASK_MODE_ISRTHREAD and then ewok.tasks.get_state (id, TASK_MODE_ISRTHREAD) = TASK_STATE_ISR_DONE then ewok.tasks.set_state (id, TASK_MODE_ISRTHREAD, TASK_STATE_IDLE); TSK.tasks_list(id).isr_ctx.frame_a := NULL; TSK.tasks_list(id).isr_ctx.device_id := ID_DEV_UNUSED; TSK.tasks_list(id).isr_ctx.sched_policy := ISR_STANDARD; ewok.tasks.set_mode (id, TASK_MODE_MAINTHREAD); -- When a task has just finished its ISR, its main thread might -- become runnable if ewok.sleep.is_sleeping (id) then ewok.sleep.try_waking_up (id); elsif TSK.tasks_list(id).state = TASK_STATE_IDLE then ewok.tasks.set_state (id, TASK_MODE_MAINTHREAD, TASK_STATE_RUNNABLE); end if; end if; end loop; -- -- Execute SOFTIRQ if there are some pending ISRs and/or syscalls -- if ewok.tasks.get_state (ID_SOFTIRQ, TASK_MODE_MAINTHREAD) = TASK_STATE_RUNNABLE then elected := ID_SOFTIRQ; goto ok_return; end if; -- -- IPC can force task election to reduce IPC overhead -- for id in config.applications.list'range loop if TSK.tasks_list(id).state = TASK_STATE_FORCED then ewok.tasks.set_state (id, TASK_MODE_MAINTHREAD, TASK_STATE_RUNNABLE); elected := id; goto ok_return; end if; end loop; #if CONFIG_SCHED_RAND declare random : aliased unsigned_32; id : t_task_id; ok : boolean; pragma unreferenced (ok); begin ewok.rng.random (random'access, ok); id := t_task_id'val ((config.applications.list'first)'pos + (random mod config.applications.list'length)); for i in 1 .. config.applications.list'length loop if ewok.tasks.get_state (id, TASK_MODE_MAINTHREAD) = TASK_STATE_RUNNABLE then elected := id; goto ok_return; end if; if id /= config.applications.list'last then id := t_task_id'succ (id); else id := config.applications.list'first; end if; end loop; end; #end if; #if CONFIG_SCHED_RR declare id : t_task_id; begin id := last_main_user_task_id; for i in 1 .. config.applications.list'length loop if id < config.applications.list'last then id := t_task_id'succ (id); else id := config.applications.list'first; end if; if ewok.tasks.get_state (id, TASK_MODE_MAINTHREAD) = TASK_STATE_RUNNABLE then elected := id; last_main_user_task_id := elected; goto ok_return; end if; end loop; end; #end if; #if CONFIG_SCHED_MLQ_RR declare max_prio : unsigned_8 := 0; id : t_task_id; begin -- Max priority for id in config.applications.list'range loop if TSK.tasks_list(id).prio > max_prio and ewok.tasks.get_state (id, TASK_MODE_MAINTHREAD) = TASK_STATE_RUNNABLE then max_prio := TSK.tasks_list(id).prio; end if; end loop; -- Round Robin election on tasks with the max priority id := last_main_user_task_id; for i in 1 .. config.applications.list'length loop if id < config.applications.list'last then id := t_task_id'succ (id); else id := config.applications.list'first; end if; if TSK.tasks_list(id).prio = max_prio and ewok.tasks.get_state (id, TASK_MODE_MAINTHREAD) = TASK_STATE_RUNNABLE then elected := id; last_main_user_task_id := elected; goto ok_return; end if; end loop; end; #end if; -- Default elected := ID_KERNEL; <<ok_return>> --pragma DEBUG (debug.log (debug.DEBUG, "task " & t_task_id'image (elected) & " elected")); return elected; end task_elect; function pendsv_handler (frame_a : ewok.t_stack_frame_access) return ewok.t_stack_frame_access is old_task_id : constant t_task_id := current_task_id; old_task_mode : constant t_task_mode := current_task_mode; begin -- Keep ISR threads running until they finish if current_task_mode = TASK_MODE_ISRTHREAD and then ewok.tasks.get_state (current_task_id, TASK_MODE_ISRTHREAD) = TASK_STATE_RUNNABLE then return frame_a; end if; #if CONFIG_KERNEL_EXP_REENTRANCY -- This global variable write access is not reentrant, but, by -- construction can't be accedded concurently in a monoprocessor -- system due to processor's IRQ priority. -- Although, we make IRQ locked here for future compatibility -- -- TODO: define a clear denomination for locking/unlocking critical -- sections in kernel instead of directly calling HW primitives m4.cpu.disable_irq; #end if; -- Save current context if current_task_mode = TASK_MODE_ISRTHREAD then TSK.tasks_list(current_task_id).isr_ctx.frame_a := frame_a; else TSK.tasks_list(current_task_id).ctx.frame_a := frame_a; end if; -- Elect a new task and change current_task_id current_task_id := task_elect; current_task_mode := TSK.tasks_list(current_task_id).mode; #if CONFIG_KERNEL_EXP_REENTRANCY -- End of global variables WR access m4.cpu.enable_irq; #end if; -- Apply MPU specific configuration if not (current_task_id = old_task_id and current_task_mode = old_task_mode) then ewok.memory.map_task (current_task_id); end if; -- Return the new context if current_task_mode = TASK_MODE_ISRTHREAD then return TSK.tasks_list(current_task_id).isr_ctx.frame_a; else return TSK.tasks_list(current_task_id).ctx.frame_a; end if; end pendsv_handler; function systick_handler (frame_a : ewok.t_stack_frame_access) return ewok.t_stack_frame_access is old_task_id : constant t_task_id := current_task_id; old_task_mode : constant t_task_mode := current_task_mode; begin m4.systick.increment; sched_period := sched_period + 1; -- Managing DWT cycle count overflow soc.dwt.ovf_manage; -- FIXME - CONFIG_SCHED_PERIOD must be in milliseconds, -- not in ticks if sched_period /= $CONFIG_SCHED_PERIOD then return frame_a; else sched_period := 0; end if; #if CONFIG_KERNEL_EXP_REENTRANCY -- This global variable write access is not reentrant, but, by -- construction can't be accedded concurently in a monoprocessor -- system due to processor's IRQ priority. -- Although, we make IRQ locked here for future compatibility -- Here we lock down to the end of globals usage to avoid to -- many successive disable/enable of IRQs m4.cpu.disable_irq; #end if; -- Waking-up sleeping tasks ewok.sleep.check_is_awoke; -- Trigger alarms ewok.alarm.check_alarms; -- Keep ISR threads running until they finish if current_task_mode = TASK_MODE_ISRTHREAD and then ewok.tasks.get_state (current_task_id, TASK_MODE_ISRTHREAD) = TASK_STATE_RUNNABLE then #if CONFIG_KERNEL_EXP_REENTRANCY m4.cpu.enable_irq; #end if; return frame_a; end if; -- Save current context if current_task_mode = TASK_MODE_ISRTHREAD then TSK.tasks_list(current_task_id).isr_ctx.frame_a := frame_a; else TSK.tasks_list(current_task_id).ctx.frame_a := frame_a; end if; -- Elect a new task current_task_id := task_elect; current_task_mode := TSK.tasks_list(current_task_id).mode; #if CONFIG_KERNEL_EXP_REENTRANCY -- End of global variable access m4.cpu.enable_irq; #end if; -- Apply MPU specific configuration if not (current_task_id = old_task_id and current_task_mode = old_task_mode) then ewok.memory.map_task (current_task_id); end if; -- Return the new context if current_task_mode = TASK_MODE_ISRTHREAD then return TSK.tasks_list(current_task_id).isr_ctx.frame_a; else return TSK.tasks_list(current_task_id).ctx.frame_a; end if; end systick_handler; procedure init is idle_task : t_task renames ewok.tasks.tasks_list(ID_KERNEL); ok : boolean; begin current_task_id := ID_KERNEL; ewok.interrupts.set_task_switching_handler (soc.interrupts.INT_SYSTICK, systick_handler'access, ID_KERNEL, ID_DEV_UNUSED, ok); if not ok then raise program_error; end if; ewok.interrupts.set_task_switching_handler (soc.interrupts.INT_PENDSV, pendsv_handler'access, ID_KERNEL, ID_DEV_UNUSED, ok); if not ok then raise program_error; end if; ewok.interrupts.set_task_switching_handler (soc.interrupts.INT_SVC, ewok.syscalls.handler.svc_handler'access, ID_KERNEL, ID_DEV_UNUSED, ok); if not ok then raise program_error; end if; -- -- Jump to the kernel task -- system.machine_code.asm ("mov r0, %0" & ascii.lf & "msr psp, r0" & ascii.lf & "mov r0, 2" & ascii.lf & "msr control, r0" & ascii.lf & "mov r1, %1" & ascii.lf & "bx r1", inputs => (system_address'asm_input ("r", to_system_address (idle_task.ctx.frame_a)), system_address'asm_input ("r", idle_task.entry_point)), clobber => "r0, r1", volatile => true); end init; end ewok.sched;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E R R O U T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines to output error messages. They are -- basically system independent, however in some environments, e.g. when the -- parser is embedded into an editor, it may be appropriate to replace the -- implementation of this package. with Err_Vars; with Erroutc; with Namet; use Namet; with Table; with Types; use Types; with Uintp; use Uintp; with System; package Errout is Current_Error_Source_File : Source_File_Index renames Err_Vars.Current_Error_Source_File; -- Id of current messages. Used to post file name when unit changes. This -- is initialized to Main_Source_File at the start of a compilation, which -- means that no file names will be output unless there are errors in -- units other than the main unit. However, if the main unit has a pragma -- Source_Reference line, then this is initialized to No_Source_File, to -- force an initial reference to the real source file name. Raise_Exception_On_Error : Nat renames Err_Vars.Raise_Exception_On_Error; -- If this value is non-zero, then any attempt to generate an error -- message raises the exception Error_Msg_Exception, and the error message -- is not output. This is used for defending against junk resulting from -- illegalities, and also for substitution of more appropriate error -- messages from higher semantic levels. It is a counter so that the -- increment/decrement protocol nests neatly. Error_Msg_Exception : exception renames Err_Vars.Error_Msg_Exception; -- Exception raised if Raise_Exception_On_Error is true Warning_Doc_Switch : Boolean renames Err_Vars.Warning_Doc_Switch; -- If this is set True, then the ??/?*?/?$?/?x?/?X? insertion sequences in -- error messages generate appropriate tags for the output error messages. -- If this switch is False, then these sequences are still recognized (for -- the purposes of implementing the pattern matching in pragmas Warnings -- (Off,..) and Warning_As_Pragma(...) but do not result in adding the -- error message tag. The -gnatw.d switch sets this flag True, -gnatw.D -- sets this flag False. Current_Node : Node_Id := Empty; -- Used by Error_Msg as a default Node_Id. -- Relevant only when Opt.Include_Subprogram_In_Messages is set. ----------------------------------- -- Suppression of Error Messages -- ----------------------------------- -- In an effort to reduce the impact of redundant error messages, the -- error output routines in this package normally suppress certain -- classes of messages as follows: -- 1. Identical messages placed at the same point in the text. Such -- duplicate error message result for example from rescanning -- sections of the text that contain lexical errors. Only one of -- such a set of duplicate messages is output, and the rest are -- suppressed. -- 2. If more than one parser message is generated for a single source -- line, then only the first message is output, the remaining -- messages on the same line are suppressed. -- 3. If a message is posted on a node for which a message has been -- previously posted, then only the first message is retained. The -- Error_Posted flag is used to detect such multiple postings. Note -- that this only applies to semantic messages, since otherwise -- for parser messages, this would be a special case of case 2. -- 4. If a message is posted on a node whose Etype or Entity -- fields reference entities on which an error message has -- already been placed, as indicated by the Error_Posted flag -- being set on these entities, then the message is suppressed. -- 5. If a message attempts to insert an Error node, or a direct -- reference to the Any_Type node, then the message is suppressed. -- 6. Note that cases 2-5 only apply to error messages, not warning -- messages. Warning messages are only suppressed for case 1, and -- when they come from other than the main extended unit. -- 7. If an error or warning references an internal name, and we have -- already placed an error (not warning) message at that location, -- then we assume this is cascaded junk and delete the message. -- This normal suppression action may be overridden in cases 2-5 (but -- not in case 1 or 7) by setting All_Errors mode, or by setting the -- unconditional message insertion character (!) as described below. --------------------------------------------------------- -- Error Message Text and Message Insertion Characters -- --------------------------------------------------------- -- Error message text strings are composed of lower case letters, digits -- and the special characters space, comma, period, colon and semicolon, -- apostrophe and parentheses. Special insertion characters can also -- appear which cause the error message circuit to modify the given -- string as follows: -- Insertion character % (Percent: insert name from Names table) -- The character % is replaced by the text for the name specified by -- the Name_Id value stored in Error_Msg_Name_1. A blank precedes the -- name if it is preceded by a non-blank character other than left -- parenthesis. The name is enclosed in quotes unless manual quotation -- mode is set. If the Name_Id is set to No_Name, then no insertion -- occurs; if the Name_Id is set to Error_Name, then the string -- <error> is inserted. A second and third % may appear in a single -- message, similarly replaced by the names which are specified by the -- Name_Id values stored in Error_Msg_Name_2 and Error_Msg_Name_3. The -- names are decoded and cased according to the current identifier -- casing mode. Note: if a unit name ending with %b or %s is passed -- for this kind of insertion, this suffix is simply stripped. Use a -- unit name insertion ($) to process the suffix. -- -- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed -- to insert the string xxx'Class into the message. -- Insertion character %% (Double percent: insert literal name) -- The character sequence %% acts as described above for %, except -- that the name is simply obtained with Get_Name_String and is not -- decoded or cased, it is inserted literally from the names table. -- A trailing %b or %s is not treated specially. -- -- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed -- to insert the string xxx'Class into the message. -- Insertion character $ (Dollar: insert unit name from Names table) -- The character $ is treated similarly to %, except that the name is -- obtained from the Unit_Name_Type value in Error_Msg_Unit_1 and -- Error_Msg_Unit_2, as provided by Get_Unit_Name_String in package -- Uname. Note that this name includes the postfix (spec) or (body) -- strings. If this postfix is not required, use the normal % insertion -- for the unit name. -- Insertion character { (Left brace: insert file name from names table) -- The character { is treated similarly to %, except that the input -- value is a File_Name_Type value stored in Error_Msg_File_1 or -- Error_Msg_File_2 or Error_Msg_File_3. The value is output literally, -- enclosed in quotes as for %, but the case is not modified, the -- insertion is the exact string stored in the names table without -- adjusting the casing. -- Insertion character * (Asterisk: insert reserved word name) -- The insertion character * is treated exactly like % except that the -- resulting name is cased according to the default conventions for -- reserved words (see package Scans). -- Insertion character & (Ampersand: insert name from node) -- The insertion character & is treated similarly to %, except that -- the name is taken from the Chars field of the given node, and may -- refer to a child unit name, or a selected component. The casing is, -- if possible, taken from the original source reference, which is -- obtained from the Sloc field of the given node or nodes. If no Sloc -- is available (happens e.g. for nodes in package Standard), then the -- default case (see Scans spec) is used. The nodes to be used are -- stored in Error_Msg_Node_1, Error_Msg_Node_2. No insertion occurs -- for the Empty node, and the Error node results in the insertion of -- the characters <error>. In addition, if the special global variable -- Error_Msg_Qual_Level is non-zero, then the reference will include -- up to the given number of levels of qualification, using the scope -- chain. -- -- Note: the special names _xxx (xxx = Pre/Post/Invariant) are changed -- to insert the string xxx'Class into the message. -- Insertion character # (Pound: insert line number reference) -- The character # is replaced by the string indicating the source -- position stored in Error_Msg_Sloc. There are three cases: -- -- for package Standard: in package Standard -- for locations in current file: at line nnn:ccc -- for locations in other files: at filename:nnn:ccc -- -- By convention, the # insertion character is only used at the end of -- an error message, so the above strings only appear as the last -- characters of an error message. The only exceptions to this rule -- are that an RM reference may follow in the form (RM .....) and a -- right parenthesis may immediately follow the #. In the case of -- continued messages, # can only appear at the end of a group of -- continuation messages, except that \\ messages which always start -- a new line end the sequence from the point of view of this rule. -- The idea is that for any use of -gnatj, it will still be the case -- that a location reference appears only at the end of a line. -- Note: the output of the string "at " is suppressed if the string -- " from" or " from " immediately precedes the insertion character #. -- Certain messages read better with from than at. -- Insertion character } (Right brace: insert type reference) -- The character } is replaced by a string describing the type -- referenced by the entity whose Id is stored in Error_Msg_Node_1. -- The string gives the name or description of the type, and also -- where appropriate the location of its declaration. Special cases -- like "some integer type" are handled appropriately. Only one } is -- allowed in a message, since there is not enough room for two (the -- insertion can be quite long, including a file name). In addition, if -- the special global variable Error_Msg_Qual_Level is non-zero, then -- the reference will include up to the given number of levels of -- qualification, using the scope chain. -- Insertion character @ (At: insert column number reference) -- The character @ is replaced by null if the RM_Column_Check mode is -- off (False). If the switch is on (True), then @ is replaced by the -- text string " in column nnn" where nnn is the decimal -- representation of the column number stored in Error_Msg_Col plus -- one (the plus one is because the number is stored 0-origin and -- displayed 1-origin). -- Insertion character ^ (Caret: insert integer value) -- The character ^ is replaced by the decimal conversion of the Uint -- value stored in Error_Msg_Uint_1, with a possible leading minus. -- A second ^ may occur in the message, in which case it is replaced -- by the decimal conversion of the Uint value in Error_Msg_Uint_2. -- Insertion character > (Greater Than: run time name) -- The character > is replaced by a string of the form (name) if -- Targparm scanned out a Run_Time_Name (see package Targparm for -- details). The name is enclosed in parentheses and output in mixed -- case mode (upper case after any space in the name). If no run time -- name is defined, this insertion character has no effect. -- Insertion character ! (Exclamation: unconditional message) -- The character ! appearing anywhere in the text of a message makes -- the message unconditional which means that it is output even if it -- would normally be suppressed. See section above for a description -- of the cases in which messages are normally suppressed. Note that -- in the case of warnings, the meaning is that the warning should not -- be removed in dead code (that's the only time that the use of ! -- has any effect for a warning). -- -- Note: the presence of ! is ignored in continuation messages (i.e. -- messages starting with the \ insertion character). The effect of the -- use of ! in a parent message automatically applies to all of its -- continuation messages (since we clearly don't want any case in which -- continuations are separated from the main message). It is allowable -- to put ! in continuation messages, and the usual style is to include -- it, since it makes it clear that the continuation is part of an -- unconditional message. -- Insertion character !! (Double exclamation: unconditional warning) -- Normally warning messages issued in other than the main unit are -- suppressed. If the message contains !! then this suppression is -- avoided. This is currently used by the Compile_Time_Warning pragma -- to ensure the message for a with'ed unit is output, and for warnings -- on ineffective back-end inlining, which is detected in units that -- contain subprograms to be inlined in the main program. It is also -- used by the Compiler_Unit_Warning pragma for similar reasons. -- Insertion character ? (Question: warning message) -- The character ? appearing anywhere in a message makes the message -- warning instead of a normal error message, and the text of the -- message will be preceded by "warning:" in the normal case. The -- handling of warnings if further controlled by the Warning_Mode -- option (-w switch), see package Opt for further details, and also by -- the current setting from pragma Warnings. This pragma applies only -- to warnings issued from the semantic phase (not the parser), but -- currently all relevant warnings are posted by the semantic phase -- anyway. Messages starting with (style) are also treated as warning -- messages. -- -- Note: when a warning message is output, the text of the message is -- preceded by "warning: " in the normal case. An exception to this -- rule occurs when the text of the message starts with "info: " in -- which case this string is not prepended. This allows callers to -- label certain warnings as informational messages, rather than as -- warning messages requiring some action. -- -- Note: the presence of ? is ignored in continuation messages (i.e. -- messages starting with the \ insertion character). The warning -- status of continuations is determined only by the parent message -- which is being continued. It is allowable to put ? in continuation -- messages, and the usual style is to include it, since it makes it -- clear that the continuation is part of a warning message, but it is -- not necessary to go through any computational effort to include it. -- -- Note: this usage is obsolete, use ?? ?*? ?$? ?x? ?X? to specify -- the string to be added when Warn_Doc_Switch is set to True. If this -- switch is True, then for simple ? messages it has no effect. This -- simple form is to ease transition and may be removed later except -- for GNATprove-specific messages (info and warnings) which are not -- subject to the same GNAT warning switches. -- Insertion character ?? (Two question marks: default warning) -- Like ?, but if the flag Warn_Doc_Switch is True, adds the string -- "[enabled by default]" at the end of the warning message. For -- continuations, use this in each continuation message. -- Insertion character ?x? (warning with switch) -- Like ?, but if the flag Warn_Doc_Switch is True, adds the string -- "[-gnatwx]" at the end of the warning message. x is a lower case -- letter. For continuations, use this on each continuation message. -- Insertion character ?X? (warning with dot switch) -- Like ?, but if the flag Warn_Doc_Switch is True, adds the string -- "[-gnatw.x]" at the end of the warning message. X is an upper case -- letter corresponding to the lower case letter x in the message. -- For continuations, use this on each continuation message. -- Insertion character ?*? (restriction warning) -- Like ?, but if the flag Warn_Doc_Switch is True, adds the string -- "[restriction warning]" at the end of the warning message. For -- continuations, use this on each continuation message. -- Insertion character ?$? (elaboration informational messages) -- Like ?, but if the flag Warn_Doc_Switch is True, adds the string -- "[-gnatel]" at the end of the info message. This is used for the -- messages generated by the switch -gnatel. For continuations, use -- this on each continuation message. -- Insertion character < (Less Than: conditional warning message) -- The character < appearing anywhere in a message is used for a -- conditional error message. If Error_Msg_Warn is True, then the -- effect is the same as ? described above, and in particular << <X< -- <x< <$< <*< have the effect of ?? ?X? ?x? ?$? ?*? respectively. If -- Error_Msg_Warn is False, then the < << or <X< sequence is ignored -- and the message is treated as a error rather than a warning. -- Insertion character A-Z (Upper case letter: Ada reserved word) -- If two or more upper case letters appear in the message, they are -- taken as an Ada reserved word, and are converted to the default -- case for reserved words (see Scans package spec). Surrounding -- quotes are added unless manual quotation mode is currently set. -- RM and SPARK are special exceptions, they are never treated as -- keywords, and just appear verbatim, with no surrounding quotes. -- As a special case, 'R'M is used instead of RM (which is not treated -- as a keyword) to indicate when the reference to the RM is possibly -- not useful anymore, and could possibly be replaced by a comment -- in the source. -- Insertion character ` (Backquote: set manual quotation mode) -- The backquote character always appears in pairs. Each backquote of -- the pair is replaced by a double quote character. In addition, any -- reserved keywords, or name insertions between these backquotes are -- not surrounded by the usual automatic double quotes. See the -- section below on manual quotation mode for further details. -- Insertion character ' (Quote: literal character) -- Precedes a character which is placed literally into the message. -- Used to insert characters into messages that are one of the -- insertion characters defined here. Also used for insertion of -- upper case letter sequences not to be treated as keywords. -- Insertion character \ (Backslash: continuation message) -- Indicates that the message is a continuation of a message -- previously posted. This is used to ensure that such groups of -- messages are treated as a unit. The \ character must be the first -- character of the message text. -- Insertion character \\ (Two backslashes: continuation with new line) -- This differs from \ only in -gnatjnn mode (Error_Message_Line_Length -- set non-zero). This sequence forces a new line to start even when -- continuations are being gathered into a single message. -- Insertion character | (Vertical bar: non-serious error) -- By default, error messages (other than warning messages) are -- considered to be fatal error messages which prevent expansion or -- generation of code in the presence of the -gnatQ switch. If the -- insertion character | appears, the message is considered to be -- non-serious, and does not cause Serious_Errors_Detected to be -- incremented (so expansion is not prevented by such a msg). This -- insertion character is ignored in continuation messages. -- Insertion character ~ (Tilde: insert string) -- Indicates that Error_Msg_String (1 .. Error_Msg_Strlen) is to be -- inserted to replace the ~ character. The string is inserted in the -- literal form it appears, without any action on special characters. -- Insertion character [ (Left bracket: will/would be raised at run time) -- This is used in messages about exceptions being raised at run-time. -- If the current message is a warning message, then if the code is -- executed, the exception will be raised, and [ inserts: -- -- will be raised at run time -- -- If the current message is an error message, then it is an error -- because the exception would have been raised and [ inserts: -- -- would have been raised at run time -- -- Typically the message contains a < insertion which means that the -- message is a warning or error depending on Error_Msg_Warn. This is -- most typically used in the context of messages which are normally -- warnings, but are errors in GNATprove mode, corresponding to the -- permission in the definition of SPARK that allows an implementation -- to reject a program as illegal if a situation arises in which the -- compiler can determine that it is certain that a run-time check -- would have fail if the statement was executed. -- Insertion character ] (Right bracket: may/might be raised at run time) -- This is like [ except that the insertion messages say may/might, -- instead of will/would. -- Insertion sequence "(style)" (style message) -- This appears only at the start of the message (and not any of its -- continuations, if any), and indicates that the message is a style -- message. Style messages are also considered to be warnings, but -- they do not get a tag. -- Insertion sequence "info: " (informational message) -- This appears only at the start of the message (and not any of its -- continuations, if any), and indicates that the message is an info -- message. The message will be output with this prefix, and if there -- are continuations that are not printed using the -gnatj switch they -- will also have this prefix. Informational messages are usually also -- warnings, but they don't have to be. -- Insertion sequence "low: " or "medium: " or "high: " (check message) -- This appears only at the start of the message (and not any of its -- continuations, if any), and indicates that the message is a check -- message. The message will be output with this prefix. Check -- messages are not fatal (so are like info messages in that respect) -- and are not controlled by pragma Warnings. ----------------------------------------------------- -- Global Values Used for Error Message Insertions -- ----------------------------------------------------- -- The following global variables are essentially additional parameters -- passed to the error message routine for insertion sequences described -- above. The reason these are passed globally is that the insertion -- mechanism is essentially an untyped one in which the appropriate -- variables are set depending on the specific insertion characters used. -- Note that is mandatory that the caller ensure that global variables -- are set before the Error_Msg call, otherwise the result is undefined. -- Also note that calls to Error_Msg and its variants destroy the value of -- these global variables, as a way to support the inclusion of multiple -- insertion characters of the same type. For example, support for -- multiple characters % for a name in the message (up to 3) is -- implemented by unconditionally shifting the value for Error_Msg_Nam_2 -- to Error_Msg_Nam_1 and from Error_Msg_Nam_3 to Error_Msg_Nam_2 after -- dealing with insertion character %. The caller should ensure that all -- global variables are restored if needed prior to calling Error_Msg. Error_Msg_Col : Column_Number renames Err_Vars.Error_Msg_Col; -- Column for @ insertion character in message Error_Msg_Uint_1 : Uint renames Err_Vars.Error_Msg_Uint_1; Error_Msg_Uint_2 : Uint renames Err_Vars.Error_Msg_Uint_2; -- Uint values for ^ insertion characters in message Error_Msg_Sloc : Source_Ptr renames Err_Vars.Error_Msg_Sloc; -- Source location for # insertion character in message Error_Msg_Name_1 : Name_Id renames Err_Vars.Error_Msg_Name_1; Error_Msg_Name_2 : Name_Id renames Err_Vars.Error_Msg_Name_2; Error_Msg_Name_3 : Name_Id renames Err_Vars.Error_Msg_Name_3; -- Name_Id values for % insertion characters in message Error_Msg_File_1 : File_Name_Type renames Err_Vars.Error_Msg_File_1; Error_Msg_File_2 : File_Name_Type renames Err_Vars.Error_Msg_File_2; Error_Msg_File_3 : File_Name_Type renames Err_Vars.Error_Msg_File_3; -- File_Name_Type values for { insertion characters in message Error_Msg_Unit_1 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_1; Error_Msg_Unit_2 : Unit_Name_Type renames Err_Vars.Error_Msg_Unit_2; -- Unit_Name_Type values for $ insertion characters in message Error_Msg_Node_1 : Node_Id renames Err_Vars.Error_Msg_Node_1; Error_Msg_Node_2 : Node_Id renames Err_Vars.Error_Msg_Node_2; -- Node_Id values for & insertion characters in message Error_Msg_Qual_Level : Nat renames Err_Vars.Error_Msg_Qual_Level; -- Number of levels of qualification required for type name (see the -- description of the } insertion character). Note that this value does -- not get reset by any Error_Msg call, so the caller is responsible -- for resetting it. Error_Msg_Warn : Boolean renames Err_Vars.Error_Msg_Warn; -- Used if current message contains a < insertion character to indicate -- if the current message is a warning message. Must be set appropriately -- before any call to Error_Msg_xxx with a < insertion character present. -- Setting is irrelevant if no < insertion character is present. Error_Msg_String : String renames Err_Vars.Error_Msg_String; Error_Msg_Strlen : Natural renames Err_Vars.Error_Msg_Strlen; -- Used if current message contains a ~ insertion character to indicate -- insertion of the string Error_Msg_String (1 .. Error_Msg_Strlen). ----------------------------------------------------- -- Format of Messages and Manual Quotation Control -- ----------------------------------------------------- -- Messages are generally all in lower case, except for inserted names -- and appear in one of the following three forms: -- error: text -- warning: text -- The prefixes error and warning are supplied automatically (depending -- on the use of the ? insertion character), and the call to the error -- message routine supplies the text. The "error: " prefix is omitted -- in brief error message formats. -- Reserved Ada keywords in the message are in the default keyword case -- (determined from the given source program), surrounded by quotation -- marks. This is achieved by spelling the reserved word in upper case -- letters, which is recognized as a request for insertion of quotation -- marks by the error text processor. Thus for example: -- Error_Msg_AP ("IS expected"); -- would result in the output of one of the following: -- error: "is" expected -- error: "IS" expected -- error: "Is" expected -- the choice between these being made by looking at the casing convention -- used for keywords (actually the first compilation unit keyword) in the -- source file. -- Note: a special exception is that RM is never treated as a keyword -- but instead is copied literally into the message, this avoids the -- need for writing 'R'M for all reference manual quotes. A similar -- exception is applied to the occurrence of the string SPARK used in -- error messages about the SPARK subset of Ada. -- In the case of names, the default mode for the error text processor -- is to surround the name by quotation marks automatically. The case -- used for the identifier names is taken from the source program where -- possible, and otherwise is the default casing convention taken from -- the source file usage. -- In some cases, better control over the placement of quote marks is -- required. This is achieved using manual quotation mode. In this mode, -- one or more insertion sequences is surrounded by backquote characters. -- The backquote characters are output as double quote marks, and normal -- automatic insertion of quotes is suppressed between the double quotes. -- For example: -- Error_Msg_AP ("`END &;` expected"); -- generates a message like -- error: "end Open_Scope;" expected -- where the node specifying the name Open_Scope has been stored in -- Error_Msg_Node_1 prior to the call. The great majority of error -- messages operates in normal quotation mode. -- Note: the normal automatic insertion of spaces before insertion -- sequences (such as those that come from & and %) is suppressed in -- manual quotation mode, so blanks, if needed as in the above example, -- must be explicitly present. ---------------------------- -- Message ID Definitions -- ---------------------------- subtype Error_Msg_Id is Erroutc.Error_Msg_Id; function "=" (Left, Right : Error_Msg_Id) return Boolean renames Erroutc."="; -- A type used to represent specific error messages. Used by the clients -- of this package only in the context of the Get_Error_Id and -- Change_Error_Text subprograms. No_Error_Msg : constant Error_Msg_Id := Erroutc.No_Error_Msg; -- A constant which is different from any value returned by Get_Error_Id. -- Typically used by a client to indicate absense of a saved Id value. Warning_Msg : Error_Msg_Id := No_Error_Msg; -- This is set if a warning message is generated to the ID of the resulting -- message. Continuation messages have no effect. It is legitimate for the -- client to set this to No_Error_Msg and then test it to see if a warning -- message has been issued. procedure Delete_Warning_And_Continuations (Msg : Error_Msg_Id); -- Deletes the given warning message and all its continuations. This is -- typically used in conjunction with reading the value of Warning_Msg. function Get_Msg_Id return Error_Msg_Id renames Erroutc.Get_Msg_Id; -- Returns the Id of the message most recently posted using one of the -- Error_Msg routines. function Get_Location (E : Error_Msg_Id) return Source_Ptr renames Erroutc.Get_Location; -- Returns the flag location of the error message with the given id E ------------------------ -- List Pragmas Table -- ------------------------ -- When a pragma Page or pragma List is encountered by the parser, an -- entry is made in the following table. This table is then used to -- control the full listing if one is being generated. Note that the -- reason we do the processing in the parser is so that we get proper -- listing control even in syntax check only mode. type List_Pragma_Type is (List_On, List_Off, Page); type List_Pragma_Record is record Ptyp : List_Pragma_Type; Ploc : Source_Ptr; end record; -- Note: Ploc points to the terminating semicolon in the List_Off and Page -- cases, and to the pragma keyword for List_On. In the case of a pragma -- List_Off, a List_On entry is also made in the table, pointing to the -- pragma keyword. This ensures that, as required, a List (Off) pragma is -- listed even in list off mode. package List_Pragmas is new Table.Table ( Table_Component_Type => List_Pragma_Record, Table_Index_Type => Int, Table_Low_Bound => 1, Table_Initial => 50, Table_Increment => 200, Table_Name => "List_Pragmas"); --------------------------- -- Ignore_Errors Feature -- --------------------------- -- In certain cases, notably for optional subunits, the compiler operates -- in a mode where errors are to be ignored, and the whole unit is to be -- considered as not present. To implement this we provide the following -- flag to enable special handling, where error messages are suppressed, -- but the Fatal_Error flag will still be set in the normal manner. Ignore_Errors_Enable : Nat := 0; -- Triggering switch. If non-zero, then ignore errors mode is activated. -- This is a counter to allow convenient nesting of enable/disable. ----------------------- -- CODEFIX Facility -- ----------------------- -- The GNAT Studio and GNATBench IDE's have a codefix facility that allows -- for automatic correction of a subset of the errors and warnings issued -- by the compiler. This is done by recognizing the text of specific -- messages using appropriate matching patterns. -- The text of such messages should not be altered without coordinating -- with the codefix code. All such messages are marked by a specific -- style of comments, as shown by the following example: -- Error_Msg_N -- CODEFIX -- (parameters ....) -- Any message marked with this -- CODEFIX comment should not be modified -- without appropriate coordination. ------------------------------ -- Error Output Subprograms -- ------------------------------ procedure Initialize; -- Initializes for output of error messages. Must be called for each -- source file before using any of the other routines in the package. procedure Finalize (Last_Call : Boolean); -- Finalize processing of error message list. Includes processing for -- duplicated error messages, and other similar final adjustment of the -- list of error messages. Note that this procedure must be called before -- calling Compilation_Errors to determine if there were any errors. It -- is perfectly fine to call Finalize more than once, providing that the -- parameter Last_Call is set False for every call except the last call. -- This multiple call capability is used to do some processing that may -- generate messages. Call Finalize to eliminate duplicates and remove -- deleted warnings. Test for compilation errors using Compilation_Errors, -- then generate some more errors/warnings, call Finalize again to make -- sure that all duplicates in these new messages are dealt with, then -- finally call Output_Messages to output the final list of messages. The -- argument Last_Call must be set False on all calls except the last call, -- and must be set True on the last call (a value of True activates some -- processing that must only be done after all messages are posted). procedure Output_Messages; -- Output list of messages, including messages giving number of detected -- errors and warnings. procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr); procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr; N : Node_Id); -- Output a message at specified location. Can be called from the parser -- or the semantic analyzer. If N is set, points to the relevant node for -- this message. procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr; Is_Compile_Time_Pragma : Boolean); -- Same as Error_Msg (String, Source_Ptr) except Is_Compile_Time_Pragma -- lets the caller specify whether this is a Compile_Time_Warning or -- Compile_Time_Error pragma. procedure Error_Msg_S (Msg : String); -- Output a message at current scan pointer location. This routine can be -- called only from the parser, since it references Scan_Ptr. procedure Error_Msg_AP (Msg : String); -- Output a message just after the previous token. This routine can be -- called only from the parser, since it references Prev_Token_Ptr. procedure Error_Msg_BC (Msg : String); -- Output a message just before the current token. Note that the important -- difference between this and the previous routine is that the BC case -- posts a flag on the current line, whereas AP can post a flag at the -- end of the preceding line. This routine can be called only from the -- parser, since it references Token_Ptr. procedure Error_Msg_SC (Msg : String); -- Output a message at the start of the current token, unless we are at -- the end of file, in which case we always output the message after the -- last real token in the file. This routine can be called only from the -- parser, since it references Token_Ptr. procedure Error_Msg_SP (Msg : String); -- Output a message at the start of the previous token. This routine can -- be called only from the parser, since it references Prev_Token_Ptr. procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id); -- Output a message at the Sloc of the given node. This routine can be -- called from the parser or the semantic analyzer, although the call from -- the latter is much more common (and is the most usual way of generating -- error messages from the analyzer). The message text may contain a -- single & insertion, which will reference the given node. The message is -- suppressed if the node N already has a message posted, or if it is a -- warning and N is an entity node for which warnings are suppressed. -- WARNING: There is a matching C declaration of this subprogram in fe.h procedure Error_Msg_F (Msg : String; N : Node_Id); -- Similar to Error_Msg_N except that the message is placed on the first -- node of the construct N (First_Node (N)). Note that this procedure uses -- Original_Node to look at the original source tree, since that's what we -- want for placing an error message flag in the right place. procedure Error_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id); -- Output a message at the Sloc of the given node N, with an insertion of -- the name from the given entity node E. This is used by the semantic -- routines, where this is a common error message situation. The Msg text -- will contain a & or } as usual to mark the insertion point. This -- routine can be called from the parser or the analyzer. -- WARNING: There is a matching C declaration of this subprogram in fe.h procedure Error_Msg_FE (Msg : String; N : Node_Id; E : Node_Or_Entity_Id); -- Same as Error_Msg_NE, except that the message is placed on the first -- node of the construct N (First_Node (N)). procedure Error_Msg_NEL (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id; Flag_Location : Source_Ptr); -- Exactly the same as Error_Msg_NE, except that the flag is placed at -- the specified Flag_Location instead of at Sloc (N). procedure Error_Msg_NW (Eflag : Boolean; Msg : String; N : Node_Or_Entity_Id); -- This routine is used for posting a message conditionally. The message -- is posted (with the same effect as Error_Msg_N (Msg, N) if and only -- if Eflag is True and if the node N is within the main extended source -- unit and comes from source. Typically this is a warning mode flag. -- This routine can only be called during semantic analysis. It may not -- be called during parsing. procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String); -- The error message text of the message identified by Id is replaced by -- the given text. This text may contain insertion characters in the -- usual manner, and need not be the same length as the original text. function First_Node (C : Node_Id) return Node_Id; -- Given a construct C, finds the first node in the construct, i.e. the one -- with the lowest Sloc value. This is useful in placing error msgs. Note -- that this procedure uses Original_Node to look at the original source -- tree, since that's what we want for placing an error message flag in -- the right place. function First_Sloc (N : Node_Id) return Source_Ptr; -- Given the node for an expression, return a source pointer value that -- points to the start of the first token in the expression. In the case -- where the expression is parenthesized, an attempt is made to include -- the parentheses (i.e. to return the location of the initial paren). function Get_Ignore_Errors return Boolean; -- Return True if all error calls are ignored. procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr) renames Erroutc.Purge_Messages; -- All error messages whose location is in the range From .. To (not -- including the end points) will be deleted from the error listing. procedure Remove_Warning_Messages (N : Node_Id); -- Remove any warning messages corresponding to the Sloc of N or any -- of its descendant nodes. No effect if no such warnings. Note that -- style messages (identified by the fact that they start with "(style)") -- are not removed by this call. Basically the idea behind this procedure -- is to remove warnings about execution conditions from known dead code. procedure Remove_Warning_Messages (L : List_Id); -- Remove warnings on all elements of a list (Calls Remove_Warning_Messages -- on each element of the list, see above). procedure Reset_Warnings; -- Reset the counts related to warnings. This is used both to initialize -- these counts and to reset them after each phase of analysis for a given -- value of Opt.Warning_Mode in gnat2why. procedure Set_Ignore_Errors (To : Boolean); -- Following a call to this procedure with To=True, all error calls are -- ignored. A call with To=False restores the default treatment in which -- error calls are treated as usual (and as described in this spec). procedure Set_Warnings_Mode_Off (Loc : Source_Ptr; Reason : String_Id) renames Erroutc.Set_Warnings_Mode_Off; -- Called in response to a pragma Warnings (Off) to record the source -- location from which warnings are to be turned off. Reason is the -- Reason from the pragma, or the null string if none is given. procedure Set_Warnings_Mode_On (Loc : Source_Ptr) renames Erroutc.Set_Warnings_Mode_On; -- Called in response to a pragma Warnings (On) to record the source -- location from which warnings are to be turned back on. procedure Set_Specific_Warning_Off (Loc : Source_Ptr; Msg : String; Reason : String_Id; Config : Boolean; Used : Boolean := False) renames Erroutc.Set_Specific_Warning_Off; -- This is called in response to the two argument form of pragma Warnings -- where the first argument is OFF, and the second argument is a string -- which identifies a specific warning to be suppressed. The first argument -- is the start of the suppression range, and the second argument is the -- string from the pragma. Loc is the location of the pragma (which is the -- start of the range to suppress). Reason is the reason string from the -- pragma, or the null string if no reason is given. Config is True for the -- configuration pragma case (where there is no requirement for a matching -- OFF pragma). Used is set True to disable the check that the warning -- actually has the effect of suppressing a warning. procedure Set_Specific_Warning_On (Loc : Source_Ptr; Msg : String; Err : out Boolean) renames Erroutc.Set_Specific_Warning_On; -- This is called in response to the two argument form of pragma Warnings -- where the first argument is ON, and the second argument is the prefix -- of a specific warning to be suppressed. The first argument is the end -- of the suppression range, and the second argument is the string from -- the pragma. Err is set to True on return to report the error of no -- matching Warnings Off pragma preceding this one. function Compilation_Errors return Boolean; -- Returns True if errors have been detected, or warnings in -gnatwe (treat -- warnings as errors) mode. Note that it is mandatory to call Finalize -- before calling this routine. To account for changes to Warning_Mode in -- gnat2why between phases, the past or current presence of an error is -- recorded in a global variable at each call. procedure Error_Msg_CRT (Feature : String; N : Node_Id); -- Posts a non-fatal message on node N saying that the feature identified -- by the Feature argument is not supported in either configurable -- run-time mode or no run-time mode (as appropriate). In the former case, -- the name of the library is output if available. procedure Error_Msg_PT (E : Entity_Id; Iface_Prim : Entity_Id); -- Posts an error on protected type entry or subprogram E (referencing its -- overridden interface primitive Iface_Prim) indicating wrong mode of the -- first formal (RM 9.4(11.9/3)). procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr); -- If not operating in Ada 2012 mode or higher, posts errors complaining -- that Feature is only supported in Ada 2012, with appropriate suggestions -- to fix this. Loc is the location at which the flag is to be posted. -- Feature, which appears at the start of the first generated message, may -- contain error message insertion characters in the normal manner, and in -- particular may start with | to flag a non-serious error. procedure Error_Msg_Ada_2020_Feature (Feature : String; Loc : Source_Ptr); -- Analogous to Error_Msg_Ada_2012_Feature procedure dmsg (Id : Error_Msg_Id) renames Erroutc.dmsg; -- Debugging routine to dump an error message ------------------------------------ -- SPARK Error Output Subprograms -- ------------------------------------ -- The following routines are intended to report semantic errors in SPARK -- constructs subject to aspect/pragma SPARK_Mode. Note that syntax errors -- must be reported using the Error_Msg_XXX routines. This allows for the -- partial analysis of SPARK features when they are disabled via SPARK_Mode -- set to "off". procedure SPARK_Msg_N (Msg : String; N : Node_Or_Entity_Id); pragma Inline (SPARK_Msg_N); -- Same as Error_Msg_N, but the error is suppressed if SPARK_Mode is Off. -- The routine is inlined because it acts as a simple wrapper. procedure SPARK_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id); pragma Inline (SPARK_Msg_NE); -- Same as Error_Msg_NE, but the error is suppressed if SPARK_Mode is Off. -- The routine is inlined because it acts as a simple wrapper. ------------------------------------------ -- Utility Interface for Casing Control -- ------------------------------------------ procedure Adjust_Name_Case (Buf : in out Bounded_String; Loc : Source_Ptr); -- Given a name stored in Buf, set proper casing. Loc is an associated -- source position, and if we can find a match between the name in Buf and -- the name at that source location, we copy the casing from the source, -- otherwise we set appropriate default casing. procedure Adjust_Name_Case (Loc : Source_Ptr); -- Uses Buf => Global_Name_Buffer. There are no calls to this in the -- compiler, but it is called in SPARK 2014. procedure Set_Identifier_Casing (Identifier_Name : System.Address; File_Name : System.Address); -- This subprogram can be used by the back end for the purposes of -- concocting error messages that are not output via Errout, e.g. -- the messages generated by the gcc back end. -- -- The identifier is a null terminated string that represents the name of -- an identifier appearing in the source program. File_Name is a null -- terminated string giving the corresponding file name for the identifier -- as obtained from the front end by the use of Full_Debug_Name to the -- source file referenced by the corresponding source location value. On -- return, the name is in Name_Buffer, null terminated with Name_Len set. -- This name is the identifier name as passed, cased according to the -- default identifier casing for the given file. -- WARNING: There is a matching C declaration of this subprogram in fe.h function Is_Size_Too_Small_Message (S : String) return Boolean; Size_Too_Small_Message : constant String := "size for& too small, minimum allowed is ^"; -- This message is printed in Freeze and Sem_Ch13. We also test for it in -- the body of this package (see Special_Msg_Delete) ???which is somewhat -- questionable. The Is_Size_Too_Small_Message function tests for it by -- testing a prefix. The function and constant should be kept in synch. end Errout;
----------------------------------------------------------------------- -- awa-events-dispatchers-actions -- Event dispatcher to Ada bean actions -- Copyright (C) 2012, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers.Doubly_Linked_Lists; with EL.Expressions; with EL.Beans; with AWA.Events.Queues; with AWA.Applications; -- The <b>AWA.Events.Dispatchers.Actions</b> package implements an event dispatcher -- which calls a set of Ada bean action methods that have been registered on the dispatcher -- during configuration time. package AWA.Events.Dispatchers.Actions is -- ------------------------------ -- Event action dispatcher -- ------------------------------ type Action_Dispatcher (Application : AWA.Applications.Application_Access) is new Dispatcher with private; -- Dispatch the event identified by <b>Event</b>. -- The event actions which are associated with the event are executed synchronously. overriding procedure Dispatch (Manager : in Action_Dispatcher; Event : in Module_Event'Class); -- Add an action invoked when an event is dispatched through this dispatcher. -- When the event queue dispatches the event, the Ada bean identified by the method action -- represented by <b>Action</b> is created and initialized by evaluating and setting the -- parameters defined in <b>Params</b>. The action method is then invoked. overriding procedure Add_Action (Manager : in out Action_Dispatcher; Action : in EL.Expressions.Method_Expression; Params : in EL.Beans.Param_Vectors.Vector); -- Create a new dispatcher associated with the application. function Create_Dispatcher (Application : in AWA.Applications.Application_Access) return Dispatcher_Access; private -- An event action records a method expression which identifies an Ada bean and a method -- that must be invoked when the event is dispatched. The Ada bean instance is populated -- by evaluating and setting the set of properties before calling the action method. type Event_Action is record Action : EL.Expressions.Method_Expression; Properties : EL.Beans.Param_Vectors.Vector; end record; -- A list of event actions. package Event_Action_Lists is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Event_Action); -- The dispatcher maintains a list of event actions to which the events are dispatched. type Action_Dispatcher (Application : AWA.Applications.Application_Access) is new Dispatcher with record Actions : Event_Action_Lists.List; Queue : AWA.Events.Queues.Queue_Ref; end record; end AWA.Events.Dispatchers.Actions;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics 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 file is based on: -- -- -- -- @file stm32f4xx_hal_spi.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief SPI HAL module driver. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with System; with STM32_SVD.SPI; use STM32_SVD.SPI; package body STM32.SPI is use type HAL.SPI.SPI_Data_Size; Baud_Rate_Value : constant array (SPI_Baud_Rate_Prescaler) of UInt3 := (BRP_2 => 2#000#, BRP_4 => 2#001#, BRP_8 => 2#010#, BRP_16 => 2#011#, BRP_32 => 2#100#, BRP_64 => 2#101#, BRP_128 => 2#110#, BRP_256 => 2#111#); type Half_Word_Pointer is access all Short with Storage_Size => 0; function As_Half_Word_Pointer is new Ada.Unchecked_Conversion (Source => System.Address, Target => Half_Word_Pointer); -- So that we can treat the address of a byte as a pointer to a two-byte -- sequence representing a Half_Word quantity --------------- -- Configure -- --------------- procedure Configure (Port : in out SPI_Port; Conf : SPI_Configuration) is begin case Conf.Mode is when Master => Port.Periph.CR1.MSTR := True; Port.Periph.CR1.SSI := True; when Slave => Port.Periph.CR1.MSTR := False; Port.Periph.CR1.SSI := False; end case; case Conf.Direction is when D2Lines_FullDuplex => Port.Periph.CR1.BIDIMODE := False; Port.Periph.CR1.BIDIOE := False; Port.Periph.CR1.RXONLY := False; when D2Lines_RxOnly => Port.Periph.CR1.BIDIMODE := False; Port.Periph.CR1.BIDIOE := False; Port.Periph.CR1.RXONLY := True; when D1Line_Rx => Port.Periph.CR1.BIDIMODE := True; Port.Periph.CR1.BIDIOE := False; Port.Periph.CR1.RXONLY := False; when D1Line_Tx => Port.Periph.CR1.BIDIMODE := True; Port.Periph.CR1.BIDIOE := True; Port.Periph.CR1.RXONLY := False; end case; Port.Periph.CR1.DFF := Conf.Data_Size = HAL.SPI.Data_Size_16b; Port.Periph.CR1.CPOL := Conf.Clock_Polarity = High; Port.Periph.CR1.CPHA := Conf.Clock_Phase = P2Edge; Port.Periph.CR1.SSM := Conf.Slave_Management = Software_Managed; Port.Periph.CR1.BR := Baud_Rate_Value (Conf.Baud_Rate_Prescaler); Port.Periph.CR1.LSBFIRST := Conf.First_Bit = LSB; -- Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) Port.Periph.I2SCFGR.I2SMOD := False; Port.Periph.CRCPR.CRCPOLY := Conf.CRC_Poly; end Configure; ------------ -- Enable -- ------------ procedure Enable (Port : in out SPI_Port) is begin Port.Periph.CR1.SPE := True; end Enable; ------------- -- Disable -- ------------- procedure Disable (Port : in out SPI_Port) is begin Port.Periph.CR1.SPE := False; end Disable; ------------- -- Enabled -- ------------- function Enabled (Port : SPI_Port) return Boolean is begin return Port.Periph.CR1.SPE; end Enabled; ---------- -- Send -- ---------- procedure Send (Port : in out SPI_Port; Data : Short) is begin Port.Periph.DR.DR := Data; end Send; ---------- -- Data -- ---------- function Data (Port : SPI_Port) return Short is begin return Port.Periph.DR.DR; end Data; ---------- -- Send -- ---------- procedure Send (Port : in out SPI_Port; Data : Byte) is begin Send (Port, Short (Data)); end Send; ---------- -- Data -- ---------- function Data (Port : SPI_Port) return Byte is begin return Byte (Short'(Data (Port))); end Data; ------------- -- Is_Busy -- ------------- function Is_Busy (Port : SPI_Port) return Boolean is begin return (Rx_Is_Empty (Port) and then not Tx_Is_Empty (Port)) or else Busy (Port); end Is_Busy; ----------------- -- Tx_Is_Empty -- ----------------- function Tx_Is_Empty (Port : SPI_Port) return Boolean is begin return Port.Periph.SR.TXE; end Tx_Is_Empty; ----------------- -- Rx_Is_Empty -- ----------------- function Rx_Is_Empty (Port : SPI_Port) return Boolean is begin return not Port.Periph.SR.RXNE; end Rx_Is_Empty; ---------- -- Busy -- ---------- function Busy (Port : SPI_Port) return Boolean is begin return Port.Periph.SR.BSY; end Busy; ------------------ -- Current_Mode -- ------------------ function Current_Mode (Port : SPI_Port) return SPI_Mode is begin if Port.Periph.CR1.MSTR and Port.Periph.CR1.SSI then return Master; else return Slave; end if; end Current_Mode; ---------------------------- -- Current_Data_Direction -- ---------------------------- function Current_Data_Direction (Port : SPI_Port) return SPI_Data_Direction is begin if not Port.Periph.CR1.BIDIMODE then if not Port.Periph.CR1.RXONLY then return D2Lines_FullDuplex; else return D2Lines_RxOnly; end if; else if not Port.Periph.CR1.BIDIOE then return D1Line_Rx; else return D1Line_Tx; end if; end if; end Current_Data_Direction; ----------------- -- CRC_Enabled -- ----------------- function CRC_Enabled (Port : SPI_Port) return Boolean is (Port.Periph.CR1.CRCEN); ---------------------------- -- Channel_Side_Indicated -- ---------------------------- function Channel_Side_Indicated (Port : SPI_Port) return Boolean is (Port.Periph.SR.CHSIDE); ------------------------ -- Underrun_Indicated -- ------------------------ function Underrun_Indicated (Port : SPI_Port) return Boolean is (Port.Periph.SR.UDR); ------------------------- -- CRC_Error_Indicated -- ------------------------- function CRC_Error_Indicated (Port : SPI_Port) return Boolean is (Port.Periph.SR.CRCERR); -------------------------- -- Mode_Fault_Indicated -- -------------------------- function Mode_Fault_Indicated (Port : SPI_Port) return Boolean is (Port.Periph.SR.MODF); ----------------------- -- Overrun_Indicated -- ----------------------- function Overrun_Indicated (Port : SPI_Port) return Boolean is (Port.Periph.SR.OVR); ------------------------------- -- Frame_Fmt_Error_Indicated -- ------------------------------- function Frame_Fmt_Error_Indicated (Port : SPI_Port) return Boolean is begin return Port.Periph.SR.TIFRFE; end Frame_Fmt_Error_Indicated; ------------------- -- Clear_Overrun -- ------------------- procedure Clear_Overrun (Port : SPI_Port) is Dummy1 : Short; Dummy2 : SR_Register; begin Dummy1 := Port.Periph.DR.DR; Dummy2 := Port.Periph.SR; end Clear_Overrun; --------------- -- Reset_CRC -- --------------- procedure Reset_CRC (Port : in out SPI_Port) is begin Port.Periph.CR1.CRCEN := False; Port.Periph.CR1.CRCEN := True; end Reset_CRC; ------------------------- -- Is_Data_Frame_16bit -- ------------------------- function Is_Data_Frame_16bit (Port : SPI_Port) return Boolean is (Port.Periph.CR1.DFF); --------------- -- Data_Size -- --------------- overriding function Data_Size (Port : SPI_Port) return HAL.SPI.SPI_Data_Size is begin if Port.Periph.CR1.DFF then return HAL.SPI.Data_Size_16b; else return HAL.SPI.Data_Size_8b; end if; end Data_Size; -------------- -- Transmit -- -------------- overriding procedure Transmit (Port : in out SPI_Port; Data : HAL.SPI.SPI_Data_8b; Status : out HAL.SPI.SPI_Status; Timeout : Natural := 1000) is pragma Unreferenced (Timeout); begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; -- ??? right value to compare??? if Current_Data_Direction (Port) = D1Line_Tx then Port.Periph.CR1.BIDIOE := True; end if; Clear_Overrun (Port); if not Enabled (Port) then Enable (Port); end if; Send_8bit_Mode (Port, Data); -- Wait until TXE flag is set to send data while not Tx_Is_Empty (Port) loop null; end loop; -- Wait until Busy flag is reset before disabling SPI while Busy (Port) loop null; end loop; -- Clear OVERUN flag in 2-Line communication mode because received byte -- is not read. if Current_Data_Direction (Port) in D2Lines_RxOnly | D2Lines_FullDuplex then -- right comparison ??? Clear_Overrun (Port); end if; Status := HAL.SPI.Ok; end Transmit; -------------- -- Transmit -- -------------- overriding procedure Transmit (Port : in out SPI_Port; Data : HAL.SPI.SPI_Data_16b; Status : out HAL.SPI.SPI_Status; Timeout : Natural := 1000) is pragma Unreferenced (Timeout); begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; -- ??? right value to compare??? if Current_Data_Direction (Port) = D1Line_Tx then Port.Periph.CR1.BIDIOE := True; end if; Clear_Overrun (Port); if not Enabled (Port) then Enable (Port); end if; Send_16bit_Mode (Port, Data); -- Wait until TXE flag is set to send data while not Tx_Is_Empty (Port) loop null; end loop; -- Wait until Busy flag is reset before disabling SPI while Busy (Port) loop null; end loop; -- Clear OVERUN flag in 2-Line communication mode because received byte -- is not read. if Current_Data_Direction (Port) in D2Lines_RxOnly | D2Lines_FullDuplex then -- right comparison ??? Clear_Overrun (Port); Status := HAL.SPI.Err_Error; end if; Status := HAL.SPI.Ok; end Transmit; -------------- -- Transmit -- -------------- procedure Transmit (Port : in out SPI_Port; Outgoing : Byte) is begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; -- ??? right value to compare??? if Current_Data_Direction (Port) = D1Line_Tx then Port.Periph.CR1.BIDIOE := True; end if; if not Enabled (Port) then Enable (Port); end if; Port.Periph.DR.DR := Short (Outgoing); while not Tx_Is_Empty (Port) loop null; end loop; while Busy (Port) loop null; end loop; -- Clear OVERUN flag in 2-Line communication mode because received byte -- is not read. if Current_Data_Direction (Port) in D2Lines_RxOnly | D2Lines_FullDuplex then -- right comparison ??? Clear_Overrun (Port); end if; end Transmit; ------------- -- Receive -- ------------- overriding procedure Receive (Port : in out SPI_Port; Data : out HAL.SPI.SPI_Data_8b; Status : out HAL.SPI.SPI_Status; Timeout : Natural := 1000) is pragma Unreferenced (Timeout); begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; if not Enabled (Port) then Enable (Port); end if; Receive_8bit_Mode (Port, Data); while Busy (Port) loop null; end loop; if CRC_Enabled (Port) and CRC_Error_Indicated (Port) then Reset_CRC (Port); Status := HAL.SPI.Err_Error; end if; Status := HAL.SPI.Ok; end Receive; ------------- -- Receive -- ------------- overriding procedure Receive (Port : in out SPI_Port; Data : out HAL.SPI.SPI_Data_16b; Status : out HAL.SPI.SPI_Status; Timeout : Natural := 1000) is pragma Unreferenced (Timeout); begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; if not Enabled (Port) then Enable (Port); end if; Receive_16bit_Mode (Port, Data); while Busy (Port) loop null; end loop; if CRC_Enabled (Port) and CRC_Error_Indicated (Port) then Reset_CRC (Port); Status := HAL.SPI.Err_Error; end if; Status := HAL.SPI.Ok; end Receive; ------------- -- Receive -- ------------- procedure Receive (Port : in out SPI_Port; Incoming : out Byte) is begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; if not Enabled (Port) then Enable (Port); end if; Port.Periph.DR.DR := 0; -- generate clock while Rx_Is_Empty (Port) loop null; end loop; Incoming := Byte (Port.Periph.DR.DR); if CRC_Enabled (Port) then while Rx_Is_Empty (Port) loop null; end loop; Read_CRC : declare Dummy : Short; begin Dummy := Port.Periph.DR.DR; end Read_CRC; end if; while Busy (Port) loop null; end loop; if CRC_Enabled (Port) and CRC_Error_Indicated (Port) then Reset_CRC (Port); end if; end Receive; ---------------------- -- Transmit_Receive -- ---------------------- procedure Transmit_Receive (Port : in out SPI_Port; Outgoing : Byte_Buffer; Incoming : out Byte_Buffer; Size : Positive) is begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; if not Enabled (Port) then Enable (Port); end if; if Is_Data_Frame_16bit (Port) then Send_Receive_16bit_Mode (Port, Outgoing, Incoming, Size); else Send_Receive_8bit_Mode (Port, Outgoing, Incoming, Size); end if; -- Read CRC to close CRC calculation process if CRC_Enabled (Port) then -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Read_CRC : declare Dummy : Short; begin Dummy := Port.Periph.DR.DR; end Read_CRC; end if; while Busy (Port) loop null; end loop; if CRC_Enabled (Port) and CRC_Error_Indicated (Port) then Reset_CRC (Port); end if; end Transmit_Receive; ---------------------- -- Transmit_Receive -- ---------------------- procedure Transmit_Receive (Port : in out SPI_Port; Outgoing : Byte; Incoming : out Byte) is begin if CRC_Enabled (Port) then Reset_CRC (Port); end if; if not Enabled (Port) then Enable (Port); end if; if Is_Data_Frame_16bit (Port) then raise Program_Error; end if; Port.Periph.DR.DR := Short (Outgoing); -- enable CRC transmission if CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Incoming := Byte (Port.Periph.DR.DR); -- Read CRC byte to close CRC calculation if CRC_Enabled (Port) then -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Read_CRC : declare Dummy : Short; begin Dummy := Port.Periph.DR.DR; end Read_CRC; end if; while Busy (Port) loop null; end loop; if CRC_Enabled (Port) and CRC_Error_Indicated (Port) then Reset_CRC (Port); end if; end Transmit_Receive; ----------------------------- -- Send_Receive_16bit_Mode -- ----------------------------- procedure Send_Receive_16bit_Mode (Port : in out SPI_Port; Outgoing : Byte_Buffer; Incoming : out Byte_Buffer; Size : Positive) is Tx_Count : Natural := Size; Outgoing_Index : Natural := Outgoing'First; Incoming_Index : Natural := Incoming'First; begin if Current_Mode (Port) = Slave or else Tx_Count = 1 then Port.Periph.DR.DR := As_Half_Word_Pointer (Outgoing (Outgoing_Index)'Address).all; Outgoing_Index := Outgoing_Index + 2; Tx_Count := Tx_Count - 1; end if; if Tx_Count = 0 then -- enable CRC transmission if CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; As_Half_Word_Pointer (Incoming (Incoming_Index)'Address).all := Port.Periph.DR.DR; Incoming_Index := Incoming_Index + 2; return; end if; while Tx_Count > 0 loop -- wait until we can send data while not Tx_Is_Empty (Port) loop null; end loop; Port.Periph.DR.DR := As_Half_Word_Pointer (Outgoing (Outgoing_Index)'Address).all; Outgoing_Index := Outgoing_Index + 2; Tx_Count := Tx_Count - 1; -- enable CRC transmission if Tx_Count = 0 and CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; As_Half_Word_Pointer (Incoming (Incoming_Index)'Address).all := Port.Periph.DR.DR; Incoming_Index := Incoming_Index + 2; end loop; -- receive the last byte if Current_Mode (Port) = Slave then -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; As_Half_Word_Pointer (Incoming (Incoming_Index)'Address).all := Port.Periph.DR.DR; Incoming_Index := Incoming_Index + 2; end if; end Send_Receive_16bit_Mode; ---------------------------- -- Send_Receive_8bit_Mode -- ---------------------------- procedure Send_Receive_8bit_Mode (Port : in out SPI_Port; Outgoing : Byte_Buffer; Incoming : out Byte_Buffer; Size : Positive) is Tx_Count : Natural := Size; Outgoing_Index : Natural := Outgoing'First; Incoming_Index : Natural := Incoming'First; begin if Current_Mode (Port) = Slave or else Tx_Count = 1 then Port.Periph.DR.DR := Short (Outgoing (Outgoing_Index)); Outgoing_Index := Outgoing_Index + 1; Tx_Count := Tx_Count - 1; end if; if Tx_Count = 0 then -- enable CRC transmission if CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Incoming (Incoming_Index) := Byte (Port.Periph.DR.DR); return; end if; while Tx_Count > 0 loop -- wait until we can send data while not Tx_Is_Empty (Port) loop null; end loop; Port.Periph.DR.DR := Short (Outgoing (Outgoing_Index)); Outgoing_Index := Outgoing_Index + 1; Tx_Count := Tx_Count - 1; -- enable CRC transmission if Tx_Count = 0 and CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Incoming (Incoming_Index) := Byte (Port.Periph.DR.DR); Incoming_Index := Incoming_Index + 1; end loop; if Current_Mode (Port) = Slave then -- wait until data is received while Rx_Is_Empty (Port) loop null; end loop; Incoming (Incoming_Index) := Data (Port); Incoming_Index := Incoming_Index + 1; end if; end Send_Receive_8bit_Mode; --------------------- -- Send_16bit_Mode -- --------------------- procedure Send_16bit_Mode (Port : in out SPI_Port; Outgoing : HAL.SPI.SPI_Data_16b) is Tx_Count : Natural := Outgoing'Length; Index : Natural := Outgoing'First; begin if Current_Mode (Port) = Slave or else Tx_Count = 1 then Port.Periph.DR.DR := As_Half_Word_Pointer (Outgoing (Index)'Address).all; Index := Index + 2; Tx_Count := Tx_Count - 1; end if; while Tx_Count > 0 loop -- wait until we can send data while not Tx_Is_Empty (Port) loop null; end loop; Port.Periph.DR.DR := As_Half_Word_Pointer (Outgoing (Index)'Address).all; Index := Index + 2; Tx_Count := Tx_Count - 1; end loop; if CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; end Send_16bit_Mode; -------------------- -- Send_8bit_Mode -- -------------------- procedure Send_8bit_Mode (Port : in out SPI_Port; Outgoing : HAL.SPI.SPI_Data_8b) is Tx_Count : Natural := Outgoing'Length; Index : Natural := Outgoing'First; begin if Current_Mode (Port) = Slave or else Tx_Count = 1 then Port.Periph.DR.DR := Short (Outgoing (Index)); Index := Index + 1; Tx_Count := Tx_Count - 1; end if; while Tx_Count > 0 loop -- wait until we can send data while not Tx_Is_Empty (Port) loop null; end loop; Port.Periph.DR.DR := Short (Outgoing (Index)); Index := Index + 1; Tx_Count := Tx_Count - 1; end loop; if CRC_Enabled (Port) then Port.Periph.CR1.CRCNEXT := True; end if; end Send_8bit_Mode; ------------------------ -- Receive_16bit_Mode -- ------------------------ procedure Receive_16bit_Mode (Port : in out SPI_Port; Incoming : out HAL.SPI.SPI_Data_16b) is Generate_Clock : constant Boolean := Current_Mode (Port) = Master; begin for K of Incoming loop if Generate_Clock then Port.Periph.DR.DR := 0; end if; while Rx_Is_Empty (Port) loop null; end loop; K := Port.Periph.DR.DR; end loop; end Receive_16bit_Mode; ----------------------- -- Receive_8bit_Mode -- ----------------------- procedure Receive_8bit_Mode (Port : in out SPI_Port; Incoming : out HAL.SPI.SPI_Data_8b) is Generate_Clock : constant Boolean := Current_Mode (Port) = Master; begin for K of Incoming loop if Generate_Clock then Port.Periph.DR.DR := 0; end if; while Rx_Is_Empty (Port) loop null; end loop; K := Byte (Port.Periph.DR.DR); end loop; end Receive_8bit_Mode; end STM32.SPI;
-- CB3004A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT WHEN AN INNER UNIT REDECLARES AN EXCEPTION NAME -- THE HIDDEN DEFINITION IS STILL AVAILABLE FOR USE. -- NOTE : WE ASSUME FUNCTIONS ACT LIKE PROCEDURES AND -- THAT UNITS, BLOCKS, AND PROCEDURES ACT THE SAME -- IN OTHER CONTEXTS (E.G. TASKS AND PACKAGES). -- DCB 6/2/80 -- JRK 11/19/80 -- SPS 3/24/83 WITH REPORT; PROCEDURE CB3004A IS USE REPORT; E1 : EXCEPTION; FLOW_COUNT : INTEGER := 0; PROCEDURE P1 IS E1, E2 : EXCEPTION; PROCEDURE P2 IS E1 : EXCEPTION; BEGIN FLOW_COUNT := FLOW_COUNT + 1; RAISE E1; FAILED("E1 EXCEPTION NOT RAISED"); EXCEPTION WHEN P1.E1 => FAILED("P1.E1 EXCEPTION RAISED WHEN " & "(P2)E1 EXPECTED"); WHEN E1 => BEGIN FLOW_COUNT := FLOW_COUNT + 1; RAISE P1.E1; FAILED("P1.E1 EXCEPTION NOT RAISED"); EXCEPTION WHEN E1 => FAILED("(P2)E1 EXCEPTION RAISED WHEN" & " P1.E1 EXPECTED"); WHEN P1.E1 => FLOW_COUNT := FLOW_COUNT + 1; WHEN OTHERS => FAILED("OTHERS RAISED WHEN P1.E1 " & "EXPECTED"); END; WHEN OTHERS => FAILED("OTHERS RAISED WHEN (P2)E1 EXPECTED"); END P2; PROCEDURE P3 IS CONSTRAINT_ERROR : EXCEPTION; BEGIN FLOW_COUNT := FLOW_COUNT + 1; RAISE CONSTRAINT_ERROR; FAILED("CONSTRAINT_ERROR EXCEPTION NOT RAISED"); EXCEPTION WHEN STANDARD.CONSTRAINT_ERROR => FAILED("STANDARD.CONSTRAINT_ERROR EXCEPTION " & "RAISED WHEN " & "(P3)CONSTRAINT_ERROR EXPECTED"); WHEN CONSTRAINT_ERROR => BEGIN FLOW_COUNT := FLOW_COUNT + 1; RAISE STANDARD.CONSTRAINT_ERROR; FAILED("STANDARD.CONSTRAINT_ERROR " & "EXCEPTION NOT RAISED"); EXCEPTION WHEN CONSTRAINT_ERROR => FAILED("(P3)CONSTRAINT_ERROR " & "EXCEPTION RAISED WHEN " & "STANDARD.CONSTRAINT_ERROR " & "EXPECTED"); WHEN STANDARD.CONSTRAINT_ERROR => FLOW_COUNT := FLOW_COUNT + 1; WHEN OTHERS => FAILED("OTHERS RAISED WHEN " & "STANDARD.CONSTRAINT_ERROR " & "EXPECTED"); END; WHEN OTHERS => FAILED("OTHERS RAISED WHEN " & "(P3)CONSTRAINT_ERROR EXPECTED"); END P3; PROCEDURE P4 IS E2 : EXCEPTION; BEGIN FLOW_COUNT := FLOW_COUNT + 1; RAISE P1.E2; FAILED("P1.E2 EXCEPTION NOT RAISED"); EXCEPTION WHEN E2 => FAILED("(P4).E2 RAISED WHEN P1.E2 EXPECTED"); END P4; BEGIN -- P1 P2; P3; P4; FAILED("P1.E2 EXCEPTION NOT PROPAGATED FROM P4"); EXCEPTION WHEN E2 => FLOW_COUNT := FLOW_COUNT + 1; WHEN OTHERS => FAILED("EXCEPTION RAISED WHERE NONE EXPECTED"); END P1; BEGIN TEST("CB3004A","CHECK THAT WHEN EXCEPTION NAMES" & " ARE REDECLARED THE HIDDEN DEFINITION IS STILL AVAILABLE"); P1; IF FLOW_COUNT /= 8 THEN FAILED("INCORRECT FLOW_COUNT VALUE"); END IF; RESULT; END CB3004A;
procedure Accept_Statement is task type The_Task_Type is entry The_Entry; end The_Task_Type; task body The_Task_Type is begin accept The_Entry; accept The_Entry do null; end The_Entry; end The_Task_Type; begin null; end Accept_Statement;
-- -- Copyright (c) 2007-2009 Tero Koskinen <tero.koskinen@iki.fi> -- -- Permission to use, copy, modify, and distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- with Ada.Text_IO; with Ada.Strings.Fixed; with Ada.Characters.Latin_1; with Ada.IO_Exceptions; with Ahven.Runner; with Ahven.XML_Runner; with Ahven.AStrings; use Ada.Text_IO; use Ada.Strings.Fixed; package body Ahven.Text_Runner is use Ahven.Results; use Ahven.Framework; use Ahven.AStrings; -- Local procedures procedure Pad (Level : Natural); procedure Print_Test (Info : Result_Info; Level : Natural; Result : String); procedure Print_Passes (Result : Result_Collection; Level : Natural); procedure Report_Results (Result : Result_Collection; Verbose : Boolean := False); procedure Print_Log_File (Filename : String); procedure Pad (Level : Natural) is begin for A in Integer range 1 .. Level loop Put (" "); end loop; end Pad; procedure Pad (Amount : in Natural; Total : in out Natural) is begin for A in Natural range 1 .. Amount loop Put (" "); end loop; Total := Total + Amount; end Pad; procedure Multiline_Pad (Input : String; Level : Natural) is begin Pad (Level); for A in Input'Range loop Put (Input (A)); if (Input (A) = Ada.Characters.Latin_1.LF) and (A /= Input'Last) then Pad (Level); end if; end loop; end Multiline_Pad; procedure Print_Test (Info : Result_Info; Level : Natural; Result : String) is use Ada.Strings; Max_Output_Width : constant := 50; Max_Result_Width : constant := 7; Max_Time_Out_Width : constant := 12; subtype Result_Size is Integer range 1 .. Max_Result_Width; subtype Time_Out_Size is Integer range 1 .. Max_Time_Out_Width; procedure Print_Text (Str : String; Total : in out Natural) is begin Put (Str); Total := Total + Str'Length; end Print_Text; Msg : constant String := Get_Message (Info); Result_Out : String (Result_Size) := (others => ' '); Time_Out : String (Time_Out_Size) := (others => ' '); Total_Text : Natural := 0; begin Pad (Level + 1, Total_Text); Print_Text (Get_Routine_Name (Info), Total_Text); if Msg'Length > 0 then Print_Text (" - ", Total_Text); Print_Text (Msg, Total_Text); end if; if Total_Text < Max_Output_Width then Pad (Max_Output_Width - Total_Text, Total_Text); end if; -- If we know the name of the routine, we print it, -- the result, and the execution time. if Get_Routine_Name (Info)'Length > 0 then Move (Source => Result, Target => Result_Out, Drop => Right, Justify => Left, Pad => ' '); Move (Source => Duration'Image (Get_Execution_Time (Info)), Target => Time_Out, Drop => Right, Justify => Right, Pad => ' '); Put (" " & Result_Out); Put (" " & Time_Out & "s"); end if; if Get_Long_Message (Info)'Length > 0 then New_Line; Multiline_Pad (Get_Long_Message (Info), Level + 2); end if; New_Line; end Print_Test; type Print_Child_Proc is access procedure (Result : Result_Collection; Level : Natural); type Child_Count_Proc is access function (Result : Result_Collection) return Natural; procedure Print_Children (Result : Result_Collection; Level : Natural; Action : Print_Child_Proc; Count : Child_Count_Proc) is Child_Iter : Result_Collection_Cursor := First_Child (Result); begin loop exit when not Is_Valid (Child_Iter); if Count.all (Data (Child_Iter).all) > 0 then Action.all (Data (Child_Iter).all, Level + 1); end if; Child_Iter := Next (Child_Iter); end loop; end Print_Children; procedure Print_Statuses (Result : Result_Collection; Level : Natural; Start : Result_Info_Cursor; Action : Print_Child_Proc; Status : String; Count : Child_Count_Proc; Print_Log : Boolean) is Position : Result_Info_Cursor := Start; begin if Length (Get_Test_Name (Result)) > 0 then Pad (Level); Put_Line (To_String (Get_Test_Name (Result)) & ":"); end if; Test_Loop : loop exit Test_Loop when not Is_Valid (Position); Print_Test (Data (Position), Level, Status); if Print_Log and (Length (Get_Output_File (Data (Position))) > 0) then Print_Log_File (To_String (Get_Output_File (Data (Position)))); end if; Position := Next (Position); end loop Test_Loop; Print_Children (Result => Result, Level => Level, Action => Action, Count => Count); end Print_Statuses; -- -- Print all failures from the result collection -- and then recurse into child collections. -- procedure Print_Failures (Result : Result_Collection; Level : Natural) is begin Print_Statuses (Result => Result, Level => Level, Start => First_Failure (Result), Action => Print_Failures'Access, Status => "FAIL", Count => Failure_Count'Access, Print_Log => True); end Print_Failures; -- -- Print all skips from the result collection -- and then recurse into child collections. -- procedure Print_Skips (Result : Result_Collection; Level : Natural) is begin Print_Statuses (Result => Result, Level => Level, Start => First_Skipped (Result), Action => Print_Skips'Access, Status => "SKIPPED", Count => Skipped_Count'Access, Print_Log => True); end Print_Skips; -- -- Print all errors from the result collection -- and then recurse into child collections. -- procedure Print_Errors (Result : Result_Collection; Level : Natural) is begin Print_Statuses (Result => Result, Level => Level, Start => First_Error (Result), Action => Print_Errors'Access, Status => "ERROR", Count => Error_Count'Access, Print_Log => True); end Print_Errors; -- -- Print all passes from the result collection -- and then recurse into child collections. -- procedure Print_Passes (Result : Result_Collection; Level : Natural) is begin Print_Statuses (Result => Result, Level => Level, Start => First_Pass (Result), Action => Print_Passes'Access, Status => "PASS", Count => Pass_Count'Access, Print_Log => False); end Print_Passes; -- -- Report passes, skips, failures, and errors from the result collection. procedure Report_Results (Result : Result_Collection; Verbose : Boolean := False) is begin Put_Line ("Passed : " & Integer'Image (Pass_Count (Result))); if Verbose then Print_Passes (Result => Result, Level => 0); end if; New_Line; if Skipped_Count (Result) > 0 then Put_Line ("Skipped : " & Integer'Image (Skipped_Count (Result))); Print_Skips (Result => Result, Level => 0); New_Line; end if; if Failure_Count (Result) > 0 then Put_Line ("Failed : " & Integer'Image (Failure_Count (Result))); Print_Failures (Result => Result, Level => 0); New_Line; end if; if Error_Count (Result) > 0 then Put_Line ("Errors : " & Integer'Image (Error_Count (Result))); Print_Errors (Result => Result, Level => 0); end if; end Report_Results; procedure Print_Log_File (Filename : String) is Handle : File_Type; Char : Character := ' '; First : Boolean := True; begin Open (Handle, In_File, Filename); begin loop exit when End_Of_File (Handle); Get (Handle, Char); if First then Put_Line ("===== Output ======="); First := False; end if; Put (Char); if End_Of_Line (Handle) then New_Line; end if; end loop; -- The End_Error exception is sometimes raised. exception when Ada.IO_Exceptions.End_Error => null; end; Close (Handle); if not First then Put_Line ("===================="); end if; end Print_Log_File; procedure Do_Report (Test_Results : Results.Result_Collection; Args : Parameters.Parameter_Info) is begin if Parameters.XML_Results (Args) then XML_Runner.Report_Results (Test_Results, Parameters.Result_Dir (Args)); else Report_Results (Test_Results, Parameters.Verbose (Args)); end if; end Do_Report; procedure Run (Suite : in out Framework.Test'Class) is begin Runner.Run_Suite (Suite, Do_Report'Access); end Run; procedure Run (Suite : Framework.Test_Suite_Access) is begin Run (Suite.all); end Run; end Ahven.Text_Runner;
-- $Id: Strings.md,v 1.3 1992/08/07 14:45:41 grosch rel $ -- $Log: Strings.md,v $ -- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994 with Text_Io; use Text_Io; package strings is type tString is access String; NoString : tString := new String'(""); function Length (Source: tString) return Natural; procedure To_tString (Source: String; Target: in out tString); function To_String (Source: tString) return String; function "&" (Left, Right: tString) return tString; function "&" (Left: tString ; Right: String ) return tString; function "&" (Left: String ; Right: tString ) return tString; function "&" (Left: tString ; Right: Character) return tString; function "&" (Left: Character; Right: tString ) return tString; function Element (Source: tString; Index: Positive) return Character; procedure Replace_Element (Source: in out tString; Index: Positive; By: Character); function Slice (Source: tString; Low: Positive; High: Natural) return String; function Replace_Slice (Source: tString; Low: Positive; High: Natural; By: String) return tString; function "=" (Left, Right : tString) return Boolean; function "<" (Left, Right : tString) return Boolean; function "<=" (Left, Right : tString) return Boolean; function ">" (Left, Right : tString) return Boolean; function ">=" (Left, Right : tString) return Boolean; procedure ReadS (File: File_Type; Target: in out tString); procedure WriteS (File: File_Type; Source: tString); end strings;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Stream_Element_Vectors; with Web_Services.SOAP.Payloads.Faults.Simple; with Web_Services.SOAP.Security.Constants; with Web_Services.SOAP.Security.Headers; with Web_Services.SOAP.Security.Password_Digest_Utilities; package body Web_Services.SOAP.Security.Modules is procedure Default_Provider (Username : League.Strings.Universal_String; Password : out League.Strings.Universal_String; Success : out Boolean); Get_Authentication_Data : Authentication_Data_Provider := Default_Provider'Access; procedure Create_Invalid_Security_Token_Fault (Output : out Web_Services.SOAP.Messages.SOAP_Message_Access); procedure Create_Failed_Authentication_Fault (Output : out Web_Services.SOAP.Messages.SOAP_Message_Access); ---------------------------------------- -- Create_Failed_Authentication_Fault -- ---------------------------------------- procedure Create_Failed_Authentication_Fault (Output : out Web_Services.SOAP.Messages.SOAP_Message_Access) is begin Output := new Web_Services.SOAP.Messages.SOAP_Message' (Payload => Web_Services.SOAP.Payloads.Faults.Simple.Create_Sender_Fault (Web_Services.SOAP.Security.Constants.WSSE_Namespace_URI, League.Strings.To_Universal_String ("FailedAuthentication"), League.Strings.To_Universal_String ("wsse"), League.Strings.To_Universal_String ("en-US"), League.Strings.To_Universal_String ("The security token could not be authenticated" & " or authorized")), others => <>); end Create_Failed_Authentication_Fault; ----------------------------------------- -- Create_Invalid_Security_Token_Fault -- ----------------------------------------- procedure Create_Invalid_Security_Token_Fault (Output : out Web_Services.SOAP.Messages.SOAP_Message_Access) is begin Output := new Web_Services.SOAP.Messages.SOAP_Message' (Payload => Web_Services.SOAP.Payloads.Faults.Simple.Create_Sender_Fault (Web_Services.SOAP.Security.Constants.WSSE_Namespace_URI, League.Strings.To_Universal_String ("InvalidSecurityToken"), League.Strings.To_Universal_String ("wsse"), League.Strings.To_Universal_String ("en-US"), League.Strings.To_Universal_String ("An invalid security token was provided")), others => <>); end Create_Invalid_Security_Token_Fault; ---------------------- -- Default_Provider -- ---------------------- procedure Default_Provider (Username : League.Strings.Universal_String; Password : out League.Strings.Universal_String; Success : out Boolean) is use type League.Strings.Universal_String; begin if Username /= League.Strings.To_Universal_String ("boris") then Success := False; else Success := True; Password := League.Strings.To_Universal_String ("123"); end if; end Default_Provider; --------------------- -- Receive_Request -- --------------------- overriding procedure Receive_Request (Self : in out Security_Module; Message : in out Web_Services.SOAP.Messages.SOAP_Message; Output : in out Web_Services.SOAP.Messages.SOAP_Message_Access) is pragma Unreferenced (Self); use type League.Stream_Element_Vectors.Stream_Element_Vector; use type League.Strings.Universal_String; use type Web_Services.SOAP.Security.Headers.Username_Token_Header_Access; Token : Web_Services.SOAP.Security.Headers.Username_Token_Header_Access; Password : League.Strings.Universal_String; Success : Boolean; begin -- There is no authentication data provider configured, security is -- disabled. if Get_Authentication_Data = null then return; end if; -- Obtain authentication token. for Header of Message.Headers loop if Header.all in Web_Services.SOAP.Security.Headers.Username_Token_Header'Class then Token := Web_Services.SOAP.Security.Headers.Username_Token_Header_Access (Header); exit; end if; end loop; -- Authentication token is not provided, return fault. if Token = null then Create_Invalid_Security_Token_Fault (Output); return; end if; -- Obtain authentication data. Get_Authentication_Data (Token.Username, Password, Success); if not Success then Create_Failed_Authentication_Fault (Output); return; end if; -- Check password. case Token.Mode is when Web_Services.SOAP.Security.Headers.Text => if Password /= Token.Password then Create_Failed_Authentication_Fault (Output); return; end if; when Web_Services.SOAP.Security.Headers.Digest => -- Password digest is calculated as: -- -- Password_Digest = -- Base64 ( SHA-1 ( nonce + created + password ) ) if Web_Services.SOAP.Security.Password_Digest_Utilities. Compute_Digest (Password, Token.Nonce, Token.Created) /= Token.Digest then Create_Failed_Authentication_Fault (Output); return; end if; end case; end Receive_Request; ------------------ -- Send_Request -- ------------------ overriding procedure Send_Request (Self : in out Security_Module; Message : in out Web_Services.SOAP.Messages.SOAP_Message; User : League.Strings.Universal_String; Password : League.Strings.Universal_String) is pragma Unreferenced (Self); begin if User.Is_Empty then return; end if; declare Header : constant Web_Services.SOAP.Security.Headers.Username_Token_Header_Access := new Web_Services.SOAP.Security.Headers.Username_Token_Header; begin Header.Mode := Headers.Digest; -- FIXME: How does user set mode? Header.Password := Password; -- For Mode = Text Header.Username := User; Header.Nonce := Web_Services.SOAP.Security.Password_Digest_Utilities.Generate_Nonce; Header.Created := Web_Services.SOAP.Security.Password_Digest_Utilities. Generate_Created; Header.Digest := Web_Services.SOAP.Security.Password_Digest_Utilities.Compute_Digest (Password, Header.Nonce, Header.Created); Message.Headers.Insert (Header.all'Access); end; end Send_Request; -------------------------------------- -- Set_Authentication_Data_Provider -- -------------------------------------- procedure Set_Authentication_Data_Provider (Provider : Authentication_Data_Provider) is begin Get_Authentication_Data := Provider; end Set_Authentication_Data_Provider; end Web_Services.SOAP.Security.Modules;
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- S Y S T E M . W C H _ J I S -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- The GNAT library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU Library General Public License as published by -- -- the Free Software Foundation; either version 2, or (at your option) any -- -- later version. The GNAT library is distributed in the hope that it will -- -- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty -- -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Library General Public License for more details. You should have -- -- received a copy of the GNU Library General Public License along with -- -- the GNAT library; see the file COPYING.LIB. If not, write to the Free -- -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines used for converting between internal -- JIS codes and the two external forms we support (EUC and Shift-JIS) package System.WCh_JIS is pragma Pure (WCh_JIS); function EUC_To_JIS (EUC1, EUC2 : Character) return Wide_Character; -- Given the two bytes of a EUC representation, return the -- corresponding JIS code wide character. Raises Constraint_Error -- if the two characters are not a valid EUC encoding. procedure JIS_To_EUC (J : in Wide_Character; EUC1 : out Character; EUC2 : out Character); -- Given a wide character in JIS form, produce the corresponding -- two bytes of the EUC representation of this character. This is -- only used if J is not in the normal ASCII range, i.e. on entry -- we know that Wide_Character'Pos (J) >= 16#0080# and that we -- thus require a two byte EUC representation (ASCII codes appear -- unchanged as a single byte in EUC). No error checking is performed, -- the input code is assumed to be in an appropriate range. procedure JIS_To_Shift_JIS (J : in Wide_Character; SJ1 : out Character; SJ2 : out Character); -- Given a wide character code in JIS form, produce the corresponding -- two bytes of the Shift-JIS representation of this character. This -- is only used if J is not in the normal ASCII range, i.e. on entry -- we know that Wide_Character'Pos (J) >= 16#0080# and that we -- thus require a two byte EUC representation (ASCII codes appear -- unchanged as a single byte in EUC). No error checking is performed, -- the input code is assumed to be in an appropriate range (note in -- particular that input codes in the range 16#0080#-16#00FF#, i.e. -- Hankaku Kana, do not appear, since Shift JIS has no representation -- for such codes. function Shift_JIS_To_JIS (SJ1, SJ2 : Character) return Wide_Character; -- Given the two bytes of a Shift-JIS representation, return the -- corresponding JIS code wide character. Raises Constraint_Error if -- the two characters are not a valid shift-JIS encoding. end System.WCh_JIS;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Identifiers; with Program.Elements.Variants; with Program.Elements.Variant_Parts; with Program.Element_Visitors; package Program.Nodes.Variant_Parts is pragma Preelaborate; type Variant_Part is new Program.Nodes.Node and Program.Elements.Variant_Parts.Variant_Part and Program.Elements.Variant_Parts.Variant_Part_Text with private; function Create (Case_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Discriminant : not null Program.Elements.Identifiers.Identifier_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Variants : not null Program.Elements.Variants .Variant_Vector_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Case_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Variant_Part; type Implicit_Variant_Part is new Program.Nodes.Node and Program.Elements.Variant_Parts.Variant_Part with private; function Create (Discriminant : not null Program.Elements.Identifiers .Identifier_Access; Variants : not null Program.Elements.Variants .Variant_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Variant_Part with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Variant_Part is abstract new Program.Nodes.Node and Program.Elements.Variant_Parts.Variant_Part with record Discriminant : not null Program.Elements.Identifiers.Identifier_Access; Variants : not null Program.Elements.Variants .Variant_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Variant_Part'Class); overriding procedure Visit (Self : not null access Base_Variant_Part; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Discriminant (Self : Base_Variant_Part) return not null Program.Elements.Identifiers.Identifier_Access; overriding function Variants (Self : Base_Variant_Part) return not null Program.Elements.Variants.Variant_Vector_Access; overriding function Is_Variant_Part_Element (Self : Base_Variant_Part) return Boolean; overriding function Is_Definition_Element (Self : Base_Variant_Part) return Boolean; type Variant_Part is new Base_Variant_Part and Program.Elements.Variant_Parts.Variant_Part_Text with record Case_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Case_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Variant_Part_Text (Self : aliased in out Variant_Part) return Program.Elements.Variant_Parts.Variant_Part_Text_Access; overriding function Case_Token (Self : Variant_Part) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Is_Token (Self : Variant_Part) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function End_Token (Self : Variant_Part) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Case_Token_2 (Self : Variant_Part) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Variant_Part) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Variant_Part is new Base_Variant_Part with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Variant_Part_Text (Self : aliased in out Implicit_Variant_Part) return Program.Elements.Variant_Parts.Variant_Part_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Variant_Part) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Variant_Part) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Variant_Part) return Boolean; end Program.Nodes.Variant_Parts;
----------------------------------------------------------------------- -- jason-tickets-modules -- Module tickets -- Copyright (C) 2016, 2017, 2019 Stephane.Carrez -- Written by Stephane.Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar; with AWA.Modules.Beans; with AWA.Modules.Get; with AWA.Permissions; with AWA.Comments.Models; with Util.Log.Loggers; with Jason.Tickets.Beans; with ADO.Sessions; with AWA.Services.Contexts; with ADO.Sessions.Entities; package body Jason.Tickets.Modules is use type ADO.Identifier; package ASC renames AWA.Services.Contexts; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Jason.Tickets.Module"); package Register is new AWA.Modules.Beans (Module => Ticket_Module, Module_Access => Ticket_Module_Access); -- ------------------------------ -- Initialize the tickets module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Ticket_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the tickets module"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_Bean'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_List_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_List_Bean'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Status_List_Bean", Handler => Jason.Tickets.Beans.Create_Status_List'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Type_List_Bean", Handler => Jason.Tickets.Beans.Create_Type_List'Access); Register.Register (Plugin => Plugin, Name => "Jason.Tickets.Beans.Ticket_Report_Bean", Handler => Jason.Tickets.Beans.Create_Ticket_Report_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); -- Add here the creation of manager instances. end Initialize; -- ------------------------------ -- Get the tickets module. -- ------------------------------ function Get_Ticket_Module return Ticket_Module_Access is function Get is new AWA.Modules.Get (Ticket_Module, Ticket_Module_Access, NAME); begin return Get; end Get_Ticket_Module; -- ------------------------------ -- Load the ticket. -- ------------------------------ procedure Load_Ticket (Model : in Ticket_Module; Ticket : in out Jason.Tickets.Models.Ticket_Ref'Class; Project : in out Jason.Projects.Models.Project_Ref'Class; Tags : in out AWA.Tags.Beans.Tag_List_Bean; Id : in ADO.Identifier) is DB : ADO.Sessions.Session := Model.Get_Session; Found : Boolean; begin if Id /= ADO.NO_IDENTIFIER then Ticket.Load (DB, Id, Found); if Found then Project.Load (DB, Ticket.Get_Project.Get_Id, Found); end if; else Project.Load (DB, Project.Get_Id, Found); end if; -- Jason.Projects.Models.Project_Ref (Project) := ; -- Ticket.Get_Project.Copy (Projects.Models.Project_Ref (Project)); if Id /= ADO.NO_IDENTIFIER and Found then Tags.Load_Tags (DB, Id); end if; end Load_Ticket; -- ------------------------------ -- Create -- ------------------------------ procedure Create (Model : in Ticket_Module; Entity : in out Jason.Tickets.Models.Ticket_Ref'Class; Project_Id : in ADO.Identifier) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); User : constant ADO.Identifier := Ctx.Get_User_Identifier; Project : Jason.Projects.Models.Project_Ref; begin -- Check that the user has the create ticket permission on the given project. AWA.Permissions.Check (Permission => ACL_Create_Tickets.Permission, Entity => Project_Id); Ctx.Start; Project.Load (DB, Project_Id); Project.Set_Last_Ticket (Project.Get_Last_Ticket + 1); Entity.Set_Create_Date (Ada.Calendar.Clock); Entity.Set_Status (Jason.Tickets.Models.OPEN); Entity.Set_Creator (Ctx.Get_User); Entity.Set_Project (Project); Entity.Set_Ident (Project.Get_Last_Ticket); Entity.Save (DB); Project.Save (DB); Ctx.Commit; Log.Info ("Ticket {0} created for user {1}", ADO.Identifier'Image (Entity.Get_Id), ADO.Identifier'Image (User)); end Create; -- ------------------------------ -- Save -- ------------------------------ procedure Save (Model : in Ticket_Module; Entity : in out Jason.Tickets.Models.Ticket_Ref'Class; Comment : in String) is pragma Unreferenced (Model); Ctx : constant ASC.Service_Context_Access := ASC.Current; DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx); Cmt : AWA.Comments.Models.Comment_Ref; Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; begin -- Check that the user has the update ticket permission on the given ticket. AWA.Permissions.Check (Permission => ACL_Update_Tickets.Permission, Entity => Entity); Ctx.Start; Entity.Set_Update_Date (Now); if Comment'Length > 0 then Cmt.Set_Author (Ctx.Get_User); Cmt.Set_Create_Date (Now); Cmt.Set_Message (Comment); Cmt.Set_Entity_Id (Entity.Get_Id); Cmt.Set_Entity_Type (ADO.Sessions.Entities.Find_Entity_Type (DB, Models.TICKET_TABLE)); Cmt.Save (DB); end if; Entity.Save (DB); Ctx.Commit; end Save; end Jason.Tickets.Modules;
-- -- Monochrome Bitmap Graphics Library -- -- with Interfaces; use Interfaces; with Bitmap_Graphics; use Bitmap_Graphics; generic Width : Natural; Height : Natural; package Bitmap_Buffer is type Content is array ( 0 .. (Width * Height/8) ) of Unsigned_8; type Buffer is record Data : Content; end record; type Buffer_Ref is access all Buffer; -- Set the color for the whole buffer. procedure Set (Buf: Buffer_Ref; Clr: Color); -- Set the color for one point. procedure Set (Buf: Buffer_Ref; P: Point; Clr: Color); -- Draw a point with a color. procedure Dot (Buf:Buffer_Ref; P:Point; Size:Positive:=1; Clr:Color:=White); -- Draw a line from P to Q. procedure Line (Buf:Buffer_Ref; P,Q: Point; Size:Positive:=1; Clr:Color:=White); -- Outline a rectangle P,Q procedure Rectangle (Buf:Buffer_Ref; P,Q: Point; Size:Positive:=1; Clr:Color:=White); procedure Fill_Rectangle (Buf:Buffer_Ref; P,Q: Point; Clr:Color:=White); procedure Circle (Buf:Buffer_Ref; P: Point; R: Natural; Size: Positive:=1; Clr: Color:=White); procedure Fill_Circle (Buf:Buffer_Ref; P: Point; R: Natural; Clr: Color:=White); procedure Put (Buf : Buffer_Ref; P : Point; Ch : Character; Size: Positive; Fgnd: Color:= White; Bgnd: Color:= Black); procedure Put (Buf : Buffer_Ref; P : Point; Str : String; Size: Positive; Fgnd: Color:= White; Bgnd: Color:= Black); procedure Put (Buf : Buffer_Ref; P : Point; Num : Natural; Size: Positive; Fgnd: Color:= White; Bgnd: Color:= Black); procedure Bitmap (Buf : Buffer_Ref; P : Point; Bytes : Byte_Array_Access; Siz : Size); procedure Bitmap (Buf : Buffer_Ref; P : Point; Icon : Bitmap_Icon); end Bitmap_Buffer;
------------------------------------------------------------------------------ -- G N A T C O L L -- -- -- -- Copyright (C) 2009-2019, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- cspell:words GNATCOLL -- This package provides a type useful to manipulate command lines with GNAT.OS_Lib; with GNAT.Strings; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package GNATCOLL.Arg_Lists is type Command_Line_Mode is (Raw_String, Separate_Args); -- There are two ways to treat a command line in GNATCOLL. -- Raw_String: these command lines should never be parsed for arguments -- and processing should be minimal. -- Separate_Args: these command lines need argument handling. type Argument_Mode is (Expandable, One_Arg); -- This type controls the behavior of arguments with respect to expansion. -- Expandable means that this argument can be expanded into multiple -- arguments. -- One_Arg means that this argument will only remain one argument, -- even if it gets expanded to separate space-separated strings. type Arg_List is private; -- A command line. -- This contains one command (an executable, typically) and a list of -- arguments. Empty_Command_Line : constant Arg_List; function Get_Command (C : Arg_List) return String; -- Return the command contained in C function Create (Command : String) return Arg_List; -- Create a command line from command. -- This creates a command line which has Command as a command and -- no arguments. function Argument_List_To_String (List : GNAT.Strings.String_List; Protect_Quotes : Boolean := True) return String; -- Concatenate all the elements in List into a single string. -- Argument_String_To_List (Argument_List_To_String (X)) = X -- The returned string ends with a space. -- If Protect_Quotes is True, then all quotes (single and double) are -- preceded by a backslash. function Parse_String (Text : String; Mode : Command_Line_Mode) return Arg_List; -- Parse Text and return a Arg_List, assuming that Text contains both -- the command and the arguments function Parse_String (Command : String; Text : String) return Arg_List; -- Return a command line, assuming Command contains the command and -- Text contains the arguments procedure Append_Argument (C : in out Arg_List; Argument : String; Mode : Argument_Mode); -- Append Argument to the list of arguments in C function Args_Length (C : Arg_List) return Integer; -- Return the length of the arguments. The command is not included in this -- count. -- Return 0 if there is only a command and no arguments. -- Return -1 if the command is empty. function Nth_Arg (C : Arg_List; N : Natural) return String; -- Return the Nth argument. Nth_Arg (0) returns the command function Nth_Arg (C : Arg_List; N : Natural) return Unbounded_String; -- Return the Nth argument. Nth_Arg (0) returns the command procedure Set_Nth_Arg (C : in out Arg_List; N : Natural; Arg : String); -- Set the Nth arg. -- If there are not enough args, create them. ------------------ -- Substitution -- ------------------ type Substitution_Function is access function (Param : String; Mode : Command_Line_Mode) return Arg_List; -- This type is preserved for backwards compatibility: it used to be the -- type of the Callback formal below. procedure Substitute (CL : in out Arg_List; Char : Character; Callback : access function (Param : String; Mode : Command_Line_Mode) return Arg_List); -- Substitute all parameters that start with Char using the mechanisms -- specified in Callback. function To_List (C : Arg_List; Include_Command : Boolean) return GNAT.OS_Lib.Argument_List; -- Return as an Argument_List: -- - the whole command line if Include_Command is True -- - only the arguments if Include_Command is False -- Caller must free the result. --------------------------- -- Conversions to string -- --------------------------- function To_Display_String (C : Arg_List; Include_Command : Boolean := True; Max_Arg_Length : Positive := Positive'Last) return String; -- Return a string that represents C, for display purposes. -- For instance -- cmd /c make LIBRARY_TYPE=static -- If Include_Command is False, display only the arguments. -- Max_Arg_Length is the maximum length returned for each argument in C. function To_Debug_String (C : Arg_List) return String; -- Return a string that represents C, for display purposes. -- For instance: -- command: "cmd" -- arg: "/c" -- arg: "make LIBRARY_TYPE=static" function To_Script_String (C : Arg_List) return String; -- Return a string that represents C, ready to be sent to a script -- For instance: -- cmd /c make\ LIBRARY_TYPE=static private type Argument_Type is record Mode : Argument_Mode; Text : Unbounded_String; end record; package Arg_List_Vector is new Ada.Containers.Vectors (Natural, Argument_Type); type Arg_List is record Mode : Command_Line_Mode := Separate_Args; V : Arg_List_Vector.Vector; -- The element number 0 is the command, and the following elements are -- arguments. end record; Empty_Command_Line : constant Arg_List := (Mode => Separate_Args, V => Arg_List_Vector.Empty_Vector); end GNATCOLL.Arg_Lists;
----------------------------------------------------------------------- -- package body Spherical_Harmonics. Generates Spherical Harmonics. -- Copyright (C) 2018 Jonathan S. Parker -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --------------------------------------------------------------------------- -- with Clenshaw; with A_Legendre; package body Spherical_Harmonics is subtype Poly_Index is Base_Poly_Index range 0..Poly_Limit; Zero : constant Real := +0.0; One : constant Real := +1.0; package A_Legen is new A_Legendre (Real, Sqrt, Exp, Log, Base_Poly_Index); package Clen is new Clenshaw (Real, Base_Poly_Index, Poly_Limit, A_Legen.Alpha, A_Legen.Beta, A_Legen.Q_0); use Clen; -- -- Some global types: a table of Normalization -- factors, and present settings. -- Norm_Factor_Table : array (Poly_Index) of Real; m_Setting_Of_Table : Base_Poly_Index := Poly_Index'First - 1; Max_k_Of_Table : Base_Poly_Index := Poly_Index'First - 1; ------------------------- -- Make_Table_Of_Norms -- ------------------------- procedure Make_Table_Of_Norms (m : in Real; From_This_k : in Poly_Index; To_That_k : in Poly_Index) is begin for k in From_This_k .. To_That_k loop Norm_Factor_Table (k) := A_Legen.Normalization_Factor (k, m); end loop; end Make_Table_Of_Norms; ------------------- -- X_Lower_Bound -- ------------------- function X_Lower_Bound return Real is begin return A_Legen.X_Lower_Bound; end; ------------------- -- X_Upper_Bound -- ------------------- function X_Upper_Bound return Real is begin return A_Legen.X_Upper_Bound; end; ---------------------- -- Spherical_Harm_2 -- ---------------------- -- This is designed to be best when k changes a lot, and m -- changes rarely. A table of Normalization factors for fixed -- m and varying k is made. -- C0 : constant Coefficients := (others => Zero); -- init. important function Spherical_Harm_2 (l : Base_Poly_Index; m : Real; X : Real; Iterations : Positive := 1) return Real is Int_m : constant Poly_Index := Poly_Index (m); k : constant Poly_Index := l - Int_m; Norm_Factor, Result : Real; Abs_m : constant Real := Abs (m); Real_l : constant Real := +Real (l); C : Coefficients; begin if Abs_m > Real_l then raise Constraint_Error; end if; if Abs X > One then raise Constraint_Error; end if; -- Designed to be efficient when X and k change a lot, and m changes rarely: if Int_m /= m_Setting_Of_Table then Make_Table_Of_Norms (m, From_This_k => Poly_Index'First, To_That_k => k); m_Setting_Of_Table := Int_m; Max_k_Of_Table := k; end if; if k > Max_k_Of_Table then Make_Table_Of_Norms (m, From_This_k => Max_k_Of_Table, To_That_k => k); Max_k_Of_Table := k; end if; Norm_Factor := Norm_Factor_Table (k); C := C0; C(k) := One; Result := Norm_Factor * Sum (X, C, k, Abs_m, Iterations); -- Do have negative m in Spherical Harm., but -- don't have negative m in A_Legendre polys, so use Abs_m. return Result; end Spherical_Harm_2; -------------------- -- Spherical_Harm -- -------------------- -- Uses calls to Evaluate_Q, rather than to Sum. function Spherical_Harm (l : Base_Poly_Index; m : Real; X : Real; Iterations : Positive := 1) return Real is Int_m : constant Poly_Index := Poly_Index (m); k : constant Poly_Index := l - Int_m; Abs_m : constant Real := Abs (m); Real_l : constant Real := +Real (l); Norm_Factor, Result : Real; Q : Poly_Values; begin if Abs_m > Real_l then raise Constraint_Error; end if; if Abs (X) > One then raise Constraint_Error; end if; -- Designed to be efficient when X and k change a lot, and m changes rarely: if Int_m /= m_Setting_Of_Table then Make_Table_Of_Norms (m, From_This_k => Poly_Index'First, To_That_k => k); m_Setting_Of_Table := Int_m; Max_k_Of_Table := k; end if; if k > Max_k_Of_Table then Make_Table_Of_Norms (m, From_This_k => Max_k_Of_Table, To_That_k => k); Max_k_Of_Table := k; end if; Norm_Factor := Norm_Factor_Table (k); Evaluate_Qs (X, Q, k, Abs_m, Iterations); Result := Norm_Factor * Q(k); -- Do have negative m in Spherical Harm., but -- don't have negative m in A_Legendre polys, so use Abs_m. return Result; end Spherical_Harm; ----------------- -- Poly_Weight -- ----------------- function Poly_Weight (X : Real) return Real is begin return A_Legen.Poly_Weight(X); end Poly_Weight; end Spherical_Harmonics;
with Ada.Unchecked_Deallocation; package body Communication is function Communication_Init (Data_Rate : Baud_Code; Name : String) return Serial_Port is Port : Serial_Port; begin Port := new Serial_Port_Inst; Port.Open (Name => Name, Data_Rate => B115200); return Port; end Communication_Init; procedure Free_Serial_Port is new Ada.Unchecked_Deallocation (Object => Serial_Port_Inst, Name => Serial_Port); procedure Communications_Close (Port : in out Serial_Port) is begin Port.Close; Free_Serial_Port (Port); end Communications_Close; procedure Clear_Comm_Buffer (Port : in Serial_Port) is Ret : Integer; PP : Boolean; Buf : UByte_Array (1 .. 256); begin loop PP := Port.Poll (Seconds => 1); exit when PP = False; Ret := Port.Read (Buffer => Buf); end loop; end Clear_Comm_Buffer; procedure Send_Command (Port : in Serial_Port; Rec : in Comm_Rec) is Raw_TX : UByte_Array (1 .. Rec'Size / 8) with Address => Rec'Address; Ret : Integer; begin Ret := Port.Write (Buffer => Raw_TX); end Send_Command; procedure Send_Command (Port : in Serial_Port; Rec : in Comm_Rec; Data : in UByte_Array) is Raw_TX : UByte_Array (1 .. Rec'Size / 8) with Address => Rec'Address; Ret : Integer; begin Ret := Port.Write (Buffer => Raw_TX & Data); end Send_Command; procedure Read_Sensors (Port : in Serial_Port; Buffer : out UByte_Array) is Ret_Poll : Boolean; Ret_Read : Integer; Bytes_Read : Natural := 0; begin loop -- Ret_Poll := Port.Poll; Ret_Read := Port.Read (Buffer => Buffer (Buffer'First + Bytes_Read .. Buffer'Last)); Bytes_Read := Bytes_Read + Ret_Read; exit when Bytes_Read >= Buffer'Length; end loop; end Read_Sensors; procedure Open (Self : in out Serial_Port_Inst; Name : in String; Data_Rate : Baud_Code) is CName : constant String := Name & ASCII.NUL; Name_Addr : constant C_File_Name := CName (CName'First)'Address; Ret_Int : C.Int; Ret_Unsigned : C.Unsigned; Options : aliased Termios; begin Self.Fd := File_Descriptor (C_Open (Pathname => Name_Addr, Flags => C.Int(Self.Flags))); if Self.Fd = Invalid_FD then Raise_Error ("Could not open file."); end if; Ret_Int := C_Tcgetattr (Fildes => C.Int(Self.Fd), Termios_P => Options'Address); if Ret_Int < 0 then Raise_Error ("Could not get tty attr."); end if; Options.C_Cflag := C_Data_Rate (Data_Rate) or System.OS_Constants.CS8 or -- System.OS_Constants.CSTOPB or -- System.OS_Constants.PARENB or System.OS_Constants.CLOCAL or System.OS_Constants.CREAD; Options.C_Lflag := 0; Options.C_Iflag := 0; Options.C_Oflag := 0; Options.C_Ispeed := C_Data_Rate (Data_Rate); Options.C_Ospeed := C_Data_Rate (Data_Rate); -- Minimum number of characters for noncanonical read (MIN). Options.C_CC (System.OS_Constants.VMIN) := Char'Val (0); -- Timeout in deciseconds for noncanonical read (TIME). Options.C_Cc (System.OS_Constants.VTIME) := Char'Val (100); Ret_Int := C_Tcflush (Fd => C.Int (Self.Fd), Queue_Selector => System.OS_Constants.TCIFLUSH); if Ret_Int < 0 then Raise_Error ("Could not flush input."); end if; Ret_Int := C_Tcsetattr (Fildes => C.Int(Self.Fd), Optional_Actions => System.OS_Constants.TCSANOW, Termios_P => Options'Address); if Ret_Int < 0 then Raise_Error ("Could not write configuration to port."); end if; end Open; procedure Close (Self : in out Serial_Port_Inst) is begin GNAT.OS_Lib.Close (FD => Self.Fd); Self.Fd := 0; end Close; function Read (Self : in Serial_Port_Inst; Buffer : out UByte_Array) return Integer is Ret : Integer; begin Ret := GNAT.OS_Lib.Read (FD => Self.Fd, A => Buffer'Address, N => Buffer'Length); if Ret = -1 then Raise_Error ("Read failed."); end if; return Ret; end Read; function Write (Self : in Serial_Port_Inst; Buffer : in UByte_Array) return Integer is Ret : Integer; begin Ret := GNAT.OS_Lib.Write (FD => Self.Fd, A => Buffer'Address, N => Buffer'Length); if Ret = -1 then Raise_Error ("Write failed."); end if; return Ret; end Write; function Poll (Self : in Serial_Port_Inst; Seconds : Natural := 0) return Boolean is Readfds : aliased Fd_Set; Timeout : aliased Timeval := (others => 0); Timeout_Acc : access Timeval := null; Ret : C.int; begin if Seconds > 0 then Timeout.Tv_Sec := C.Int (Seconds); Timeout_Acc := Timeout'Access; end if; loop Readfds := 2 ** Natural (Self.Fd); Ret := C_Select (Nfds => C.Int(Self.Fd) + 1, Readfds => Readfds'Access, Writefds => null, Exceptfds => null, Timeout => Timeout_Acc); exit when Ret >= 0; end loop; if Ret = 0 then return False; end if; return True; end Poll; Serial_Error : exception; procedure Raise_Error (Message : String; Error : Integer := Errno) is begin raise Serial_Error with Message & (if Error /= 0 then " (" & Errno_Message (Err => Error) & ')' else ""); end Raise_Error; end Communication;
with Buggy_Package; procedure Buggy_Package_Demo is function Func_INTEGER is new Buggy_Package.Func_INT( INTEGER ); procedure Proc_INTEGER is new Buggy_Package.Proc_INT( INTEGER ); begin NULL; end Buggy_Package_Demo;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT INTERFACE COMPONENTS -- -- -- -- A S I S . I T E R A T O R -- -- -- -- S p e c -- -- -- -- Copyright (c) 2006, Free Software Foundation, Inc. -- -- -- -- This specification is adapted from the Ada Semantic Interface -- -- Specification Standard (ISO/IEC 15291) for use with GNAT. In accordance -- -- with the copyright of that document, you can freely copy and modify this -- -- specification, provided that if you redistribute a modified version, any -- -- changes that you have made are clearly indicated. The copyright notice -- -- above, and the license provisions that follow apply solely to the -- -- contents of the part following the private keyword. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 14 package Asis.Iterator ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Asis.Iterator is ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Asis.Iterator encapsulates the generic procedure Traverse_Element which -- allows an ASIS application to perform an iterative traversal of a -- logical syntax tree. It requires the use of two generic procedures, -- Pre_Operation, which identifies processing for the traversal, and -- Post_Operation, which identifies processing after the traversal. -- The State_Information allows processing state to be passed during the -- iteration of Traverse_Element. -- -- Package Asis.Iterator is established as a child package to highlight the -- iteration capability and to facilitate the translation of ASIS to IDL. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 14.1 procedure Traverse_Element ------------------------------------------------------------------------------ generic type State_Information is limited private; with procedure Pre_Operation (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information) is <>; with procedure Post_Operation (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information) is <>; procedure Traverse_Element (Element : Asis.Element; Control : in out Traverse_Control; State : in out State_Information); ------------------------------------------------------------------------------ -- Element - Specifies the initial element in the traversal -- Control - Specifies what next to do with the traversal -- State_Information - Specifies other information for the traversal -- -- Traverses the element and all its component elements, if any. -- Component elements are all elements that can be obtained by a combination -- of the ASIS structural queries appropriate for the given element. -- -- If an element has one or more component elements, each is called a child -- element. An element's parent element is its Enclosing_Element. Children -- with the same parent are sibling elements. The type Traverse_Control uses -- the terms children and siblings to control the traverse. -- -- For each element, the formal procedure Pre_Operation is called when first -- visiting the element. Each of that element's children are then visited -- and finally the formal procedure Post_Operation is called for the element. -- -- The order of Element traversal is in terms of the textual representation of -- the Elements. Elements are traversed in left-to-right and top-to-bottom -- order. -- -- Traversal of Implicit Elements: -- -- Implicit elements are not traversed by default. However, they may be -- explicitly queried and then passed to the traversal instance. Implicit -- elements include implicit predefined operator declarations, implicit -- inherited subprogram declarations, implicit expanded generic specifications -- and bodies, default expressions supplied to procedure, function, and entry -- calls, etc. -- -- Applications that wish to traverse these implicit Elements shall query for -- them at the appropriate places in a traversal and then recursively call -- their instantiation of the traversal generic. (Implicit elements provided -- by ASIS do not cover all possible Ada implicit constructs. For example, -- implicit initializations for variables of an access type are not provided -- by ASIS.) -- -- Traversal of Association lists: -- -- Argument and association lists for procedure calls, function calls, entry -- calls, generic instantiations, and aggregates are traversed in their -- unnormalized forms, as if the Normalized parameter was False for those -- queries. Implementations that always normalize certain associations may -- return Is_Normalized associations. See the Implementation Permissions -- for the queries Discriminant_Associations, Generic_Actual_Part, -- Call_Statement_Parameters, Record_Component_Associations, or -- Function_Call_Parameters. -- -- Applications that wish to explicitly traverse normalized associations can -- do so by querying the appropriate locations in order to obtain the -- normalized list. The list can then be traversed by recursively calling -- the traverse instance. Once that sub-traversal is finished, the Control -- parameter can be set to Abandon_Children to skip processing of the -- unnormalized argument list. -- -- Traversal can be controlled with the Control parameter. -- -- A call to an instance of Traverse_Element will not result in calls to -- Pre_Operation or Post_Operation unless Control is set to Continue. -- -- The subprograms matching Pre_Operation and Post_Operation can set -- their Control parameter to affect the traverse: -- -- Continue -- Continues the normal depth-first traversal. -- -- Abandon_Children -- Prevents traversal of the current element's -- -- children. -- -- If set in a Pre_Operation, traversal picks up -- -- with the next sibling element of the current -- -- element. -- -- If set in a Post_Operation, this is the -- -- same as Continue, all children will already -- -- have been traversed. Traversal picks up with -- -- the Post_Operation of the parent. -- -- Abandon_Siblings -- Prevents traversal of the current element's -- -- children and remaining siblings. -- -- If set in a Pre_Operation, this abandons the -- -- associated Post_Operation for the current -- -- element. Traversal picks up with the -- -- Post_Operation of the parent. -- -- If set in a Post_Operation, traversal picks -- -- up with the Post_Operation of the parent. -- -- Terminate_Immediately -- Does exactly that. -- -- Raises ASIS_Inappropriate_Element if the element is a Nil_Element ------------------------------------------------------------------------------ end Asis.Iterator;
-- This spec has been automatically generated from STM32F0xx.svd -- Definition of the device's interrupts package STM32_SVD.Interrupts is ---------------- -- Interrupts -- ---------------- -- Window Watchdog interrupt WWDG : constant := 0; -- PVD through EXTI line detection PVD : constant := 1; -- RTC global interrupt RTC : constant := 2; -- Flash global interrupt FLASH : constant := 3; -- RCC global interrupt RCC : constant := 4; -- EXTI Line[1:0] interrupts EXTI0_1 : constant := 5; -- EXTI Line[3:2] interrupts EXTI2_3 : constant := 6; -- EXTI Line15 and EXTI4 interrupts EXTI4_15 : constant := 7; -- Touch sensing interrupt TSC : constant := 8; -- DMA channel 1 interrupt DMA_CH1 : constant := 9; -- DMA channel 2 and 3 interrupts DMA_CH2_3 : constant := 10; -- DMA channel 4 and 5 interrupts DMA_CH4_5 : constant := 11; -- ADC and comparator 1 and 2 ADC_COMP : constant := 12; -- TIM1 Break, update, trigger and TIM1_BRK_UP : constant := 13; -- TIM1 Capture Compare interrupt TIM1_CC : constant := 14; -- TIM2 global interrupt TIM2 : constant := 15; -- TIM3 global interrupt TIM3 : constant := 16; -- TIM6 global interrupt and DAC TIM6_DAC : constant := 17; -- TIM14 global interrupt TIM14 : constant := 19; -- TIM15 global interrupt TIM15 : constant := 20; -- TIM16 global interrupt TIM16 : constant := 21; -- TIM17 global interrupt TIM17 : constant := 22; -- I2C1 global interrupt I2C1 : constant := 23; -- I2C2 global interrupt I2C2 : constant := 24; -- SPI1_global_interrupt SPI1 : constant := 25; -- SPI2 global interrupt SPI2 : constant := 26; -- USART1 global interrupt USART1 : constant := 27; -- USART2 global interrupt USART2 : constant := 28; -- CEC global interrupt CEC : constant := 30; end STM32_SVD.Interrupts;
----------------------------------------------------------------------- -- util-commands -- Support to make command line tools -- Copyright (C) 2017, 2018, 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. ----------------------------------------------------------------------- private with Util.Strings.Vectors; private with Ada.Strings.Unbounded; -- = Command Line Utilities = -- The `Util.Commands` package provides a support to help in writing command line -- applications. It allows to have several commands in the application, each of them -- being identified by a unique name. Each command has its own options and arguments. -- The command line support is built arround several children packages. -- -- The `Util.Commands.Drivers` package is a generic package that must be instantiated -- to define the list of commands that the application supports. It provides operations -- to register commands and then to execute them with a list of arguments. When a -- command is executed, it gets its name, the command arguments and an application -- context. The application context can be used to provide arbitrary information that -- is needed by the application. -- -- The `Util.Commands.Parsers` package provides the support to parse the command -- line arguments. -- -- The `Util.Commands.Consoles` package is a generic package that can help for the -- implementation of a command to display its results. Its use is optional. -- -- == Command arguments == -- The `Argument_List` interface defines a common interface to get access to the command -- line arguments. It has several concrete implementations. This is the interface type -- that is used by commands registered and executed in the driver. -- -- The `Default_Argument_List` gives access to the program command line arguments through -- the `Ada.Command_Line` package. -- -- The `String_Argument_List` allows to split a string into a list of arguments. It can -- be used to build new command line arguments. -- -- @include util-commands-drivers.ads -- @include util-commands-parsers.ads -- -- == Example == -- First, an application context type is defined to allow a command to get some application -- specific information. The context type is passed during the instantiation of the -- `Util.Commands.Drivers` package and will be passed to commands through the `Execute` -- procedure. -- -- type Context_Type is limited record -- ... -- Some application specific data -- end record; -- -- package Drivers is -- new Util.Commands.Drivers -- (Context_Type => Context_Type, -- Config_Parser => Util.Commands.Parsers.GNAT_Parser.Config_Parser, -- Driver_Name => "tool"); -- -- Then an instance of the command driver must be declared. Commands are then registered -- to the command driver so that it is able to find them and execute them. -- -- Driver : Drivers.Driver_Type; -- -- A command can be implemented by a simple procedure or by using the `Command_Type` -- abstract tagged record and implementing the `Execute` procedure: -- -- procedure Command_1 (Name : in String; -- Args : in Argument_List'Class; -- Context : in out Context_Type); -- -- type My_Command is new Drivers.Command_Type with null record; -- procedure Execute (Command : in out My_Command; -- Name : in String; -- Args : in Argument_List'Class; -- Context : in out Context_Type); -- -- Commands are registered during the application initialization. -- And registered in the driver by using the `Add_Command` procedure: -- -- Driver.Add_Command (Name => "cmd1", -- Description => "", -- Handler => Command_1'Access); -- -- A command is executed by giving its name and a list of arguments. By using the -- `Default_Argument_List` type, it is possible to give to the command the application -- command line arguments. -- -- Ctx : Context_Type; -- Args : Util.Commands.Default_Argument_List (0); -- ... -- Driver.Execute ("cmd1", Args, Ctx); -- package Util.Commands is -- Exception raised when a command was not found. Not_Found : exception; -- The argument list interface that gives access to command arguments. type Argument_List is limited interface; -- Get the number of arguments available. function Get_Count (List : in Argument_List) return Natural is abstract; -- Get the argument at the given position. function Get_Argument (List : in Argument_List; Pos : in Positive) return String is abstract; -- Get the command name. function Get_Command_Name (List : in Argument_List) return String is abstract; type Default_Argument_List (Offset : Natural) is new Argument_List with null record; -- Get the number of arguments available. overriding function Get_Count (List : in Default_Argument_List) return Natural; -- Get the argument at the given position. overriding function Get_Argument (List : in Default_Argument_List; Pos : in Positive) return String; -- Get the command name. function Get_Command_Name (List : in Default_Argument_List) return String; type String_Argument_List (Max_Length : Positive; Max_Args : Positive) is new Argument_List with private; -- Set the argument list to the given string and split the arguments. procedure Initialize (List : in out String_Argument_List; Line : in String); -- Get the number of arguments available. overriding function Get_Count (List : in String_Argument_List) return Natural; -- Get the argument at the given position. overriding function Get_Argument (List : in String_Argument_List; Pos : in Positive) return String; -- Get the command name. overriding function Get_Command_Name (List : in String_Argument_List) return String; -- The argument list interface that gives access to command arguments. type Dynamic_Argument_List is limited new Argument_List with private; -- Get the number of arguments available. function Get_Count (List : in Dynamic_Argument_List) return Natural; -- Get the argument at the given position. function Get_Argument (List : in Dynamic_Argument_List; Pos : in Positive) return String; -- Get the command name. function Get_Command_Name (List : in Dynamic_Argument_List) return String; function No_Translate (Message : in String) return String is (Message) with Inline; private type Argument_Pos is array (Natural range <>) of Natural; type String_Argument_List (Max_Length : Positive; Max_Args : Positive) is new Argument_List with record Count : Natural := 0; Length : Natural := 0; Line : String (1 .. Max_Length); Start_Pos : Argument_Pos (0 .. Max_Args) := (others => 0); End_Pos : Argument_Pos (0 .. Max_Args) := (others => 0); end record; type Dynamic_Argument_List is limited new Argument_List with record List : Util.Strings.Vectors.Vector; Name : Ada.Strings.Unbounded.Unbounded_String; end record; end Util.Commands;
-------------------------------------------------------- -- E n c o d i n g s -- -- -- -- Tools for convertion strings between Unicode and -- -- national/vendor character sets. -- -- - - - - - - - - - -- -- Read copyright and license at the end of this file -- -------------------------------------------------------- -- This unit points to encodings linked into executable -- Add here required encodings -- If encoding isn't linked it will be read from text -- file in run time (if Encodings.Maps.Runtime linked). -- Otherwite encoding isn't available. with Encodings.Maps.Utf_8; -- with Encodings.Maps.Runtime; -- with Encodings.Maps.ISO_8859_1; -- with Encodings.Maps.ISO_8859_2; -- with Encodings.Maps.ISO_8859_3; -- with Encodings.Maps.ISO_8859_4; -- with Encodings.Maps.ISO_8859_5; -- with Encodings.Maps.ISO_8859_6; -- with Encodings.Maps.ISO_8859_7; -- with Encodings.Maps.ISO_8859_8; -- with Encodings.Maps.ISO_8859_9; -- with Encodings.Maps.ISO_8859_10; -- with Encodings.Maps.ISO_8859_11; -- with Encodings.Maps.ISO_8859_13; -- with Encodings.Maps.ISO_8859_14; -- with Encodings.Maps.ISO_8859_15; -- with Encodings.Maps.ISO_8859_16; -- with Encodings.Maps.CP_037; -- with Encodings.Maps.CP_424; -- with Encodings.Maps.CP_437; -- with Encodings.Maps.CP_500; -- with Encodings.Maps.CP_737; -- with Encodings.Maps.CP_775; -- with Encodings.Maps.CP_850; -- with Encodings.Maps.CP_852; -- with Encodings.Maps.CP_855; -- with Encodings.Maps.CP_856; -- with Encodings.Maps.CP_857; -- with Encodings.Maps.CP_860; -- with Encodings.Maps.CP_861; -- with Encodings.Maps.CP_862; -- with Encodings.Maps.CP_863; -- with Encodings.Maps.CP_864; -- with Encodings.Maps.CP_865; -- with Encodings.Maps.CP_866; -- with Encodings.Maps.CP_869; -- with Encodings.Maps.CP_874; -- with Encodings.Maps.CP_875; -- with Encodings.Maps.CP_1006; -- with Encodings.Maps.CP_1026; -- with Encodings.Maps.CP_1250; -- with Encodings.Maps.CP_1251; -- with Encodings.Maps.CP_1252; -- with Encodings.Maps.CP_1253; -- with Encodings.Maps.CP_1254; -- with Encodings.Maps.CP_1255; -- with Encodings.Maps.CP_1256; -- with Encodings.Maps.CP_1257; -- with Encodings.Maps.CP_1258; -- with Encodings.Maps.AtariST; -- with Encodings.Maps.KOI8_R; package Encodings.Maps.Linked is end Encodings.Maps.Linked; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, Maxim Reznik -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- O S I N T -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2005 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the low level, operating system routines used in -- the GNAT compiler and binder for command line processing and file input -- output. with GNAT.OS_Lib; use GNAT.OS_Lib; with System; use System; with Types; use Types; pragma Elaborate (GNAT.OS_Lib); package Osint is Multi_Unit_Index_Character : Character := '~'; -- The character before the index of the unit in a multi-unit source, -- in ALI and object file names. This is not a constant, because it is -- changed to '$' on VMS. Ada_Include_Path : constant String := "ADA_INCLUDE_PATH"; Ada_Objects_Path : constant String := "ADA_OBJECTS_PATH"; Project_Include_Path_File : constant String := "ADA_PRJ_INCLUDE_FILE"; Project_Objects_Path_File : constant String := "ADA_PRJ_OBJECTS_FILE"; procedure Initialize; -- Initialize internal tables function Normalize_Directory_Name (Directory : String) return String_Ptr; -- Verify and normalize a directory name. If directory name is invalid, -- this will return an empty string. Otherwise it will insure a trailing -- slash and make other normalizations. type File_Type is (Source, Library, Config, Definition, Preprocessing_Data); function Find_File (N : File_Name_Type; T : File_Type) return File_Name_Type; -- Finds a source, library or config file depending on the value -- of T following the directory search order rules unless N is the -- name of the file just read with Next_Main_File and already -- contains directiory information, in which case just look in the -- Primary_Directory. Returns File_Name_Type of the full file name -- if found, No_File if file not found. Note that for the special -- case of gnat.adc, only the compilation environment directory is -- searched, i.e. the directory where the ali and object files are -- written. Another special case is when Debug_Generated_Code is -- set and the file name ends on ".dg", in which case we look for -- the generated file only in the current directory, since that is -- where it is always built. function Get_File_Names_Case_Sensitive return Int; pragma Import (C, Get_File_Names_Case_Sensitive, "__gnat_get_file_names_case_sensitive"); File_Names_Case_Sensitive : constant Boolean := Get_File_Names_Case_Sensitive /= 0; -- Set to indicate whether the operating system convention is for file -- names to be case sensitive (e.g., in Unix, set True), or non case -- sensitive (e.g., in OS/2, set False). procedure Canonical_Case_File_Name (S : in out String); -- Given a file name, converts it to canonical case form. For systems -- where file names are case sensitive, this procedure has no effect. -- If file names are not case sensitive (i.e. for example if you have -- the file "xyz.adb", you can refer to it as XYZ.adb or XyZ.AdB), then -- this call converts the given string to canonical all lower case form, -- so that two file names compare equal if they refer to the same file. function Number_Of_Files return Int; -- Gives the total number of filenames found on the command line No_Index : constant := -1; -- Value used in Add_File to indicate no index is specified for main procedure Add_File (File_Name : String; Index : Int := No_Index); -- Called by the subprogram processing the command line for each file name -- found. The index, when not defaulted to No_Index is the index of the -- subprogram in its source, zero indicating that the source is not -- multi-unit. procedure Find_Program_Name; -- Put simple name of current program being run (excluding the directory -- path) in Name_Buffer, with the length in Name_Len. function Program_Name (Nam : String) return String_Access; -- In the native compilation case, Create a string containing Nam. In the -- cross compilation case, looks at the prefix of the current program being -- run and prepend it to Nam. For instance if the program being run is -- <target>-gnatmake and Nam is "gcc", the returned value will be a pointer -- to "<target>-gcc". This function clobbers Name_Buffer and Name_Len. procedure Write_Program_Name; -- Writes name of program as invoked to the current output -- (normally standard output). procedure Fail (S1 : String; S2 : String := ""; S3 : String := ""); pragma No_Return (Fail); -- Outputs error messages S1 & S2 & S3 preceded by the name of the -- executing program and exits with E_Fatal. The output goes to standard -- error, except if special output is in effect (see Output). function Is_Directory_Separator (C : Character) return Boolean; -- Returns True if C is a directory separator function Get_Directory (Name : File_Name_Type) return File_Name_Type; -- Get the prefix directory name (if any) from Name. The last separator -- is preserved. Return the normalized current directory if there is no -- directory part in the name. function Is_Readonly_Library (File : File_Name_Type) return Boolean; -- Check if this library file is a read-only file function Strip_Directory (Name : File_Name_Type) return File_Name_Type; -- Strips the prefix directory name (if any) from Name. Returns the -- stripped name. Name cannot end with a directory separator. function Strip_Suffix (Name : File_Name_Type) return File_Name_Type; -- Strips the suffix (the last '.' and whatever comes after it) from Name. -- Returns the stripped name. function Executable_Name (Name : File_Name_Type) return File_Name_Type; -- Given a file name it adds the appropriate suffix at the end so that -- it becomes the name of the executable on the system at end. For -- instance under DOS it adds the ".exe" suffix, whereas under UNIX no -- suffix is added. function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type; -- Returns the time stamp of file Name. Name should include relative -- path information in order to locate it. If the source file cannot be -- opened, or Name = No_File, and all blank time stamp is returned (this is -- not an error situation). type String_Access_List is array (Positive range <>) of String_Access; -- Deferenced type used to return a list of file specs in -- To_Canonical_File_List. type String_Access_List_Access is access all String_Access_List; -- Type used to return a String_Access_List without dragging in secondary -- stack. function To_Canonical_File_List (Wildcard_Host_File : String; Only_Dirs : Boolean) return String_Access_List_Access; -- Expand a wildcard host syntax file or directory specification (e.g. on -- a VMS host, any file or directory spec that contains: -- "*", or "%", or "...") -- and return a list of valid Unix syntax file or directory specs. -- If Only_Dirs is True, then only return directories. function To_Canonical_Dir_Spec (Host_Dir : String; Prefix_Style : Boolean) return String_Access; -- Convert a host syntax directory specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]") to canonical (Unix) syntax (e.g. "/sys$device/dir"). -- If Prefix_Style then make it a valid file specification prefix. A file -- specification prefix is a directory specification that can be appended -- with a simple file specification to yield a valid absolute or relative -- path to a file. On a conversion to Unix syntax this simply means the -- spec has a trailing slash ("/"). function To_Canonical_File_Spec (Host_File : String) return String_Access; -- Convert a host syntax file specification (e.g. on a VMS host: -- "SYS$DEVICE:[DIR]FILE.EXT;69 to canonical (Unix) syntax (e.g. -- "/sys$device/dir/file.ext.69"). function To_Canonical_Path_Spec (Host_Path : String) return String_Access; -- Convert a host syntax Path specification (e.g. on a VMS host: -- "SYS$DEVICE:[BAR],DISK$USER:[FOO] to canonical (Unix) syntax (e.g. -- "/sys$device/foo:disk$user/foo"). function To_Host_Dir_Spec (Canonical_Dir : String; Prefix_Style : Boolean) return String_Access; -- Convert a canonical syntax directory specification to host syntax. -- The Prefix_Style flag is currently ignored but should be set to -- False. function To_Host_File_Spec (Canonical_File : String) return String_Access; -- Convert a canonical syntax file specification to host syntax function Relocate_Path (Prefix : String; Path : String) return String_Ptr; -- Given an absolute path and a prefix, if Path starts with Prefix, -- replace the Prefix substring with the root installation directory. -- By default, try to compute the root installation directory by looking -- at the executable name as it was typed on the command line and, if -- needed, use the PATH environment variable. If the above computation -- fails, return Path. This function assumes Prefix'First = Path'First. function Shared_Lib (Name : String) return String; -- Returns the runtime shared library in the form -l<name>-<version> where -- version is the GNAT runtime library option for the platform. For example -- this routine called with Name set to "gnat" will return "-lgnat-5.02" -- on UNIX and Windows and -lgnat_5_02 on VMS. ------------------------- -- Search Dir Routines -- ------------------------- function Include_Dir_Default_Prefix return String; -- Return the directory of the run-time library sources, as modified -- by update_path. function Object_Dir_Default_Prefix return String; -- Return the directory of the run-time library ALI and object files, as -- modified by update_path. procedure Add_Default_Search_Dirs; -- This routine adds the default search dirs indicated by the -- environment variables and sdefault package. procedure Add_Lib_Search_Dir (Dir : String); -- Add Dir at the end of the library file search path procedure Add_Src_Search_Dir (Dir : String); -- Add Dir at the end of the source file search path procedure Get_Next_Dir_In_Path_Init (Search_Path : String_Access); function Get_Next_Dir_In_Path (Search_Path : String_Access) return String_Access; -- These subprograms are used to parse out the directory names in a -- search path specified by a Search_Path argument. The procedure -- initializes an internal pointer to point to the initial directory -- name, and calls to the function return successive directory names, -- with a null pointer marking the end of the list. type Search_File_Type is (Include, Objects); procedure Add_Search_Dirs (Search_Path : String_Ptr; Path_Type : Search_File_Type); -- These procedure adds all the search directories that are in Search_Path -- in the proper file search path (library or source) function Get_Primary_Src_Search_Directory return String_Ptr; -- Retrieved the primary directory (directory containing the main source -- file for Gnatmake. function Nb_Dir_In_Src_Search_Path return Natural; function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr; -- Functions to access the directory names in the source search path function Nb_Dir_In_Obj_Search_Path return Natural; function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr; -- Functions to access the directory names in the Object search path Include_Search_File : constant String_Access := new String'("ada_source_path"); Objects_Search_File : constant String_Access := new String'("ada_object_path"); -- Names of the files containg the default include or objects search -- directories. These files, located in Sdefault.Search_Dir_Prefix, do -- not necessarily exist. Exec_Name : String_Ptr; -- Executable name as typed by the user (used to compute the -- executable prefix). function Read_Default_Search_Dirs (Search_Dir_Prefix : String_Access; Search_File : String_Access; Search_Dir_Default_Name : String_Access) return String_Access; -- Read and return the default search directories from the file located -- in Search_Dir_Prefix (as modified by update_path) and named Search_File. -- If no such file exists or an error occurs then instead return the -- Search_Dir_Default_Name (as modified by update_path). function Get_RTS_Search_Dir (Search_Dir : String; File_Type : Search_File_Type) return String_Ptr; -- This function retrieves the paths to the search (resp. lib) dirs and -- return them. The search dir can be absolute or relative. If the search -- dir contains Include_Search_File (resp. Object_Search_File), then this -- function reads and returns the default search directories from the file. -- Otherwise, if the directory is absolute, it will try to find 'adalib' -- (resp. 'adainclude'). If found, null is returned. If the directory is -- relative, the following directories for the directories 'adalib' and -- 'adainclude' will be scanned: -- -- - current directory (from which the tool has been spawned) -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/ -- - $GNAT_ROOT/gcc/gcc-lib/$targ/$vers/rts- -- -- The scan will stop as soon as the directory being searched for (adalib -- or adainclude) is found. If the scan fails, null is returned. ----------------------- -- Source File Input -- ----------------------- -- Source file input routines are used by the compiler to read the main -- source files and the subsidiary source files (e.g. with'ed units), and -- also by the binder to check presence/time stamps of sources. procedure Read_Source_File (N : File_Name_Type; Lo : Source_Ptr; Hi : out Source_Ptr; Src : out Source_Buffer_Ptr; T : File_Type := Source); -- Allocates a Source_Buffer of appropriate length and then reads the -- entire contents of the source file N into the buffer. The address of -- the allocated buffer is returned in Src. -- -- Each line of text is terminated by one of the sequences: -- -- CR -- CR/LF -- LF/CR -- LF -- The source is terminated by an EOF (16#1A#) character, which is -- the last charcater of the returned source bufer (note that any -- EOF characters in positions other than the last source character -- are treated as representing blanks). -- -- The logical lower bound of the source buffer is the input value of Lo, -- and on exit Hi is set to the logical upper bound of the source buffer. -- Note that the returned value in Src points to an array with a physical -- lower bound of zero. This virtual origin addressing approach means that -- a constrained array pointer can be used with a low bound of zero which -- results in more efficient code. -- -- If the given file cannot be opened, then the action depends on whether -- this file is the current main unit (i.e. its name matches the name -- returned by the most recent call to Next_Main_Source). If so, then the -- failure to find the file is a fatal error, an error message is output, -- and program execution is terminated. Otherwise (for the case of a -- subsidiary source loaded directly or indirectly using with), a file -- not found condition causes null to be set as the result value. -- -- Note that the name passed to this function is the simple file name, -- without any directory information. The implementation is responsible -- for searching for the file in the appropriate directories. -- -- Note the special case that if the file name is gnat.adc, then the -- search for the file is done ONLY in the directory corresponding to -- the current compilation environment, i.e. in the same directory -- where the ali and object files will be written. function Full_Source_Name return File_Name_Type; function Current_Source_File_Stamp return Time_Stamp_Type; -- Returns the full name/time stamp of the source file most recently read -- using Read_Source_File. Calling this routine entails no source file -- directory lookup penalty. function Full_Source_Name (N : File_Name_Type) return File_Name_Type; function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type; -- Returns the full name/time stamp of the source file whose simple name -- is N which should not include path information. Note that if the file -- cannot be located No_File is returned for the first routine and an -- all blank time stamp is returned for the second (this is not an error -- situation). The full name includes the appropriate directory -- information. The source file directory lookup penalty is incurred -- every single time the routines are called unless you have previously -- called Source_File_Data (Cache => True). See below. function Current_File_Index return Int; -- Return the index in its source file of the current main unit function Matching_Full_Source_Name (N : File_Name_Type; T : Time_Stamp_Type) return File_Name_Type; -- Same semantics than Full_Source_Name but will search on the source -- path until a source file with time stamp matching T is found. If -- none is found returns No_File. procedure Source_File_Data (Cache : Boolean); -- By default source file data (full source file name and time stamp) -- are looked up every time a call to Full_Source_Name (N) or -- Source_File_Stamp (N) is made. This may be undesirable in certain -- applications as this is uselessly slow if source file data does not -- change during program execution. When this procedure is called with -- Cache => True access to source file data does not encurr a penalty if -- this data was previously retrieved. ------------------------------------------- -- Representation of Library Information -- ------------------------------------------- -- Associated with each compiled source file is library information, -- a string of bytes whose exact format is described in the body of -- Lib.Writ. Compiling a source file generates this library information -- for the compiled unit, and access the library information for units -- that were compiled previously on which the unit being compiled depends. -- How this information is stored is up to the implementation of this -- package. At the interface level, this information is simply associated -- with its corresponding source. -- Several different implementations are possible: -- 1. The information could be directly associated with the source file, -- e.g. placed in a resource fork of this file on the Mac, or on -- MS-DOS, written to the source file after the end of file mark. -- 2. The information could be written into the generated object module -- if the system supports the inclusion of arbitrary informational -- byte streams into object files. In this case there must be a naming -- convention that allows object files to be located given the name of -- the corresponding source file. -- 3. The information could be written to a separate file, whose name is -- related to the name of the source file by a fixed convention. -- Which of these three methods is chosen depends on the constraints of the -- host operating system. The interface described here is independent of -- which of these approaches is used. ------------------------------- -- Library Information Input -- ------------------------------- -- These subprograms are used by the binder to read library information -- files, see section above for representation of these files. function Read_Library_Info (Lib_File : File_Name_Type; Fatal_Err : Boolean := False) return Text_Buffer_Ptr; -- Allocates a Text_Buffer of appropriate length and reads in the entire -- source of the library information from the library information file -- whose name is given by the parameter Name. -- -- See description of Read_Source_File for details on the format of the -- returned text buffer (the format is identical). THe lower bound of -- the Text_Buffer is always zero -- -- If the specified file cannot be opened, then the action depends on -- Fatal_Err. If Fatal_Err is True, an error message is given and the -- compilation is abandoned. Otherwise if Fatal_Err is False, then null -- is returned. Note that the Lib_File is a simple name which does not -- include any directory information. The implementation is responsible -- for searching for the file in appropriate directories. -- -- If Opt.Check_Object_Consistency is set to True then this routine -- checks whether the object file corresponding to the Lib_File is -- consistent with it. The object file is inconsistent if the object -- does not exist or if it has an older time stamp than Lib_File. -- This check is not performed when the Lib_File is "locked" (i.e. -- read/only) because in this case the object file may be buried -- in a library. In case of inconsistencies Read_Library_Info -- behaves as if it did not find Lib_File (namely if Fatal_Err is -- False, null is returned). function Full_Library_Info_Name return File_Name_Type; function Full_Object_File_Name return File_Name_Type; -- Returns the full name of the library/object file most recently read -- using Read_Library_Info, including appropriate directory information. -- Calling this routine entails no library file directory lookup -- penalty. Note that the object file corresponding to a library file -- is not actually read. Its time stamp is fected when the flag -- Opt.Check_Object_Consistency is set. function Current_Library_File_Stamp return Time_Stamp_Type; function Current_Object_File_Stamp return Time_Stamp_Type; -- The time stamps of the files returned by the previous two routines. -- It is an error to call Current_Object_File_Stamp if -- Opt.Check_Object_Consistency is set to False. function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type; function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type; -- Returns the full name/time stamp of library file N. N should not -- include path information. Note that if the file cannot be located -- No_File is returned for the first routine and an all blank time stamp -- is returned for the second (this is not an error situation). The -- full name includes the appropriate directory information. The library -- file directory lookup penalty is incurred every single time this -- routine is called. function Lib_File_Name (Source_File : File_Name_Type; Munit_Index : Nat := 0) return File_Name_Type; -- Given the name of a source file, returns the name of the corresponding -- library information file. This may be the name of the object file, or -- of a separate file used to store the library information. In either case -- the returned result is suitable for use in a call to Read_Library_Info. -- The Munit_Index is the unit index in multiple unit per file mode, or -- zero in normal single unit per file mode (used to add ~nnn suffix). -- Note: this subprogram is in this section because it is used by the -- compiler to determine the proper library information names to be placed -- in the generated library information file. ----------------- -- Termination -- ----------------- type Exit_Code_Type is ( E_Success, -- No warnings or errors E_Warnings, -- Compiler warnings generated E_No_Code, -- No code generated E_No_Compile, -- Compilation not needed (smart recompilation) E_Errors, -- Compiler error messages generated E_Fatal, -- Fatal (serious) error, e.g. source file not found E_Abort); -- Internally detected compiler error procedure Exit_Program (Exit_Code : Exit_Code_Type); pragma No_Return (Exit_Program); -- A call to Exit_Program terminates execution with the given status. -- A status of zero indicates normal completion, a non-zero status -- indicates abnormal termination. ------------------------- -- Command Line Access -- ------------------------- -- Direct interface to command line parameters. (We don't want to use -- the predefined command line package because it defines functions -- returning string) function Arg_Count return Natural; pragma Import (C, Arg_Count, "__gnat_arg_count"); -- Get number of arguments (note: optional globbing may be enabled) procedure Fill_Arg (A : System.Address; Arg_Num : Integer); pragma Import (C, Fill_Arg, "__gnat_fill_arg"); -- Store one argument function Len_Arg (Arg_Num : Integer) return Integer; pragma Import (C, Len_Arg, "__gnat_len_arg"); -- Get length of argument private ALI_Suffix : constant String_Ptr := new String'("ali"); -- The suffix used for the library files (also known as ALI files) Current_Main : File_Name_Type := No_File; -- Used to save a simple file name between calls to Next_Main_Source and -- Read_Source_File. If the file name argument to Read_Source_File is -- No_File, that indicates that the file whose name was returned by the -- last call to Next_Main_Source (and stored here) is to be read. Target_Object_Suffix : constant String := Get_Target_Object_Suffix.all; -- The suffix used for the target object files Output_FD : File_Descriptor; -- The file descriptor for the current library info, tree or binder output Output_File_Name : File_Name_Type; -- File_Name_Type for name of open file whose FD is in Output_FD, the name -- stored does not include the trailing NUL character. Argument_Count : constant Integer := Arg_Count - 1; -- Number of arguments (excluding program name) type File_Name_Array is array (Int range <>) of String_Ptr; type File_Name_Array_Ptr is access File_Name_Array; File_Names : File_Name_Array_Ptr := new File_Name_Array (1 .. Int (Argument_Count) + 2); -- As arguments are scanned, file names are stored in this array -- The strings do not have terminating NUL files. The array is -- extensible, because when using project files, there may be -- more files than arguments on the command line. type File_Index_Array is array (Int range <>) of Int; type File_Index_Array_Ptr is access File_Index_Array; File_Indexes : File_Index_Array_Ptr := new File_Index_Array (1 .. Int (Argument_Count) + 2); Current_File_Name_Index : Int := 0; -- The index in File_Names of the last file opened by Next_Main_Source -- or Next_Main_Lib_File. The value 0 indicates that no files have been -- opened yet. procedure Create_File_And_Check (Fdesc : out File_Descriptor; Fmode : Mode); -- Create file whose name (NUL terminated) is in Name_Buffer (with the -- length in Name_Len), and place the resulting descriptor in Fdesc. -- Issue message and exit with fatal error if file cannot be created. -- The Fmode parameter is set to either Text or Binary (see description -- of GNAT.OS_Lib.Create_File). type Program_Type is (Compiler, Binder, Make, Gnatls, Unspecified); -- Program currently running procedure Set_Program (P : Program_Type); -- Indicates to the body of Osint the program currently running. -- This procedure is called by the child packages of Osint. -- A check is made that this procedure is not called several times. function More_Files return Boolean; -- Implements More_Source_Files and More_Lib_Files function Next_Main_File return File_Name_Type; -- Implements Next_Main_Source and Next_Main_Lib_File function Object_File_Name (N : File_Name_Type) return File_Name_Type; -- Constructs the name of the object file corresponding to library -- file N. If N is a full file name than the returned file name will -- also be a full file name. Note that no lookup in the library file -- directories is done for this file. This routine merely constructs -- the name. procedure Write_Info (Info : String); -- Implementation of Write_Binder_Info, Write_Debug_Info and -- Write_Library_Info (identical) end Osint;
-- C86006I.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT THE IDENTIFIERS "BOOLEAN, TRUE, AND FALSE" AND THE -- IDENTIFIERS "INTEGER, NATURAL, AND POSITIVE" ARE DECLARED IN -- THE PACKAGE "STANDARD", ALONG WITH THE OPERATORS OF THE TYPE -- BOOLEAN AND THE TYPE INTEGER. -- HISTORY: -- DTN 04/15/92 CONSOLIDATION OF C86006A AND C86006B. WITH REPORT; USE REPORT; PROCEDURE C86006I IS ABOOL, BBOOL : STANDARD.BOOLEAN := STANDARD.FALSE; CBOOL : STANDARD.BOOLEAN := STANDARD.TRUE; INT1 : STANDARD.INTEGER := -2; NAT1 : STANDARD.NATURAL := 0; POS1, POS2 : STANDARD.POSITIVE := 2; BEGIN TEST("C86006I", "CHECK THAT THE IDENTIFIERS ""BOOLEAN, TRUE, AND " & "FALSE"" AND THE IDENTIFIERS ""INTEGER, NATURAL, " & "AND POSITIVE"" ARE DECLARED IN THE PACKAGE " & """STANDARD"", ALONG WITH THE OPERATORS OF THE " & "TYPE BOOLEAN AND THE TYPE INTEGER"); -- STANDARD.">" OPERATOR. IF STANDARD.">"(ABOOL,BBOOL) THEN FAILED("STANDARD.> FAILED FOR BOOLEAN TYPE"); END IF; IF STANDARD.">"(INT1,NAT1) THEN FAILED("STANDARD.> FAILED FOR INTEGER-NATURAL TYPE"); END IF; -- STANDARD."/=" OPERATOR. IF STANDARD."/="(ABOOL,BBOOL) THEN FAILED("STANDARD./= FAILED FOR BOOLEAN TYPE"); END IF; IF STANDARD."/="(POS1,POS2) THEN FAILED("STANDARD./= FAILED FOR INTEGER-POSITIVE TYPE"); END IF; -- STANDARD."AND" OPERATOR. IF STANDARD."AND"(CBOOL,ABOOL) THEN FAILED("STANDARD.AND FAILED"); END IF; -- STANDARD."-" BINARY OPERATOR. IF STANDARD."-"(INT1,POS1) /= IDENT_INT(-4) THEN FAILED("STANDARD.- FAILED"); END IF; -- STANDARD."-" UNARY OPERATOR. IF STANDARD."-"(INT1) /= IDENT_INT(2) THEN FAILED("STANDARD.UNARY - FAILED"); END IF; -- STANDARD."REM" OPERATOR. IF STANDARD."REM"(IDENT_INT(14),IDENT_INT(5)) /= IDENT_INT(4) THEN FAILED("STANDARD.REM (++=+) FAILED"); END IF; -- STANDARD."MOD" OPERATOR. IF STANDARD."MOD"(IDENT_INT(14),IDENT_INT(-5)) /= IDENT_INT(-1) THEN FAILED("STANDARD.MOD (+-=-) FAILED"); END IF; RESULT; END C86006I;
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization> <boost_serialization signature="serialization::archive" version="15"> <syndb class_id="0" tracking_level="0" version="0"> <userIPLatency>-1</userIPLatency> <userIPName></userIPName> <cdfg class_id="1" tracking_level="1" version="0" object_id="_0"> <name>sobel_accel</name> <ret_bitwidth>0</ret_bitwidth> <ports class_id="2" tracking_level="0" version="0"> <count>15</count> <item_version>0</item_version> <item class_id="3" tracking_level="1" version="0" object_id="_1"> <Value class_id="4" tracking_level="0" version="0"> <Obj class_id="5" tracking_level="0" version="0"> <type>1</type> <id>1</id> <name>p_src_allocatedFlag</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo class_id="6" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_src.allocatedFlag</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs class_id="7" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_2"> <Value> <Obj> <type>1</type> <id>2</id> <name>p_src_rows</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_src.rows</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_3"> <Value> <Obj> <type>1</type> <id>3</id> <name>p_src_cols</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_src.cols</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_4"> <Value> <Obj> <type>1</type> <id>4</id> <name>p_src_size</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_src.size</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_5"> <Value> <Obj> <type>1</type> <id>5</id> <name>p_src_data_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_src.data.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>0</direction> <if_type>1</if_type> <array_size>307200</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_6"> <Value> <Obj> <type>1</type> <id>6</id> <name>p_dstgx_allocatedFlag</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgx.allocatedFlag</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_7"> <Value> <Obj> <type>1</type> <id>7</id> <name>p_dstgx_rows</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgx.rows</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_8"> <Value> <Obj> <type>1</type> <id>8</id> <name>p_dstgx_cols</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgx.cols</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_9"> <Value> <Obj> <type>1</type> <id>9</id> <name>p_dstgx_size</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgx.size</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_10"> <Value> <Obj> <type>1</type> <id>10</id> <name>p_dstgx_data_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgx.data.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>1</direction> <if_type>1</if_type> <array_size>307200</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_11"> <Value> <Obj> <type>1</type> <id>11</id> <name>p_dstgy_allocatedFlag</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgy.allocatedFlag</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_12"> <Value> <Obj> <type>1</type> <id>12</id> <name>p_dstgy_rows</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgy.rows</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_13"> <Value> <Obj> <type>1</type> <id>13</id> <name>p_dstgy_cols</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgy.cols</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_14"> <Value> <Obj> <type>1</type> <id>14</id> <name>p_dstgy_size</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgy.size</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <direction>0</direction> <if_type>0</if_type> <array_size>0</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> <item class_id_reference="3" object_id="_15"> <Value> <Obj> <type>1</type> <id>15</id> <name>p_dstgy_data_V</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName>_dstgy.data.V</originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>8</bitwidth> </Value> <direction>1</direction> <if_type>1</if_type> <array_size>307200</array_size> <bit_vecs> <count>0</count> <item_version>0</item_version> </bit_vecs> </item> </ports> <nodes class_id="8" tracking_level="0" version="0"> <count>7</count> <item_version>0</item_version> <item class_id="9" tracking_level="1" version="0" object_id="_16"> <Value> <Obj> <type>0</type> <id>33</id> <name>p_src_rows_read</name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item class_id="10" tracking_level="0" version="0"> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second class_id="11" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="12" tracking_level="0" version="0"> <first class_id="13" tracking_level="0" version="0"> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>2</count> <item_version>0</item_version> <item>42</item> <item>43</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_17"> <Value> <Obj> <type>0</type> <id>34</id> <name>p_src_cols_read</name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>2</count> <item_version>0</item_version> <item>44</item> <item>45</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_18"> <Value> <Obj> <type>0</type> <id>35</id> <name>p_dstgx_rows_read</name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>2</count> <item_version>0</item_version> <item>46</item> <item>47</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_19"> <Value> <Obj> <type>0</type> <id>36</id> <name>p_dstgx_cols_read</name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>2</count> <item_version>0</item_version> <item>48</item> <item>49</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_20"> <Value> <Obj> <type>0</type> <id>37</id> <name>p_dstgy_cols_read</name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>32</bitwidth> </Value> <oprand_edges> <count>2</count> <item_version>0</item_version> <item>50</item> <item>51</item> </oprand_edges> <opcode>read</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_21"> <Value> <Obj> <type>0</type> <id>38</id> <name></name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>37</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>37</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>9</count> <item_version>0</item_version> <item>53</item> <item>54</item> <item>55</item> <item>56</item> <item>57</item> <item>58</item> <item>59</item> <item>60</item> <item>61</item> </oprand_edges> <opcode>call</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> <item class_id_reference="9" object_id="_22"> <Value> <Obj> <type>0</type> <id>39</id> <name></name> <fileName>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</fileName> <fileDirectory>C:/Users/yakup/workspace/bitirme_v4/Release</fileDirectory> <lineNumber>39</lineNumber> <contextFuncName>sobel_accel</contextFuncName> <inlineStackInfo> <count>1</count> <item_version>0</item_version> <item> <first>C:/Users/yakup/workspace/bitirme_v4/Release</first> <second> <count>1</count> <item_version>0</item_version> <item> <first> <first>C:/Users/yakup/workspace/bitirme_v4/src/xf_sobel_accel.cpp</first> <second>sobel_accel</second> </first> <second>39</second> </item> </second> </item> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <oprand_edges> <count>0</count> <item_version>0</item_version> </oprand_edges> <opcode>ret</opcode> <m_Display>0</m_Display> <m_isOnCriticalPath>0</m_isOnCriticalPath> <m_delay>0.00</m_delay> </item> </nodes> <consts class_id="15" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="16" tracking_level="1" version="0" object_id="_23"> <Value> <Obj> <type>2</type> <id>52</id> <name>Sobel</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <bitwidth>0</bitwidth> </Value> <const_type>6</const_type> <content>&lt;constant:Sobel&gt;</content> </item> </consts> <blocks class_id="17" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="18" tracking_level="1" version="0" object_id="_24"> <Obj> <type>3</type> <id>40</id> <name>sobel_accel</name> <fileName></fileName> <fileDirectory></fileDirectory> <lineNumber>0</lineNumber> <contextFuncName></contextFuncName> <inlineStackInfo> <count>0</count> <item_version>0</item_version> </inlineStackInfo> <originalName></originalName> <rtlName></rtlName> <coreName></coreName> </Obj> <node_objs> <count>7</count> <item_version>0</item_version> <item>33</item> <item>34</item> <item>35</item> <item>36</item> <item>37</item> <item>38</item> <item>39</item> </node_objs> </item> </blocks> <edges class_id="19" tracking_level="0" version="0"> <count>14</count> <item_version>0</item_version> <item class_id="20" tracking_level="1" version="0" object_id="_25"> <id>43</id> <edge_type>1</edge_type> <source_obj>2</source_obj> <sink_obj>33</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_26"> <id>45</id> <edge_type>1</edge_type> <source_obj>3</source_obj> <sink_obj>34</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_27"> <id>47</id> <edge_type>1</edge_type> <source_obj>7</source_obj> <sink_obj>35</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_28"> <id>49</id> <edge_type>1</edge_type> <source_obj>8</source_obj> <sink_obj>36</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_29"> <id>51</id> <edge_type>1</edge_type> <source_obj>13</source_obj> <sink_obj>37</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_30"> <id>53</id> <edge_type>1</edge_type> <source_obj>52</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_31"> <id>54</id> <edge_type>1</edge_type> <source_obj>33</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_32"> <id>55</id> <edge_type>1</edge_type> <source_obj>34</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_33"> <id>56</id> <edge_type>1</edge_type> <source_obj>5</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_34"> <id>57</id> <edge_type>1</edge_type> <source_obj>35</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_35"> <id>58</id> <edge_type>1</edge_type> <source_obj>36</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_36"> <id>59</id> <edge_type>1</edge_type> <source_obj>10</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_37"> <id>60</id> <edge_type>1</edge_type> <source_obj>37</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> <item class_id_reference="20" object_id="_38"> <id>61</id> <edge_type>1</edge_type> <source_obj>15</source_obj> <sink_obj>38</sink_obj> <is_back_edge>0</is_back_edge> </item> </edges> </cdfg> <cdfg_regions class_id="21" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="22" tracking_level="1" version="0" object_id="_39"> <mId>1</mId> <mTag>sobel_accel</mTag> <mType>0</mType> <sub_regions> <count>0</count> <item_version>0</item_version> </sub_regions> <basic_blocks> <count>1</count> <item_version>0</item_version> <item>40</item> </basic_blocks> <mII>-1</mII> <mDepth>-1</mDepth> <mMinTripCount>-1</mMinTripCount> <mMaxTripCount>-1</mMaxTripCount> <mMinLatency>312166</mMinLatency> <mMaxLatency>-1</mMaxLatency> <mIsDfPipe>0</mIsDfPipe> <mDfPipe class_id="-1"></mDfPipe> </item> </cdfg_regions> <fsm class_id="-1"></fsm> <res class_id="-1"></res> <node_label_latency class_id="26" tracking_level="0" version="0"> <count>7</count> <item_version>0</item_version> <item class_id="27" tracking_level="0" version="0"> <first>33</first> <second class_id="28" tracking_level="0" version="0"> <first>0</first> <second>0</second> </second> </item> <item> <first>34</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>35</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>36</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>37</first> <second> <first>0</first> <second>0</second> </second> </item> <item> <first>38</first> <second> <first>0</first> <second>1</second> </second> </item> <item> <first>39</first> <second> <first>1</first> <second>0</second> </second> </item> </node_label_latency> <bblk_ent_exit class_id="29" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="30" tracking_level="0" version="0"> <first>40</first> <second class_id="31" tracking_level="0" version="0"> <first>0</first> <second>1</second> </second> </item> </bblk_ent_exit> <regions class_id="32" tracking_level="0" version="0"> <count>1</count> <item_version>0</item_version> <item class_id="33" tracking_level="1" version="0" object_id="_40"> <region_name>sobel_accel</region_name> <basic_blocks> <count>1</count> <item_version>0</item_version> <item>40</item> </basic_blocks> <nodes> <count>24</count> <item_version>0</item_version> <item>16</item> <item>17</item> <item>18</item> <item>19</item> <item>20</item> <item>21</item> <item>22</item> <item>23</item> <item>24</item> <item>25</item> <item>26</item> <item>27</item> <item>28</item> <item>29</item> <item>30</item> <item>31</item> <item>32</item> <item>33</item> <item>34</item> <item>35</item> <item>36</item> <item>37</item> <item>38</item> <item>39</item> </nodes> <anchor_node>-1</anchor_node> <region_type>2</region_type> <interval>0</interval> <pipe_depth>0</pipe_depth> </item> </regions> <dp_fu_nodes class_id="34" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </dp_fu_nodes> <dp_fu_nodes_expression class_id="35" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </dp_fu_nodes_expression> <dp_fu_nodes_module> <count>0</count> <item_version>0</item_version> </dp_fu_nodes_module> <dp_fu_nodes_io> <count>0</count> <item_version>0</item_version> </dp_fu_nodes_io> <return_ports> <count>0</count> <item_version>0</item_version> </return_ports> <dp_mem_port_nodes class_id="36" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </dp_mem_port_nodes> <dp_reg_nodes> <count>0</count> <item_version>0</item_version> </dp_reg_nodes> <dp_regname_nodes> <count>0</count> <item_version>0</item_version> </dp_regname_nodes> <dp_reg_phi> <count>0</count> <item_version>0</item_version> </dp_reg_phi> <dp_regname_phi> <count>0</count> <item_version>0</item_version> </dp_regname_phi> <dp_port_io_nodes class_id="37" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </dp_port_io_nodes> <port2core class_id="38" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </port2core> <node2core> <count>0</count> <item_version>0</item_version> </node2core> </syndb> </boost_serialization>
with Ada.Text_IO, Crypto.Types.Big_Numbers, Ada.Numerics.Discrete_Random; procedure Miller_Rabin is Bound: constant Positive := 256; -- can be any multiple of 32 package LN is new Crypto.Types.Big_Numbers (Bound); use type LN.Big_Unsigned; -- all computations "mod 2**Bound" function "+"(S: String) return LN.Big_Unsigned renames LN.Utils.To_Big_Unsigned; function Is_Prime (N : LN.Big_Unsigned; K : Positive := 10) return Boolean is subtype Mod_32 is Crypto.Types.Mod_Type; use type Mod_32; package R_32 is new Ada.Numerics.Discrete_Random (Mod_32); Generator : R_32.Generator; function Random return LN.Big_Unsigned is X: LN.Big_Unsigned := LN.Big_Unsigned_Zero; begin for I in 1 .. Bound/32 loop X := (X * 2**16) * 2**16; X := X + R_32.Random(Generator); end loop; return X; end Random; D: LN.Big_Unsigned := N - LN.Big_Unsigned_One; S: Natural := 0; A, X: LN.Big_Unsigned; begin -- exclude 2 and even numbers if N = 2 then return True; elsif N mod 2 = LN.Big_Unsigned_Zero then return False; else -- write N-1 as 2**S * D, with odd D while D mod 2 = LN.Big_Unsigned_Zero loop D := D / 2; S := S + 1; end loop; -- initialize RNG R_32.Reset (Generator); -- run the real test for Loops in 1 .. K loop loop A := Random; exit when (A > 1) and (A < (N - 1)); end loop; X := LN.Mod_Utils.Pow(A, D, N); -- X := (Random**D) mod N if X /= 1 and X /= N - 1 then Inner: for R in 1 .. S - 1 loop X := LN.Mod_Utils.Pow(X, LN.Big_Unsigned_Two, N); if X = 1 then return False; end if; exit Inner when X = N - 1; end loop Inner; if X /= N - 1 then return False; end if; end if; end loop; end if; return True; end Is_Prime; S: constant String := "4547337172376300111955330758342147474062293202868155909489"; T: constant String := "4547337172376300111955330758342147474062293202868155909393"; K: constant Positive := 10; begin Ada.Text_IO.Put_Line("Prime(" & S & ")=" & Boolean'Image(Is_Prime(+S, K))); Ada.Text_IO.Put_Line("Prime(" & T & ")=" & Boolean'Image(Is_Prime(+T, K))); end Miller_Rabin;
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.References.Pools provides a task-safe dynamic pool of -- -- homogeneous references. -- ------------------------------------------------------------------------------ private with Ada.Unchecked_Deallocation; generic package Natools.References.Pools is pragma Preelaborate; type Pool_Backend is limited private; pragma Preelaborable_Initialization (Pool_Backend); type Pool_Size is new Natural; protected type Pool is procedure Get (Ref : out Reference) with Post => not Ref.Is_Empty; -- Return an existing non-empty available reference from the pool, -- raising Constraint_Error when not possible. procedure Get (Constructor : not null access function return Held_Data; Ref : out Reference) with Post => not Ref.Is_Empty; -- Return an available reference from the pool, initializing it -- if needed, but without expanding the pool. -- Raise Constraint_Error when all references are in use. procedure Create (Constructor : not null access function return Held_Data; Ref : out Reference; Expand_Count : in Pool_Size := 1) with Pre => Expand_Count > 0, Post => not Ref.Is_Empty; -- Return a reference from the pool, creating it and/or initializing -- it if needed. procedure Preallocate (New_Item_Count : in Pool_Size; Constructor : access function return Held_Data := null); -- Add New_Item_Count references to the pool, using Constructor to -- initialize them if not null. procedure Release_Unused; -- Empty all references from the pool that are not used externally procedure Trim; -- Remove empty references from the pool, diminishing its capacity procedure Purge; -- Remove empty and available references from the pool. -- Equivalent to Release_Unused followed by Trim. function Capacity return Pool_Size; -- Return the number of references in the pool function Initialized_Size return Pool_Size; -- Return the number of non-empty references in the pool function Active_Size return Pool_Size; -- Return the number of externally-used references in the pool. -- WARNING: the result might be stale before it can be used by the -- client, do not take any sensitive decision from it. procedure Unchecked_Iterate (Process : not null access procedure (Ref : in Reference)); -- Iterate over all references held in the pool. -- WARNING: Process must not call any potentially blocking operations -- or any operation on the current pool, and safety of any tampering -- with Ref or its referred object must be ensured independently. private Backend : Pool_Backend; end Pool; private -- Basic types subtype Reference_Index is Pool_Size range 1 .. Pool_Size'Last; subtype Extended_Index is Pool_Size range 0 .. Pool_Size'Last; type Reference_Array is array (Reference_Index range <>) of Reference; type Reference_Array_Access is access Reference_Array; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Reference_Array, Reference_Array_Access); -- Dynamic array backend type Pool_Backend is new Ada.Finalization.Limited_Controlled with record Refs : Reference_Array_Access := null; end record; overriding procedure Finalize (Object : in out Pool_Backend); not overriding procedure Find (Container : in Pool_Backend; First_Available : out Extended_Index; First_Empty : out Extended_Index) with Post => (First_Available = 0 or else (not Container.Refs (First_Available).Is_Empty and then Container.Refs (First_Available).Is_Last)) and then (First_Empty = 0 or else Container.Refs (First_Empty).Is_Empty); not overriding function Length (Container : Pool_Backend) return Pool_Size is (if Container.Refs = null then 0 else Container.Refs'Length); not overriding procedure Preallocate (Container : in out Pool_Backend; New_Item_Count : in Pool_Size; Constructor : access function return Held_Data := null) with Post => (Container.Length = Container.Length'Old + New_Item_Count); end Natools.References.Pools;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 1 2 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Inline; use Inline; with Types; use Types; package Sem_Ch12 is procedure Analyze_Generic_Package_Declaration (N : Node_Id); procedure Analyze_Generic_Subprogram_Declaration (N : Node_Id); procedure Analyze_Package_Instantiation (N : Node_Id); procedure Analyze_Procedure_Instantiation (N : Node_Id); procedure Analyze_Function_Instantiation (N : Node_Id); procedure Analyze_Formal_Object_Declaration (N : Node_Id); procedure Analyze_Formal_Type_Declaration (N : Node_Id); procedure Analyze_Formal_Subprogram (N : Node_Id); procedure Analyze_Formal_Package (N : Node_Id); procedure Start_Generic; -- Must be invoked before starting to process a generic spec or body procedure End_Generic; -- Must be invoked just at the end of the end of the processing of a -- generic spec or body. procedure Check_Generic_Child_Unit (Gen_Id : Node_Id; Parent_Installed : in out Boolean); -- If the name of the generic unit in an instantiation or a renaming -- is a selected component, then the prefix may be an instance and the -- selector may designate a child unit. Retrieve the parent generic -- and search for the child unit that must be declared within. Similarly, -- if this is the name of a generic child unit within an instantiation of -- its own parent, retrieve the parent generic. function Copy_Generic_Node (N : Node_Id; Parent_Id : Node_Id; Instantiating : Boolean) return Node_Id; -- Copy the tree for a generic unit or its body. The unit is copied -- repeatedly: once to produce a copy on which semantic analysis of -- the generic is performed, and once for each instantiation. The tree -- being copied is not semantically analyzed, except that references to -- global entities are marked on terminal nodes. function Get_Instance_Of (A : Entity_Id) return Entity_Id; -- Retrieve actual associated with given generic parameter. -- If A is uninstantiated or not a generic parameter, return A. function Get_Package_Instantiation_Node (A : Entity_Id) return Node_Id; -- Given the entity of a unit that is an instantiation, retrieve the -- original instance node. This is used when loading the instantiations -- of the ancestors of a child generic that is being instantiated. procedure Instantiate_Package_Body (Body_Info : Pending_Body_Info; Inlined_Body : Boolean := False); -- Called after semantic analysis, to complete the instantiation of -- package instances. The flag Inlined_Body is set if the body is -- being instantiated on the fly for inlined purposes. procedure Instantiate_Subprogram_Body (Body_Info : Pending_Body_Info); -- Called after semantic analysis, to complete the instantiation of -- function and procedure instances. procedure Save_Global_References (N : Node_Id); -- Traverse the original generic unit, and capture all references to -- entities that are defined outside of the generic in the analyzed -- tree for the template. These references are copied into the original -- tree, so that they appear automatically in every instantiation. -- A critical invariant in this approach is that if an id in the generic -- resolves to a local entity, the corresponding id in the instance -- will resolve to the homologous entity in the instance, even though -- the enclosing context for resolution is different, as long as the -- global references have been captured as described here. -- Because instantiations can be nested, the environment of the instance, -- involving the actuals and other data-structures, must be saved and -- restored in stack-like fashion. Front-end inlining also uses these -- structures for the management of private/full views. procedure Set_Copied_Sloc_For_Inlined_Body (N : Node_Id; E : Entity_Id); -- This procedure is used when a subprogram body is inlined. This process -- shares the same circuitry as the creation of an instantiated copy of -- a generic template. The call to this procedure establishes a new source -- file entry representing the inlined body as an instantiation, marked as -- an inlined body (so that errout can distinguish cases for generating -- error messages, otherwise the treatment is identical). In this call -- N is the subprogram body and E is the defining identifier of the -- subprogram in quiestion. The resulting Sloc adjustment factor is -- saved as part of the internal state of the Sem_Ch12 package for use -- in subsequent calls to copy nodes. procedure Save_Env (Gen_Unit : Entity_Id; Act_Unit : Entity_Id); -- ??? comment needed procedure Restore_Env; -- ??? comment needed procedure Initialize; -- Initializes internal data structures end Sem_Ch12;
-- Implantation d'un module Dates très simplifié. with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; package body Dates is procedure Initialiser ( Date : out T_Date ; Jour : in Integer ; Mois : in T_Mois ; Annee : in Integer ) is begin Date.Jour := Jour; Date.Mois := Mois; Date.Annee := Annee; end Initialiser; -- Afficher un entier sur 2 positons au moins (avec des zéros -- supplémentaires si nécessaires) -- -- Paramètres : -- Nombre : le nombre à afficher -- -- Nécessite : -- Nombre >= 0 -- procedure Afficher_Deux_Positions (Nombre : in Integer) with Pre => Nombre >= 0 is begin Put (Nombre / 10, 1); Put (Nombre mod 10, 1); end Afficher_Deux_Positions; procedure Afficher (Date : in T_Date) is begin Afficher_Deux_Positions (Date.Jour); Put ('/'); Afficher_Deux_Positions (T_Mois'pos (Date.Mois) + 1); Put ('/'); Afficher_Deux_Positions (Date.Annee / 100); Afficher_Deux_Positions (Date.Annee mod 100); end Afficher; function Le_Jour (Date : in T_Date) return Integer is begin return Date.Jour; end Le_Jour; function Le_Mois(Date : in T_Date) return T_Mois is begin return Date.Mois; end Le_Mois; function L_Annee (Date : in T_Date) return Integer is begin return Date.Annee; end L_Annee; end Dates;
with AUnit.Test_Suites; with AUnit.Test_Suites.Simple_Main_Generic; procedure AUnit.Test_Cases.Simple_Main_Generic is use AUnit.Test_Suites; function Suite return AUnit.Test_Suites.Access_Test_Suite is Result : Access_Test_Suite; pragma Warnings (Off); begin Result := new Test_Suite; Add_Test (Result, new Test_Case); return Result; end Suite; procedure Run is new AUnit.Test_Suites.Simple_Main_Generic (Suite); begin Run; end AUnit.Test_Cases.Simple_Main_Generic;
-- { dg-do compile } package Clause_On_Volatile is type U8 is mod 2 ** 8; type Word is record A, B : U8; end record; For Word'Alignment use 4; type Vword is new Word; For Vword'Alignment use 4; pragma Volatile (Vword); type Aword is new Word; For Aword'Alignment use 4; pragma Atomic (Aword); type R1 is record W : Word; end record; for R1 use record W at 0 range 0 .. 15; -- OK end record; type A1 is record AW : Aword; end record; For A1'Alignment use 4; for A1 use record AW at 0 range 0 .. 15; -- { dg-error "must be \[0-9\]*" } end record; type A2 is record B : U8; AW : Aword; end record; For A2'Alignment use 4; for A2 use record B at 0 range 0 .. 7; AW at 1 range 0 .. 31; -- { dg-error "must be multiple" } end record; type A3 is record B : U8; AW : Aword; end record; For A3'Alignment use 4; for A3 use record B at 0 range 0 .. 7; AW at 1 range 0 .. 15; -- { dg-error "must be (multiple||\[0-9\]*)" } end record; type V1 is record VW : Vword; end record; For V1'Alignment use 4; for V1 use record VW at 0 range 0 .. 15; -- { dg-error "must be at least" } end record; type V2 is record B : U8; VW : Vword; end record; For V2'Alignment use 4; for V2 use record B at 0 range 0 .. 7; VW at 1 range 0 .. 31; -- { dg-error "must be multiple" } end record; type V3 is record B : U8; VW : Vword; end record; For V3'Alignment use 4; for V3 use record B at 0 range 0 .. 7; VW at 1 range 0 .. 15; -- { dg-error "must be (multiple|at least)" } end record; end Clause_On_Volatile;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- M A T H _ L I B -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This body is specifically for using an Ada interface to C math.h to get -- the computation engine. Many special cases are handled locally to avoid -- unnecessary calls. This is not a "strict" implementation, but takes full -- advantage of the C functions, e.g. in providing interface to hardware -- provided versions of the elementary functions. -- A known weakness is that on the x86, all computation is done in Double, -- which means that a lot of accuracy is lost for the Long_Long_Float case. -- Uses functions sqrt, exp, log, pow, sin, asin, cos, acos, tan, atan, -- sinh, cosh, tanh from C library via math.h -- This is an adaptation of Ada.Numerics.Generic_Elementary_Functions that -- provides a compatible body for the DEC Math_Lib package. with Ada.Numerics.Aux; use type Ada.Numerics.Aux.Double; with Ada.Numerics; use Ada.Numerics; package body Math_Lib is Log_Two : constant := 0.69314_71805_59945_30941_72321_21458_17656_80755; Two_Pi : constant Real'Base := 2.0 * Pi; Half_Pi : constant Real'Base := Pi / 2.0; Fourth_Pi : constant Real'Base := Pi / 4.0; Epsilon : constant Real'Base := Real'Base'Epsilon; IEpsilon : constant Real'Base := 1.0 / Epsilon; subtype Double is Aux.Double; DEpsilon : constant Double := Double (Epsilon); DIEpsilon : constant Double := Double (IEpsilon); ----------------------- -- Local Subprograms -- ----------------------- function Arctan (Y : Real; A : Real := 1.0) return Real; function Arctan (Y : Real; A : Real := 1.0; Cycle : Real) return Real; function Exact_Remainder (A : Real; Y : Real) return Real; -- Computes exact remainder of A divided by Y function Half_Log_Epsilon return Real; -- Function to provide constant: 0.5 * Log (Epsilon) function Local_Atan (Y : Real; A : Real := 1.0) return Real; -- Common code for arc tangent after cycle reduction function Log_Inverse_Epsilon return Real; -- Function to provide constant: Log (1.0 / Epsilon) function Square_Root_Epsilon return Real; -- Function to provide constant: Sqrt (Epsilon) ---------- -- "**" -- ---------- function "**" (A1, A2 : Real) return Real is begin if A1 = 0.0 and then A2 = 0.0 then raise Argument_Error; elsif A1 < 0.0 then raise Argument_Error; elsif A2 = 0.0 then return 1.0; elsif A1 = 0.0 then if A2 < 0.0 then raise Constraint_Error; else return 0.0; end if; elsif A1 = 1.0 then return 1.0; elsif A2 = 1.0 then return A1; else begin if A2 = 2.0 then return A1 * A1; else return Real (Aux.pow (Double (A1), Double (A2))); end if; exception when others => raise Constraint_Error; end; end if; end "**"; ------------ -- Arccos -- ------------ -- Natural cycle function Arccos (A : Real) return Real is Temp : Real'Base; begin if abs A > 1.0 then raise Argument_Error; elsif abs A < Square_Root_Epsilon then return Pi / 2.0 - A; elsif A = 1.0 then return 0.0; elsif A = -1.0 then return Pi; end if; Temp := Real (Aux.acos (Double (A))); if Temp < 0.0 then Temp := Pi + Temp; end if; return Temp; end Arccos; -- Arbitrary cycle function Arccos (A, Cycle : Real) return Real is Temp : Real'Base; begin if Cycle <= 0.0 then raise Argument_Error; elsif abs A > 1.0 then raise Argument_Error; elsif abs A < Square_Root_Epsilon then return Cycle / 4.0; elsif A = 1.0 then return 0.0; elsif A = -1.0 then return Cycle / 2.0; end if; Temp := Arctan (Sqrt (1.0 - A * A) / A, 1.0, Cycle); if Temp < 0.0 then Temp := Cycle / 2.0 + Temp; end if; return Temp; end Arccos; ------------- -- Arccosh -- ------------- function Arccosh (A : Real) return Real is begin -- Return Log (A - Sqrt (A * A - 1.0)); double valued, -- only positive value returned -- What is this comment ??? if A < 1.0 then raise Argument_Error; elsif A < 1.0 + Square_Root_Epsilon then return A - 1.0; elsif abs A > 1.0 / Square_Root_Epsilon then return Log (A) + Log_Two; else return Log (A + Sqrt (A * A - 1.0)); end if; end Arccosh; ------------ -- Arccot -- ------------ -- Natural cycle function Arccot (A : Real; Y : Real := 1.0) return Real is begin -- Just reverse arguments return Arctan (Y, A); end Arccot; -- Arbitrary cycle function Arccot (A : Real; Y : Real := 1.0; Cycle : Real) return Real is begin -- Just reverse arguments return Arctan (Y, A, Cycle); end Arccot; ------------- -- Arccoth -- ------------- function Arccoth (A : Real) return Real is begin if abs A = 1.0 then raise Constraint_Error; elsif abs A < 1.0 then raise Argument_Error; elsif abs A > 1.0 / Epsilon then return 0.0; else return 0.5 * Log ((1.0 + A) / (A - 1.0)); end if; end Arccoth; ------------ -- Arcsin -- ------------ -- Natural cycle function Arcsin (A : Real) return Real is begin if abs A > 1.0 then raise Argument_Error; elsif abs A < Square_Root_Epsilon then return A; elsif A = 1.0 then return Pi / 2.0; elsif A = -1.0 then return -Pi / 2.0; end if; return Real (Aux.asin (Double (A))); end Arcsin; -- Arbitrary cycle function Arcsin (A, Cycle : Real) return Real is begin if Cycle <= 0.0 then raise Argument_Error; elsif abs A > 1.0 then raise Argument_Error; elsif A = 0.0 then return A; elsif A = 1.0 then return Cycle / 4.0; elsif A = -1.0 then return -Cycle / 4.0; end if; return Arctan (A / Sqrt (1.0 - A * A), 1.0, Cycle); end Arcsin; ------------- -- Arcsinh -- ------------- function Arcsinh (A : Real) return Real is begin if abs A < Square_Root_Epsilon then return A; elsif A > 1.0 / Square_Root_Epsilon then return Log (A) + Log_Two; elsif A < -1.0 / Square_Root_Epsilon then return -(Log (-A) + Log_Two); elsif A < 0.0 then return -Log (abs A + Sqrt (A * A + 1.0)); else return Log (A + Sqrt (A * A + 1.0)); end if; end Arcsinh; ------------ -- Arctan -- ------------ -- Natural cycle function Arctan (Y : Real; A : Real := 1.0) return Real is begin if A = 0.0 and then Y = 0.0 then raise Argument_Error; elsif Y = 0.0 then if A > 0.0 then return 0.0; else -- A < 0.0 return Pi; end if; elsif A = 0.0 then if Y > 0.0 then return Half_Pi; else -- Y < 0.0 return -Half_Pi; end if; else return Local_Atan (Y, A); end if; end Arctan; -- Arbitrary cycle function Arctan (Y : Real; A : Real := 1.0; Cycle : Real) return Real is begin if Cycle <= 0.0 then raise Argument_Error; elsif A = 0.0 and then Y = 0.0 then raise Argument_Error; elsif Y = 0.0 then if A > 0.0 then return 0.0; else -- A < 0.0 return Cycle / 2.0; end if; elsif A = 0.0 then if Y > 0.0 then return Cycle / 4.0; else -- Y < 0.0 return -Cycle / 4.0; end if; else return Local_Atan (Y, A) * Cycle / Two_Pi; end if; end Arctan; ------------- -- Arctanh -- ------------- function Arctanh (A : Real) return Real is begin if abs A = 1.0 then raise Constraint_Error; elsif abs A > 1.0 then raise Argument_Error; elsif abs A < Square_Root_Epsilon then return A; else return 0.5 * Log ((1.0 + A) / (1.0 - A)); end if; end Arctanh; --------- -- Cos -- --------- -- Natural cycle function Cos (A : Real) return Real is begin if A = 0.0 then return 1.0; elsif abs A < Square_Root_Epsilon then return 1.0; end if; return Real (Aux.Cos (Double (A))); end Cos; -- Arbitrary cycle function Cos (A, Cycle : Real) return Real is T : Real'Base; begin if Cycle <= 0.0 then raise Argument_Error; elsif A = 0.0 then return 1.0; end if; T := Exact_Remainder (abs (A), Cycle) / Cycle; if T = 0.25 or else T = 0.75 or else T = -0.25 or else T = -0.75 then return 0.0; elsif T = 0.5 or T = -0.5 then return -1.0; end if; return Real (Aux.Cos (Double (T * Two_Pi))); end Cos; ---------- -- Cosh -- ---------- function Cosh (A : Real) return Real is begin if abs A < Square_Root_Epsilon then return 1.0; elsif abs A > Log_Inverse_Epsilon then return Exp ((abs A) - Log_Two); end if; return Real (Aux.cosh (Double (A))); exception when others => raise Constraint_Error; end Cosh; --------- -- Cot -- --------- -- Natural cycle function Cot (A : Real) return Real is begin if A = 0.0 then raise Constraint_Error; elsif abs A < Square_Root_Epsilon then return 1.0 / A; end if; return Real (1.0 / Real'Base (Aux.tan (Double (A)))); end Cot; -- Arbitrary cycle function Cot (A, Cycle : Real) return Real is T : Real'Base; begin if Cycle <= 0.0 then raise Argument_Error; elsif A = 0.0 then raise Constraint_Error; elsif abs A < Square_Root_Epsilon then return 1.0 / A; end if; T := Exact_Remainder (A, Cycle) / Cycle; if T = 0.0 or T = 0.5 or T = -0.5 then raise Constraint_Error; else return Cos (T * Two_Pi) / Sin (T * Two_Pi); end if; end Cot; ---------- -- Coth -- ---------- function Coth (A : Real) return Real is begin if A = 0.0 then raise Constraint_Error; elsif A < Half_Log_Epsilon then return -1.0; elsif A > -Half_Log_Epsilon then return 1.0; elsif abs A < Square_Root_Epsilon then return 1.0 / A; end if; return Real (1.0 / Real'Base (Aux.tanh (Double (A)))); end Coth; --------------------- -- Exact_Remainder -- --------------------- function Exact_Remainder (A : Real; Y : Real) return Real is Denominator : Real'Base := abs A; Divisor : Real'Base := abs Y; Reducer : Real'Base; Sign : Real'Base := 1.0; begin if Y = 0.0 then raise Constraint_Error; elsif A = 0.0 then return 0.0; elsif A = Y then return 0.0; elsif Denominator < Divisor then return A; end if; while Denominator >= Divisor loop -- Put divisors mantissa with denominators exponent to make reducer Reducer := Divisor; begin while Reducer * 1_048_576.0 < Denominator loop Reducer := Reducer * 1_048_576.0; end loop; exception when others => null; end; begin while Reducer * 1_024.0 < Denominator loop Reducer := Reducer * 1_024.0; end loop; exception when others => null; end; begin while Reducer * 2.0 < Denominator loop Reducer := Reducer * 2.0; end loop; exception when others => null; end; Denominator := Denominator - Reducer; end loop; if A < 0.0 then return -Denominator; else return Denominator; end if; end Exact_Remainder; --------- -- Exp -- --------- function Exp (A : Real) return Real is Result : Real'Base; begin if A = 0.0 then return 1.0; else Result := Real (Aux.Exp (Double (A))); -- The check here catches the case of Exp returning IEEE infinity if Result > Real'Last then raise Constraint_Error; else return Result; end if; end if; end Exp; ---------------------- -- Half_Log_Epsilon -- ---------------------- -- Cannot precompute this constant, because this is required to be a -- pure package, which allows no state. A pity, but no way around it! function Half_Log_Epsilon return Real is begin return Real (0.5 * Real'Base (Aux.Log (DEpsilon))); end Half_Log_Epsilon; ---------------- -- Local_Atan -- ---------------- function Local_Atan (Y : Real; A : Real := 1.0) return Real is Z : Real'Base; Raw_Atan : Real'Base; begin if abs Y > abs A then Z := abs (A / Y); else Z := abs (Y / A); end if; if Z < Square_Root_Epsilon then Raw_Atan := Z; elsif Z = 1.0 then Raw_Atan := Pi / 4.0; elsif Z < Square_Root_Epsilon then Raw_Atan := Z; else Raw_Atan := Real'Base (Aux.Atan (Double (Z))); end if; if abs Y > abs A then Raw_Atan := Half_Pi - Raw_Atan; end if; if A > 0.0 then if Y > 0.0 then return Raw_Atan; else -- Y < 0.0 return -Raw_Atan; end if; else -- A < 0.0 if Y > 0.0 then return Pi - Raw_Atan; else -- Y < 0.0 return -(Pi - Raw_Atan); end if; end if; end Local_Atan; --------- -- Log -- --------- -- Natural base function Log (A : Real) return Real is begin if A < 0.0 then raise Argument_Error; elsif A = 0.0 then raise Constraint_Error; elsif A = 1.0 then return 0.0; end if; return Real (Aux.Log (Double (A))); end Log; -- Arbitrary base function Log (A, Base : Real) return Real is begin if A < 0.0 then raise Argument_Error; elsif Base <= 0.0 or else Base = 1.0 then raise Argument_Error; elsif A = 0.0 then raise Constraint_Error; elsif A = 1.0 then return 0.0; end if; return Real (Aux.Log (Double (A)) / Aux.Log (Double (Base))); end Log; ------------------------- -- Log_Inverse_Epsilon -- ------------------------- -- Cannot precompute this constant, because this is required to be a -- pure package, which allows no state. A pity, but no way around it! function Log_Inverse_Epsilon return Real is begin return Real (Aux.Log (DIEpsilon)); end Log_Inverse_Epsilon; --------- -- Sin -- --------- -- Natural cycle function Sin (A : Real) return Real is begin if abs A < Square_Root_Epsilon then return A; end if; return Real (Aux.Sin (Double (A))); end Sin; -- Arbitrary cycle function Sin (A, Cycle : Real) return Real is T : Real'Base; begin if Cycle <= 0.0 then raise Argument_Error; elsif A = 0.0 then return A; end if; T := Exact_Remainder (A, Cycle) / Cycle; if T = 0.0 or T = 0.5 or T = -0.5 then return 0.0; elsif T = 0.25 or T = -0.75 then return 1.0; elsif T = -0.25 or T = 0.75 then return -1.0; end if; return Real (Aux.Sin (Double (T * Two_Pi))); end Sin; ---------- -- Sinh -- ---------- function Sinh (A : Real) return Real is begin if abs A < Square_Root_Epsilon then return A; elsif A > Log_Inverse_Epsilon then return Exp (A - Log_Two); elsif A < -Log_Inverse_Epsilon then return -Exp ((-A) - Log_Two); end if; return Real (Aux.Sinh (Double (A))); exception when others => raise Constraint_Error; end Sinh; ------------------------- -- Square_Root_Epsilon -- ------------------------- -- Cannot precompute this constant, because this is required to be a -- pure package, which allows no state. A pity, but no way around it! function Square_Root_Epsilon return Real is begin return Real (Aux.Sqrt (DEpsilon)); end Square_Root_Epsilon; ---------- -- Sqrt -- ---------- function Sqrt (A : Real) return Real is begin if A < 0.0 then raise Argument_Error; -- Special case Sqrt (0.0) to preserve possible minus sign per IEEE elsif A = 0.0 then return A; -- Sqrt (1.0) must be exact for good complex accuracy elsif A = 1.0 then return 1.0; end if; return Real (Aux.Sqrt (Double (A))); end Sqrt; --------- -- Tan -- --------- -- Natural cycle function Tan (A : Real) return Real is begin if abs A < Square_Root_Epsilon then return A; elsif abs A = Pi / 2.0 then raise Constraint_Error; end if; return Real (Aux.tan (Double (A))); end Tan; -- Arbitrary cycle function Tan (A, Cycle : Real) return Real is T : Real'Base; begin if Cycle <= 0.0 then raise Argument_Error; elsif A = 0.0 then return A; end if; T := Exact_Remainder (A, Cycle) / Cycle; if T = 0.25 or else T = 0.75 or else T = -0.25 or else T = -0.75 then raise Constraint_Error; else return Sin (T * Two_Pi) / Cos (T * Two_Pi); end if; end Tan; ---------- -- Tanh -- ---------- function Tanh (A : Real) return Real is begin if A < Half_Log_Epsilon then return -1.0; elsif A > -Half_Log_Epsilon then return 1.0; elsif abs A < Square_Root_Epsilon then return A; end if; return Real (Aux.tanh (Double (A))); end Tanh; ---------------------------- -- DEC-Specific functions -- ---------------------------- function LOG10 (A : REAL) return REAL is begin return Log (A, 10.0); end LOG10; function LOG2 (A : REAL) return REAL is begin return Log (A, 2.0); end LOG2; function ASIN (A : REAL) return REAL renames Arcsin; function ACOS (A : REAL) return REAL renames Arccos; function ATAN (A : REAL) return REAL is begin return Arctan (A, 1.0); end ATAN; function ATAN2 (A1, A2 : REAL) return REAL renames Arctan; function SIND (A : REAL) return REAL is begin return Sin (A, 360.0); end SIND; function COSD (A : REAL) return REAL is begin return Cos (A, 360.0); end COSD; function TAND (A : REAL) return REAL is begin return Tan (A, 360.0); end TAND; function ASIND (A : REAL) return REAL is begin return Arcsin (A, 360.0); end ASIND; function ACOSD (A : REAL) return REAL is begin return Arccos (A, 360.0); end ACOSD; function Arctan (A : REAL) return REAL is begin return Arctan (A, 1.0, 360.0); end Arctan; function ATAND (A : REAL) return REAL is begin return Arctan (A, 1.0, 360.0); end ATAND; function ATAN2D (A1, A2 : REAL) return REAL is begin return Arctan (A1, A2, 360.0); end ATAN2D; end Math_Lib;
with Interfaces.C; with HW; use HW; package GMA is procedure gfxinit (lightup_ok : out Interfaces.C.int); pragma Export (C, gfxinit, "gma_gfxinit"); ---------------------------------------------------------------------------- type lb_framebuffer is record tag : word32; size : word32; physical_address : word64; x_resolution : word32; y_resolution : word32; bytes_per_line : word32; bits_per_pixel : word8; red_mask_pos : word8; red_mask_size : word8; green_mask_pos : word8; green_mask_size : word8; blue_mask_pos : word8; blue_mask_size : word8; reserved_mask_pos : word8; reserved_mask_size : word8; end record; function fill_lb_framebuffer (framebuffer : in out lb_framebuffer) return Interfaces.C.int; pragma Export (C, fill_lb_framebuffer, "fill_lb_framebuffer"); end GMA;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 7 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Types; use Types; package Sem_Ch7 is procedure Analyze_Package_Body (N : Node_Id); procedure Analyze_Package_Declaration (N : Node_Id); procedure Analyze_Package_Specification (N : Node_Id); procedure Analyze_Private_Type_Declaration (N : Node_Id); procedure End_Package_Scope (P : Entity_Id); -- Calls Uninstall_Declarations, and then pops the scope stack procedure Exchange_Declarations (Id : Entity_Id); -- Exchange private and full declaration on entry/exit from a package -- declaration or body. The semantic links of the respective nodes -- are preserved in the exchange. procedure Install_Visible_Declarations (P : Entity_Id); procedure Install_Private_Declarations (P : Entity_Id); -- On entrance to a package body, make declarations in package spec -- immediately visible. -- -- When compiling the body of a package, both routines are called in -- succession. When compiling the body of a child package, the call -- to Install_Private_Declaration is immediate for private children, -- but is deferred until the compilation of the private part of the -- child for public child packages. function Unit_Requires_Body (Pack_Id : Entity_Id; Do_Abstract_States : Boolean := False) return Boolean; -- Determine whether package Pack_Id requires a body. A specification needs -- a body if it contains declarations that require completion in the body. -- A non-Ghost [generic] package does not require a body when it declares -- Ghost entities exclusively. When flag Do_Abstract_States is set to True, -- non-null abstract states are considered in determining the need for a -- body. procedure May_Need_Implicit_Body (E : Entity_Id); -- If a package declaration contains tasks or RACWs and does not require -- a body, create an implicit body at the end of the current declarative -- part to activate those tasks or contain the bodies for the RACW -- calling stubs. procedure New_Private_Type (N : Node_Id; Id : Entity_Id; Def : Node_Id); -- Common processing for private type declarations and for formal private -- type declarations. For private types, N and Def are the type declaration -- node; for formal private types, Def is the formal type definition. procedure Uninstall_Declarations (P : Entity_Id); -- At the end of a package declaration or body, declarations in the visible -- part are no longer immediately visible, and declarations in the private -- part are not visible at all. For inner packages, place visible entities -- at the end of their homonym chains. For compilation units, make -- all entities invisible. In both cases, exchange private and visible -- declarations to restore order of elaboration. end Sem_Ch7;
-- Demonstrates: -- Explicit Dereference with ada.text_io; procedure explicit_deref is type A_Int is access Integer; Var : A_Int := new Integer; begin Var.all := 12; if Var.all = 12 then ada.Text_Io.Put_Line("Explicit Dereference OK"); end if; end Explicit_Deref;
with System; with STM32F4.GPIO; use STM32F4.GPIO; with STM32F4.SPI; use STM32F4.SPI; with STM32F4.RCC; use STM32F4.RCC; with STM32F429_Discovery; use STM32F429_Discovery; with Ada.Unchecked_Conversion; package STM32F4.LCD is LCD_PIXEL_WIDTH : constant := 240; LCD_PIXEL_HEIGHT : constant := 320; type LCD_Layer is (Layer1, Layer2); subtype Width is Natural range 0 .. (LCD_PIXEL_WIDTH - 1); subtype Height is Natural range 0 .. (LCD_PIXEL_HEIGHT - 1); subtype Pixel is Half_Word; type Pixel_Color is record B : Bits_5; G : Bits_5; R : Bits_5; A : Bits_1; end record with Size => Half_Word'Size; for Pixel_Color use record B at 0 range 0 .. 4; G at 0 range 5 .. 9; R at 1 range 2 .. 6; A at 1 range 7 .. 7; end record; function Pixel_Color_To_Pixel is new Ada.Unchecked_Conversion(Pixel_Color, Pixel); Black : constant Pixel := 16#8000#; White : constant Pixel := 16#FFFF#; Red : constant Pixel := 2**15 or (31 * (2**10)); Green : constant Pixel := 2**15 or (31 * (2**5)); Blue : constant Pixel := 2**15 or 31; Gray : constant Pixel := 2**15 or 23 * (2**10) or 23 * (2**5) or 23; Light_Gray : constant Pixel := 2**15 or 30 * (2**10) or 30 * (2**5) or 30; Sky_Blue : constant Pixel := 2**15 or 19 * (2**17) or 26 * (2**5) or 31; Yellow : constant Pixel := 2**15 or 31 * (2**10) or 31 * (2**5); Orange : constant Pixel := 2**15 or 31 * (2**10) or 21 * (2**5); Pink : constant Pixel := 2**15 or 31 * (2**10) or 13 * (2**5) or 23; Violet : constant Pixel := 2**15 or 19 * (2**10) or 6 * (2**5) or 26; type Frame_Buffer_Range is range 0 .. (LCD_PIXEL_HEIGHT * LCD_PIXEL_WIDTH) - 1; type Frame_Buffer is array (Frame_Buffer_Range) of Pixel with Pack, Volatile; type Frame_Buffer_Access is not null access all Frame_Buffer; -- Pixel_Fmt_ARGB8888 : constant := 2#000#; -- Pixel_Fmt_RGB888 : constant := 2#001#; Pixel_Fmt_RGB565 : constant := 2#010#; Pixel_Fmt_ARGB1555 : constant := 2#011#; Pixel_Fmt_ARGB4444 : constant := 2#100#; -- Pixel_Fmt_L8 : constant := 2#101#; -- Pixel_Fmt_AL44 : constant := 2#110#; -- Pixel_Fmt_AL88 : constant := 2#111#; BF1_Constant_Alpha : constant := 2#100#; BF1_Pixel_Alpha : constant := 2#110#; BF2_Constant_Alpha : constant := 2#101#; BF2_Pixel_Alpha : constant := 2#111#; Default_Pixel_Fmt : constant := Pixel_Fmt_ARGB1555; type Layer_State is (Enabled, Disabled); procedure Initialize; procedure Initialize_Layer (Layer : LCD_Layer; Pixel_Fmt : Word; Blending_Factor_1 : Bits_3; Blending_Factor_2 : Bits_3); procedure Set_Background (R, G, B : Byte); procedure Set_Layer_State (Layer : LCD_Layer; State : Layer_State); function Current_Frame_Buffer (Layer : LCD_Layer) return Frame_Buffer_Access; procedure Set_Pixel (Layer : LCD_Layer; X : Width; Y : Height; Value : Pixel); function Pixel_Value (Layer : LCD_Layer; X : Width; Y : Height) return Pixel; procedure Flip_Buffers; procedure Flip_Copy_Buffers; private NCS_GPIO : GPIO_Port renames GPIO_C; WRX_GPIO : GPIO_Port renames GPIO_D; NCS_Pin : GPIO_Pin renames Pin_2; WRX_Pin : GPIO_Pin renames Pin_13; SCK_GPIO : GPIO_Port renames GPIO_F; MISO_GPIO : GPIO_Port renames GPIO_F; MOSI_GPIO : GPIO_Port renames GPIO_F; SCK_Pin : GPIO_Pin renames Pin_7; MISO_Pin : GPIO_Pin renames Pin_8; MOSI_Pin : GPIO_Pin renames Pin_9; SCK_AF : GPIO_Alternate_Function renames GPIO_AF_SPI5; MISO_AF : GPIO_Alternate_Function renames GPIO_AF_SPI5; MOSI_AF : GPIO_Alternate_Function renames GPIO_AF_SPI5; LCD_SPI : SPI_Port renames SPI_5; -- Layer Control Register type LC_Registers is record Len : Bits_1; -- Layer Enable Colken : Bits_1; -- Color Keying Enable Reserved_1 : Bits_2; Cluten : Bits_1; -- Color Look-Up Table Enable Reserved_2 : Bits_27; end record with Pack, Volatile, Size => 32; -- Layerx Window Horizontal Position Configuration Register type LWHPC_Registers is record Horizontal_Start : Bits_12; -- Window Horizontal Start Position Reserved_1 : Bits_4; Horizontal_Stop : Bits_12; -- Window Horizontal Stop Position Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 32; -- Layerx Window Vertical Position Configuration Register type LWVPC_Registers is record Vertical_Start : Bits_11; -- Window Vertical Start Position Reserved_1 : Bits_5; Vertical_Stop : Bits_11; -- Window Vertical Stop Position Reserved_2 : Bits_5; end record with Pack, Volatile, Size => 32; -- Layerx Color Keying Configuration Register type LCKC_Registers is record CKBlue : Byte; CKGreen : Byte; CKRed : Byte; Reserved_1 : Byte; end record with Pack, Volatile, Size => 32; -- Layerx Pixel Format Configuration Register subtype LPFC_Register is Word; -- Layer Constant Alpha Configuration Register type LCAC_Registers is record CONSTA : Byte; Reserved : Bits_24; end record with Pack, Volatile, Size => 32; -- Layer Default Color Configuration Register type LDCC_Registers is record DCBlue : Byte; DCGreen : Byte; DCRed : Byte; DCAlpha : Byte; end record with Pack, Volatile, Size => 32; -- Layer Blending Factors Configuration Register type LBFC_Registers is record BF2 : Bits_3; -- Blending Factor 2 Reserved_1 : Bits_5; BF1 : Bits_3; -- Blending Factor 1 Reserved_2 : Bits_21; end record with Pack, Volatile, Size => 32; -- Layer Color Frame Buffer Length Register type LCFBL_Registers is record CFBLL : Bits_13; -- Color Frame Buffer Line Length Reserved_1 : Bits_3; CFBP : Bits_13; -- Color Frame Pitch in bytes Reserved_2 : Bits_3; end record with Pack, Volatile, Size => 32; -- Layer Color Frame Buffer Line Number Register type LCFBLN_Registers is record CFBLNBR : Bits_11; -- Frame Buffer Line Number Reserved : Bits_21; end record with Pack, Volatile, Size => 32; -- Layer CLUT Write Register type LCLUTW_Registers is record Blue : Byte; Green : Byte; Red : Byte; CLUTADD : Byte; end record with Pack, Volatile, Size => 32; type Layer is record Ctrl : LC_Registers; WHPC : LWHPC_Registers; WVPC : LWVPC_Registers; CKC : LCKC_Registers; PFC : LPFC_Register; CAC : LCAC_Registers; DCC : LDCC_Registers; BFC : LBFC_Registers; Reserved_1 : Word; Reserved_2 : Word; -- Layer Color Frame Buffer Address Register CFBA : Word; CFBL : LCFBL_Registers; CFBLN : LCFBLN_Registers; Reserved_3 : Word; Reserved_4 : Word; Reserved_5 : Word; CLUTW : LCLUTW_Registers; end record with Pack, Volatile, Size => 17 * 32; -- Synchronization Size Configuration Register type SSC_Registers is record VSH : Bits_11; -- Vertical Synchronization Height Reserved_1 : Bits_5; HSW : Bits_12; -- Horizontal Synchronization Width Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 32; -- Back Porch Configuration Register type BPC_Registers is record AVBP : Bits_11; -- Accumulated Vertical back porch Reserved_1 : Bits_5; AHBP : Bits_12; -- Accumulated Horizontal back porch Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 32; -- Active Width Configuration Register type AWC_Registers is record AAH : Bits_11; -- Accumulated Active Height Reserved_1 : Bits_5; AAW : Bits_12; -- Accumulated Active Width Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 32; -- Total Width Configuration Register type TWC_Registers is record TOTALH : Bits_11; -- Total Height Reserved_1 : Bits_5; TOTALW : Bits_12; -- Total Width Reserved_2 : Bits_4; end record with Pack, Volatile, Size => 32; -- Global Control Register type GC_Registers is record LTDCEN : Bits_1; -- Controller Enable Reserved_1 : Bits_3; DBW : Bits_3; -- Dither Blue Width Reserved_2 : Bits_1; DGW : Bits_3; -- Dither Green Width Reserved_3 : Bits_1; DRW : Bits_3; -- Dither Red Width Reserved_4 : Bits_1; DEN : Bits_1; -- Dither Enable Reserved_5 : Bits_11; PCPOL : Bits_1; -- Pixel Clock Polarity DEPOL : Bits_1; -- Data Enable Polarity VSPOL : Bits_1; -- Vertical Synchronization Polarity HSPOL : Bits_1; -- Horizontal Synchronization Polarity end record with Pack, Volatile, Size => 32; -- Shadow Reload Configuration Register type SRC_Registers is record IMR : Bits_1; -- Immediate Reload VBR : Bits_1; -- Vertical Blanking Reload Reserved : Bits_30; end record with Pack, Volatile, Size => 32; -- Background Color Configuration Register type BCC_Registers is record BCBlue : Byte; BCGreen : Byte; BCRed : Byte; Reserved : Byte; end record with Pack, Volatile, Size => 32; -- Interrupt Enable Register type IE_Registers is record LIE : Bits_1; -- Line Interrupt Enable FUIE : Bits_1; -- FIFO Underrun Interrupt Enable TERRIE : Bits_1; -- Transfer Error Interrupt Enable RRIE : Bits_1; -- Register Reload interrupt enable Reserved : Bits_28; end record with Pack, Volatile, Size => 32; -- Interrupt Status Register type IS_Registers is record LIF : Bits_1; -- Line Interrupt flag FUIF : Bits_1; -- FIFO Underrun Interrupt flag TERRIF : Bits_1; -- Transfer Error Interrupt flag RRIF : Bits_1; -- Register Reload interrupt flag Reserved : Bits_28; end record with Pack, Volatile, Size => 32; -- Interrupt Clear Register type IC_Registers is record CLIF : Bits_1; -- Clear Line Interrupt flag CFUIF : Bits_1; -- Clear FIFO Underrun Interrupt flag CTERRIF : Bits_1; -- Clear Transfer Error Interrupt flag CRRIF : Bits_1; -- Clear Register Reload interrupt flag Reserved : Bits_28; end record with Pack, Volatile, Size => 32; -- Line Interrupt Position Configuration Register type LIPC_Registers is record LIPOS : Bits_11; -- Line Interrupt Position Reserved : Bits_21; end record with Pack, Volatile, Size => 32; -- Current Position Status Register type CPS_Registers is record CYPOS : Bits_16; CXPOS : Bits_16; end record with Pack, Volatile, Size => 32; -- Current Display Status Register type CDS_Registers is record VDES : Bits_1; -- Vertical Data Enable display Status HDES : Bits_1; -- Horizontal Data Enable display Status VSYNCS : Bits_1; -- Vertical Synchronization Enable display Status HSYNCS : Bits_1; -- Horizontal Synchronization Enable display Status Reserved : Bits_28; end record with Pack, Volatile, Size => 32; Polarity_Active_Low : constant := 0; Polarity_Active_High : constant := 1; type LTDCR is record SSC : SSC_Registers; BPC : BPC_Registers; AWC : AWC_Registers; TWC : TWC_Registers; GC : GC_Registers; Reserved_1 : Word; Reserved_2 : Word; SRC : SRC_Registers; Reserved_3 : Word; BCC : BCC_Registers; Reserved_4 : Word; IE : IE_Registers; ISR : IS_Registers; IC : IC_Registers; LIPC : LIPC_Registers; CPS : CPS_Registers; CDS : CDS_Registers; end record with Pack, Volatile, Size => 17 * 32; Peripheral_Base : constant := 16#4000_0000#; APB2_Peripheral_Base : constant := Peripheral_Base + 16#0001_0000#; LTDC_Base : constant := APB2_Peripheral_Base + 16#6800#; SSCR_Base : constant := LTDC_Base + 16#008#; Layer1_Base : constant := LTDC_Base + 16#084#; Layer2_Base : constant := LTDC_Base + 16#104#; LTDC : LTDCR with Volatile, Address => System'To_Address (SSCR_Base); Layer1_Reg : aliased Layer with Volatile, Address => System'To_Address (Layer1_Base); Layer2_Reg : aliased Layer with Volatile, Address => System'To_Address (Layer2_Base); type Layer_Access is access all Layer; type Nb_Frame_Buffers is mod 2; Current_Frame_Buffer_Index : Nb_Frame_Buffers := 0; Frame_Buffer_Array : array (LCD_Layer, Nb_Frame_Buffers) of aliased Frame_Buffer with Volatile, Address => System'To_Address (16#D000_0000#); -- LCD Registers LCD_SLEEP_OUT : constant := 16#11#; -- Sleep out register LCD_GAMMA : constant := 16#26#; -- Gamma register LCD_DISPLAY_OFF : constant := 16#28#; -- Display off register LCD_DISPLAY_ON : constant := 16#29#; -- Display on register LCD_COLUMN_ADDR : constant := 16#2A#; -- Colomn address register LCD_PAGE_ADDR : constant := 16#2B#; -- Page address register LCD_GRAM : constant := 16#2C#; -- GRAM register LCD_MAC : constant := 16#36#; -- Memory Access Control register LCD_PIXEL_FORMAT : constant := 16#3A#; -- Pixel Format register LCD_WDB : constant := 16#51#; -- Write Brightness Display register LCD_WCD : constant := 16#53#; -- Write Control Display register LCD_RGB_INTERFACE : constant := 16#B0#; -- RGB Interface Signal Control LCD_FRC : constant := 16#B1#; -- Frame Rate Control register LCD_BPC : constant := 16#B5#; -- Blanking Porch Control register LCD_DFC : constant := 16#B6#; -- Display Function Control register LCD_POWER1 : constant := 16#C0#; -- Power Control 1 register LCD_POWER2 : constant := 16#C1#; -- Power Control 2 register LCD_VCOM1 : constant := 16#C5#; -- VCOM Control 1 register LCD_VCOM2 : constant := 16#C7#; -- VCOM Control 2 register LCD_POWERA : constant := 16#CB#; -- Power control A register LCD_POWERB : constant := 16#CF#; -- Power control B register LCD_PGAMMA : constant := 16#E0#; -- Positive Gamma Correction register LCD_NGAMMA : constant := 16#E1#; -- Negative Gamma Correction register LCD_DTCA : constant := 16#E8#; -- Driver timing control A LCD_DTCB : constant := 16#EA#; -- Driver timing control B LCD_POWER_SEQ : constant := 16#ED#; -- Power on sequence register LCD_3GAMMA_EN : constant := 16#F2#; -- 3 Gamma enable register LCD_INTERFACE : constant := 16#F6#; -- Interface control register LCD_PRC : constant := 16#F7#; -- Pump ratio control register end STM32F4.LCD;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 8 -- -- -- -- S p e c -- -- -- -- $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 Types; use Types; package Sem_Ch8 is ----------------------------------- -- Handling extensions of System -- ----------------------------------- -- For targets that define a much larger System package than given in -- the RM, we use a child package containing additional declarations, -- which is loaded when needed, and whose entities are conceptually -- within System itself. The presence of this auxiliary package is -- controlled with the pragma Extend_System. The following variable -- holds the entity of the auxiliary package, to simplify the special -- visibility rules that apply to it. System_Aux_Id : Entity_Id := Empty; ----------------- -- Subprograms -- ----------------- procedure Analyze_Exception_Renaming (N : Node_Id); procedure Analyze_Expanded_Name (N : Node_Id); procedure Analyze_Generic_Function_Renaming (N : Node_Id); procedure Analyze_Generic_Package_Renaming (N : Node_Id); procedure Analyze_Generic_Procedure_Renaming (N : Node_Id); procedure Analyze_Object_Renaming (N : Node_Id); procedure Analyze_Package_Renaming (N : Node_Id); procedure Analyze_Subprogram_Renaming (N : Node_Id); procedure Analyze_Use_Package (N : Node_Id); procedure Analyze_Use_Type (N : Node_Id); function Applicable_Use (Pack_Name : Node_Id) return Boolean; -- Common code to Use_One_Package and Set_Use, to determine whether -- use clause must be processed. Pack_Name is an entity name that -- references the package in question. procedure End_Scope; -- Called at end of scope. On exit from blocks and bodies (subprogram, -- package, task, and protected bodies), the name of the current scope -- must be removed from the scope stack, and the local entities must be -- removed from their homonym chains. On exit from record declarations, -- from package specifications, and from tasks and protected type -- specifications, more specialized procedures are invoked. procedure End_Use_Clauses (Clause : Node_Id); -- Invoked on scope exit, to undo the effect of local use clauses. U is -- the first Use clause of a scope being exited. This can be the current -- scope, or some enclosing scopes when building a clean environment to -- compile an instance body for inlining. procedure End_Use_Package (N : Node_Id); procedure End_Use_Type (N : Node_Id); -- Subsidiaries of End_Use_Clauses. Also called directly for use clauses -- appearing in context clauses. procedure Find_Direct_Name (N : Node_Id); -- Given a direct name (Identifier or Operator_Symbol), this routine -- scans the homonym chain for the name searching for corresponding -- visible entities to find the referenced entity (or in the case of -- overloading), entities. On return, the Entity, and Etype fields -- are set. In the non-overloaded case, these are the correct final -- entries. In the overloaded case, Is_Overloaded is set, Etype and -- Entity refer to an arbitrary element of the overloads set, and -- an appropriate list of entries has been made in the overload -- interpretation table (to be disambiguated in the resolve phase). procedure Find_Expanded_Name (N : Node_Id); -- Selected component is known to be expanded name. Verify legality -- of selector given the scope denoted by prefix. procedure Find_Selected_Component (N : Node_Id); -- Resolve various cases of selected components, recognize expanded names procedure Find_Type (N : Node_Id); -- Perform name resolution, and verify that the name found is that of a -- type. On return the Entity and Etype fields of the node N are set -- appropriately. If it is an incomplete type whose full declaration has -- been seen, return the entity in the full declaration. Similarly, if -- the type is private, it has receivd a full declaration, and we are -- in the private part or body of the package, return the full -- declaration as well. Special processing for Class types as well. function Get_Full_View (T_Name : Entity_Id) return Entity_Id; -- If T_Name is an incomplete type and the full declaration has been -- seen, or is the name of a class_wide type whose root is incomplete. -- return the corresponding full declaration. function Has_Implicit_Operator (N : Node_Id) return Boolean; -- N is an expanded name whose selector is an operator name (eg P."+"). -- A declarative part contains an implicit declaration of an operator -- if it has a declaration of a type to which one of the predefined -- operators apply. The existence of this routine is an artifact of -- our implementation: a more straightforward but more space-consuming -- choice would be to make all inherited operators explicit in the -- symbol table. procedure Initialize; -- Initializes data structures used for visibility analysis. Must be -- called before analyzing each new main source program. procedure Install_Use_Clauses (Clause : Node_Id); -- applies the use clauses appearing in a given declarative part, -- when the corresponding scope has been placed back on the scope -- stack after unstacking to compile a different context (subunit or -- parent of generic body). function In_Open_Scopes (S : Entity_Id) return Boolean; -- S is the entity of a scope. This function determines if this scope -- is currently open (i.e. it appears somewhere in the scope stack). function Is_Appropriate_For_Record (T : Entity_Id) return Boolean; -- Prefix is appropriate for record if it is of a record type, or -- an access to such. function Is_Appropriate_For_Entry_Prefix (T : Entity_Id) return Boolean; -- True if it is of a task type, a protected type, or else an access -- to one of these types. procedure New_Scope (S : Entity_Id); -- Make new scope stack entry, pushing S, the entity for a scope -- onto the top of the scope table. The current setting of the scope -- suppress flags is saved for restoration on exit. procedure Pop_Scope; -- Remove top entry from scope stack, restoring the saved setting -- of the scope suppress flags. function Present_System_Aux (N : Node_Id := Empty) return Boolean; -- Return True if the auxiliary system file has been successfully loaded. -- Otherwise attempt to load it, using the name supplied by a previous -- Extend_System pragma, and report on the success of the load. -- If N is present, it is a selected component whose prefix is System, -- or else a with-clause on system. N is absent when the function is -- called to find the visibility of implicit operators. procedure Restore_Scope_Stack; procedure Save_Scope_Stack; -- These two procedures are called from Semantics, when a unit U1 is -- to be compiled in the course of the compilation of another unit U2. -- This happens whenever Rtsfind is called. U1, the unit retrieved by -- Rtsfind, must be compiled in its own context, and the current scope -- stack containing U2 and local scopes must be made unreachable. On -- return, the contents of the scope stack must be made accessible again. procedure Use_One_Package (P : Entity_Id; N : Node_Id); -- Make visible entities declarated in package P potentially use-visible -- in the current context. Also used in the analysis of subunits, when -- re-installing use clauses of parent units. N is the use_clause that -- names P (and possibly other packages). procedure Use_One_Type (Id : Node_Id; N : Node_Id); -- Id is the subtype mark from a use type clause. This procedure makes -- the primitive operators of the type potentially use-visible. -- N is the Use_Type_Clause that names Id. procedure Set_Use (L : List_Id); -- Find use clauses that are declarative items in a package declaration -- and set the potentially use-visible flags of imported entities before -- analyzing the corresponding package body. end Sem_Ch8;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_00A7 is pragma Preelaborate; Group_00A7 : aliased constant Core_Second_Stage := (16#00# .. 16#16# => -- A700 .. A716 (Modifier_Symbol, Neutral, Other, Other, Other, Alphabetic, (Case_Ignorable | Grapheme_Base => True, others => False)), 16#17# .. 16#1F# => -- A717 .. A71F (Modifier_Letter, Neutral, Other, A_Letter, O_Letter, Alphabetic, (Diacritic | Alphabetic | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False)), 16#20# .. 16#21# => -- A720 .. A721 (Modifier_Symbol, Neutral, Other, Other, Other, Alphabetic, (Diacritic | Case_Ignorable | Grapheme_Base => True, others => False)), 16#22# => -- A722 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#23# => -- A723 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#24# => -- A724 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#25# => -- A725 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#26# => -- A726 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#27# => -- A727 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#28# => -- A728 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#29# => -- A729 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#2A# => -- A72A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2B# => -- A72B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#2C# => -- A72C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2D# => -- A72D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#2E# => -- A72E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#2F# => -- A72F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#30# .. 16#31# => -- A730 .. A731 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#32# => -- A732 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#33# => -- A733 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#34# => -- A734 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#35# => -- A735 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#36# => -- A736 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#37# => -- A737 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#38# => -- A738 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#39# => -- A739 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#3A# => -- A73A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3B# => -- A73B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#3C# => -- A73C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3D# => -- A73D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#3E# => -- A73E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#3F# => -- A73F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#40# => -- A740 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#41# => -- A741 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#42# => -- A742 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#43# => -- A743 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#44# => -- A744 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#45# => -- A745 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#46# => -- A746 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#47# => -- A747 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#48# => -- A748 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#49# => -- A749 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#4A# => -- A74A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4B# => -- A74B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#4C# => -- A74C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4D# => -- A74D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#4E# => -- A74E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#4F# => -- A74F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#50# => -- A750 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#51# => -- A751 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#52# => -- A752 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#53# => -- A753 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#54# => -- A754 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#55# => -- A755 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#56# => -- A756 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#57# => -- A757 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#58# => -- A758 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#59# => -- A759 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#5A# => -- A75A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5B# => -- A75B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#5C# => -- A75C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5D# => -- A75D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#5E# => -- A75E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#5F# => -- A75F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#60# => -- A760 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#61# => -- A761 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#62# => -- A762 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#63# => -- A763 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#64# => -- A764 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#65# => -- A765 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#66# => -- A766 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#67# => -- A767 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#68# => -- A768 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#69# => -- A769 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#6A# => -- A76A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6B# => -- A76B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#6C# => -- A76C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6D# => -- A76D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#6E# => -- A76E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#6F# => -- A76F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#70# => -- A770 (Modifier_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Other_Lowercase | Alphabetic | Cased | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#71# .. 16#78# => -- A771 .. A778 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#79# => -- A779 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7A# => -- A77A (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#7B# => -- A77B (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7C# => -- A77C (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#7D# .. 16#7E# => -- A77D .. A77E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#7F# => -- A77F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#80# => -- A780 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#81# => -- A781 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#82# => -- A782 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#83# => -- A783 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#84# => -- A784 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#85# => -- A785 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#86# => -- A786 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#87# => -- A787 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#88# => -- A788 (Modifier_Letter, Neutral, Other, A_Letter, O_Letter, Alphabetic, (Diacritic | Alphabetic | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False)), 16#89# .. 16#8A# => -- A789 .. A78A (Modifier_Symbol, Neutral, Other, Other, Other, Alphabetic, (Case_Ignorable | Grapheme_Base => True, others => False)), 16#8B# => -- A78B (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#8C# => -- A78C (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#8D# => -- A78D (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#8E# => -- A78E (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#90# => -- A790 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#91# => -- A791 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#92# => -- A792 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#93# => -- A793 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#94# .. 16#95# => -- A794 .. A795 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#96# => -- A796 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#97# => -- A797 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#98# => -- A798 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#99# => -- A799 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#9A# => -- A79A (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9B# => -- A79B (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#9C# => -- A79C (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9D# => -- A79D (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#9E# => -- A79E (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9F# => -- A79F (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A0# => -- A7A0 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A1# => -- A7A1 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A2# => -- A7A2 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A3# => -- A7A3 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A4# => -- A7A4 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A5# => -- A7A5 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A6# => -- A7A6 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A7# => -- A7A7 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#A8# => -- A7A8 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#A9# => -- A7A9 (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Changes_When_Uppercased | Changes_When_Titlecased | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#AA# .. 16#AD# => -- A7AA .. A7AD (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#B0# .. 16#B1# => -- A7B0 .. A7B1 (Uppercase_Letter, Neutral, Other, A_Letter, Upper, Alphabetic, (Alphabetic | Cased | Changes_When_Lowercased | Changes_When_Casefolded | Changes_When_Casemapped | Grapheme_Base | ID_Continue | ID_Start | Uppercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#F7# => -- A7F7 (Other_Letter, Neutral, Other, A_Letter, O_Letter, Alphabetic, (Alphabetic | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False)), 16#F8# .. 16#F9# => -- A7F8 .. A7F9 (Modifier_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Diacritic | Other_Lowercase | Alphabetic | Cased | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#FA# => -- A7FA (Lowercase_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Alphabetic | Cased | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start => True, others => False)), 16#FB# .. 16#FF# => -- A7FB .. A7FF (Other_Letter, Neutral, Other, A_Letter, O_Letter, Alphabetic, (Alphabetic | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False)), others => (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False))); end Matreshka.Internals.Unicode.Ucd.Core_00A7;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O . A U X -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- 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, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package provides support routines for both Ada.Text_IO and -- Ada.Streams.Stream_IO (the latter basically borrows the Ada.Text_IO -- file interface). with Ada.Streams; with System.Unsigned_Types; private package Ada.Text_Io.Aux is Standard_In : aliased File_Type; Standard_Out : aliased File_Type; Standard_Err : aliased File_Type; Current_In : aliased File_Type; Current_Out : aliased File_Type; Current_Err : aliased File_Type; The_File : File_Type; subtype LLF is Long_Long_Float; subtype LLI is Long_Long_Integer; subtype LLU is System.Unsigned_Types.Long_Long_Unsigned; --------------------- -- File Management -- --------------------- procedure Create (File : in out File_Type; Mode : in File_Mode := Out_File; Name : in String := ""; Form : in String := ""); procedure Open (File : in out File_Type; Mode : in File_Mode; Name : in String; Form : in String := ""); procedure Close (File : in out File_Type); procedure Delete (File : in out File_Type); procedure Reset (File : in out File_Type; Mode : in File_Mode); function Mode (File : in File_Type) return File_Mode; function Name (File : in File_Type) return String; function Form (File : in File_Type) return String; function Is_Open (File : in File_Type) return Boolean; -------------------- -- Buffer Control -- -------------------- procedure Flush (File : File_Type); ------------------------------------------------------ -- Control of default input, output and error files -- ------------------------------------------------------ procedure Set_Input (File : in File_Type); procedure Set_Output (File : in File_Type); procedure Set_Error (File : in File_Type); function Standard_Input return File_Type; function Standard_Output return File_Type; function Standard_Error return File_Type; function Current_Input return File_Type; function Current_Output return File_Type; function Current_Error return File_Type; -------------------------------------------- -- Specification of line and page lengths -- -------------------------------------------- procedure Set_Line_Length (File : in File_Type; To : in Count); procedure Set_Page_Length (File : in File_Type; To : in Count); function Line_Length (File : in File_Type) return Count; function Page_Length (File : in File_Type) return Count; ------------------------------------ -- Column, Line, and Page Control -- ------------------------------------ procedure New_Line (File : in File_Type; Spacing : in Positive_Count := 1); procedure Skip_Line (File : in File_Type; Spacing : in Positive_Count := 1); function End_Of_Line (File : in File_Type) return Boolean; procedure New_Page (File : in File_Type); procedure Skip_Page (File : in File_Type); function End_Of_Page (File : in File_Type) return boolean; function End_Of_File (File : in File_Type) return boolean; procedure Set_Col (File : in File_Type; To : in Positive_Count); procedure Set_Line (File : in File_Type; To : in Positive_Count); function Col (File : in File_Type) return Positive_Count; function Line (File : in File_Type) return Positive_Count; function Page (File : in File_Type) return Positive_Count; ----------------------------- -- Characters Input-Output -- ----------------------------- procedure Get (Item : out Character); procedure Put (Item : in Character); procedure Look_Ahead (Item : out Character; End_Of_Line : out Boolean); procedure Get_Immediate (Item : out Character); procedure Get_Immediate (Item : out Character; Available : out Boolean); -------------------------- -- Strings Input-Output -- -------------------------- procedure Get (Item : out String); procedure Put (Item : in String); procedure Get_Line (File : in File_Type; Item : out String; Last : out Natural); procedure Put_Line (File : in File_Type; Item : in String); ------------------------- -- Stream Input-Output -- ------------------------- -- Used to support stream operations when text files are treated as -- streams (either through use of Text_IO.Text_Streams, or when the -- Text_IO package is used to support Stream_IO directly. procedure Read (File : in File_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (File : in File_Type; Item : in Ada.Streams.Stream_Element_Array); ----------------------------------- -- Input-Output of Integer Types -- ----------------------------------- procedure Get_Int (Item : out Integer; Width : in Field := 0); procedure Put_Integer (Item : in Integer; Width : in Field; Base : in Number_Base); procedure Put_LLI (Item : in LLI; Width : in Field; Base : in Number_Base); procedure Get_LLI (From : in String; Item : out LLI; Last : out Positive; Size : in Positive); procedure Get_LLU (From : in String; Item : out LLU; Last : out Positive; Size : in Positive); procedure Put_Integer (To : out String; Item : in Integer; Base : in Number_Base); procedure Put_LLI (To : out String; Item : in LLI; Base : in Number_Base); ----------------------------------- -- Input-Output of Modular Types -- ----------------------------------- procedure Put_Unsigned (Item : in System.Unsigned_Types.Unsigned; Width : in Field; Base : in Number_Base); procedure Put_LLU (Item : in LLU; Width : in Field; Base : in Number_Base); procedure Put_Unsigned (To : out String; Item : in System.Unsigned_Types.Unsigned; Base : in Number_Base); procedure Put_LLU (To : out String; Item : in LLU; Base : in Number_Base); ----------------------------------- -- Input-Output of Float Types -- ----------------------------------- procedure Get_Float (Item : out LLF; Width : in Field); procedure Put_Float (Item : in LLF; Fore : in Field; Aft : in Field; Exp : in Field); procedure Get_Float (From : in String; Item : out LLF; Last : out Positive); procedure Put_Float (To : out String; Item : in LLF; Aft : in Field; Exp : in Field); --------------------------------------- -- Input-Output of Enumeration Types -- --------------------------------------- procedure Get_Enum (Str : out String; Len : out Positive); procedure Get_Enum (Str : out String; From : in String; Len : out Positive; Last : out Positive); procedure Put_Enum (Item : in String; Width : in Field; Set : in Type_Set); procedure Put_Enum (To : out String; Item : in String; Set : in Type_Set); end Ada.Text_Io.Aux;
-- Copyright (c) 2020 Bartek thindil Jasicki <thindil@laeran.pl> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; use Interfaces.C.Strings; with Tashy2; use Tashy2; package body Tcl.Variables is -- ****if* Variables/Variables.Create_Flag -- FUNCTION -- Create C flag for the manipulating Tcl variables -- PARAMETERS -- Flags - Ada array with flags which will be added to the Tcl variable -- manipulation subprogram -- RESULT -- C flag from the selected array -- HISTORY -- 8.6.0 - Added -- SOURCE function Create_Flag(Flags: Flags_Array) return int is -- **** type Unsigned_Integer is mod 4_096; Default_Unsigned_Integer: constant Unsigned_Integer := 0; Flag: Unsigned_Integer := Default_Unsigned_Integer; begin Set_Flags_Loop : for Value of Flags loop Flag := Flag or Variables_Flags'Enum_Rep(Value); end loop Set_Flags_Loop; return int(Flag); end Create_Flag; function Tcl_Set_Var (Var_Name, New_Value: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Boolean is function Tcl_Set_Var_C (Interp: Tcl_Interpreter; Var_Name_C, New_Value_C: chars_ptr; Flags_C: int) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Tcl_SetVar"; Result: constant String := From_C_String (Item => Tcl_Set_Var_C (Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name), New_Value_C => To_C_String(Str => New_Value), Flags_C => Create_Flag(Flags => Flags))); begin if Result'Length = 0 then return False; end if; return True; end Tcl_Set_Var; function Tcl_Set_Var2 (Array_Name, Index_Name, New_Value: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Boolean is function Tcl_Set_Var2_C (Interp: Tcl_Interpreter; Name1, Name2, New_Value_C: chars_ptr; Flags_C: int) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Tcl_SetVar2"; Result: constant String := From_C_String (Item => Tcl_Set_Var2_C (Interp => Interpreter, Name1 => To_C_String(Str => Array_Name), Name2 => To_C_String(Str => Index_Name), New_Value_C => To_C_String(Str => New_Value), Flags_C => Create_Flag(Flags => Flags))); begin if Result'Length = 0 then return False; end if; return True; end Tcl_Set_Var2; function Tcl_Get_Var (Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return String is function Tcl_Get_Var_C (Interp: Tcl_Interpreter; Var_Name_C: chars_ptr; Flags_C: int) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Tcl_GetVar"; Result: constant chars_ptr := Tcl_Get_Var_C (Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name), Flags_C => Create_Flag(Flags => Flags)); begin if Result = Null_Ptr then return ""; end if; return From_C_String(Item => Result); end Tcl_Get_Var; function Generic_Scalar_Tcl_Get_Var (Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Result_Type is begin return Result_Type'Value (Tcl_Get_Var (Var_Name => Var_Name, Interpreter => Interpreter, Flags => Flags)); end Generic_Scalar_Tcl_Get_Var; function Generic_Float_Tcl_Get_Var (Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Result_Type is begin return Result_Type'Value (Tcl_Get_Var (Var_Name => Var_Name, Interpreter => Interpreter, Flags => Flags)); end Generic_Float_Tcl_Get_Var; function Tcl_Get_Var2 (Var_Name, Index_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return String is function Tcl_Get_Var2_C (Interp: Tcl_Interpreter; Var_Name_C, Index_Name_C: chars_ptr; Flags_C: int) return chars_ptr with Global => null, Import, Convention => C, External_Name => "Tcl_GetVar2"; Result: constant chars_ptr := Tcl_Get_Var2_C (Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name), Index_Name_C => To_C_String(Str => Index_Name), Flags_C => Create_Flag(Flags => Flags)); begin if Result = Null_Ptr then return ""; end if; return From_C_String(Item => Result); end Tcl_Get_Var2; function Generic_Scalar_Tcl_Get_Var2 (Var_Name, Index_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Result_Type is begin return Result_Type'Value (Tcl_Get_Var2 (Var_Name => Var_Name, Index_Name => Index_Name, Interpreter => Interpreter, Flags => Flags)); end Generic_Scalar_Tcl_Get_Var2; function Generic_Float_Tcl_Get_Var2 (Var_Name, Index_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Result_Type is begin return Result_Type'Value (Tcl_Get_Var2 (Var_Name => Var_Name, Index_Name => Index_Name, Interpreter => Interpreter, Flags => Flags)); end Generic_Float_Tcl_Get_Var2; function Tcl_Unset_Var (Var_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Boolean is function Tcl_Unset_Var_C (Interp: Tcl_Interpreter; Var_Name_C: chars_ptr; Flags_C: int) return int with Global => null, Import, Convention => C, External_Name => "Tcl_UnsetVar"; begin if Tcl_Unset_Var_C (Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name), Flags_C => Create_Flag(Flags => Flags)) = int(Tcl_Results'Enum_Rep(TCL_ERROR)) then return False; end if; return True; end Tcl_Unset_Var; function Tcl_Unset_Var2 (Var_Name, Index_Name: String; Interpreter: Tcl_Interpreter := Get_Interpreter; Flags: Flags_Array := Default_Flags_Array) return Boolean is function Tcl_Unset_Var2_C (Interp: Tcl_Interpreter; Var_Name_C, Index_Name_C: chars_ptr; Flags_C: int) return int with Global => null, Import, Convention => C, External_Name => "Tcl_UnsetVar2"; begin if Tcl_Unset_Var2_C (Interp => Interpreter, Var_Name_C => To_C_String(Str => Var_Name), Index_Name_C => To_C_String(Str => Index_Name), Flags_C => Create_Flag(Flags => Flags)) = int(Tcl_Results'Enum_Rep(TCL_ERROR)) then return False; end if; return True; end Tcl_Unset_Var2; end Tcl.Variables;