repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
procrastiraptor/euler | Ada | 253 | adb | with Ada.Integer_Text_IO;
procedure Euler1 is
Sum: Integer := 0;
begin
for I in Integer range 1 .. 999 loop
if I mod 3 = 0 or I mod 5 = 0 then
Sum := Sum + I;
end if;
end loop;
Ada.Integer_Text_IO.Put(Sum);
end Euler1;
|
OneWingedShark/Byron | Ada | 819 | adb | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
Procedure Lexington.Aux.P13(Data : in out Token_Vector_Pkg.Vector) is
Procedure Make_Literal(Position : Token_Vector_Pkg.Cursor) is
Package TVP renames Token_Vector_Pkg;
This : Token renames TVP.Element( Position );
This_ID : Token_ID renames Token_Pkg.ID(This);
This_Value : Wide_Wide_String renames Token_Pkg.Lexeme( This );
begin
if This_ID = Text then
declare
I : Integer renames Integer'Wide_Wide_Value( This_Value );
begin
Data.Replace_Element( Position, Token_Pkg.Make_Token(li_Integer, This_Value) );
end;
end if;
exception
when Constraint_Error => Null;
End Make_Literal;
Begin
Data.Iterate( Make_Literal'Access );
End Lexington.Aux.P13;
|
AdaCore/Ada_Drivers_Library | Ada | 15,897 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
--
-- * Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- * Neither the name of Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.TIMER is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Capture Timer value to CC[n] registers.
-- Capture Timer value to CC[n] registers.
type TASKS_CAPTURE_Registers is array (0 .. 3) of HAL.UInt32;
-- Compare event on CC[n] match.
-- Compare event on CC[n] match.
type EVENTS_COMPARE_Registers is array (0 .. 3) of HAL.UInt32;
-- Shortcut between CC[0] event and the CLEAR task.
type SHORTS_COMPARE0_CLEAR_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE0_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[1] event and the CLEAR task.
type SHORTS_COMPARE1_CLEAR_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE1_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[2] event and the CLEAR task.
type SHORTS_COMPARE2_CLEAR_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE2_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[3] event and the CLEAR task.
type SHORTS_COMPARE3_CLEAR_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE3_CLEAR_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[0] event and the STOP task.
type SHORTS_COMPARE0_STOP_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE0_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[1] event and the STOP task.
type SHORTS_COMPARE1_STOP_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE1_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[2] event and the STOP task.
type SHORTS_COMPARE2_STOP_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE2_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcut between CC[3] event and the STOP task.
type SHORTS_COMPARE3_STOP_Field is
(-- Shortcut disabled.
Disabled,
-- Shortcut enabled.
Enabled)
with Size => 1;
for SHORTS_COMPARE3_STOP_Field use
(Disabled => 0,
Enabled => 1);
-- Shortcuts for Timer.
type SHORTS_Register is record
-- Shortcut between CC[0] event and the CLEAR task.
COMPARE0_CLEAR : SHORTS_COMPARE0_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[1] event and the CLEAR task.
COMPARE1_CLEAR : SHORTS_COMPARE1_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[2] event and the CLEAR task.
COMPARE2_CLEAR : SHORTS_COMPARE2_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[3] event and the CLEAR task.
COMPARE3_CLEAR : SHORTS_COMPARE3_CLEAR_Field := NRF_SVD.TIMER.Disabled;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Shortcut between CC[0] event and the STOP task.
COMPARE0_STOP : SHORTS_COMPARE0_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[1] event and the STOP task.
COMPARE1_STOP : SHORTS_COMPARE1_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[2] event and the STOP task.
COMPARE2_STOP : SHORTS_COMPARE2_STOP_Field := NRF_SVD.TIMER.Disabled;
-- Shortcut between CC[3] event and the STOP task.
COMPARE3_STOP : SHORTS_COMPARE3_STOP_Field := NRF_SVD.TIMER.Disabled;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SHORTS_Register use record
COMPARE0_CLEAR at 0 range 0 .. 0;
COMPARE1_CLEAR at 0 range 1 .. 1;
COMPARE2_CLEAR at 0 range 2 .. 2;
COMPARE3_CLEAR at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
COMPARE0_STOP at 0 range 8 .. 8;
COMPARE1_STOP at 0 range 9 .. 9;
COMPARE2_STOP at 0 range 10 .. 10;
COMPARE3_STOP at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- Enable interrupt on COMPARE[0]
type INTENSET_COMPARE0_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_COMPARE0_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on COMPARE[0]
type INTENSET_COMPARE0_Field_1 is
(-- Reset value for the field
Intenset_Compare0_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_COMPARE0_Field_1 use
(Intenset_Compare0_Field_Reset => 0,
Set => 1);
-- INTENSET_COMPARE array
type INTENSET_COMPARE_Field_Array is array (0 .. 3)
of INTENSET_COMPARE0_Field_1
with Component_Size => 1, Size => 4;
-- Type definition for INTENSET_COMPARE
type INTENSET_COMPARE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPARE as a value
Val : HAL.UInt4;
when True =>
-- COMPARE as an array
Arr : INTENSET_COMPARE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for INTENSET_COMPARE_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Interrupt enable set register.
type INTENSET_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Enable interrupt on COMPARE[0]
COMPARE : INTENSET_COMPARE_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
Reserved_0_15 at 0 range 0 .. 15;
COMPARE at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Disable interrupt on COMPARE[0]
type INTENCLR_COMPARE0_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_COMPARE0_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on COMPARE[0]
type INTENCLR_COMPARE0_Field_1 is
(-- Reset value for the field
Intenclr_Compare0_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_COMPARE0_Field_1 use
(Intenclr_Compare0_Field_Reset => 0,
Clear => 1);
-- INTENCLR_COMPARE array
type INTENCLR_COMPARE_Field_Array is array (0 .. 3)
of INTENCLR_COMPARE0_Field_1
with Component_Size => 1, Size => 4;
-- Type definition for INTENCLR_COMPARE
type INTENCLR_COMPARE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPARE as a value
Val : HAL.UInt4;
when True =>
-- COMPARE as an array
Arr : INTENCLR_COMPARE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 4;
for INTENCLR_COMPARE_Field use record
Val at 0 range 0 .. 3;
Arr at 0 range 0 .. 3;
end record;
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Disable interrupt on COMPARE[0]
COMPARE : INTENCLR_COMPARE_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_20_31 : HAL.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
Reserved_0_15 at 0 range 0 .. 15;
COMPARE at 0 range 16 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
-- Select Normal or Counter mode.
type MODE_MODE_Field is
(-- Timer in Normal mode.
Timer,
-- Timer in Counter mode.
Counter)
with Size => 1;
for MODE_MODE_Field use
(Timer => 0,
Counter => 1);
-- Timer Mode selection.
type MODE_Register is record
-- Select Normal or Counter mode.
MODE : MODE_MODE_Field := NRF_SVD.TIMER.Timer;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for MODE_Register use record
MODE at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- Sets timer behaviour ro be like the implementation of a timer with width
-- as indicated.
type BITMODE_BITMODE_Field is
(-- 16-bit timer behaviour.
Val_16Bit,
-- 8-bit timer behaviour.
Val_08Bit,
-- 24-bit timer behaviour.
Val_24Bit,
-- 32-bit timer behaviour.
Val_32Bit)
with Size => 2;
for BITMODE_BITMODE_Field use
(Val_16Bit => 0,
Val_08Bit => 1,
Val_24Bit => 2,
Val_32Bit => 3);
-- Sets timer behaviour.
type BITMODE_Register is record
-- Sets timer behaviour ro be like the implementation of a timer with
-- width as indicated.
BITMODE : BITMODE_BITMODE_Field := NRF_SVD.TIMER.Val_16Bit;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BITMODE_Register use record
BITMODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype PRESCALER_PRESCALER_Field is HAL.UInt4;
-- 4-bit prescaler to source clock frequency (max value 9). Source clock
-- frequency is divided by 2^SCALE.
type PRESCALER_Register is record
-- Timer PRESCALER value. Max value is 9.
PRESCALER : PRESCALER_PRESCALER_Field := 16#4#;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for PRESCALER_Register use record
PRESCALER at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Capture/compare registers.
-- Capture/compare registers.
type CC_Registers is array (0 .. 3) of HAL.UInt32;
-- Peripheral power control.
type POWER_POWER_Field is
(-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF_SVD.TIMER.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Timer 0.
type TIMER_Peripheral is record
-- Start Timer.
TASKS_START : aliased HAL.UInt32;
-- Stop Timer.
TASKS_STOP : aliased HAL.UInt32;
-- Increment Timer (In counter mode).
TASKS_COUNT : aliased HAL.UInt32;
-- Clear timer.
TASKS_CLEAR : aliased HAL.UInt32;
-- Shutdown timer.
TASKS_SHUTDOWN : aliased HAL.UInt32;
-- Capture Timer value to CC[n] registers.
TASKS_CAPTURE : aliased TASKS_CAPTURE_Registers;
-- Compare event on CC[n] match.
EVENTS_COMPARE : aliased EVENTS_COMPARE_Registers;
-- Shortcuts for Timer.
SHORTS : aliased SHORTS_Register;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- Timer Mode selection.
MODE : aliased MODE_Register;
-- Sets timer behaviour.
BITMODE : aliased BITMODE_Register;
-- 4-bit prescaler to source clock frequency (max value 9). Source clock
-- frequency is divided by 2^SCALE.
PRESCALER : aliased PRESCALER_Register;
-- Capture/compare registers.
CC : aliased CC_Registers;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for TIMER_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#4# range 0 .. 31;
TASKS_COUNT at 16#8# range 0 .. 31;
TASKS_CLEAR at 16#C# range 0 .. 31;
TASKS_SHUTDOWN at 16#10# range 0 .. 31;
TASKS_CAPTURE at 16#40# range 0 .. 127;
EVENTS_COMPARE at 16#140# range 0 .. 127;
SHORTS at 16#200# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
MODE at 16#504# range 0 .. 31;
BITMODE at 16#508# range 0 .. 31;
PRESCALER at 16#510# range 0 .. 31;
CC at 16#540# range 0 .. 127;
POWER at 16#FFC# range 0 .. 31;
end record;
-- Timer 0.
TIMER0_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER0_Base;
-- Timer 1.
TIMER1_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER1_Base;
-- Timer 2.
TIMER2_Periph : aliased TIMER_Peripheral
with Import, Address => TIMER2_Base;
end NRF_SVD.TIMER;
|
reznikmm/matreshka | Ada | 3,666 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with League.Holders.Generic_Holders;
package AMF.DG.Holders.Gradient_Stops is
new League.Holders.Generic_Holders
(AMF.DG.DG_Gradient_Stop);
pragma Preelaborate (AMF.DG.Holders.Gradient_Stops);
|
reznikmm/matreshka | Ada | 3,764 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Style_Font_Weight_Complex_Attributes is
pragma Preelaborate;
type ODF_Style_Font_Weight_Complex_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Font_Weight_Complex_Attribute_Access is
access all ODF_Style_Font_Weight_Complex_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Font_Weight_Complex_Attributes;
|
micahwelf/FLTK-Ada | Ada | 531 | ads |
package FLTK.Images.RGB.JPEG is
type JPEG_Image is new RGB_Image with private;
type JPEG_Image_Reference (Data : not null access JPEG_Image'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(Filename : in String)
return JPEG_Image;
end Forge;
private
type JPEG_Image is new RGB_Image with null record;
overriding procedure Finalize
(This : in out JPEG_Image);
end FLTK.Images.RGB.JPEG;
|
reznikmm/matreshka | Ada | 4,015 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- 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 Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Horizontal;
package ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal.Internals is
function Create
(Node : Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Horizontal.Draw_End_Line_Spacing_Horizontal_Access)
return ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal.ODF_Draw_End_Line_Spacing_Horizontal;
function Wrap
(Node : Matreshka.ODF_Attributes.Draw.End_Line_Spacing_Horizontal.Draw_End_Line_Spacing_Horizontal_Access)
return ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal.ODF_Draw_End_Line_Spacing_Horizontal;
end ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal.Internals;
|
annexi-strayline/AURA | Ada | 11,634 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Core --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020-2023, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Assertions;
with Workers;
with Registrar.Registry;
with Registrar.Executive.Unit_Entry;
with Registrar.Registration.Unchecked_Deregister_Unit;
package body Registrar.Registration is
--
-- All Enter_Units simply fill and submit Work_Orders to the worker pool
--
----------------
-- Enter_Unit --
----------------
procedure Set_File_Name
(Order: out Executive.Unit_Entry.Unit_Entry_Order;
File : in Ada.Directories.Directory_Entry_Type)
is
begin
Executive.Unit_Entry.UBS.Set_Unbounded_String
(Target => Order.File_Full_Name,
Source => Ada.Directories.Full_Name (File));
end Set_File_Name;
----------------------------------------------------------------------------
-- Non-AURA units
procedure Enter_Unit (File: in Ada.Directories.Directory_Entry_Type) is
Order: Executive.Unit_Entry.Unit_Entry_Order
:= (Tracker => Entry_Progress'Access,
AURA => False,
others => <>);
begin
Set_File_Name (Order => Order, File => File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end Enter_Unit;
----------------------------------------------------------------------------
-- AURA units
procedure Enter_Unit
(File : in Ada.Directories.Directory_Entry_Type;
AURA_Subsystem: in Registrar.Subsystems.Subsystem)
is
Order: Executive.Unit_Entry.Unit_Entry_Order
:= (Tracker => Entry_Progress'Access,
AURA => True,
AURA_Subsystem => AURA_Subsystem,
others => <>);
begin
Set_File_Name (Order => Order, File => File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end Enter_Unit;
---------------------
-- Enter_Directory --
---------------------
procedure Enter_Directory
(Directory_Path: in String;
Order_Template: in Executive.Unit_Entry.Unit_Entry_Order)
is
use Ada.Directories;
Search: Search_Type;
File : Directory_Entry_Type;
Order: Executive.Unit_Entry.Unit_Entry_Order := Order_Template;
procedure Enter_Extension (Extension: in String) is
begin
Start_Search (Search => Search,
Directory => Directory_Path,
Pattern => "*." & Extension,
Filter => (Ordinary_File => True, others => False));
while More_Entries (Search) loop
Get_Next_Entry (Search => Search, Directory_Entry => File);
Set_File_Name (Order, File);
Entry_Progress.Increment_Total_Items;
Workers.Enqueue_Order (Order);
end loop;
End_Search (Search);
end Enter_Extension;
begin
Order.Tracker := Entry_Progress'Access;
Enter_Extension ("ads");
Enter_Extension ("adb");
Enter_Extension ("c");
end Enter_Directory;
--------------------------------------------------
procedure Enter_Directory
(Directory : in Ada.Directories.Directory_Entry_Type;
AURA_Subsystem: in Subsystems.Subsystem)
is
use Ada.Directories;
begin
Enter_Directory (Directory_Path => Full_Name (Directory),
Order_Template => (AURA => True,
AURA_Subsystem => AURA_Subsystem,
others => <>));
end Enter_Directory;
----------------
-- Enter_Root --
----------------
procedure Enter_Root is
use Ada.Directories;
begin
Enter_Directory (Directory_Path => Full_Name (Current_Directory),
Order_Template => (AURA => False,
others => <>));
end Enter_Root;
--------------------
-- Enter_All_AURA --
--------------------
procedure Enter_All_AURA is
use Ada.Directories;
AURA_Subsystem_Path: constant String :=
Compose (Containing_Directory => Current_Directory,
Name => "aura");
begin
pragma Assert (Exists (AURA_Subsystem_Path)
and then Kind (AURA_Subsystem_Path) = Directory);
-- Ensuring the 'aura' subdirectory exists is the responsibility of
-- the Scheduling subsystem. This provides more ergonomic error
-- reporting opportunities for the CLI, for what is possibly a common
-- error
Enter_Directory (Directory_Path => AURA_Subsystem_Path,
Order_Template => (AURA => False,
others => <>));
end Enter_All_AURA;
----------------------------
-- Request_AURA_Subsystem --
----------------------------
procedure Request_AURA_Subsystem (Name: in Unit_Names.Unit_Name;
OK : out Boolean)
is
use Subsystems;
package All_Subsystems renames Registry.All_Subsystems;
Requested_Subsys: constant Subsystem
:= (AURA => True,
Name => Name.Subsystem_Name,
State => Requested,
others => <>);
begin
if All_Subsystems.Contains_Element (Requested_Subsys) then
OK := All_Subsystems.Extract_Element(Requested_Subsys).AURA;
-- The registry already contains this subsystem. If it is not AURA
-- then that means the Root Project is already claiming this subsystem,
-- and therefore we can't aquire it.
--
-- Otherwise it's already been requested or aquired, and so no action
-- needs to be taken
else
-- Add it
All_Subsystems.Insert (New_Item => Requested_Subsys,
Inserted => OK);
pragma Assert (OK);
-- There are no cases where OK should be False. First of all, we
-- have already determined that it doesn't already exist in the set.
-- So if OK is False, this should mean it was inserted sometime between
-- that check and our attempt. That shouldn't happen because
-- Request_AURA_Subsystem should only be called from the CLI driver
-- before any work orders are executing.
end if;
end Request_AURA_Subsystem;
----------------------
-- Update_Subsystem --
----------------------
procedure Update_Subsystem (Update: Subsystems.Subsystem) is
begin
Registry.All_Subsystems.Replace (Update);
end Update_Subsystem;
-------------------------
-- Update_Library_Unit --
-------------------------
procedure Update_Library_Unit (Update: in Library_Units.Library_Unit) is
begin
Registry.All_Library_Units.Replace (Update);
end Update_Library_Unit;
--------------------------------
-- Update_Library_Unit_Subset --
--------------------------------
procedure Update_Library_Unit_Subset
(Update: in Library_Units.Library_Unit_Sets.Set) is
begin
if not Registry.All_Library_Units.Is_Subset (Update) then
raise Constraint_Error with
"Update_Library_Unit_Subset cannot add new units";
end if;
Registry.All_Library_Units.Include_Subset (Update);
end Update_Library_Unit_Subset;
-----------------------
-- Exclude_Manifests --
-----------------------
procedure Exclude_Manifests is
use Unit_Names;
use Library_Units;
Manifest: Library_Unit;
begin
for Subsys of Registry.All_Subsystems.Extract_Set loop
Manifest.Name := Subsys.Name & ".aura";
if Registry.All_Library_Units.Contains_Element (Manifest) then
Manifest := Registry.All_Library_Units.Extract_Element (Manifest);
Registrar.Registration.Unchecked_Deregister_Unit (Manifest);
end if;
end loop;
end Exclude_Manifests;
end Registrar.Registration;
|
reznikmm/matreshka | Ada | 7,106 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- 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_01F1 is
pragma Preelaborate;
Group_01F1 : aliased constant Core_Second_Stage
:= (16#00# .. 16#0A# => -- 01F100 .. 01F10A
(Other_Number, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#0B# .. 16#0C# => -- 01F10B .. 01F10C
(Other_Number, Neutral,
Other, Other, Other, Ambiguous,
(Grapheme_Base => True,
others => False)),
16#10# .. 16#2D# => -- 01F110 .. 01F12D
(Other_Symbol, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#2E# => -- 01F12E
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#30# .. 16#49# => -- 01F130 .. 01F149
(Other_Symbol, Ambiguous,
Other, A_Letter, Upper, Ambiguous,
(Other_Alphabetic
| Other_Uppercase
| Alphabetic
| Cased
| Grapheme_Base
| Uppercase
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#4A# .. 16#4F# => -- 01F14A .. 01F14F
(Other_Symbol, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#50# .. 16#69# => -- 01F150 .. 01F169
(Other_Symbol, Ambiguous,
Other, A_Letter, Upper, Ambiguous,
(Other_Alphabetic
| Other_Uppercase
| Alphabetic
| Cased
| Grapheme_Base
| Uppercase => True,
others => False)),
16#6A# .. 16#6B# => -- 01F16A .. 01F16B
(Other_Symbol, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#70# .. 16#89# => -- 01F170 .. 01F189
(Other_Symbol, Ambiguous,
Other, A_Letter, Upper, Ambiguous,
(Other_Alphabetic
| Other_Uppercase
| Alphabetic
| Cased
| Grapheme_Base
| Uppercase => True,
others => False)),
16#8A# .. 16#8F# => -- 01F18A .. 01F18F
(Other_Symbol, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base => True,
others => False)),
16#90# => -- 01F190
(Other_Symbol, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base
| Changes_When_NFKC_Casefolded => True,
others => False)),
16#91# .. 16#9A# => -- 01F191 .. 01F19A
(Other_Symbol, Ambiguous,
Other, Other, Other, Ambiguous,
(Grapheme_Base => True,
others => False)),
16#E6# .. 16#FF# => -- 01F1E6 .. 01F1FF
(Other_Symbol, Neutral,
Regional_Indicator, Regional_Indicator, Other, Regional_Indicator,
(Grapheme_Base => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_01F1;
|
Fabien-Chouteau/samd51-hal | Ada | 7,195 | ads | with System; use System;
with SAM.TC; use SAM.TC;
with SAM.SERCOM.USART; use SAM.SERCOM.USART;
with SAM.SERCOM.SPI; use SAM.SERCOM.SPI;
with SAM.SERCOM.I2C; use SAM.SERCOM.I2C;
with SAM.SERCOM; use SAM.SERCOM;
with SAM.Port; use SAM.Port;
with SAM.ADC; use SAM.ADC;
-- Generated by a script from an "avr tools device file" (atdf)
package SAM.Device is
-- ADC0 --
ADC0_Internal : aliased SAM.ADC.ADC_Internal
with Import, Address => System'To_Address (16#43001C00#);
ADC0 : aliased SAM.ADC.ADC_Device (ADC0_Internal'Access);
-- ADC1 --
ADC1_Internal : aliased SAM.ADC.ADC_Internal
with Import, Address => System'To_Address (16#43002000#);
ADC1 : aliased SAM.ADC.ADC_Device (ADC1_Internal'Access);
-- PORTA --
PORTA_Internal : aliased Port_Internal
with Import, Address => System'To_Address (16#41008000# + 16#000#);
PORTA : aliased Port_Controller (PORTA_Internal'Access);
PA00 : aliased GPIO_Point (PORTA'Access, 0);
PA01 : aliased GPIO_Point (PORTA'Access, 1);
PA02 : aliased GPIO_Point (PORTA'Access, 2);
PA03 : aliased GPIO_Point (PORTA'Access, 3);
PA04 : aliased GPIO_Point (PORTA'Access, 4);
PA05 : aliased GPIO_Point (PORTA'Access, 5);
PA06 : aliased GPIO_Point (PORTA'Access, 6);
PA07 : aliased GPIO_Point (PORTA'Access, 7);
PA08 : aliased GPIO_Point (PORTA'Access, 8);
PA09 : aliased GPIO_Point (PORTA'Access, 9);
PA10 : aliased GPIO_Point (PORTA'Access, 10);
PA11 : aliased GPIO_Point (PORTA'Access, 11);
PA12 : aliased GPIO_Point (PORTA'Access, 12);
PA13 : aliased GPIO_Point (PORTA'Access, 13);
PA14 : aliased GPIO_Point (PORTA'Access, 14);
PA15 : aliased GPIO_Point (PORTA'Access, 15);
PA16 : aliased GPIO_Point (PORTA'Access, 16);
PA17 : aliased GPIO_Point (PORTA'Access, 17);
PA18 : aliased GPIO_Point (PORTA'Access, 18);
PA19 : aliased GPIO_Point (PORTA'Access, 19);
PA20 : aliased GPIO_Point (PORTA'Access, 20);
PA21 : aliased GPIO_Point (PORTA'Access, 21);
PA22 : aliased GPIO_Point (PORTA'Access, 22);
PA23 : aliased GPIO_Point (PORTA'Access, 23);
PA24 : aliased GPIO_Point (PORTA'Access, 24);
PA25 : aliased GPIO_Point (PORTA'Access, 25);
PA26 : aliased GPIO_Point (PORTA'Access, 26);
PA27 : aliased GPIO_Point (PORTA'Access, 27);
PA28 : aliased GPIO_Point (PORTA'Access, 28);
PA29 : aliased GPIO_Point (PORTA'Access, 29);
PA30 : aliased GPIO_Point (PORTA'Access, 30);
PA31 : aliased GPIO_Point (PORTA'Access, 31);
-- PORTB --
PORTB_Internal : aliased Port_Internal
with Import, Address => System'To_Address (16#41008000# + 16#080#);
PORTB : aliased Port_Controller (PORTB_Internal'Access);
PB00 : aliased GPIO_Point (PORTB'Access, 0);
PB01 : aliased GPIO_Point (PORTB'Access, 1);
PB02 : aliased GPIO_Point (PORTB'Access, 2);
PB03 : aliased GPIO_Point (PORTB'Access, 3);
PB04 : aliased GPIO_Point (PORTB'Access, 4);
PB05 : aliased GPIO_Point (PORTB'Access, 5);
PB06 : aliased GPIO_Point (PORTB'Access, 6);
PB07 : aliased GPIO_Point (PORTB'Access, 7);
PB08 : aliased GPIO_Point (PORTB'Access, 8);
PB09 : aliased GPIO_Point (PORTB'Access, 9);
PB10 : aliased GPIO_Point (PORTB'Access, 10);
PB11 : aliased GPIO_Point (PORTB'Access, 11);
PB12 : aliased GPIO_Point (PORTB'Access, 12);
PB13 : aliased GPIO_Point (PORTB'Access, 13);
PB14 : aliased GPIO_Point (PORTB'Access, 14);
PB15 : aliased GPIO_Point (PORTB'Access, 15);
PB16 : aliased GPIO_Point (PORTB'Access, 16);
PB17 : aliased GPIO_Point (PORTB'Access, 17);
PB18 : aliased GPIO_Point (PORTB'Access, 18);
PB19 : aliased GPIO_Point (PORTB'Access, 19);
PB20 : aliased GPIO_Point (PORTB'Access, 20);
PB21 : aliased GPIO_Point (PORTB'Access, 21);
PB22 : aliased GPIO_Point (PORTB'Access, 22);
PB23 : aliased GPIO_Point (PORTB'Access, 23);
PB24 : aliased GPIO_Point (PORTB'Access, 24);
PB25 : aliased GPIO_Point (PORTB'Access, 25);
PB26 : aliased GPIO_Point (PORTB'Access, 26);
PB27 : aliased GPIO_Point (PORTB'Access, 27);
PB28 : aliased GPIO_Point (PORTB'Access, 28);
PB29 : aliased GPIO_Point (PORTB'Access, 29);
PB30 : aliased GPIO_Point (PORTB'Access, 30);
PB31 : aliased GPIO_Point (PORTB'Access, 31);
-- SERCOM0 --
SERCOM0_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#40003000#);
SPI0 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM0_Internal'Access);
I2C0 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM0_Internal'Access);
USART0 : aliased SAM.SERCOM.USART.USART_Device (SERCOM0_Internal'Access);
-- SERCOM1 --
SERCOM1_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#40003400#);
SPI1 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM1_Internal'Access);
I2C1 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM1_Internal'Access);
USART1 : aliased SAM.SERCOM.USART.USART_Device (SERCOM1_Internal'Access);
-- SERCOM2 --
SERCOM2_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#41012000#);
SPI2 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM2_Internal'Access);
I2C2 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM2_Internal'Access);
USART2 : aliased SAM.SERCOM.USART.USART_Device (SERCOM2_Internal'Access);
-- SERCOM3 --
SERCOM3_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#41014000#);
SPI3 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM3_Internal'Access);
I2C3 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM3_Internal'Access);
USART3 : aliased SAM.SERCOM.USART.USART_Device (SERCOM3_Internal'Access);
-- SERCOM4 --
SERCOM4_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#43000000#);
SPI4 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM4_Internal'Access);
I2C4 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM4_Internal'Access);
USART4 : aliased SAM.SERCOM.USART.USART_Device (SERCOM4_Internal'Access);
-- SERCOM5 --
SERCOM5_Internal : aliased SAM.SERCOM.SERCOM_Internal
with Import, Address => System'To_Address (16#43000400#);
SPI5 : aliased SAM.SERCOM.SPI.SPI_Device (SERCOM5_Internal'Access);
I2C5 : aliased SAM.SERCOM.I2C.I2C_Device (SERCOM5_Internal'Access);
USART5 : aliased SAM.SERCOM.USART.USART_Device (SERCOM5_Internal'Access);
-- TC0 --
TC0_Internal : aliased SAM.TC.TC_Internal
with Import, Address => System'To_Address (16#40003800#);
TC0 : aliased SAM.TC.TC_Device (TC0_Internal'Access, Master => True);
-- TC1 --
TC1_Internal : aliased SAM.TC.TC_Internal
with Import, Address => System'To_Address (16#40003C00#);
TC1 : aliased SAM.TC.TC_Device (TC1_Internal'Access, Master => False);
-- TC2 --
TC2_Internal : aliased SAM.TC.TC_Internal
with Import, Address => System'To_Address (16#4101A000#);
TC2 : aliased SAM.TC.TC_Device (TC2_Internal'Access, Master => True);
-- TC3 --
TC3_Internal : aliased SAM.TC.TC_Internal
with Import, Address => System'To_Address (16#4101C000#);
TC3 : aliased SAM.TC.TC_Device (TC3_Internal'Access, Master => False);
end SAM.Device;
|
Fabien-Chouteau/AGATE | Ada | 853 | ads | -- This spec has been automatically generated from FE310.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- E31 CPU Coreplex, high-performance, 32-bit RV32IMAC core
--
package FE310_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
GPIO0_Base : constant System.Address :=
System'To_Address (16#10012000#);
UART0_Base : constant System.Address :=
System'To_Address (16#10013000#);
UART1_Base : constant System.Address :=
System'To_Address (16#10023000#);
PWM0_Base : constant System.Address :=
System'To_Address (16#10015000#);
PWM1_Base : constant System.Address :=
System'To_Address (16#10025000#);
PWM2_Base : constant System.Address :=
System'To_Address (16#10035000#);
end FE310_SVD;
|
stcarrez/ada-asf | Ada | 3,984 | ads | -----------------------------------------------------------------------
-- asf-validators -- ASF Validators
-- Copyright (C) 2010 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Objects;
with ASF.Components.Base;
with ASF.Contexts.Faces;
-- = Validators =
-- The validators participate in the validation of submitted values during
-- the request validation phase. They are responsible for checking whether the
-- input parameter complies with the validation rules associated with the input
-- field. The validator is expected to raise an exception and an error message
-- is then associated with the faulty input field.
--
-- The validator is described in the XHTML file by using one of the following
-- JSF core components:
--
-- | Component | Validation type |
-- |------------------------|-----------------------------------------------------|
-- | f:validateLength | The input field must have a minimun/maximum length |
-- | f:validateLongRange | The input field must be a number in the given range |
-- | f:validator | An Ada registered or custom validator is used |
-- | f:validateRegex | The input field must match the regular expression |
--
-- A validator instance must implement the `ASF.Validators.Validator` interface.
-- It only needs to implement the `Validate` procedure which gets the UI
-- component, the faces request context and the submitted value. It must verify
-- the value according to the validator's rule and the UI component. When the
-- value is incorrect, it must set an error message in the UI component so that
-- some user friendly message is reported. In case of error, it must also
-- raise the `Invalid_Value` exception.
--
-- @include asf-validators-texts.ads
-- @include asf-validators-numbers.ads
--
package ASF.Validators is
Invalid_Value : exception;
-- ------------------------------
-- Validator
-- ------------------------------
-- The <b>Validator</b> implements a procedure to verify the validity of
-- an input parameter. The <b>validate</b> procedure is called after the
-- converter. The validator instance must be registered in
-- the component factory (See <b>ASF.Factory.Component_Factory</b>).
-- Unlike the Java implementation, the instance will be shared by multiple
-- views and requests. The validator is also responsible for adding the necessary
-- error message in the faces context.
type Validator is limited interface;
type Validator_Access is access all Validator'Class;
-- Verify that the value matches the validation rules defined by the validator.
-- If some error are found, the procedure should create a <b>FacesMessage</b>
-- describing the problem and add that message to the current faces context.
-- The procedure can examine the state and modify the component tree.
-- It must raise the <b>Invalid_Value</b> exception if the value is not valid.
procedure Validate (Valid : in Validator;
Context : in out ASF.Contexts.Faces.Faces_Context'Class;
Component : in out ASF.Components.Base.UIComponent'Class;
Value : in EL.Objects.Object) is abstract;
end ASF.Validators;
|
Lucretia/so | Ada | 1,258 | adb | ------------------------------------------------------------------------------------------------------------------------
-- See COPYING for licence information.
------------------------------------------------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Text_Streams;
with Ada.Streams.Stream_IO;
package body Oberon.Files is
function Open (File_Name : String) return File is
package Dirs renames Ada.Directories;
Actual_Name : String := File_Name & ".obn";
Size : Dirs.File_Size := Dirs.Size (Actual_Name);
Data_File : Ada.Text_IO.File_Type;
Data : File (1 .. Natural (Size));
Stream : Ada.Text_IO.Text_Streams.Stream_Access := null;
use type Ada.Text_IO.File_Mode;
begin
Ada.Text_IO.Open (File => Data_File, Mode => Ada.Text_IO.In_File, Name => Actual_Name);
Stream := Ada.Text_IO.Text_Streams.Stream (File => Data_File);
File'Read (Stream, Data);
Ada.Text_IO.Close (File => Data_File);
return Data;
exception
when others =>
Put_Line ("Error, reading source file, " & Actual_Name);
raise;
end Open;
end Oberon.Files;
|
Gabriel-Degret/adalib | Ada | 1,397 | ads | -- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Strings.UTF_Encoding is
pragma Pure (UTF_Encoding);
-- Declarations common to the string encoding packages
type Encoding_Scheme is (UTF_8, UTF_16BE, UTF_16LE);
subtype UTF_String is String;
subtype UTF_8_String is String;
subtype UTF_16_Wide_String is Wide_String;
Encoding_Error : exception;
BOM_8 : constant UTF_8_String :=
Character'Val(16#EF#) &
Character'Val(16#BB#) &
Character'Val(16#BF#);
BOM_16BE : constant UTF_String :=
Character'Val(16#FE#) &
Character'Val(16#FF#);
BOM_16LE : constant UTF_String :=
Character'Val(16#FF#) &
Character'Val(16#FE#);
BOM_16 : constant UTF_16_Wide_String :=
(1 => Wide_Character'Val(16#FEFF#));
function Encoding (Item : UTF_String;
Default : Encoding_Scheme := UTF_8)
return Encoding_Scheme;
end Ada.Strings.UTF_Encoding;
|
reznikmm/matreshka | Ada | 6,718 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Db.Query_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Query_Element_Node is
begin
return Self : Db_Query_Element_Node do
Matreshka.ODF_Db.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Db_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Db_Query_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Db_Query
(ODF.DOM.Db_Query_Elements.ODF_Db_Query_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Db_Query_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Query_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_Query_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Db_Query
(ODF.DOM.Db_Query_Elements.ODF_Db_Query_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Db_Query_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Db_Query
(Visitor,
ODF.DOM.Db_Query_Elements.ODF_Db_Query_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Db_URI,
Matreshka.ODF_String_Constants.Query_Element,
Db_Query_Element_Node'Tag);
end Matreshka.ODF_Db.Query_Elements;
|
sungyeon/drake | Ada | 291 | ads | pragma License (Unrestricted);
with Ada.Numerics.Complex_Types;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
package Ada.Numerics.Complex_Elementary_Functions is
new Generic_Complex_Elementary_Functions (Complex_Types);
pragma Pure (Ada.Numerics.Complex_Elementary_Functions);
|
rahulyhg/swaggy-jenkins | Ada | 19,318 | ads | -- Swaggy Jenkins
-- Jenkins API clients generated from Swagger / Open API specification
-- ------------ EDIT NOTE ------------
-- This file was generated with openapi-generator. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .openapi-generator-ignore file:
--
-- src/-servers.ads
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
with Swagger.Servers;
with .Models;
with .Skeletons;
package .Servers is
use .Models;
type Server_Type is limited new .Skeletons.Server_Type with null record;
--
-- Delete queue item from an organization pipeline queue
overriding
procedure Delete_Pipeline_Queue_Item
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Queue : in Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve authenticated user details for an organization
overriding
procedure Get_Authenticated_User
(Server : in out Server_Type;
Organization : in Swagger.UString;
Result : out .Models.User_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Get a list of class names supported by a given class
overriding
procedure Get_Classes
(Server : in out Server_Type;
Class : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve JSON Web Key
overriding
procedure Get_Json_Web_Key
(Server : in out Server_Type;
Key : in Integer;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve JSON Web Token
overriding
procedure Get_Json_Web_Token
(Server : in out Server_Type;
Expiry_Time_In_Mins : in Swagger.Nullable_Integer;
Max_Expiry_Time_In_Mins : in Swagger.Nullable_Integer;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve organization details
overriding
procedure Get_Organisation
(Server : in out Server_Type;
Organization : in Swagger.UString;
Result : out .Models.Organisation_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve all organizations details
overriding
procedure Get_Organisations
(Server : in out Server_Type
;
Result : out .Models.Organisations_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve pipeline details for an organization
overriding
procedure Get_Pipeline
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.Pipeline_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve all activities details for an organization pipeline
overriding
procedure Get_Pipeline_Activities
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.PipelineActivities_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve branch details for an organization pipeline
overriding
procedure Get_Pipeline_Branch
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Branch : in Swagger.UString;
Result : out .Models.BranchImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve branch run details for an organization pipeline
overriding
procedure Get_Pipeline_Branch_Run
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Branch : in Swagger.UString;
Run : in Swagger.UString;
Result : out .Models.PipelineRun_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve all branches details for an organization pipeline
overriding
procedure Get_Pipeline_Branches
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.MultibranchPipeline_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve pipeline folder for an organization
overriding
procedure Get_Pipeline_Folder
(Server : in out Server_Type;
Organization : in Swagger.UString;
Folder : in Swagger.UString;
Result : out .Models.PipelineFolderImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve pipeline details for an organization folder
overriding
procedure Get_Pipeline_Folder_Pipeline
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Folder : in Swagger.UString;
Result : out .Models.PipelineImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve queue details for an organization pipeline
overriding
procedure Get_Pipeline_Queue
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.PipelineQueue_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve run details for an organization pipeline
overriding
procedure Get_Pipeline_Run
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Result : out .Models.PipelineRun_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Get log for a pipeline run
overriding
procedure Get_Pipeline_Run_Log
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Start : in Swagger.Nullable_Integer;
Download : in Swagger.Nullable_Boolean;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve run node details for an organization pipeline
overriding
procedure Get_Pipeline_Run_Node
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Node : in Swagger.UString;
Result : out .Models.PipelineRunNode_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve run node details for an organization pipeline
overriding
procedure Get_Pipeline_Run_Node_Step
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Node : in Swagger.UString;
Step : in Swagger.UString;
Result : out .Models.PipelineStepImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Get log for a pipeline run node step
overriding
procedure Get_Pipeline_Run_Node_Step_Log
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Node : in Swagger.UString;
Step : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve run node steps details for an organization pipeline
overriding
procedure Get_Pipeline_Run_Node_Steps
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Node : in Swagger.UString;
Result : out .Models.PipelineRunNodeSteps_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve run nodes details for an organization pipeline
overriding
procedure Get_Pipeline_Run_Nodes
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Result : out .Models.PipelineRunNodes_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve all runs details for an organization pipeline
overriding
procedure Get_Pipeline_Runs
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.PipelineRuns_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve all pipelines details for an organization
overriding
procedure Get_Pipelines
(Server : in out Server_Type;
Organization : in Swagger.UString;
Result : out .Models.Pipelines_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve SCM details for an organization
overriding
procedure Get_S_C_M
(Server : in out Server_Type;
Organization : in Swagger.UString;
Scm : in Swagger.UString;
Result : out .Models.GithubScm_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve SCM organization repositories details for an organization
overriding
procedure Get_S_C_M_Organisation_Repositories
(Server : in out Server_Type;
Organization : in Swagger.UString;
Scm : in Swagger.UString;
Scm_Organisation : in Swagger.UString;
Credential_Id : in Swagger.Nullable_UString;
Page_Size : in Swagger.Nullable_Integer;
Page_Number : in Swagger.Nullable_Integer;
Result : out .Models.ScmOrganisations_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve SCM organization repository details for an organization
overriding
procedure Get_S_C_M_Organisation_Repository
(Server : in out Server_Type;
Organization : in Swagger.UString;
Scm : in Swagger.UString;
Scm_Organisation : in Swagger.UString;
Repository : in Swagger.UString;
Credential_Id : in Swagger.Nullable_UString;
Result : out .Models.ScmOrganisations_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve SCM organizations details for an organization
overriding
procedure Get_S_C_M_Organisations
(Server : in out Server_Type;
Organization : in Swagger.UString;
Scm : in Swagger.UString;
Credential_Id : in Swagger.Nullable_UString;
Result : out .Models.ScmOrganisations_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve user details for an organization
overriding
procedure Get_User
(Server : in out Server_Type;
Organization : in Swagger.UString;
User : in Swagger.UString;
Result : out .Models.User_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve user favorites details for an organization
overriding
procedure Get_User_Favorites
(Server : in out Server_Type;
User : in Swagger.UString;
Result : out .Models.UserFavorites_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve users details for an organization
overriding
procedure Get_Users
(Server : in out Server_Type;
Organization : in Swagger.UString;
Result : out .Models.User_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Replay an organization pipeline run
overriding
procedure Post_Pipeline_Run
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Result : out .Models.QueueItemImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Start a build for an organization pipeline
overriding
procedure Post_Pipeline_Runs
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Result : out .Models.QueueItemImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Favorite/unfavorite a pipeline
overriding
procedure Put_Pipeline_Favorite
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Body_Type : in Body_Type;
Result : out .Models.FavoriteImpl_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Stop a build of an organization pipeline
overriding
procedure Put_Pipeline_Run
(Server : in out Server_Type;
Organization : in Swagger.UString;
Pipeline : in Swagger.UString;
Run : in Swagger.UString;
Blocking : in Swagger.Nullable_UString;
Time_Out_In_Secs : in Swagger.Nullable_Integer;
Result : out .Models.PipelineRun_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Search for any resource details
overriding
procedure Search
(Server : in out Server_Type;
Q : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Get classes details
overriding
procedure Search_Classes
(Server : in out Server_Type;
Q : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve computer details
overriding
procedure Get_Computer
(Server : in out Server_Type;
Depth : in Integer;
Result : out .Models.ComputerSet_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve CSRF protection token
overriding
procedure Get_Crumb
(Server : in out Server_Type
;
Result : out .Models.DefaultCrumbIssuer_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve Jenkins details
overriding
procedure Get_Jenkins
(Server : in out Server_Type
;
Result : out .Models.Hudson_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve job details
overriding
procedure Get_Job
(Server : in out Server_Type;
Name : in Swagger.UString;
Result : out .Models.FreeStyleProject_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve job configuration
overriding
procedure Get_Job_Config
(Server : in out Server_Type;
Name : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve job's last build details
overriding
procedure Get_Job_Last_Build
(Server : in out Server_Type;
Name : in Swagger.UString;
Result : out .Models.FreeStyleBuild_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve job's build progressive text output
overriding
procedure Get_Job_Progressive_Text
(Server : in out Server_Type;
Name : in Swagger.UString;
Number : in Swagger.UString;
Start : in Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve queue details
overriding
procedure Get_Queue
(Server : in out Server_Type
;
Result : out .Models.Queue_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve queued item details
overriding
procedure Get_Queue_Item
(Server : in out Server_Type;
Number : in Swagger.UString;
Result : out .Models.Queue_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve view details
overriding
procedure Get_View
(Server : in out Server_Type;
Name : in Swagger.UString;
Result : out .Models.ListView_Type;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve view configuration
overriding
procedure Get_View_Config
(Server : in out Server_Type;
Name : in Swagger.UString;
Result : out Swagger.UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Retrieve Jenkins headers
overriding
procedure Head_Jenkins
(Server : in out Server_Type
;
Context : in out Swagger.Servers.Context_Type);
--
-- Create a new job using job configuration, or copied from an existing job
overriding
procedure Post_Create_Item
(Server : in out Server_Type;
Name : in Swagger.UString;
From : in Swagger.Nullable_UString;
Mode : in Swagger.Nullable_UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Content_Type : in Swagger.Nullable_UString;
P_Body : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Create a new view using view configuration
overriding
procedure Post_Create_View
(Server : in out Server_Type;
Name : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Content_Type : in Swagger.Nullable_UString;
P_Body : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Build a job
overriding
procedure Post_Job_Build
(Server : in out Server_Type;
Name : in Swagger.UString;
Json : in Swagger.UString;
Token : in Swagger.Nullable_UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Update job configuration
overriding
procedure Post_Job_Config
(Server : in out Server_Type;
Name : in Swagger.UString;
P_Body : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Delete a job
overriding
procedure Post_Job_Delete
(Server : in out Server_Type;
Name : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Disable a job
overriding
procedure Post_Job_Disable
(Server : in out Server_Type;
Name : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Enable a job
overriding
procedure Post_Job_Enable
(Server : in out Server_Type;
Name : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Stop a job
overriding
procedure Post_Job_Last_Build_Stop
(Server : in out Server_Type;
Name : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
--
-- Update view configuration
overriding
procedure Post_View_Config
(Server : in out Server_Type;
Name : in Swagger.UString;
P_Body : in Swagger.UString;
Jenkins_Crumb : in Swagger.Nullable_UString;
Context : in out Swagger.Servers.Context_Type);
package Server_Impl is
new .Skeletons.Shared_Instance (Server_Type);
end .Servers;
|
DrenfongWong/tkm-rpc | Ada | 263 | ads | with Tkmrpc.Request;
with Tkmrpc.Response;
package Tkmrpc.Operation_Handlers.Ike.Isa_Reset is
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type);
-- Handler for the isa_reset operation.
end Tkmrpc.Operation_Handlers.Ike.Isa_Reset;
|
PThierry/ewok-kernel | Ada | 10,743 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - 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;
pragma Annotate (GNATprove,
Intentional,
"initialization of init_done is not mentioned in Initializes contract",
"init_done is not a register, while it is a volatile");
package soc.dwt
with
spark_mode => on,
abstract_state => ((Ctrl with external), -- this is a register
(Cnt with external), -- this is a register
(Lar_register with external), -- this is a register
(Dem with external), -- this is a register
Ini_F, Loo, Last),
initializes => (Ctrl, Cnt, Dem, Ini_F) -- assumed as initialized
is
pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE);
-----------------------------------------------------
-- SPARK ghost functions and procedures
-----------------------------------------------------
function init_is_done return boolean
with ghost;
function check_32bits_overflow return boolean
with ghost;
--------------------------------------------------
-- The Data Watchpoint and Trace unit (DWT) --
-- (Cf. ARMv7-M Arch. Ref. Manual, C1.8, p.779) --
--------------------------------------------------
-- Reset the DWT-based timer
procedure reset_timer
with
pre => not init_is_done,
global => (input => Ini_F,
in_out => (Dem, Ctrl),
output => (Lar_register, Cnt)),
depends => (Dem =>+ null,
Lar_register => null,
Cnt => null,
Ctrl =>+ null,
null => Ini_F);
-- Start the DWT timer. The register is counting the number of CPU cycles
procedure start_timer
with
pre => not init_is_done,
global => (input => Ini_F,
in_out => Ctrl),
depends => (Ctrl =>+ null,
null => Ini_F);
-- Stop the DWT timer
procedure stop_timer
with
pre => init_is_done,
global => (input => Ini_F,
in_out => Ctrl),
depends => (Ctrl =>+ null,
null => Ini_F);
-- Periodically check the DWT CYCCNT register for overflow. This permit
-- to detect each time an overflow happends and increment the
-- overflow counter to keep a valid 64 bit time value
-- precondition check that the package has been initialized and that
-- dwt_loop doesn't overflow
procedure ovf_manage
with
pre => check_32bits_overflow;
-- Initialize the DWT module
procedure init
with
pre => not init_is_done,
global => (in_out => (Ini_F, Ctrl, Dem),
output => (Last, Loo, Cnt, Lar_register));
-- Get the DWT timer (without overflow support, keep a 32bit value)
procedure get_cycles_32(cycles : out unsigned_32)
with
inline,
pre => init_is_done,
global => (input => Ini_F,
in_out => Cnt),
depends => (Cnt =>+ null,
cycles => Cnt,
null => Ini_F);
-- Get the DWT timer with overflow support. permits linear measurement
-- on 64 bits cycles time window (approx. 1270857 days)
procedure get_cycles (cycles : out unsigned_64)
with
pre => init_is_done,
global => (input => (Ini_F, Loo),
in_out => Cnt),
depends => (Cnt =>+ null,
cycles => (Cnt, Loo),
null => Ini_F);
procedure get_microseconds (micros : out unsigned_64)
with
inline,
pre => init_is_done,
global => (input => (Ini_F, Loo),
in_out => Cnt),
depends => (micros => (Cnt, Loo),
Cnt =>+ null,
null => Ini_F);
procedure get_milliseconds (milli : out unsigned_64)
with
inline,
pre => init_is_done,
global => (in_out => Cnt,
input => (Loo, Ini_F)),
depends => (milli => (Cnt, Loo),
Cnt =>+ null,
null => Ini_F);
private
--
-- Control register
--
type t_DWT_CTRL is record
CYCCNTENA : boolean; -- Enables CYCCNT
POSTPRESET : bits_4;
POSTINIT : bits_4;
CYCTAP : bit;
SYNCTAP : bits_2;
PCSAMPLENA : bit;
reserved_13_15 : bits_3;
EXCTRCENA : bit;
CPIEVTENA : bit;
EXCEVTENA : bit;
SLEEPEVTENA : bit;
LSUEVTENA : bit;
FOLDEVTENA : bit;
CYCEVTENA : bit;
reserved_23 : bit;
NOPRFCNT : bit;
NOCYCCNT : bit;
NOEXTTRIG : bit;
NOTRCPKT : bit;
NUMCOMP : bits_4;
end record
with size => 32;
for t_DWT_CTRL use record
CYCCNTENA at 0 range 0 .. 0;
POSTPRESET at 0 range 1 .. 4;
POSTINIT at 0 range 5 .. 8;
CYCTAP at 0 range 9 .. 9;
SYNCTAP at 0 range 10 .. 11;
PCSAMPLENA at 0 range 12 .. 12;
reserved_13_15 at 0 range 13 .. 15;
EXCTRCENA at 0 range 16 .. 16;
CPIEVTENA at 0 range 17 .. 17;
EXCEVTENA at 0 range 18 .. 18;
SLEEPEVTENA at 0 range 19 .. 19;
LSUEVTENA at 0 range 20 .. 20;
FOLDEVTENA at 0 range 21 .. 21;
CYCEVTENA at 0 range 22 .. 22;
reserved_23 at 0 range 23 .. 23;
NOPRFCNT at 0 range 24 .. 24;
NOCYCCNT at 0 range 25 .. 25;
NOEXTTRIG at 0 range 26 .. 26;
NOTRCPKT at 0 range 27 .. 27;
NUMCOMP at 0 range 28 .. 31;
end record;
DWT_CONTROL : t_DWT_CTRL
with
import,
volatile,
address => system'to_address (16#E000_1000#),
part_of => Ctrl;
--
-- CYCCNT register
--
subtype t_DWT_CYCCNT is unsigned_32;
DWT_CYCCNT : t_DWT_CYCCNT
with
import,
volatile,
address => system'to_address (16#E000_1004#),
part_of => Cnt;
-- Specify the package state. Set to true by init().
init_done : boolean := false with part_of => Ini_F;
--
-- DWT CYCCNT register overflow counting
-- This permit to support incremental getcycle
-- with a time window of 64bits length (instead of 32bits)
--
dwt_loops : unsigned_64 with part_of => Loo;
--
-- Last measured DWT CYCCNT. Compared with current measurement,
-- we can detect if the register has generated an overflow or not
--
last_dwt : unsigned_32 with part_of => Last;
--------------------------------------------------
-- CoreSight Software Lock registers --
-- Ref.: --
-- - ARMv7-M Arch. Ref. Manual, D1.1, p.826) --
-- - CoreSight Arch. Spec. B2.5.9, p.48 --
--------------------------------------------------
--
-- Lock Access Register (LAR)
--
LAR : unsigned_32
with
import,
volatile,
address => system'to_address (16#E000_1FB0#),
part_of => Lar_register;
LAR_ENABLE_WRITE_KEY : constant := 16#C5AC_CE55#;
---------------------------------------------------------
-- Debug Exception and Monitor Control Register, DEMCR --
-- (Cf. ARMv7-M Arch. Ref. Manual, C1.6.5, p.765) --
---------------------------------------------------------
type t_DEMCR is record
VC_CORERESET : boolean; -- Reset Vector Catch enabled
reserved_1_3 : bits_3;
VC_MMERR : boolean; -- Debug trap on a MemManage exception
VC_NOCPERR : boolean;
-- Debug trap on a UsageFault exception caused by an access to a
-- Coprocessor
VC_CHKERR : boolean;
-- Debug trap on a UsageFault exception caused by a checking error
VC_STATERR : boolean;
-- Debug trap on a UsageFault exception caused by a state information
-- error
VC_BUSERR : boolean; -- Debug trap on a BusFault exception
VC_INTERR : boolean;
-- Debug trap on a fault occurring during exception entry or exception
-- return
VC_HARDERR : boolean; -- Debug trap on a HardFault exception
reserved_11_15 : bits_5;
MON_EN : boolean; -- DebugMonitor exception enabled
MON_PEND : boolean; -- Sets or clears the pending state of the
-- DebugMonitor exception
MON_STEP : boolean; -- Step the processor
MON_REQ : boolean; -- DebugMonitor semaphore bit
reserved_20_23 : bits_4;
TRCENA : boolean; -- DWT and ITM units enabled
end record
with size => 32;
for t_DEMCR use record
VC_CORERESET at 0 range 0 .. 0;
reserved_1_3 at 0 range 1 .. 3;
VC_MMERR at 0 range 4 .. 4;
VC_NOCPERR at 0 range 5 .. 5;
VC_CHKERR at 0 range 6 .. 6;
VC_STATERR at 0 range 7 .. 7;
VC_BUSERR at 0 range 8 .. 8;
VC_INTERR at 0 range 9 .. 9;
VC_HARDERR at 0 range 10 .. 10;
reserved_11_15 at 0 range 11 .. 15;
MON_EN at 0 range 16 .. 16;
MON_PEND at 0 range 17 .. 17;
MON_STEP at 0 range 18 .. 18;
MON_REQ at 0 range 19 .. 19;
reserved_20_23 at 0 range 20 .. 23;
TRCENA at 0 range 24 .. 24;
end record;
DEMCR : t_DEMCR
with import,
volatile,
address => system'to_address (16#E000_EDFC#),
part_of => Dem;
end soc.dwt;
|
reznikmm/matreshka | Ada | 3,953 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- 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_0E02 is
pragma Preelaborate;
Group_0E02 : aliased constant Core_Second_Stage
:= (others =>
(Unassigned, Neutral,
Control, Other, Other, Unknown,
(Other_Default_Ignorable_Code_Point
| Default_Ignorable_Code_Point
| Changes_When_NFKC_Casefolded => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0E02;
|
reznikmm/matreshka | Ada | 4,605 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Fo.Column_Count_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Column_Count_Attribute_Node is
begin
return Self : Fo_Column_Count_Attribute_Node do
Matreshka.ODF_Fo.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Fo_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Fo_Column_Count_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Column_Count_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Fo_URI,
Matreshka.ODF_String_Constants.Column_Count_Attribute,
Fo_Column_Count_Attribute_Node'Tag);
end Matreshka.ODF_Fo.Column_Count_Attributes;
|
reznikmm/matreshka | Ada | 3,744 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Attributes;
package ODF.DOM.Draw_Marker_End_Width_Attributes is
pragma Preelaborate;
type ODF_Draw_Marker_End_Width_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Marker_End_Width_Attribute_Access is
access all ODF_Draw_Marker_End_Width_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Marker_End_Width_Attributes;
|
Letractively/ada-ado | Ada | 4,144 | ads | -----------------------------------------------------------------------
-- ADO Databases -- Database Objects
-- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Streams;
with Ada.Calendar;
with Util.Refs;
package ADO is
type Int64 is range -2**63 .. 2**63 - 1;
for Int64'Size use 64;
type Unsigned64 is mod 2**64;
for Unsigned64'Size use 64;
DEFAULT_TIME : constant Ada.Calendar.Time;
-- ------------------------------
-- Database Identifier
-- ------------------------------
--
type Identifier is range -2**47 .. 2**47 - 1;
NO_IDENTIFIER : constant Identifier := -1;
type Entity_Type is range 0 .. 2**16 - 1;
NO_ENTITY_TYPE : constant Entity_Type := 0;
type Object_Id is record
Id : Identifier;
Kind : Entity_Type;
end record;
pragma Pack (Object_Id);
-- ------------------------------
-- Nullable Types
-- ------------------------------
-- Most database allow to store a NULL instead of an actual integer, date or string value.
-- Unlike Java, there is no easy way to distinguish between a NULL and an actual valid value.
-- The <b>Nullable_T</b> types provide a way to specify and check whether a value is null
-- or not.
-- An integer which can be null.
type Nullable_Integer is record
Value : Integer := 0;
Is_Null : Boolean := True;
end record;
-- A string which can be null.
type Nullable_String is record
Value : Ada.Strings.Unbounded.Unbounded_String;
Is_Null : Boolean := True;
end record;
-- A date which can be null.
type Nullable_Time is record
Value : Ada.Calendar.Time;
Is_Null : Boolean := True;
end record;
-- ------------------------------
-- Blob data type
-- ------------------------------
-- The <b>Blob</b> type is used to represent database blobs. The data is stored
-- in an <b>Ada.Streams.Stream_Element_Array</b> pointed to by the <b>Data</b> member.
-- The query statement and bind parameter will use a <b>Blob_Ref</b> which represents
-- a reference to the blob data. This is intended to minimize data copy.
type Blob (Len : Ada.Streams.Stream_Element_Offset) is new Util.Refs.Ref_Entity with record
Data : Ada.Streams.Stream_Element_Array (1 .. Len);
end record;
type Blob_Access is access all Blob;
package Blob_References is new Util.Refs.Indefinite_References (Blob, Blob_Access);
subtype Blob_Ref is Blob_References.Ref;
-- Create a blob with an allocated buffer of <b>Size</b> bytes.
function Create_Blob (Size : in Natural) return Blob_Ref;
-- Create a blob initialized with the given data buffer.
function Create_Blob (Data : in Ada.Streams.Stream_Element_Array) return Blob_Ref;
-- Create a blob initialized with the content from the file whose path is <b>Path</b>.
-- Raises an IO exception if the file does not exist.
function Create_Blob (Path : in String) return Blob_Ref;
-- Return a null blob.
function Null_Blob return Blob_Ref;
private
DEFAULT_TIME : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901,
Month => 1,
Day => 2,
Seconds => 0.0);
end ADO;
|
reznikmm/matreshka | Ada | 1,000 | ads | with Ada.Streams.Stream_IO;
with Matreshka.Internals.Unicode;
package Sources is
type Source is tagged limited private;
type Source_Access is access all Source'Class;
type Read_Status is (Successful, Mailformed, End_Of_Data, End_Of_Input);
procedure Next
(Self : in out Source;
Code : out Matreshka.Internals.Unicode.Code_Point;
Status : out Read_Status);
procedure Open (Self : in out Source; File_Name : String);
private
type UTF8_Meta_Class is mod 2 ** 8;
type UTF8_DFA_State is mod 2 ** 8;
type Source is tagged limited record
-- Source stream
File : Ada.Streams.Stream_IO.File_Type;
-- Internal buffer
Buffer : Ada.Streams.Stream_Element_Array (1 .. 1024);
Last : Ada.Streams.Stream_Element_Offset;
Position : Ada.Streams.Stream_Element_Offset;
-- Decoder state
State : UTF8_DFA_State;
Code : Matreshka.Internals.Unicode.Code_Unit_32;
end record;
end Sources;
|
stcarrez/ada-servlet | Ada | 1,189 | ads | -----------------------------------------------------------------------
-- servlet-streams-json -- JSON Print streams for servlets
-- Copyright (C) 2016, 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Serialize.IO.JSON;
package Servlet.Streams.JSON is
subtype Print_Stream is Util.Serialize.IO.JSON.Output_Stream;
-- Initialize the stream
procedure Initialize (Stream : in out Print_Stream;
To : in Servlet.Streams.Print_Stream'Class);
end Servlet.Streams.JSON;
|
sungyeon/drake | Ada | 1,034 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Packed_Arrays;
package System.Pack_10 is
pragma Preelaborate;
-- It can not be Pure, subprograms would become __attribute__((const)).
type Bits_10 is mod 2 ** 10;
for Bits_10'Size use 10;
package Indexing is new Packed_Arrays.Indexing (Bits_10);
-- required for accessing aligned arrays by compiler
function Get_10 (
Arr : Address;
N : Natural;
Rev_SSO : Boolean)
return Bits_10
renames Indexing.Get;
procedure Set_10 (
Arr : Address;
N : Natural;
E : Bits_10;
Rev_SSO : Boolean)
renames Indexing.Set;
-- required for accessing unaligned arrays by compiler
function GetU_10 (
Arr : Address;
N : Natural;
Rev_SSO : Boolean)
return Bits_10
renames Indexing.Get;
procedure SetU_10 (
Arr : Address;
N : Natural;
E : Bits_10;
Rev_SSO : Boolean)
renames Indexing.Set;
end System.Pack_10;
|
reznikmm/matreshka | Ada | 4,337 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Nodes;
with XML.DOM.Elements.Internals;
package body ODF.DOM.Elements.Style.Table_Row_Properties.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Elements.Style.Table_Row_Properties.Style_Table_Row_Properties_Access)
return ODF.DOM.Elements.Style.Table_Row_Properties.ODF_Style_Table_Row_Properties is
begin
return
(XML.DOM.Elements.Internals.Create
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Elements.Style.Table_Row_Properties.Style_Table_Row_Properties_Access)
return ODF.DOM.Elements.Style.Table_Row_Properties.ODF_Style_Table_Row_Properties is
begin
return
(XML.DOM.Elements.Internals.Wrap
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Elements.Style.Table_Row_Properties.Internals;
|
Fabien-Chouteau/samd51-hal | Ada | 36,574 | ads |
-- Generated by a script from an "avr tools device file" (atdf)
with SAM.Port; use SAM.Port;
package SAM.Functions is
PA04_AC_AIN0 : constant Peripheral_Function := B;
PA05_AC_AIN1 : constant Peripheral_Function := B;
PA06_AC_AIN2 : constant Peripheral_Function := B;
PA07_AC_AIN3 : constant Peripheral_Function := B;
PA12_AC_CMP0 : constant Peripheral_Function := M;
PA18_AC_CMP0 : constant Peripheral_Function := M;
PB24_AC_CMP0 : constant Peripheral_Function := M;
PA13_AC_CMP1 : constant Peripheral_Function := M;
PA19_AC_CMP1 : constant Peripheral_Function := M;
PB25_AC_CMP1 : constant Peripheral_Function := M;
PA02_ADC0_AIN0 : constant Peripheral_Function := B;
PA03_ADC0_AIN1 : constant Peripheral_Function := B;
PB08_ADC0_AIN2 : constant Peripheral_Function := B;
PB09_ADC0_AIN3 : constant Peripheral_Function := B;
PA04_ADC0_AIN4 : constant Peripheral_Function := B;
PA05_ADC0_AIN5 : constant Peripheral_Function := B;
PA06_ADC0_AIN6 : constant Peripheral_Function := B;
PA07_ADC0_AIN7 : constant Peripheral_Function := B;
PA08_ADC0_AIN8 : constant Peripheral_Function := B;
PA09_ADC0_AIN9 : constant Peripheral_Function := B;
PA10_ADC0_AIN10 : constant Peripheral_Function := B;
PA11_ADC0_AIN11 : constant Peripheral_Function := B;
PB00_ADC0_AIN12 : constant Peripheral_Function := B;
PB01_ADC0_AIN13 : constant Peripheral_Function := B;
PB02_ADC0_AIN14 : constant Peripheral_Function := B;
PB03_ADC0_AIN15 : constant Peripheral_Function := B;
PA03_ADC0_X0 : constant Peripheral_Function := B;
PA03_ADC0_Y0 : constant Peripheral_Function := B;
PB08_ADC0_X1 : constant Peripheral_Function := B;
PB08_ADC0_Y1 : constant Peripheral_Function := B;
PB09_ADC0_X2 : constant Peripheral_Function := B;
PB09_ADC0_Y2 : constant Peripheral_Function := B;
PA04_ADC0_X3 : constant Peripheral_Function := B;
PA04_ADC0_Y3 : constant Peripheral_Function := B;
PA06_ADC0_X4 : constant Peripheral_Function := B;
PA06_ADC0_Y4 : constant Peripheral_Function := B;
PA07_ADC0_X5 : constant Peripheral_Function := B;
PA07_ADC0_Y5 : constant Peripheral_Function := B;
PA08_ADC0_X6 : constant Peripheral_Function := B;
PA08_ADC0_Y6 : constant Peripheral_Function := B;
PA09_ADC0_X7 : constant Peripheral_Function := B;
PA09_ADC0_Y7 : constant Peripheral_Function := B;
PA10_ADC0_X8 : constant Peripheral_Function := B;
PA10_ADC0_Y8 : constant Peripheral_Function := B;
PA11_ADC0_X9 : constant Peripheral_Function := B;
PA11_ADC0_Y9 : constant Peripheral_Function := B;
PA16_ADC0_X10 : constant Peripheral_Function := B;
PA16_ADC0_Y10 : constant Peripheral_Function := B;
PA17_ADC0_X11 : constant Peripheral_Function := B;
PA17_ADC0_Y11 : constant Peripheral_Function := B;
PA18_ADC0_X12 : constant Peripheral_Function := B;
PA18_ADC0_Y12 : constant Peripheral_Function := B;
PA19_ADC0_X13 : constant Peripheral_Function := B;
PA19_ADC0_Y13 : constant Peripheral_Function := B;
PA20_ADC0_X14 : constant Peripheral_Function := B;
PA20_ADC0_Y14 : constant Peripheral_Function := B;
PA21_ADC0_X15 : constant Peripheral_Function := B;
PA21_ADC0_Y15 : constant Peripheral_Function := B;
PA22_ADC0_X16 : constant Peripheral_Function := B;
PA22_ADC0_Y16 : constant Peripheral_Function := B;
PA23_ADC0_X17 : constant Peripheral_Function := B;
PA23_ADC0_Y17 : constant Peripheral_Function := B;
PA27_ADC0_X18 : constant Peripheral_Function := B;
PA27_ADC0_Y18 : constant Peripheral_Function := B;
PA30_ADC0_X19 : constant Peripheral_Function := B;
PA30_ADC0_Y19 : constant Peripheral_Function := B;
PB02_ADC0_X20 : constant Peripheral_Function := B;
PB02_ADC0_Y20 : constant Peripheral_Function := B;
PB03_ADC0_X21 : constant Peripheral_Function := B;
PB03_ADC0_Y21 : constant Peripheral_Function := B;
PB04_ADC0_X22 : constant Peripheral_Function := B;
PB04_ADC0_Y22 : constant Peripheral_Function := B;
PB05_ADC0_X23 : constant Peripheral_Function := B;
PB05_ADC0_Y23 : constant Peripheral_Function := B;
PB06_ADC0_X24 : constant Peripheral_Function := B;
PB06_ADC0_Y24 : constant Peripheral_Function := B;
PB07_ADC0_X25 : constant Peripheral_Function := B;
PB07_ADC0_Y25 : constant Peripheral_Function := B;
PB12_ADC0_X26 : constant Peripheral_Function := B;
PB12_ADC0_Y26 : constant Peripheral_Function := B;
PB13_ADC0_X27 : constant Peripheral_Function := B;
PB13_ADC0_Y27 : constant Peripheral_Function := B;
PB14_ADC0_X28 : constant Peripheral_Function := B;
PB14_ADC0_Y28 : constant Peripheral_Function := B;
PB15_ADC0_X29 : constant Peripheral_Function := B;
PB15_ADC0_Y29 : constant Peripheral_Function := B;
PB00_ADC0_X30 : constant Peripheral_Function := B;
PB00_ADC0_Y30 : constant Peripheral_Function := B;
PB01_ADC0_X31 : constant Peripheral_Function := B;
PB01_ADC0_Y31 : constant Peripheral_Function := B;
PB08_ADC1_AIN0 : constant Peripheral_Function := B;
PB09_ADC1_AIN1 : constant Peripheral_Function := B;
PA08_ADC1_AIN2 : constant Peripheral_Function := B;
PA09_ADC1_AIN3 : constant Peripheral_Function := B;
PC02_ADC1_AIN4 : constant Peripheral_Function := B;
PC03_ADC1_AIN5 : constant Peripheral_Function := B;
PB04_ADC1_AIN6 : constant Peripheral_Function := B;
PB05_ADC1_AIN7 : constant Peripheral_Function := B;
PB06_ADC1_AIN8 : constant Peripheral_Function := B;
PB07_ADC1_AIN9 : constant Peripheral_Function := B;
PC00_ADC1_AIN10 : constant Peripheral_Function := B;
PC01_ADC1_AIN11 : constant Peripheral_Function := B;
PA04_CCL_IN0 : constant Peripheral_Function := N;
PA16_CCL_IN0 : constant Peripheral_Function := N;
PB22_CCL_IN0 : constant Peripheral_Function := N;
PA05_CCL_IN1 : constant Peripheral_Function := N;
PA17_CCL_IN1 : constant Peripheral_Function := N;
PB00_CCL_IN1 : constant Peripheral_Function := N;
PA06_CCL_IN2 : constant Peripheral_Function := N;
PA18_CCL_IN2 : constant Peripheral_Function := N;
PB01_CCL_IN2 : constant Peripheral_Function := N;
PA08_CCL_IN3 : constant Peripheral_Function := N;
PA30_CCL_IN3 : constant Peripheral_Function := N;
PA09_CCL_IN4 : constant Peripheral_Function := N;
PC27_CCL_IN4 : constant Peripheral_Function := N;
PA10_CCL_IN5 : constant Peripheral_Function := N;
PC28_CCL_IN5 : constant Peripheral_Function := N;
PA22_CCL_IN6 : constant Peripheral_Function := N;
PB06_CCL_IN6 : constant Peripheral_Function := N;
PA23_CCL_IN7 : constant Peripheral_Function := N;
PB07_CCL_IN7 : constant Peripheral_Function := N;
PA24_CCL_IN8 : constant Peripheral_Function := N;
PB08_CCL_IN8 : constant Peripheral_Function := N;
PB14_CCL_IN9 : constant Peripheral_Function := N;
PC20_CCL_IN9 : constant Peripheral_Function := N;
PB15_CCL_IN10 : constant Peripheral_Function := N;
PC21_CCL_IN10 : constant Peripheral_Function := N;
PB10_CCL_IN11 : constant Peripheral_Function := N;
PB16_CCL_IN11 : constant Peripheral_Function := N;
PA07_CCL_OUT0 : constant Peripheral_Function := N;
PA19_CCL_OUT0 : constant Peripheral_Function := N;
PB02_CCL_OUT0 : constant Peripheral_Function := N;
PB23_CCL_OUT0 : constant Peripheral_Function := N;
PA11_CCL_OUT1 : constant Peripheral_Function := N;
PA31_CCL_OUT1 : constant Peripheral_Function := N;
PB11_CCL_OUT1 : constant Peripheral_Function := N;
PA25_CCL_OUT2 : constant Peripheral_Function := N;
PB09_CCL_OUT2 : constant Peripheral_Function := N;
PB17_CCL_OUT3 : constant Peripheral_Function := N;
PA02_DAC_VOUT0 : constant Peripheral_Function := B;
PA05_DAC_VOUT1 : constant Peripheral_Function := B;
PA00_EIC_EXTINT0 : constant Peripheral_Function := A;
PA16_EIC_EXTINT0 : constant Peripheral_Function := A;
PB00_EIC_EXTINT0 : constant Peripheral_Function := A;
PB16_EIC_EXTINT0 : constant Peripheral_Function := A;
PC00_EIC_EXTINT0 : constant Peripheral_Function := A;
PC16_EIC_EXTINT0 : constant Peripheral_Function := A;
PA01_EIC_EXTINT1 : constant Peripheral_Function := A;
PA17_EIC_EXTINT1 : constant Peripheral_Function := A;
PB01_EIC_EXTINT1 : constant Peripheral_Function := A;
PB17_EIC_EXTINT1 : constant Peripheral_Function := A;
PC01_EIC_EXTINT1 : constant Peripheral_Function := A;
PC17_EIC_EXTINT1 : constant Peripheral_Function := A;
PA02_EIC_EXTINT2 : constant Peripheral_Function := A;
PA18_EIC_EXTINT2 : constant Peripheral_Function := A;
PB02_EIC_EXTINT2 : constant Peripheral_Function := A;
PB18_EIC_EXTINT2 : constant Peripheral_Function := A;
PC02_EIC_EXTINT2 : constant Peripheral_Function := A;
PC18_EIC_EXTINT2 : constant Peripheral_Function := A;
PA03_EIC_EXTINT3 : constant Peripheral_Function := A;
PA19_EIC_EXTINT3 : constant Peripheral_Function := A;
PB03_EIC_EXTINT3 : constant Peripheral_Function := A;
PB19_EIC_EXTINT3 : constant Peripheral_Function := A;
PC03_EIC_EXTINT3 : constant Peripheral_Function := A;
PC19_EIC_EXTINT3 : constant Peripheral_Function := A;
PA04_EIC_EXTINT4 : constant Peripheral_Function := A;
PA20_EIC_EXTINT4 : constant Peripheral_Function := A;
PB04_EIC_EXTINT4 : constant Peripheral_Function := A;
PB20_EIC_EXTINT4 : constant Peripheral_Function := A;
PC20_EIC_EXTINT4 : constant Peripheral_Function := A;
PA05_EIC_EXTINT5 : constant Peripheral_Function := A;
PA21_EIC_EXTINT5 : constant Peripheral_Function := A;
PB05_EIC_EXTINT5 : constant Peripheral_Function := A;
PB21_EIC_EXTINT5 : constant Peripheral_Function := A;
PC05_EIC_EXTINT5 : constant Peripheral_Function := A;
PC21_EIC_EXTINT5 : constant Peripheral_Function := A;
PA06_EIC_EXTINT6 : constant Peripheral_Function := A;
PA22_EIC_EXTINT6 : constant Peripheral_Function := A;
PB06_EIC_EXTINT6 : constant Peripheral_Function := A;
PB22_EIC_EXTINT6 : constant Peripheral_Function := A;
PC06_EIC_EXTINT6 : constant Peripheral_Function := A;
PA07_EIC_EXTINT7 : constant Peripheral_Function := A;
PA23_EIC_EXTINT7 : constant Peripheral_Function := A;
PB07_EIC_EXTINT7 : constant Peripheral_Function := A;
PB23_EIC_EXTINT7 : constant Peripheral_Function := A;
PA24_EIC_EXTINT8 : constant Peripheral_Function := A;
PB08_EIC_EXTINT8 : constant Peripheral_Function := A;
PB24_EIC_EXTINT8 : constant Peripheral_Function := A;
PC24_EIC_EXTINT8 : constant Peripheral_Function := A;
PA09_EIC_EXTINT9 : constant Peripheral_Function := A;
PA25_EIC_EXTINT9 : constant Peripheral_Function := A;
PB09_EIC_EXTINT9 : constant Peripheral_Function := A;
PB25_EIC_EXTINT9 : constant Peripheral_Function := A;
PC07_EIC_EXTINT9 : constant Peripheral_Function := A;
PC25_EIC_EXTINT9 : constant Peripheral_Function := A;
PA10_EIC_EXTINT10 : constant Peripheral_Function := A;
PB10_EIC_EXTINT10 : constant Peripheral_Function := A;
PC10_EIC_EXTINT10 : constant Peripheral_Function := A;
PC26_EIC_EXTINT10 : constant Peripheral_Function := A;
PA11_EIC_EXTINT11 : constant Peripheral_Function := A;
PA27_EIC_EXTINT11 : constant Peripheral_Function := A;
PB11_EIC_EXTINT11 : constant Peripheral_Function := A;
PC11_EIC_EXTINT11 : constant Peripheral_Function := A;
PC27_EIC_EXTINT11 : constant Peripheral_Function := A;
PA12_EIC_EXTINT12 : constant Peripheral_Function := A;
PB12_EIC_EXTINT12 : constant Peripheral_Function := A;
PC12_EIC_EXTINT12 : constant Peripheral_Function := A;
PC28_EIC_EXTINT12 : constant Peripheral_Function := A;
PA13_EIC_EXTINT13 : constant Peripheral_Function := A;
PB13_EIC_EXTINT13 : constant Peripheral_Function := A;
PC13_EIC_EXTINT13 : constant Peripheral_Function := A;
PA30_EIC_EXTINT14 : constant Peripheral_Function := A;
PB14_EIC_EXTINT14 : constant Peripheral_Function := A;
PB30_EIC_EXTINT14 : constant Peripheral_Function := A;
PC14_EIC_EXTINT14 : constant Peripheral_Function := A;
PA14_EIC_EXTINT14 : constant Peripheral_Function := A;
PA15_EIC_EXTINT15 : constant Peripheral_Function := A;
PA31_EIC_EXTINT15 : constant Peripheral_Function := A;
PB15_EIC_EXTINT15 : constant Peripheral_Function := A;
PB31_EIC_EXTINT15 : constant Peripheral_Function := A;
PC15_EIC_EXTINT15 : constant Peripheral_Function := A;
PA08_EIC_NMI : constant Peripheral_Function := A;
PA30_GCLK_IO0 : constant Peripheral_Function := M;
PB14_GCLK_IO0 : constant Peripheral_Function := M;
PA14_GCLK_IO0 : constant Peripheral_Function := M;
PB22_GCLK_IO0 : constant Peripheral_Function := M;
PB15_GCLK_IO1 : constant Peripheral_Function := M;
PA15_GCLK_IO1 : constant Peripheral_Function := M;
PB23_GCLK_IO1 : constant Peripheral_Function := M;
PA27_GCLK_IO1 : constant Peripheral_Function := M;
PA16_GCLK_IO2 : constant Peripheral_Function := M;
PB16_GCLK_IO2 : constant Peripheral_Function := M;
PA17_GCLK_IO3 : constant Peripheral_Function := M;
PB17_GCLK_IO3 : constant Peripheral_Function := M;
PA10_GCLK_IO4 : constant Peripheral_Function := M;
PB10_GCLK_IO4 : constant Peripheral_Function := M;
PB18_GCLK_IO4 : constant Peripheral_Function := M;
PA11_GCLK_IO5 : constant Peripheral_Function := M;
PB11_GCLK_IO5 : constant Peripheral_Function := M;
PB19_GCLK_IO5 : constant Peripheral_Function := M;
PB12_GCLK_IO6 : constant Peripheral_Function := M;
PB20_GCLK_IO6 : constant Peripheral_Function := M;
PB13_GCLK_IO7 : constant Peripheral_Function := M;
PB21_GCLK_IO7 : constant Peripheral_Function := M;
PA09_I2S_FS0 : constant Peripheral_Function := J;
PA20_I2S_FS0 : constant Peripheral_Function := J;
PA23_I2S_FS1 : constant Peripheral_Function := J;
PB11_I2S_FS1 : constant Peripheral_Function := J;
PA08_I2S_MCK0 : constant Peripheral_Function := J;
PB17_I2S_MCK0 : constant Peripheral_Function := J;
PB13_I2S_MCK1 : constant Peripheral_Function := J;
PA10_I2S_SCK0 : constant Peripheral_Function := J;
PB16_I2S_SCK0 : constant Peripheral_Function := J;
PB12_I2S_SCK1 : constant Peripheral_Function := J;
PA22_I2S_SDI : constant Peripheral_Function := J;
PB10_I2S_SDI : constant Peripheral_Function := J;
PA11_I2S_SDO : constant Peripheral_Function := J;
PA21_I2S_SDO : constant Peripheral_Function := J;
PA14_PCC_CLK : constant Peripheral_Function := K;
PA16_PCC_DATA0 : constant Peripheral_Function := K;
PA17_PCC_DATA1 : constant Peripheral_Function := K;
PA18_PCC_DATA2 : constant Peripheral_Function := K;
PA19_PCC_DATA3 : constant Peripheral_Function := K;
PA20_PCC_DATA4 : constant Peripheral_Function := K;
PA21_PCC_DATA5 : constant Peripheral_Function := K;
PA22_PCC_DATA6 : constant Peripheral_Function := K;
PA23_PCC_DATA7 : constant Peripheral_Function := K;
PB14_PCC_DATA8 : constant Peripheral_Function := K;
PB15_PCC_DATA9 : constant Peripheral_Function := K;
PC12_PCC_DATA10 : constant Peripheral_Function := K;
PC13_PCC_DATA11 : constant Peripheral_Function := K;
PC14_PCC_DATA12 : constant Peripheral_Function := K;
PC15_PCC_DATA13 : constant Peripheral_Function := K;
PA12_PCC_DEN1 : constant Peripheral_Function := K;
PA13_PCC_DEN2 : constant Peripheral_Function := K;
PB18_PDEC_QDI0 : constant Peripheral_Function := G;
PB23_PDEC_QDI0 : constant Peripheral_Function := G;
PC16_PDEC_QDI0 : constant Peripheral_Function := G;
PA24_PDEC_QDI0 : constant Peripheral_Function := G;
PB19_PDEC_QDI1 : constant Peripheral_Function := G;
PB24_PDEC_QDI1 : constant Peripheral_Function := G;
PC17_PDEC_QDI1 : constant Peripheral_Function := G;
PA25_PDEC_QDI1 : constant Peripheral_Function := G;
PB20_PDEC_QDI2 : constant Peripheral_Function := G;
PB25_PDEC_QDI2 : constant Peripheral_Function := G;
PC18_PDEC_QDI2 : constant Peripheral_Function := G;
PB22_PDEC_QDI2 : constant Peripheral_Function := G;
PB11_QSPI_CS : constant Peripheral_Function := H;
PA08_QSPI_DATA0 : constant Peripheral_Function := H;
PA09_QSPI_DATA1 : constant Peripheral_Function := H;
PA10_QSPI_DATA2 : constant Peripheral_Function := H;
PA11_QSPI_DATA3 : constant Peripheral_Function := H;
PB10_QSPI_SCK : constant Peripheral_Function := H;
PA06_SDHC0_SDCD : constant Peripheral_Function := I;
PA12_SDHC0_SDCD : constant Peripheral_Function := I;
PB12_SDHC0_SDCD : constant Peripheral_Function := I;
PC06_SDHC0_SDCD : constant Peripheral_Function := I;
PB11_SDHC0_SDCK : constant Peripheral_Function := I;
PA08_SDHC0_SDCMD : constant Peripheral_Function := I;
PA09_SDHC0_SDDAT0 : constant Peripheral_Function := I;
PA10_SDHC0_SDDAT1 : constant Peripheral_Function := I;
PA11_SDHC0_SDDAT2 : constant Peripheral_Function := I;
PB10_SDHC0_SDDAT3 : constant Peripheral_Function := I;
PA07_SDHC0_SDWP : constant Peripheral_Function := I;
PA13_SDHC0_SDWP : constant Peripheral_Function := I;
PB13_SDHC0_SDWP : constant Peripheral_Function := I;
PC07_SDHC0_SDWP : constant Peripheral_Function := I;
PB16_SDHC1_SDCD : constant Peripheral_Function := I;
PC20_SDHC1_SDCD : constant Peripheral_Function := I;
PA21_SDHC1_SDCK : constant Peripheral_Function := I;
PA20_SDHC1_SDCMD : constant Peripheral_Function := I;
PB18_SDHC1_SDDAT0 : constant Peripheral_Function := I;
PB19_SDHC1_SDDAT1 : constant Peripheral_Function := I;
PB20_SDHC1_SDDAT2 : constant Peripheral_Function := I;
PB21_SDHC1_SDDAT3 : constant Peripheral_Function := I;
PB17_SDHC1_SDWP : constant Peripheral_Function := I;
PC21_SDHC1_SDWP : constant Peripheral_Function := I;
PA04_SERCOM0_PAD0 : constant Peripheral_Function := D;
PC17_SERCOM0_PAD0 : constant Peripheral_Function := D;
PA08_SERCOM0_PAD0 : constant Peripheral_Function := C;
PB24_SERCOM0_PAD0 : constant Peripheral_Function := C;
PA05_SERCOM0_PAD1 : constant Peripheral_Function := D;
PC16_SERCOM0_PAD1 : constant Peripheral_Function := D;
PA09_SERCOM0_PAD1 : constant Peripheral_Function := C;
PB25_SERCOM0_PAD1 : constant Peripheral_Function := C;
PA06_SERCOM0_PAD2 : constant Peripheral_Function := D;
PC18_SERCOM0_PAD2 : constant Peripheral_Function := D;
PA10_SERCOM0_PAD2 : constant Peripheral_Function := C;
PC24_SERCOM0_PAD2 : constant Peripheral_Function := C;
PA07_SERCOM0_PAD3 : constant Peripheral_Function := D;
PC19_SERCOM0_PAD3 : constant Peripheral_Function := D;
PA11_SERCOM0_PAD3 : constant Peripheral_Function := C;
PC25_SERCOM0_PAD3 : constant Peripheral_Function := C;
PA00_SERCOM1_PAD0 : constant Peripheral_Function := D;
PA16_SERCOM1_PAD0 : constant Peripheral_Function := C;
PC27_SERCOM1_PAD0 : constant Peripheral_Function := C;
PA01_SERCOM1_PAD1 : constant Peripheral_Function := D;
PA17_SERCOM1_PAD1 : constant Peripheral_Function := C;
PC28_SERCOM1_PAD1 : constant Peripheral_Function := C;
PA30_SERCOM1_PAD2 : constant Peripheral_Function := D;
PA18_SERCOM1_PAD2 : constant Peripheral_Function := C;
PB22_SERCOM1_PAD2 : constant Peripheral_Function := C;
PA31_SERCOM1_PAD3 : constant Peripheral_Function := D;
PA19_SERCOM1_PAD3 : constant Peripheral_Function := C;
PB23_SERCOM1_PAD3 : constant Peripheral_Function := C;
PA09_SERCOM2_PAD0 : constant Peripheral_Function := D;
PB25_SERCOM2_PAD0 : constant Peripheral_Function := D;
PA12_SERCOM2_PAD0 : constant Peripheral_Function := C;
PA08_SERCOM2_PAD1 : constant Peripheral_Function := D;
PB24_SERCOM2_PAD1 : constant Peripheral_Function := D;
PA13_SERCOM2_PAD1 : constant Peripheral_Function := C;
PA10_SERCOM2_PAD2 : constant Peripheral_Function := D;
PC24_SERCOM2_PAD2 : constant Peripheral_Function := D;
PA14_SERCOM2_PAD2 : constant Peripheral_Function := C;
PA11_SERCOM2_PAD3 : constant Peripheral_Function := D;
PC25_SERCOM2_PAD3 : constant Peripheral_Function := D;
PA15_SERCOM2_PAD3 : constant Peripheral_Function := C;
PA17_SERCOM3_PAD0 : constant Peripheral_Function := D;
PA22_SERCOM3_PAD0 : constant Peripheral_Function := C;
PB20_SERCOM3_PAD0 : constant Peripheral_Function := C;
PA16_SERCOM3_PAD1 : constant Peripheral_Function := D;
PA23_SERCOM3_PAD1 : constant Peripheral_Function := C;
PB21_SERCOM3_PAD1 : constant Peripheral_Function := C;
PA18_SERCOM3_PAD2 : constant Peripheral_Function := D;
PA20_SERCOM3_PAD2 : constant Peripheral_Function := D;
PA24_SERCOM3_PAD2 : constant Peripheral_Function := C;
PA19_SERCOM3_PAD3 : constant Peripheral_Function := D;
PA21_SERCOM3_PAD3 : constant Peripheral_Function := D;
PA25_SERCOM3_PAD3 : constant Peripheral_Function := C;
PA13_SERCOM4_PAD0 : constant Peripheral_Function := D;
PB08_SERCOM4_PAD0 : constant Peripheral_Function := D;
PB12_SERCOM4_PAD0 : constant Peripheral_Function := C;
PA12_SERCOM4_PAD1 : constant Peripheral_Function := D;
PB09_SERCOM4_PAD1 : constant Peripheral_Function := D;
PB13_SERCOM4_PAD1 : constant Peripheral_Function := C;
PA14_SERCOM4_PAD2 : constant Peripheral_Function := D;
PB10_SERCOM4_PAD2 : constant Peripheral_Function := D;
PB14_SERCOM4_PAD2 : constant Peripheral_Function := C;
PB11_SERCOM4_PAD3 : constant Peripheral_Function := D;
PA15_SERCOM4_PAD3 : constant Peripheral_Function := D;
PB15_SERCOM4_PAD3 : constant Peripheral_Function := C;
PA23_SERCOM5_PAD0 : constant Peripheral_Function := D;
PB02_SERCOM5_PAD0 : constant Peripheral_Function := D;
PB31_SERCOM5_PAD0 : constant Peripheral_Function := D;
PB16_SERCOM5_PAD0 : constant Peripheral_Function := C;
PA22_SERCOM5_PAD1 : constant Peripheral_Function := D;
PB03_SERCOM5_PAD1 : constant Peripheral_Function := D;
PB30_SERCOM5_PAD1 : constant Peripheral_Function := D;
PB17_SERCOM5_PAD1 : constant Peripheral_Function := C;
PA24_SERCOM5_PAD2 : constant Peripheral_Function := D;
PB00_SERCOM5_PAD2 : constant Peripheral_Function := D;
PB22_SERCOM5_PAD2 : constant Peripheral_Function := D;
PA20_SERCOM5_PAD2 : constant Peripheral_Function := C;
PB18_SERCOM5_PAD2 : constant Peripheral_Function := C;
PA25_SERCOM5_PAD3 : constant Peripheral_Function := D;
PB01_SERCOM5_PAD3 : constant Peripheral_Function := D;
PB23_SERCOM5_PAD3 : constant Peripheral_Function := D;
PA21_SERCOM5_PAD3 : constant Peripheral_Function := C;
PB19_SERCOM5_PAD3 : constant Peripheral_Function := C;
PC13_SERCOM6_PAD0 : constant Peripheral_Function := D;
PC16_SERCOM6_PAD0 : constant Peripheral_Function := C;
PC12_SERCOM6_PAD1 : constant Peripheral_Function := D;
PC05_SERCOM6_PAD1 : constant Peripheral_Function := C;
PC17_SERCOM6_PAD1 : constant Peripheral_Function := C;
PC14_SERCOM6_PAD2 : constant Peripheral_Function := D;
PC06_SERCOM6_PAD2 : constant Peripheral_Function := C;
PC10_SERCOM6_PAD2 : constant Peripheral_Function := C;
PC18_SERCOM6_PAD2 : constant Peripheral_Function := C;
PC15_SERCOM6_PAD3 : constant Peripheral_Function := D;
PC07_SERCOM6_PAD3 : constant Peripheral_Function := C;
PC11_SERCOM6_PAD3 : constant Peripheral_Function := C;
PC19_SERCOM6_PAD3 : constant Peripheral_Function := C;
PB21_SERCOM7_PAD0 : constant Peripheral_Function := D;
PB30_SERCOM7_PAD0 : constant Peripheral_Function := C;
PC12_SERCOM7_PAD0 : constant Peripheral_Function := C;
PB20_SERCOM7_PAD1 : constant Peripheral_Function := D;
PB31_SERCOM7_PAD1 : constant Peripheral_Function := C;
PC13_SERCOM7_PAD1 : constant Peripheral_Function := C;
PB18_SERCOM7_PAD2 : constant Peripheral_Function := D;
PC10_SERCOM7_PAD2 : constant Peripheral_Function := D;
PC14_SERCOM7_PAD2 : constant Peripheral_Function := C;
PA30_SERCOM7_PAD2 : constant Peripheral_Function := C;
PB19_SERCOM7_PAD3 : constant Peripheral_Function := D;
PC11_SERCOM7_PAD3 : constant Peripheral_Function := D;
PC15_SERCOM7_PAD3 : constant Peripheral_Function := C;
PA31_SERCOM7_PAD3 : constant Peripheral_Function := C;
PA04_TC0_WO0 : constant Peripheral_Function := E;
PA08_TC0_WO0 : constant Peripheral_Function := E;
PB30_TC0_WO0 : constant Peripheral_Function := E;
PA05_TC0_WO1 : constant Peripheral_Function := E;
PA09_TC0_WO1 : constant Peripheral_Function := E;
PB31_TC0_WO1 : constant Peripheral_Function := E;
PA06_TC1_WO0 : constant Peripheral_Function := E;
PA10_TC1_WO0 : constant Peripheral_Function := E;
PA07_TC1_WO1 : constant Peripheral_Function := E;
PA11_TC1_WO1 : constant Peripheral_Function := E;
PA12_TC2_WO0 : constant Peripheral_Function := E;
PA16_TC2_WO0 : constant Peripheral_Function := E;
PA00_TC2_WO0 : constant Peripheral_Function := E;
PA01_TC2_WO1 : constant Peripheral_Function := E;
PA13_TC2_WO1 : constant Peripheral_Function := E;
PA17_TC2_WO1 : constant Peripheral_Function := E;
PA18_TC3_WO0 : constant Peripheral_Function := E;
PA14_TC3_WO0 : constant Peripheral_Function := E;
PA15_TC3_WO1 : constant Peripheral_Function := E;
PA19_TC3_WO1 : constant Peripheral_Function := E;
PA22_TC4_WO0 : constant Peripheral_Function := E;
PB08_TC4_WO0 : constant Peripheral_Function := E;
PB12_TC4_WO0 : constant Peripheral_Function := E;
PA23_TC4_WO1 : constant Peripheral_Function := E;
PB09_TC4_WO1 : constant Peripheral_Function := E;
PB13_TC4_WO1 : constant Peripheral_Function := E;
PA24_TC5_WO0 : constant Peripheral_Function := E;
PB10_TC5_WO0 : constant Peripheral_Function := E;
PB14_TC5_WO0 : constant Peripheral_Function := E;
PA25_TC5_WO1 : constant Peripheral_Function := E;
PB11_TC5_WO1 : constant Peripheral_Function := E;
PB15_TC5_WO1 : constant Peripheral_Function := E;
PA30_TC6_WO0 : constant Peripheral_Function := E;
PB02_TC6_WO0 : constant Peripheral_Function := E;
PB16_TC6_WO0 : constant Peripheral_Function := E;
PA31_TC6_WO1 : constant Peripheral_Function := E;
PB03_TC6_WO1 : constant Peripheral_Function := E;
PB17_TC6_WO1 : constant Peripheral_Function := E;
PA20_TC7_WO0 : constant Peripheral_Function := E;
PB00_TC7_WO0 : constant Peripheral_Function := E;
PB22_TC7_WO0 : constant Peripheral_Function := E;
PA21_TC7_WO1 : constant Peripheral_Function := E;
PB01_TC7_WO1 : constant Peripheral_Function := E;
PB23_TC7_WO1 : constant Peripheral_Function := E;
PA20_TCC0_WO0 : constant Peripheral_Function := G;
PB12_TCC0_WO0 : constant Peripheral_Function := G;
PA08_TCC0_WO0 : constant Peripheral_Function := F;
PC10_TCC0_WO0 : constant Peripheral_Function := F;
PC16_TCC0_WO0 : constant Peripheral_Function := F;
PA21_TCC0_WO1 : constant Peripheral_Function := G;
PB13_TCC0_WO1 : constant Peripheral_Function := G;
PA09_TCC0_WO1 : constant Peripheral_Function := F;
PC11_TCC0_WO1 : constant Peripheral_Function := F;
PC17_TCC0_WO1 : constant Peripheral_Function := F;
PA22_TCC0_WO2 : constant Peripheral_Function := G;
PB14_TCC0_WO2 : constant Peripheral_Function := G;
PA10_TCC0_WO2 : constant Peripheral_Function := F;
PC12_TCC0_WO2 : constant Peripheral_Function := F;
PC18_TCC0_WO2 : constant Peripheral_Function := F;
PA23_TCC0_WO3 : constant Peripheral_Function := G;
PB15_TCC0_WO3 : constant Peripheral_Function := G;
PA11_TCC0_WO3 : constant Peripheral_Function := F;
PC13_TCC0_WO3 : constant Peripheral_Function := F;
PC19_TCC0_WO3 : constant Peripheral_Function := F;
PA16_TCC0_WO4 : constant Peripheral_Function := G;
PB16_TCC0_WO4 : constant Peripheral_Function := G;
PB10_TCC0_WO4 : constant Peripheral_Function := F;
PC14_TCC0_WO4 : constant Peripheral_Function := F;
PC20_TCC0_WO4 : constant Peripheral_Function := F;
PA17_TCC0_WO5 : constant Peripheral_Function := G;
PB17_TCC0_WO5 : constant Peripheral_Function := G;
PB11_TCC0_WO5 : constant Peripheral_Function := F;
PC15_TCC0_WO5 : constant Peripheral_Function := F;
PC21_TCC0_WO5 : constant Peripheral_Function := F;
PA18_TCC0_WO6 : constant Peripheral_Function := G;
PB30_TCC0_WO6 : constant Peripheral_Function := G;
PA12_TCC0_WO6 : constant Peripheral_Function := F;
PA19_TCC0_WO7 : constant Peripheral_Function := G;
PB31_TCC0_WO7 : constant Peripheral_Function := G;
PA13_TCC0_WO7 : constant Peripheral_Function := F;
PB10_TCC1_WO0 : constant Peripheral_Function := G;
PC14_TCC1_WO0 : constant Peripheral_Function := G;
PA16_TCC1_WO0 : constant Peripheral_Function := F;
PB18_TCC1_WO0 : constant Peripheral_Function := F;
PB11_TCC1_WO1 : constant Peripheral_Function := G;
PC15_TCC1_WO1 : constant Peripheral_Function := G;
PA17_TCC1_WO1 : constant Peripheral_Function := F;
PB19_TCC1_WO1 : constant Peripheral_Function := F;
PA12_TCC1_WO2 : constant Peripheral_Function := G;
PA14_TCC1_WO2 : constant Peripheral_Function := G;
PA18_TCC1_WO2 : constant Peripheral_Function := F;
PB20_TCC1_WO2 : constant Peripheral_Function := F;
PA13_TCC1_WO3 : constant Peripheral_Function := G;
PA15_TCC1_WO3 : constant Peripheral_Function := G;
PA19_TCC1_WO3 : constant Peripheral_Function := F;
PB21_TCC1_WO3 : constant Peripheral_Function := F;
PA08_TCC1_WO4 : constant Peripheral_Function := G;
PC10_TCC1_WO4 : constant Peripheral_Function := G;
PA20_TCC1_WO4 : constant Peripheral_Function := F;
PA09_TCC1_WO5 : constant Peripheral_Function := G;
PC11_TCC1_WO5 : constant Peripheral_Function := G;
PA21_TCC1_WO5 : constant Peripheral_Function := F;
PA10_TCC1_WO6 : constant Peripheral_Function := G;
PC12_TCC1_WO6 : constant Peripheral_Function := G;
PA22_TCC1_WO6 : constant Peripheral_Function := F;
PA11_TCC1_WO7 : constant Peripheral_Function := G;
PC13_TCC1_WO7 : constant Peripheral_Function := G;
PA23_TCC1_WO7 : constant Peripheral_Function := F;
PA14_TCC2_WO0 : constant Peripheral_Function := F;
PA30_TCC2_WO0 : constant Peripheral_Function := F;
PA15_TCC2_WO1 : constant Peripheral_Function := F;
PA31_TCC2_WO1 : constant Peripheral_Function := F;
PA24_TCC2_WO2 : constant Peripheral_Function := F;
PB02_TCC2_WO2 : constant Peripheral_Function := F;
PB12_TCC3_WO0 : constant Peripheral_Function := F;
PB16_TCC3_WO0 : constant Peripheral_Function := F;
PB13_TCC3_WO1 : constant Peripheral_Function := F;
PB17_TCC3_WO1 : constant Peripheral_Function := F;
PB14_TCC4_WO0 : constant Peripheral_Function := F;
PB30_TCC4_WO0 : constant Peripheral_Function := F;
PB15_TCC4_WO1 : constant Peripheral_Function := F;
PB31_TCC4_WO1 : constant Peripheral_Function := F;
PA24_USB_DM : constant Peripheral_Function := H;
PA25_USB_DP : constant Peripheral_Function := H;
PA23_USB_SOF_1KHZ : constant Peripheral_Function := H;
PB22_USB_SOF_1KHZ : constant Peripheral_Function := H;
end SAM.Functions;
|
AdaCore/Ada_Drivers_Library | Ada | 8,416 | ads | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with System;
package HAL.Filesystem is
pragma Preelaborate;
type Status_Code is
(OK,
Non_Empty_Directory,
Disk_Error, -- A hardware error occurred in the low level disk I/O
Disk_Full,
Internal_Error,
Drive_Not_Ready,
No_Such_File,
No_Such_Path,
Not_Mounted, -- The mount point is invalid
Invalid_Name,
Access_Denied,
Already_Exists,
Invalid_Object_Entry,
Write_Protected,
Invalid_Drive,
No_Filesystem, -- The volume is not a FAT volume
Locked,
Too_Many_Open_Files, -- All available handles are used
Invalid_Parameter,
Input_Output_Error,
No_MBR_Found,
No_Partition_Found,
No_More_Entries,
Read_Only_File_System,
Operation_Not_Permitted);
type File_Mode is (Read_Only, Write_Only, Read_Write);
type Seek_Mode is
(
-- Seek from the beginning of the file, forward
From_Start,
-- Seek from the end of the file, backward
From_End,
-- Seek from the current position, forward
Forward,
-- Seek from the current position, backward
Backward);
type File_Size is new HAL.UInt64;
-- Modern fs all support 64-bit file size. Only old or limited ones support
-- max 32-bit (FAT in particular). So let's see big and not limit ourselves
-- in this API with 32-bit only.
type Filesystem_Driver is limited interface;
type Any_Filesystem_Driver is access all Filesystem_Driver'Class;
type Directory_Handle is limited interface;
type Any_Directory_Handle is access all Directory_Handle'Class;
type File_Handle is limited interface;
type Any_File_Handle is access all File_Handle'Class;
type Node_Handle is interface;
type Any_Node_Handle is access all Node_Handle'Class;
---------------------------
-- Directory operations --
---------------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Handle : out Any_Directory_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Create_File (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
function Unlink (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the regular file located at Path in the This filesystem_Driver
function Remove_Directory (This : in out Filesystem_Driver;
Path : String)
return Status_Code is abstract;
-- Remove the directory located at Path in the This filesystem_Driver
function Get_FS
(This : Directory_Handle) return Any_Filesystem_Driver
is abstract;
-- Return the filesystem_Driver the handle belongs to.
function Root_Node
(This : in out Filesystem_Driver;
As : String;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Open a new Directory Handle at the given Filesystem_Driver Path
function Read
(This : in out Directory_Handle;
Handle : out Any_Node_Handle)
return Status_Code is abstract;
-- Reads the next directory entry. If no such entry is there, an error
-- code is returned in Status.
procedure Reset (This : in out Directory_Handle) is abstract;
-- Resets the handle to the first node
procedure Close (This : in out Directory_Handle) is abstract;
-- Closes the handle, and free the associated resources.
---------------------
-- Node operations --
---------------------
function Get_FS (This : Node_Handle) return Any_Filesystem_Driver is abstract;
function Basename (This : Node_Handle) return String is abstract;
function Is_Read_Only (This : Node_Handle) return Boolean is abstract;
function Is_Hidden (This : Node_Handle) return Boolean is abstract;
function Is_Subdirectory (This : Node_Handle) return Boolean is abstract;
function Is_Symlink (This : Node_Handle) return Boolean is abstract;
function Size (This : Node_Handle) return File_Size is abstract;
procedure Close (This : in out Node_Handle) is abstract;
---------------------
-- File operations --
---------------------
function Open
(This : in out Filesystem_Driver;
Path : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract;
-- Open a new File Handle at the given Filesystem_Driver Path
function Open
(This : Node_Handle;
Name : String;
Mode : File_Mode;
Handle : out Any_File_Handle)
return Status_Code is abstract
with Pre'Class => Is_Subdirectory (This);
function Get_FS
(This : in out File_Handle) return Any_Filesystem_Driver is abstract;
function Size
(This : File_Handle) return File_Size is abstract;
function Mode
(This : File_Handle) return File_Mode is abstract;
function Read
(This : in out File_Handle;
Addr : System.Address;
Length : in out File_Size)
return Status_Code is abstract
with Pre'Class => Mode (This) in Read_Only | Read_Write;
function Write
(This : in out File_Handle;
Addr : System.Address;
Length : File_Size)
return Status_Code is abstract
with
Pre'Class => Mode (This) in Write_Only | Read_Write;
function Offset
(This : File_Handle)
return File_Size is abstract;
function Flush
(This : in out File_Handle)
return Status_Code is abstract;
function Seek
(This : in out File_Handle;
Origin : Seek_Mode;
Amount : in out File_Size)
return Status_Code is abstract;
procedure Close (This : in out File_Handle) is abstract;
-------------------
-- FS operations --
-------------------
procedure Close (This : in out Filesystem_Driver) is abstract;
end HAL.Filesystem;
|
reznikmm/matreshka | Ada | 4,768 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Visitors;
with ODF.DOM.Db_Column_Definition_Elements;
package Matreshka.ODF_Db.Column_Definition_Elements is
type Db_Column_Definition_Element_Node is
new Matreshka.ODF_Db.Abstract_Db_Element_Node
and ODF.DOM.Db_Column_Definition_Elements.ODF_Db_Column_Definition
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Column_Definition_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Db_Column_Definition_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Db_Column_Definition_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Db_Column_Definition_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Db_Column_Definition_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Db.Column_Definition_Elements;
|
stcarrez/ada-libsecret | Ada | 2,375 | ads | -----------------------------------------------------------------------
-- secret-values -- Ada wrapper for Secret Service
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.
-----------------------------------------------------------------------
-- === Secret Values ===
-- A secret value is represented by the <tt>Secret_Type</tt> type. The value is internally
-- held and managed by the libsecret in some secure memory region. The secret value is
-- associated with a content type that can be retrieved as well. The Ada library only creates
-- secret values with the "text/plain" content type.
--
-- A secret value is only copied by reference that is the secret value stored in the secure
-- memory region is shared among different <tt>Secret_Type</tt> instances. A secret value
-- cannot be modified once it is created.
--
-- To create a secret value, you can use the <tt>Create</tt> function as follows:
--
-- Value : Secret.Values.Secret_Type := Secret.Values.Create ("my-secret-password");
--
package Secret.Values is
-- Represents a value returned by the secret server.
type Secret_Type is new Object_Type with null record;
-- Create a value with the default content type text/plain.
function Create (Value : in String) return Secret_Type
with Post => not Create'Result.Is_Null;
-- Get the value content type.
function Get_Content_Type (Value : in Secret_Type) return String
with Pre => not Value.Is_Null;
-- Get the value as a string.
function Get_Value (Value : in Secret_Type) return String
with Pre => not Value.Is_Null;
private
overriding
procedure Adjust (Object : in out Secret_Type);
overriding
procedure Finalize (Object : in out Secret_Type);
end Secret.Values;
|
reznikmm/matreshka | Ada | 6,841 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Dde_Link_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Dde_Link_Element_Node is
begin
return Self : Table_Dde_Link_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Dde_Link_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Table_Dde_Link
(ODF.DOM.Table_Dde_Link_Elements.ODF_Table_Dde_Link_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Dde_Link_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Dde_Link_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Dde_Link_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Table_Dde_Link
(ODF.DOM.Table_Dde_Link_Elements.ODF_Table_Dde_Link_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Table_Dde_Link_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Table_Dde_Link
(Visitor,
ODF.DOM.Table_Dde_Link_Elements.ODF_Table_Dde_Link_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Dde_Link_Element,
Table_Dde_Link_Element_Node'Tag);
end Matreshka.ODF_Table.Dde_Link_Elements;
|
MonadnockSystems/Ada_Drivers_Library | Ada | 3,024 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with NRF51_SVD.TEMP; use NRF51_SVD.TEMP;
with HAL; use HAL;
package body nRF51.Temperature is
type RAW_Temp is delta 0.25 range
Temp_Celsius'First * 4.0 .. Temp_Celsius'Last * 4.0;
----------
-- Read --
----------
function Read return Temp_Celsius is
Raw : RAW_Temp;
begin
-- Clear event
TEMP_Periph.EVENTS_DATARDY := 0;
-- Start temperature measurement
TEMP_Periph.TASKS_START := 1;
while TEMP_Periph.EVENTS_DATARDY = 0 loop
null;
end loop;
Raw := RAW_Temp (TEMP_Periph.TEMP);
return Temp_Celsius (Raw / 4);
end Read;
end nRF51.Temperature;
|
charlie5/aIDE | Ada | 1,261 | ads | with
AdaM.Environment,
AdaM.Source,
AdaM.compilation_Unit,
AdaM.a_Package,
AdaM.a_Type,
AdaM.Declaration.of_package,
ada.Strings.Unbounded.Hash,
ada.Containers.Hashed_Maps;
package AdaM.Assist.Query.find_All.Metrics
is
Environment : AdaM.Environment.item;
standard_Unit : AdaM.compilation_Unit.item;
compilation_Unit : AdaM.compilation_Unit.item; -- Current
current_Packages : AdaM.a_Package.Vector;
all_Types : AdaM.a_Type.Vector;
use type a_Package.view;
package name_Maps_of_package is new ada.Containers.Hashed_Maps (Key_Type => ada.Strings.Unbounded.Unbounded_String,
Element_Type => a_Package.view,
Hash => ada.Strings.Unbounded.Hash,
Equivalent_Keys => "=");
all_Packages : name_Maps_of_package.Map;
current_compilation_Unit : AdaM.compilation_Unit.view;
current_package_Declaration : AdaM.Declaration.of_package.view;
current_Parent : AdaM.Source.Entity_View;
procedure dummy;
end AdaM.Assist.Query.find_All.Metrics;
|
sparre/Ada-2012-Examples | Ada | 584 | ads | with Classes.Parent;
package Classes.Child is
subtype Parent is Classes.Parent.Instance;
type Instance is new Parent with private;
subtype Class is Instance'Class;
type Reference is access all Instance;
type Years is range -60_000_000_000 .. +60_000_000_000;
subtype Human_Age is Years range 0 .. 150;
procedure Set (Item : in out Instance;
Age : in Human_Age);
function Age (Item : in Instance) return Human_Age;
private
type Instance is new Parent with
record
Age : Human_Age;
end record;
end Classes.Child;
|
zhmu/ananas | Ada | 43,311 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- G N A T . G R A P H S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2018-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body GNAT.Graphs is
-----------------------
-- Local subprograms --
-----------------------
function Sequence_Next_Component return Component_Id;
-- Produce the next handle for a component. The handle is guaranteed to be
-- unique across all graphs.
--------------------
-- Directed_Graph --
--------------------
package body Directed_Graphs is
-----------------------
-- Local subprograms --
-----------------------
procedure Add_Component
(G : Directed_Graph;
Comp : Component_Id;
Vertices : Vertex_List.Doubly_Linked_List);
pragma Inline (Add_Component);
-- Add component Comp which houses vertices Vertices to graph G
procedure Ensure_Created (G : Directed_Graph);
pragma Inline (Ensure_Created);
-- Verify that graph G is created. Raise Not_Created if this is not the
-- case.
procedure Ensure_Not_Present
(G : Directed_Graph;
E : Edge_Id);
pragma Inline (Ensure_Not_Present);
-- Verify that graph G lacks edge E. Raise Duplicate_Edge if this is not
-- the case.
procedure Ensure_Not_Present
(G : Directed_Graph;
V : Vertex_Id);
pragma Inline (Ensure_Not_Present);
-- Verify that graph G lacks vertex V. Raise Duplicate_Vertex if this is
-- not the case.
procedure Ensure_Present
(G : Directed_Graph;
Comp : Component_Id);
pragma Inline (Ensure_Present);
-- Verify that component Comp exists in graph G. Raise Missing_Component
-- if this is not the case.
procedure Ensure_Present
(G : Directed_Graph;
E : Edge_Id);
pragma Inline (Ensure_Present);
-- Verify that edge E is present in graph G. Raise Missing_Edge if this
-- is not the case.
procedure Ensure_Present
(G : Directed_Graph;
V : Vertex_Id);
pragma Inline (Ensure_Present);
-- Verify that vertex V is present in graph G. Raise Missing_Vertex if
-- this is not the case.
procedure Free is
new Ada.Unchecked_Deallocation
(Directed_Graph_Attributes, Directed_Graph);
function Get_Component_Attributes
(G : Directed_Graph;
Comp : Component_Id) return Component_Attributes;
pragma Inline (Get_Component_Attributes);
-- Obtain the attributes of component Comp of graph G
function Get_Edge_Attributes
(G : Directed_Graph;
E : Edge_Id) return Edge_Attributes;
pragma Inline (Get_Edge_Attributes);
-- Obtain the attributes of edge E of graph G
function Get_Vertex_Attributes
(G : Directed_Graph;
V : Vertex_Id) return Vertex_Attributes;
pragma Inline (Get_Vertex_Attributes);
-- Obtain the attributes of vertex V of graph G
function Get_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Edge_Set.Membership_Set;
pragma Inline (Get_Outgoing_Edges);
-- Obtain the Outgoing_Edges attribute of vertex V of graph G
function Get_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Vertex_List.Doubly_Linked_List;
pragma Inline (Get_Vertices);
-- Obtain the Vertices attribute of component Comp of graph G
procedure Set_Component
(G : Directed_Graph;
V : Vertex_Id;
Val : Component_Id);
pragma Inline (Set_Component);
-- Set attribute Component of vertex V of graph G to value Val
procedure Set_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id;
Val : Edge_Set.Membership_Set);
pragma Inline (Set_Outgoing_Edges);
-- Set attribute Outgoing_Edges of vertex V of graph G to value Val
procedure Set_Vertex_Attributes
(G : Directed_Graph;
V : Vertex_Id;
Val : Vertex_Attributes);
pragma Inline (Set_Vertex_Attributes);
-- Set the attributes of vertex V of graph G to value Val
-------------------
-- Add_Component --
-------------------
procedure Add_Component
(G : Directed_Graph;
Comp : Component_Id;
Vertices : Vertex_List.Doubly_Linked_List)
is
begin
pragma Assert (Present (G));
-- Add the component to the set of all components in the graph
Component_Map.Put
(T => G.Components,
Key => Comp,
Value => (Vertices => Vertices));
end Add_Component;
--------------
-- Add_Edge --
--------------
procedure Add_Edge
(G : Directed_Graph;
E : Edge_Id;
Source : Vertex_Id;
Destination : Vertex_Id)
is
begin
Ensure_Created (G);
Ensure_Not_Present (G, E);
Ensure_Present (G, Source);
Ensure_Present (G, Destination);
-- Add the edge to the set of all edges in the graph
Edge_Map.Put
(T => G.All_Edges,
Key => E,
Value =>
(Destination => Destination,
Source => Source));
-- Associate the edge with its source vertex which effectively "owns"
-- the edge.
Edge_Set.Insert
(S => Get_Outgoing_Edges (G, Source),
Elem => E);
end Add_Edge;
----------------
-- Add_Vertex --
----------------
procedure Add_Vertex
(G : Directed_Graph;
V : Vertex_Id)
is
begin
Ensure_Created (G);
Ensure_Not_Present (G, V);
-- Add the vertex to the set of all vertices in the graph
Vertex_Map.Put
(T => G.All_Vertices,
Key => V,
Value =>
(Component => No_Component,
Outgoing_Edges => Edge_Set.Nil));
-- It is assumed that the vertex will have at least one outgoing
-- edge. It is important not to create the set of edges above as
-- the call to Put may fail in case the vertices are iterated.
-- This would lead to a memory leak because the set would not be
-- reclaimed.
Set_Outgoing_Edges (G, V, Edge_Set.Create (1));
end Add_Vertex;
---------------
-- Component --
---------------
function Component
(G : Directed_Graph;
V : Vertex_Id) return Component_Id
is
begin
Ensure_Created (G);
Ensure_Present (G, V);
return Get_Vertex_Attributes (G, V).Component;
end Component;
------------------------
-- Contains_Component --
------------------------
function Contains_Component
(G : Directed_Graph;
Comp : Component_Id) return Boolean
is
begin
Ensure_Created (G);
return Component_Map.Contains (G.Components, Comp);
end Contains_Component;
-------------------
-- Contains_Edge --
-------------------
function Contains_Edge
(G : Directed_Graph;
E : Edge_Id) return Boolean
is
begin
Ensure_Created (G);
return Edge_Map.Contains (G.All_Edges, E);
end Contains_Edge;
---------------------
-- Contains_Vertex --
---------------------
function Contains_Vertex
(G : Directed_Graph;
V : Vertex_Id) return Boolean
is
begin
Ensure_Created (G);
return Vertex_Map.Contains (G.All_Vertices, V);
end Contains_Vertex;
------------
-- Create --
------------
function Create
(Initial_Vertices : Positive;
Initial_Edges : Positive) return Directed_Graph
is
G : constant Directed_Graph := new Directed_Graph_Attributes;
begin
G.All_Edges := Edge_Map.Create (Initial_Edges);
G.All_Vertices := Vertex_Map.Create (Initial_Vertices);
G.Components := Component_Map.Create (Initial_Vertices);
return G;
end Create;
-----------------
-- Delete_Edge --
-----------------
procedure Delete_Edge
(G : Directed_Graph;
E : Edge_Id)
is
Source : Vertex_Id;
begin
Ensure_Created (G);
Ensure_Present (G, E);
Source := Source_Vertex (G, E);
Ensure_Present (G, Source);
-- Delete the edge from its source vertex which effectively "owns"
-- the edge.
Edge_Set.Delete (Get_Outgoing_Edges (G, Source), E);
-- Delete the edge from the set of all edges
Edge_Map.Delete (G.All_Edges, E);
end Delete_Edge;
------------------------
-- Destination_Vertex --
------------------------
function Destination_Vertex
(G : Directed_Graph;
E : Edge_Id) return Vertex_Id
is
begin
Ensure_Created (G);
Ensure_Present (G, E);
return Get_Edge_Attributes (G, E).Destination;
end Destination_Vertex;
-------------
-- Destroy --
-------------
procedure Destroy (G : in out Directed_Graph) is
begin
Ensure_Created (G);
Edge_Map.Destroy (G.All_Edges);
Vertex_Map.Destroy (G.All_Vertices);
Component_Map.Destroy (G.Components);
Free (G);
end Destroy;
----------------------------------
-- Destroy_Component_Attributes --
----------------------------------
procedure Destroy_Component_Attributes
(Attrs : in out Component_Attributes)
is
begin
Vertex_List.Destroy (Attrs.Vertices);
end Destroy_Component_Attributes;
-----------------------------
-- Destroy_Edge_Attributes --
-----------------------------
procedure Destroy_Edge_Attributes (Attrs : in out Edge_Attributes) is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Edge_Attributes;
--------------------
-- Destroy_Vertex --
--------------------
procedure Destroy_Vertex (V : in out Vertex_Id) is
pragma Unreferenced (V);
begin
null;
end Destroy_Vertex;
-------------------------------
-- Destroy_Vertex_Attributes --
-------------------------------
procedure Destroy_Vertex_Attributes (Attrs : in out Vertex_Attributes) is
begin
Edge_Set.Destroy (Attrs.Outgoing_Edges);
end Destroy_Vertex_Attributes;
--------------------
-- Ensure_Created --
--------------------
procedure Ensure_Created (G : Directed_Graph) is
begin
if not Present (G) then
raise Not_Created;
end if;
end Ensure_Created;
------------------------
-- Ensure_Not_Present --
------------------------
procedure Ensure_Not_Present
(G : Directed_Graph;
E : Edge_Id)
is
begin
if Contains_Edge (G, E) then
raise Duplicate_Edge;
end if;
end Ensure_Not_Present;
------------------------
-- Ensure_Not_Present --
------------------------
procedure Ensure_Not_Present
(G : Directed_Graph;
V : Vertex_Id)
is
begin
if Contains_Vertex (G, V) then
raise Duplicate_Vertex;
end if;
end Ensure_Not_Present;
--------------------
-- Ensure_Present --
--------------------
procedure Ensure_Present
(G : Directed_Graph;
Comp : Component_Id)
is
begin
if not Contains_Component (G, Comp) then
raise Missing_Component;
end if;
end Ensure_Present;
--------------------
-- Ensure_Present --
--------------------
procedure Ensure_Present
(G : Directed_Graph;
E : Edge_Id)
is
begin
if not Contains_Edge (G, E) then
raise Missing_Edge;
end if;
end Ensure_Present;
--------------------
-- Ensure_Present --
--------------------
procedure Ensure_Present
(G : Directed_Graph;
V : Vertex_Id)
is
begin
if not Contains_Vertex (G, V) then
raise Missing_Vertex;
end if;
end Ensure_Present;
---------------------
-- Find_Components --
---------------------
procedure Find_Components (G : Directed_Graph) is
-- The components of graph G are discovered using Tarjan's strongly
-- connected component algorithm. Do not modify this code unless you
-- intimately understand the algorithm.
----------------
-- Tarjan_Map --
----------------
type Visitation_Number is new Natural;
No_Visitation_Number : constant Visitation_Number :=
Visitation_Number'First;
First_Visitation_Number : constant Visitation_Number :=
No_Visitation_Number + 1;
type Tarjan_Attributes is record
Index : Visitation_Number := No_Visitation_Number;
-- Visitation number
Low_Link : Visitation_Number := No_Visitation_Number;
-- Lowest visitation number
On_Stack : Boolean := False;
-- Set when the corresponding vertex appears on the Stack
end record;
No_Tarjan_Attributes : constant Tarjan_Attributes :=
(Index => No_Visitation_Number,
Low_Link => No_Visitation_Number,
On_Stack => False);
procedure Destroy_Tarjan_Attributes
(Attrs : in out Tarjan_Attributes);
-- Destroy the contents of attributes Attrs
package Tarjan_Map is new Dynamic_Hash_Tables
(Key_Type => Vertex_Id,
Value_Type => Tarjan_Attributes,
No_Value => No_Tarjan_Attributes,
Expansion_Threshold => 1.5,
Expansion_Factor => 2,
Compression_Threshold => 0.3,
Compression_Factor => 2,
"=" => Same_Vertex,
Destroy_Value => Destroy_Tarjan_Attributes,
Hash => Hash_Vertex);
------------------
-- Tarjan_Stack --
------------------
package Tarjan_Stack is new Doubly_Linked_Lists
(Element_Type => Vertex_Id,
"=" => Same_Vertex,
Destroy_Element => Destroy_Vertex);
-----------------
-- Global data --
-----------------
Attrs : Tarjan_Map.Dynamic_Hash_Table := Tarjan_Map.Nil;
Stack : Tarjan_Stack.Doubly_Linked_List := Tarjan_Stack.Nil;
-----------------------
-- Local subprograms --
-----------------------
procedure Associate_All_Vertices;
pragma Inline (Associate_All_Vertices);
-- Associate all vertices in the graph with the corresponding
-- components that house them.
procedure Associate_Vertices (Comp : Component_Id);
pragma Inline (Associate_Vertices);
-- Associate all vertices of component Comp with the component
procedure Create_Component (V : Vertex_Id);
pragma Inline (Create_Component);
-- Create a new component with root vertex V
function Get_Tarjan_Attributes
(V : Vertex_Id) return Tarjan_Attributes;
pragma Inline (Get_Tarjan_Attributes);
-- Obtain the Tarjan attributes of vertex V
function Index (V : Vertex_Id) return Visitation_Number;
pragma Inline (Index);
-- Obtain the Index attribute of vertex V
procedure Initialize_Components;
pragma Inline (Initialize_Components);
-- Initialize or reinitialize the components of the graph
function Is_Visited (V : Vertex_Id) return Boolean;
pragma Inline (Is_Visited);
-- Determine whether vertex V has been visited
function Low_Link (V : Vertex_Id) return Visitation_Number;
pragma Inline (Low_Link);
-- Obtain the Low_Link attribute of vertex V
function On_Stack (V : Vertex_Id) return Boolean;
pragma Inline (On_Stack);
-- Obtain the On_Stack attribute of vertex V
function Pop return Vertex_Id;
pragma Inline (Pop);
-- Pop a vertex off Stack
procedure Push (V : Vertex_Id);
pragma Inline (Push);
-- Push vertex V on Stack
procedure Record_Visit (V : Vertex_Id);
pragma Inline (Record_Visit);
-- Save the visitation of vertex V by setting relevant attributes
function Sequence_Next_Index return Visitation_Number;
pragma Inline (Sequence_Next_Index);
-- Procedure the next visitation number of the DFS traversal
procedure Set_Index
(V : Vertex_Id;
Val : Visitation_Number);
pragma Inline (Set_Index);
-- Set attribute Index of vertex V to value Val
procedure Set_Low_Link
(V : Vertex_Id;
Val : Visitation_Number);
pragma Inline (Set_Low_Link);
-- Set attribute Low_Link of vertex V to value Val
procedure Set_On_Stack
(V : Vertex_Id;
Val : Boolean);
pragma Inline (Set_On_Stack);
-- Set attribute On_Stack of vertex V to value Val
procedure Set_Tarjan_Attributes
(V : Vertex_Id;
Val : Tarjan_Attributes);
pragma Inline (Set_Tarjan_Attributes);
-- Set the attributes of vertex V to value Val
procedure Visit_Successors (V : Vertex_Id);
pragma Inline (Visit_Successors);
-- Visit the successors of vertex V
procedure Visit_Vertex (V : Vertex_Id);
pragma Inline (Visit_Vertex);
-- Visit single vertex V
procedure Visit_Vertices;
pragma Inline (Visit_Vertices);
-- Visit all vertices in the graph
----------------------------
-- Associate_All_Vertices --
----------------------------
procedure Associate_All_Vertices is
Comp : Component_Id;
Iter : Component_Iterator;
begin
Iter := Iterate_Components (G);
while Has_Next (Iter) loop
Next (Iter, Comp);
Associate_Vertices (Comp);
end loop;
end Associate_All_Vertices;
------------------------
-- Associate_Vertices --
------------------------
procedure Associate_Vertices (Comp : Component_Id) is
Iter : Component_Vertex_Iterator;
V : Vertex_Id;
begin
Iter := Iterate_Component_Vertices (G, Comp);
while Has_Next (Iter) loop
Next (Iter, V);
Set_Component (G, V, Comp);
end loop;
end Associate_Vertices;
----------------------
-- Create_Component --
----------------------
procedure Create_Component (V : Vertex_Id) is
Curr_V : Vertex_Id;
Vertices : Vertex_List.Doubly_Linked_List;
begin
Vertices := Vertex_List.Create;
-- Collect all vertices that comprise the current component by
-- popping the stack until reaching the root vertex V.
loop
Curr_V := Pop;
Vertex_List.Append (Vertices, Curr_V);
exit when Same_Vertex (Curr_V, V);
end loop;
Add_Component
(G => G,
Comp => Sequence_Next_Component,
Vertices => Vertices);
end Create_Component;
-------------------------------
-- Destroy_Tarjan_Attributes --
-------------------------------
procedure Destroy_Tarjan_Attributes
(Attrs : in out Tarjan_Attributes)
is
pragma Unreferenced (Attrs);
begin
null;
end Destroy_Tarjan_Attributes;
---------------------------
-- Get_Tarjan_Attributes --
---------------------------
function Get_Tarjan_Attributes
(V : Vertex_Id) return Tarjan_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Tarjan_Map.Get (Attrs, V);
end Get_Tarjan_Attributes;
-----------
-- Index --
-----------
function Index (V : Vertex_Id) return Visitation_Number is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Get_Tarjan_Attributes (V).Index;
end Index;
---------------------------
-- Initialize_Components --
---------------------------
procedure Initialize_Components is
begin
pragma Assert (Present (G));
-- The graph already contains a set of components. Reinitialize
-- them in order to accommodate the new set of components about to
-- be computed.
if Number_Of_Components (G) > 0 then
Component_Map.Destroy (G.Components);
G.Components := Component_Map.Create (Number_Of_Vertices (G));
end if;
end Initialize_Components;
----------------
-- Is_Visited --
----------------
function Is_Visited (V : Vertex_Id) return Boolean is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Index (V) /= No_Visitation_Number;
end Is_Visited;
--------------
-- Low_Link --
--------------
function Low_Link (V : Vertex_Id) return Visitation_Number is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Get_Tarjan_Attributes (V).Low_Link;
end Low_Link;
--------------
-- On_Stack --
--------------
function On_Stack (V : Vertex_Id) return Boolean is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Get_Tarjan_Attributes (V).On_Stack;
end On_Stack;
---------
-- Pop --
---------
function Pop return Vertex_Id is
V : Vertex_Id;
begin
V := Tarjan_Stack.Last (Stack);
Tarjan_Stack.Delete_Last (Stack);
Set_On_Stack (V, False);
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return V;
end Pop;
----------
-- Push --
----------
procedure Push (V : Vertex_Id) is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
Tarjan_Stack.Append (Stack, V);
Set_On_Stack (V, True);
end Push;
------------------
-- Record_Visit --
------------------
procedure Record_Visit (V : Vertex_Id) is
Index : constant Visitation_Number := Sequence_Next_Index;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
Set_Index (V, Index);
Set_Low_Link (V, Index);
end Record_Visit;
-------------------------
-- Sequence_Next_Index --
-------------------------
Index_Sequencer : Visitation_Number := First_Visitation_Number;
-- The counter for visitation numbers. Do not directly manipulate its
-- value because this will destroy the Index and Low_Link invariants
-- of the algorithm.
function Sequence_Next_Index return Visitation_Number is
Index : constant Visitation_Number := Index_Sequencer;
begin
Index_Sequencer := Index_Sequencer + 1;
return Index;
end Sequence_Next_Index;
---------------
-- Set_Index --
---------------
procedure Set_Index
(V : Vertex_Id;
Val : Visitation_Number)
is
TA : Tarjan_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
TA := Get_Tarjan_Attributes (V);
TA.Index := Val;
Set_Tarjan_Attributes (V, TA);
end Set_Index;
------------------
-- Set_Low_Link --
------------------
procedure Set_Low_Link
(V : Vertex_Id;
Val : Visitation_Number)
is
TA : Tarjan_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
TA := Get_Tarjan_Attributes (V);
TA.Low_Link := Val;
Set_Tarjan_Attributes (V, TA);
end Set_Low_Link;
------------------
-- Set_On_Stack --
------------------
procedure Set_On_Stack
(V : Vertex_Id;
Val : Boolean)
is
TA : Tarjan_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
TA := Get_Tarjan_Attributes (V);
TA.On_Stack := Val;
Set_Tarjan_Attributes (V, TA);
end Set_On_Stack;
---------------------------
-- Set_Tarjan_Attributes --
---------------------------
procedure Set_Tarjan_Attributes
(V : Vertex_Id;
Val : Tarjan_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
Tarjan_Map.Put (Attrs, V, Val);
end Set_Tarjan_Attributes;
----------------------
-- Visit_Successors --
----------------------
procedure Visit_Successors (V : Vertex_Id) is
E : Edge_Id;
Iter : Outgoing_Edge_Iterator;
Succ : Vertex_Id;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
Iter := Iterate_Outgoing_Edges (G, V);
while Has_Next (Iter) loop
Next (Iter, E);
Succ := Destination_Vertex (G, E);
pragma Assert (Contains_Vertex (G, Succ));
-- The current successor has not been visited yet. Extend the
-- DFS traversal into it.
if not Is_Visited (Succ) then
Visit_Vertex (Succ);
Set_Low_Link (V,
Visitation_Number'Min (Low_Link (V), Low_Link (Succ)));
-- The current successor has been visited, and still remains on
-- the stack which indicates that it does not participate in a
-- component yet.
elsif On_Stack (Succ) then
Set_Low_Link (V,
Visitation_Number'Min (Low_Link (V), Index (Succ)));
end if;
end loop;
end Visit_Successors;
------------------
-- Visit_Vertex --
------------------
procedure Visit_Vertex (V : Vertex_Id) is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
if not Is_Visited (V) then
Record_Visit (V);
Push (V);
Visit_Successors (V);
-- The current vertex is the root of a component
if Low_Link (V) = Index (V) then
Create_Component (V);
end if;
end if;
end Visit_Vertex;
--------------------
-- Visit_Vertices --
--------------------
procedure Visit_Vertices is
Iter : All_Vertex_Iterator;
V : Vertex_Id;
begin
Iter := Iterate_All_Vertices (G);
while Has_Next (Iter) loop
Next (Iter, V);
Visit_Vertex (V);
end loop;
end Visit_Vertices;
-- Start of processing for Find_Components
begin
-- Initialize or reinitialize the components of the graph
Initialize_Components;
-- Prepare the extra attributes needed for each vertex, global
-- visitation number, and the stack where examined vertices are
-- placed.
Attrs := Tarjan_Map.Create (Number_Of_Vertices (G));
Stack := Tarjan_Stack.Create;
-- Start the DFS traversal of Tarjan's SCC algorithm
Visit_Vertices;
Tarjan_Map.Destroy (Attrs);
Tarjan_Stack.Destroy (Stack);
-- Associate each vertex with the component it belongs to
Associate_All_Vertices;
end Find_Components;
------------------------------
-- Get_Component_Attributes --
------------------------------
function Get_Component_Attributes
(G : Directed_Graph;
Comp : Component_Id) return Component_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Component (G, Comp));
return Component_Map.Get (G.Components, Comp);
end Get_Component_Attributes;
-------------------------
-- Get_Edge_Attributes --
-------------------------
function Get_Edge_Attributes
(G : Directed_Graph;
E : Edge_Id) return Edge_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Edge (G, E));
return Edge_Map.Get (G.All_Edges, E);
end Get_Edge_Attributes;
---------------------------
-- Get_Vertex_Attributes --
---------------------------
function Get_Vertex_Attributes
(G : Directed_Graph;
V : Vertex_Id) return Vertex_Attributes
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Vertex_Map.Get (G.All_Vertices, V);
end Get_Vertex_Attributes;
------------------------
-- Get_Outgoing_Edges --
------------------------
function Get_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Edge_Set.Membership_Set
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
return Get_Vertex_Attributes (G, V).Outgoing_Edges;
end Get_Outgoing_Edges;
------------------
-- Get_Vertices --
------------------
function Get_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Vertex_List.Doubly_Linked_List
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Component (G, Comp));
return Get_Component_Attributes (G, Comp).Vertices;
end Get_Vertices;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Edge_Iterator) return Boolean is
begin
return Edge_Map.Has_Next (Edge_Map.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : All_Vertex_Iterator) return Boolean is
begin
return Vertex_Map.Has_Next (Vertex_Map.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Component_Iterator) return Boolean is
begin
return Component_Map.Has_Next (Component_Map.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Component_Vertex_Iterator) return Boolean is
begin
return Vertex_List.Has_Next (Vertex_List.Iterator (Iter));
end Has_Next;
--------------
-- Has_Next --
--------------
function Has_Next (Iter : Outgoing_Edge_Iterator) return Boolean is
begin
return Edge_Set.Has_Next (Edge_Set.Iterator (Iter));
end Has_Next;
--------------
-- Is_Empty --
--------------
function Is_Empty (G : Directed_Graph) return Boolean is
begin
Ensure_Created (G);
return
Edge_Map.Is_Empty (G.All_Edges)
and then Vertex_Map.Is_Empty (G.All_Vertices);
end Is_Empty;
-----------------------
-- Iterate_All_Edges --
-----------------------
function Iterate_All_Edges
(G : Directed_Graph) return All_Edge_Iterator
is
begin
Ensure_Created (G);
return All_Edge_Iterator (Edge_Map.Iterate (G.All_Edges));
end Iterate_All_Edges;
--------------------------
-- Iterate_All_Vertices --
--------------------------
function Iterate_All_Vertices
(G : Directed_Graph) return All_Vertex_Iterator
is
begin
Ensure_Created (G);
return All_Vertex_Iterator (Vertex_Map.Iterate (G.All_Vertices));
end Iterate_All_Vertices;
------------------------
-- Iterate_Components --
------------------------
function Iterate_Components
(G : Directed_Graph) return Component_Iterator
is
begin
Ensure_Created (G);
return Component_Iterator (Component_Map.Iterate (G.Components));
end Iterate_Components;
--------------------------------
-- Iterate_Component_Vertices --
--------------------------------
function Iterate_Component_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Component_Vertex_Iterator
is
begin
Ensure_Created (G);
Ensure_Present (G, Comp);
return
Component_Vertex_Iterator
(Vertex_List.Iterate (Get_Vertices (G, Comp)));
end Iterate_Component_Vertices;
----------------------------
-- Iterate_Outgoing_Edges --
----------------------------
function Iterate_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Outgoing_Edge_Iterator
is
begin
Ensure_Created (G);
Ensure_Present (G, V);
return
Outgoing_Edge_Iterator
(Edge_Set.Iterate (Get_Outgoing_Edges (G, V)));
end Iterate_Outgoing_Edges;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Edge_Iterator;
E : out Edge_Id)
is
begin
Edge_Map.Next (Edge_Map.Iterator (Iter), E);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out All_Vertex_Iterator;
V : out Vertex_Id)
is
begin
Vertex_Map.Next (Vertex_Map.Iterator (Iter), V);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Component_Iterator;
Comp : out Component_Id)
is
begin
Component_Map.Next (Component_Map.Iterator (Iter), Comp);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Component_Vertex_Iterator;
V : out Vertex_Id)
is
begin
Vertex_List.Next (Vertex_List.Iterator (Iter), V);
end Next;
----------
-- Next --
----------
procedure Next
(Iter : in out Outgoing_Edge_Iterator;
E : out Edge_Id)
is
begin
Edge_Set.Next (Edge_Set.Iterator (Iter), E);
end Next;
----------------------------------
-- Number_Of_Component_Vertices --
----------------------------------
function Number_Of_Component_Vertices
(G : Directed_Graph;
Comp : Component_Id) return Natural
is
begin
Ensure_Created (G);
Ensure_Present (G, Comp);
return Vertex_List.Size (Get_Vertices (G, Comp));
end Number_Of_Component_Vertices;
--------------------------
-- Number_Of_Components --
--------------------------
function Number_Of_Components (G : Directed_Graph) return Natural is
begin
Ensure_Created (G);
return Component_Map.Size (G.Components);
end Number_Of_Components;
---------------------
-- Number_Of_Edges --
---------------------
function Number_Of_Edges (G : Directed_Graph) return Natural is
begin
Ensure_Created (G);
return Edge_Map.Size (G.All_Edges);
end Number_Of_Edges;
------------------------------
-- Number_Of_Outgoing_Edges --
------------------------------
function Number_Of_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id) return Natural
is
begin
Ensure_Created (G);
Ensure_Present (G, V);
return Edge_Set.Size (Get_Outgoing_Edges (G, V));
end Number_Of_Outgoing_Edges;
------------------------
-- Number_Of_Vertices --
------------------------
function Number_Of_Vertices (G : Directed_Graph) return Natural is
begin
Ensure_Created (G);
return Vertex_Map.Size (G.All_Vertices);
end Number_Of_Vertices;
-------------
-- Present --
-------------
function Present (G : Directed_Graph) return Boolean is
begin
return G /= Nil;
end Present;
-------------------
-- Set_Component --
-------------------
procedure Set_Component
(G : Directed_Graph;
V : Vertex_Id;
Val : Component_Id)
is
VA : Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
VA := Get_Vertex_Attributes (G, V);
VA.Component := Val;
Set_Vertex_Attributes (G, V, VA);
end Set_Component;
------------------------
-- Set_Outgoing_Edges --
------------------------
procedure Set_Outgoing_Edges
(G : Directed_Graph;
V : Vertex_Id;
Val : Edge_Set.Membership_Set)
is
VA : Vertex_Attributes;
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
VA := Get_Vertex_Attributes (G, V);
VA.Outgoing_Edges := Val;
Set_Vertex_Attributes (G, V, VA);
end Set_Outgoing_Edges;
---------------------------
-- Set_Vertex_Attributes --
---------------------------
procedure Set_Vertex_Attributes
(G : Directed_Graph;
V : Vertex_Id;
Val : Vertex_Attributes)
is
begin
pragma Assert (Present (G));
pragma Assert (Contains_Vertex (G, V));
Vertex_Map.Put (G.All_Vertices, V, Val);
end Set_Vertex_Attributes;
-------------------
-- Source_Vertex --
-------------------
function Source_Vertex
(G : Directed_Graph;
E : Edge_Id) return Vertex_Id
is
begin
Ensure_Created (G);
Ensure_Present (G, E);
return Get_Edge_Attributes (G, E).Source;
end Source_Vertex;
end Directed_Graphs;
--------------------
-- Hash_Component --
--------------------
function Hash_Component (Comp : Component_Id) return Bucket_Range_Type is
begin
return Bucket_Range_Type (Comp);
end Hash_Component;
-------------
-- Present --
-------------
function Present (Comp : Component_Id) return Boolean is
begin
return Comp /= No_Component;
end Present;
-----------------------------
-- Sequence_Next_Component --
-----------------------------
Component_Sequencer : Component_Id := First_Component;
-- The counter for component handles. Do not directly manipulate its value
-- because this will destroy the invariant of the handles.
function Sequence_Next_Component return Component_Id is
Component : constant Component_Id := Component_Sequencer;
begin
Component_Sequencer := Component_Sequencer + 1;
return Component;
end Sequence_Next_Component;
end GNAT.Graphs;
|
MinimSecure/unum-sdk | Ada | 831 | adb | -- Copyright 2005-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 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/>.
procedure Second is
procedure Break_Me is
begin
null;
end Break_Me;
begin
Break_Me;
end Second;
|
KipodAfterFree/KAF-2019-FireHog | Ada | 6,355 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Curses_Demo --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.7 $
-- Binding Version 00.93
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
with Terminal_Interface.Curses.Panels.User_Data;
with Sample.Manifest; use Sample.Manifest;
with Sample.Helpers; use Sample.Helpers;
with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Header_Handler; use Sample.Header_Handler;
with Sample.Explanation; use Sample.Explanation;
with Sample.Menu_Demo.Handler;
with Sample.Curses_Demo.Mouse;
with Sample.Curses_Demo.Attributes;
package body Sample.Curses_Demo is
type User_Data is new Integer;
type User_Data_Access is access all User_Data;
package PUD is new Panels.User_Data (User_Data, User_Data_Access);
-- We use above instantiation of the generic User_Data package to
-- demonstrate and test the use of the user data maechanism.
procedure Demo
is
function My_Driver (M : Menu;
K : Key_Code;
Pan : Panel) return Boolean;
package Mh is new Sample.Menu_Demo.Handler (My_Driver);
Itm : Item_Array_Access := new Item_Array'
(New_Item ("Attributes Demo"),
New_Item ("Mouse Demo"),
Null_Item);
M : Menu := New_Menu (Itm);
U1 : User_Data_Access := new User_Data'(4711);
U2 : User_Data_Access;
function My_Driver (M : Menu;
K : Key_Code;
Pan : Panel) return Boolean
is
Idx : constant Positive := Get_Index (Current (M));
Result : Boolean := False;
begin
PUD.Set_User_Data (Pan, U1); -- set some user data, just for fun
if K in User_Key_Code'Range then
if K = QUIT then
Result := True;
elsif K = SELECT_ITEM then
if Idx in Itm'Range then
Hide (Pan);
Update_Panels;
end if;
case Idx is
when 1 => Sample.Curses_Demo.Attributes.Demo;
when 2 => Sample.Curses_Demo.Mouse.Demo;
when others => Not_Implemented;
end case;
if Idx in Itm'Range then
Top (Pan);
Show (Pan);
Update_Panels;
Update_Screen;
end if;
end if;
end if;
PUD.Get_User_Data (Pan, U2); -- get the user data
pragma Assert (U1.all = U2.all and then U1 = U2);
return Result;
end My_Driver;
begin
if (1 + Item_Count (M)) /= Itm'Length then
raise Constraint_Error;
end if;
if not Has_Mouse then
declare
O : Item_Option_Set;
begin
Get_Options (Itm (2), O);
O.Selectable := False;
Set_Options (Itm (2), O);
end;
end if;
Push_Environment ("CURSES00");
Notepad ("CURSES-PAD00");
Default_Labels;
Refresh_Soft_Label_Keys_Without_Update;
Mh.Drive_Me (M, " Demo ");
Pop_Environment;
Delete (M);
Free (Itm, True);
end Demo;
end Sample.Curses_Demo;
|
AdaDoom3/wayland_ada_binding | Ada | 1,977 | adb | with Ada.Text_IO;
package body Aida.Text_IO with SPARK_Mode => Off is
procedure Put_Line (Item : Standard.String) is
begin
Ada.Text_IO.Put_Line(Item);
end Put_Line;
procedure Put_Line (S1 : Standard.String;
S2 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put_Line (S2);
end Put_Line;
procedure Put_Line (S1 : Standard.String;
S2 : Standard.String;
S3 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put (S2);
Ada.Text_IO.Put_Line (S3);
end Put_Line;
procedure Put_Line (S1 : Standard.String;
S2 : Standard.String;
S3 : Standard.String;
S4 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put (S2);
Ada.Text_IO.Put (S3);
Ada.Text_IO.Put_Line (S4);
end Put_Line;
procedure Put_Line (S1 : Standard.String;
S2 : Standard.String;
S3 : Standard.String;
S4 : Standard.String;
S5 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put (S2);
Ada.Text_IO.Put (S3);
Ada.Text_IO.Put (S4);
Ada.Text_IO.Put_Line (S5);
end Put_Line;
procedure Put (Item : Standard.String) is
begin
Ada.Text_IO.Put (Item);
end Put;
procedure Put (S1 : Standard.String;
S2 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put (S2);
end Put;
procedure Put (S1 : Standard.String;
S2 : Standard.String;
S3 : Standard.String) is
begin
Ada.Text_IO.Put (S1);
Ada.Text_IO.Put (S2);
Ada.Text_IO.Put (S3);
end Put;
function Get_Line return Standard.String is
begin
return Standard.String (Ada.Text_IO.Get_Line);
end Get_Line;
end Aida.Text_IO;
|
sungyeon/drake | Ada | 312 | adb | package body Ada.Strings.Maps.Naked is
function To_Set return Character_Set is
begin
return Create (Set_Data_Access (Source));
end To_Set;
function To_Mapping return Character_Mapping is
begin
return Create (Map_Data_Access (Source));
end To_Mapping;
end Ada.Strings.Maps.Naked;
|
reznikmm/matreshka | Ada | 25,084 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- 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: 1793 $ $Date: 2011-06-11 10:40:44 +0300 (Сб, 11 июн 2011) $
------------------------------------------------------------------------------
with Ada.Streams;
with Ada.Unchecked_Deallocation;
with System.Address_To_Access_Conversions;
with League.Calendars.ISO_8601;
package body Matreshka.Internals.SQL_Drivers.Firebird.Fields is
procedure Free is
new Ada.Unchecked_Deallocation (Isc_Short, Isc_Short_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Sql_Data_Array, Sql_Data_Array_Access);
package To_Isc_Date is
new System.Address_To_Access_Conversions (Isc_Date);
package To_Isc_Timestamp is
new System.Address_To_Access_Conversions (Isc_Timestamp);
package To_Isc_Time is
new System.Address_To_Access_Conversions (Isc_Time);
package To_Long_Long_Integer is
new System.Address_To_Access_Conversions (Long_Long_Integer);
package To_Short_Float is
new System.Address_To_Access_Conversions (Short_Float);
package To_Short_Integer is
new System.Address_To_Access_Conversions (Short_Integer);
package To_Long_Integer is
new System.Address_To_Access_Conversions (Long_Integer);
package To_Long_Float is
new System.Address_To_Access_Conversions (Long_Float);
Calendar : League.Calendars.ISO_8601.ISO_8601_Calendar;
--------------------
-- Adjust_Sqldata --
--------------------
procedure Adjust_Sqldata (Self : not null access Field) is
use type Isc_Short;
begin
if Self.Sql_Dada_Space /= null
and then Self.Sql_Dada_Space'Length = Self.Sqlvar.Sqllen
then
return;
end if;
Self.Free_Sqldata;
Self.Alloc_Sqldata (Self.Sqlvar.Sqllen);
end Adjust_Sqldata;
-------------------
-- Alloc_Sqldata --
-------------------
procedure Alloc_Sqldata (Self : not null access Field; Size : Isc_Short) is
use type Isc_Short;
begin
if Size > 0 then
Self.Sql_Dada_Space := new Sql_Data_Array (1 .. Size);
Self.Sql_Dada_Space.all := (others => 0);
Self.Sqlvar.Sqldata := Self.Sql_Dada_Space (1)'Address;
end if;
end Alloc_Sqldata;
------------------
-- Alloc_Sqlind --
------------------
procedure Alloc_Sqlind (Self : not null access Field) is
begin
if Self.Sqlvar.Sqlind = null then
Self.Sqlvar.Sqlind := new Isc_Short'(0);
end if;
end Alloc_Sqlind;
-------------------
-- Adjust_Sqlind --
-------------------
procedure Adjust_Sqlind (Self : not null access Field) is
begin
if Self.Sqlvar.Sqltype (Isc_Sqlind_Flag) then
Self.Alloc_Sqlind;
else
Free (Self.Sqlvar.Sqlind);
end if;
end Adjust_Sqlind;
----------------
-- As_Boolean --
----------------
function As_Boolean (Self : not null access Field) return Boolean is
begin
return To_Short_Integer.To_Pointer (Self.Sqlvar.Sqldata).all = Isc_True;
end As_Boolean;
-------------
-- As_Date --
-------------
function As_Date
(Self : not null access Field) return League.Calendars.Date
is
use League.Calendars.ISO_8601;
use type Interfaces.C.int;
C_Date : aliased C_Time;
begin
Isc_Decode_Sql_Date
(To_Isc_Date.To_Pointer (Self.Sqlvar.Sqldata), C_Date'Access);
return
Create
(Year_Number (C_Date.Tm_Year + 1900),
Month_Number (C_Date.Tm_Mon + 1),
Day_Number (C_Date.Tm_Mday));
end As_Date;
-------------
-- As_Date --
-------------
procedure As_Date
(Self : not null access Field;
Value : League.Calendars.Date)
is
use Interfaces.C;
C_Date : aliased C_Time;
Date : aliased Isc_Date;
begin
C_Date.Tm_Year := int (Calendar.Year (Value)) - 1900;
C_Date.Tm_Mon := int (Calendar.Month (Value)) - 1;
C_Date.Tm_Mday := int (Calendar.Day (Value));
Isc_Encode_Sql_Date (C_Date'Access, Date'Access);
Self.Set_Value (Isc_Type_Date, Isc_Date'Size / 8, Date'Address);
end As_Date;
------------------
-- As_Date_Time --
------------------
function As_Date_Time
(Self : not null access Field)
return League.Calendars.Date_Time
is
use League.Calendars.ISO_8601;
use type Interfaces.C.int;
C_Date : aliased C_Time;
begin
Isc_Decode_Timestamp
(To_Isc_Timestamp.To_Pointer (Self.Sqlvar.Sqldata), C_Date'Access);
raise Program_Error with "Not Implemented";
-- return Create
-- (Year_Number (C_Date.Tm_Year + 1900),
-- Month_Number (C_Date.Tm_Mon + 1),
-- Day_Number (C_Date.Tm_Mday),
-- Create (Hour_Number (C_Date.Tm_Hour),
-- Minute_Number (C_Date.Tm_Min),
-- Second_Number (C_Date.Tm_Sec)));
return League.Calendars.Clock;
end As_Date_Time;
------------------
-- As_Date_Time --
------------------
procedure As_Date_Time
(Self : not null access Field; Value : League.Calendars.Date_Time)
is
use Interfaces.C;
C_Date : aliased C_Time;
Timestamp : aliased Isc_Timestamp;
begin
C_Date.Tm_Year := int (Calendar.Year (Value)) - 1900;
C_Date.Tm_Mon := int (Calendar.Month (Value)) - 1;
C_Date.Tm_Mday := int (Calendar.Day (Value));
C_Date.Tm_Hour := int (Calendar.Hour (Value));
C_Date.Tm_Min := int (Calendar.Minute (Value));
C_Date.Tm_Sec := int (Calendar.Second (Value));
Isc_Encode_Timestamp (C_Date'Access, Timestamp'Access);
Self.Set_Value
(Isc_Type_Timestamp, Isc_Timestamp'Size / 8, Timestamp'Address);
end As_Date_Time;
-------------------
-- As_Long_Float --
-------------------
function As_Long_Float (Self : not null access Field) return Long_Float is
use type Isc_Short;
begin
if Self.Sql_Type = Isc_Type_Double
or else Self.Sql_Type = Isc_Type_D_Float
then
return To_Long_Float.To_Pointer (Self.Sqlvar.Sqldata).all;
elsif Self.Sql_Type = Isc_Type_Long then
return
Long_Float
(To_Long_Integer.To_Pointer (Self.Sqlvar.Sqldata).all)
/ Long_Float (10 ** Integer (-Self.Sqlvar.Sqlscale));
else
raise Constraint_Error;
end if;
end As_Long_Float;
---------------------
-- As_Long_Integer --
---------------------
function As_Long_Integer
(Self : not null access Field) return Long_Integer is
begin
return To_Long_Integer.To_Pointer (Self.Sqlvar.Sqldata).all;
end As_Long_Integer;
--------------------
-- As_Short_Float --
--------------------
function As_Short_Float (Self : not null access Field) return Short_Float is
use type Isc_Short;
begin
if Self.Sql_Type = Isc_Type_Float then
return To_Short_Float.To_Pointer (Self.Sqlvar.Sqldata).all;
elsif Self.Sql_Type = Isc_Type_Short then
return
Short_Float
(To_Short_Integer.To_Pointer (Self.Sqlvar.Sqldata).all)
/ Short_Float (10 ** Integer (-Self.Sqlvar.Sqlscale));
else
raise Constraint_Error;
end if;
end As_Short_Float;
----------------------
-- As_Short_Integer --
----------------------
function As_Short_Integer
(Self : not null access Field) return Short_Integer is
begin
return To_Short_Integer.To_Pointer (Self.Sqlvar.Sqldata).all;
end As_Short_Integer;
-------------
-- As_Time --
-------------
function As_Time
(Self : not null access Field) return League.Calendars.Time
is
use League.Calendars.ISO_8601;
C_Date : aliased C_Time;
Dummy : League.Calendars.Time;
begin
Isc_Decode_Sql_Time
(To_Isc_Time.To_Pointer (Self.Sqlvar.Sqldata), C_Date'Access);
raise Program_Error with "Not Implemented";
-- return Create
-- (Hour_Number (C_Date.Tm_Hour),
-- Minute_Number (C_Date.Tm_Min),
-- Second_Number (C_Date.Tm_Sec));
return Dummy;
end As_Time;
-------------
-- As_Time --
-------------
procedure As_Time
(Self : not null access Field;
Value : League.Calendars.Time)
is
use Interfaces.C;
C_Date : aliased C_Time;
Time : aliased Isc_Time;
begin
C_Date.Tm_Hour := int (Calendar.Hour (Value));
C_Date.Tm_Min := int (Calendar.Minute (Value));
C_Date.Tm_Sec := int (Calendar.Second (Value));
Isc_Encode_Sql_Time (C_Date'Access, Time'Access);
Self.Set_Value (Isc_Type_Time, Isc_Time'Size / 8, Time'Address);
end As_Time;
------------------------
-- As_Universal_Float --
------------------------
function As_Universal_Float
(Self : not null access Field) return League.Holders.Universal_Float
is
use type Isc_Short;
v : constant Long_Long_Integer
:= To_Long_Long_Integer.To_Pointer (Self.Sqlvar.Sqldata).all;
begin
return
League.Holders.Universal_Float
(Long_Long_Float (v)
/ Long_Long_Float (10 ** Integer (-Self.Sqlvar.Sqlscale)));
end As_Universal_Float;
------------------------
-- As_Universal_Float --
------------------------
procedure As_Universal_Float
(Self : not null access Field;
Value : League.Holders.Universal_Float)
is
use League.Holders;
use type Universal_Float;
use type Isc_Short;
v : constant Universal_Integer
:= Universal_Integer
(Universal_Float'Truncation
(Value * Universal_Float (10 ** Integer (-Self.Srv_Sql_Scale))));
begin
Self.As_Universal_Integer (v);
Self.Sqlvar.Sqlscale := Self.Srv_Sql_Scale;
end As_Universal_Float;
--------------------------
-- As_Universal_Integer --
--------------------------
function As_Universal_Integer
(Self : not null access Field) return League.Holders.Universal_Integer is
begin
return League.Holders.Universal_Integer
(To_Long_Long_Integer.To_Pointer (Self.Sqlvar.Sqldata).all);
end As_Universal_Integer;
--------------------------
-- As_Universal_Integer --
--------------------------
procedure As_Universal_Integer
(Self : not null access Field;
Value : League.Holders.Universal_Integer)
is
use type Isc_Short;
V : Long_Long_Integer := Long_Long_Integer (Value);
begin
Self.Set_Value
(Isc_Type_Int64,
Long_Long_Integer'Size / 8,
V'Address);
end As_Universal_Integer;
---------------
-- As_String --
---------------
function As_String
(Self : not null access Field) return League.Strings.Universal_String
is
use Ada.Streams;
Len : Integer;
function Get_Length (Addr : Isc_Address) return Integer;
function Extract
(Addr : Isc_Address;
From : Stream_Element_Offset;
To : Stream_Element_Offset) return Stream_Element_Array;
----------------
-- Get_Length --
----------------
function Get_Length (Addr : Isc_Address) return Integer is
subtype Header is Isc_String (1 .. 2);
package To_Header is
new System.Address_To_Access_Conversions (Header);
begin
return
Integer
(Isc_Vax_Integer (To_Header.To_Pointer (Addr) (1 .. 2), 2));
end Get_Length;
-------------
-- Extract --
-------------
function Extract
(Addr : Isc_Address;
From : Stream_Element_Offset;
To : Stream_Element_Offset) return Stream_Element_Array
is
subtype Constrained is Stream_Element_Array (1 .. To);
package To_Array is
new System.Address_To_Access_Conversions (Constrained);
begin
return To_Array.To_Pointer (Addr) (From .. To);
end Extract;
begin
if Self.Sql_Type = Isc_Type_Text then
Len := Integer (Self.Sqlvar.Sqllen);
else
Len := Get_Length (Self.Sqlvar.Sqldata);
end if;
declare
Result : Ada.Streams.Stream_Element_Array
(1 .. Ada.Streams.Stream_Element_Offset (Len));
begin
if Self.Sql_Type = Isc_Type_Text then
Result :=
Extract (Self.Sqlvar.Sqldata, 1, Stream_Element_Offset (Len));
else
Result :=
Extract
(Self.Sqlvar.Sqldata, 3, Stream_Element_Offset (Len + 2));
end if;
return League.Text_Codecs.Decode (Self.Codec.all, Result);
end;
end As_String;
---------------
-- As_String --
---------------
procedure As_String
(Self : not null access Field;
Value : League.Strings.Universal_String)
is
use type Interfaces.C.char;
Sql_Type : Isc_Sqltype;
begin
Sql_Type := Self.Server_Sql_Type;
declare
Item : constant Ada.Streams.Stream_Element_Array
:= Self.Codec.Encode (Value).To_Stream_Element_Array;
begin
if Item'Length > 32767 then
raise Constraint_Error;
end if;
if Self.Utf then
Self.Sqlvar.Sqlsubtype := 3; -- UNICODE_FSS
end if;
if Item'Length > 0 then
Self.Set_Value
(Isc_Type_Text, Item'Length, Item (Item'First)'Address);
else
if Is_Numeric_Type (Sql_Type)
or else Is_Datetime_Type (Sql_Type)
then
Self.Set_Null (True);
else
Self.Set_Value (Isc_Type_Text, 0, Zero);
end if;
end if;
end;
end As_String;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Field) is
begin
if Self.Sqlvar /= null then
Free (Self.Sqlvar.Sqlind);
end if;
Self.Free_Sqldata;
end Finalize;
------------------
-- Free_Sqldata --
------------------
procedure Free_Sqldata (Self : in out Field) is
begin
Free (Self.Sql_Dada_Space);
Self.Sqlvar.Sqldata := System.Null_Address;
end Free_Sqldata;
-------------
-- Is_Null --
-------------
function Is_Null (Self : not null access Field) return Boolean is
use type Isc_Short;
begin
return
(Self.Is_Nullable and then Self.Sqlvar.Sqlind.all = -1)
or else Self.Sqlvar.Sqltype = Isc_Type_Empty
or else Self.Sqlvar.Sqltype = Isc_Type_Empty1;
end Is_Null;
-----------------
-- Is_Nullable --
-----------------
function Is_Nullable (Self : not null access Field) return Boolean is
begin
if Self.Sqlvar.Sqltype (Isc_Sqlind_Flag) then
Self.Alloc_Sqlind;
return True;
else
return False;
end if;
end Is_Nullable;
-----------------
-- Is_Nullable --
-----------------
procedure Is_Nullable (Self : not null access Field; Value : Boolean) is
begin
if Value /= Self.Is_Nullable then
if Value then
Self.Sqlvar.Sqltype (Isc_Sqlind_Flag) := True;
Self.Alloc_Sqlind;
else
Self.Sqlvar.Sqltype (Isc_Sqlind_Flag) := False;
Free (Self.Sqlvar.Sqlind);
end if;
end if;
end Is_Nullable;
--------------------
-- Reserv_Sqldata --
--------------------
procedure Reserv_Sqldata (Self : not null access Field; Size : Isc_Short) is
use type Isc_Short;
begin
if Self.Sql_Dada_Space /= null
and then Self.Sql_Dada_Space'Length = Size
then
return;
end if;
Self.Free_Sqldata;
Self.Alloc_Sqldata (Size);
end Reserv_Sqldata;
---------------------
-- Server_Sql_Type --
---------------------
function Server_Sql_Type
(Self : not null access Field) return Isc_Sqltype
is
Result : Isc_Sqltype := Self.Srv_Sql_Type;
begin
Result (Isc_Sqlind_Flag) := False;
return Result;
end Server_Sql_Type;
--------------
-- Set_Null --
--------------
procedure Set_Null (Self : not null access Field; Value : Boolean) is
use type Isc_Short;
begin
if Value then
if Self.Sqlvar.Sqltype = Isc_Type_Empty
or else Self.Sqlvar.Sqltype = Isc_Type_Empty1
then
Self.Sqlvar.Sqltype := Isc_Type_Text;
Self.Sqlvar.Sqllen := 0;
Self.Free_Sqldata;
end if;
if not Self.Is_Nullable then
Self.Is_Nullable (True);
end if;
Self.Sqlvar.Sqlind.all := -1;
else
if Self.Is_Nullable then
Self.Sqlvar.Sqlind.all := 0;
end if;
end if;
end Set_Null;
---------------
-- Set_Value --
---------------
procedure Set_Value
(Self : not null access Field;
Sql_Type : Isc_Sqltype;
Size : Isc_Short;
Value : Isc_Address)
is
use type Isc_Address;
use type Isc_Short;
subtype C_Array is Sql_Data_Array (1 .. Size);
package To_Array_Conv is
new System.Address_To_Access_Conversions (C_Array);
Set_Sql_Type : Isc_Sqltype := Sql_Type;
begin
if Self.Is_Null then
Self.Set_Null (False);
end if;
Self.Sqlvar.Sqlscale := 0;
if Value = Zero
or else Size = 0
then
Self.Sqlvar.Sqllen := 0;
Self.Reserv_Sqldata (1);
else
Self.Sqlvar.Sqllen := Size;
if Self.Sql_Dada_Space /= null
and then Self.Sql_Dada_Space'Length /= Self.Sqlvar.Sqllen
then
Self.Free_Sqldata;
end if;
if Self.Sql_Dada_Space = null then
Self.Alloc_Sqldata (Self.Sqlvar.Sqllen);
end if;
Self.Sql_Dada_Space (1 .. Size) :=
To_Array_Conv.To_Pointer (Value) (1 .. Size);
end if;
Set_Sql_Type (Isc_Sqlind_Flag) := Self.Sqlvar.Sqltype (Isc_Sqlind_Flag);
Self.Sqlvar.Sqltype := Set_Sql_Type;
end Set_Value;
--------------
-- Sql_Type --
--------------
function Sql_Type (Self : not null access Field) return Isc_Sqltype is
Result : Isc_Sqltype := Self.Sqlvar.Sqltype;
begin
Result (Isc_Sqlind_Flag) := False;
return Result;
end Sql_Type;
-----------
-- Value --
-----------
function Value
(Self : not null access Field) return League.Holders.Holder
is
use League.Holders;
use type Isc_Short;
Sql_Type : Isc_Sqltype;
Result : Holder;
begin
if Self.Is_Null then
return Result;
end if;
Sql_Type := Self.Sql_Type;
if Sql_Type = Isc_Type_Text
or else Sql_Type = Isc_Type_Varying
then
Replace_Element (Result, Self.As_String);
elsif Sql_Type = Isc_Type_Short then
if Self.Sqlvar.Sqlscale /= 0 then
Replace_Element (Result, Universal_Float (Self.As_Short_Float));
else
Replace_Element
(Result, Universal_Integer (Self.As_Short_Integer));
end if;
elsif Sql_Type = Isc_Type_Long then
if Self.Sqlvar.Sqlscale /= 0 then
Replace_Element (Result, Universal_Float (Self.As_Long_Float));
else
Replace_Element (Result, Universal_Integer (Self.As_Long_Integer));
end if;
elsif Sql_Type = Isc_Type_Float then
Replace_Element (Result, Universal_Float (Self.As_Short_Float));
elsif Sql_Type = Isc_Type_Double
or else Sql_Type = Isc_Type_D_Float
then
Replace_Element (Result, Universal_Float (Self.As_Long_Float));
elsif Sql_Type = Isc_Type_Blob then
Replace_Element
(Result, League.Strings.To_Universal_String ("(BLOB)"));
elsif Sql_Type = Isc_Type_Array then
Replace_Element
(Result, League.Strings.To_Universal_String ("(ARRAY)"));
elsif Sql_Type = Isc_Type_Quad then
raise Constraint_Error;
elsif Sql_Type = Isc_Type_Time then
Replace_Element (Result, Self.As_Time);
elsif Sql_Type = Isc_Type_Timestamp then
Replace_Element (Result, Self.As_Date_Time);
elsif Sql_Type = Isc_Type_Date then
Replace_Element (Result, Self.As_Date);
elsif Sql_Type = Isc_Type_Int64 then
if Self.Sqlvar.Sqlscale /= 0 then
Replace_Element (Result, Self.As_Universal_Float);
else
Replace_Element (Result, Self.As_Universal_Integer);
end if;
elsif Sql_Type = Isc_Type_Boolean then
Replace_Element
(Result, League.Strings.To_Universal_String
(Boolean'Wide_Wide_Image (Self.As_Boolean)));
else
raise Constraint_Error;
end if;
return Result;
end Value;
-----------
-- Value --
-----------
procedure Value
(Self : not null access Field; Holder : League.Holders.Holder) is
begin
if League.Holders.Is_Empty (Holder) then
Self.Set_Null (True);
elsif League.Holders.Is_Universal_String (Holder) then
Self.As_String (League.Holders.Element (Holder));
elsif League.Holders.Is_Abstract_Integer (Holder) then
Self.As_Universal_Integer (League.Holders.Element (Holder));
elsif League.Holders.Is_Abstract_Float (Holder) then
Self.As_Universal_Float (League.Holders.Element (Holder));
elsif League.Holders.Is_Time (Holder) then
Self.As_Time (League.Holders.Element (Holder));
elsif League.Holders.Is_Date (Holder) then
Self.As_Date (League.Holders.Element (Holder));
elsif League.Holders.Is_Date_Time (Holder) then
Self.As_Date_Time (League.Holders.Element (Holder));
else
raise Constraint_Error;
end if;
end Value;
end Matreshka.Internals.SQL_Drivers.Firebird.Fields;
|
ikasarov/multiapps-cli-plugin | Ada | 484 | ads | artifacts builderVersion:"1.1", {
version "${buildBaseVersion}", {
group "${groupId}", {
artifact "${artifactId}", {
file "${genroot}/out/mta_plugin_linux_amd64", classifier: "linux", extension: "bin"
file "${genroot}/out/mta_plugin_darwin_amd64", classifier: "darwin", extension: "bin"
file "${genroot}/out/mta_plugin_windows_amd64.exe", classifier: "windows", extension: "exe"
}
}
}
}
|
optikos/oasis | Ada | 1,139 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
package Program.Elements.String_Literals is
pragma Pure (Program.Elements.String_Literals);
type String_Literal is
limited interface and Program.Elements.Expressions.Expression;
type String_Literal_Access is access all String_Literal'Class
with Storage_Size => 0;
not overriding function Image (Self : String_Literal) return Text
is abstract;
type String_Literal_Text is limited interface;
type String_Literal_Text_Access is access all String_Literal_Text'Class
with Storage_Size => 0;
not overriding function To_String_Literal_Text
(Self : aliased in out String_Literal)
return String_Literal_Text_Access is abstract;
not overriding function String_Literal_Token
(Self : String_Literal_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.String_Literals;
|
clairvoyant/anagram | Ada | 6,369 | adb | -- Copyright (c) 2010-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Anagram.Grammars.LR_Tables is
----------
-- Free --
----------
procedure Free (Self : in out Table_Access) is
procedure Drop is new Ada.Unchecked_Deallocation (Table, Table_Access);
begin
Drop (Self);
end Free;
--------------
-- Is_Empty --
--------------
function Is_Empty (Self : Reduce_Iterator) return Boolean is
begin
return Self.Production = 0;
end Is_Empty;
----------------
-- Last_State --
----------------
function Last_State (Self : Table) return LR.State_Index is
begin
return Self.Last_State;
end Last_State;
----------
-- Part --
----------
function Part (Self : Reduce_Iterator) return Part_Count is
begin
return Self.Part;
end Part;
----------------
-- Production --
----------------
function Production (Self : Reduce_Iterator) return Production_Index is
begin
return Self.Production;
end Production;
----------
-- Next --
----------
procedure Next
(Self : Table;
Item : in out Reduce_Iterator)
is
begin
if Item.Next = 0 then
Item.Production := 0;
else
Item := Self.Reduce_Vector (Item.Next);
end if;
end Next;
------------
-- Create --
------------
function Create
(Last_State : LR.State_Index;
Last_Terminal : Terminal_Index;
Last_Non_Terminal : Non_Terminal_Index) return Table_Access is
begin
return new Table'(Last_State,
Last_Terminal,
Last_Non_Terminal,
Reduce_Vector => <>,
T_Shift => (others => (others => 0)),
T_Finish => (others => False),
T_Reduce => (others => (others => 0)),
NT_Shift => (others => (others => 0)),
NT_Reduce => (others => (others => 0)));
end Create;
-----------
-- Shift --
-----------
function Shift
(Self : Table;
State : LR.State_Index;
NT : Non_Terminal_Index)
return LR.State_Count is
begin
return Self.NT_Shift (State, NT);
end Shift;
-----------
-- Shift --
-----------
function Shift
(Self : Table;
State : LR.State_Index;
T : Terminal_Count)
return LR.State_Count is
begin
return Self.T_Shift (State, T);
end Shift;
------------
-- Reduce --
------------
function Reduce
(Self : Table;
State : LR.State_Index;
T : Terminal_Count)
return Reduce_Iterator
is
Index : constant Natural := Self.T_Reduce (State, T);
begin
if Index = 0 then
return (0, 0, 0);
else
return Self.Reduce_Vector (Index);
end if;
end Reduce;
------------
-- Reduce --
------------
function Reduce
(Self : Table;
State : LR.State_Index;
NT : Non_Terminal_Index) return Reduce_Iterator
is
Index : constant Natural := Self.NT_Reduce (State, NT);
begin
if Index = 0 then
return (0, 0, 0);
else
return Self.Reduce_Vector (Index);
end if;
end Reduce;
-------------------
-- Remove_Reduce --
-------------------
procedure Remove_Reduce
(Self : in out Table;
State : LR.State_Index;
T : Terminal_Count;
Value : Production_Index)
is
Index : Natural := Self.T_Reduce (State, T);
Next : Natural := Self.Reduce_Vector (Index).Next;
begin
if Self.Reduce_Vector (Index).Production = Value then
Self.T_Reduce (State, T) := Next;
return;
end if;
while Self.Reduce_Vector (Next).Production /= Value loop
Index := Next;
Next := Self.Reduce_Vector (Index).Next;
end loop;
Self.Reduce_Vector (Index).Next := Self.Reduce_Vector (Next).Next;
end Remove_Reduce;
------------------
-- Remove_Shift --
------------------
procedure Remove_Shift
(Self : in out Table;
State : LR.State_Index;
T : Terminal_Count) is
begin
Self.T_Shift (State, T) := 0;
end Remove_Shift;
------------
-- Finish --
------------
function Finish
(Self : Table;
State : LR.State_Index)
return Boolean is
begin
return Self.T_Finish (State);
end Finish;
---------------
-- Set_Shift --
---------------
procedure Set_Shift
(Self : in out Table;
State : LR.State_Index;
NT : Non_Terminal_Index;
Value : LR.State_Index) is
begin
Self.NT_Shift (State, NT) := Value;
end Set_Shift;
---------------
-- Set_Shift --
---------------
procedure Set_Shift
(Self : in out Table;
State : LR.State_Index;
T : Terminal_Count;
Value : LR.State_Index)
is
begin
Self.T_Shift (State, T) := Value;
end Set_Shift;
----------------
-- Set_Reduce --
----------------
procedure Set_Reduce
(Self : in out Table;
State : LR.State_Index;
T : Terminal_Count;
Value : Production_Index;
Part : Part_Count := 0)
is
Item : constant Reduce_Iterator :=
(Value, Part, Self.T_Reduce (State, T));
begin
Self.Reduce_Vector.Append (Item);
Self.T_Reduce (State, T) := Self.Reduce_Vector.Last_Index;
end Set_Reduce;
----------------
-- Set_Reduce --
----------------
procedure Set_Reduce
(Self : in out Table;
State : LR.State_Index;
NT : Non_Terminal_Index;
Value : Production_Index;
Part : Part_Count := 0)
is
Item : constant Reduce_Iterator :=
(Value, Part, Self.NT_Reduce (State, NT));
begin
Self.Reduce_Vector.Append (Item);
Self.NT_Reduce (State, NT) := Self.Reduce_Vector.Last_Index;
end Set_Reduce;
----------------
-- Set_Finish --
----------------
procedure Set_Finish
(Self : in out Table;
State : LR.State_Index) is
begin
Self.T_Finish (State) := True;
end Set_Finish;
end Anagram.Grammars.LR_Tables;
|
reznikmm/matreshka | Ada | 5,110 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A literal unlimited natural is a specification of an unlimited natural
-- number.
------------------------------------------------------------------------------
with AMF.UML.Literal_Specifications;
package AMF.UML.Literal_Unlimited_Naturals is
pragma Preelaborate;
type UML_Literal_Unlimited_Natural is limited interface
and AMF.UML.Literal_Specifications.UML_Literal_Specification;
type UML_Literal_Unlimited_Natural_Access is
access all UML_Literal_Unlimited_Natural'Class;
for UML_Literal_Unlimited_Natural_Access'Storage_Size use 0;
not overriding function Get_Value
(Self : not null access constant UML_Literal_Unlimited_Natural)
return AMF.Unlimited_Natural is abstract;
-- Getter of LiteralUnlimitedNatural::value.
--
-- The specified UnlimitedNatural value.
not overriding procedure Set_Value
(Self : not null access UML_Literal_Unlimited_Natural;
To : AMF.Unlimited_Natural) is abstract;
-- Setter of LiteralUnlimitedNatural::value.
--
-- The specified UnlimitedNatural value.
overriding function Is_Computable
(Self : not null access constant UML_Literal_Unlimited_Natural)
return Boolean is abstract;
-- Operation LiteralUnlimitedNatural::isComputable.
--
-- The query isComputable() is redefined to be true.
not overriding function Unlimited_Value
(Self : not null access constant UML_Literal_Unlimited_Natural)
return AMF.Unlimited_Natural is abstract;
-- Operation LiteralUnlimitedNatural::unlimitedValue.
--
-- The query unlimitedValue() gives the value.
end AMF.UML.Literal_Unlimited_Naturals;
|
reznikmm/matreshka | Ada | 4,728 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Visitors;
with ODF.DOM.Text_Author_Name_Elements;
package Matreshka.ODF_Text.Author_Name_Elements is
type Text_Author_Name_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Author_Name_Elements.ODF_Text_Author_Name
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Author_Name_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Author_Name_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Author_Name_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Author_Name_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Author_Name_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Author_Name_Elements;
|
tum-ei-rcs/StratoX | Ada | 9,407 | adb | with Interfaces; use Interfaces;
with Bounded_Image; use Bounded_Image;
package body Units with SPARK_Mode is
function average( signal : Unit_Array ) return Unit_Type is
function Sat_Add_Unit is new Saturated_Addition (Unit_Type);
avg : Unit_Type := 0.0;
begin
if signal'Length > 0 then
for index in Integer range signal'First .. signal'Last loop
avg := Sat_Add_Unit (avg, signal (index));
end loop;
avg := avg / Unit_Type (signal'Length);
end if;
return avg;
end average;
function Clip_Unitcircle (X : Unit_Type) return Unit_Type is
begin
if X < Unit_Type (-1.0) then
return Unit_Type (-1.0);
elsif X > Unit_Type (1.0) then
return Unit_Type (1.0);
end if;
return X;
end Clip_Unitcircle;
--function wrap_Angle( angle : Angle_Type; min : Angle_Type; max : Angle_Type) return Angle_Type is
-- ( Angle_Type'Remainder( (angle - min - (max-min)/2.0) , (max-min) ) + (max+min)/2.0 );
function wrap_angle (angle : Angle_Type; min : Angle_Type; max : Angle_Type) return Angle_Type is
span : constant Angle_Type := max - min;
d_flt : Float;
d_int : Float;
frac : Float;
less : Angle_Type;
wr : Angle_Type;
off : Angle_Type;
f64 : Interfaces.IEEE_Float_64;
function Sat_Add_Angle is new Saturated_Addition (Angle_Type);
function Sat_Sub_Angle is new Saturated_Subtraction (Angle_Type);
begin
if span = Angle_Type (0.0) then
-- this might happen due to float cancellation, despite precondition
wr := min;
else
pragma Assert (span > Angle_Type (0.0));
if angle >= min and angle <= max then
wr := angle;
elsif angle < min then
off := (min - angle);
d_flt := Float (off / span); -- overflow check might fail
d_int := Float'Floor (d_flt);
frac := Float (d_flt - d_int);
f64 := Interfaces.IEEE_Float_64 (frac) * Interfaces.IEEE_Float_64 (span);
--pragma Assert (f64 >= 0.0);
if f64 < Interfaces.IEEE_Float_64 (Angle_Type'Last) and f64 >= Interfaces.IEEE_Float_64 (Angle_Type'First) then
less := Angle_Type (f64); -- overflow check might fail
wr := Sat_Sub_Angle (max, less);
else
wr := min;
end if;
else -- angle > max
off := angle - max;
d_flt := Float (off / span); -- overflow check might fail
d_int := Float'Floor (d_flt);
frac := Float (d_flt - d_int);
pragma Assert (frac >= 0.0);
f64 := Interfaces.IEEE_Float_64 (frac) * Interfaces.IEEE_Float_64 (span);
--pragma Assert (f64 >= 0.0); -- this fails. why? both span and frac are positive
if f64 > Interfaces.IEEE_Float_64 (Angle_Type'First) and f64 < Interfaces.IEEE_Float_64 (Angle_Type'Last) then
less := Angle_Type (f64);
wr := Sat_Add_Angle (min, less);
else
wr := max;
end if;
end if;
end if;
return wr;
end wrap_angle;
function mirror_Angle( angle : Angle_Type; min : Angle_Type; max : Angle_Type) return Angle_Type is
span : constant Angle_Type := max - min;
cmax : constant Angle_Type := max + span / 2.0;
cmin : constant Angle_Type := min - span / 2.0;
-- limit to the ranges of wrap_angle's preconditions
amax : constant Angle_Type := Angle_Type (if cmax < Angle_Type'Last / 2.0 then cmax else Angle_Type'Last / 2.0);
amin : constant Angle_Type := Angle_Type (if cmin > Angle_Type'First / 2.0 then cmin else Angle_Type'First / 2.0);
--pragma Assert (amin <= 0.0 * Radian);
--pragma Assert (amax >= 0.0 * Radian);
--pragma Assert (max > min);
--pragma Assert (amin >= Angle_Type'First / 2.0);
--pragma Assert (amax <= Angle_Type'Last / 2.0);
wrapped : Angle_Type := wrap_angle (angle => angle, min => amin, max => amax);
result : Angle_Type := wrapped;
begin
if wrapped > max then
result := max - (wrapped - max);
elsif wrapped < min then
result := min - (wrapped - min);
end if;
return result;
end mirror_Angle;
function delta_Angle (From : Angle_Type; To : Angle_Type) return Angle_Type is
function Sat_Sub_Flt is new Saturated_Subtraction (Float);
diff : constant Float := Sat_Sub_Flt (Float (To), Float (From));
begin
return wrap_angle (angle => Angle_Type (diff), min => -180.0 * Degree, max => 180.0 * Degree);
end delta_Angle;
function Image (unit : Unit_Type) return String is
first : constant Float := Float'Truncation (Float (unit));
rest : constant String := Integer_Img (Integer ((Float (unit) - first) * Float(10.0)));
begin
if Float ( unit ) < 0.0 and -1.0 < Float ( unit ) then
return "-" & Integer_Img (Types.Sat_Cast_Int (first)) & "." & rest (rest'Length);
else
return Integer_Img (Types.Sat_Cast_Int (first)) & "." & rest (rest'Length);
end if;
end Image;
function AImage (unit : Angle_Type) return String is
begin
return Integer_Img (Types.Sat_Cast_Int (Float (unit) / Ada.Numerics.Pi * Float(180.0))) & "deg";
end AImage;
function RImage (unit : Angle_Type) return String is
begin
return " " & Image (Unit_Type(unit)) & "rad";
end RImage;
function Saturated_Cast (val : Float) return T is
ret : T;
begin
if val >= Float (T'Last) then
ret := T'Last;
elsif val <= Float (T'First) then
ret := T'First;
else
ret := T (val);
end if;
return ret;
end Saturated_Cast;
function Saturated_Addition (left, right : T) return T is
ret : T;
begin
if right >= T (0.0) and then left >= (T'Last - right) then
ret := T'Last;
elsif right <= T (0.0) and then left <= (T'First - right) then
ret := T'First;
else
declare
cand : constant Float := Float (left) + Float (right); -- this needs to be constant and not a direct assignment to ret
begin
-- range check
if cand > Float (T'Last) then
ret := T'Last;
elsif cand < Float (T'First) then
ret := T'First;
else
ret := T (cand);
end if;
end;
end if;
return ret;
end Saturated_Addition;
function Saturated_Subtraction (left, right : T) return T is
ret : T;
begin
if right >= T (0.0) and then (right + T'First) >= left then
ret := T'First;
elsif right <= T (0.0) and then left >= (T'Last + right) then
ret := T'Last;
else
declare
cand : constant T := left - right; -- this needs to be constant and not a direct assignment to ret
begin
ret := cand;
end;
end if;
return ret;
end Saturated_Subtraction;
function Wrapped_Addition (left, right : T) return T is
cand : constant Float := Float (left) + Float (right);
min : constant T := T'First;
max : constant T := T'Last;
span : constant Float := Float (max - min);
d_flt : Float;
d_int : Float;
frac : Float;
less : T;
off : Float;
f64 : Interfaces.IEEE_Float_64;
wr : T;
begin
if span = 0.0 then
-- this might happen due to float cancellation, despite precondition
wr := min;
else
pragma Assert (span > 0.0);
if cand >= Float (min) and cand <= Float (max) then
wr := T (cand);
elsif cand < Float (min) then
off := (Float (min) - cand);
d_flt := Float (off / span); -- overflow check might fail
d_int := Float'Floor (d_flt);
frac := Float (d_flt - d_int);
f64 := Interfaces.IEEE_Float_64 (frac) * Interfaces.IEEE_Float_64 (span);
--pragma Assert (f64 >= 0.0);
if f64 < Interfaces.IEEE_Float_64 (T'Last) and f64 >= Interfaces.IEEE_Float_64 (T'First) then
less := T (f64); -- overflow check might fail
wr := max - less;
else
wr := min;
end if;
else -- cand > max
off := cand - Float (max);
d_flt := Float (off / span); -- overflow check might fail
d_int := Float'Floor (d_flt);
frac := Float (d_flt - d_int);
pragma Assert (frac >= 0.0);
f64 := Interfaces.IEEE_Float_64 (frac) * Interfaces.IEEE_Float_64 (span);
--pragma Assert (f64 >= 0.0); -- this fails. why? both span and frac are positive
if f64 > Interfaces.IEEE_Float_64 (T'First) and f64 < Interfaces.IEEE_Float_64 (T'Last) then
less := T (f64);
wr := min + less;
else
wr := max;
end if;
end if;
end if;
return wr;
end Wrapped_Addition;
function Saturate (val, min, max : T) return T is
ret : T;
begin
if val < min then
ret := min;
elsif val > max then
ret := max;
else
ret := val;
end if;
return ret;
end Saturate;
end Units;
|
pchapin/augusta | Ada | 151 | adb |
procedure Main is
X : Integer := 0;
Y : Integer;
Z : Integer;
begin
X := (3 + 2)/(3 - 2);
Y := 2*X - 1;
Z := 3*(X + Y/2);
end Main;
|
io7m/coreland-gnatver | Ada | 2,829 | adb | with GNAT.Compiler_Version;
with GNAT.Regpat;
package body GNATver is
package Ver is new GNAT.Compiler_Version;
use type GNAT.Regpat.Match_Location;
Regex_FSF : constant String := "^(GNAT Version: ){0,1}([0-9]).([0-9]).([0-9])";
Regex_GPL : constant String := "^(GNAT Version: ){0,1}GPL [0-9]+ \(([0-9]{4})([0-9]{2})([0-9]{2})\)";
Regex_GAP : constant String := "^(GNAT Version: ){0,1}GAP [0-9]+ \(([0-9]{4})([0-9]{2})([0-9]{2})\)";
Regex_Pro : constant String := "^(GNAT Version: ){0,1}Pro ([0-9]).([0-9]).([0-9])";
procedure Decode
(Version : out Version_t;
Image : in String)
is
Matches : GNAT.Regpat.Match_Array (0 .. 4);
begin
-- check FSF
GNAT.Regpat.Match
(Expression => Regex_FSF,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_FSF;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check GPL
GNAT.Regpat.Match
(Expression => Regex_GPL,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_GPL;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check GAP
GNAT.Regpat.Match
(Expression => Regex_GAP,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_GAP;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
-- check Pro
GNAT.Regpat.Match
(Expression => Regex_Pro,
Data => Image,
Matches => Matches);
if Matches (0) /= GNAT.Regpat.No_Match then
Version.Variant := GNAT_PRO;
Version.Major := Natural'Value (Image (Matches (2).First .. Matches (2).Last));
Version.Minor := Natural'Value (Image (Matches (3).First .. Matches (3).Last));
Version.Patch := Natural'Value (Image (Matches (4).First .. Matches (4).Last));
end if;
end Decode;
procedure Decode_Current
(Version : out Version_t) is
begin
Decode
(Version => Version,
Image => Ver.Version);
end Decode_Current;
end GNATver;
|
stcarrez/ada-el | Ada | 2,743 | ads | -----------------------------------------------------------------------
-- el-beans -- Bean utilities
-- Copyright (C) 2011, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Indefinite_Vectors;
with Util.Beans.Basic;
with EL.Contexts;
with EL.Expressions;
package EL.Beans is
pragma Preelaborate;
-- ------------------------------
-- Bean Initialization
-- ------------------------------
-- The <b>Param_Value</b> describes a bean property that must be initialized by evaluating the
-- associated EL expression. A list of <b>Param_Value</b> can be used to initialize several
-- bean properties of an object. The bean object must implement the <b>Bean</b> interface
-- with the <b>Set_Value</b> operation.
type Param_Value (Length : Natural) is record
Name : String (1 .. Length);
Value : EL.Expressions.Expression;
end record;
package Param_Vectors is
new Ada.Containers.Indefinite_Vectors (Index_Type => Positive,
Element_Type => Param_Value,
"=" => "=");
-- Add a parameter to initialize the bean property identified by the name <b>Name</b>
-- to the value represented by <b>Value</b>. The value string is evaluated as a string or
-- as an EL expression.
procedure Add_Parameter (Container : in out Param_Vectors.Vector;
Name : in String;
Value : in String;
Context : in EL.Contexts.ELContext'Class);
-- Initialize the bean object by evaluation the parameters and set the bean property.
-- Each parameter expression is evaluated by using the EL context. The value is then
-- set on the bean object by using the bean <b>Set_Value</b> procedure.
procedure Initialize (Bean : in out Util.Beans.Basic.Bean'Class;
Params : in Param_Vectors.Vector;
Context : in EL.Contexts.ELContext'Class);
end EL.Beans;
|
Louis-Aime/Milesian_calendar_Ada | Ada | 18,180 | adb | -- Milesian converter
-- A simple converter to and from Milesian dates
-- This programme is a console demonstrator for the referred packages
-- copyright Miletus 2015-2019 - no transformation allowed, no commercial use
-- application developed using GPS GPL 2014 of Adacore
-- inquiries: see www.calendriermilesien.org
-- Versions
-- M2017-01-13 : adaptation to new package specifications
-- M2019-01-16 : Milesian calendar intercalation back to Gregorian
----------------------------------------------------------------------------
-- Copyright Miletus 2015-2019
-- 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:
-- 1. The above copyright notice and this permission notice shall be included
-- in all copies or substantial portions of the Software.
-- 2. Changes with respect to any former version shall be documented.
--
-- The software is provided "as is", without warranty of any kind,
-- express of implied, including but not limited to the warranties of
-- merchantability, fitness for a particular purpose and noninfringement.
-- In no event shall the authors of 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.
-- Inquiries: www.calendriermilesien.org
-------------------------------------------------------------------------------
with Calendar; use Calendar;
with Calendar.Formatting; use Calendar.Formatting;
with Scaliger; use Scaliger;
with Scaliger.Ada_conversion; use Scaliger.Ada_conversion;
with Milesian_calendar; use Milesian_calendar;
with Julian_calendar; use Julian_calendar;
with Lunar_phase_computations; use Lunar_phase_computations;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Text_IO; use Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Milesian_environment; use Milesian_environment;
use Milesian_environment.Week_Day_IO;
use Milesian_environment.Julian_Day_IO;
procedure Milesian_converter is
NL : constant String := CR & LF ;
Licence_text : constant String :=
"Date converter and moon phase computer using the Milesian calendar." & NL &
"Written by Louis A. de Fouquieres, Miletus," & NL &
"Initial version M2015-09-30, actual version M2019-01-16." & NL &
"Generated with the GNAT Programming Studio GPL Edition 2014." & NL &
"No warranty of any kind arising from or in connection with this application."
& NL & "Library sources available on demand under GP licence."
& NL & "No commercial usage allowed - inquiries: www.calendriermilesien.org";
Prompter : constant String := "Type command and figures, or H for Help:";
Help_text : constant String :=
"This line mode program converts dates from and to "
& NL &
"Julian day, Milesian, Gregorian, and Julian calendars." & NL &
"Mean Moon age, residue and lunar time are also computed, " & NL &
"as well as yearly key figures."
& NL &
"Syntax: <Command> <1 to 6 numbers separated with spaces>." & NL &
"<Command> is one character as described hereunder." & NL &
"Numbers are decimal possibly beginning with + or -, without spaces," & NL &
"with a dot (.) as decimal separator when applicable." & NL &
"When a date is expected, it must be entered as: year (-4800 to 9999),"
& NL &
"month number (1 to 12, by default: 1), day number (1 to 31, by default: 1),"
& NL &
"hours (0 to 23, default 12), minutes and seconds (default 0, max 59)."
& NL & "Time of day is Terrestrial Time (64,184 s ahead of UTC in 2000)."
& NL &
"Lunar time is time of day where the mean Moon stands" & NL &
"at the same azimuth than the mean Sun at this solar time." & NL &
"Yearly key figures ('Y' command) include" & NL &
"- doomsday, i.e. day of the week that falls at same dates every year," & NL &
"- lunar figures at new year's eve at 7h30 UTC," & NL &
"- Milesian epact and yearly lunar residue, in half-integer," & NL &
"- spring full moon residue in integer value," & NL &
"- for years A.D., days between 21st March and Easter"
& NL &
"following the Gregorian and Julian Catholic ecclesiastical computus," & NL &
"and finally the delay, in days, of dates in Julian compared to Gregorian."
& NL &
"Available commands:" & NL &
"D <Positive integer or decimal number>: Julian day;" & NL &
"G <Date>: Date in Gregorian calendar (even before 1582);" & NL &
"J <Date>: Date in Julian calendar;" & NL &
"M <Date>: Date in Milesian calendar;" & NL &
"Y <Year>: Yearly key figures (see above);"
& NL &
"A <Days> [<Hours> [<Minutes> [<Seconds>]]]: Add days, hours, mins, secs"
& NL & "to current date, each figure is a signed integer, 0 by default;"
& NL &
"H: display this text;" & NL &
"L: display licence notice;" & NL &
"X: exit program.";
Command : Character := ' ';
Roman_calendar_type : Calendar_type := Unspecified;
-- Duration to substract to Julian Day of first day of a year, in order
-- to obtain time of "doomsday" at which the moon phase is computed.
To_Doomsday_time_duration : constant Historical_Duration
:= 86_400.0 + 4*3600.0 + 30*60.0;
-- To substract to Milesian epact to obtain a good estimate
-- of Easter full moon residue
To_Spring_Full_Moon : Constant := 12.52 * 86_400;
This_year : Historical_year_number := 0;
M_date: Milesian_date := (4, 12, -4713);
R_date : Roman_date := (1, 1, -4712);
This_Julian_day: Julian_day := 0; -- in integer days
This_historical_time: Historical_Time := 0.0; -- in seconds
Displayed_time: Fractional_day_duration := 0.0; -- in fractional days
This_hour : Hour_Number := 12;
This_minute : Minute_Number := 0;
This_second : Second_Number :=0;
Day_time : Day_Duration := 0.0;
Julian_hour : Day_Historical_Duration := 0.0;
Day_Number_in_Week : Integer range 0..6;
Moon_time, Moon_time_shift : H24_Historical_Duration;
Moon_hour : Hour_Number;
Moon_minute: Minute_Number;
Moon_second: Second_Number;
Moon_subsecond: Second_Duration;
Help_request, Licence_request : Exception;
begin
Put (Licence_text); New_Line;
loop
begin -- a block with exception handler
Put (Prompter); New_Line;
Get (Command);
case Command is
when 'H' => Skip_Line; raise Help_request;
when 'L' => Skip_Line; raise Licence_request;
when 'D' =>
--Get section
Get (Displayed_time); Skip_Line;
-- Conversion section
This_historical_time := Convert_from_julian_day (Displayed_time);
This_Julian_day := Julian_Day_Of (This_historical_time);
M_date := jd_to_milesian (This_Julian_day);
Julian_hour := This_historical_time - Julian_Duration_Of (This_Julian_day);
Day_time := Day_Offset (Julian_hour);
This_hour := Integer (Day_time) / 3600;
This_minute := Integer (Day_time) / 60 - This_hour*60;
This_second := Integer (Day_time) - This_hour*3600 - This_minute*60;
when 'G' | 'J' =>
-- Get section.
case Command is
when 'G' => Roman_calendar_type := Gregorian;
when 'J' => Roman_calendar_type := Julian;
when others => Roman_calendar_type := Unspecified;
end case;
R_date := (1, 1, -4712);
This_hour := 12; This_minute := 0; This_second := 0;
Get (R_date.year);
if not End_Of_Line then Get (R_date.month); end if;
if not End_Of_Line then Get (R_date.day); end if;
if not End_Of_Line then Get (This_hour); end if;
if not End_Of_Line then Get (This_minute); end if;
if not End_Of_Line then Get (This_second); end if;
Skip_Line;
-- Conversion section;
This_Julian_day := Roman_to_JD (R_date, Roman_calendar_type);
-- This function raises Time_Error if date is improper
Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second;
This_historical_time := Julian_Duration_Of (This_Julian_day) + Day_Julian_Offset (Day_time);
Displayed_time := Fractionnal_day_of (This_historical_time);
M_date := JD_to_Milesian (This_Julian_day);
when 'M' =>
M_Date := (1, 1, -4712);
This_hour := 12; This_minute := 0; This_second := 0;
Get (M_date.year);
if not End_Of_Line then Get (M_date.month); end if;
if not End_Of_Line then Get (M_date.day); end if;
if not End_Of_Line then Get (This_hour); end if;
if not End_Of_Line then Get (This_minute); end if;
if not End_Of_Line then Get (This_second); end if;
Skip_Line;
-- Conversion section;
This_Julian_day := Milesian_to_JD (M_date);
-- This function raises Time_Error if date is improper
Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second;
This_historical_time := Julian_Duration_Of (This_Julian_day) + Day_Julian_Offset (Day_time);
Displayed_time := Fractionnal_day_of (This_historical_time);
M_date := JD_to_Milesian (This_Julian_day);
when 'Y' =>
M_Date := (1, 1, -4712);
This_hour := 12; This_minute := 0; This_second := 0;
Get (This_year); M_date.year := This_year;
Skip_Line;
-- Conversion section: compute "doomsday"
This_Julian_day := Milesian_to_JD (M_date);
-- Set to "doomsday"
Day_time := 3600.0 * This_hour + 60.0 * This_minute + 1.0 * This_second;
This_historical_time := Julian_Duration_Of (This_Julian_day)
+ Day_Julian_Offset (Day_time)
- To_Doomsday_time_duration;
This_Julian_day := Julian_Day_Of (This_historical_time);
M_date := jd_to_milesian (This_Julian_day);
Displayed_time := Fractionnal_day_of (This_historical_time);
when 'A' =>
declare
Days : Julian_Day_Duration := 0;
Hour_Offset, Minute_Offset, Second_Offset : Integer := 0;
Julian_Time_Offset : Historical_Duration := 0.0;
begin
-- Get section
Get (Days);
if not End_Of_Line then Get (Hour_Offset); end if;
if not End_Of_Line then Get (Minute_Offset); end if;
if not End_Of_Line then Get (Second_Offset); end if;
Skip_Line;
-- Conversion section
Julian_Time_Offset := Julian_Duration_Of
(3600.0 * Hour_Offset
+ 60.0 * Minute_Offset
+ 1.0 * Second_Offset);
This_historical_time :=
This_historical_time + Julian_Duration_Of (Days) + Julian_Time_Offset ;
This_Julian_day := Julian_Day_Of (This_historical_time);
M_date := jd_to_milesian (This_Julian_day);
Julian_hour := This_historical_time - Julian_Duration_Of (This_Julian_day);
Displayed_time := Fractionnal_day_of (This_historical_time);
begin
Day_time := Day_Offset (Julian_hour);
exception
when Constraint_Error =>
Put("Day time out of bounds - correcting"); New_Line;
Day_time := 86_399.88;
-- avoids out of bounds.
end;
This_hour := Integer (Day_time) / 3600;
This_minute := Integer (Day_time) / 60 - This_hour*60;
This_second := Integer (Day_time) - This_hour*3600 - This_minute*60;
end;
when 'X' => put ("Bye");
when others =>
put (">Invalid command "); New_Line; Skip_Line;
end case;
exit when Command = 'X';
-- Display results section - Julian day and Milesian date.
Day_Number_in_Week := This_Julian_day mod 7;
If Command /= 'Y' then
put ("Julian day : ");
put (Displayed_time,1,6); put ("; ");
put ("Milesian : ");
put (Day_Name'Val (This_Julian_day mod 7),3, Lower_Case); Put (' ');
put (M_date.day,1); put (' ');
put (M_date.month, 1); put("m "); put (M_date.year, 1);
put (", "); put (This_hour, 1); put ("h "); put (This_minute, 1);
put ("mn "); put (This_second, 1); Put ("s");
New_Line;
-- Put Julian and Gregorian calendar equivalent
Put ("Julian : ");
R_date := JD_to_Roman (This_Julian_day, Julian);
Put (R_date.day,1); Put ('/');
Put (R_date.month,1); Put ('/');
Put (R_date.year,1);
Put ("; Gregorian : ");
R_date := JD_to_Roman (This_Julian_day, Gregorian);
Put (R_date.day,1); Put ('/');
Put (R_date.month,1); Put ('/');
Put (R_date.year,1);
else
put ("Year: "); put (This_year, 4); put("; Doomsday: ");
put (Day_Name'Val (This_Julian_day mod 7),3, Lower_Case); Put (' ');
end if ;
-- Give Lunar phase
New_Line;
Put ("Lunar age: ");
Julian_Day_IO.Put (Fractionnal_day_of(Mean_lunar_age (This_historical_time)),1);
Put ("; Lunar residue: ");
Julian_Day_IO.Put (Fractionnal_day_of(Mean_lunar_residue (This_historical_time)),1);
Put (";");
if Command /= 'Y' then -- Display lunar hour - not with year infos.
New_Line; Put("Lunar time: ");
Moon_time_shift := Mean_lunar_time_shift (This_historical_time);
if Day_time >= Duration(Moon_time_shift)
then Moon_time
:= H24_Historical_Duration(Day_time - Duration(Moon_time_shift));
else Moon_time
:= H24_Historical_Duration(86_400.0 + Day_time - Duration(Moon_time_shift));
end if;
Split (Duration(Moon_time), Moon_hour, Moon_minute, Moon_second,
Moon_subsecond);
Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn ");
Put (Moon_second,2); Put ("s (shift : -");
Split (Duration(Moon_time_shift), Moon_hour, Moon_minute, Moon_second,
Moon_subsecond);
Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn ");
Put (Moon_second,2); Put ("s, or +");
Split (Duration(86_400.0 - Moon_time_shift), Moon_hour, Moon_minute, Moon_second,
Moon_subsecond);
Put(Moon_hour,2); Put ("h "); Put (Moon_minute,2); Put ("mn ");
Put (Moon_second,2); Put ("s)");
end if;
If Command = 'Y' then
declare
type Simplified_lunar_age is delta 0.5 range 0.0 .. 29.5;
package Lunar_age_IO is
new Text_IO.Fixed_IO (Num => Simplified_lunar_age);
Age : Lunar_age := Mean_lunar_age (This_historical_time);
Simple_Age : Simplified_lunar_age :=
Simplified_lunar_age (Float(Fractionnal_day_of(Age)));
Simple_Residue : Simplified_lunar_age := 29.5 - Simple_Age;
Spring_residue : Integer := 0;
begin
if Age <= To_Spring_Full_Moon
then Spring_residue := Integer (Float'Floor
(Float(Fractionnal_day_of(To_Spring_Full_Moon - Age))));
else Spring_residue := Integer (Float'Floor
(Float(29.53 - Fractionnal_day_of
(Age - To_Spring_Full_Moon))));
end if;
New_Line;
Put ("Year moon age: ");
Lunar_age_IO.Put(Item => Simple_Age,
Fore => 2,
Aft => 1);
Put ("; Year moon residue: ");
Lunar_age_IO.Put(Item => Simple_Residue,
Fore => 2,
Aft => 1);
Put ("; Spring full moon residue: ");
Put(Spring_residue, 2); Put (".");
If This_year >= 1 then
New_Line;
Put ("21 March to Easter, Gregorian Computus: ");
Put (Easter_days (This_year,Gregorian),2);
Put (", Julian: "); Put (Easter_days (This_year,Julian),2);
Put (".");
end if;
New_Line;
Put ("Delay in days of Julian calendar with respect to Gregorian :");
Put (Julian_to_Gregorian_Delay(This_year),3);
end;
end if;
exception
when Constraint_Error =>
Put (" Out of bounds");
when Data_Error =>
Put (" Invalid data");
when Scaliger.Time_Error =>
Put (" Invalid date");
when Help_request => Put (Help_text);
when Licence_request => Put (Licence_text);
when others => Put (" Unknown error");
end;
New_Line;
end loop;
end Milesian_converter;
|
stcarrez/dynamo | Ada | 34,718 | adb | -----------------------------------------------------------------------
-- gen-model-xmi -- UML-XMI model
-- Copyright (C) 2012, 2013, 2015, 2016, 2021, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- 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.Tags;
with Util.Strings;
with Util.Log.Loggers;
package body Gen.Model.XMI is
use Ada.Strings.Unbounded;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Gen.Model.XMI");
procedure Append_Message (Into : in out UString;
Message : in String);
-- ------------------------------
-- Append a message to the error message. A newline is inserted if the buffer contains
-- an existing message.
-- ------------------------------
procedure Append_Message (Into : in out UString;
Message : in String) is
begin
if Length (Into) > 0 then
Append (Into, ASCII.LF);
end if;
Append (Into, Message);
end Append_Message;
-- ------------------------------
-- Iterate on the model element of the type <tt>On</tt> and execute the <tt>Process</tt>
-- procedure.
-- ------------------------------
procedure Iterate (Model : in Model_Map.Map;
On : in Element_Type;
Process : not null access procedure (Id : in UString;
Node : in Model_Element_Access)) is
Iter : Model_Map_Cursor := Model.First;
begin
while Has_Element (Iter) loop
declare
Node : constant Model_Element_Access := Element (Iter);
begin
if Node.Get_Type = On then
Process (Model_Map.Key (Iter), Node);
end if;
end;
Next (Iter);
end loop;
end Iterate;
-- ------------------------------
-- Iterate over the model elements of the list.
-- ------------------------------
procedure Iterate_Elements (Closure : in out T;
List : in Model_Vector;
Process : not null access
procedure (Closure : in out T;
Node : in Model_Element_Access)) is
Iter : Model_Cursor := List.First;
begin
while Model_Vectors.Has_Element (Iter) loop
Process (Closure, Model_Vectors.Element (Iter));
Model_Vectors.Next (Iter);
end loop;
end Iterate_Elements;
-- ------------------------------
-- Find the model element with the given XMI id or given name.
-- Returns null if the model element is not found.
-- ------------------------------
function Find (Model : in Model_Map.Map;
Key : in String;
Mode : in Search_Type := BY_ID) return Model_Element_Access is
begin
if Mode = BY_ID then
declare
Pos : constant Model_Map_Cursor := Model.Find (To_UString (Key));
begin
if Has_Element (Pos) then
return Element (Pos);
else
Log.Error ("Model element id '{0}' not found", Key);
return null;
end if;
end;
else
declare
Iter : Model_Map_Cursor := Model.First;
Pos : Natural;
begin
if Key (Key'First) /= '@' then
Pos := Util.Strings.Index (Key, '.');
else
Pos := 0;
end if;
while Has_Element (Iter) loop
declare
Node : Model_Element_Access := Element (Iter);
begin
-- Find in the package only. If there is no '.', check the package name only.
if Node.Get_Type = XMI_PACKAGE then
if Pos = 0 and then Node.Name = Key then
return Node;
end if;
-- Check that the package name matches and look in it.
if Pos > 0 and then Node.Name = Key (Key'First .. Pos - 1) then
Node := Node.Find (Key (Pos + 1 .. Key'Last));
if Node /= null then
return Node;
end if;
end if;
end if;
end;
Next (Iter);
end loop;
end;
return null;
end if;
end Find;
-- ------------------------------
-- Find from the model file identified by <tt>Name</tt>, the model element with the
-- identifier or name represented by <tt>Key</tt>.
-- Returns null if the model element is not found.
-- ------------------------------
function Find_Element (Model : in UML_Model;
Name : in String;
Key : in String;
Mode : in Search_Type := BY_ID)
return Element_Type_Access is
Model_Pos : constant UML_Model_Map.Cursor := Model.Find (To_UString (Name));
Item : Model_Element_Access;
begin
if UML_Model_Map.Has_Element (Model_Pos) then
if Mode = BY_ID or else Mode = BY_NAME then
Item := Find (UML_Model_Map.Element (Model_Pos), Key, Mode);
else
declare
Iter : Model_Map_Cursor := UML_Model_Map.Element (Model_Pos).First;
begin
while Has_Element (Iter) loop
declare
Node : constant Model_Element_Access := Element (Iter);
begin
if Node.all in Element_Type'Class and then Node.Name = Key then
return Element_Type'Class (Node.all)'Access;
end if;
end;
Next (Iter);
end loop;
end;
end if;
if Item = null then
Log.Error ("The model file {0} does not define {1}",
Name, Key);
return null;
end if;
if not (Item.all in Element_Type'Class) then
Log.Error ("The model file {0} defines the element {1}",
Name, Key);
return null;
end if;
return Element_Type'Class (Item.all)'Access;
else
Log.Error ("Model file {0} not found", Name);
return null;
end if;
end Find_Element;
-- ------------------------------
-- Find the model element within all loaded UML models.
-- Returns null if the model element is not found.
-- ------------------------------
function Find (Model : in UML_Model;
Current : in Model_Map.Map;
Id : in UString)
return Model_Element_Access is
Pos : constant Natural := Index (Id, "#");
First : Natural;
begin
if Pos = 0 then
return Find (Current, To_String (Id));
end if;
First := Index (Id, "/", Pos, Ada.Strings.Backward);
if First = 0 then
First := 1;
else
First := First + 1;
end if;
declare
Len : constant Natural := Length (Id);
Name : constant UString := Unbounded_Slice (Id, First, Pos - 1);
Model_Pos : constant UML_Model_Map.Cursor := Model.Find (Name);
begin
if UML_Model_Map.Has_Element (Model_Pos) then
return Find (UML_Model_Map.Element (Model_Pos),
Slice (Id, Pos + 1, Len));
else
Log.Error ("Model element {0} not found", To_String (Id));
return null;
end if;
end;
end Find;
-- ------------------------------
-- Dump the XMI model elements.
-- ------------------------------
procedure Dump (Map : in Model_Map.Map) is
Iter : Model_Map_Cursor := Map.First;
begin
while Has_Element (Iter) loop
Element (Iter).Dump;
Next (Iter);
end loop;
end Dump;
-- ------------------------------
-- Reconcile all the UML model elements by resolving all the references to UML elements.
-- ------------------------------
procedure Reconcile (Model : in out UML_Model;
Debug : in Boolean := False) is
procedure Reconcile_Model (Key : in UString;
Map : in out Model_Map.Map);
procedure Reconcile_Model (Key : in UString;
Map : in out Model_Map.Map) is
pragma Unreferenced (Key);
Iter : Model_Map_Cursor := Map.First;
begin
while Has_Element (Iter) loop
declare
Node : constant Model_Element_Access := Element (Iter);
begin
Node.Reconcile (Model);
end;
Next (Iter);
end loop;
if Debug then
Gen.Model.XMI.Dump (Map);
end if;
end Reconcile_Model;
Iter : UML_Model_Map.Cursor := Model.First;
begin
while UML_Model_Map.Has_Element (Iter) loop
UML_Model_Map.Update_Element (Model, Iter, Reconcile_Model'Access);
UML_Model_Map.Next (Iter);
end loop;
end Reconcile;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
procedure Reconcile (Node : in out Model_Element;
Model : in UML_Model) is
Iter : Model_Cursor := Node.Stereotypes.First;
begin
while Model_Vectors.Has_Element (Iter) loop
Model_Vectors.Element (Iter).Reconcile (Model);
Model_Vectors.Next (Iter);
end loop;
end Reconcile;
-- ------------------------------
-- Find the element with the given name. If the name is a qualified name, navigate
-- down the package/class to find the appropriate element.
-- Returns null if the element was not found.
-- ------------------------------
function Find (Node : in Model_Element;
Name : in String) return Model_Element_Access is
Pos : constant Natural := Util.Strings.Index (Name, '.');
Iter : Model_Cursor;
Item : Model_Element_Access;
begin
if Pos = 0 or else Name (Name'First) = '@' then
Iter := Node.Elements.First;
while Model_Vectors.Has_Element (Iter) loop
Item := Model_Vectors.Element (Iter);
if Item.Name = Name then
return Item;
end if;
Model_Vectors.Next (Iter);
end loop;
return null;
else
Item := Node.Find (Name (Name'First .. Pos - 1));
if Item = null then
return null;
end if;
return Item.Find (Name (Pos + 1 .. Name'Last));
end if;
end Find;
-- ------------------------------
-- Set the model name.
-- ------------------------------
procedure Set_Name (Node : in out Model_Element;
Value : in UBO.Object) is
begin
if not UBO.Is_Null (Value) then
Node.Set_Name (UBO.To_Unbounded_String (Value));
end if;
end Set_Name;
-- ------------------------------
-- Set the model XMI unique id.
-- ------------------------------
procedure Set_XMI_Id (Node : in out Model_Element;
Value : in UBO.Object) is
begin
Node.XMI_Id := UBO.To_Unbounded_String (Value);
end Set_XMI_Id;
-- ------------------------------
-- Validate the node definition as much as we can before the reconcile phase.
-- If an error is detected, return a message. Returns an empty string if everything is ok.
-- ------------------------------
function Get_Error_Message (Node : in Model_Element) return String is
Result : UString;
begin
if Length (Node.XMI_Id) = 0 then
Append (Result, "the 'xmi.id' attribute is empty");
end if;
return To_String (Result);
end Get_Error_Message;
-- ------------------------------
-- Dump the node to get some debugging description about it.
-- ------------------------------
procedure Dump (Node : in Model_Element) is
begin
Log.Info ("XMI {0} - {2}: {1}",
Element_Type'Image (Model_Element'Class (Node).Get_Type),
To_String (Node.XMI_Id), To_String (Node.Name));
if Node.Parent /= null then
Log.Info (" Parent: {0} ({1})", To_String (Node.Parent.Name),
Element_Type'Image (Node.Parent.Get_Type));
end if;
declare
Iter : Model_Cursor := Node.Tagged_Values.First;
Tag : Tagged_Value_Element_Access;
begin
while Model_Vectors.Has_Element (Iter) loop
Tag := Tagged_Value_Element'Class (Model_Vectors.Element (Iter).all)'Access;
if Tag.Tag_Def /= null then
Log.Info (" Tag: {0} = {1}",
To_String (Tag.Tag_Def.Name),
To_String (Tag.Value));
else
Log.Info (" Undef tag: {0} = {1}",
To_String (Tag.XMI_Id), To_String (Tag.Value));
end if;
Model_Vectors.Next (Iter);
end loop;
end;
declare
Stereotype : Model_Cursor := Node.Stereotypes.First;
begin
while Model_Vectors.Has_Element (Stereotype) loop
Log.Info (" Stereotype: <<{0}>>: {1}",
To_String (Model_Vectors.Element (Stereotype).Name),
To_String (Model_Vectors.Element (Stereotype).XMI_Id));
Model_Vectors.Next (Stereotype);
end loop;
end;
end Dump;
-- ------------------------------
-- Find the tag value element with the given name.
-- Returns null if there is no such tag.
-- ------------------------------
function Find_Tag_Value (Node : in Model_Element;
Name : in String) return Tagged_Value_Element_Access is
Pos : Model_Cursor := Node.Tagged_Values.First;
Tag : Model_Element_Access;
begin
while Model_Vectors.Has_Element (Pos) loop
Tag := Model_Vectors.Element (Pos);
if Tag.Name = Name then
return Tagged_Value_Element'Class (Tag.all)'Access;
end if;
Model_Vectors.Next (Pos);
end loop;
return null;
end Find_Tag_Value;
-- ------------------------------
-- Find the tag value associated with the given tag definition.
-- Returns the tag value if it was found, otherwise returns the default
-- ------------------------------
function Find_Tag_Value (Node : in Model_Element;
Definition : in Tag_Definition_Element_Access;
Default : in String := "") return String is
Pos : Model_Cursor := Node.Tagged_Values.First;
Tag : Model_Element_Access;
begin
while Model_Vectors.Has_Element (Pos) loop
Tag := Model_Vectors.Element (Pos);
if Tag.all in Tagged_Value_Element'Class and then
Tagged_Value_Element'Class (Tag.all).Tag_Def = Definition
then
return To_String (Tagged_Value_Element'Class (Tag.all).Value);
end if;
Model_Vectors.Next (Pos);
end loop;
return Default;
end Find_Tag_Value;
-- ------------------------------
-- Get the documentation and comment associated with the model element.
-- Returns the empty string if there is no comment.
-- ------------------------------
function Get_Comment (Node : in Model_Element) return String is
procedure Collect_Comment (Id : in UString;
Item : in Model_Element_Access);
Doc : constant Tagged_Value_Element_Access := Node.Find_Tag_Value (TAG_DOCUMENTATION);
Result : UString;
procedure Collect_Comment (Id : in UString;
Item : in Model_Element_Access) is
pragma Unreferenced (Id);
Comment : constant Comment_Element_Access := Comment_Element'Class (Item.all)'Access;
begin
if Comment.Ref_Id = Node.XMI_Id then
Append (Result, Comment.Text);
end if;
end Collect_Comment;
begin
Iterate (Node.Model.all, XMI_COMMENT, Collect_Comment'Access);
if Doc /= null then
Append (Result, Doc.Value);
end if;
return To_String (Result);
end Get_Comment;
-- ------------------------------
-- Get the full qualified name for the element.
-- ------------------------------
function Get_Qualified_Name (Node : in Model_Element) return String is
begin
if Node.Parent /= null then
return Node.Parent.Get_Qualified_Name & "." & To_String (Node.Name);
else
return To_String (Node.Name);
end if;
end Get_Qualified_Name;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Ref_Type_Element) return Element_Type is
begin
if Node.Ref /= null then
return Node.Ref.Get_Type;
else
return XMI_UNKNOWN;
end if;
end Get_Type;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Ref_Type_Element;
Model : in UML_Model) is
Item : constant Model_Element_Access := Find (Model, Node.Model.all, Node.Ref_Id);
begin
if Item /= null then
Node.Set_Name (Item.Name);
Node.Ref := Item;
Node.XMI_Id := Item.XMI_Id;
end if;
Model_Element (Node).Reconcile (Model);
end Reconcile;
-- ------------------------------
-- Set the reference id and collect in the profiles set the UML profiles that must
-- be loaded to get the reference.
-- ------------------------------
procedure Set_Reference_Id (Node : in out Ref_Type_Element;
Ref : in String;
Profiles : in out Util.Strings.Sets.Set) is
Pos : constant Natural := Util.Strings.Index (Ref, '#');
begin
Node.Ref_Id := To_UString (Ref);
if Pos > 0 then
declare
First : constant Natural := Util.Strings.Rindex (Ref, '/', Pos);
begin
Profiles.Include (Ref (First + 1 .. Pos - 1));
end;
end if;
end Set_Reference_Id;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Data_Type_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_DATA_TYPE;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Enum_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_ENUMERATION;
end Get_Type;
-- ------------------------------
-- Validate the node definition as much as we can before the reconcile phase.
-- An enum must not be empty, it must have at least one literal.
-- If an error is detected, return a message. Returns an empty string if everything is ok.
-- ------------------------------
overriding
function Get_Error_Message (Node : in Enum_Element) return String is
Result : UString;
begin
Append (Result, Model_Element (Node).Get_Error_Message);
if Node.Elements.Is_Empty then
Append_Message (Result, "the enum '" & To_String (Node.Name) & "' is empty.");
end if;
return To_String (Result);
end Get_Error_Message;
-- ------------------------------
-- Create an enum literal and add it to the enum.
-- ------------------------------
procedure Add_Literal (Node : in out Enum_Element;
Id : in UBO.Object;
Name : in UBO.Object;
Literal : out Literal_Element_Access) is
begin
Literal := new Literal_Element (Node.Model);
Literal.XMI_Id := UBO.To_Unbounded_String (Id);
Literal.Set_Name (UBO.To_Unbounded_String (Name));
Node.Elements.Append (Literal.all'Access);
end Add_Literal;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Literal_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_ENUMERATION_LITERAL;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Stereotype_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_STEREOTYPE;
end Get_Type;
-- ------------------------------
-- Returns True if the model element has the stereotype with the given name.
-- ------------------------------
function Has_Stereotype (Node : in Model_Element'Class;
Stereotype : in Stereotype_Element_Access) return Boolean is
Iter : Model_Cursor := Node.Stereotypes.First;
begin
if Stereotype = null then
return False;
end if;
while Model_Vectors.Has_Element (Iter) loop
declare
S : constant Model_Element_Access := Model_Vectors.Element (Iter);
begin
if S = Stereotype.all'Access then
return True;
end if;
if S.XMI_Id = Stereotype.XMI_Id then
return True;
end if;
end;
Model_Vectors.Next (Iter);
end loop;
return False;
end Has_Stereotype;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Comment_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_COMMENT;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Operation_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_OPERATION;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Attribute_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_ATTRIBUTE;
end Get_Type;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Attribute_Element;
Model : in UML_Model) is
Item : Model_Element_Access;
begin
if Length (Node.Ref_Id) = 0 then
return;
end if;
Item := Find (Model, Node.Model.all, Node.Ref_Id);
Model_Element (Node).Reconcile (Model);
if Item = null then
return;
end if;
if not (Item.all in Data_Type_Element'Class) then
Log.Error ("Invalid data type {0}", To_String (Node.Ref_Id));
return;
end if;
Node.Data_Type := Data_Type_Element'Class (Item.all)'Access;
end Reconcile;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Parameter_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_PARAMETER;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Association_End_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_ASSOCIATION_END;
end Get_Type;
-- ------------------------------
-- Get the documentation and comment associated with the model element.
-- Integrates the comment from the association itself as well as this association end.
-- Returns the empty string if there is no comment.
-- ------------------------------
overriding
function Get_Comment (Node : in Association_End_Element) return String is
Comment : constant String := Model_Element (Node).Get_Comment;
Association_Comment : constant String := Node.Parent.Get_Comment;
begin
if Association_Comment'Length = 0 then
return Comment;
elsif Comment'Length = 0 then
return Association_Comment;
else
return Association_Comment & ASCII.LF & Comment;
end if;
end Get_Comment;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Association_End_Element;
Model : in UML_Model) is
begin
Model_Element (Node).Reconcile (Model);
end Reconcile;
-- ------------------------------
-- Make the association between the two ends.
-- ------------------------------
procedure Make_Association (From : in out Association_End_Element;
To : in out Association_End_Element'Class;
Model : in UML_Model) is
Target : Model_Element_Access;
Source : Model_Element_Access;
begin
Log.Info ("Reconcile association {0} - {1}",
To_String (From.Name), To_String (To.Name));
Target := Find (Model, From.Model.all, To.Ref_Id);
if Target = null then
Log.Error ("Association end {0} not found", To_String (From.Name));
return;
end if;
Source := Find (Model, From.Model.all, From.Ref_Id);
if Source = null then
Log.Error ("Association end {0} not found", To_String (To.Name));
return;
end if;
if From.Navigable then
Class_Element'Class (Target.all).Associations.Append (From'Unchecked_Access);
From.Target_Element := Target.all'Access;
From.Source_Element := Source.all'Access;
Log.Info ("Class {0} { {1}: {2} }",
To_String (Target.Name),
To_String (From.Name),
To_String (Source.Name));
if Length (From.Name) = 0 then
Log.Error ("Class {0}: missing association end name to class {1}",
To_String (Target.Name), To_String (Source.Name));
end if;
end if;
end Make_Association;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Association_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_ASSOCIATION;
end Get_Type;
-- ------------------------------
-- Validate the node definition as much as we can before the reconcile phase.
-- An association must contain two ends and a name is necessary on the navigable ends.
-- If an error is detected, return a message. Returns an empty string if everything is ok.
-- ------------------------------
overriding
function Get_Error_Message (Node : in Association_Element) return String is
use type Ada.Containers.Count_Type;
Result : UString;
begin
Append (Result, Model_Element (Node).Get_Error_Message);
if Length (Node.Name) = 0 then
Append_Message (Result, "Association has an empty name.");
end if;
if Node.Connections.Length = 2 then
declare
First, Second : Association_End_Element_Access;
begin
First := Association_End_Element'Class (Node.Connections.Element (1).all)'Access;
Second := Association_End_Element'Class (Node.Connections.Element (2).all)'Access;
if First.Navigable and then Length (First.Name) = 0 then
Append_Message (Result, "Association '" & To_String (Node.Name) &
"' has a navigable association end with an empty name.");
end if;
if Second.Navigable and then Length (Second.Name) = 0 then
Append_Message (Result, "Association '" & To_String (Node.Name) &
"' has a navigable association end with an empty name.");
end if;
if not First.Navigable and then not Second.Navigable then
Append_Message (Result, "Association '" & To_String (Node.Name) &
"' has no navigable association ends.");
end if;
end;
elsif Node.Connections.Length /= 0 then
Append_Message (Result, "Association '" & To_String (Node.Name)
& "' needs 2 association ends");
end if;
return To_String (Result);
end Get_Error_Message;
-- ------------------------------
-- Reconcile the association between classes in the package. Find the association
-- ends and add the necessary links to the corresponding class elements.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Association_Element;
Model : in UML_Model) is
use type Ada.Containers.Count_Type;
begin
Model_Element (Node).Reconcile (Model);
if Node.Connections.Length >= 2 then
declare
First, Second : Association_End_Element_Access;
begin
First := Association_End_Element'Class (Node.Connections.Element (1).all)'Access;
Second := Association_End_Element'Class (Node.Connections.Element (2).all)'Access;
First.Make_Association (Second.all, Model);
Second.Make_Association (First.all, Model);
end;
elsif Node.Connections.Length > 0 then
Log.Info ("Association {0} needs 2 association ends", To_String (Node.Name));
end if;
end Reconcile;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Generalization_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_GENERALIZATION;
end Get_Type;
-- ------------------------------
-- Reconcile the association between classes in the package. Find the association
-- ends and add the necessary links to the corresponding class elements.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Generalization_Element;
Model : in UML_Model) is
begin
Ref_Type_Element (Node).Reconcile (Model);
Node.Child_Class := Find (Model, Node.Model.all, Node.Child_Id);
if Node.Child_Class /= null then
if Node.Child_Class.all in Class_Element'Class then
Class_Element'Class (Node.Child_Class.all).Parent_Class := Node'Unchecked_Access;
elsif Node.Child_Class.all in Data_Type_Element'Class then
Data_Type_Element'Class (Node.Child_Class.all).Parent_Type := Node'Unchecked_Access;
end if;
end if;
end Reconcile;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Tagged_Value_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_TAGGED_VALUE;
end Get_Type;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Tagged_Value_Element;
Model : in UML_Model) is
Item : constant Model_Element_Access := Find (Model, Node.Model.all, Node.Ref_Id);
begin
Model_Element (Node).Reconcile (Model);
if Item /= null then
Node.Set_Name (Item.Name);
if not (Item.all in Tag_Definition_Element'Class) then
Log.Error ("Element {0} is not a tag definition. Tag is {1}, reference is {2}",
To_String (Item.Name),
Ada.Tags.Expanded_Name (Item'Tag),
To_String (Node.Ref_Id));
else
Node.Tag_Def := Tag_Definition_Element'Class (Item.all)'Access;
end if;
end if;
end Reconcile;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Tag_Definition_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_TAG_DEFINITION;
end Get_Type;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Class_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_CLASS;
end Get_Type;
-- ------------------------------
-- Reconcile the element by resolving the references to other elements in the model.
-- ------------------------------
overriding
procedure Reconcile (Node : in out Class_Element;
Model : in UML_Model) is
begin
if Node.Parent_Class /= null then
Node.Parent_Class.Reconcile (Model);
end if;
Data_Type_Element (Node).Reconcile (Model);
end Reconcile;
-- ------------------------------
-- Get the element type.
-- ------------------------------
overriding
function Get_Type (Node : in Package_Element) return Element_Type is
pragma Unreferenced (Node);
begin
return XMI_PACKAGE;
end Get_Type;
end Gen.Model.XMI;
|
reznikmm/matreshka | Ada | 4,615 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Class_Names_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Class_Names_Attribute_Node is
begin
return Self : Draw_Class_Names_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Class_Names_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Class_Names_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Class_Names_Attribute,
Draw_Class_Names_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Class_Names_Attributes;
|
AdaCore/gpr | Ada | 2,998 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
-- This is an internal GPR2 Unit used to implement a cache for attribute
-- evaluation. The cache protocol is the following:
--
-- C := Check_Cache (...);
-- if Has_Element (C) then
-- return Element (C);
-- end if;
--
-- Schedule_Update_Cache;
--
-- ... compute value to cache ...
--
-- Update_Cache (..., New_Value);
--
-- The cache is thread safe and lock-free on read operations. The lock-free
-- read is possible by using using some extra memory. It relies also in the
-- fact that in Indefinite_Hashed_Maps reallocation is done only if there is
-- need for new capacity.
with GPR2.Project.Attribute;
with GPR2.Project.Attribute_Index;
package GPR2.Project.Attribute_Cache is
type Object is tagged private;
type Cursor is private;
function Check_Cache
(Self : Object;
Name : Q_Attribute_Id;
Index : Project.Attribute_Index.Object := Attribute_Index.Undefined;
At_Pos : Unit_Index := No_Index)
return Cursor;
function Has_Element (C : Cursor) return Boolean;
function Element (C : Cursor) return GPR2.Project.Attribute.Object;
procedure Schedule_Update_Cache (Self : Object);
procedure Update_Cache
(Self : Object;
Name : Q_Attribute_Id;
Index : Project.Attribute_Index.Object := Attribute_Index.Undefined;
At_Pos : Unit_Index := No_Index;
Attr : GPR2.Project.Attribute.Object);
procedure Clear_Cache (Self : Object);
-- Empty the cache
procedure Disable_Cache (Self : Object);
-- Empty the cache, and do not store anything until the cache is re-enabled
procedure Enable_Cache (Self : Object);
-- Re-enable storage in the cache
private
package Attribute_Cache_Maps is
new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => Project.Attribute.Object,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => Project.Attribute."=");
type Map_Access is access Attribute_Cache_Maps.Map;
type Count_Type_Access is access Ada.Containers.Count_Type;
type Cursor is new Attribute_Cache_Maps.Cursor;
type Inner_Object is record
Enabled : Boolean := True;
Table : Map_Access := null;
Former_Table : Map_Access := null;
Needed_Extra_Capacity : Ada.Containers.Count_Type := 0;
end record;
type Inner_Object_Access is access Inner_Object;
type Object is new Ada.Finalization.Controlled with record
Inner : Inner_Object_Access := null;
end record;
overriding procedure Initialize (Cache : in out Object);
overriding procedure Finalize (Cache : in out Object);
overriding procedure Adjust (Cache : in out Object);
Min_Cache_Size : constant Ada.Containers.Count_Type := 128;
end GPR2.Project.Attribute_Cache;
|
sungyeon/drake | Ada | 594 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Parameters is
pragma Pure;
-- required for task by compiler (s-parame.ads)
type Size_Type is new Integer;
Unspecified_Size : constant := Size_Type'First;
-- required for 'Storage_Size by compiler (s-parame.ads)
function Adjust_Storage_Size (Size : Size_Type) return Size_Type
renames "+"; -- no effect
-- required by compiler ??? (s-parame.ads)
-- function Default_Stack_Size return Size_Type;
-- Garbage_Collected : constant Boolean := False;
end System.Parameters;
|
stcarrez/ada-keystore | Ada | 6,457 | ads | -----------------------------------------------------------------------
-- keystore-keys -- Keystore key management
-- Copyright (C) 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Interfaces;
with Util.Encoders.AES;
with Keystore.IO;
with Keystore.Random;
with Keystore.Passwords.Keys;
with Keystore.Marshallers;
private package Keystore.Keys is
use type IO.Block_Index;
type Cryptor is limited record
Cipher : Util.Encoders.AES.Encoder;
Decipher : Util.Encoders.AES.Decoder;
Key : Secret_Key (Length => 32);
IV : Secret_Key (Length => 16);
Sign : Secret_Key (Length => 32);
end record;
-- Set the IV vector to be used for the encryption and decryption of the given block number.
procedure Set_IV (Into : in out Cryptor;
Block : in IO.Block_Number);
procedure Set_Key (Into : in out Cryptor;
From : in Cryptor);
type Wallet_Config is limited record
UUID : UUID_Type;
Keys : Key_Slot_Allocation := (others => False);
Slot : Key_Slot;
Data : Cryptor;
Dir : Cryptor;
Key : Cryptor;
Max_Counter : Interfaces.Unsigned_32 := 300_000;
Min_Counter : Interfaces.Unsigned_32 := 100_000;
Randomize : Boolean := True;
Cache_Directory : Boolean := False;
Ignore_Bad_Entry : Boolean := False;
end record;
type Key_Manager is limited private;
-- Open the key manager and read the wallet header block. Use the secret key
-- to decrypt/encrypt the wallet header block.
procedure Open (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : out Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Process : access procedure (Buffer : in out Marshallers.Marshaller;
Slot : in Key_Slot);
Stream : in out IO.Wallet_Stream'Class);
-- Create the wallet key block.
procedure Create (Manager : in out Key_Manager;
Password : in out Passwords.Provider'Class;
Slot : in Key_Slot;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Root : in Keystore.IO.Storage_Block;
Config : in out Wallet_Config;
Stream : in out IO.Wallet_Stream'Class);
-- Set a new key
procedure Set_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
New_Password : in out Keystore.Passwords.Provider'Class;
Config : in Keystore.Wallet_Config;
Mode : in Mode_Type;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class);
-- Remove the key from the key slot identified by `Slot`. The password is necessary to
-- make sure a valid password is available. The `Remove_Current` must be set to remove
-- the slot when it corresponds to the used password.
procedure Remove_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Provider'Class;
Slot : in Key_Slot;
Remove_Current : in Boolean;
Ident : in Wallet_Identifier;
Block : in Keystore.IO.Storage_Block;
Stream : in out IO.Wallet_Stream'Class);
-- Create a new masker keys for a children wallet and save the new keys in the buffer.
procedure Create_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor);
-- Extract from the buffer the master keys to open the children wallet.
procedure Load_Master_Key (Manager : in out Key_Manager;
Buffer : in out Marshallers.Marshaller;
Crypt : in Cryptor);
-- Set the master key by using the password provider.
procedure Set_Master_Key (Manager : in out Key_Manager;
Password : in out Keystore.Passwords.Keys.Key_Provider'Class);
private
-- Size of a key slot.
WH_SLOT_SIZE : constant := 512;
-- Wallet header magic.
WH_MAGIC : constant := 16#Ada00Ada#;
WH_KEY_SIZE : constant := Util.Encoders.AES.AES_256_Length;
WH_HEADER_START : constant IO.Block_Index := IO.BT_DATA_START;
WH_HEADER_LENGTH : constant := 16 + 16 + 8;
WH_KEY_LIST_START : constant IO.Block_Index := WH_HEADER_START + WH_HEADER_LENGTH + 1;
-- Key slot type is using PBKDF2-HMAC-256.
WH_KEY_PBKDF2 : constant := 16#0001#;
-- Key slot type is using PBKDF2-HMAC-256 with a GPG2 key.
WH_KEY_GPG2 : constant := 16#0002#;
type Key_Manager is limited record
Id : Wallet_Identifier;
Parent_Id : Wallet_Identifier;
Header_Block : Keystore.IO.Storage_Block;
Random : Keystore.Random.Generator;
Crypt : Cryptor;
end record;
function Key_Position (Slot : in Key_Slot) return IO.Block_Index is
(WH_KEY_LIST_START + IO.Block_Index (Slot) * WH_SLOT_SIZE - WH_SLOT_SIZE - 1);
end Keystore.Keys;
|
PhiTheta/ADLAS_Ada_System | Ada | 2,039 | adb | ------------------------------------------------------------------------------------------------------------------------
--
-- Project: Project_System
-- File name: <Template>
-- Description: This is the description of the test file
--
--
--
------------------------------------------------------------------------------------------------------------------------
-- Change History:
-- Version Date Author Description
-- ------- ---- ------ -----------
-- 1.0 22/08/17 S.Crowther Initial version
------------------------------------------------------------------------------------------------------------------------
--
-- Parameters:
-- Name Direction Description
-- ---- --------- ----
-- Input_1 Input Template array
-- Output_1 Output Template array
--
------------------------------------------------------------------------------------------------------------------------
-- Function name: Template
-- Description: Template
--
--
-- Equation Logic: If x = 1 then
-- If template_variable = 1 then
-- Test_Failed
-- else
-- Test Passed
-- end if
-- Else
-- Test Passed
-- End if
------------------------------------------------------------------------------------------------------------------------
-- Return:
-- Boolean Value
------------------------------------------------------------------------------------------------------------------------
separate(General_Checks)
procedure Check_Arming_Key_Lock
(Example_In : in Example_Phase_Type,
Example_Out : out Sub_Example_Phase_Type)
is
begin
end Check_Arming_Key_Lock;
|
reznikmm/matreshka | Ada | 25,186 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- 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 AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Destroy_Object_Actions is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Destroy_Object_Action
(AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Destroy_Object_Action
(AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Destroy_Object_Action
(Visitor,
AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access (Self),
Control);
end if;
end Visit_Element;
--------------------------
-- Get_Is_Destroy_Links --
--------------------------
overriding function Get_Is_Destroy_Links
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Destroy_Links
(Self.Element);
end Get_Is_Destroy_Links;
--------------------------
-- Set_Is_Destroy_Links --
--------------------------
overriding procedure Set_Is_Destroy_Links
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Destroy_Links
(Self.Element, To);
end Set_Is_Destroy_Links;
----------------------------------
-- Get_Is_Destroy_Owned_Objects --
----------------------------------
overriding function Get_Is_Destroy_Owned_Objects
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Destroy_Owned_Objects
(Self.Element);
end Get_Is_Destroy_Owned_Objects;
----------------------------------
-- Set_Is_Destroy_Owned_Objects --
----------------------------------
overriding procedure Set_Is_Destroy_Owned_Objects
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Destroy_Owned_Objects
(Self.Element, To);
end Set_Is_Destroy_Owned_Objects;
----------------
-- Get_Target --
----------------
overriding function Get_Target
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is
begin
return
AMF.UML.Input_Pins.UML_Input_Pin_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
(Self.Element)));
end Get_Target;
----------------
-- Set_Target --
----------------
overriding procedure Set_Target
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Target
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Target;
-----------------
-- Get_Context --
-----------------
overriding function Get_Context
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
return
AMF.UML.Classifiers.UML_Classifier_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Context
(Self.Element)));
end Get_Context;
---------------
-- Get_Input --
---------------
overriding function Get_Input
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Input_Pins.Collections.Ordered_Set_Of_UML_Input_Pin is
begin
return
AMF.UML.Input_Pins.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Input
(Self.Element)));
end Get_Input;
------------------------------
-- Get_Is_Locally_Reentrant --
------------------------------
overriding function Get_Is_Locally_Reentrant
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Locally_Reentrant
(Self.Element);
end Get_Is_Locally_Reentrant;
------------------------------
-- Set_Is_Locally_Reentrant --
------------------------------
overriding procedure Set_Is_Locally_Reentrant
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Locally_Reentrant
(Self.Element, To);
end Set_Is_Locally_Reentrant;
-----------------------------
-- Get_Local_Postcondition --
-----------------------------
overriding function Get_Local_Postcondition
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Postcondition
(Self.Element)));
end Get_Local_Postcondition;
----------------------------
-- Get_Local_Precondition --
----------------------------
overriding function Get_Local_Precondition
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint is
begin
return
AMF.UML.Constraints.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Precondition
(Self.Element)));
end Get_Local_Precondition;
----------------
-- Get_Output --
----------------
overriding function Get_Output
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin is
begin
return
AMF.UML.Output_Pins.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Output
(Self.Element)));
end Get_Output;
-----------------
-- Get_Handler --
-----------------
overriding function Get_Handler
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Exception_Handlers.Collections.Set_Of_UML_Exception_Handler is
begin
return
AMF.UML.Exception_Handlers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Handler
(Self.Element)));
end Get_Handler;
------------------
-- Get_Activity --
------------------
overriding function Get_Activity
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activities.UML_Activity_Access is
begin
return
AMF.UML.Activities.UML_Activity_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity
(Self.Element)));
end Get_Activity;
------------------
-- Set_Activity --
------------------
overriding procedure Set_Activity
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : AMF.UML.Activities.UML_Activity_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Activity;
------------------
-- Get_In_Group --
------------------
overriding function Get_In_Group
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is
begin
return
AMF.UML.Activity_Groups.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group
(Self.Element)));
end Get_In_Group;
---------------------------------
-- Get_In_Interruptible_Region --
---------------------------------
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is
begin
return
AMF.UML.Interruptible_Activity_Regions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region
(Self.Element)));
end Get_In_Interruptible_Region;
----------------------
-- Get_In_Partition --
----------------------
overriding function Get_In_Partition
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is
begin
return
AMF.UML.Activity_Partitions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition
(Self.Element)));
end Get_In_Partition;
----------------------------
-- Get_In_Structured_Node --
----------------------------
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
begin
return
AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node
(Self.Element)));
end Get_In_Structured_Node;
----------------------------
-- Set_In_Structured_Node --
----------------------------
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_In_Structured_Node;
------------------
-- Get_Incoming --
------------------
overriding function Get_Incoming
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming
(Self.Element)));
end Get_Incoming;
------------------
-- Get_Outgoing --
------------------
overriding function Get_Outgoing
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing
(Self.Element)));
end Get_Outgoing;
------------------------
-- Get_Redefined_Node --
------------------------
overriding function Get_Redefined_Node
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is
begin
return
AMF.UML.Activity_Nodes.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node
(Self.Element)));
end Get_Redefined_Node;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Destroy_Object_Action_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
-------------
-- Context --
-------------
overriding function Context
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Classifiers.UML_Classifier_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Context unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.Context";
return Context (Self);
end Context;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Destroy_Object_Action_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Destroy_Object_Action_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Destroy_Object_Action_Proxy.Namespace";
return Namespace (Self);
end Namespace;
end AMF.Internals.UML_Destroy_Object_Actions;
|
flyx/OpenGLAda | Ada | 12,186 | ads | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Toggles;
with GL.Low_Level;
private package GL.Enums is
pragma Preelaborate;
type Attribute_Mask is record
Depth_Buffer : Boolean;
Stencil_Buffer : Boolean;
Color_Buffer : Boolean;
end record;
type Blending_Factor_Destination is (Zero, One, Src_Color, One_Minus_Src_Color,
Src_Alpha, One_Minus_Src_Alpha, Dst_Alpha,
One_Minus_Dst_Alpha);
type Blending_Factor_Source is (Dst_Color, One_Minus_Dst_Color,
Src_Alpha_Saturate);
type Front_Face_Direction is (CW, CCW);
type Matrix_Mode is (Modelview, Projection, Texture, Color);
type Light_Model_Parameter is (Local_Viewer, Two_Side,
Ambient, Color_Control);
for Light_Model_Parameter use (Local_Viewer => 16#0B51#,
Two_Side => 16#0B52#,
Ambient => 16#0B53#,
Color_Control => 16#81F8#);
for Light_Model_Parameter'Size use Low_Level.Enum'Size;
subtype Light_Model_Ambient_Parameter is Light_Model_Parameter range
Ambient .. Ambient;
subtype Light_Model_CC_Parameter is Light_Model_Parameter range
Color_Control .. Color_Control;
subtype Light_Model_Toggle_Parameter is Light_Model_Parameter range
Local_Viewer .. Two_Side;
type Light_Param is (Ambient, Diffuse, Specular, Position,
Spot_Direction, Spot_Exponent, Spot_Cutoff,
Constant_Attenduation, Linear_Attenduation,
Quadratic_Attenduation);
subtype Light_Name is Toggles.Toggle range Toggles.Light0 .. Toggles.Light7;
type Shader_Param is (Shader_Type, Delete_Status, Compile_Status,
Info_Log_Length, Shader_Source_Length);
type Program_Param is
(Program_Binary_Length, Geometry_Vertices_Out, Geometry_Input_Type,
Geometry_Output_Type, Active_Uniform_Block_Max_Name_Length,
Active_Uniform_Blocks, Delete_Status, Link_Status, Validate_Status,
Info_Log_Length, Attached_Shaders, Active_Uniforms,
Active_Uniform_Max_Length, Active_Attributes, Active_Attribute_Max_Length,
Transform_Feedback_Varying_Max_Length, Transform_Feedback_Buffer_Mode,
Transform_Feedback_Varyings,
Transform_Feedback_Buffer_Start, Transform_Feedback_Buffer_Size,
Primitives_Generated, Transform_Feedback_Primitives_Written,
Rasterizer_Discard, Max_Transform_Feedback_Interleaved_Components,
Max_Transform_Feedback_Separate_Attribs, Interleaved_Attribs,
Separate_Attribs, Transform_Feedback_Buffer,
Transform_Feedback_Buffer_Binding,
Tess_Control_Output_Vertices, Tess_Gen_Mode,
Tess_Gen_Spacing, Tess_Gen_Vertex_Order, Tess_Gen_Point_Mode);
type Program_Stage_Param is (Active_Subroutines, Active_Subroutine_Uniforms,
Active_Subroutine_Uniform_Locations,
Active_Subroutine_Max_Length,
Active_Subroutine_Uniform_Max_Length);
type Clamp_Color_Param is (Clamp_Read_Color);
type Pixel_Store_Param is (Unpack_Swap_Bytes, Unpack_LSB_First,
Unpack_Row_Length, Unpack_Skip_Rows,
Unpack_Skip_Pixels, Unpack_Alignment,
Pack_Swap_Bytes, Pack_LSB_First, Pack_Row_Length,
Pack_Skip_Rows, Pack_Skip_Pixels,
Pack_Alignment, Pack_Skip_Images, Pack_Image_Height,
Unpack_Skip_Images, Unpack_Image_Height);
type Buffer_Param is (Buffer_Size, Buffer_Usage,
Buffer_Access, Buffer_Mapped);
type Buffer_Pointer_Param is (Buffer_Map_Pointer);
type Framebuffer_Param is (Default_Width, Default_Height, Default_Layers,
Default_Samples, Default_Fixed_Sample_Locations);
type Patch_Parameter_Int is (Vertices);
type Patch_Parameter_Float_Array is
(Default_Inner_Level, Default_Outer_Level);
type Point_Param is (Fade_Threshold_Size);
private
for Attribute_Mask use record
Depth_Buffer at 1 range 0 .. 0;
Stencil_Buffer at 1 range 2 .. 2;
Color_Buffer at 1 range 6 .. 6;
end record;
for Attribute_Mask'Size use Low_Level.Bitfield'Size;
for Blending_Factor_Destination use (Zero => 0,
One => 1,
Src_Color => 16#0300#,
One_Minus_Src_Color => 16#0301#,
Src_Alpha => 16#0302#,
One_Minus_Src_Alpha => 16#0303#,
Dst_Alpha => 16#0304#,
One_Minus_Dst_Alpha => 16#0305#);
for Blending_Factor_Destination'Size use Low_Level.Enum'Size;
for Blending_Factor_Source use (Dst_Color => 16#0306#,
One_Minus_Dst_Color => 16#0307#,
Src_Alpha_Saturate => 16#0308#);
for Blending_Factor_Source'Size use Low_Level.Enum'Size;
for Front_Face_Direction use (CW => 16#0900#,
CCW => 16#0901#);
for Front_Face_Direction'Size use Low_Level.Enum'Size;
for Matrix_Mode use (Modelview => 16#1700#,
Projection => 16#1701#,
Texture => 16#1702#,
Color => 16#1800#);
for Matrix_Mode'Size use Low_Level.Enum'Size;
for Light_Param use (Ambient => 16#1200#,
Diffuse => 16#1201#,
Specular => 16#1202#,
Position => 16#1203#,
Spot_Direction => 16#1204#,
Spot_Exponent => 16#1205#,
Spot_Cutoff => 16#1206#,
Constant_Attenduation => 16#1207#,
Linear_Attenduation => 16#1208#,
Quadratic_Attenduation => 16#1209#);
for Light_Param'Size use Low_Level.Enum'Size;
for Shader_Param use (Shader_Type => 16#8B4F#,
Delete_Status => 16#8B80#,
Compile_Status => 16#8B81#,
Info_Log_Length => 16#8B84#,
Shader_Source_Length => 16#8B88#);
for Shader_Param'Size use Low_Level.Enum'Size;
for Program_Param use (Program_Binary_Length => 16#8741#,
Geometry_Vertices_Out => 16#8916#,
Geometry_Input_Type => 16#8917#,
Geometry_Output_Type => 16#8918#,
Active_Uniform_Block_Max_Name_Length => 16#8A35#,
Active_Uniform_Blocks => 16#8A36#,
Delete_Status => 16#8B4F#,
Link_Status => 16#8B82#,
Validate_Status => 16#8B83#,
Info_Log_Length => 16#8B84#,
Attached_Shaders => 16#8B85#,
Active_Uniforms => 16#8B86#,
Active_Uniform_Max_Length => 16#8B87#,
Active_Attributes => 16#8B89#,
Active_Attribute_Max_Length => 16#8B8A#,
Transform_Feedback_Varying_Max_Length => 16#8C76#,
Transform_Feedback_Buffer_Mode => 16#8C7F#,
Transform_Feedback_Varyings => 16#8C83#,
Transform_Feedback_Buffer_Start => 16#8C84#,
Transform_Feedback_Buffer_Size => 16#8C85#,
Primitives_Generated => 16#8C87#,
Transform_Feedback_Primitives_Written => 16#8C88#,
Rasterizer_Discard => 16#8C89#,
Max_Transform_Feedback_Interleaved_Components => 16#8C8A#,
Max_Transform_Feedback_Separate_Attribs => 16#8C8B#,
Interleaved_Attribs => 16#8C8C#,
Separate_Attribs => 16#8C8D#,
Transform_Feedback_Buffer => 16#8C8E#,
Transform_Feedback_Buffer_Binding => 16#8C8F#,
Tess_Control_Output_Vertices => 16#8E75#,
Tess_Gen_Mode => 16#8E76#,
Tess_Gen_Spacing => 16#8E77#,
Tess_Gen_Vertex_Order => 16#8E78#,
Tess_Gen_Point_Mode => 16#8E79#);
for Program_Param'Size use Low_Level.Enum'Size;
for Program_Stage_Param use (Active_Subroutines => 16#8DE5#,
Active_Subroutine_Uniforms => 16#8DE6#,
Active_Subroutine_Uniform_Locations => 16#8E47#,
Active_Subroutine_Max_Length => 16#8E48#,
Active_Subroutine_Uniform_Max_Length => 16#8E49#);
for Program_Stage_Param'Size use Low_Level.Enum'Size;
for Clamp_Color_Param use (Clamp_Read_Color => 16#891C#);
for Clamp_Color_Param'Size use Low_Level.Enum'Size;
for Pixel_Store_Param use (Unpack_Swap_Bytes => 16#0CF0#,
Unpack_LSB_First => 16#0CF1#,
Unpack_Row_Length => 16#0CF2#,
Unpack_Skip_Rows => 16#0CF3#,
Unpack_Skip_Pixels => 16#0CF4#,
Unpack_Alignment => 16#0CF5#,
Pack_Swap_Bytes => 16#0D00#,
Pack_LSB_First => 16#0D01#,
Pack_Row_Length => 16#0D02#,
Pack_Skip_Rows => 16#0D03#,
Pack_Skip_Pixels => 16#0D04#,
Pack_Alignment => 16#0D05#,
Pack_Skip_Images => 16#806B#,
Pack_Image_Height => 16#806C#,
Unpack_Skip_Images => 16#806D#,
Unpack_Image_Height => 16#806E#);
for Pixel_Store_Param'Size use Low_Level.Enum'Size;
for Buffer_Param use (Buffer_Size => 16#8764#,
Buffer_Usage => 16#8765#,
Buffer_Access => 16#88BB#,
Buffer_Mapped => 16#88BC#);
for Buffer_Param'Size use Low_Level.Enum'Size;
for Buffer_Pointer_Param use (Buffer_Map_Pointer => 16#88BD#);
for Buffer_Pointer_Param'Size use Low_Level.Enum'Size;
for Framebuffer_Param use (Default_Width => 16#9310#,
Default_Height => 16#9311#,
Default_Layers => 16#9312#,
Default_Samples => 16#9313#,
Default_Fixed_Sample_Locations => 16#9314#);
for Framebuffer_Param'Size use Low_Level.Enum'Size;
for Patch_Parameter_Int use (Vertices => 16#8E72#);
for Patch_Parameter_Int'Size use Low_Level.Enum'Size;
for Patch_Parameter_Float_Array use (Default_Inner_Level => 16#8E73#,
Default_Outer_Level => 16#8E74#);
for Patch_Parameter_Float_Array'Size use Low_Level.Enum'Size;
for Point_Param use (Fade_Threshold_Size => 16#8128#);
for Point_Param'Size use Low_Level.Enum'Size;
end GL.Enums;
|
burratoo/Acton | Ada | 3,128 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK CORE SUPPORT PACKAGE --
-- ARM CORTEX M4F --
-- --
-- ISA.ARM.CORTEX_M4.TPIU --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with System; use System;
with Interfaces; use Interfaces;
package ISA.ARM.Cortex_M4.TPIU with Preelaborate is
-- Not complete
---------------------------
-- TPIU Memory Addresses --
---------------------------
TPIU_Base_Address : constant := 16#E004_0000#;
SSPSR_Offset_Address : constant := 16#0#;
CSPSR_Offset_Address : constant := 16#4#;
ACPR_Offset_Address : constant := 16#10#;
SPPR_Offset_Address : constant := 16#F0#;
FFCR_Offset_Address : constant := 16#304#;
-----------------------
-- Hardware Features --
-----------------------
----------------
-- TPIU Types --
----------------
type TX_Modes is (Parallel_Trace, SWO_Manchester, SWO_NRZ);
type Selected_Pin_Protocol is record
Transmit_Mode : TX_Modes;
end record with Size => 32;
type Asynchronous_Clock_Prescaler is record
SWO_Prescaler : Unsigned_16;
end record with Size => 32;
type Formatter_And_Flush_Control is record
Triggers_Inserted : Boolean;
Continuous_Formatting : Enable_Type;
end record;
------------------------------
-- Hardware Representations --
------------------------------
for TX_Modes use (Parallel_Trace => 0, SWO_Manchester => 2#01#,
SWO_NRZ => 2#10#);
for Asynchronous_Clock_Prescaler use record
SWO_Prescaler at 0 range 0 .. 15;
end record;
for Selected_Pin_Protocol use record
Transmit_Mode at 0 range 0 .. 1;
end record;
for Formatter_And_Flush_Control use record
Triggers_Inserted at 0 range 8 .. 8;
Continuous_Formatting at 0 range 1 .. 1;
end record;
--------------------
-- TPIU Registers --
--------------------
Asynchronous_Clock_Prescaler_Register : Asynchronous_Clock_Prescaler
with Address =>
System'To_Address (TPIU_Base_Address + ACPR_Offset_Address);
Selected_Pin_Protocol_Register : Selected_Pin_Protocol
with Address =>
System'To_Address (TPIU_Base_Address + SPPR_Offset_Address);
Formatter_And_Flush_Control_Register : Formatter_And_Flush_Control
with Address =>
System'To_Address (TPIU_Base_Address + FFCR_Offset_Address);
end ISA.ARM.Cortex_M4.TPIU;
|
BrickBot/Bound-T-H8-300 | Ada | 10,609 | adb | -- Bounds.Timing (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form 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.
--
-- 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.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.6 $
-- $Date: 2015/10/24 20:05:46 $
--
-- $Log: bounds-timing.adb,v $
-- Revision 1.6 2015/10/24 20:05:46 niklas
-- Moved to free licence.
--
-- Revision 1.5 2008-07-23 09:07:15 niklas
-- BT-CH-0139: Fix recursion in Programs.Execution.Paths.
--
-- Revision 1.4 2008/07/15 06:38:39 niklas
-- BT-CH-0136: "No feasible execution path" demoted to Warning.
--
-- Revision 1.3 2008/02/27 14:58:48 niklas
-- BT-CH-0116: Call-specific time and stack assertions.
--
-- Revision 1.2 2008/01/31 21:57:44 niklas
-- BT-CH-0108: Fixes to BT-CH-0098.
--
-- Revision 1.1 2007/12/17 13:54:34 niklas
-- BT-CH-0098: Assertions on stack usage and final stack height, etc.
--
with Arithmetic.Opt;
with Flow.Computation;
with Loops;
with Output;
with Processor;
with Programs.Execution.Opt;
package body Bounds.Timing is
procedure Apply_Assertions (
Asserts : in Assertions.Assertion_Set_T;
Exec_Bounds : in Programs.Execution.Bounds_Ref)
is
use type Processor.Time_T;
Time : constant Assertions.Time_Bound_T :=
Assertions.Subprogram_Time (
Subprogram => Programs.Execution.Subprogram (Exec_Bounds),
Asserts => Asserts);
-- The execution time possibly asserted for the subprogram.
begin
if Time.Max < Processor.Time_T'Last then
-- An upper time bound is asserted.
Programs.Execution.Bound_Time (
Time => Time.Max,
State => Programs.Execution.Asserted,
Within => Exec_Bounds);
end if;
end Apply_Assertions;
procedure Define_Time_State (Within : in Programs.Execution.Bounds_Ref)
--
-- Implements Evaluate_Time_State for bounds in which the time-state
-- is initially Undefined.
--
is
use type Arithmetic.Opt.Choice_T;
use Programs;
use Programs.Execution;
Arith_Choice : constant Arithmetic.Opt.Choice_T :=
Programs.Arithmetic_Analysis (Subprogram (Within));
-- Whether "arithmetic analysis" is allowed or denied.
Num_Inputs : constant Natural := Number_Of_Input_Cells (Within);
-- The number of input cells on which these execution bounds
-- may depend, if not already fully bounded.
Loose_Loops : constant Loops.Loop_List_T :=
Unbounded_Loops (Within => Within, Eternal => True);
-- Feasible but still unbounded loops, including eternal loops
-- that are not bounded by loop-repeat assertions.
Calls : constant Call_Bounds_List_T := Call_Bounds (Within);
-- Feasible calls and their current, possibly context-dependent bounds.
State : Time_State_T := Computable;
-- The final time-state. Optimistically initialized.
Call_State : Time_State_T;
-- The time-state of one of the Calls.
begin
-- Check the properties of this subprogram itself:
if not Flow.Computation.Is_Feasible (Computation (Within).all) then
-- There is no feasible execution path in the subprogram.
-- The Loose_Loops and Calls are necessarily null.
Output.Warning ("No feasible execution path.");
State := Infeasible;
elsif Enough_For_Time (Within) then
-- We are assured that enough execution-count assertions exist
-- to bound the execution paths for a Computable time-bound,
-- even if there are unbounded loops and even if the flow-graph
-- is irreducible.
if Loose_Loops'Length > 0 then
Output.Warning (
"Ignoring"
& Natural'Image (Loose_Loops'Length)
& " unbounded loop(s) because ""enough"" is asserted.");
elsif not Reducible (Subprogram (Within)) then
Output.Warning (
"Ignoring irreducibility because ""enough"" is asserted.");
end if;
elsif Loose_Loops'Length > 0 then
-- Some loops are still not bounded.
-- Perhaps we need more parameter context, or context-specific
-- assertions on relevant locally used variables.
-- The following logic will need TBA extensions if:
-- > loops can be bounded by other than arithmetic analysis, or
-- > context-specific assertions are allowed.
if Num_Inputs = 0
and Opt.Warn_Unbounded_Call
then
Output.Warning ("No inputs for context-dependent time bounds.");
end if;
if Arith_Choice /= Arithmetic.Opt.Disabled
and Num_Inputs > 0
then
-- Arithmetic analysis is allowed, and the bounds seem to
-- depend on some inputs, so we can make use of context.
State := Depends;
else
-- The execution bounds are either without input cells, which
-- means that the present analysis is as good as we can make
-- it, or arithmetic analysis is denied, which means that we
-- cannot make any use of context even if there are input cells.
State := Vague;
end if;
elsif not Reducible (Subprogram (Within)) then
Output.Error ("Irreducible flow-graph.");
State := Vague;
end if;
-- Check the time-state of the calls:
for C in Calls'Range loop
Call_State := Time_State (Calls(C).Bounds);
case Call_State is
when Undefined =>
-- Whoops, how did this happen?
Output.Fault (
Location => "Bounds.Timing.Define_Time_State",
Locus => Locus (Calls(C).Call, Within),
Text =>
"Callee Time_State is "
& Time_State_T'Image (Call_State));
when Vague =>
State := Time_State_T'Min (State, Call_State);
when Depends =>
-- The following logic will need TBA extensions if:
-- > caller input context can be transmitted to callees
-- by other means than arithmetic analysis.
if Arith_Choice /= Arithmetic.Opt.Disabled then
-- Arithmetic analysis of the caller is allowed, which
-- means that caller-context can be transmitted to
-- callees that depend on inputs.
State := Time_State_T'Min (State, Call_State);
else
-- Arithmetic analysis of the caller is denied, so
-- analysis of the caller cannot provide context for
-- bounding the calls.
State := Time_State_T'Min (State, Vague);
end if;
when Computable
| Computed
| Asserted =>
-- Good.
null;
when Infeasible
| Unbounded =>
-- The constraints on the callee make its execution
-- infeasible or unbounded. We mark the caller as Vague,
-- not infeasible or unbounded, to help the display of
-- "unbounded" parts.
State := Time_State_T'Min (State, Vague);
when Failed =>
-- This obviously prevents us from computing a time-bound
-- on this caller subprogram. But the failure was already
-- reported, and another error will be reported when we
-- try to compute the time-bounde for this caller. So we
-- can ignore it here.
null;
end case;
end loop;
Output.Note (
"Time_State for bounds #"
& Bounds_Index_T'Image (Index (Within))
& " defined as "
& Time_State_T'Image (State));
Set_Time_State (
To => State,
Within => Within);
end Define_Time_State;
procedure Evaluate_Time_State (Within : in Programs.Execution.Bounds_Ref)
is
use Programs;
use Programs.Execution;
begin
case Time_State (Within) is
when Undefined =>
-- The subprogram is not a stub and does not have an asserted
-- execution time (in this context) and does not inherit a
-- computed execution time (in this context).
Define_Time_State (Within);
when Vague =>
-- The subprogram is a stub but does not have an asserted
-- execution time (in this context).
-- Nothing we can do.
null;
when Asserted =>
-- Nothing to do.
null;
when others =>
-- The execution bounds were Adopted_To some _Context and
-- inherited the Time_State of the original bounds for a
-- shallower context.
Output.Note (
"Adopted Time_State left as "
& Time_State_T'Image (Time_State (Within)));
end case;
end Evaluate_Time_State;
end Bounds.Timing;
|
Rodeo-McCabe/orka | Ada | 14,702 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2012 Felix Krause <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with System;
with GL.API;
with GL.Enums.Getter;
with GL.Pixels;
package body GL.Objects.Buffers is
function Minimum_Alignment return Types.Size is
Ret : Types.Size := 64;
begin
API.Get_Size.Ref (Enums.Getter.Min_Map_Buffer_Alignment, Ret);
return Ret;
end Minimum_Alignment;
use type Enums.Buffer_Kind;
type Format_Data is record
Internal_Format : GL.Pixels.Internal_Format_Buffer_Texture;
Format : GL.Pixels.Format;
Data_Type : GL.Pixels.Data_Type;
end record;
function Get_Format_Data (Kind : Numeric_Type; Length : Natural) return Format_Data is
use GL.Pixels;
type Format_Array is array (1 .. 4) of Format;
Float_Formats : constant Format_Array := (Red, RG, RGB, RGBA);
Integer_Formats : constant Format_Array := (Red_Integer, RG_Integer, RGB_Integer, RGBA_Integer);
type Internal_Format_Array is array (1 .. 4) of Internal_Format_Buffer_Texture;
Internal_Formats : Internal_Format_Array;
begin
return Result : Format_Data do
-- For certain data types, OpenGL does not provide a sized
-- internal format [for buffer textures] that has three components
case Kind is
when Byte_Type =>
Result.Data_Type := Pixels.Byte;
Internal_Formats := (R8I, RG8I, R8I, RGBA8I);
-- Third position invalid
when UByte_Type =>
Result.Data_Type := Pixels.Unsigned_Byte;
Internal_Formats := (R8UI, RG8UI, R8UI, RGBA8UI);
-- Third position invalid
when Short_Type =>
Result.Data_Type := Pixels.Short;
Internal_Formats := (R16I, RG16I, R16I, RGBA16I);
-- Third position invalid
when UShort_Type =>
Result.Data_Type := Pixels.Unsigned_Short;
Internal_Formats := (R16UI, RG16UI, R16UI, RGBA16UI);
-- Third position invalid
when Int_Type =>
Result.Data_Type := Pixels.Int;
Internal_Formats := (R32I, RG32I, RGB32I, RGBA32I);
when UInt_Type =>
Result.Data_Type := Pixels.Unsigned_Int;
Internal_Formats := (R32UI, RG32UI, RGB32UI, RGBA32UI);
when Half_Type =>
Result.Data_Type := Pixels.Half_Float;
Internal_Formats := (R16F, RG16F, R16F, RGBA16F);
-- Third position invalid
when Single_Type =>
Result.Data_Type := Pixels.Float;
Internal_Formats := (R32F, RG32F, RGB32F, RGBA32F);
when Double_Type =>
raise Constraint_Error;
end case;
Result.Internal_Format := Internal_Formats (Length);
case Kind is
when Byte_Type .. UInt_Type =>
Result.Format := Integer_Formats (Length);
when Half_Type | Single_Type =>
Result.Format := Float_Formats (Length);
when Double_Type =>
raise Constraint_Error;
end case;
end return;
end Get_Format_Data;
function Kind (Target : Buffer_Target) return Indexed_Buffer_Target is
(case Target.Kind is
when Enums.Shader_Storage_Buffer => Shader_Storage,
when Enums.Uniform_Buffer => Uniform,
when Enums.Atomic_Counter_Buffer => Atomic_Counter,
when others => raise Constraint_Error);
procedure Bind (Target : Buffer_Target; Object : Buffer'Class) is
begin
API.Bind_Buffer.Ref (Target.Kind, Object.Reference.GL_Id);
end Bind;
procedure Bind_Base (Target : Buffer_Target; Object : Buffer'Class; Index : Natural) is
begin
API.Bind_Buffer_Base.Ref (Target.Kind, UInt (Index), Object.Reference.GL_Id);
end Bind_Base;
procedure Allocate_Storage
(Object : in out Buffer;
Length : Long;
Kind : Numeric_Type;
Flags : Storage_Bits)
is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Source => Storage_Bits, Target => Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield :=
Convert (Flags) and 2#0000001111000011#;
Number_Of_Bytes : Long;
begin
case Kind is
when Half_Type =>
Number_Of_Bytes := Length * Half'Size / System.Storage_Unit;
when Single_Type =>
Number_Of_Bytes := Length * Single'Size / System.Storage_Unit;
when Double_Type =>
Number_Of_Bytes := Length * Double'Size / System.Storage_Unit;
when UInt_Type =>
Number_Of_Bytes := Length * UInt'Size / System.Storage_Unit;
when UByte_Type =>
Number_Of_Bytes := Length * UByte'Size / System.Storage_Unit;
when UShort_Type =>
Number_Of_Bytes := Length * UShort'Size / System.Storage_Unit;
when Int_Type =>
Number_Of_Bytes := Length * Int'Size / System.Storage_Unit;
when Byte_Type =>
Number_Of_Bytes := Length * Byte'Size / System.Storage_Unit;
when Short_Type =>
Number_Of_Bytes := Length * Short'Size / System.Storage_Unit;
end case;
API.Named_Buffer_Storage.Ref
(Object.Reference.GL_Id, Low_Level.SizeIPtr (Number_Of_Bytes),
System.Null_Address, Raw_Bits);
Object.Allocated := True;
end Allocate_Storage;
function Allocated (Object : Buffer) return Boolean is (Object.Allocated);
function Mapped (Object : Buffer) return Boolean is (Object.Mapped);
overriding procedure Initialize_Id (Object : in out Buffer) is
New_Id : UInt := 0;
begin
API.Create_Buffers.Ref (1, New_Id);
Object.Reference.GL_Id := New_Id;
end Initialize_Id;
overriding procedure Delete_Id (Object : in out Buffer) is
Arr : constant Low_Level.UInt_Array := (1 => Object.Reference.GL_Id);
begin
API.Delete_Buffers.Ref (1, Arr);
Object.Reference.GL_Id := 0;
end Delete_Id;
procedure Unmap (Object : in out Buffer) is
begin
API.Unmap_Named_Buffer.Ref (Object.Reference.GL_Id);
Object.Mapped := False;
end Unmap;
procedure Invalidate_Data (Object : in out Buffer) is
begin
API.Invalidate_Buffer_Data.Ref (Object.Reference.GL_Id);
end Invalidate_Data;
package body Buffer_Pointers is
package Map_Named_Buffer_Range is new API.Loader.Function_With_4_Params
("glMapNamedBufferRange", UInt, Low_Level.IntPtr, Low_Level.SizeIPtr,
Low_Level.Bitfield, Pointers.Pointer);
package Get_Named_Buffer_Sub_Data is new API.Loader.Getter_With_4_Params
("glGetNamedBufferSubData", UInt, Low_Level.IntPtr,
Low_Level.SizeIPtr, Pointers.Element_Array);
Element_In_Bytes : constant Int := Pointers.Element'Size / System.Storage_Unit;
procedure Bind_Range
(Target : Buffer_Target;
Object : Buffer'Class;
Index : Natural;
Offset, Length : Types.Size)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Length * Element_In_Bytes;
begin
API.Bind_Buffer_Range.Ref
(Target.Kind, UInt (Index), Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes));
end Bind_Range;
procedure Allocate_And_Load_From_Data
(Object : in out Buffer;
Data : Pointers.Element_Array;
Flags : Storage_Bits)
is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Source => Storage_Bits, Target => Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield :=
Convert (Flags) and 2#0000001111000011#;
Number_Of_Bytes : constant Int := Data'Length * Element_In_Bytes;
begin
API.Named_Buffer_Storage.Ref
(Object.Reference.GL_Id, Low_Level.SizeIPtr (Number_Of_Bytes),
Data (Data'First)'Address, Raw_Bits);
Object.Allocated := True;
end Allocate_And_Load_From_Data;
procedure Map_Range
(Object : in out Buffer;
Flags : Access_Bits;
Offset, Length : Types.Size;
Pointer : out Pointers.Pointer)
is
use type Low_Level.Bitfield;
use type Pointers.Pointer;
function Convert is new Ada.Unchecked_Conversion
(Source => Access_Bits, Target => Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield :=
Convert (Flags) and 2#0000000011111111#;
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Length * Element_In_Bytes;
begin
Pointer := Map_Named_Buffer_Range.Ref
(Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes),
Raw_Bits);
Object.Mapped := Pointer /= null;
end Map_Range;
function Get_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset, Length : Types.Size) return Pointers.Element_Array
is
package IC renames Interfaces.C;
use type Pointers.Pointer;
begin
return Pointers.Value (Pointer + IC.ptrdiff_t (Offset), IC.ptrdiff_t (Length));
end Get_Mapped_Data;
procedure Set_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset : Types.Size;
Data : Pointers.Element_Array)
is
package IC renames Interfaces.C;
use type Pointers.Pointer;
subtype Data_Array is Pointers.Element_Array (Data'Range);
type Data_Access is access Data_Array;
function Convert is new Ada.Unchecked_Conversion
(Source => Pointers.Pointer, Target => Data_Access);
begin
Convert (Pointer + IC.ptrdiff_t (Offset)).all := Data;
end Set_Mapped_Data;
procedure Set_Mapped_Data
(Pointer : not null Pointers.Pointer;
Offset : Types.Size;
Value : Pointers.Element)
is
package IC renames Interfaces.C;
use type Pointers.Pointer;
Offset_Pointer : constant Pointers.Pointer := Pointer + IC.ptrdiff_t (Offset);
begin
Offset_Pointer.all := Value;
end Set_Mapped_Data;
procedure Flush_Buffer_Range (Object : in out Buffer;
Offset, Length : Types.Size)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Length * Element_In_Bytes;
begin
API.Flush_Mapped_Named_Buffer_Range.Ref
(Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes));
end Flush_Buffer_Range;
procedure Clear_Sub_Data
(Object : Buffer;
Kind : Numeric_Type;
Offset, Length : Types.Size;
Data : in out Pointers.Element_Array)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Length_In_Bytes : constant Int := Length * Element_In_Bytes;
Format_Info : constant Format_Data := Get_Format_Data (Kind, Natural'Max (1, Data'Length));
begin
API.Clear_Named_Buffer_Sub_Data.Ref
(Object.Reference.GL_Id, Format_Info.Internal_Format,
Low_Level.IntPtr (Offset_In_Bytes), Low_Level.SizeIPtr (Length_In_Bytes),
Format_Info.Format, Format_Info.Data_Type,
(if Data'Length = 0 then System.Null_Address else Data (Data'First)'Address));
end Clear_Sub_Data;
procedure Copy_Sub_Data
(Object, Target_Object : Buffer;
Read_Offset, Write_Offset, Length : Types.Size)
is
Read_Offset_In_Bytes : constant Int := Read_Offset * Element_In_Bytes;
Write_Offset_In_Bytes : constant Int := Write_Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Length * Element_In_Bytes;
begin
API.Copy_Named_Buffer_Sub_Data.Ref
(Object.Reference.GL_Id, Target_Object.Reference.GL_Id,
Low_Level.IntPtr (Read_Offset_In_Bytes),
Low_Level.IntPtr (Write_Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes));
end Copy_Sub_Data;
procedure Set_Sub_Data (Object : Buffer;
Offset : Types.Size;
Data : Pointers.Element_Array)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Data'Length * Element_In_Bytes;
begin
API.Named_Buffer_Sub_Data.Ref
(Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes), Low_Level.SizeIPtr (Number_Of_Bytes),
Data (Data'First)'Address);
end Set_Sub_Data;
procedure Get_Sub_Data (Object : Buffer;
Offset : Types.Size;
Data : out Pointers.Element_Array)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Data'Length * Element_In_Bytes;
begin
Get_Named_Buffer_Sub_Data.Ref
(Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes),
Data);
end Get_Sub_Data;
procedure Invalidate_Sub_Data (Object : Buffer;
Offset, Length : Types.Size)
is
Offset_In_Bytes : constant Int := Offset * Element_In_Bytes;
Number_Of_Bytes : constant Int := Length * Element_In_Bytes;
begin
API.Invalidate_Buffer_Sub_Data.Ref
(Object.Reference.GL_Id,
Low_Level.IntPtr (Offset_In_Bytes),
Low_Level.SizeIPtr (Number_Of_Bytes));
end Invalidate_Sub_Data;
end Buffer_Pointers;
end GL.Objects.Buffers;
|
charlie5/lace | Ada | 25,538 | adb | with
lace.Environ.OS_Commands,
lace.Text.utility,
posix.file_Status,
posix.Calendar,
shell.Directories,
lace.Text.all_Tokens,
ada.Strings.fixed,
ada.Characters.handling,
ada.Directories,
ada.Direct_IO,
ada.Tags,
ada.Text_IO,
ada.IO_Exceptions;
package body lace.Environ.Paths
is
-----------
--- General
--
function "+" (Source : in unbounded_String) return String
renames to_String;
function expand_GLOB (GLOB : in String) return String
is
use ada.Text_IO;
FileName : constant File := +"/tmp/lace_environ_temporary_shell.sh";
File : File_Type;
begin
create (File, out_File, +Filename);
put_Line (File, "echo " & GLOB);
close (File);
change_Mode (Path (Filename), to => "a+rwx");
declare
use lace.Environ.OS_Commands;
Output : constant String := run_OS ("bash " & (+Filename));
begin
rid_File (Filename);
return Output;
end;
end expand_GLOB;
---------
--- Paths
--
function to_String (Self : in Path'Class) return String
is
begin
return to_String (Self.Name);
end to_String;
procedure check (Self : in Path'Class)
is
use ada.Tags,
ada.Strings.fixed,
ada.Characters.handling;
Tag_full_Name : constant String := to_Lower (ada.Tags.expanded_Name (Self'Tag));
Tag_Name : constant String := (if Self'Tag = Folder'Tag then Tail (Tag_full_Name, 6)
else Tail (Tag_full_Name, 4));
begin
if Self.Name = ""
then
raise Error with "No " & Tag_Name & " specified.";
end if;
if not Exists (Self)
then
raise Error with Tag_Name & " '" & (+Self) & "' does not exist.";
end if;
end check;
procedure link (Self, To : in Path)
is
begin
check (Self);
declare
use lace.Environ.OS_Commands;
Output : constant String := run_OS ( "ln -s "
& (+Self)
& " "
& (+To));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
end link;
procedure change_Mode (Self : in Path;
To : in String)
is
begin
check (Self);
declare
use lace.Environ.OS_Commands;
Output : constant String := run_OS ("chmod -R " & To & " " & (+Self));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
end change_Mode;
procedure change_Owner (Self : in Path;
To : in String)
is
begin
check (Self);
declare
use lace.Environ.OS_Commands;
Output : constant String := run_OS ("chown -R " & To & " " & (+Self));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
end change_Owner;
function Exists (Self : in Path) return Boolean
is
begin
if +Self = ""
then
raise Error with "No path specified.";
end if;
return ada.Directories.exists (+Self);
end Exists;
function is_Folder (Self : in Path) return Boolean
is
use ada.Directories;
begin
check (Self);
return Kind (+Self) = Directory;
end is_Folder;
function is_File (Self : in Path) return Boolean
is
use ada.Directories;
begin
check (Self);
return Kind (+Self) = Ordinary_File;
end is_File;
function is_Special (Self : in Path) return Boolean
is
use ada.Directories;
begin
check (Self);
return Kind (+Self) = Special_File;
end is_Special;
function is_Absolute (Self : in Path) return Boolean
is
begin
if Length (Self.Name) = 0
then
return False;
end if;
return Element (Self.Name, 1) = '/';
end is_Absolute;
function is_Relative (Self : in Path) return Boolean
is
begin
return not is_Absolute (Self);
end is_Relative;
function modify_Time (Self : in Path) return ada.Calendar.Time
is
begin
check (Self);
declare
use Posix,
posix.Calendar,
posix.File_Status;
the_Status : constant Status := get_File_Status (Pathname => to_posix_String (+Self));
Time : constant POSIX_Time := last_modification_Time_of (the_Status);
begin
return to_Time (Time);
end;
end modify_Time;
function Parent (Self : in Path'Class) return Folder
is
begin
declare
use ada.Strings;
Index : constant Natural := fixed.Index (+Self, "/", going => Backward);
begin
if Index = 0
then
return no_Folder;
elsif Index = 1
then
return +"/";
end if;
declare
Result : Folder;
begin
Result.Name := Head (Self.Name,
Count => Index - 1);
return Result;
end;
end;
end Parent;
function Name (Self : in Path) return String
is
begin
return +Self.Name;
end Name;
function Simple (Self : in Path) return String
is
begin
check (Self);
declare
use ada.Strings;
i : constant Natural := Index (Self.Name, "/", going => Backward);
Last : constant Natural := Length (Self.Name);
begin
if i = 0
then
return +Self;
else
return Slice (Self.Name, Low => i + 1,
High => Last);
end if;
end;
end Simple;
-----------
--- Folders
--
function to_Folder (Name : in String) return Folder
is
begin
return (Name => to_unbounded_String (Name));
end to_Folder;
function "+" (Left : in Folder; Right : in Folder) return Folder
is
Result : Folder;
R_Folder : constant String := (if Right.is_Absolute then Right.Simple
else +Right);
begin
Result.Name := Left.Name;
append (Result.Name, "/" & R_Folder);
return Result;
end "+";
function "+" (Left : in Folder'Class;
Right : in File 'Class) return File
is
Result : File;
R_File : constant String := (if Right.is_Absolute then Right.Simple
else +Right);
begin
Result.Name := Left.Name;
append (Result.Name, "/" & R_File);
return Result;
end "+";
function current_Folder return Folder
is
begin
return +ada.Directories.current_Directory;
end current_Folder;
protected folder_Lock
is
entry change (To : in Folder);
procedure clear;
private
Locked : Boolean := False;
end folder_Lock;
protected body folder_Lock
is
entry change (To : in Folder)
when not Locked
is
begin
check (To);
ada.Directories.set_Directory (+To);
Locked := True;
end change;
procedure clear
is
begin
Locked := False;
end clear;
end folder_Lock;
procedure go_to_Folder (Self : in Folder;
lock : in Boolean := False)
is
begin
check (Self);
if lock
then
folder_Lock.change (Self);
else
ada.Directories.set_Directory (+Self);
end if;
end go_to_Folder;
procedure unlock_Folder
is
begin
folder_Lock.clear;
end unlock_Folder;
function contents_Count (Self : in Folder;
recurse : in Boolean := False) return Natural
is
use shell.Directories,
ada.Directories;
Count : Natural := 0;
begin
check (Self);
for Each of To_Directory (+Self, Recurse)
loop
declare
Name : constant String := Simple_Name (Each);
begin
if not ( Name = "."
or Name = "..")
then
Count := Count + 1;
end if;
end;
end loop;
return Count;
end contents_Count;
function is_Empty (Self : in Folder) return Boolean
is
begin
check (Self);
return contents_Count (Self) = 0;
end is_Empty;
procedure rid_Folder (Self : in Folder)
is
begin
check (Self);
ada.Directories.delete_Tree (+Self);
exception
when ada.IO_Exceptions.name_Error =>
null;
end rid_Folder;
procedure copy_Folder (Self : in Folder; To : in Folder)
is
use lace.Environ.OS_Commands;
begin
check (Self);
check (To);
run_OS ("cp -fr " & (+Self) & " " & (+To));
end copy_Folder;
procedure move_Folder (Self : in Folder; To : in Folder)
is
use lace.Environ.OS_Commands;
begin
check (Self);
check (To);
run_OS ("mv " & (+Self) & " " & (+To));
end move_Folder;
procedure rename_Folder (Self : in Folder; To : in Folder)
is
begin
check (Self);
ada.Directories.rename (+Self, +To);
end rename_Folder;
procedure ensure_Folder (Self : in Folder)
is
begin
if Self.Name = ""
then
raise Error with "No folder specified.";
end if;
ada.Directories.create_Path (+Self);
end ensure_Folder;
function Relative (Self : in Folder; To : in Folder'Class) return Folder
is
use lace.Text,
lace.Text.utility;
Filename : constant lace.Text.item := to_Text (+Self);
relative_Folder : constant lace.Text.item := replace (Filename, pattern => +To & "/",
by => "");
begin
return to_Folder (+relative_Folder);
end Relative;
-------------------
--- Folder Contexts
--
procedure push_Folder (Context : in out folder_Context;
goto_Folder : in Folder'Class)
is
begin
check (goto_Folder);
Context.folder_Stack.append (current_Folder);
go_to_Folder (goto_Folder);
end push_Folder;
procedure pop_Folder (Context : in out folder_Context)
is
begin
if Context.folder_Stack.is_Empty
then
raise Error with "'pop_Folder': No prior folder exists.";
end if;
declare
prior_Folder : constant Folder := Context.folder_Stack.last_Element;
begin
Context.folder_Stack.delete_Last;
go_to_Folder (prior_Folder);
end;
end pop_Folder;
procedure pop_All (Context : in out folder_Context)
is
begin
if Context.folder_Stack.is_Empty
then
raise Error with "'pop_All': No initial folder exists.";
end if;
go_to_Folder (Context.folder_Stack.Element (1));
Context.folder_Stack.clear;
end pop_All;
---------
--- Files
--
function to_File (Name : in String) return File
is
Self : File;
begin
set_unbounded_String (Self.Name, Name);
return Self;
end to_File;
function "+" (Left : in File'Class;
Right : in File_Extension) return File
is
begin
return to_File (+Left & "." & String (Right));
end "+";
function Extension (Self : in File) return File_Extension
is
use ada.Directories;
begin
return File_Extension (Extension (+Self.Name));
end Extension;
procedure save (Self : in File; Text : in String;
Binary : in Boolean := False)
is
begin
if Binary
then
declare
type binary_String is new String (Text'Range);
package Binary_IO is new ada.Direct_IO (binary_String);
use Binary_IO;
File : File_type;
begin
create (File, out_File, +Self);
write (File, binary_String (Text));
close (File);
end;
else
declare
use ada.Text_IO;
File : File_type;
begin
create (File, out_File, +Self);
put (File, Text);
close (File);
end;
end if;
end save;
procedure save (Self : in File; Data : in environ.Data)
is
begin
check (Self);
declare
type Element_Array is new environ.Data (Data'Range);
package Binary_IO is new ada.Direct_IO (Element_Array);
use Binary_IO;
File : File_type;
begin
create (File, out_File, +Self);
write (File, Element_Array (Data));
close (File);
end;
end save;
function load (Self : in File) return String
is
use type ada.Directories.File_Size;
Size : ada.Directories.File_Size;
begin
check (Self);
Size := ada.Directories.Size (+Self);
if Size = 0
then
return "";
end if;
declare
type my_String is new String (1 .. Natural (Size));
package String_IO is new ada.Direct_IO (my_String);
use String_IO;
File : File_type;
Result : my_String;
begin
open (File, in_File, +Self);
read (File, Result);
close (File);
return String (Result);
end;
exception
when ada.IO_Exceptions.name_Error =>
raise Error with "Cannot load missing file: '" & (+Self) & "'";
end load;
function load (Self : in File) return Data
is
begin
check (Self);
declare
use ada.Streams;
Size : constant ada.Directories.File_Size := ada.Directories.Size (+Self);
type Element_Array is new Data (0 .. Stream_Element_Offset (Size) - 1);
package Binary_IO is new ada.Direct_IO (Element_Array);
use Binary_IO;
File : Binary_IO.File_type;
Result : Element_Array;
begin
open (File, out_File, +Self);
read (File, Result);
close (File);
return Data (Result);
end;
exception
when ada.IO_Exceptions.name_Error =>
raise Error with "Cannot load missing file: '" & (+Self) & "'";
end load;
procedure copy_File (Self : in File; To : in File)
is
begin
check (Self);
check (To);
ada.Directories.copy_File (+Self, +To);
end copy_File;
procedure copy_Files (Named : in String; To : in Folder)
is
use lace.Text,
lace.Text.all_Tokens,
ada.Strings.fixed;
all_Files : constant String := (if Index (Named, "*") /= 0 then expand_GLOB (Named)
else Named);
file_List : constant Text.items_1k := Tokens (to_Text (all_Files));
begin
check (To);
for Each of file_List
loop
declare
use ada.Directories;
Name : constant String := +Each;
begin
if Kind (Name) = Directory
then
copy_Folder (+Name,
To);
else
copy_File (to_File (Name),
To + to_File (simple_Name (Name)));
end if;
end;
end loop;
end copy_Files;
procedure move_File (Self : in File; To : in File)
is
begin
check (Self);
check (To);
-- 'Ada.Directories.Rename' fails when the file is moved across a device.
-- For instance Rename ("/tmp/a_file", "/home/user/a_file");
ada.Directories.copy_File (+Self, +To);
rid_File (Self);
end move_File;
procedure move_Files (Named : in String; To : in Folder)
is
begin
check (To);
declare
use lace.Text,
lace.Text.all_Tokens,
ada.Strings.fixed;
all_Files : constant String := (if Index (Named, "*") /= 0 then Expand_GLOB (Named)
else Named);
file_List : constant Text.items_1k := Tokens (to_Text (all_Files));
begin
for Each of file_List
loop
if +Each /= +To -- Don't move a directory to a subdirectory of itself.
then
declare
use ada.Directories;
Name : constant String := +Each;
begin
if Kind (Name) = Directory
then
move_Folder (+Name,
To);
else
move_File (to_File (Name),
To + to_File (simple_Name (Name)));
end if;
end;
end if;
end loop;
end;
end move_Files;
procedure append (Self : in File; Text : in String)
is
begin
check (Self);
declare
use ada.Text_IO;
Target : File_type;
begin
open (Target, append_File, Name => +Self);
put (Target, Text);
close (Target);
end;
end append;
procedure append_File (Self : in File; To : in File)
is
begin
check (Self);
check (To);
declare
use ada.Text_IO;
Text : constant String := load (Self);
Target : File_type;
begin
open (Target, append_File, Name => +To);
put (Target, Text);
close (Target);
end;
end append_File;
procedure rid_File (Self : in File)
is
begin
check (Self);
ada.Directories.delete_File (+Self);
end rid_File;
procedure rid_Files (Named : in String)
is
use lace.Text,
lace.Text.all_Tokens,
ada.Strings.fixed;
all_Files : constant String := (if Index (Named, "*") /= 0 then Expand_GLOB (Named)
else Named);
file_List : constant Text.items_1k := Tokens (to_Text (all_Files));
begin
for Each of file_List
loop
check (to_File (+Each));
rid_File (to_File (+Each));
end loop;
end rid_Files;
procedure touch (Self : in File)
is
use lace.Environ.OS_Commands;
Output : constant String := run_OS ("touch " & (+Self));
begin
if Output /= ""
then
raise Error with Output;
end if;
end touch;
function Relative (Self : in File; To : in Folder'Class) return File
is
use lace.Text,
lace.Text.utility;
Filename : constant lace.Text.item := to_Text (+Self);
relative_File : constant lace.Text.item := replace (Filename, Pattern => +To & "/",
By => "");
begin
return to_File (+relative_File);
end Relative;
function rid_Extension (Self : in File) return File
is
use ada.Directories;
Parent : constant Folder := Self.Parent;
Name : constant String := base_Name (+Self.Name);
begin
return Parent + to_File (Name);
end rid_Extension;
---------------
--- Compression
--
procedure compress (the_Path : in Path'Class;
the_Format : in compress_Format := Tar_Xz;
the_Level : in compress_Level := 6)
is
use lace.Environ.OS_Commands;
function level_Flag return String
is
use ada.Strings,
ada.Strings.fixed;
begin
return " -"
& Trim (compress_Level'Image (the_Level),
Left)
& " ";
end level_Flag;
begin
check (the_Path);
case the_Format
is
when Tar |Tar_Bz2 | Tar_Gz | Tar_Xz =>
declare
Options : constant String := (case the_Format
is
when Tar => "-cf",
when Tar_Bz2 => "-cjf",
when Tar_Gz => "-czf",
when Tar_Xz => "-cJf",
when others => raise program_Error);
Output : constant String := run_OS ( "tar " & Options
& " " & (+the_Path) & format_Suffix (the_Format)
& " " & (+the_Path));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Gz =>
declare
Output : constant String := run_OS ( "gzip --force --keep --rsyncable"
& level_Flag
& " " & (+the_Path));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Bz2 =>
declare
Output : constant String := run_OS ( "bzip2 --force --keep"
& level_Flag
& " " & (+the_Path));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Xz =>
declare
Output : constant String := run_OS ("xz --force --keep --threads=0 " & (+the_Path));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
end case;
end compress;
procedure decompress (Name : in File)
is
use lace.Environ.OS_Commands;
begin
check (Name);
declare
use ada.Strings.fixed;
the_Format : constant compress_Format := (if Tail (+Name, 4) = ".tar" then Tar
elsif Tail (+Name, 8) = ".tar.bz2" then Tar_Bz2
elsif Tail (+Name, 7) = ".tar.gz"
or Tail (+Name, 4) = ".tgz" then Tar_Gz
elsif Tail (+Name, 7) = ".tar.xz" then Tar_Xz
elsif Tail (+Name, 3) = ".gz" then Gz
elsif Tail (+Name, 4) = ".bz2" then Bz2
elsif Tail (+Name, 3) = ".xz" then Xz
else raise Error with "Unknown decompress format: " & (+Name));
begin
case the_Format
is
when Tar |Tar_Bz2 | Tar_Gz | Tar_Xz =>
declare
Options : aliased constant String := (case the_Format
is
when Tar => "-xf",
when Tar_Bz2 => "-xjf",
when Tar_Gz => "-xzf",
when Tar_Xz => "-xJf",
when others => raise program_Error);
Output : constant String := run_OS ("tar " & Options & " " & (+Name));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Gz =>
declare
Output : constant String := run_OS ("gunzip --force --keep " & (+Name));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Bz2 =>
declare
Output : constant String := run_OS ("bunzip2 --force --keep " & (+Name));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
when Xz =>
declare
Output : constant String := run_OS ("xz --decompress --force --keep " & (+Name));
begin
if Output /= ""
then
raise Error with Output;
end if;
end;
end case;
end;
end decompress;
function format_Suffix (Format : compress_Format) return String
is
begin
case Format
is
when Tar => return ".tar";
when Tar_Bz2 => return ".tar.bz2";
when Tar_Gz => return ".tar.gz";
when Tar_Xz => return ".tar.xz";
when Bz2 => return ".bz2";
when Gz => return ".gz";
when Xz => return ".xz";
end case;
end format_Suffix;
end lace.Environ.Paths;
|
sebsgit/textproc | Ada | 911 | ads | with PixelArray; use PixelArray;
with Ada.Containers; use Ada.Containers;
package ImageThresholds is
type MinMaxIntensity is record
min, max: PixelArray.Pixel;
end record;
function isBinary(image: PixelArray.ImagePlane) return Boolean;
procedure simple(image: in out PixelArray.ImagePlane; threshold: PixelArray.Pixel)
with
Pre => (image.width > 0 and image.height > 0),
Post => (isBinary(image));
function simple(image: PixelArray.ImagePlane; threshold: PixelArray.Pixel) return PixelArray.ImagePlane
with Post => (isBinary(simple'Result));
function circleMinMax(image: PixelArray.ImagePlane; x, y: Natural; radius: Positive) return MinMaxIntensity;
function bernsenAdaptative(image: PixelArray.ImagePlane; radius: Positive; c_min: PixelArray.Pixel) return PixelArray.ImagePlane
with Post => (isBinary(bernsenAdaptative'Result));
end ImageThresholds;
|
AdaCore/Ada_Drivers_Library | Ada | 9,289 | ads | -- This spec has been automatically generated from STM32F7x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.SYSCFG is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype MEMRM_MEM_MODE_Field is HAL.UInt3;
subtype MEMRM_SWP_FMC_Field is HAL.UInt2;
-- memory remap register
type MEMRM_Register is record
-- Memory mapping selection
MEM_MODE : MEMRM_MEM_MODE_Field := 16#0#;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Flash bank mode selection
FB_MODE : Boolean := False;
-- unspecified
Reserved_9_9 : HAL.Bit := 16#0#;
-- FMC memory mapping swap
SWP_FMC : MEMRM_SWP_FMC_Field := 16#0#;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MEMRM_Register use record
MEM_MODE at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
FB_MODE at 0 range 8 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
SWP_FMC at 0 range 10 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- peripheral mode configuration register
type PMC_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- ADC1DC2
ADC1DC2 : Boolean := False;
-- ADC2DC2
ADC2DC2 : Boolean := False;
-- ADC3DC2
ADC3DC2 : Boolean := False;
-- unspecified
Reserved_19_22 : HAL.UInt4 := 16#0#;
-- Ethernet PHY interface selection
MII_RMII_SEL : Boolean := False;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_Register use record
Reserved_0_15 at 0 range 0 .. 15;
ADC1DC2 at 0 range 16 .. 16;
ADC2DC2 at 0 range 17 .. 17;
ADC3DC2 at 0 range 18 .. 18;
Reserved_19_22 at 0 range 19 .. 22;
MII_RMII_SEL at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- EXTICR1_EXTI array element
subtype EXTICR1_EXTI_Element is HAL.UInt4;
-- EXTICR1_EXTI array
type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR1_EXTI
type EXTICR1_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : HAL.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR1_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR1_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 1
type EXTICR1_Register is record
-- EXTI x configuration (x = 0 to 3)
EXTI : EXTICR1_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR1_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR2_EXTI array element
subtype EXTICR2_EXTI_Element is HAL.UInt4;
-- EXTICR2_EXTI array
type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR2_EXTI
type EXTICR2_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : HAL.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR2_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR2_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 2
type EXTICR2_Register is record
-- EXTI x configuration (x = 4 to 7)
EXTI : EXTICR2_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR2_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR3_EXTI array element
subtype EXTICR3_EXTI_Element is HAL.UInt4;
-- EXTICR3_EXTI array
type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR3_EXTI
type EXTICR3_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : HAL.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR3_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR3_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 3
type EXTICR3_Register is record
-- EXTI x configuration (x = 8 to 11)
EXTI : EXTICR3_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR3_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR4_EXTI array element
subtype EXTICR4_EXTI_Element is HAL.UInt4;
-- EXTICR4_EXTI array
type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR4_EXTI
type EXTICR4_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : HAL.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR4_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR4_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 4
type EXTICR4_Register is record
-- EXTI x configuration (x = 12 to 15)
EXTI : EXTICR4_EXTI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EXTICR4_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Compensation cell control register
type CMPCR_Register is record
-- Read-only. Compensation cell power-down
CMP_PD : Boolean;
-- unspecified
Reserved_1_7 : HAL.UInt7;
-- Read-only. READY
READY : Boolean;
-- unspecified
Reserved_9_31 : HAL.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMPCR_Register use record
CMP_PD at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
READY at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- System configuration controller
type SYSCFG_Peripheral is record
-- memory remap register
MEMRM : aliased MEMRM_Register;
-- peripheral mode configuration register
PMC : aliased PMC_Register;
-- external interrupt configuration register 1
EXTICR1 : aliased EXTICR1_Register;
-- external interrupt configuration register 2
EXTICR2 : aliased EXTICR2_Register;
-- external interrupt configuration register 3
EXTICR3 : aliased EXTICR3_Register;
-- external interrupt configuration register 4
EXTICR4 : aliased EXTICR4_Register;
-- Compensation cell control register
CMPCR : aliased CMPCR_Register;
end record
with Volatile;
for SYSCFG_Peripheral use record
MEMRM at 16#0# range 0 .. 31;
PMC at 16#4# range 0 .. 31;
EXTICR1 at 16#8# range 0 .. 31;
EXTICR2 at 16#C# range 0 .. 31;
EXTICR3 at 16#10# range 0 .. 31;
EXTICR4 at 16#14# range 0 .. 31;
CMPCR at 16#20# range 0 .. 31;
end record;
-- System configuration controller
SYSCFG_Periph : aliased SYSCFG_Peripheral
with Import, Address => System'To_Address (16#40013800#);
end STM32_SVD.SYSCFG;
|
reznikmm/matreshka | Ada | 3,621 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Variable_Actions.Hash is
new AMF.Elements.Generic_Hash (UML_Variable_Action, UML_Variable_Action_Access);
|
AaronC98/PlaneSystem | Ada | 4,378 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2003-2017, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
-- This package provides services to handle WSDL
with DOM.Core;
package SOAP.WSDL is
WSDL_Error : exception;
type Object is new DOM.Core.Document;
function Load (Filename : String) return Object;
-- Load and parse a WSDL document and return the XML tree representation
type Parameter_Type is
(P_Long, P_Integer, P_Short, P_Byte, P_Float, P_Double, P_String,
P_Character, P_Boolean, P_Time, P_B64, P_Unsigned_Long, P_Unsigned_Int,
P_Unsigned_Short, P_Unsigned_Byte, P_Any_Type);
-- These are the types supported by the WSDL parser
function Is_Standard (XSD_Type : String) return Boolean;
-- Returns true is XSD_Type is a standard type (not an array or a record)
function To_Type (XSD_Type : String) return Parameter_Type;
-- Returns the Ada parameter style for the XML type XSD_Type
function From_Type (P : Parameter_Type) return String;
-- Returns the xsd type for the given parameter
function To_Ada
(P : Parameter_Type;
Constrained : Boolean := False) return String;
-- Returns P's Ada type string representation
procedure From_Ada
(Ada_Type : String;
Result : out WSDL.Parameter_Type;
Standard : out Boolean);
-- Set Result with the type corresponding to the Ada type name
function To_XSD (P : WSDL.Parameter_Type) return String;
-- Returns the XSD type corresponding to P
function V_Routine
(P : Parameter_Type;
Constrained : Boolean := False) return String;
-- Returns the V routine to use to get value for a Parameter_Type
function Get_Routine
(P : Parameter_Type;
Constrained : Boolean := False) return String;
-- Returns the Get routine to use to get value for a Parameter_Type
function Set_Routine
(P : Parameter_Type;
Constrained : Boolean := False) return String;
function Set_Routine
(P : String;
Constrained : Boolean := False) return String;
-- Returns the constructor to use to create a Parameter_Type
function Set_Type (P : Parameter_Type) return String;
-- Returns SOAP type for P
end SOAP.WSDL;
|
stcarrez/ada-awa | Ada | 112,402 | adb | -----------------------------------------------------------------------
-- AWA.Wikis.Models -- AWA.Wikis.Models
-----------------------------------------------------------------------
-- File generated by Dynamo DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0
-----------------------------------------------------------------------
-- Copyright (C) 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
pragma Warnings (Off);
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
pragma Warnings (On);
package body AWA.Wikis.Models is
pragma Style_Checks ("-mrIu");
pragma Warnings (Off, "formal parameter * is not referenced");
pragma Warnings (Off, "use clause for type *");
pragma Warnings (Off, "use clause for private type *");
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
function Wiki_Content_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_CONTENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Content_Key;
function Wiki_Content_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_CONTENT_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Content_Key;
function "=" (Left, Right : Wiki_Content_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Wiki_Content_Ref'Class;
Impl : out Wiki_Content_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Wiki_Content_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Wiki_Content_Ref) is
Impl : Wiki_Content_Access;
begin
Impl := new Wiki_Content_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Format := Format_Type'First;
Impl.Version := 0;
Impl.Page_Version := 0;
Impl.Page_Id := ADO.NO_IDENTIFIER;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Wiki_Content
-- ----------------------------------------
procedure Set_Id (Object : in out Wiki_Content_Ref;
Value : in ADO.Identifier) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Wiki_Content_Ref)
return ADO.Identifier is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Create_Date (Object : in out Wiki_Content_Ref;
Value : in Ada.Calendar.Time) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Wiki_Content_Ref)
return Ada.Calendar.Time is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Content (Object : in out Wiki_Content_Ref;
Value : in String) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Content, Value);
end Set_Content;
procedure Set_Content (Object : in out Wiki_Content_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Content, Value);
end Set_Content;
function Get_Content (Object : in Wiki_Content_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Content);
end Get_Content;
function Get_Content (Object : in Wiki_Content_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Content;
end Get_Content;
procedure Set_Format (Object : in out Wiki_Content_Ref;
Value : in Format_Type) is
procedure Set_Field_Discrete is
new ADO.Objects.Set_Field_Operation
(Format_Type);
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 4, Impl.Format, Value);
end Set_Format;
function Get_Format (Object : in Wiki_Content_Ref)
return Format_Type is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Format;
end Get_Format;
procedure Set_Save_Comment (Object : in out Wiki_Content_Ref;
Value : in String) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 5, Impl.Save_Comment, Value);
end Set_Save_Comment;
procedure Set_Save_Comment (Object : in out Wiki_Content_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 5, Impl.Save_Comment, Value);
end Set_Save_Comment;
function Get_Save_Comment (Object : in Wiki_Content_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Save_Comment);
end Get_Save_Comment;
function Get_Save_Comment (Object : in Wiki_Content_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Save_Comment;
end Get_Save_Comment;
function Get_Version (Object : in Wiki_Content_Ref)
return Integer is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Page_Version (Object : in out Wiki_Content_Ref;
Value : in Integer) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 7, Impl.Page_Version, Value);
end Set_Page_Version;
function Get_Page_Version (Object : in Wiki_Content_Ref)
return Integer is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Page_Version;
end Get_Page_Version;
procedure Set_Page_Id (Object : in out Wiki_Content_Ref;
Value : in ADO.Identifier) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Identifier (Impl.all, 8, Impl.Page_Id, Value);
end Set_Page_Id;
function Get_Page_Id (Object : in Wiki_Content_Ref)
return ADO.Identifier is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Page_Id;
end Get_Page_Id;
procedure Set_Author (Object : in out Wiki_Content_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Wiki_Content_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Author, Value);
end Set_Author;
function Get_Author (Object : in Wiki_Content_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Author;
end Get_Author;
-- Copy of the object.
procedure Copy (Object : in Wiki_Content_Ref;
Into : in out Wiki_Content_Ref) is
Result : Wiki_Content_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Wiki_Content_Access
:= Wiki_Content_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Wiki_Content_Access
:= new Wiki_Content_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Create_Date := Impl.Create_Date;
Copy.Content := Impl.Content;
Copy.Format := Impl.Format;
Copy.Save_Comment := Impl.Save_Comment;
Copy.Version := Impl.Version;
Copy.Page_Version := Impl.Page_Version;
Copy.Page_Id := Impl.Page_Id;
Copy.Author := Impl.Author;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Wiki_Content_Access := new Wiki_Content_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Wiki_Content_Access := new Wiki_Content_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Wiki_Content_Access := new Wiki_Content_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Wiki_Content_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Wiki_Content_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_CONTENT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Wiki_Content_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Wiki_Content_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Wiki_Content_Impl) is
type Wiki_Content_Impl_Ptr is access all Wiki_Content_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Wiki_Content_Impl, Wiki_Content_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Wiki_Content_Impl_Ptr := Wiki_Content_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Wiki_Content_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_CONTENT_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Wiki_Content_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Wiki_Content_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (WIKI_CONTENT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- page_version
Value => Object.Page_Version);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- page_id
Value => Object.Page_Id);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Object.Clear_Modified (9);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
overriding
procedure Create (Object : in out Wiki_Content_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (WIKI_CONTENT_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_2_1_NAME, -- content
Value => Object.Content);
Query.Save_Field (Name => COL_3_1_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Query.Save_Field (Name => COL_4_1_NAME, -- save_comment
Value => Object.Save_Comment);
Query.Save_Field (Name => COL_5_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_6_1_NAME, -- page_version
Value => Object.Page_Version);
Query.Save_Field (Name => COL_7_1_NAME, -- page_id
Value => Object.Page_Id);
Query.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
overriding
procedure Delete (Object : in out Wiki_Content_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (WIKI_CONTENT_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Content_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Wiki_Content_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Wiki_Content_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "content" then
return Util.Beans.Objects.To_Object (Impl.Content);
elsif Name = "format" then
return Format_Type_Objects.To_Object (Impl.Format);
elsif Name = "save_comment" then
return Util.Beans.Objects.To_Object (Impl.Save_Comment);
elsif Name = "page_version" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Page_Version));
elsif Name = "page_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Page_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Wiki_Content_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Create_Date := Stmt.Get_Time (1);
Object.Content := Stmt.Get_Unbounded_String (2);
Object.Format := Format_Type'Enum_Val (Stmt.Get_Integer (3));
Object.Save_Comment := Stmt.Get_Unbounded_String (4);
Object.Page_Version := Stmt.Get_Integer (6);
Object.Page_Id := Stmt.Get_Identifier (7);
if not Stmt.Is_Null (8) then
Object.Author.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
Object.Version := Stmt.Get_Integer (5);
ADO.Objects.Set_Created (Object);
end Load;
function Wiki_Space_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_SPACE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Space_Key;
function Wiki_Space_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_SPACE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Space_Key;
function "=" (Left, Right : Wiki_Space_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Wiki_Space_Ref'Class;
Impl : out Wiki_Space_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Wiki_Space_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Wiki_Space_Ref) is
Impl : Wiki_Space_Access;
begin
Impl := new Wiki_Space_Impl;
Impl.Is_Public := False;
Impl.Version := 0;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Format := Format_Type'First;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Wiki_Space
-- ----------------------------------------
procedure Set_Id (Object : in out Wiki_Space_Ref;
Value : in ADO.Identifier) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Wiki_Space_Ref)
return ADO.Identifier is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Wiki_Space_Ref;
Value : in String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Wiki_Space_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Wiki_Space_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Wiki_Space_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Is_Public (Object : in out Wiki_Space_Ref;
Value : in Boolean) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Boolean (Impl.all, 3, Impl.Is_Public, Value);
end Set_Is_Public;
function Get_Is_Public (Object : in Wiki_Space_Ref)
return Boolean is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Is_Public;
end Get_Is_Public;
function Get_Version (Object : in Wiki_Space_Ref)
return Integer is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Create_Date (Object : in out Wiki_Space_Ref;
Value : in Ada.Calendar.Time) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 5, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Wiki_Space_Ref)
return Ada.Calendar.Time is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Left_Side (Object : in out Wiki_Space_Ref;
Value : in String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 6, Impl.Left_Side, Value);
end Set_Left_Side;
procedure Set_Left_Side (Object : in out Wiki_Space_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 6, Impl.Left_Side, Value);
end Set_Left_Side;
function Get_Left_Side (Object : in Wiki_Space_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Left_Side);
end Get_Left_Side;
function Get_Left_Side (Object : in Wiki_Space_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Left_Side;
end Get_Left_Side;
procedure Set_Right_Side (Object : in out Wiki_Space_Ref;
Value : in String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 7, Impl.Right_Side, Value);
end Set_Right_Side;
procedure Set_Right_Side (Object : in out Wiki_Space_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 7, Impl.Right_Side, Value);
end Set_Right_Side;
function Get_Right_Side (Object : in Wiki_Space_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Right_Side);
end Get_Right_Side;
function Get_Right_Side (Object : in Wiki_Space_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Right_Side;
end Get_Right_Side;
procedure Set_Format (Object : in out Wiki_Space_Ref;
Value : in Format_Type) is
procedure Set_Field_Discrete is
new ADO.Audits.Set_Field_Operation
(Format_Type,
Format_Type_Objects.To_Object);
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
Set_Field_Discrete (Impl.all, 8, Impl.Format, Value);
end Set_Format;
function Get_Format (Object : in Wiki_Space_Ref)
return Format_Type is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Format;
end Get_Format;
procedure Set_Workspace (Object : in out Wiki_Space_Ref;
Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is
Impl : Wiki_Space_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Workspace, Value);
end Set_Workspace;
function Get_Workspace (Object : in Wiki_Space_Ref)
return AWA.Workspaces.Models.Workspace_Ref'Class is
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Workspace;
end Get_Workspace;
-- Copy of the object.
procedure Copy (Object : in Wiki_Space_Ref;
Into : in out Wiki_Space_Ref) is
Result : Wiki_Space_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Wiki_Space_Access
:= Wiki_Space_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Wiki_Space_Access
:= new Wiki_Space_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
Copy.Is_Public := Impl.Is_Public;
Copy.Version := Impl.Version;
Copy.Create_Date := Impl.Create_Date;
Copy.Left_Side := Impl.Left_Side;
Copy.Right_Side := Impl.Right_Side;
Copy.Format := Impl.Format;
Copy.Workspace := Impl.Workspace;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Wiki_Space_Access := new Wiki_Space_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Wiki_Space_Access := new Wiki_Space_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Wiki_Space_Access := new Wiki_Space_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Wiki_Space_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Wiki_Space_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_SPACE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Wiki_Space_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Wiki_Space_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Wiki_Space_Impl) is
type Wiki_Space_Impl_Ptr is access all Wiki_Space_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Wiki_Space_Impl, Wiki_Space_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Wiki_Space_Impl_Ptr := Wiki_Space_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Wiki_Space_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_SPACE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Wiki_Space_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Wiki_Space_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (WIKI_SPACE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- is_public
Value => Object.Is_Public);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_2_NAME, -- left_side
Value => Object.Left_Side);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_2_NAME, -- right_side
Value => Object.Right_Side);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_2_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_2_NAME, -- workspace_id
Value => Object.Workspace);
Object.Clear_Modified (9);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
ADO.Audits.Save (Object, Session);
end;
end if;
end Save;
overriding
procedure Create (Object : in out Wiki_Space_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (WIKI_SPACE_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_2_2_NAME, -- is_public
Value => Object.Is_Public);
Query.Save_Field (Name => COL_3_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_4_2_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_5_2_NAME, -- left_side
Value => Object.Left_Side);
Query.Save_Field (Name => COL_6_2_NAME, -- right_side
Value => Object.Right_Side);
Query.Save_Field (Name => COL_7_2_NAME, -- format
Value => Integer (Format_Type'Enum_Rep (Object.Format)));
Query.Save_Field (Name => COL_8_2_NAME, -- workspace_id
Value => Object.Workspace);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
ADO.Audits.Save (Object, Session);
end Create;
overriding
procedure Delete (Object : in out Wiki_Space_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (WIKI_SPACE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Space_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Wiki_Space_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Wiki_Space_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "is_public" then
return Util.Beans.Objects.To_Object (Impl.Is_Public);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "left_side" then
return Util.Beans.Objects.To_Object (Impl.Left_Side);
elsif Name = "right_side" then
return Util.Beans.Objects.To_Object (Impl.Right_Side);
elsif Name = "format" then
return Format_Type_Objects.To_Object (Impl.Format);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Wiki_Space_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
Object.Is_Public := Stmt.Get_Boolean (2);
Object.Create_Date := Stmt.Get_Time (4);
Object.Left_Side := Stmt.Get_Unbounded_String (5);
Object.Right_Side := Stmt.Get_Unbounded_String (6);
Object.Format := Format_Type'Enum_Val (Stmt.Get_Integer (7));
if not Stmt.Is_Null (8) then
Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
Object.Version := Stmt.Get_Integer (3);
ADO.Objects.Set_Created (Object);
end Load;
function Wiki_Page_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_PAGE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Page_Key;
function Wiki_Page_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => WIKI_PAGE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Wiki_Page_Key;
function "=" (Left, Right : Wiki_Page_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Wiki_Page_Ref'Class;
Impl : out Wiki_Page_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Wiki_Page_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
overriding
procedure Allocate (Object : in out Wiki_Page_Ref) is
Impl : Wiki_Page_Access;
begin
Impl := new Wiki_Page_Impl;
Impl.Last_Version := 0;
Impl.Is_Public := False;
Impl.Version := 0;
Impl.Read_Count := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Wiki_Page
-- ----------------------------------------
procedure Set_Id (Object : in out Wiki_Page_Ref;
Value : in ADO.Identifier) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Wiki_Page_Ref)
return ADO.Identifier is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Name (Object : in out Wiki_Page_Ref;
Value : in String) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
procedure Set_Name (Object : in out Wiki_Page_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value);
end Set_Name;
function Get_Name (Object : in Wiki_Page_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Name);
end Get_Name;
function Get_Name (Object : in Wiki_Page_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Name;
end Get_Name;
procedure Set_Last_Version (Object : in out Wiki_Page_Ref;
Value : in Integer) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Integer (Impl.all, 3, Impl.Last_Version, Value);
end Set_Last_Version;
function Get_Last_Version (Object : in Wiki_Page_Ref)
return Integer is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Last_Version;
end Get_Last_Version;
procedure Set_Is_Public (Object : in out Wiki_Page_Ref;
Value : in Boolean) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Boolean (Impl.all, 4, Impl.Is_Public, Value);
end Set_Is_Public;
function Get_Is_Public (Object : in Wiki_Page_Ref)
return Boolean is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Is_Public;
end Get_Is_Public;
procedure Set_Title (Object : in out Wiki_Page_Ref;
Value : in String) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_String (Impl.all, 5, Impl.Title, Value);
end Set_Title;
procedure Set_Title (Object : in out Wiki_Page_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Audits.Set_Field_Unbounded_String (Impl.all, 5, Impl.Title, Value);
end Set_Title;
function Get_Title (Object : in Wiki_Page_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Title);
end Get_Title;
function Get_Title (Object : in Wiki_Page_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Title;
end Get_Title;
function Get_Version (Object : in Wiki_Page_Ref)
return Integer is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Read_Count (Object : in out Wiki_Page_Ref;
Value : in Integer) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 7, Impl.Read_Count, Value);
end Set_Read_Count;
function Get_Read_Count (Object : in Wiki_Page_Ref)
return Integer is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Read_Count;
end Get_Read_Count;
procedure Set_Preview (Object : in out Wiki_Page_Ref;
Value : in AWA.Images.Models.Image_Ref'Class) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 8, Impl.Preview, Value);
end Set_Preview;
function Get_Preview (Object : in Wiki_Page_Ref)
return AWA.Images.Models.Image_Ref'Class is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Preview;
end Get_Preview;
procedure Set_Wiki (Object : in out Wiki_Page_Ref;
Value : in Wiki_Space_Ref'Class) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Wiki, Value);
end Set_Wiki;
function Get_Wiki (Object : in Wiki_Page_Ref)
return Wiki_Space_Ref'Class is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Wiki;
end Get_Wiki;
procedure Set_Content (Object : in out Wiki_Page_Ref;
Value : in Wiki_Content_Ref'Class) is
Impl : Wiki_Page_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Content, Value);
end Set_Content;
function Get_Content (Object : in Wiki_Page_Ref)
return Wiki_Content_Ref'Class is
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Content;
end Get_Content;
-- Copy of the object.
procedure Copy (Object : in Wiki_Page_Ref;
Into : in out Wiki_Page_Ref) is
Result : Wiki_Page_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Wiki_Page_Access
:= Wiki_Page_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Wiki_Page_Access
:= new Wiki_Page_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Name := Impl.Name;
Copy.Last_Version := Impl.Last_Version;
Copy.Is_Public := Impl.Is_Public;
Copy.Title := Impl.Title;
Copy.Version := Impl.Version;
Copy.Read_Count := Impl.Read_Count;
Copy.Preview := Impl.Preview;
Copy.Wiki := Impl.Wiki;
Copy.Content := Impl.Content;
end;
end if;
Into := Result;
end Copy;
overriding
procedure Find (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Wiki_Page_Access := new Wiki_Page_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Wiki_Page_Access := new Wiki_Page_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Wiki_Page_Access := new Wiki_Page_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Reload (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Session'Class;
Updated : out Boolean) is
Result : ADO.Objects.Object_Record_Access;
Impl : Wiki_Page_Access;
Query : ADO.SQL.Query;
Id : ADO.Identifier;
begin
if Object.Is_Null then
raise ADO.Objects.NULL_ERROR;
end if;
Object.Prepare_Modify (Result);
Impl := Wiki_Page_Impl (Result.all)'Access;
Id := ADO.Objects.Get_Key_Value (Impl.all);
Query.Bind_Param (Position => 1, Value => Id);
Query.Bind_Param (Position => 2, Value => Impl.Version);
Query.Set_Filter ("id = ? AND version != ?");
declare
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_PAGE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Updated := True;
Impl.Load (Stmt, Session);
else
Updated := False;
end if;
end;
end Reload;
overriding
procedure Save (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Wiki_Page_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
overriding
procedure Delete (Object : in out Wiki_Page_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
overriding
procedure Destroy (Object : access Wiki_Page_Impl) is
type Wiki_Page_Impl_Ptr is access all Wiki_Page_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Wiki_Page_Impl, Wiki_Page_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Wiki_Page_Impl_Ptr := Wiki_Page_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
overriding
procedure Find (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, WIKI_PAGE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
overriding
procedure Save (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (WIKI_PAGE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_3_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_3_NAME, -- last_version
Value => Object.Last_Version);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_3_NAME, -- is_public
Value => Object.Is_Public);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_3_NAME, -- title
Value => Object.Title);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_3_NAME, -- read_count
Value => Object.Read_Count);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_3_NAME, -- preview_id
Value => Object.Preview);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_3_NAME, -- wiki_id
Value => Object.Wiki);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_3_NAME, -- content_id
Value => Object.Content);
Object.Clear_Modified (10);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
ADO.Audits.Save (Object, Session);
end;
end if;
end Save;
overriding
procedure Create (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (WIKI_PAGE_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_3_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_3_NAME, -- name
Value => Object.Name);
Query.Save_Field (Name => COL_2_3_NAME, -- last_version
Value => Object.Last_Version);
Query.Save_Field (Name => COL_3_3_NAME, -- is_public
Value => Object.Is_Public);
Query.Save_Field (Name => COL_4_3_NAME, -- title
Value => Object.Title);
Query.Save_Field (Name => COL_5_3_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_6_3_NAME, -- read_count
Value => Object.Read_Count);
Query.Save_Field (Name => COL_7_3_NAME, -- preview_id
Value => Object.Preview);
Query.Save_Field (Name => COL_8_3_NAME, -- wiki_id
Value => Object.Wiki);
Query.Save_Field (Name => COL_9_3_NAME, -- content_id
Value => Object.Content);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
ADO.Audits.Save (Object, Session);
end Create;
overriding
procedure Delete (Object : in out Wiki_Page_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (WIKI_PAGE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Page_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Wiki_Page_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Wiki_Page_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "name" then
return Util.Beans.Objects.To_Object (Impl.Name);
elsif Name = "last_version" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Last_Version));
elsif Name = "is_public" then
return Util.Beans.Objects.To_Object (Impl.Is_Public);
elsif Name = "title" then
return Util.Beans.Objects.To_Object (Impl.Title);
elsif Name = "read_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Read_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Wiki_Page_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Name := Stmt.Get_Unbounded_String (1);
Object.Last_Version := Stmt.Get_Integer (2);
Object.Is_Public := Stmt.Get_Boolean (3);
Object.Title := Stmt.Get_Unbounded_String (4);
Object.Read_Count := Stmt.Get_Integer (6);
if not Stmt.Is_Null (7) then
Object.Preview.Set_Key_Value (Stmt.Get_Identifier (7), Session);
end if;
if not Stmt.Is_Null (8) then
Object.Wiki.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
if not Stmt.Is_Null (9) then
Object.Content.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
Object.Version := Stmt.Get_Integer (5);
ADO.Objects.Set_Created (Object);
end Load;
procedure Op_Load (Bean : in out Wiki_Image_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Image_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Image_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Image_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Image_Bean,
Method => Op_Load,
Name => "load");
Binding_Wiki_Image_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Image_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Image_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Image_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Image_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "folder_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id));
elsif Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "create_date" then
if From.Create_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (From.Create_Date.Value);
end if;
elsif Name = "uri" then
if From.Uri.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Uri.Value);
end if;
elsif Name = "storage" then
return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage);
elsif Name = "mime_type" then
if From.Mime_Type.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Mime_Type.Value);
end if;
elsif Name = "file_size" then
if From.File_Size.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size.Value));
end if;
elsif Name = "width" then
if From.Width.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width.Value));
end if;
elsif Name = "height" then
if From.Height.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height.Value));
end if;
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Image_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "folder_id" then
Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "create_date" then
Item.Create_Date.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Create_Date.Is_Null then
Item.Create_Date.Value := Util.Beans.Objects.Time.To_Time (Value);
end if;
elsif Name = "uri" then
Item.Uri.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Uri.Is_Null then
Item.Uri.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "storage" then
Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value);
elsif Name = "mime_type" then
Item.Mime_Type.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Mime_Type.Is_Null then
Item.Mime_Type.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "file_size" then
Item.File_Size.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.File_Size.Is_Null then
Item.File_Size.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "width" then
Item.Width.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Width.Is_Null then
Item.Width.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "height" then
Item.Height.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Height.Is_Null then
Item.Height.Value := Util.Beans.Objects.To_Integer (Value);
end if;
end if;
end Set_Value;
-- --------------------
-- Read in the object the data from the query result and prepare to read the next row.
-- If there is no row, raise the ADO.NOT_FOUND exception.
-- --------------------
procedure Read (Into : in out Wiki_Image_Bean;
Stmt : in out ADO.Statements.Query_Statement'Class) is
begin
if not Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
Into.Folder_Id := Stmt.Get_Identifier (0);
Into.Id := Stmt.Get_Identifier (1);
Into.Create_Date := Stmt.Get_Nullable_Time (2);
Into.Uri := Stmt.Get_Nullable_String (3);
Into.Storage := AWA.Storages.Models.Storage_Type'Enum_Val (Stmt.Get_Integer (4));
Into.Mime_Type := Stmt.Get_Nullable_String (5);
Into.File_Size := Stmt.Get_Nullable_Integer (6);
Into.Width := Stmt.Get_Nullable_Integer (7);
Into.Height := Stmt.Get_Nullable_Integer (8);
Stmt.Next;
end Read;
-- --------------------
-- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>.
-- --------------------
procedure Load (Object : in out Wiki_Image_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context);
begin
Stmt.Execute;
Read (Object, Stmt);
if Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Image_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "folder_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Folder_Id));
elsif Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "create_date" then
if From.Create_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (From.Create_Date.Value);
end if;
elsif Name = "uri" then
if From.Uri.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Uri.Value);
end if;
elsif Name = "storage" then
return AWA.Storages.Models.Storage_Type_Objects.To_Object (From.Storage);
elsif Name = "mime_type" then
if From.Mime_Type.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Mime_Type.Value);
end if;
elsif Name = "file_size" then
if From.File_Size.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.File_Size.Value));
end if;
elsif Name = "width" then
if From.Width.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Width.Value));
end if;
elsif Name = "height" then
if From.Height.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Height.Value));
end if;
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Image_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "folder_id" then
Item.Folder_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "create_date" then
Item.Create_Date.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Create_Date.Is_Null then
Item.Create_Date.Value := Util.Beans.Objects.Time.To_Time (Value);
end if;
elsif Name = "uri" then
Item.Uri.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Uri.Is_Null then
Item.Uri.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "storage" then
Item.Storage := AWA.Storages.Models.Storage_Type_Objects.To_Value (Value);
elsif Name = "mime_type" then
Item.Mime_Type.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Mime_Type.Is_Null then
Item.Mime_Type.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "file_size" then
Item.File_Size.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.File_Size.Is_Null then
Item.File_Size.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "width" then
Item.Width.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Width.Is_Null then
Item.Width.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "height" then
Item.Height.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Height.Is_Null then
Item.Height.Value := Util.Beans.Objects.To_Integer (Value);
end if;
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Wiki_Image_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The information about an image used in a wiki page.
-- --------------------
procedure List (Object : in out Wiki_Image_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Wiki_Image_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Wiki_Image_Info) is
begin
Into.Folder_Id := Stmt.Get_Identifier (0);
Into.Id := Stmt.Get_Identifier (1);
Into.Create_Date := Stmt.Get_Nullable_Time (2);
Into.Uri := Stmt.Get_Nullable_String (3);
Into.Storage := AWA.Storages.Models.Storage_Type'Enum_Val (Stmt.Get_Integer (4));
Into.Mime_Type := Stmt.Get_Nullable_String (5);
Into.File_Size := Stmt.Get_Nullable_Integer (6);
Into.Width := Stmt.Get_Nullable_Integer (7);
Into.Height := Stmt.Get_Nullable_Integer (8);
end Read;
begin
Stmt.Execute;
Wiki_Image_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "name" then
return Util.Beans.Objects.To_Object (From.Name);
elsif Name = "is_public" then
return Util.Beans.Objects.To_Object (From.Is_Public);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "page_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "name" then
Item.Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "is_public" then
Item.Is_Public := Util.Beans.Objects.To_Boolean (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "page_count" then
Item.Page_Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Wiki_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of wikis.
-- --------------------
procedure List (Object : in out Wiki_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Wiki_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Wiki_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Name := Stmt.Get_Unbounded_String (1);
Into.Is_Public := Stmt.Get_Boolean (2);
Into.Create_Date := Stmt.Get_Time (3);
Into.Page_Count := Stmt.Get_Integer (4);
end Read;
begin
Stmt.Execute;
Wiki_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Page_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "name" then
return Util.Beans.Objects.To_Object (From.Name);
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "is_public" then
return Util.Beans.Objects.To_Object (From.Is_Public);
elsif Name = "last_version" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Last_Version));
elsif Name = "read_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Read_Count));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "author" then
return Util.Beans.Objects.To_Object (From.Author);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Page_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "name" then
Item.Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "is_public" then
Item.Is_Public := Util.Beans.Objects.To_Boolean (Value);
elsif Name = "last_version" then
Item.Last_Version := Util.Beans.Objects.To_Integer (Value);
elsif Name = "read_count" then
Item.Read_Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "author" then
Item.Author := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Wiki_Page_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The information about a wiki page.
-- --------------------
procedure List (Object : in out Wiki_Page_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Wiki_Page_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Wiki_Page_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Name := Stmt.Get_Unbounded_String (1);
Into.Title := Stmt.Get_Unbounded_String (2);
Into.Is_Public := Stmt.Get_Boolean (3);
Into.Last_Version := Stmt.Get_Integer (4);
Into.Read_Count := Stmt.Get_Integer (5);
Into.Create_Date := Stmt.Get_Time (6);
Into.Author := Stmt.Get_Unbounded_String (7);
end Read;
begin
Stmt.Execute;
Wiki_Page_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Version_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "comment" then
return Util.Beans.Objects.To_Object (From.Comment);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "page_version" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Version));
elsif Name = "author" then
return Util.Beans.Objects.To_Object (From.Author);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Version_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "comment" then
Item.Comment := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "page_version" then
Item.Page_Version := Util.Beans.Objects.To_Integer (Value);
elsif Name = "author" then
Item.Author := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Wiki_Version_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The information about a wiki page version.
-- --------------------
procedure List (Object : in out Wiki_Version_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Wiki_Version_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Wiki_Version_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Comment := Stmt.Get_Unbounded_String (1);
Into.Create_Date := Stmt.Get_Time (2);
Into.Page_Version := Stmt.Get_Integer (3);
Into.Author := Stmt.Get_Unbounded_String (4);
end Read;
begin
Stmt.Execute;
Wiki_Version_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Load (Bean : in out Wiki_View_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_View_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_View_Info'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_View_Info_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_View_Info,
Method => Op_Load,
Name => "load");
Binding_Wiki_View_Info_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_View_Info_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_View_Info)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_View_Info_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_View_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "name" then
if From.Name.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Name.Value);
end if;
elsif Name = "title" then
if From.Title.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Title.Value);
end if;
elsif Name = "is_public" then
if From.Is_Public.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Is_Public.Value);
end if;
elsif Name = "version" then
if From.Version.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Version.Value));
end if;
elsif Name = "read_count" then
if From.Read_Count.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Read_Count.Value));
end if;
elsif Name = "date" then
if From.Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (From.Date.Value);
end if;
elsif Name = "format" then
if From.Format.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Format_Type_Objects.To_Object (From.Format.Value);
end if;
elsif Name = "content" then
if From.Content.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Content.Value);
end if;
elsif Name = "save_comment" then
if From.Save_Comment.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Save_Comment.Value);
end if;
elsif Name = "left_side" then
return Util.Beans.Objects.To_Object (From.Left_Side);
elsif Name = "right_side" then
return Util.Beans.Objects.To_Object (From.Right_Side);
elsif Name = "side_format" then
return Format_Type_Objects.To_Object (From.Side_Format);
elsif Name = "author" then
if From.Author.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (From.Author.Value);
end if;
elsif Name = "acl_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Acl_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_View_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "name" then
Item.Name.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Name.Is_Null then
Item.Name.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "title" then
Item.Title.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Title.Is_Null then
Item.Title.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "is_public" then
Item.Is_Public.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Is_Public.Is_Null then
Item.Is_Public.Value := Util.Beans.Objects.To_Boolean (Value);
end if;
elsif Name = "version" then
Item.Version.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Version.Is_Null then
Item.Version.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "read_count" then
Item.Read_Count.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Read_Count.Is_Null then
Item.Read_Count.Value := Util.Beans.Objects.To_Integer (Value);
end if;
elsif Name = "date" then
Item.Date.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Date.Is_Null then
Item.Date.Value := Util.Beans.Objects.Time.To_Time (Value);
end if;
elsif Name = "format" then
Item.Format.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Format.Is_Null then
Item.Format.Value := Format_Type_Objects.To_Value (Value);
end if;
elsif Name = "content" then
Item.Content.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Content.Is_Null then
Item.Content.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "save_comment" then
Item.Save_Comment.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Save_Comment.Is_Null then
Item.Save_Comment.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "left_side" then
Item.Left_Side := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "right_side" then
Item.Right_Side := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "side_format" then
Item.Side_Format := Format_Type_Objects.To_Value (Value);
elsif Name = "author" then
Item.Author.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Author.Is_Null then
Item.Author.Value := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
elsif Name = "acl_id" then
Item.Acl_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end Set_Value;
-- --------------------
-- Read in the object the data from the query result and prepare to read the next row.
-- If there is no row, raise the ADO.NOT_FOUND exception.
-- --------------------
procedure Read (Into : in out Wiki_View_Info;
Stmt : in out ADO.Statements.Query_Statement'Class) is
begin
if not Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
Into.Id := Stmt.Get_Identifier (0);
Into.Name := Stmt.Get_Nullable_String (1);
Into.Title := Stmt.Get_Nullable_String (2);
Into.Is_Public := Stmt.Get_Nullable_Boolean (3);
Into.Version := Stmt.Get_Nullable_Integer (4);
Into.Read_Count := Stmt.Get_Nullable_Integer (5);
Into.Date := Stmt.Get_Nullable_Time (6);
Into.Format.Is_Null := Stmt.Is_Null (7);
if not Into.Format.Is_Null then
Into.Format.Value := Format_Type'Enum_Val (Stmt.Get_Integer (7));
end if;
Into.Content := Stmt.Get_Nullable_String (8);
Into.Save_Comment := Stmt.Get_Nullable_String (9);
Into.Left_Side := Stmt.Get_Unbounded_String (10);
Into.Right_Side := Stmt.Get_Unbounded_String (11);
Into.Side_Format := Format_Type'Enum_Val (Stmt.Get_Integer (12));
Into.Author := Stmt.Get_Nullable_String (13);
Into.Acl_Id := Stmt.Get_Identifier (14);
Stmt.Next;
end Read;
-- --------------------
-- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>.
-- --------------------
procedure Load (Object : in out Wiki_View_Info'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context);
begin
Stmt.Execute;
Read (Object, Stmt);
if Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Op_Save (Bean : in out Wiki_Space_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Wiki_Space_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Space_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Wiki_Space_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Space_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Load (Bean : in out Wiki_Space_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Space_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Space_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Space_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Space_Bean,
Method => Op_Load,
Name => "load");
Binding_Wiki_Space_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Space_Bean_1.Proxy'Access,
2 => Binding_Wiki_Space_Bean_2.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Space_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Space_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Space_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
Item.Set_Name (Util.Beans.Objects.To_String (Value));
elsif Name = "is_public" then
Item.Set_Is_Public (Util.Beans.Objects.To_Boolean (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "left_side" then
Item.Set_Left_Side (Util.Beans.Objects.To_String (Value));
elsif Name = "right_side" then
Item.Set_Right_Side (Util.Beans.Objects.To_String (Value));
elsif Name = "format" then
Item.Set_Format (Format_Type_Objects.To_Value (Value));
end if;
end Set_Value;
procedure Op_Save (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Wiki_Page_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Delete (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Delete (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_Bean'Class (Bean).Delete (Outcome);
end Op_Delete;
package Binding_Wiki_Page_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean,
Method => Op_Delete,
Name => "delete");
procedure Op_Load (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Page_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean,
Method => Op_Load,
Name => "load");
procedure Op_Setup (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Setup (Bean : in out Wiki_Page_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_Bean'Class (Bean).Setup (Outcome);
end Op_Setup;
package Binding_Wiki_Page_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Bean,
Method => Op_Setup,
Name => "setup");
Binding_Wiki_Page_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Page_Bean_1.Proxy'Access,
2 => Binding_Wiki_Page_Bean_2.Proxy'Access,
3 => Binding_Wiki_Page_Bean_3.Proxy'Access,
4 => Binding_Wiki_Page_Bean_4.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Page_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Page_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Page_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "name" then
Item.Set_Name (Util.Beans.Objects.To_String (Value));
elsif Name = "last_version" then
Item.Set_Last_Version (Util.Beans.Objects.To_Integer (Value));
elsif Name = "is_public" then
Item.Set_Is_Public (Util.Beans.Objects.To_Boolean (Value));
elsif Name = "title" then
Item.Set_Title (Util.Beans.Objects.To_String (Value));
elsif Name = "read_count" then
Item.Set_Read_Count (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Wiki_Page_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Page_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Page_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Wiki_Page_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Page_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Page_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Page_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Page_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
elsif Name = "wiki_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id));
elsif Name = "sort" then
return Util.Beans.Objects.To_Object (From.Sort);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Page_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "wiki_id" then
Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "sort" then
Item.Sort := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
procedure Op_Load (Bean : in out Wiki_Version_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Version_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Version_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Version_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Version_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Wiki_Version_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Version_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Version_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Version_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Version_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "wiki_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id));
elsif Name = "page_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Version_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "wiki_id" then
Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "page_id" then
Item.Page_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Wiki_Page_Info_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Wiki_Page_Info_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Wiki_Page_Info_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Wiki_Page_Info_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Wiki_Page_Info_Bean,
Method => Op_Load,
Name => "load");
Binding_Wiki_Page_Info_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Wiki_Page_Info_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Wiki_Page_Info_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Wiki_Page_Info_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Wiki_Page_Info_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "wiki_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Wiki_Id));
elsif Name = "page_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Wiki_Page_Info_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "wiki_id" then
Item.Wiki_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "page_id" then
Item.Page_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end Set_Value;
end AWA.Wikis.Models;
|
reznikmm/matreshka | Ada | 4,655 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.Current_Selected_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Current_Selected_Attribute_Node is
begin
return Self : Form_Current_Selected_Attribute_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Current_Selected_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Current_Selected_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Current_Selected_Attribute,
Form_Current_Selected_Attribute_Node'Tag);
end Matreshka.ODF_Form.Current_Selected_Attributes;
|
dan76/Amass | Ada | 1,202 | ads | -- Copyright © by Jeff Foley 2017-2023. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-- SPDX-License-Identifier: Apache-2.0
name = "SpyOnWeb"
type = "scrape"
function start()
set_rate_limit(2)
end
function horizontal(ctx, domain)
local resp, err = request(ctx, {['url']=build_url(domain)})
if (err ~= nil and err ~= "") then
log(ctx, "horizontal request to service failed: " .. err)
return
elseif (resp.status_code < 200 or resp.status_code >= 400) then
log(ctx, "horizontal request to service returned with status code: " .. resp.status)
return
end
local pattern = "\"/go/([a-z0-9-]{2,63}[.][a-z]{2,3}([a-z]{2}|))\""
local matches = submatch(resp.body, pattern)
if (matches == nil or #matches == 0) then
log(ctx, "failed to discover registered domain names in the response")
return
end
for _, match in pairs(matches) do
if (match ~= nil and #match >= 2 and match[2] ~= "") then
associated(ctx, domain, match[2])
end
end
end
function build_url(domain)
return "https://spyonweb.com/" .. domain
end
|
mokafiht/u2f_key_SDCC | Ada | 12,700 | adb | M:InitDevice
F:G$enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LInitDevice.enter_DefaultMode_from_RESET$SFRPAGE_save$1$21({1}SC:U),R,0,0,[r7]
F:G$VREG_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$CLOCK_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PORTS_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PORTS_1_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PBCFG_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$CIP51_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$TIMER01_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LInitDevice.TIMER01_0_enter_DefaultMode_from_RESET$TCON_save$1$35({1}SC:U),R,0,0,[r7]
F:G$TIMER16_2_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LInitDevice.TIMER16_2_enter_DefaultMode_from_RESET$TMR2CN0_TR2_save$1$37({1}SC:U),R,0,0,[r7]
F:G$TIMER16_3_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LInitDevice.TIMER16_3_enter_DefaultMode_from_RESET$TMR3CN0_TR3_save$1$39({1}SC:U),R,0,0,[r7]
F:G$TIMER_SETUP_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$SMBUS_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$UART_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$INTERRUPT_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCA_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCACH_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCACH_1_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCACH_2_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),Z,0,0,0,0,0
T:FInitDevice$SI_UU32[({0}S:S$u32$0$0({4}SL:U),Z,0,0)({0}S:S$s32$0$0({4}SL:S),Z,0,0)({0}S:S$uu16$0$0({4}DA2d,STSI_UU16:S),Z,0,0)({0}S:S$u16$0$0({4}DA2d,SI:U),Z,0,0)({0}S:S$s16$0$0({4}DA2d,SI:S),Z,0,0)({0}S:S$u8$0$0({4}DA4d,SC:U),Z,0,0)({0}S:S$s8$0$0({4}DA4d,SC:S),Z,0,0)]
T:FInitDevice$SI_UU16[({0}S:S$u16$0$0({2}SI:U),Z,0,0)({0}S:S$s16$0$0({2}SI:S),Z,0,0)({0}S:S$u8$0$0({2}DA2d,SC:U),Z,0,0)({0}S:S$s8$0$0({2}DA2d,SC:S),Z,0,0)]
T:FInitDevice$SI_GEN_PTR[({0}S:S$u8$0$0({3}DA3d,SC:U),Z,0,0)({0}S:S$gptr$0$0({3}ST__00000000:S),Z,0,0)]
T:FInitDevice$__00000000[({0}S:S$memtype$0$0({1}SC:U),Z,0,0)({1}S:S$address$0$0({2}STSI_UU16:S),Z,0,0)]
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$ADC0AC$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$ADC0CN0$0$0({1}SC:U),I,0,0
S:G$ADC0CN1$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0MX$0$0({1}SC:U),I,0,0
S:G$ADC0PWR$0$0({1}SC:U),I,0,0
S:G$ADC0TK$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$CKCON0$0$0({1}SC:U),I,0,0
S:G$CKCON1$0$0({1}SC:U),I,0,0
S:G$CLKSEL$0$0({1}SC:U),I,0,0
S:G$CMP0CN0$0$0({1}SC:U),I,0,0
S:G$CMP0CN1$0$0({1}SC:U),I,0,0
S:G$CMP0MD$0$0({1}SC:U),I,0,0
S:G$CMP0MX$0$0({1}SC:U),I,0,0
S:G$CMP1CN0$0$0({1}SC:U),I,0,0
S:G$CMP1CN1$0$0({1}SC:U),I,0,0
S:G$CMP1MD$0$0({1}SC:U),I,0,0
S:G$CMP1MX$0$0({1}SC:U),I,0,0
S:G$CRC0CN0$0$0({1}SC:U),I,0,0
S:G$CRC0CN1$0$0({1}SC:U),I,0,0
S:G$CRC0CNT$0$0({1}SC:U),I,0,0
S:G$CRC0DAT$0$0({1}SC:U),I,0,0
S:G$CRC0FLIP$0$0({1}SC:U),I,0,0
S:G$CRC0IN$0$0({1}SC:U),I,0,0
S:G$CRC0ST$0$0({1}SC:U),I,0,0
S:G$DERIVID$0$0({1}SC:U),I,0,0
S:G$DEVICEID$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP1H$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$EIP2H$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$FLKEY$0$0({1}SC:U),I,0,0
S:G$HFO0CAL$0$0({1}SC:U),I,0,0
S:G$HFO1CAL$0$0({1}SC:U),I,0,0
S:G$HFOCN$0$0({1}SC:U),I,0,0
S:G$I2C0CN0$0$0({1}SC:U),I,0,0
S:G$I2C0DIN$0$0({1}SC:U),I,0,0
S:G$I2C0DOUT$0$0({1}SC:U),I,0,0
S:G$I2C0FCN0$0$0({1}SC:U),I,0,0
S:G$I2C0FCN1$0$0({1}SC:U),I,0,0
S:G$I2C0FCT$0$0({1}SC:U),I,0,0
S:G$I2C0SLAD$0$0({1}SC:U),I,0,0
S:G$I2C0STAT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$IPH$0$0({1}SC:U),I,0,0
S:G$IT01CF$0$0({1}SC:U),I,0,0
S:G$LFO0CN$0$0({1}SC:U),I,0,0
S:G$P0$0$0({1}SC:U),I,0,0
S:G$P0MASK$0$0({1}SC:U),I,0,0
S:G$P0MAT$0$0({1}SC:U),I,0,0
S:G$P0MDIN$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$P0SKIP$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$P1MASK$0$0({1}SC:U),I,0,0
S:G$P1MAT$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$P1SKIP$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$P2MASK$0$0({1}SC:U),I,0,0
S:G$P2MAT$0$0({1}SC:U),I,0,0
S:G$P2MDIN$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$P2SKIP$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$P3MDIN$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$PCA0CENT$0$0({1}SC:U),I,0,0
S:G$PCA0CLR$0$0({1}SC:U),I,0,0
S:G$PCA0CN0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0POL$0$0({1}SC:U),I,0,0
S:G$PCA0PWM$0$0({1}SC:U),I,0,0
S:G$PCON0$0$0({1}SC:U),I,0,0
S:G$PCON1$0$0({1}SC:U),I,0,0
S:G$PFE0CN$0$0({1}SC:U),I,0,0
S:G$PRTDRV$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$REG0CN$0$0({1}SC:U),I,0,0
S:G$REG1CN$0$0({1}SC:U),I,0,0
S:G$REVID$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$SBCON1$0$0({1}SC:U),I,0,0
S:G$SBRLH1$0$0({1}SC:U),I,0,0
S:G$SBRLL1$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SFRPAGE$0$0({1}SC:U),I,0,0
S:G$SFRPGCN$0$0({1}SC:U),I,0,0
S:G$SFRSTACK$0$0({1}SC:U),I,0,0
S:G$SMB0ADM$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$SMB0CF$0$0({1}SC:U),I,0,0
S:G$SMB0CN0$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0FCN0$0$0({1}SC:U),I,0,0
S:G$SMB0FCN1$0$0({1}SC:U),I,0,0
S:G$SMB0FCT$0$0({1}SC:U),I,0,0
S:G$SMB0RXLN$0$0({1}SC:U),I,0,0
S:G$SMB0TC$0$0({1}SC:U),I,0,0
S:G$SMOD1$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$SPI0CN0$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$SPI0FCN0$0$0({1}SC:U),I,0,0
S:G$SPI0FCN1$0$0({1}SC:U),I,0,0
S:G$SPI0FCT$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TMR2CN0$0$0({1}SC:U),I,0,0
S:G$TMR2CN1$0$0({1}SC:U),I,0,0
S:G$TMR2H$0$0({1}SC:U),I,0,0
S:G$TMR2L$0$0({1}SC:U),I,0,0
S:G$TMR2RLH$0$0({1}SC:U),I,0,0
S:G$TMR2RLL$0$0({1}SC:U),I,0,0
S:G$TMR3CN0$0$0({1}SC:U),I,0,0
S:G$TMR3CN1$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR4CN0$0$0({1}SC:U),I,0,0
S:G$TMR4CN1$0$0({1}SC:U),I,0,0
S:G$TMR4H$0$0({1}SC:U),I,0,0
S:G$TMR4L$0$0({1}SC:U),I,0,0
S:G$TMR4RLH$0$0({1}SC:U),I,0,0
S:G$TMR4RLL$0$0({1}SC:U),I,0,0
S:G$UART1FCN0$0$0({1}SC:U),I,0,0
S:G$UART1FCN1$0$0({1}SC:U),I,0,0
S:G$UART1FCT$0$0({1}SC:U),I,0,0
S:G$UART1LIN$0$0({1}SC:U),I,0,0
S:G$USB0ADR$0$0({1}SC:U),I,0,0
S:G$USB0AEC$0$0({1}SC:U),I,0,0
S:G$USB0CDCF$0$0({1}SC:U),I,0,0
S:G$USB0CDCN$0$0({1}SC:U),I,0,0
S:G$USB0CDSTA$0$0({1}SC:U),I,0,0
S:G$USB0CF$0$0({1}SC:U),I,0,0
S:G$USB0DAT$0$0({1}SC:U),I,0,0
S:G$USB0XCN$0$0({1}SC:U),I,0,0
S:G$VDM0CN$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DP$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$SBRL1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$TMR2RL$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$TMR4RL$0$0({2}SI:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$ACC_ACC0$0$0({1}SX:U),J,0,0
S:G$ACC_ACC1$0$0({1}SX:U),J,0,0
S:G$ACC_ACC2$0$0({1}SX:U),J,0,0
S:G$ACC_ACC3$0$0({1}SX:U),J,0,0
S:G$ACC_ACC4$0$0({1}SX:U),J,0,0
S:G$ACC_ACC5$0$0({1}SX:U),J,0,0
S:G$ACC_ACC6$0$0({1}SX:U),J,0,0
S:G$ACC_ACC7$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM0$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM1$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM2$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADWINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBUSY$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBMEN$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADEN$0$0({1}SX:U),J,0,0
S:G$B_B0$0$0({1}SX:U),J,0,0
S:G$B_B1$0$0({1}SX:U),J,0,0
S:G$B_B2$0$0({1}SX:U),J,0,0
S:G$B_B3$0$0({1}SX:U),J,0,0
S:G$B_B4$0$0({1}SX:U),J,0,0
S:G$B_B5$0$0({1}SX:U),J,0,0
S:G$B_B6$0$0({1}SX:U),J,0,0
S:G$B_B7$0$0({1}SX:U),J,0,0
S:G$IE_EX0$0$0({1}SX:U),J,0,0
S:G$IE_ET0$0$0({1}SX:U),J,0,0
S:G$IE_EX1$0$0({1}SX:U),J,0,0
S:G$IE_ET1$0$0({1}SX:U),J,0,0
S:G$IE_ES0$0$0({1}SX:U),J,0,0
S:G$IE_ET2$0$0({1}SX:U),J,0,0
S:G$IE_ESPI0$0$0({1}SX:U),J,0,0
S:G$IE_EA$0$0({1}SX:U),J,0,0
S:G$IP_PX0$0$0({1}SX:U),J,0,0
S:G$IP_PT0$0$0({1}SX:U),J,0,0
S:G$IP_PX1$0$0({1}SX:U),J,0,0
S:G$IP_PT1$0$0({1}SX:U),J,0,0
S:G$IP_PS0$0$0({1}SX:U),J,0,0
S:G$IP_PT2$0$0({1}SX:U),J,0,0
S:G$IP_PSPI0$0$0({1}SX:U),J,0,0
S:G$P0_B0$0$0({1}SX:U),J,0,0
S:G$P0_B1$0$0({1}SX:U),J,0,0
S:G$P0_B2$0$0({1}SX:U),J,0,0
S:G$P0_B3$0$0({1}SX:U),J,0,0
S:G$P0_B4$0$0({1}SX:U),J,0,0
S:G$P0_B5$0$0({1}SX:U),J,0,0
S:G$P0_B6$0$0({1}SX:U),J,0,0
S:G$P0_B7$0$0({1}SX:U),J,0,0
S:G$P1_B0$0$0({1}SX:U),J,0,0
S:G$P1_B1$0$0({1}SX:U),J,0,0
S:G$P1_B2$0$0({1}SX:U),J,0,0
S:G$P1_B3$0$0({1}SX:U),J,0,0
S:G$P1_B4$0$0({1}SX:U),J,0,0
S:G$P1_B5$0$0({1}SX:U),J,0,0
S:G$P1_B6$0$0({1}SX:U),J,0,0
S:G$P1_B7$0$0({1}SX:U),J,0,0
S:G$P2_B0$0$0({1}SX:U),J,0,0
S:G$P2_B1$0$0({1}SX:U),J,0,0
S:G$P2_B2$0$0({1}SX:U),J,0,0
S:G$P2_B3$0$0({1}SX:U),J,0,0
S:G$P3_B0$0$0({1}SX:U),J,0,0
S:G$P3_B1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF0$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF2$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CR$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CF$0$0({1}SX:U),J,0,0
S:G$PSW_PARITY$0$0({1}SX:U),J,0,0
S:G$PSW_F1$0$0({1}SX:U),J,0,0
S:G$PSW_OV$0$0({1}SX:U),J,0,0
S:G$PSW_RS0$0$0({1}SX:U),J,0,0
S:G$PSW_RS1$0$0({1}SX:U),J,0,0
S:G$PSW_F0$0$0({1}SX:U),J,0,0
S:G$PSW_AC$0$0({1}SX:U),J,0,0
S:G$PSW_CY$0$0({1}SX:U),J,0,0
S:G$SCON0_RI$0$0({1}SX:U),J,0,0
S:G$SCON0_TI$0$0({1}SX:U),J,0,0
S:G$SCON0_RB8$0$0({1}SX:U),J,0,0
S:G$SCON0_TB8$0$0({1}SX:U),J,0,0
S:G$SCON0_REN$0$0({1}SX:U),J,0,0
S:G$SCON0_MCE$0$0({1}SX:U),J,0,0
S:G$SCON0_SMODE$0$0({1}SX:U),J,0,0
S:G$SCON1_RI$0$0({1}SX:U),J,0,0
S:G$SCON1_TI$0$0({1}SX:U),J,0,0
S:G$SCON1_RBX$0$0({1}SX:U),J,0,0
S:G$SCON1_TBX$0$0({1}SX:U),J,0,0
S:G$SCON1_REN$0$0({1}SX:U),J,0,0
S:G$SCON1_PERR$0$0({1}SX:U),J,0,0
S:G$SCON1_OVR$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_SI$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACK$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ARBLOST$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACKRQ$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STO$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STA$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_TXMODE$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_MASTER$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIEN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_TXNF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD0$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD1$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_RXOVRN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_MODF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_WCOL$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIF$0$0({1}SX:U),J,0,0
S:G$TCON_IT0$0$0({1}SX:U),J,0,0
S:G$TCON_IE0$0$0({1}SX:U),J,0,0
S:G$TCON_IT1$0$0({1}SX:U),J,0,0
S:G$TCON_IE1$0$0({1}SX:U),J,0,0
S:G$TCON_TR0$0$0({1}SX:U),J,0,0
S:G$TCON_TF0$0$0({1}SX:U),J,0,0
S:G$TCON_TR1$0$0({1}SX:U),J,0,0
S:G$TCON_TF1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TR2$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2CEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2LEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2L$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2H$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TR4$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4CEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4LEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4L$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4H$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO0$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO1$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RFRQ$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXHOLD$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXNF$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TFRQ$0$0({1}SX:U),J,0,0
S:G$HFOSC_0_enter_DefaultMode_from_RESET$0$0({2}DF,SV:S),C,0,0
|
mspiegel/ada-initiative | Ada | 105 | adb | with Ada.Text_IO;
procedure Hello_World is
begin
Ada.Text_IO.Put_Line("Hello world!");
end Hello_World;
|
Fabien-Chouteau/lvgl-ada | Ada | 9,906 | ads | with Lv.Style;
with Lv.Area;
with Lv.Objx.Cont;
package Lv.Objx.Page is
subtype Instance is Obj_T;
-- Scrollbar modes: shows when should the scrollbars be visible
type Mode_T is
(Sb_Mode_Off, -- Never show scrollbars
Sb_Mode_On, -- Always show scrollbars
Sb_Mode_Drag, -- Show scrollbars when page is being dragged
Sb_Mode_Auto, -- Show scrollbars when the scrollable container is large enough to be scrolled
Sb_Mode_Hide, -- Hide the scroll bar temporally
Sb_Mode_Unhide); -- Unhide the previously hidden scrollbar. Recover it's type too
type Style_T is (Style_Bg,
Style_Scrl,
Style_Sb);
-- Create a page objects
-- @param par pointer to an object, it will be the parent of the new page
-- @param copy pointer to a page object, if not NULL then the new object will be copied from it
-- @return pointer to the created page
function Create (Par : Obj_T; Copy : Instance) return Instance;
-- Delete all children of the scrl object, without deleting scrl child.
-- @param self pointer to an object
procedure Clean (Self : Instance);
-- Get the press action of the page
-- @param self pointer to a page object
-- @return a function to call when the page is pressed
function Pr_Action (Self : Instance) return Action_Func_T;
-- Get the release action of the page
-- @param self pointer to a page object
-- @return a function to call when the page is released
function Rel_Action (Self : Instance) return Action_Func_T;
-- Get the scrollable object of a page
-- @param self pointer to a page object
-- @return pointer to a container which is the scrollable part of the page
function Scrl (Arg1 : Instance) return Obj_T;
----------------------
-- Setter functions --
----------------------
-- Set a release action for the page
-- @param self pointer to a page object
-- @param rel_action a function to call when the page is released
procedure Set_Rel_Action (Self : Instance; Rel_Action : Action_Func_T);
-- Set a press action for the page
-- @param self pointer to a page object
-- @param pr_action a function to call when the page is pressed
procedure Set_Pr_Action (Self : Instance; Pr_Action : Action_Func_T);
-- Set the scroll bar mode on a page
-- @param self pointer to a page object
-- @param sb_mode the new mode from 'lv_page_sb.mode_t' enum
procedure Set_Sb_Mode (Self : Instance; Sb_Mode : Mode_T);
-- Enable/Disable scrolling with arrows if the page is in group (arrows: LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN)
-- @param self pointer to a page object
-- @param en true: enable scrolling with arrows
procedure Set_Arrow_Scroll (Self : Instance; En : U_Bool);
-- Set the fit attribute of the scrollable part of a page.
-- It means it can set its size automatically to involve all children.
-- (Can be set separately horizontally and vertically)
-- @param self pointer to a page object
-- @param hor_en true: enable horizontal fit
-- @param ver_en true: enable vertical fit
procedure Set_Scrl_Fit (Self : Instance; Hor_En : U_Bool; Ver_En : U_Bool);
-- Set width of the scrollable part of a page
-- @param self pointer to a page object
-- @param w the new width of the scrollable (it ha no effect is horizontal fit is enabled)
procedure Set_Scrl_Width (Self : Instance; W : Lv.Area.Coord_T);
-- Set height of the scrollable part of a page
-- @param self pointer to a page object
-- @param h the new height of the scrollable (it ha no effect is vertical fit is enabled)
procedure Set_Scrl_Height (Self : Instance; H : Lv.Area.Coord_T);
-- Set the layout of the scrollable part of the page
-- @param self pointer to a page object
-- @param layout a layout from 'lv_cont_layout_t'
procedure Set_Scrl_Layout (Self : Instance; Layout : Lv.Objx.Cont.Layout_T);
-- Set a style of a page
-- @param self pointer to a page object
-- @param type which style should be set
-- @param style pointer to a style
procedure Set_Style
(Self : Instance;
Typ : Style_T;
Style : Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Set the scroll bar mode on a page
-- @param self pointer to a page object
-- @return the mode from 'lv_page_sb.mode_t' enum
function Sb_Mode (Self : Instance) return Mode_T;
-- Get the the scrolling with arrows (LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN) is enabled or not
-- @param self pointer to a page object
-- @return true: scrolling with arrows is enabled
function Arrow_Scroll (Self : Instance) return U_Bool;
-- Get that width which can be set to the children to still not cause overflow (show scrollbars)
-- @param self pointer to a page object
-- @return the width which still fits into the page
function Fit_Width (Self : Instance) return Lv.Area.Coord_T;
-- Get that height which can be set to the children to still not cause overflow (show scrollbars)
-- @param self pointer to a page object
-- @return the height which still fits into the page
function Fit_Height (Self : Instance) return Lv.Area.Coord_T;
-- Get width of the scrollable part of a page
-- @param self pointer to a page object
-- @return the width of the scrollable
function Scrl_Width (Self : Instance) return Lv.Area.Coord_T;
-- Get height of the scrollable part of a page
-- @param self pointer to a page object
-- @return the height of the scrollable
function Scrl_Height (Self : Instance) return Lv.Area.Coord_T;
-- Get the layout of the scrollable part of a page
-- @param self pointer to page object
-- @return the layout from 'lv_cont_layout_t'
function Scrl_Layout (Self : Instance) return Lv.Objx.Cont.Layout_T;
-- Get horizontal fit attribute of the scrollable part of a page
-- @param self pointer to a page object
-- @return true: horizontal fit is enabled; false: disabled
function Scrl_Hor_Fit (Self : Instance) return U_Bool;
-- Get vertical fit attribute of the scrollable part of a page
-- @param self pointer to a page object
-- @return true: vertical fit is enabled; false: disabled
function Scrl_Fit_Ver (Self : Instance) return U_Bool;
-- Get a style of a page
-- @param self pointer to page object
-- @param type which style should be get
-- @return style pointer to a style
function Style
(Self : Instance;
Type_P : Style_T) return Lv.Style.Style;
---------------------
-- Other functions --
---------------------
-- Glue the object to the page. After it the page can be moved (dragged) with this object too.
-- @param obj pointer to an object on a page
-- @param glue true: enable glue, false: disable glue
procedure Glue_Obj (Self : Obj_T; Glue : U_Bool);
-- Focus on an object. It ensures that the object will be visible on the page.
-- @param self pointer to a page object
-- @param obj pointer to an object to focus (must be on the page)
-- @param anim_time scroll animation time in milliseconds (0: no animation)
procedure Focus (Self : Instance; Ob : Obj_T; Anim_Time : Uint16_T);
-- Scroll the page horizontally
-- @param self pointer to a page object
-- @param dist the distance to scroll (< 0: scroll left; > 0 scroll right)
procedure Scroll_Hor (Self : Instance; Dist : Lv.Area.Coord_T);
-- Scroll the page vertically
-- @param self pointer to a page object
-- @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
procedure Scroll_Ver (Self : Instance; Dist : Lv.Area.Coord_T);
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_page_create");
pragma Import (C, Clean, "lv_page_clean");
pragma Import (C, Pr_Action, "lv_page_get_pr_action");
pragma Import (C, Rel_Action, "lv_page_get_rel_action");
pragma Import (C, Scrl, "lv_page_get_scrl");
pragma Import (C, Set_Rel_Action, "lv_page_set_rel_action");
pragma Import (C, Set_Pr_Action, "lv_page_set_pr_action");
pragma Import (C, Set_Sb_Mode, "lv_page_set_sb_mode");
pragma Import (C, Set_Arrow_Scroll, "lv_page_set_arrow_scroll");
pragma Import (C, Set_Scrl_Fit, "lv_page_set_scrl_fit_inline");
pragma Import (C, Set_Scrl_Width, "lv_page_set_scrl_width_inline");
pragma Import (C, Set_Scrl_Height, "lv_page_set_scrl_height_inline");
pragma Import (C, Set_Scrl_Layout, "lv_page_set_scrl_layout_inline");
pragma Import (C, Set_Style, "lv_page_set_style");
pragma Import (C, Sb_Mode, "lv_page_get_sb_mode");
pragma Import (C, Arrow_Scroll, "lv_page_get_arrow_scroll");
pragma Import (C, Fit_Width, "lv_page_get_fit_width");
pragma Import (C, Fit_Height, "lv_page_get_fit_height");
pragma Import (C, Scrl_Width, "lv_page_get_scrl_width_inline");
pragma Import (C, Scrl_Height, "lv_page_get_scrl_height_inline");
pragma Import (C, Scrl_Layout, "lv_page_get_scrl_layout_inline");
pragma Import (C, Scrl_Hor_Fit, "lv_page_get_scrl_hor_fit_inline");
pragma Import (C, Scrl_Fit_Ver, "lv_page_get_scrl_fit_ver_inline");
pragma Import (C, Style, "lv_page_get_style");
pragma Import (C, Glue_Obj, "lv_page_glue_obj");
pragma Import (C, Focus, "lv_page_focus");
pragma Import (C, Scroll_Hor, "lv_page_scroll_hor");
pragma Import (C, Scroll_Ver, "lv_page_scroll_ver");
for Mode_T'Size use 8;
for Mode_T use
(Sb_Mode_Off => 0,
Sb_Mode_On => 1,
Sb_Mode_Drag => 2,
Sb_Mode_Auto => 3,
Sb_Mode_Hide => 4,
Sb_Mode_Unhide => 5);
for Style_T'Size use 8;
for Style_T use (Style_Bg => 0,
Style_Scrl => 1,
Style_Sb => 2);
end Lv.Objx.Page;
|
jwarwick/aoc_2020 | Ada | 1,219 | adb | -- AoC 2020, Day 8
with VM; use VM;
with Ada.Text_IO;
with Ada.Containers.Ordered_Sets;
with Ada.Containers; use Ada.Containers;
package body Day is
package TIO renames Ada.Text_IO;
package PC_Sets is new Ada.Containers.Ordered_Sets (Element_Type => Instruction_Index);
use PC_Sets;
function acc_before_repeat(filename : in String) return Integer is
v : VM.VM := load_file(filename);
i : Instruction_Index := pc(v);
seen : PC_Sets.Set;
halt : Boolean;
begin
loop
if seen.contains(i) then
exit;
end if;
seen.insert(i);
halt := step(v);
i := pc(v);
end loop;
TIO.put_line("Halted?: " & Boolean'Image(halt));
return acc(v);
end acc_before_repeat;
function acc_after_terminate(filename : in String) return Integer is
v : VM.VM := load_file(filename);
max : constant Count_Type := instructions(v);
begin
for i in 0..max-1 loop
swap_nop_jmp(Instruction_Index(i), v);
-- backed this value down to find a reasonable cutoff
if eval(v, 250) then
return acc(v);
end if;
swap_nop_jmp(Instruction_Index(i), v);
reset(v);
end loop;
return -1;
end acc_after_terminate;
end Day;
|
reznikmm/matreshka | Ada | 2,040 | adb |
with Unchecked_Deallocation;
package body Stack_Pack is
SCCS_ID : constant String := "@(#) stack.ada, Version 1.2";
type Node is
record
Datum : Element;
Next : Link;
end record;
function Top_Value (S: in Stack) return Element is
begin
if S.Top = null then
raise Stack_Underflow;
else
return S.Top.Datum;
end if;
end Top_Value;
function Depth_of_Stack (S: in Stack) return Natural is
begin
return S.Tos;
end Depth_of_Stack;
procedure Make_Stack(S: out Stack) is
begin
S := (Tos => 0, Top | Extras => null);
end Make_Stack;
procedure Push(S: in out Stack; Value: in Element) is
New_Node : Link;
begin
S.Tos := S.Tos + 1;
if S.Extras = null then
New_Node := new Node;
else
New_Node := S.Extras;
S.Extras := S.Extras.Next;
end if;
New_Node.all := (Datum => Value, Next => S.Top);
S.Top := New_Node;
end Push;
procedure Pop (S: in out Stack; Value: out Element) is
Temp : Link;
begin
if S.Tos = 0 then
raise Stack_Underflow;
end if;
Value := S.Top.Datum;
Temp := S.Top.Next;
S.Top.Next := S.Extras;
S.Extras := S.Top;
S.Top := Temp;
S.Tos := S.Tos - 1;
end Pop;
procedure Free is new Unchecked_Deallocation(Node, Link);
-- procedure free(x : link);
-- pragma interface(c , free);
procedure Free_List(List: in out Link) is
Temp : Link;
begin
Temp := List;
while Temp /= null loop
List := List.Next;
Free(Temp);
Temp := List;
end loop;
end Free_List;
procedure Free_Stack(S: in out Stack) is
begin
Free_List(S.Top);
Free_List(S.Extras);
end Free_Stack;
end Stack_Pack;
|
AdaCore/ada-traits-containers | Ada | 3,680 | ads | --
-- Copyright (C) 2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Ada.Containers; use Ada.Containers;
package Conts.Maps is
-------------
-- Probing --
-------------
-- The implementation of the hashed map stores all elements in a single
-- array. Preferably, the bucket used is the one corresponding to the hash
-- computed from the key. But in case there is already another element at
-- that position, other positions have to be tried. There are multiple
-- strategies for this.
-- We use a tagged record for this, since some strategies need to keep
-- data. A new instance of the object is created and initialized every time
-- we search for a new key.
type Probing_Strategy is interface;
-- An object whose goal is to compute the next candidate
procedure Initialize_Probing
(Self : in out Probing_Strategy;
Hash : Hash_Type;
Size : Hash_Type) is null;
-- Called once when a lookup starts
function Next_Probing
(Self : in out Probing_Strategy;
Previous : Hash_Type) return Hash_Type is abstract;
-- Compute the next position to check, given we checked Previous and found
-- this position already in use.
--------------------
-- Linear probing --
--------------------
-- Simple probing: check the next place in the array. This is simple,
-- but not optimal in general when the keys are sequential integers for
-- instance, since we end up with blocks of filled slots, which slows the
-- lookup.
type Linear_Probing is new Probing_Strategy with null record;
overriding function Next_Probing
(Self : in out Linear_Probing; Previous : Hash_Type) return Hash_Type
is (Previous + 1) with Inline;
-------------------------
-- Pertubation_Probing --
-------------------------
-- Similar to linear probing, but more efficient since it will try various
-- places in the array.
type Perturbation_Probing is new Probing_Strategy with private;
overriding procedure Initialize_Probing
(Self : in out Perturbation_Probing;
Hash : Hash_Type;
Size : Hash_Type) with Inline;
overriding function Next_Probing
(Self : in out Perturbation_Probing;
Previous : Hash_Type) return Hash_Type
with Inline;
---------------------
-- Resize strategy --
---------------------
function Resize_2_3
(Used : Count_Type;
Fill : Count_Type;
Capacity : Count_Type) return Count_Type
is (Count_Type
(Hash_Type'Min
((if Hash_Type (Fill) > (Hash_Type (Capacity) * 2) / 3
then (if Used > 100_000
then Hash_Type (Used) * 2
else Hash_Type (Used) * 4)
else 0), -- no resizing in this case
Hash_Type (Count_Type'Last))))
with Inline;
-- This strategy attempts to keep the table at most 2/3. If this isn't the
-- case, the size of the table is multiplied by 4 (which trades memory for
-- efficiency by limiting the number of mallocs). However, when the table
-- is already large, we only double the size.
--
-- If memory is more important than pure speed for you, you could modify
-- this strategy.
--
-- The actual size allocated for the table will be the nearest power of 2
-- greater than the returned value.
--
-- See Conts.Maps.Generics.Resize_Strategy for more information on the
-- parameters.
private
type Perturbation_Probing is new Probing_Strategy with record
Pertub : Hash_Type;
end record;
end Conts.Maps;
|
usnistgov/rcslib | Ada | 12,111 | adb |
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Interfaces.C, Interfaces.C.Strings;
use Interfaces.C, Interfaces.C.Strings;
with Ada.Finalization;
use Ada.Finalization;
with Unchecked_Deallocation;
with Unchecked_Conversion;
package body Nml is
pragma Linker_Options("-lrcs");
function Nml_New(Func : in Format_Callback_Func;
Bufname, ProcessName,Cfgfile : in Interfaces.C.Strings.Chars_Ptr)
return Nml_C_T;
pragma Import(C,Nml_New,"nml_new");
procedure Nml_Set_Msg_Base_Offset(Nml : Nml_C_T; S: Interfaces.C.Int);
pragma Import(C,Nml_Set_Msg_Base_Offset,"nml_set_msg_base_offset");
procedure Nml_Cms_Pointer_Check_Disable(Nml : Nml_C_T);
pragma Import(C,Nml_Cms_Pointer_Check_Disable,"nml_cms_pointer_check_disable");
function CreateConnection(NewCallBackFunction : in Format_Callback_Func; BufferName,ProcessName,ConfigSource: in String) return NmlConnection_Access is
Nca : NmlConnection_Access;
Bn : Interfaces.C.Strings.Chars_Ptr;
Pn : Interfaces.C.Strings.Chars_Ptr;
Cf : Interfaces.C.Strings.Chars_Ptr;
M:NmlMsg;
begin
Bn := Interfaces.C.Strings.New_String(BufferName);
Pn := Interfaces.C.Strings.New_String(ProcessName);
Cf := Interfaces.C.Strings.New_String(ConfigSource);
Nca := new NmlConnection;
Nca.CallBackFunc := NewCallBackFunction;
Nca.Nml_C_Ptr := Nml_New(NewCallBackFunction,Bn,Pn,Cf);
Nml_Cms_Pointer_Check_Disable(Nca.Nml_C_Ptr);
-- Nml_Set_Msg_Base_Offset(Nca.Nml_C_Ptr,(M'Size-M.NmlType'Position)/8);
Interfaces.C.Strings.Free(Bn);
Interfaces.C.Strings.Free(Pn);
Interfaces.C.Strings.Free(Cf);
return Nca;
end CreateConnection;
function Nml_Valid(Nml : in Nml_C_T) return Interfaces.C.Int;
pragma Import(C,Nml_Valid,"nml_valid");
function Valid(Connection : in NmlConnection_Access) return Boolean is
Ok_Int :Interfaces.C.Int;
OK : Integer;
begin
if null = Connection then
return False;
end if;
Ok_Int := Nml_Valid(Connection.NML_C_Ptr);
OK := Integer(Ok_Int);
if OK = 1 then
return True;
else
return False;
end if;
end Valid;
procedure Nml_Set_To_Server_C;
pragma Import(C,Nml_Set_To_Server_C,"nml_set_to_server_c");
procedure Set_To_Server is
begin
Nml_Set_To_Server_C;
end Set_To_Server;
function Nml_Write(Nml : in Nml_C_T;
Message : in NmlMsg_Access;
NmlType : in Interfaces.C.Long;
Size : in Interfaces.C.Size_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Write,"nml_write");
function Write(Connection : in NmlConnection_Access; Message : in NmlMsg_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Write(Connection.NML_C_Ptr,Message,Message.NmlType,Message.Size);
returnvalue := Integer(I);
return ReturnValue;
end Write;
function Nml_Write_If_Read(Nml : in Nml_C_T;
Message : in NmlMsg_Access;
NmlType : in Interfaces.C.Long;
Size : in Interfaces.C.Size_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Write_If_Read,"nml_write_if_read");
function Write_If_Read(Connection : in NmlConnection_Access; Message : in NmlMsg_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Write_If_Read(Connection.NML_C_Ptr,Message,Message.NmlType,Message.Size);
returnvalue := Integer(I);
return ReturnValue;
end Write_If_Read;
function Nml_Read(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Read,"nml_read");
function Read(Connection : in NmlConnection_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Read(Connection.NML_C_Ptr);
returnvalue := Integer(I);
return ReturnValue;
end Read;
function Nml_Blocking_Read(Nml : in Nml_C_T;
Timeout : in Interfaces.C.Double)
return Interfaces.C.Int;
pragma Import(C,Nml_Blocking_Read,"nml_blocking_read");
function Blocking_Read(Connection : in NmlConnection_Access;
Timeout : in Interfaces.C.Double)
return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Blocking_Read(Connection.NML_C_Ptr,Timeout);
returnvalue := Integer(I);
return ReturnValue;
end Blocking_Read;
function Nml_Peek(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Peek,"nml_peek");
function Peek(Connection : in NmlConnection_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Peek(Connection.NML_C_Ptr);
returnvalue := Integer(I);
return ReturnValue;
end Peek;
function Nml_Get_Msg_Count(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Get_Msg_Count,"nml_get_msg_count");
function Get_Msg_Count(Connection : in NmlConnection_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Get_Msg_Count(Connection.NML_C_Ptr);
returnvalue := Integer(I);
return ReturnValue;
end Get_Msg_Count;
function Nml_Get_Queue_Length(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Get_Queue_Length,"nml_get_queue_length");
function Get_Queue_Length(Connection : in NmlConnection_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Get_Queue_Length(Connection.NML_C_Ptr);
returnvalue := Integer(I);
return ReturnValue;
end Get_Queue_Length;
function Nml_Get_Space_Available(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Get_Space_Available,"nml_get_space_available");
function Get_Space_Available(Connection : in NmlConnection_Access) return Integer is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
begin
I := Nml_Peek(Connection.NML_C_Ptr);
returnvalue := Integer(I);
return ReturnValue;
end Get_Space_Available;
function Nml_Get_Address(Nml : in Nml_C_T)
return NmlMsg_Access;
pragma Import(C,Nml_Get_Address,"nml_get_address");
function Get_Address(Connection : in NmlConnection_Access) return NmlMsg_Access is
begin
return Nml_Get_Address(Connection.NML_C_Ptr);
end Get_Address;
procedure Run_Nml_Servers_C;
pragma Import(C,Run_Nml_Servers_C,"run_nml_servers_c");
procedure Run_Servers is
begin
Run_Nml_Servers_C;
end Run_Servers;
procedure Nml_Free(Nml : in Nml_C_T);
pragma Import(C,Nml_Free,"nml_free");
procedure Finalize(Object : in out NmlConnection) is
begin
if Object.NML_C_Ptr /= null then
Nml_Free(Object.NML_C_Ptr);
Object.NML_C_Ptr := null;
end if;
end Finalize;
function Nml_Xml_Schema_Save_As(Connection : in NmlConnection_Access;
File_Name : in Interfaces.C.Strings.Chars_Ptr )
return Interfaces.C.Int;
pragma Import(C,Nml_Xml_Schema_Save_As,"nml_xml_schema_save_as");
procedure Save_Xml_Schema(Connection : in NmlConnection_Access;
File_Name : in String) is
C_Ptr : Interfaces.C.Strings.Chars_Ptr := Interfaces.C.Strings.New_String(File_Name);
Ok : Interfaces.C.Int := 0;
begin
Ok := Nml_Xml_Schema_Save_As(Connection,C_Ptr);
Interfaces.C.Strings.Free(C_Ptr);
end Save_Xml_Schema;
function Nml_Xml_Msg_Save_As(Nml : in Nml_C_T;
Message : in NmlMsg_Access;
NmlType : in Interfaces.C.Long;
Size : in Interfaces.C.Size_T;
ConfigFile : in Interfaces.C.Strings.Chars_Ptr)
return Interfaces.C.Int;
pragma Import(C,Nml_Xml_Msg_Save_As,"nml_xml_msg_save_as");
procedure Save_Xml_Msg(Connection : in NmlConnection_Access;
Message : in NmlMsg_Access;
File_Name : in String) is
ReturnValue : Integer := 0;
I : Interfaces.C.int;
C_Ptr : Interfaces.C.Strings.Chars_Ptr := Interfaces.C.Strings.New_String(File_Name);
begin
I := Nml_Xml_Msg_Save_As(Connection.NML_C_Ptr,Message,Message.NmlType,Message.Size,C_Ptr);
returnvalue := Integer(I);
end Save_Xml_Msg;
function nml_xml_msg_read_from_file(
Nml : in Nml_C_T;
File_Name : Interfaces.C.Strings.Chars_Ptr
) return Interfaces.C.Int;
pragma Import(C,Nml_Xml_Msg_Read_From_File,"nml_xml_msg_read_from_file");
function Read_Xml_Msg(Connection : in NmlConnection_Access;
File_Name : in String)
return Integer is
C_Ptr : Interfaces.C.Strings.Chars_Ptr := Interfaces.C.Strings.New_String(File_Name);
Ok_Int : Interfaces.C.Int;
Ok : Integer;
begin
Ok_Int := Nml_Xml_Msg_Read_From_File(Connection.NML_C_Ptr,C_Ptr);
Ok := Integer(Ok_Int);
return Ok;
end Read_Xml_Msg;
function Int_To_Enum_NML_ERROR_TYPE(enum_int: in int) return NML_ERROR_TYPE is
begin
case enum_int is
when 9 => return NML_INVALID_CONSTRUCTOR_ARG;
when 6 => return NML_NO_MASTER_ERROR;
when 11 => return NML_NO_FORMAT_FUNCTION;
when 2 => return NML_TIMED_OUT;
when 3 => return NML_INVALID_CONFIGURATION;
when 4 => return NML_FORMAT_ERROR;
when 12 => return NML_OUT_OF_MEMORY_ERROR;
when 10 => return NML_INTERRUPTED_OPERATION;
when 5 => return NML_INTERNAL_CMS_ERROR;
when 0 => return NML_NO_ERROR;
when 7 => return NML_INVALID_MESSAGE_ERROR;
when 1 => return NML_BUFFER_NOT_READ;
when 8 => return NML_QUEUE_FULL_ERROR;
when others => return Bad_NML_ERROR_TYPE_Value;
end case;
end Int_To_Enum_NML_ERROR_TYPE;
function Nml_Get_Last_Error_Type(Nml : in Nml_C_T)
return Interfaces.C.Int;
pragma Import(C,Nml_Get_Last_Error_Type,"nml_get_last_error_type");
function Get_Last_Error_Type(Connection : in NmlConnection_Access)
return NML_ERROR_TYPE is
begin
return Int_To_Enum_NML_ERROR_TYPE(Nml_Get_Last_Error_Type(Connection.NML_C_Ptr));
end Get_Last_Error_Type;
procedure Nml_Set_Print_Destination_C(Dest_Int : Int);
pragma Import(C,Nml_Set_Print_Destination_C,"nml_set_print_destination_c");
procedure Set_Print_Destination( T : RCS_PRINT_DESTINATION_TYPE) is
begin
case T is
when RCS_PRINT_TO_STDOUT => Nml_Set_Print_Destination_C(0);
when RCS_PRINT_TO_STDERR => Nml_Set_Print_Destination_C(1);
when RCS_PRINT_TO_NULL => Nml_Set_Print_Destination_C(2);
when RCS_PRINT_TO_FILE => Nml_Set_Print_Destination_C(4);
end case;
end Set_Print_Destination;
procedure Nml_Set_Print_File_C(Fn : Interfaces.C.Strings.Chars_Ptr);
pragma Import(C,Nml_Set_Print_File_C,"nml_set_print_file_c");
procedure Set_Print_File(File_Name :String) is
begin
Nml_Set_Print_File_C(Interfaces.C.Strings.New_String(File_Name));
end Set_Print_File;
procedure Nml_Debug_On_C;
pragma Import(C,Nml_Debug_On_C,"nml_debug_on_c");
procedure Debug_On is
begin
Nml_Debug_On_C;
end Debug_On;
procedure Nml_Debug_Off_C;
pragma Import(C,Nml_Debug_Off_C,"nml_debug_off_c");
procedure Debug_Off is
begin
Nml_Debug_Off_C;
end Debug_Off;
end Nml;
|
stcarrez/swagger-ada | Ada | 6,717 | adb | -----------------------------------------------------------------------
-- openapi-streams-forms -- x-www-form-urlencoded streams
-- Copyright (C) 2018, 2022, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body OpenAPI.Streams.Forms is
procedure Initialize (Stream : in out Output_Stream;
Buffer : in Util.Streams.Texts.Print_Stream_Access) is
begin
Stream.Stream := Buffer;
end Initialize;
-- ------------------------------
-- Flush the buffer (if any) to the sink.
-- ------------------------------
overriding
procedure Flush (Stream : in out Output_Stream) is
begin
Stream.Stream.Flush;
end Flush;
-- ------------------------------
-- Close the sink.
-- ------------------------------
overriding
procedure Close (Stream : in out Output_Stream) is
begin
Stream.Stream.Close;
end Close;
-- ------------------------------
-- Write the buffer array to the output stream.
-- ------------------------------
overriding
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array) is
begin
Stream.Stream.Write (Buffer);
end Write;
-- Write the attribute name/value pair.
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
if Stream.Has_Param then
Stream.Stream.Write ('&');
end if;
Stream.Has_Param := True;
Stream.Stream.Write (Name);
Stream.Stream.Write ('=');
Stream.Stream.Write (Value);
end Write_Attribute;
overriding
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
if Stream.Has_Param then
Stream.Stream.Write ('&');
end if;
Stream.Has_Param := True;
Stream.Stream.Write (Name);
Stream.Stream.Write ('=');
for C of Value loop
Stream.Stream.Write_Wide (C);
end loop;
end Write_Wide_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
if Stream.Has_Param then
Stream.Stream.Write ('&');
end if;
Stream.Has_Param := True;
Stream.Stream.Write (Name);
Stream.Stream.Write ('=');
Stream.Stream.Write (Util.Strings.Image (Value));
end Write_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
if Stream.Has_Param then
Stream.Stream.Write ('&');
end if;
Stream.Has_Param := True;
Stream.Stream.Write (Name);
Stream.Stream.Write ('=');
Stream.Stream.Write (if Value then "true" else "false");
end Write_Attribute;
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
null;
end Write_Attribute;
-- Write the attribute with a null value.
overriding
procedure Write_Null_Attribute (Stream : in out Output_Stream;
Name : in String) is
begin
null;
end Write_Null_Attribute;
-- Write the entity value.
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String) is
begin
Stream.Write_Wide_Attribute (Name, Value);
end Write_Wide_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer) is
begin
Stream.Write_Attribute (Name, Value);
end Write_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time) is
begin
null;
end Write_Entity;
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer) is
begin
null;
end Write_Long_Entity;
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Float) is
begin
null;
end Write_Long_Entity;
overriding
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String) is
begin
null;
end Write_Enum_Entity;
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
null;
end Write_Entity;
-- Write an entity with a null value.
overriding
procedure Write_Null_Entity (Stream : in out Output_Stream;
Name : in String) is
begin
null;
end Write_Null_Entity;
end OpenAPI.Streams.Forms;
|
reznikmm/matreshka | Ada | 3,890 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- 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.Strings.Hash;
package body WSDL.AST is
use type League.Strings.Universal_String;
----------
-- Hash --
----------
function Hash (Item : Qualified_Name) return Ada.Containers.Hash_Type is
begin
return League.Strings.Hash (Item.Namespace_URI & Item.Local_Name);
end Hash;
-----------
-- Image --
-----------
function Image
(Item : Qualified_Name) return League.Strings.Universal_String is
begin
return '{' & Item.Namespace_URI & '}' & Item.Local_Name;
end Image;
end WSDL.AST;
|
damaki/libkeccak | Ada | 5,004 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- 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.
-- * The name of the copyright holder may not 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 BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
package body Keccak.Generic_XOF
is
------------
-- Init --
------------
procedure Init (Ctx : out Context)
is
begin
XOF_Sponge.Init (Ctx.Sponge_Ctx, Capacity, Permutation_Initial_Value);
Ctx.Update_Complete := False;
end Init;
--------------
-- Update --
--------------
procedure Update (Ctx : in out Context;
Message : in Keccak.Types.Byte_Array;
Bit_Length : in Natural)
is
Num_Bytes : constant Natural := (Bit_Length + 7) / 8;
begin
pragma Assert (Num_Bytes <= Message'Length);
if Num_Bytes > 0 then
if Bit_Length mod 8 = 0 then
XOF_Sponge.Absorb (Ctx.Sponge_Ctx,
Message (Message'First ..
Message'First + (Num_Bytes - 1)),
Bit_Length);
else
XOF_Sponge.Absorb_With_Suffix (Ctx.Sponge_Ctx,
Message (Message'First ..
Message'First + (Num_Bytes - 1)),
Bit_Length,
Suffix,
Suffix_Size);
Ctx.Update_Complete := True;
end if;
end if;
end Update;
--------------
-- Update --
--------------
procedure Update (Ctx : in out Context;
Message : in Byte_Array)
is
Max_Chunk_Len : constant := (Natural'Last / 8) - 1;
Remaining : Natural := Message'Length;
Offset : Natural := 0;
begin
while Remaining >= Max_Chunk_Len loop
pragma Loop_Variant (Decreases => Remaining);
pragma Loop_Invariant (Remaining + Offset = Message'Length
and State_Of (Ctx) = Updating);
Update (Ctx,
Message (Message'First + Offset .. Message'First + Offset + (Max_Chunk_Len - 1)),
Max_Chunk_Len * 8);
Remaining := Remaining - Max_Chunk_Len;
Offset := Offset + Max_Chunk_Len;
end loop;
if Remaining > 0 then
pragma Assert_And_Cut (Remaining < Natural'Last / 8
and Offset + Remaining = Message'Length
and State_Of (Ctx) = Updating);
Update (Ctx,
Message (Message'First + Offset .. Message'Last),
Remaining * 8);
pragma Assert (State_Of (Ctx) = Updating);
end if;
end Update;
---------------
-- Extract --
---------------
procedure Extract (Ctx : in out Context;
Digest : out Byte_Array)
is
Empty_Array : constant Keccak.Types.Byte_Array (0 .. -1) := (others => 0);
begin
if State_Of (Ctx) = Updating then
XOF_Sponge.Absorb_With_Suffix (Ctx.Sponge_Ctx,
Empty_Array,
0,
Suffix,
Suffix_Size);
end if;
XOF_Sponge.Squeeze (Ctx.Sponge_Ctx, Digest);
end Extract;
end Keccak.Generic_XOF;
|
flyx/OpenGLAda | Ada | 487 | adb | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.API;
package body GL.Raster is
procedure Set_Pos (Position : Vector2) is
begin
API.Raster_Pos2 (Position);
end Set_Pos;
procedure Set_Pos (Position : Vector3) is
begin
API.Raster_Pos3 (Position);
end Set_Pos;
procedure Set_Pos (Position : Vector4) is
begin
API.Raster_Pos4 (Position);
end Set_Pos;
end GL.Raster;
|
swagger-api/swagger-codegen | Ada | 10,697 | adb | with Samples.Petstore.Clients;
with Samples.Petstore.Models;
with Swagger;
with Util.Http.Clients.Curl;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Calendar.Formatting;
with Ada.Strings.Unbounded;
with Ada.Exceptions;
procedure Test is
use Ada.Text_IO;
use type Ada.Strings.Unbounded.Unbounded_String;
procedure Usage;
procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type);
procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type);
procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type);
procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type);
procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type);
procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type);
procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Login (C : in out Samples.Petstore.Clients.Client_Type;
Username : in String;
Password : in String);
Server : constant Swagger.UString := Swagger.To_UString ("http://petstore.swagger.io/v2");
Arg_Count : constant Natural := Ada.Command_Line.Argument_Count;
Arg : Positive := 1;
procedure Usage is
begin
Put_Line ("Usage: petstore {list|add|rm|update} {user|order|pet} {params}...");
Put_Line (" get pet <id>... Print pet given its id");
Put_Line (" get user <name>... Print user given its name");
Put_Line (" get order <id>... Print order given its id");
Put_Line (" list pet <status>... List the pets with the given status");
Put_Line (" list inventory List the inventory");
Put_Line (" add pet <id> <name> <status> <category-id> <category-name");
Put_Line (" Add a pet");
Put_Line (" rm user <name>... Remove user with given name");
Put_Line (" rm order <id>... Remove order with given id");
Put_Line (" login <username> <password> Use login operation to get a session");
end Usage;
procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type) is
Need_Indent : Boolean := False;
begin
Put_Line ("Id : " & Swagger.Long'Image (Pet.Id.Value));
Put_Line ("Name : " & Swagger.To_String (Pet.Name));
Put_Line ("Status : " & Swagger.To_String (Pet.Status.Value));
if not Pet.Tags.Is_Empty then
Put ("Tags : ");
for Tag of Pet.Tags loop
Put_Line ((if Need_Indent then " " else "")
& Swagger.To_String (Tag.Name.Value));
Need_Indent := True;
end loop;
end if;
if not Pet.Photo_Urls.Is_Empty then
Need_Indent := False;
Put ("URLs : ");
for Url of Pet.Photo_Urls loop
Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Url.Value));
Need_Indent := True;
end loop;
end if;
end Print_Pet;
procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type) is
begin
Put_Line ("Id : " & Swagger.Long'Image (Order.Id.Value));
Put_Line ("Pet id : " & Swagger.Long'Image (Order.Pet_Id.Value));
Put_Line ("Quantity : " & Integer'Image (Order.Quantity.Value));
Put_Line ("Status : " & Swagger.To_String (Order.Status.Value));
Put_Line ("Ship date : " & Ada.Calendar.Formatting.Image (Order.Ship_Date.Value));
Put_Line ("Complete : " & Boolean'Image (Order.Complete.Value));
end Print_Order;
procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type) is
User : Samples.Petstore.Models.User_Type;
begin
for I in Arg .. Arg_Count loop
C.Get_User_By_Name (Swagger.To_UString (Ada.Command_Line.Argument (I)), User);
Put_Line ("Id : " & Swagger.Long'Image (User.Id.Value));
Put_Line ("Username : " & Swagger.To_String (User.Username.Value));
Put_Line ("Firstname: " & Swagger.To_String (User.First_Name.Value));
Put_Line ("Lastname : " & Swagger.To_String (User.Last_Name.Value));
Put_Line ("Email : " & Swagger.To_String (User.Email.Value));
Put_Line ("Password : " & Swagger.To_String (User.Password.Value));
Put_Line ("Phone : " & Swagger.To_String (User.Phone.Value));
end loop;
end Get_User;
procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pet : Samples.Petstore.Models.Pet_Type;
begin
C.Set_Server (Server);
for I in Arg .. Arg_Count loop
declare
P : constant String := Ada.Command_Line.Argument (I);
begin
C.Get_Pet_By_Id (Swagger.Long'Value (P), Pet);
Print_Pet (Pet);
end;
end loop;
end Get_Pet;
procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type) is
Order : Samples.Petstore.Models.Order_Type;
begin
C.Set_Server (Server);
for I in Arg .. Arg_Count loop
declare
P : constant String := Ada.Command_Line.Argument (I);
begin
C.Get_Order_By_Id (Swagger.Long'Value (P), Order);
Print_Order (Order);
end;
end loop;
end Get_Order;
procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pets : Samples.Petstore.Models.Pet_Type_Vectors.Vector;
begin
for I in Arg .. Arg_Count loop
declare
Status : Swagger.Nullable_UString_Vectors.Vector;
P : constant String := Ada.Command_Line.Argument (I);
begin
Status.Append ((Is_Null => False, Value => Swagger.To_UString (P)));
C.Find_Pets_By_Status (Status, Pets);
for Pet of Pets loop
Print_Pet (Pet);
end loop;
end;
end loop;
end List_Pet;
procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type) is
List : Swagger.Nullable_Integer_Map;
Iter : Swagger.Nullable_Integer_Maps.Cursor;
begin
C.Get_Inventory (List);
Ada.Text_IO.Put_Line ("Inventory size " & Natural'Image (Natural (List.Length)));
Iter := List.First;
while Swagger.Nullable_Integer_Maps.Has_Element (Iter) loop
Put (Swagger.Nullable_Integer_Maps.Key (Iter));
Set_Col (70);
Put_Line (Natural'Image (Swagger.Nullable_Integer_Maps.Element (Iter).Value));
Swagger.Nullable_Integer_Maps.Next (Iter);
end loop;
end List_Inventory;
procedure Login (C : in out Samples.Petstore.Clients.Client_Type;
Username : in String;
Password : in String) is
Session : Swagger.UString;
begin
C.Login_User (Swagger.To_UString (Username),
Swagger.To_UString (Password),
Session);
Put_Line ("New session : " & Swagger.To_String (Session));
end Login;
procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pet : Samples.Petstore.Models.Pet_Type;
begin
if Arg_Count /= 7 then
Put_Line ("Missing some arguments for add pet command");
Usage;
return;
end if;
Pet.Id := (Is_Null => False, Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg)));
Pet.Name := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 1));
Pet.Status := (Is_Null => False,
Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 2)));
Pet.Category.Id := (Is_Null => False,
Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg + 3)));
Pet.Category.Name := (Is_Null => False,
Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 4)));
C.Add_Pet (Pet);
end Add_Pet;
procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type) is
begin
for I in Arg .. Arg_Count loop
C.Delete_User (Username => Swagger.To_UString (Ada.Command_Line.Argument (I)));
end loop;
end Delete_User;
procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type) is
begin
for I in Arg .. Arg_Count loop
C.Delete_Order (Swagger.To_UString (Ada.Command_Line.Argument (I)));
end loop;
end Delete_Order;
procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Key : constant Swagger.UString := Swagger.To_UString (Ada.Command_Line.Argument (Arg));
begin
Arg := Arg + 1;
for I in Arg .. Arg_Count loop
C.Delete_Pet (Swagger.Long'Value (Ada.Command_Line.Argument (I)),
(Is_Null => False, Value => Key));
end loop;
end Delete_Pet;
begin
if Arg_Count <= 1 then
Usage;
return;
end if;
Util.Http.Clients.Curl.Register;
declare
Command : constant String := Ada.Command_Line.Argument (Arg);
Item : constant String := Ada.Command_Line.Argument (Arg + 1);
C : Samples.Petstore.Clients.Client_Type;
begin
C.Set_Server (Server);
Arg := Arg + 2;
if Command = "login" then
Login (C, Item, Ada.Command_Line.Argument (Arg));
elsif Command = "get" then
if Item = "user" then
Get_User (C);
elsif Item = "pet" then
Get_Pet (C);
elsif Item = "order" then
Get_Order (C);
else
Usage;
end if;
elsif Command = "list" then
if Item = "pet" then
List_Pet (C);
elsif Item = "inventory" then
List_Inventory (C);
else
Usage;
end if;
elsif Command = "add" then
if Item = "pet" then
Add_Pet (C);
else
Usage;
end if;
elsif Command = "rm" then
if Item = "user" then
Delete_User (C);
elsif Item = "order" then
Delete_Order (C);
elsif Item = "pet" then
Delete_Pet (C);
else
Usage;
end if;
elsif Command = "update" then
Usage;
else
Usage;
end if;
exception
when E : Constraint_Error =>
Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E));
end;
end Test;
|
RREE/build-avr-ada-toolchain | Ada | 10,836 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (AVR Version) --
-- --
-- Copyright (C) 1992-2007 Free Software Foundation, Inc. --
-- Copyright (C) 2004, 2010, 2012, 2015, 2019 Rolf Ebert --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
pragma Restrictions (No_Exception_Propagation);
-- Only local exception handling is supported in this profile
pragma Restrictions (No_Exception_Registration);
-- Disable exception name registration. This capability is not used because
-- it is only required by exception stream attributes which are not supported.
pragma Restrictions (No_Implicit_Dynamic_Code);
-- Pointers to nested subprograms are not allowed, in order
-- to prevent the compiler from building "trampolines".
pragma Restrictions (No_Finalization);
-- Controlled types are not supported in this run time
pragma Discard_Names;
-- Disable explicitly the generation of names associated with entities in
-- order to reduce the amount of storage used. These names are not used anyway
-- (attributes such as 'Image and 'Value are not supported in this run time).
package System 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).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := Long_Long_Integer'First;
Max_Int : constant := Long_Long_Integer'Last;
Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := 63;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 1.0;
-- Storage-related Declarations
Storage_Unit : constant := 8;
Word_Size : constant := 16;
Memory_Size : constant := 2 ** 16;
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := Low_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
Max_Priority : constant Positive := 245;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 245;
subtype Interrupt_Priority is Any_Priority range 246 .. 255;
Default_Priority : constant Priority := 122;
private
Run_Time_Name : constant String := "AVR Zero Footprint Run Time";
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Atomic_Sync_Default : constant Boolean := False;
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := False;
-- Set False if no command line arguments on target. Note that if this
-- is False in with Configurable_Run_Time_On_Target set to True, then
-- this causes suppression of generation of the argv/argc variables
-- used to record command line arguments.
Configurable_Run_Time : constant Boolean := True;
-- Indicates that the system.ads file is for a configurable run-time
--
-- In configurable run-time mode, the system run-time may not support
-- the full Ada language. The effect of setting this switch is to let
-- the compiler know that it is not surprising (i.e. the system is not
-- misconfigured) if run-time library units or entities within units are
-- not present in the run-time.
--
-- This has some specific effects as follows
--
-- The binder generates the gnat_argc/argv/envp variables in the
-- binder file instead of being imported from the run-time library.
-- If Command_Line_Args_On_Target is set to False, then the
-- generation of these variables is suppressed completely.
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := True;
Duration_Delta_Microseconds : constant := 1000;
-- If True, then Duration is represented in 32 bits and the delta
-- and small values are set to Duration_Delta_Microseconds*(10**(-6))
-- (i.e. for Duration_Delta_Microseconds = 20000 it is a count in
-- units of 20 milliseconds.
-- Duration_Delta_Microseconds must be named integer number.
Exit_Status_Supported : constant Boolean := False;
-- Set False if returning of an exit status is not supported on target.
-- Note that if this False in with Configurable_Run_Time_On_Target
-- set to True, then this causes suppression of the gnat_exit_status
-- variable used to record the exit status.
Fractional_Fixed_Ops : constant Boolean := False;
Frontend_Layout : constant Boolean := False;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
Signed_Zeros : constant Boolean := True;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := False;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Atomic_Primitives : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := True;
Suppress_Standard_Library : constant Boolean := True;
-- If this flag is True, then the standard library is not included by
-- default in the executable (see unit System.Standard_Library in file
-- s-stalib.ads for details of what this includes). This is for example
-- set True for the zero foot print case, where these files should not
-- be included by default.
--
-- This flag has some other related effects:
--
-- The generation of global variables in the bind file is suppressed,
-- with the exception of the priority of the environment task, which
-- is needed by the Ravenscar run-time.
--
-- The generation of exception tables is suppressed for front end
-- ZCX exception handling (since we assume no exception handling).
--
-- The calls to __gnat_initialize and __gnat_finalize are omitted
--
-- All finalization and initialization (controlled types) is omitted
--
-- The routine __gnat_handler_installed is not imported
Use_Ada_Main_Program_Name : constant Boolean := False;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := True;
GCC_ZCX_Support : constant Boolean := False;
end System;
|
AdaCore/libadalang | Ada | 308 | adb | procedure Test is
type Foo is record
Foo : Integer;
end record;
function Bar (I : Integer) return Foo is (Foo => I);
function Bar (I : Integer) return String is
X : Integer := Bar (12).Foo;
pragma Test_Statement;
begin
return "";
end Bar;
begin
null;
end Test;
|
zhmu/ananas | Ada | 111 | ads | package Opt79 is
type Arr is array (1 .. 8) of Integer;
function F (I : Integer) return Arr;
end Opt79;
|
charlie5/lace | Ada | 1,763 | ads | with
openGL.Geometry,
openGL.Texture;
package openGL.Model.hexagon_Column.lit_colored_textured_faceted
--
-- Models a lit, colored and textured column with 6 faceted shaft sides.
--
is
type Item is new Model.hexagon_Column.Item with private;
type View is access all Item'Class;
---------
--- Faces
--
type hex_Face is
record
center_Color : lucid_Color; -- The color of the center of the hex.
Colors : lucid_Colors (1 .. 6); -- The color of each of the faces 4 vertices.
Texture : asset_Name := openGL.null_Asset; -- The texture to be applied to the face.
end record;
type shaft_Face is
record
Color : lucid_Color; -- The color of the shaft.
Texture : asset_Name := null_Asset; -- The texture to be applied to the shaft.
end record;
---------
--- Forge
--
function new_hexagon_Column (Radius : in Real;
Height : in Real;
Upper,
Lower : in hex_Face;
Shaft : in shaft_Face) return View;
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views;
private
type Item is new Model.hexagon_Column.item with
record
upper_Face,
lower_Face : hex_Face;
Shaft : shaft_Face;
end record;
end openGL.Model.hexagon_Column.lit_colored_textured_faceted;
|
bmsauer/termbox-ada | Ada | 9,945 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
with Interfaces.C.Strings;
package x86_64_linux_gnu_bits_types_h is
-- bits/types.h -- definitions of __*_t types underlying *_t types.
-- Copyright (C) 2002-2018 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C Library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- The GNU C Library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with the GNU C Library; if not, see
-- <http://www.gnu.org/licenses/>.
-- * Never include this file directly; use <sys/types.h> instead.
--
-- Convenience types.
subtype uu_u_char is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:30
subtype uu_u_short is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:31
subtype uu_u_int is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:32
subtype uu_u_long is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:33
-- Fixed-size types, underlying types depend on word size and compiler.
subtype uu_int8_t is signed_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:36
subtype uu_uint8_t is unsigned_char; -- /usr/include/x86_64-linux-gnu/bits/types.h:37
subtype uu_int16_t is short; -- /usr/include/x86_64-linux-gnu/bits/types.h:38
subtype uu_uint16_t is unsigned_short; -- /usr/include/x86_64-linux-gnu/bits/types.h:39
subtype uu_int32_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:40
subtype uu_uint32_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:41
subtype uu_int64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:43
subtype uu_uint64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:44
-- quad_t is also 64 bits.
subtype uu_quad_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:52
subtype uu_u_quad_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:53
-- Largest integral types.
subtype uu_intmax_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:61
subtype uu_uintmax_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:62
-- The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
-- macros for each of the OS types we define below. The definitions
-- of those macros must use the following macros for underlying types.
-- We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
-- variants of each of the following integer types on this machine.
-- 16 -- "natural" 16-bit type (always short)
-- 32 -- "natural" 32-bit type (always int)
-- 64 -- "natural" 64-bit type (long or long long)
-- LONG32 -- 32-bit type, traditionally long
-- QUAD -- 64-bit type, always long long
-- WORD -- natural type of __WORDSIZE bits (int or long)
-- LONGWORD -- type of __WORDSIZE bits, traditionally long
-- We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
-- conventional uses of `long' or `long long' type modifiers match the
-- types we define, even when a less-adorned type would be the same size.
-- This matters for (somewhat) portably writing printf/scanf formats for
-- these types, where using the appropriate l or ll format modifiers can
-- make the typedefs and the formats match up across all GNU platforms. If
-- we used `long' when it's 64 bits where `long long' is expected, then the
-- compiler would warn about the formats not matching the argument types,
-- and the programmer changing them to shut up the compiler would break the
-- program's portability.
-- Here we assume what is presently the case in all the GCC configurations
-- we support: long long is always 64 bits, long is always word/address size,
-- and int is always 32 bits.
-- We want __extension__ before typedef's that use nonstandard base types
-- such as `long long' in C89 mode.
-- No need to mark the typedef with __extension__.
-- Defines __*_T_TYPE macros.
-- Type of device numbers.
subtype uu_dev_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:133
-- Type of user identifications.
subtype uu_uid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:134
-- Type of group identifications.
subtype uu_gid_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:135
-- Type of file serial numbers.
subtype uu_ino_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:136
-- Type of file serial numbers (LFS).
subtype uu_ino64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:137
-- Type of file attribute bitmasks.
subtype uu_mode_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:138
-- Type of file link counts.
subtype uu_nlink_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:139
-- Type of file sizes and offsets.
subtype uu_off_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:140
-- Type of file sizes and offsets (LFS).
subtype uu_off64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:141
-- Type of process identifications.
subtype uu_pid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:142
-- Type of file system IDs.
type uu_fsid_t_uu_val_array is array (0 .. 1) of aliased int;
type uu_fsid_t is record
uu_val : aliased uu_fsid_t_uu_val_array; -- /usr/include/x86_64-linux-gnu/bits/types.h:143
end record;
pragma Convention (C_Pass_By_Copy, uu_fsid_t); -- /usr/include/x86_64-linux-gnu/bits/types.h:143
-- skipped anonymous struct anon_0
-- Type of CPU usage counts.
subtype uu_clock_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:144
-- Type for resource measurement.
subtype uu_rlim_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:145
-- Type for resource measurement (LFS).
subtype uu_rlim64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:146
-- General type for IDs.
subtype uu_id_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:147
-- Seconds since the Epoch.
subtype uu_time_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:148
-- Count of microseconds.
subtype uu_useconds_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:149
-- Signed count of microseconds.
subtype uu_suseconds_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:150
-- The type of a disk address.
subtype uu_daddr_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:152
-- Type of an IPC key.
subtype uu_key_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:153
-- Clock ID used in clock and timer functions.
subtype uu_clockid_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:156
-- Timer ID returned by `timer_create'.
type uu_timer_t is new System.Address; -- /usr/include/x86_64-linux-gnu/bits/types.h:159
-- Type to represent block size.
subtype uu_blksize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:162
-- Types from the Large File Support interface.
-- Type to count number of disk blocks.
subtype uu_blkcnt_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:167
subtype uu_blkcnt64_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:168
-- Type to count file system blocks.
subtype uu_fsblkcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:171
subtype uu_fsblkcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:172
-- Type to count file system nodes.
subtype uu_fsfilcnt_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:175
subtype uu_fsfilcnt64_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:176
-- Type of miscellaneous file system fields.
subtype uu_fsword_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:179
-- Type of a byte count, or error.
subtype uu_ssize_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:181
-- Signed long type used in system calls.
subtype uu_syscall_slong_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:184
-- Unsigned long type used in system calls.
subtype uu_syscall_ulong_t is unsigned_long; -- /usr/include/x86_64-linux-gnu/bits/types.h:186
-- These few don't really vary by system, they always correspond
-- to one of the other defined types.
-- Type of file sizes and offsets (LFS).
subtype uu_loff_t is uu_off64_t; -- /usr/include/x86_64-linux-gnu/bits/types.h:190
type uu_caddr_t is new Interfaces.C.Strings.chars_ptr; -- /usr/include/x86_64-linux-gnu/bits/types.h:191
-- Duplicates info from stdint.h but this is used in unistd.h.
subtype uu_intptr_t is long; -- /usr/include/x86_64-linux-gnu/bits/types.h:194
-- Duplicate info from sys/socket.h.
subtype uu_socklen_t is unsigned; -- /usr/include/x86_64-linux-gnu/bits/types.h:197
-- C99: An integer type that can be accessed as an atomic entity,
-- even in the presence of asynchronous interrupts.
-- It is not currently necessary for this to be machine-specific.
subtype uu_sig_atomic_t is int; -- /usr/include/x86_64-linux-gnu/bits/types.h:202
end x86_64_linux_gnu_bits_types_h;
|
reznikmm/matreshka | Ada | 3,601 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Properties.Hash is
new AMF.Elements.Generic_Hash (UML_Property, UML_Property_Access);
|
sungyeon/drake | Ada | 256 | ads | pragma License (Unrestricted);
-- implementation unit
package System.Long_Long_Float_Types is
pragma Pure;
procedure Divide (
Left, Right : Long_Long_Float;
Quotient, Remainder : out Long_Long_Float);
end System.Long_Long_Float_Types;
|
AdaCore/libadalang | Ada | 610 | adb | procedure Test is
task T is
entry Start;
entry Foo (X : Integer);
entry Foo (X : Float);
end T;
task body T is
begin
accept Start do
null;
end Start;
--% node.p_corresponding_entry()
select
accept Foo (X : Float) do
null;
end Foo;
--% node.p_corresponding_entry()
accept Foo (X : Integer) do
null;
end Foo;
--% node.p_corresponding_entry()
end select;
end T;
task U is
entry Start;
end U;
task body U is separate;
begin
null;
end Test;
|
reznikmm/matreshka | Ada | 4,075 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 ODF.DOM.Style_Text_Overline_Mode_Attributes;
package Matreshka.ODF_Style.Text_Overline_Mode_Attributes is
type Style_Text_Overline_Mode_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Text_Overline_Mode_Attributes.ODF_Style_Text_Overline_Mode_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Text_Overline_Mode_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Text_Overline_Mode_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Text_Overline_Mode_Attributes;
|
reznikmm/matreshka | Ada | 4,959 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 XML.DOM.Visitors;
with ODF.DOM.Text_Note_Continuation_Notice_Forward_Elements;
package Matreshka.ODF_Text.Note_Continuation_Notice_Forward_Elements is
type Text_Note_Continuation_Notice_Forward_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Note_Continuation_Notice_Forward_Elements.ODF_Text_Note_Continuation_Notice_Forward
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Note_Continuation_Notice_Forward_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Note_Continuation_Notice_Forward_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Note_Continuation_Notice_Forward_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Note_Continuation_Notice_Forward_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Note_Continuation_Notice_Forward_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Note_Continuation_Notice_Forward_Elements;
|
reznikmm/matreshka | Ada | 4,559 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- 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 Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Form.Size_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Form_Size_Attribute_Node is
begin
return Self : Form_Size_Attribute_Node do
Matreshka.ODF_Form.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Form_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Form_Size_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Size_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Form_URI,
Matreshka.ODF_String_Constants.Size_Attribute,
Form_Size_Attribute_Node'Tag);
end Matreshka.ODF_Form.Size_Attributes;
|
apple-oss-distributions/old_ncurses | Ada | 3,045 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Form_Demo --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer <[email protected]> 1996
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
package Sample.Form_Demo is
procedure Demo;
end Sample.Form_Demo;
|
Gabriel-Degret/adalib | Ada | 937 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
generic
type Object (<>) is limited private;
package System.Address_To_Access_Conversions is
pragma Preelaborate (Address_To_Access_Conversions);
type Object_Pointer is access all Object;
function To_Pointer (Value : Address) return Object_Pointer;
function To_Address (Value : Object_Pointer) return Address;
pragma Convention (Intrinsic, To_Pointer);
pragma Convention (Intrinsic, To_Address);
end System.Address_To_Access_Conversions;
|
reznikmm/matreshka | Ada | 5,097 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.DI.Diagram_Elements.Collections is
pragma Preelaborate;
package DI_Diagram_Element_Collections is
new AMF.Generic_Collections
(DI_Diagram_Element,
DI_Diagram_Element_Access);
type Set_Of_DI_Diagram_Element is
new DI_Diagram_Element_Collections.Set with null record;
Empty_Set_Of_DI_Diagram_Element : constant Set_Of_DI_Diagram_Element;
type Ordered_Set_Of_DI_Diagram_Element is
new DI_Diagram_Element_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_DI_Diagram_Element : constant Ordered_Set_Of_DI_Diagram_Element;
type Bag_Of_DI_Diagram_Element is
new DI_Diagram_Element_Collections.Bag with null record;
Empty_Bag_Of_DI_Diagram_Element : constant Bag_Of_DI_Diagram_Element;
type Sequence_Of_DI_Diagram_Element is
new DI_Diagram_Element_Collections.Sequence with null record;
Empty_Sequence_Of_DI_Diagram_Element : constant Sequence_Of_DI_Diagram_Element;
private
Empty_Set_Of_DI_Diagram_Element : constant Set_Of_DI_Diagram_Element
:= (DI_Diagram_Element_Collections.Set with null record);
Empty_Ordered_Set_Of_DI_Diagram_Element : constant Ordered_Set_Of_DI_Diagram_Element
:= (DI_Diagram_Element_Collections.Ordered_Set with null record);
Empty_Bag_Of_DI_Diagram_Element : constant Bag_Of_DI_Diagram_Element
:= (DI_Diagram_Element_Collections.Bag with null record);
Empty_Sequence_Of_DI_Diagram_Element : constant Sequence_Of_DI_Diagram_Element
:= (DI_Diagram_Element_Collections.Sequence with null record);
end AMF.DI.Diagram_Elements.Collections;
|
burratoo/Acton | Ada | 15,039 | adb | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.AGENT.OAK_AGENT --
-- --
-- Copyright (C) 2013-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Oak.Oak_Time; use Oak.Oak_Time;
with Oak.Memory.Call_Stack.Ops; use Oak.Memory.Call_Stack.Ops;
with Interfaces; use Interfaces;
with Ada.Unchecked_Conversion;
package body Oak.Agent.Oak_Agent is
-----------------------
-- Local Subprograms --
-----------------------
procedure Set_Name
(Agent_Id : in Oak_Agent_Id;
Name : in String);
-- Sets the name of the Agent.
---------------------------
-- Charge_Execution_Time --
---------------------------
procedure Charge_Execution_Time
(To_Agent : in Oak_Agent_Id;
Exec_Time : in Oak_Time.Time_Span)
is
Agent : Oak_Agent_Record renames Agent_Pool (To_Agent);
begin
Agent.Current_Execution_Time := Agent.Current_Execution_Time + Exec_Time;
Agent.Total_Execution_Time := Agent.Total_Execution_Time + Exec_Time;
-- Only decrement remaining budget only if it does not contain
-- Time_Span_Last since that signifies that the Remaining_Budget
-- variable is not begining used.
if Agent.Remaining_Budget < Oak_Time.Time_Span_Last then
Agent.Remaining_Budget := Agent.Remaining_Budget - Exec_Time;
end if;
end Charge_Execution_Time;
-----------------------------------
-- Charge_Execution_Time_To_List --
-----------------------------------
procedure Charge_Execution_Time_To_List
(List : in Charge_List_Head;
Exec_Time : in Oak_Time.Time_Span;
Current_Agent : in Oak_Agent_Id;
Current_Priority : in Any_Priority)
is
Agent : Oak_Agent_Id := List;
begin
-- The first node on the charge list can be the No_Node (since it is
-- also the sleep node), so the check for the terminating No_Node is
-- done at the bottom.
loop
case Agent_Pool (Agent).When_To_Charge is
when Only_While_Running =>
if Agent = Current_Agent then
Charge_Execution_Time (Agent, Exec_Time);
end if;
when Same_Priority =>
if Current_Priority = Agent_Pool (Agent).Normal_Priority then
Charge_Execution_Time (Agent, Exec_Time);
end if;
when All_Priorities =>
Charge_Execution_Time (Agent, Exec_Time);
when At_Or_Below_Priority =>
if Current_Priority <= Agent_Pool (Agent).Normal_Priority then
Charge_Execution_Time (Agent, Exec_Time);
end if;
end case;
if Agent in Scheduler_Id or else Agent = No_Agent then
Increment_Execution_Cycle_Count (Agent);
end if;
Agent := Agent_Pool (Agent).Next_Charge_Agent;
exit when Agent = No_Agent;
end loop;
end Charge_Execution_Time_To_List;
----------------------
-- Copy_Oak_Message --
----------------------
procedure Copy_Oak_Message (Destination, Source : in Address) is
type Message_Array is
array (1 .. Oak_Message'Object_Size / Word_Size)
of Unsigned_32;
type Memptr is access Message_Array;
function To_Memptr is
new
Ada.Unchecked_Conversion (Address, Memptr);
Dest_P : constant Memptr := To_Memptr (Destination);
Src_P : constant Memptr := To_Memptr (Source);
begin
for J in Message_Array'Range loop
Dest_P (J) := Src_P (J);
end loop;
end Copy_Oak_Message;
------------------
-- Delete_Agent --
------------------
procedure Delete_Agent (Agent : Oak_Agent_Id) renames Deallocate_Agent;
------------------------------
-- Earliest_Expiring_Budget --
------------------------------
function Earliest_Expiring_Budget
(Charge_List : in Charge_List_Head;
Current_Priority : in Any_Priority)
return Oak_Agent_Id
is
Selected_Agent : Oak_Agent_Id := No_Agent;
Agent : Oak_Agent_Id := Charge_List;
begin
while Agent /= No_Agent loop
declare
A : Oak_Agent_Record renames Agent_Pool (Agent);
begin
if (A.When_To_Charge = Only_While_Running
or else A.When_To_Charge = All_Priorities
or else (A.When_To_Charge = Same_Priority
and then Current_Priority = A.Normal_Priority)
or else (A.When_To_Charge = At_Or_Below_Priority
and then Current_Priority <= A.Normal_Priority))
and then A.Remaining_Budget
< Agent_Pool (Selected_Agent).Remaining_Budget
then
Selected_Agent := Agent;
end if;
end;
Agent := Agent_Pool (Agent).Next_Charge_Agent;
end loop;
return
(if Agent_Pool (Selected_Agent).Remaining_Budget =
Oak_Time.Time_Span_Last
then
No_Agent else Selected_Agent);
end Earliest_Expiring_Budget;
-------------------------------------
-- Increment_Execution_Cycle_Count --
-------------------------------------
procedure Increment_Execution_Cycle_Count
(For_Agent : in Oak_Agent_Id;
By : in Natural := 1)
is
A : Oak_Agent_Record renames Agent_Pool (For_Agent);
begin
A.Execution_Cycles := A.Execution_Cycles + By;
if A.Current_Execution_Time > A.Max_Execution_Time then
A.Max_Execution_Time := A.Current_Execution_Time;
end if;
A.Last_Cycle := Previous_Cycle'Succ (A.Last_Cycle);
A.Cycle_Execution_Times (A.Last_Cycle) := A.Current_Execution_Time;
A.Current_Execution_Time := Oak_Time.Time_Span_Zero;
end Increment_Execution_Cycle_Count;
---------------
-- New_Agent --
---------------
procedure New_Agent
(Agent : in Oak_Agent_Id;
Name : in String;
Call_Stack_Address : in Address;
Call_Stack_Size : in Storage_Count;
Run_Loop : in Address;
Run_Loop_Parameter : in Address;
Normal_Priority : in Any_Priority;
Initial_State : in Agent_State;
Scheduler_Agent : in Scheduler_Id_With_No := No_Agent;
Wake_Time : in Oak_Time.Time := Oak_Time.Time_Last;
When_To_Charge_Agent : in Charge_Occurrence := All_Priorities)
is
A : Oak_Agent_Record renames Agent_Pool (Agent);
begin
Allocate_An_Agent_With_Id (Agent);
Set_Name (Agent, Name);
if Call_Stack_Address = Null_Address and Call_Stack_Size > 0 then
-- Allocate a call stack if needed.
Allocate_Call_Stack
(Stack => A.Call_Stack,
Size_In_Elements => Call_Stack_Size);
if Agent in Task_Id then
-- Scheduler agent only need their initial instruction set
Initialise_Call_Stack
(Stack => A.Call_Stack,
Start_Instruction => Run_Loop,
Task_Value_Record => Run_Loop_Parameter);
elsif Agent not in Kernel_Id then
-- Kernel agents do not have to have their call stacks
-- initialised here
Initialise_Call_Stack
(Stack => A.Call_Stack,
Start_Instruction => Run_Loop);
end if;
elsif Call_Stack_Address /= Null_Address then
-- Otherwise just assigned the passed stack
Initialise_Call_Stack
(Stack => A.Call_Stack,
Start_Instruction => Run_Loop,
Task_Value_Record => Run_Loop_Parameter,
Stack_Address => Call_Stack_Address,
Stack_Size => Call_Stack_Size);
end if;
A.Next_Agent := No_Agent;
A.Next_Charge_Agent := No_Agent;
A.State := Initial_State;
A.Normal_Priority := Normal_Priority;
A.Scheduler_Agent := Scheduler_Agent;
A.Wake_Time := Wake_Time;
A.Absolute_Deadline := Oak_Time.Time_Last;
A.Total_Execution_Time := Oak_Time.Time_Span_Zero;
A.Max_Execution_Time := Oak_Time.Time_Span_Zero;
A.Current_Execution_Time := Oak_Time.Time_Span_Zero;
A.Remaining_Budget := Oak_Time.Time_Span_Last;
A.Execution_Cycles := Natural'First;
A.Scheduler_Agent := Scheduler_Agent;
A.When_To_Charge := When_To_Charge_Agent;
if Agent in Task_Id then
A.Agent_Interrupted := True;
else
A.Agent_Interrupted := False;
end if;
end New_Agent;
---------------------------
-- Set_Agent_Interrupted --
---------------------------
procedure Set_Agent_Interrupted
(For_Agent : in Oak_Agent_Id;
Value : Boolean := True) is
begin
Agent_Pool (For_Agent).Agent_Interrupted := Value;
end Set_Agent_Interrupted;
---------------------------
-- Set_Absolute_Deadline --
---------------------------
procedure Set_Absolute_Deadline
(For_Agent : in Oak_Agent_Id;
Deadline : in Oak_Time.Time) is
begin
Agent_Pool (For_Agent).Absolute_Deadline := Deadline;
end Set_Absolute_Deadline;
-------------------------------
-- Set_Agent_Message_Address --
-------------------------------
procedure Set_Agent_Message_Address
(For_Agent : in Oak_Agent_Id;
Message_Address : in Address) is
begin
Agent_Pool (For_Agent).Agent_Message_Address := Message_Address;
end Set_Agent_Message_Address;
--------------------------------
-- Set_Current_Execution_Time --
--------------------------------
procedure Set_Current_Execution_Time
(For_Agent : in Oak_Agent_Id;
To : in Oak_Time.Time_Span) is
begin
Agent_Pool (For_Agent).Current_Execution_Time := To;
end Set_Current_Execution_Time;
----------------------------
-- Set_Max_Execution_Time --
----------------------------
procedure Set_Max_Execution_Time
(For_Agent : in Oak_Agent_Id;
To : in Oak_Time.Time_Span) is
begin
Agent_Pool (For_Agent).Max_Execution_Time := To;
end Set_Max_Execution_Time;
---------------------
-- Set_Oak_Message --
---------------------
procedure Set_Oak_Message
(For_Agent : in Oak_Agent_Id;
Message : in Oak_Message)
is
Message_Address : Address renames
Agent_Pool (For_Agent).Agent_Message_Address;
begin
if Message_Address /= Null_Address then
-- Cannot convert Message_Dest to a pointer since Ada makes
-- a mutable variant record immutable when it is accessed through
-- a pointer. So we brute force copy using Mem_Copy.
Copy_Oak_Message (Destination => Message_Address,
Source => Message'Address);
end if;
end Set_Oak_Message;
--------------
-- Set_Name --
--------------
procedure Set_Name
(Agent_Id : in Oak_Agent_Id;
Name : in String)
is
Agent : Oak_Agent_Record renames Agent_Pool (Agent_Id);
begin
Agent.Name_Length :=
Natural'Min (Name'Length, Agent.Name'Length);
Agent.Name (1 .. Agent.Name_Length) :=
Name (Name'First .. Name'First + Agent.Name_Length - 1);
end Set_Name;
--------------------
-- Set_Next_Agent --
--------------------
procedure Set_Next_Agent
(For_Agent : in Oak_Agent_Id;
Next_Agent : in Oak_Agent_Id) is
begin
Agent_Pool (For_Agent).Next_Agent := Next_Agent;
end Set_Next_Agent;
---------------------------
-- Set_Next_Charge_Agent --
---------------------------
procedure Set_Next_Charge_Agent
(For_Agent : in Oak_Agent_Id;
Next_Agent : in Oak_Agent_Id) is
begin
Agent_Pool (For_Agent).Next_Charge_Agent := Next_Agent;
end Set_Next_Charge_Agent;
--------------------------
-- Set_Remaining_Budget --
--------------------------
procedure Set_Remaining_Budget
(For_Agent : in Oak_Agent_Id;
To_Amount : in Oak_Time.Time_Span) is
begin
Agent_Pool (For_Agent).Remaining_Budget := To_Amount;
end Set_Remaining_Budget;
---------------------------------
-- Set_Secondary_Stack_Pointer --
---------------------------------
procedure Set_Secondary_Stack_Pointer
(For_Agent : in Oak_Agent_Id;
Pointer : in Address) is
begin
Agent_Pool (For_Agent).Call_Stack.Secondary_Stack_Pointer := Pointer;
end Set_Secondary_Stack_Pointer;
-------------------------
-- Set_Scheduler_Agent --
-------------------------
procedure Set_Scheduler_Agent
(For_Agent : in Oak_Agent_Id;
Scheduler : in Scheduler_Id_With_No) is
begin
Agent_Pool (For_Agent).Scheduler_Agent := Scheduler;
end Set_Scheduler_Agent;
-----------------------
-- Set_Stack_Pointer --
-----------------------
procedure Set_Stack_Pointer
(For_Agent : in Oak_Agent_Id;
Stack_Pointer : in System.Address) is
begin
Agent_Pool (For_Agent).Call_Stack.Pointer := Stack_Pointer;
end Set_Stack_Pointer;
---------------
-- Set_State --
---------------
procedure Set_State
(For_Agent : in Oak_Agent_Id;
State : in Agent_State) is
begin
Agent_Pool (For_Agent).State := State;
end Set_State;
-------------------
-- Set_Wake_Time --
-------------------
procedure Set_Wake_Time
(For_Agent : in Oak_Agent_Id;
Wake_Time : in Oak_Time.Time) is
begin
Agent_Pool (For_Agent).Wake_Time := Wake_Time;
end Set_Wake_Time;
-------------------
-- Setup_Storage --
-------------------
procedure Setup_Storage is
begin
Oak_Agent_Pool.Setup_Storage;
end Setup_Storage;
--------------------------------
-- Replenish_Execution_Budget --
--------------------------------
procedure Replenish_Execution_Budget
(For_Agent : in Oak_Agent_Id;
By_Amount : in Oak_Time.Time_Span)
is
Agent : Oak_Agent_Record renames Agent_Pool (For_Agent);
begin
Agent.Remaining_Budget := Agent.Remaining_Budget + By_Amount;
end Replenish_Execution_Budget;
end Oak.Agent.Oak_Agent;
|
reznikmm/matreshka | Ada | 4,084 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- 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 Matreshka.Internals.SQL_Drivers.Firebird.Databases;
package body Matreshka.Internals.SQL_Drivers.Firebird.Factory is
type Firebird_Factory is new Abstract_Factory with null record;
overriding function Create
(Self : not null access Firebird_Factory) return not null Database_Access;
------------
-- Create --
------------
overriding function Create
(Self : not null access Firebird_Factory) return not null Database_Access is
begin
return new Databases.Firebird_Database;
end Create;
use type Interfaces.C.int;
Factory : aliased Firebird_Factory;
begin
Register (League.Strings.To_Universal_String ("FIREBIRD"), Factory'Access);
end Matreshka.Internals.SQL_Drivers.Firebird.Factory;
|
persan/A-gst | Ada | 11,392 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
-- with GStreamer.GST_Low_Level.glib_2_0_gobject_gobject_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gqueue_h;
with System;
-- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h;
with glib;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstdataqueue_h is
-- unsupported macro: GST_TYPE_DATA_QUEUE (gst_data_queue_get_type())
-- arg-macro: function GST_DATA_QUEUE (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue);
-- arg-macro: function GST_DATA_QUEUE_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass);
-- arg-macro: function GST_IS_DATA_QUEUE (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE);
-- arg-macro: function GST_IS_DATA_QUEUE_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE);
-- GStreamer
-- * Copyright (C) 2006 Edward Hervey <[email protected]>
-- *
-- * gstdataqueue.h:
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
type GstDataQueue;
type anon_311;
type anon_312 is record
waiting_add : aliased GLIB.gboolean; -- gst/base/gstdataqueue.h:140
waiting_del : aliased GLIB.gboolean; -- gst/base/gstdataqueue.h:141
end record;
pragma Convention (C_Pass_By_Copy, anon_312);
type u_GstDataQueue_u_gst_reserved_array is array (0 .. 1) of System.Address;
type anon_311 (discr : unsigned := 0) is record
case discr is
when 0 =>
ABI : aliased anon_312; -- gst/base/gstdataqueue.h:142
when others =>
u_gst_reserved : u_GstDataQueue_u_gst_reserved_array; -- gst/base/gstdataqueue.h:143
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_311);
pragma Unchecked_Union (anon_311);--subtype GstDataQueue is u_GstDataQueue; -- gst/base/gstdataqueue.h:39
type GstDataQueueClass;
type u_GstDataQueueClass_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstDataQueueClass is u_GstDataQueueClass; -- gst/base/gstdataqueue.h:40
type GstDataQueueSize;
--subtype GstDataQueueSize is u_GstDataQueueSize; -- gst/base/gstdataqueue.h:41
type GstDataQueueItem;
--subtype GstDataQueueItem is u_GstDataQueueItem; -- gst/base/gstdataqueue.h:42
--*
-- * GstDataQueueItem:
-- * @object: the #GstMiniObject to queue.
-- * @size: the size in bytes of the miniobject.
-- * @duration: the duration in #GstClockTime of the miniobject. Can not be
-- * #GST_CLOCK_TIME_NONE.
-- * @visible: #TRUE if @object should be considered as a visible object.
-- * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
-- * This function should also drop the reference to @object the owner of the
-- * #GstDataQueueItem is assumed to hold.
-- *
-- * Structure used by #GstDataQueue. You can supply a different structure, as
-- * long as the top of the structure is identical to this structure.
-- *
-- * Since: 0.10.11
--
type GstDataQueueItem is record
object : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstminiobject_h.GstMiniObject; -- gst/base/gstdataqueue.h:63
size : aliased GLIB.guint; -- gst/base/gstdataqueue.h:64
duration : aliased GLIB.guint64; -- gst/base/gstdataqueue.h:65
visible : aliased GLIB.gboolean; -- gst/base/gstdataqueue.h:66
destroy : GStreamer.GST_Low_Level.glib_2_0_glib_gtypes_h.GDestroyNotify; -- gst/base/gstdataqueue.h:69
end record;
pragma Convention (C_Pass_By_Copy, GstDataQueueItem); -- gst/base/gstdataqueue.h:61
-- user supplied destroy function
--*
-- * GstDataQueueSize:
-- * @visible: number of buffers
-- * @bytes: number of bytes
-- * @time: amount of time
-- *
-- * Structure describing the size of a queue.
-- *
-- * Since: 0.10.11
--
type GstDataQueueSize is record
visible : aliased GLIB.guint; -- gst/base/gstdataqueue.h:84
bytes : aliased GLIB.guint; -- gst/base/gstdataqueue.h:85
time : aliased GLIB.guint64; -- gst/base/gstdataqueue.h:86
end record;
pragma Convention (C_Pass_By_Copy, GstDataQueueSize); -- gst/base/gstdataqueue.h:82
--*
-- * GstDataQueueCheckFullFunction:
-- * @queue: a #GstDataQueue.
-- * @visible: The number of visible items currently in the queue.
-- * @bytes: The amount of bytes currently in the queue.
-- * @time: The accumulated duration of the items currently in the queue.
-- * @checkdata: The #gpointer registered when the #GstDataQueue was created.
-- *
-- * The prototype of the function used to inform the queue that it should be
-- * considered as full.
-- *
-- * Returns: #TRUE if the queue should be considered full.
-- *
-- * Since: 0.10.11
--
type GstDataQueueCheckFullFunction is access function
(arg1 : access GstDataQueue;
arg2 : GLIB.guint;
arg3 : GLIB.guint;
arg4 : GLIB.guint64;
arg5 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstDataQueueCheckFullFunction); -- gst/base/gstdataqueue.h:104
type GstDataQueueFullCallback is access procedure (arg1 : access GstDataQueue; arg2 : System.Address);
pragma Convention (C, GstDataQueueFullCallback); -- gst/base/gstdataqueue.h:107
type GstDataQueueEmptyCallback is access procedure (arg1 : access GstDataQueue; arg2 : System.Address);
pragma Convention (C, GstDataQueueEmptyCallback); -- gst/base/gstdataqueue.h:108
--*
-- * GstDataQueue:
-- * @object: the parent structure
-- *
-- * Opaque #GstDataQueue structure.
-- *
-- * Since: 0.10.11
--
type GstDataQueue is record
object : aliased GLIB.Object.GObject; -- gst/base/gstdataqueue.h:120
queue : access GStreamer.GST_Low_Level.glib_2_0_glib_gqueue_h.GQueue; -- gst/base/gstdataqueue.h:124
cur_level : aliased GstDataQueueSize; -- gst/base/gstdataqueue.h:126
checkfull : GstDataQueueCheckFullFunction; -- gst/base/gstdataqueue.h:127
checkdata : System.Address; -- gst/base/gstdataqueue.h:128
qlock : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/base/gstdataqueue.h:130
item_add : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/base/gstdataqueue.h:131
item_del : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GCond; -- gst/base/gstdataqueue.h:132
flushing : aliased GLIB.gboolean; -- gst/base/gstdataqueue.h:133
fullcallback : GstDataQueueFullCallback; -- gst/base/gstdataqueue.h:135
emptycallback : GstDataQueueEmptyCallback; -- gst/base/gstdataqueue.h:136
abidata : aliased anon_311; -- gst/base/gstdataqueue.h:144
end record;
pragma Convention (C_Pass_By_Copy, GstDataQueue); -- gst/base/gstdataqueue.h:118
--< private >
-- the queue of data we're keeping our grubby hands on
-- size of the queue
-- Callback to check if the queue is full
-- lock for queue (vs object lock)
-- signals buffers now available for reading
-- signals space now available for writing
-- indicates whether conditions where signalled because
-- * of external flushing
type GstDataQueueClass is record
parent_class : aliased GLIB.Object.GObject_Class; -- gst/base/gstdataqueue.h:149
empty : access procedure (arg1 : access GstDataQueue); -- gst/base/gstdataqueue.h:152
full : access procedure (arg1 : access GstDataQueue); -- gst/base/gstdataqueue.h:153
u_gst_reserved : u_GstDataQueueClass_u_gst_reserved_array; -- gst/base/gstdataqueue.h:155
end record;
pragma Convention (C_Pass_By_Copy, GstDataQueueClass); -- gst/base/gstdataqueue.h:147
-- signals
function gst_data_queue_get_type return GLIB.GType; -- gst/base/gstdataqueue.h:158
pragma Import (C, gst_data_queue_get_type, "gst_data_queue_get_type");
function gst_data_queue_new (checkfull : GstDataQueueCheckFullFunction; checkdata : System.Address) return access GstDataQueue; -- gst/base/gstdataqueue.h:160
pragma Import (C, gst_data_queue_new, "gst_data_queue_new");
function gst_data_queue_new_full
(checkfull : GstDataQueueCheckFullFunction;
fullcallback : GstDataQueueFullCallback;
emptycallback : GstDataQueueEmptyCallback;
checkdata : System.Address) return access GstDataQueue; -- gst/base/gstdataqueue.h:163
pragma Import (C, gst_data_queue_new_full, "gst_data_queue_new_full");
function gst_data_queue_push (queue : access GstDataQueue; item : access GstDataQueueItem) return GLIB.gboolean; -- gst/base/gstdataqueue.h:168
pragma Import (C, gst_data_queue_push, "gst_data_queue_push");
function gst_data_queue_pop (queue : access GstDataQueue; item : System.Address) return GLIB.gboolean; -- gst/base/gstdataqueue.h:169
pragma Import (C, gst_data_queue_pop, "gst_data_queue_pop");
procedure gst_data_queue_flush (queue : access GstDataQueue); -- gst/base/gstdataqueue.h:171
pragma Import (C, gst_data_queue_flush, "gst_data_queue_flush");
procedure gst_data_queue_set_flushing (queue : access GstDataQueue; flushing : GLIB.gboolean); -- gst/base/gstdataqueue.h:172
pragma Import (C, gst_data_queue_set_flushing, "gst_data_queue_set_flushing");
function gst_data_queue_drop_head (queue : access GstDataQueue; c_type : GLIB.GType) return GLIB.gboolean; -- gst/base/gstdataqueue.h:174
pragma Import (C, gst_data_queue_drop_head, "gst_data_queue_drop_head");
function gst_data_queue_is_full (queue : access GstDataQueue) return GLIB.gboolean; -- gst/base/gstdataqueue.h:176
pragma Import (C, gst_data_queue_is_full, "gst_data_queue_is_full");
function gst_data_queue_is_empty (queue : access GstDataQueue) return GLIB.gboolean; -- gst/base/gstdataqueue.h:177
pragma Import (C, gst_data_queue_is_empty, "gst_data_queue_is_empty");
procedure gst_data_queue_get_level (queue : access GstDataQueue; level : access GstDataQueueSize); -- gst/base/gstdataqueue.h:179
pragma Import (C, gst_data_queue_get_level, "gst_data_queue_get_level");
procedure gst_data_queue_limits_changed (queue : access GstDataQueue); -- gst/base/gstdataqueue.h:180
pragma Import (C, gst_data_queue_limits_changed, "gst_data_queue_limits_changed");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstdataqueue_h;
|
mirror/ncurses | Ada | 31,187 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Menus --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2018,2020 Thomas E. Dickey --
-- Copyright 1999-2011,2014 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.34 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C.Pointers;
package body Terminal_Interface.Curses.Menus is
type C_Item_Array is array (Natural range <>) of aliased Item;
package I_Array is new
Interfaces.C.Pointers (Natural, Item, C_Item_Array, Null_Item);
subtype chars_ptr is Interfaces.C.Strings.chars_ptr;
------------------------------------------------------------------------------
procedure Request_Name (Key : Menu_Request_Code;
Name : out String)
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
Fill_String (Request_Name (C_Int (Key)), Name);
end Request_Name;
function Request_Name (Key : Menu_Request_Code) return String
is
function Request_Name (Key : C_Int) return chars_ptr;
pragma Import (C, Request_Name, "menu_request_name");
begin
return Fill_String (Request_Name (C_Int (Key)));
end Request_Name;
function Create (Name : String;
Description : String := "") return Item
is
type Char_Ptr is access all Interfaces.C.char;
function Newitem (Name, Desc : Char_Ptr) return Item;
pragma Import (C, Newitem, "new_item");
type Name_String is new char_array (0 .. Name'Length);
type Name_String_Ptr is access Name_String;
pragma Controlled (Name_String_Ptr);
type Desc_String is new char_array (0 .. Description'Length);
type Desc_String_Ptr is access Desc_String;
pragma Controlled (Desc_String_Ptr);
Name_Str : constant Name_String_Ptr := new Name_String;
Desc_Str : constant Desc_String_Ptr := new Desc_String;
Name_Len, Desc_Len : size_t;
Result : Item;
begin
To_C (Name, Name_Str.all, Name_Len);
To_C (Description, Desc_Str.all, Desc_Len);
Result := Newitem (Name_Str.all (Name_Str.all'First)'Access,
Desc_Str.all (Desc_Str.all'First)'Access);
if Result = Null_Item then
raise Eti_System_Error;
end if;
return Result;
end Create;
procedure Delete (Itm : in out Item)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
function Freeitem (Itm : Item) return Eti_Error;
pragma Import (C, Freeitem, "free_item");
Ptr : chars_ptr;
begin
Ptr := Descname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Ptr := Itemname (Itm);
if Ptr /= Null_Ptr then
Interfaces.C.Strings.Free (Ptr);
end if;
Eti_Exception (Freeitem (Itm));
Itm := Null_Item;
end Delete;
-------------------------------------------------------------------------------
procedure Set_Value (Itm : Item;
Value : Boolean := True)
is
function Set_Item_Val (Itm : Item;
Val : C_Int) return Eti_Error;
pragma Import (C, Set_Item_Val, "set_item_value");
begin
Eti_Exception (Set_Item_Val (Itm, Boolean'Pos (Value)));
end Set_Value;
function Value (Itm : Item) return Boolean
is
function Item_Val (Itm : Item) return C_Int;
pragma Import (C, Item_Val, "item_value");
begin
if Item_Val (Itm) = Curses_False then
return False;
else
return True;
end if;
end Value;
-------------------------------------------------------------------------------
function Visible (Itm : Item) return Boolean
is
function Item_Vis (Itm : Item) return C_Int;
pragma Import (C, Item_Vis, "item_visible");
begin
if Item_Vis (Itm) = Curses_False then
return False;
else
return True;
end if;
end Visible;
-------------------------------------------------------------------------------
procedure Set_Options (Itm : Item;
Options : Item_Option_Set)
is
function Set_Item_Opts (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Set_Item_Opts, "set_item_opts");
begin
Eti_Exception (Set_Item_Opts (Itm, Options));
end Set_Options;
procedure Switch_Options (Itm : Item;
Options : Item_Option_Set;
On : Boolean := True)
is
function Item_Opts_On (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_On, "item_opts_on");
function Item_Opts_Off (Itm : Item;
Opt : Item_Option_Set) return Eti_Error;
pragma Import (C, Item_Opts_Off, "item_opts_off");
begin
if On then
Eti_Exception (Item_Opts_On (Itm, Options));
else
Eti_Exception (Item_Opts_Off (Itm, Options));
end if;
end Switch_Options;
procedure Get_Options (Itm : Item;
Options : out Item_Option_Set)
is
function Item_Opts (Itm : Item) return Item_Option_Set;
pragma Import (C, Item_Opts, "item_opts");
begin
Options := Item_Opts (Itm);
end Get_Options;
function Get_Options (Itm : Item := Null_Item) return Item_Option_Set
is
Ios : Item_Option_Set;
begin
Get_Options (Itm, Ios);
return Ios;
end Get_Options;
-------------------------------------------------------------------------------
procedure Name (Itm : Item;
Name : out String)
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
Fill_String (Itemname (Itm), Name);
end Name;
function Name (Itm : Item) return String
is
function Itemname (Itm : Item) return chars_ptr;
pragma Import (C, Itemname, "item_name");
begin
return Fill_String (Itemname (Itm));
end Name;
procedure Description (Itm : Item;
Description : out String)
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
Fill_String (Descname (Itm), Description);
end Description;
function Description (Itm : Item) return String
is
function Descname (Itm : Item) return chars_ptr;
pragma Import (C, Descname, "item_description");
begin
return Fill_String (Descname (Itm));
end Description;
-------------------------------------------------------------------------------
procedure Set_Current (Men : Menu;
Itm : Item)
is
function Set_Curr_Item (Men : Menu;
Itm : Item) return Eti_Error;
pragma Import (C, Set_Curr_Item, "set_current_item");
begin
Eti_Exception (Set_Curr_Item (Men, Itm));
end Set_Current;
function Current (Men : Menu) return Item
is
function Curr_Item (Men : Menu) return Item;
pragma Import (C, Curr_Item, "current_item");
Res : constant Item := Curr_Item (Men);
begin
if Res = Null_Item then
raise Menu_Exception;
end if;
return Res;
end Current;
procedure Set_Top_Row (Men : Menu;
Line : Line_Position)
is
function Set_Toprow (Men : Menu;
Line : C_Int) return Eti_Error;
pragma Import (C, Set_Toprow, "set_top_row");
begin
Eti_Exception (Set_Toprow (Men, C_Int (Line)));
end Set_Top_Row;
function Top_Row (Men : Menu) return Line_Position
is
function Toprow (Men : Menu) return C_Int;
pragma Import (C, Toprow, "top_row");
Res : constant C_Int := Toprow (Men);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Line_Position (Res);
end Top_Row;
function Get_Index (Itm : Item) return Positive
is
function Get_Itemindex (Itm : Item) return C_Int;
pragma Import (C, Get_Itemindex, "item_index");
Res : constant C_Int := Get_Itemindex (Itm);
begin
if Res = Curses_Err then
raise Menu_Exception;
end if;
return Positive (Natural (Res) + Positive'First);
end Get_Index;
-------------------------------------------------------------------------------
procedure Post (Men : Menu;
Post : Boolean := True)
is
function M_Post (Men : Menu) return Eti_Error;
pragma Import (C, M_Post, "post_menu");
function M_Unpost (Men : Menu) return Eti_Error;
pragma Import (C, M_Unpost, "unpost_menu");
begin
if Post then
Eti_Exception (M_Post (Men));
else
Eti_Exception (M_Unpost (Men));
end if;
end Post;
-------------------------------------------------------------------------------
procedure Set_Options (Men : Menu;
Options : Menu_Option_Set)
is
function Set_Menu_Opts (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Set_Menu_Opts, "set_menu_opts");
begin
Eti_Exception (Set_Menu_Opts (Men, Options));
end Set_Options;
procedure Switch_Options (Men : Menu;
Options : Menu_Option_Set;
On : Boolean := True)
is
function Menu_Opts_On (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_On, "menu_opts_on");
function Menu_Opts_Off (Men : Menu;
Opt : Menu_Option_Set) return Eti_Error;
pragma Import (C, Menu_Opts_Off, "menu_opts_off");
begin
if On then
Eti_Exception (Menu_Opts_On (Men, Options));
else
Eti_Exception (Menu_Opts_Off (Men, Options));
end if;
end Switch_Options;
procedure Get_Options (Men : Menu;
Options : out Menu_Option_Set)
is
function Menu_Opts (Men : Menu) return Menu_Option_Set;
pragma Import (C, Menu_Opts, "menu_opts");
begin
Options := Menu_Opts (Men);
end Get_Options;
function Get_Options (Men : Menu := Null_Menu) return Menu_Option_Set
is
Mos : Menu_Option_Set;
begin
Get_Options (Men, Mos);
return Mos;
end Get_Options;
-------------------------------------------------------------------------------
procedure Set_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Win (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Win, "set_menu_win");
begin
Eti_Exception (Set_Menu_Win (Men, Win));
end Set_Window;
function Get_Window (Men : Menu) return Window
is
function Menu_Win (Men : Menu) return Window;
pragma Import (C, Menu_Win, "menu_win");
W : constant Window := Menu_Win (Men);
begin
return W;
end Get_Window;
procedure Set_Sub_Window (Men : Menu;
Win : Window)
is
function Set_Menu_Sub (Men : Menu;
Win : Window) return Eti_Error;
pragma Import (C, Set_Menu_Sub, "set_menu_sub");
begin
Eti_Exception (Set_Menu_Sub (Men, Win));
end Set_Sub_Window;
function Get_Sub_Window (Men : Menu) return Window
is
function Menu_Sub (Men : Menu) return Window;
pragma Import (C, Menu_Sub, "menu_sub");
W : constant Window := Menu_Sub (Men);
begin
return W;
end Get_Sub_Window;
procedure Scale (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function M_Scale (Men : Menu;
Yp, Xp : C_Int_Access) return Eti_Error;
pragma Import (C, M_Scale, "scale_menu");
X, Y : aliased C_Int;
begin
Eti_Exception (M_Scale (Men, Y'Access, X'Access));
Lines := Line_Count (Y);
Columns := Column_Count (X);
end Scale;
-------------------------------------------------------------------------------
procedure Position_Cursor (Men : Menu)
is
function Pos_Menu_Cursor (Men : Menu) return Eti_Error;
pragma Import (C, Pos_Menu_Cursor, "pos_menu_cursor");
begin
Eti_Exception (Pos_Menu_Cursor (Men));
end Position_Cursor;
-------------------------------------------------------------------------------
procedure Set_Mark (Men : Menu;
Mark : String)
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Mark (Men : Menu;
Mark : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Mark, "set_menu_mark");
Txt : char_array (0 .. Mark'Length);
Len : size_t;
begin
To_C (Mark, Txt, Len);
Eti_Exception (Set_Mark (Men, Txt (Txt'First)'Access));
end Set_Mark;
procedure Mark (Men : Menu;
Mark : out String)
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
Fill_String (Get_Menu_Mark (Men), Mark);
end Mark;
function Mark (Men : Menu) return String
is
function Get_Menu_Mark (Men : Menu) return chars_ptr;
pragma Import (C, Get_Menu_Mark, "menu_mark");
begin
return Fill_String (Get_Menu_Mark (Men));
end Mark;
-------------------------------------------------------------------------------
procedure Set_Foreground
(Men : Menu;
Fore : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Fore (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Fore, "set_menu_fore");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Fore);
begin
Eti_Exception (Set_Menu_Fore (Men, Ch));
end Set_Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
end Foreground;
procedure Foreground (Men : Menu;
Fore : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Fore (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Fore, "menu_fore");
begin
Fore := Menu_Fore (Men).Attr;
Color := Menu_Fore (Men).Color;
end Foreground;
procedure Set_Background
(Men : Menu;
Back : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Back (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Back, "set_menu_back");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Back);
begin
Eti_Exception (Set_Menu_Back (Men, Ch));
end Set_Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
end Background;
procedure Background (Men : Menu;
Back : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Back (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Back, "menu_back");
begin
Back := Menu_Back (Men).Attr;
Color := Menu_Back (Men).Color;
end Background;
procedure Set_Grey (Men : Menu;
Grey : Character_Attribute_Set := Normal_Video;
Color : Color_Pair := Color_Pair'First)
is
function Set_Menu_Grey (Men : Menu;
Attr : Attributed_Character) return Eti_Error;
pragma Import (C, Set_Menu_Grey, "set_menu_grey");
Ch : constant Attributed_Character := (Ch => Character'First,
Color => Color,
Attr => Grey);
begin
Eti_Exception (Set_Menu_Grey (Men, Ch));
end Set_Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
end Grey;
procedure Grey (Men : Menu;
Grey : out Character_Attribute_Set;
Color : out Color_Pair)
is
function Menu_Grey (Men : Menu) return Attributed_Character;
pragma Import (C, Menu_Grey, "menu_grey");
begin
Grey := Menu_Grey (Men).Attr;
Color := Menu_Grey (Men).Color;
end Grey;
procedure Set_Pad_Character (Men : Menu;
Pad : Character := Space)
is
function Set_Menu_Pad (Men : Menu;
Ch : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Pad, "set_menu_pad");
begin
Eti_Exception (Set_Menu_Pad (Men, C_Int (Character'Pos (Pad))));
end Set_Pad_Character;
procedure Pad_Character (Men : Menu;
Pad : out Character)
is
function Menu_Pad (Men : Menu) return C_Int;
pragma Import (C, Menu_Pad, "menu_pad");
begin
Pad := Character'Val (Menu_Pad (Men));
end Pad_Character;
-------------------------------------------------------------------------------
procedure Set_Spacing (Men : Menu;
Descr : Column_Position := 0;
Row : Line_Position := 0;
Col : Column_Position := 0)
is
function Set_Spacing (Men : Menu;
D, R, C : C_Int) return Eti_Error;
pragma Import (C, Set_Spacing, "set_menu_spacing");
begin
Eti_Exception (Set_Spacing (Men,
C_Int (Descr),
C_Int (Row),
C_Int (Col)));
end Set_Spacing;
procedure Spacing (Men : Menu;
Descr : out Column_Position;
Row : out Line_Position;
Col : out Column_Position)
is
type C_Int_Access is access all C_Int;
function Get_Spacing (Men : Menu;
D, R, C : C_Int_Access) return Eti_Error;
pragma Import (C, Get_Spacing, "menu_spacing");
D, R, C : aliased C_Int;
begin
Eti_Exception (Get_Spacing (Men,
D'Access,
R'Access,
C'Access));
Descr := Column_Position (D);
Row := Line_Position (R);
Col := Column_Position (C);
end Spacing;
-------------------------------------------------------------------------------
function Set_Pattern (Men : Menu;
Text : String) return Boolean
is
type Char_Ptr is access all Interfaces.C.char;
function Set_Pattern (Men : Menu;
Pattern : Char_Ptr) return Eti_Error;
pragma Import (C, Set_Pattern, "set_menu_pattern");
S : char_array (0 .. Text'Length);
L : size_t;
Res : Eti_Error;
begin
To_C (Text, S, L);
Res := Set_Pattern (Men, S (S'First)'Access);
case Res is
when E_No_Match =>
return False;
when others =>
Eti_Exception (Res);
return True;
end case;
end Set_Pattern;
procedure Pattern (Men : Menu;
Text : out String)
is
function Get_Pattern (Men : Menu) return chars_ptr;
pragma Import (C, Get_Pattern, "menu_pattern");
begin
Fill_String (Get_Pattern (Men), Text);
end Pattern;
-------------------------------------------------------------------------------
procedure Set_Format (Men : Menu;
Lines : Line_Count;
Columns : Column_Count)
is
function Set_Menu_Fmt (Men : Menu;
Lin : C_Int;
Col : C_Int) return Eti_Error;
pragma Import (C, Set_Menu_Fmt, "set_menu_format");
begin
Eti_Exception (Set_Menu_Fmt (Men,
C_Int (Lines),
C_Int (Columns)));
end Set_Format;
procedure Format (Men : Menu;
Lines : out Line_Count;
Columns : out Column_Count)
is
type C_Int_Access is access all C_Int;
function Menu_Fmt (Men : Menu;
Y, X : C_Int_Access) return Eti_Error;
pragma Import (C, Menu_Fmt, "menu_format");
L, C : aliased C_Int;
begin
Eti_Exception (Menu_Fmt (Men, L'Access, C'Access));
Lines := Line_Count (L);
Columns := Column_Count (C);
end Format;
-------------------------------------------------------------------------------
procedure Set_Item_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Init, "set_item_init");
begin
Eti_Exception (Set_Item_Init (Men, Proc));
end Set_Item_Init_Hook;
procedure Set_Item_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Item_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Item_Term, "set_item_term");
begin
Eti_Exception (Set_Item_Term (Men, Proc));
end Set_Item_Term_Hook;
procedure Set_Menu_Init_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Init (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Init, "set_menu_init");
begin
Eti_Exception (Set_Menu_Init (Men, Proc));
end Set_Menu_Init_Hook;
procedure Set_Menu_Term_Hook (Men : Menu;
Proc : Menu_Hook_Function)
is
function Set_Menu_Term (Men : Menu;
Proc : Menu_Hook_Function) return Eti_Error;
pragma Import (C, Set_Menu_Term, "set_menu_term");
begin
Eti_Exception (Set_Menu_Term (Men, Proc));
end Set_Menu_Term_Hook;
function Get_Item_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Init, "item_init");
begin
return Item_Init (Men);
end Get_Item_Init_Hook;
function Get_Item_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Item_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Item_Term, "item_term");
begin
return Item_Term (Men);
end Get_Item_Term_Hook;
function Get_Menu_Init_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Init (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Init, "menu_init");
begin
return Menu_Init (Men);
end Get_Menu_Init_Hook;
function Get_Menu_Term_Hook (Men : Menu) return Menu_Hook_Function
is
function Menu_Term (Men : Menu) return Menu_Hook_Function;
pragma Import (C, Menu_Term, "menu_term");
begin
return Menu_Term (Men);
end Get_Menu_Term_Hook;
-------------------------------------------------------------------------------
procedure Redefine (Men : Menu;
Items : Item_Array_Access)
is
function Set_Items (Men : Menu;
Items : System.Address) return Eti_Error;
pragma Import (C, Set_Items, "set_menu_items");
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
Eti_Exception (Set_Items (Men, Items.all'Address));
end if;
end Redefine;
function Item_Count (Men : Menu) return Natural
is
function Count (Men : Menu) return C_Int;
pragma Import (C, Count, "item_count");
begin
return Natural (Count (Men));
end Item_Count;
function Items (Men : Menu;
Index : Positive) return Item
is
use I_Array;
function C_Mitems (Men : Menu) return Pointer;
pragma Import (C, C_Mitems, "menu_items");
P : Pointer := C_Mitems (Men);
begin
if P = null or else Index > Item_Count (Men) then
raise Menu_Exception;
else
P := P + ptrdiff_t (C_Int (Index) - 1);
return P.all;
end if;
end Items;
-------------------------------------------------------------------------------
function Create (Items : Item_Array_Access) return Menu
is
function Newmenu (Items : System.Address) return Menu;
pragma Import (C, Newmenu, "new_menu");
M : Menu;
begin
pragma Assert (Items.all (Items'Last) = Null_Item);
if Items.all (Items'Last) /= Null_Item then
raise Menu_Exception;
else
M := Newmenu (Items.all'Address);
if M = Null_Menu then
raise Menu_Exception;
end if;
return M;
end if;
end Create;
procedure Delete (Men : in out Menu)
is
function Free (Men : Menu) return Eti_Error;
pragma Import (C, Free, "free_menu");
begin
Eti_Exception (Free (Men));
Men := Null_Menu;
end Delete;
------------------------------------------------------------------------------
function Driver (Men : Menu;
Key : Key_Code) return Driver_Result
is
function Driver (Men : Menu;
Key : C_Int) return Eti_Error;
pragma Import (C, Driver, "menu_driver");
R : constant Eti_Error := Driver (Men, C_Int (Key));
begin
case R is
when E_Unknown_Command =>
return Unknown_Request;
when E_No_Match =>
return No_Match;
when E_Request_Denied | E_Not_Selectable =>
return Request_Denied;
when others =>
Eti_Exception (R);
return Menu_Ok;
end case;
end Driver;
procedure Free (IA : in out Item_Array_Access;
Free_Items : Boolean := False)
is
procedure Release is new Ada.Unchecked_Deallocation
(Item_Array, Item_Array_Access);
begin
if IA /= null and then Free_Items then
for I in IA'First .. (IA'Last - 1) loop
if IA.all (I) /= Null_Item then
Delete (IA.all (I));
end if;
end loop;
end if;
Release (IA);
end Free;
-------------------------------------------------------------------------------
function Default_Menu_Options return Menu_Option_Set
is
begin
return Get_Options (Null_Menu);
end Default_Menu_Options;
function Default_Item_Options return Item_Option_Set
is
begin
return Get_Options (Null_Item);
end Default_Item_Options;
-------------------------------------------------------------------------------
end Terminal_Interface.Curses.Menus;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.