repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
AdaCore/libadalang | Ada | 39 | adb | procedure P1 is
begin
null;
end P1;
|
Irvise/Ada_Scheme_Example | Ada | 477 | adb |
package body Scheme_Test is
function Hello_Ada(Num : Int) return Int is
Len : Int;
begin
Len := Num;
Len := Len + 1;
Put_Line ("Hello Scheme, from Ada.");
Put_Line ("The number passed is: " & Num'Image);
-- Can we call Scheme directly here?
Len := Hello_Scheme("How is the weather in your interpreter?");
Put_Line("String length sent to Scheme, as computed by Scheme is: " & Len'Image);
return(Len);
end Hello_Ada;
end Scheme_Test;
|
reznikmm/matreshka | Ada | 6,861 | 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.Even_Rows_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Even_Rows_Element_Node is
begin
return Self : Table_Even_Rows_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_Even_Rows_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_Even_Rows
(ODF.DOM.Table_Even_Rows_Elements.ODF_Table_Even_Rows_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_Even_Rows_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Even_Rows_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Even_Rows_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_Even_Rows
(ODF.DOM.Table_Even_Rows_Elements.ODF_Table_Even_Rows_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_Even_Rows_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_Even_Rows
(Visitor,
ODF.DOM.Table_Even_Rows_Elements.ODF_Table_Even_Rows_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.Even_Rows_Element,
Table_Even_Rows_Element_Node'Tag);
end Matreshka.ODF_Table.Even_Rows_Elements;
|
sf17k/sdlada | Ada | 3,441 | adb | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2014-2015 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces.C.Strings;
with SDL.Error;
with System;
package body SDL.Libraries is
package C renames Interfaces.C;
procedure Load (Self : out Handles; Name : in String) is
function SDL_Load_Object (C_Str : in C.Strings.chars_ptr) return Internal_Handle_Access with
Import => True,
Convention => C,
External_Name => "SDL_LoadObject";
C_Str : C.Strings.chars_ptr := C.Strings.New_String (Name);
begin
Self.Internal := SDL_Load_Object (C_Str);
C.Strings.Free (C_Str);
if Self.Internal = null then
raise Library_Error with SDL.Error.Get;
end if;
end Load;
procedure Unload (Self : in out Handles) is
procedure SDL_Unload_Object (H : in Internal_Handle_Access) with
Import => True,
Convention => C,
External_Name => "SDL_UnloadObject";
begin
SDL_Unload_Object (Self.Internal);
Self.Internal := null;
end Unload;
function Load_Sub_Program (From_Library : in Handles) return Access_To_Sub_Program is
-- TODO: How can I get rid of this Address use?
function To_Sub_Program is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Access_To_Sub_Program);
function SDL_Load_Function (H : in Internal_Handle_Access; N : in C.Strings.chars_ptr)
return System.Address with
Import => True,
Convention => C,
External_Name => "SDL_LoadFunction";
C_Str : C.Strings.chars_ptr := C.Strings.New_String (Name);
Func_Ptr : constant System.Address := SDL_Load_Function (From_Library.Internal, C_Str);
use type System.Address;
begin
C.Strings.Free (C_Str);
if Func_Ptr = System.Null_Address then
raise Library_Error with SDL.Error.Get;
end if;
-- return To_Sub_Program (Func_Ptr);
return To_Sub_Program (Func_Ptr);
end Load_Sub_Program;
overriding
procedure Finalize (Self : in out Handles) is
begin
-- In case the user has already called Unload or Finalize on a derived type.
if Self.Internal /= null then
Unload (Self);
end if;
end Finalize;
end SDL.Libraries;
|
apple-oss-distributions/old_ncurses | Ada | 4,117 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.IntField --
-- --
-- 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.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Interfaces.C;
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.IntField is
use type Interfaces.C.int;
procedure Set_Field_Type (Fld : in Field;
Typ : in Integer_Field)
is
C_Integer_Field_Type : C_Field_Type;
pragma Import (C, C_Integer_Field_Type, "TYPE_INTEGER");
function Set_Fld_Type (F : Field := Fld;
Cft : C_Field_Type := C_Integer_Field_Type;
Arg1 : C_Int;
Arg2 : C_Long_Int;
Arg3 : C_Long_Int) return C_Int;
pragma Import (C, Set_Fld_Type, "set_field_type");
Res : Eti_Error;
begin
Res := Set_Fld_Type (Arg1 => C_Int (Typ.Precision),
Arg2 => C_Long_Int (Typ.Lower_Limit),
Arg3 => C_Long_Int (Typ.Upper_Limit));
if Res /= E_Ok then
Eti_Exception (Res);
end if;
Wrap_Builtin (Fld, Typ);
end Set_Field_Type;
end Terminal_Interface.Curses.Forms.Field_Types.IntField;
|
reznikmm/matreshka | Ada | 4,666 | 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$
------------------------------------------------------------------------------
package Matreshka.ODF_Elements.Office.Styles is
type Office_Styles_Node is
new Matreshka.ODF_Elements.Office.Office_Node_Base with null record;
type Office_Styles_Access is access all Office_Styles_Node'Class;
overriding procedure Enter_Element
(Self : not null access Office_Styles_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Local_Name
(Self : not null access constant Office_Styles_Node)
return League.Strings.Universal_String;
overriding procedure Leave_Element
(Self : not null access Office_Styles_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Office_Styles_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements.Office.Styles;
|
reznikmm/matreshka | Ada | 4,651 | 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_Span_Elements;
package Matreshka.ODF_Text.Span_Elements is
type Text_Span_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Span_Elements.ODF_Text_Span
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Span_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Span_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Span_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_Span_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_Span_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.Span_Elements;
|
AdaCore/Ada_Drivers_Library | Ada | 4,520 | 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 System;
-- nRF51 reference description for radio MCU with ARM 32-bit Cortex-M0
-- Microcontroller at 16MHz CPU clock
package NRF_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
POWER_Base : constant System.Address := System'To_Address (16#40000000#);
CLOCK_Base : constant System.Address := System'To_Address (16#40000000#);
MPU_Base : constant System.Address := System'To_Address (16#40000000#);
AMLI_Base : constant System.Address := System'To_Address (16#40000000#);
RADIO_Base : constant System.Address := System'To_Address (16#40001000#);
UART0_Base : constant System.Address := System'To_Address (16#40002000#);
SPI0_Base : constant System.Address := System'To_Address (16#40003000#);
TWI0_Base : constant System.Address := System'To_Address (16#40003000#);
SPI1_Base : constant System.Address := System'To_Address (16#40004000#);
TWI1_Base : constant System.Address := System'To_Address (16#40004000#);
SPIS1_Base : constant System.Address := System'To_Address (16#40004000#);
SPIM1_Base : constant System.Address := System'To_Address (16#40004000#);
GPIOTE_Base : constant System.Address := System'To_Address (16#40006000#);
ADC_Base : constant System.Address := System'To_Address (16#40007000#);
TIMER0_Base : constant System.Address := System'To_Address (16#40008000#);
TIMER1_Base : constant System.Address := System'To_Address (16#40009000#);
TIMER2_Base : constant System.Address := System'To_Address (16#4000A000#);
RTC0_Base : constant System.Address := System'To_Address (16#4000B000#);
TEMP_Base : constant System.Address := System'To_Address (16#4000C000#);
RNG_Base : constant System.Address := System'To_Address (16#4000D000#);
ECB_Base : constant System.Address := System'To_Address (16#4000E000#);
AAR_Base : constant System.Address := System'To_Address (16#4000F000#);
CCM_Base : constant System.Address := System'To_Address (16#4000F000#);
WDT_Base : constant System.Address := System'To_Address (16#40010000#);
RTC1_Base : constant System.Address := System'To_Address (16#40011000#);
QDEC_Base : constant System.Address := System'To_Address (16#40012000#);
LPCOMP_Base : constant System.Address := System'To_Address (16#40013000#);
SWI_Base : constant System.Address := System'To_Address (16#40014000#);
NVMC_Base : constant System.Address := System'To_Address (16#4001E000#);
PPI_Base : constant System.Address := System'To_Address (16#4001F000#);
FICR_Base : constant System.Address := System'To_Address (16#10000000#);
UICR_Base : constant System.Address := System'To_Address (16#10001000#);
GPIO_Base : constant System.Address := System'To_Address (16#50000000#);
end NRF_SVD;
|
onox/orka | Ada | 2,952 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 onox <[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 Orka.Transforms.Doubles.Quaternions;
with Orka.Transforms.Doubles.Vectors;
private with Orka.Numerics.Doubles.Tensors.CPU;
private with Orka.Numerics.Kalman.CDKF;
private package AWT.IMUs is
pragma Preelaborate;
package Quaternions renames Orka.Transforms.Doubles.Quaternions;
package Vectors renames Orka.Transforms.Doubles.Vectors;
type Estimated_State is record
Orientation : Quaternions.Quaternion;
Angular_Velocity : Vectors.Direction;
end record;
-- Estimated true angular velocity is (pitch up, yaw left, roll left) in rad/s
type IMU is tagged private;
procedure Integrate
(Object : in out IMU;
Velocity : Vectors.Direction;
Acceleration : Vectors.Vector4;
DT : Duration;
State : out Estimated_State;
Calibrated : out Boolean);
-- Perform numerical integration using the given angular velocity and linear acceleration
--
-- Angular velocity should be (pitch up, yaw left, roll left, 0) in rad/s
-- and linear acceleration should be (right, up, forward, 0) in g's where
-- g is the gravitational acceleration constant (1 g = 9.81 m/s^2).
procedure Initialize
(Object : in out IMU;
Orientation : Quaternions.Quaternion := Quaternions.Identity);
-- Initialize the whole filter and reset the orientation to
-- the given value
--
-- To reset the orientation at any time after having initialized
-- the IMU, call procedure Reset.
procedure Reset
(Object : in out IMU;
Orientation : Quaternions.Quaternion := Quaternions.Identity);
-- Reset the orientation to the given value
private
use Orka.Numerics.Doubles.Tensors.CPU;
package Kalman is new Orka.Numerics.Kalman (Orka.Numerics.Doubles.Tensors, CPU_Tensor);
package CDKF is new Kalman.CDKF;
type Direction_Array is array (Positive range <>) of Vectors.Direction;
type IMU is tagged record
Filter : Kalman.Filter
(Kind => Kalman.Filter_CDKF,
Dimension_X => 7,
Dimension_Z => 3);
-- Measurements of angular velocity to calibrate gyro bias
Velocity_Measurements : Direction_Array (1 .. 1_000);
Velocity_Index : Natural;
end record;
end AWT.IMUs;
|
reznikmm/matreshka | Ada | 10,267 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling 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 Qt4.Actions;
with Qt4.Menus.Constructors;
with Qt4.Styles;
with AMF.DC;
package body Modeler.Diagram_Items is
use type Qt4.Q_Real;
-------------------
-- Attribute_Set --
-------------------
overriding procedure Attribute_Set
(Self : not null access Diagram_Item;
Element : not null AMF.Elements.Element_Access;
Property : not null AMF.CMOF.Properties.CMOF_Property_Access;
Position : AMF.Optional_Integer;
Old_Value : League.Holders.Holder;
New_Value : League.Holders.Holder)
is
use type AMF.Optional_String;
begin
if Property.Get_Name = +"bounds" then
-- Notify about change of item's geometry.
Self.Prepare_Geometry_Change;
end if;
end Attribute_Set;
-------------------
-- Bounding_Rect --
-------------------
overriding function Bounding_Rect
(Self : not null access constant Diagram_Item)
return Qt4.Rect_Fs.Q_Rect_F
is
Bounds : constant AMF.DC.Optional_DC_Bounds
:= Self.Element.Get_Bounds;
begin
if Bounds.Is_Empty then
return Qt4.Rect_Fs.Create;
else
return
Qt4.Rect_Fs.Create
(Qt4.Q_Real (Bounds.Value.X),
Qt4.Q_Real (Bounds.Value.Y),
Qt4.Q_Real (Bounds.Value.Width),
Qt4.Q_Real (Bounds.Value.Height));
end if;
end Bounding_Rect;
------------------
-- Constructors --
------------------
package body Constructors is
procedure Initialize
(Self : not null access Diagram_Item'Class;
Diagram :
not null access AMF.UMLDI.UML_Diagrams.UMLDI_UML_Diagram'Class;
Parent : access Qt4.Graphics_Items.Q_Graphics_Item'Class);
------------
-- Create --
------------
function Create
(Diagram :
not null access AMF.UMLDI.UML_Diagrams.UMLDI_UML_Diagram'Class;
Parent : access Qt4.Graphics_Items.Q_Graphics_Item'Class := null)
return not null Diagram_Item_Access is
begin
return Self : constant not null Diagram_Item_Access
:= new Diagram_Item
do
Initialize (Self, Diagram, Parent);
Self.Set_Flag (Qt4.Graphics_Items.Item_Is_Selectable);
end return;
end Create;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : not null access Diagram_Item'Class;
Diagram :
not null access AMF.UMLDI.UML_Diagrams.UMLDI_UML_Diagram'Class;
Parent : access Qt4.Graphics_Items.Q_Graphics_Item'Class) is
begin
Qt4.Graphics_Items.Directors.Constructors.Initialize (Self, Parent);
Self.Element := Diagram;
AMF.Listeners.Register_Instance_Listener
(AMF.Listeners.Listener_Access (Self),
AMF.Elements.Element_Access (Diagram));
-- GNAT Pro 7.1w (20120405): explicit type conversion is needed to
-- workaround compiler's bug.
end Initialize;
end Constructors;
------------------------
-- Context_Menu_Event --
------------------------
overriding procedure Context_Menu_Event
(Self : not null access Diagram_Item;
Event : not null access
Qt4.Graphics_Scene_Context_Menu_Events.Q_Graphics_Scene_Context_Menu_Event'Class)
is
Action : Qt4.Actions.Q_Action_Access;
Menu : Qt4.Menus.Q_Menu_Access;
begin
Event.Set_Accepted (True);
Menu := Qt4.Menus.Constructors.Create;
Action := Menu.Add_Action (+"Create");
Action := Menu.Exec (Event.Screen_Pos);
Menu.Delete_Later;
end Context_Menu_Event;
-----------
-- Paint --
-----------
overriding procedure Paint
(Self : not null access Diagram_Item;
Painter : in out Qt4.Painters.Q_Painter'Class;
Option :
Qt4.Style_Option_Graphics_Items.Q_Style_Option_Graphics_Item'Class;
Widget : access Qt4.Widgets.Q_Widget'Class := null)
is
State : constant Qt4.Styles.State := Option.State;
--------------------
-- Draw_Selection --
--------------------
procedure Draw_Selection (X, Y, Width, Height, Scale : Qt4.Q_Real) is
Offset : constant Qt4.Q_Real := 2.0 / Scale;
Offset_2 : constant Qt4.Q_Real := 2.0 * Offset;
Offset_3 : constant Qt4.Q_Real := 3.0 / Scale;
One : constant Qt4.Q_Real := 1.0 / Scale;
Size : constant Qt4.Q_Real := 4.0 / Scale;
X2 : constant Qt4.Q_Real := (X + Width) / 2.0;
Y2 : constant Qt4.Q_Real := (Y + Height) / 2.0;
Size2 : constant Qt4.Q_Real := Size / 2.0;
begin
Painter.Draw_Rect
(Qt4.Rect_Fs.Create
(X - Offset, Y - Offset, Width + Offset_2, Height + Offset_2));
Painter.Fill_Rect
(Qt4.Rect_Fs.Create
(X - Offset - Size + One + One,
Y - Offset - Size + One + One,
Size,
Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create (X + Width, Y + Height + One, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create
(X + Width, Y - Offset - Size + One + One, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create
(X - Offset - Size + One + One, Y + Height + One, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create
(X2 - Size2, Y - Offset - Size + One + One, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create (X + Width, Y2 - Size2, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create (X2 - Size2, Y + Height + One, Size, Size),
Qt4.Solid_Pattern);
Painter.Fill_Rect
(Qt4.Rect_Fs.Create
(X - Offset - Size + One + One, Y2 - Size2, Size, Size),
Qt4.Solid_Pattern);
end Draw_Selection;
Bounds : constant AMF.DC.Optional_DC_Bounds
:= Self.Element.Get_Bounds;
begin
if Bounds.Is_Empty then
return;
end if;
Painter.Draw_Rect
(Qt4.Rect_Fs.Create
(Qt4.Q_Real (Bounds.Value.X),
Qt4.Q_Real (Bounds.Value.Y),
Qt4.Q_Real (Bounds.Value.Width),
Qt4.Q_Real (Bounds.Value.Height)));
-- Draw selection rectangle.
if Qt4.Styles.Is_Set (State, Qt4.Styles.State_Selected) then
Draw_Selection
(Qt4.Q_Real (Bounds.Value.X),
Qt4.Q_Real (Bounds.Value.Y),
Qt4.Q_Real (Bounds.Value.Width),
Qt4.Q_Real (Bounds.Value.Height),
Qt4.Style_Option_Graphics_Items.Level_Of_Detail_From_Transform
(Painter.World_Transform));
end if;
end Paint;
end Modeler.Diagram_Items;
|
stcarrez/ada-css | Ada | 1,061 | ads | -----------------------------------------------------------------------
-- css-reports -- CSS Reports
-- 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.
-----------------------------------------------------------------------
with CSS.Printer;
with CSS.Analysis.Classes;
package CSS.Reports.Docs is
procedure Print (Stream : in out CSS.Printer.File_Type'Class;
Data : in CSS.Analysis.Classes.Map);
end CSS.Reports.Docs;
|
reznikmm/matreshka | Ada | 4,786 | 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$
------------------------------------------------------------------------------
package Matreshka.ODF_Elements.Style.Table_Row_Properties is
type Style_Table_Row_Properties_Node is
new Matreshka.ODF_Elements.Style.Style_Node_Base with null record;
type Style_Table_Row_Properties_Access is
access all Style_Table_Row_Properties_Node'Class;
overriding procedure Enter_Element
(Self : not null access Style_Table_Row_Properties_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding function Get_Local_Name
(Self : not null access constant Style_Table_Row_Properties_Node)
return League.Strings.Universal_String;
overriding procedure Leave_Element
(Self : not null access Style_Table_Row_Properties_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access Style_Table_Row_Properties_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);
-- Dispatch call to corresponding subprogram of iterator interface.
end Matreshka.ODF_Elements.Style.Table_Row_Properties;
|
ne-oss/urban-os | Ada | 1,492 | adb | -- {{Ada/Sourceforge|to_lower_1.adb}}
pragma License (Gpl);
pragma Ada_95;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Characters.Handling;
procedure To_Lower_1 is
package CL renames Ada.Command_Line;
package T_IO renames Ada.Text_IO;
function To_Lower (Str : String) return String;
Value : constant String := CL.Argument (1);
function To_Lower (C : Character) return Character renames
Ada.Characters.Handling.To_Lower;
-- tolower - translates all alphabetic, uppercase characters
-- in str to lowercase
function To_Lower (Str : String) return String is
Result : String (Str'Range) := (others => ' ');
begin
for C in Str'Range loop
Result (C) := To_Lower (Str (C));
end loop;
return Result;
end To_Lower;
begin
T_IO.Put ("The lower case of ");
T_IO.Put (Value);
T_IO.Put (" is ");
T_IO.Put (To_Lower (Value));
return;
end To_Lower_1;
----------------------------------------------------------------------------
-- $Author: krischik $
--
-- $Revision: 226 $
-- $Date: 2007-12-02 15:11:44 +0000 (Sun, 02 Dec 2007) $
--
-- $Id: to_lower_1.adb 226 2007-12-02 15:11:44Z krischik $
-- $HeadURL: file:///svn/p/wikibook-ada/code/trunk/demos/Source/to_lower_1.adb $
----------------------------------------------------------------------------
-- vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab
-- vim: filetype=ada encoding=utf-8 fileformat=unix foldmethod=indent
|
flyx/OpenGLAda | Ada | 1,224 | ads | with Ada.Streams;
with GL.Objects.Textures;
with GL.Pixels;
package GL.Images is
-- This procedure loads the contents of the given Source to the given
-- texture object.
-- The texture object will be initialized if it is uninitialized.
-- The texture's image is created with the given internal format.
--
-- The image type is determined from its signature. TGA images do not have a
-- signature, so if the source contains TGA data, you need to set Try_TGA to
-- True.
--
-- If the given Texture_Format contains components with more than 8 bits,
-- the image is loaded with 16-bit components before it is given to OpenGL.
procedure Load_Image_To_Texture (
Source : in out Ada.Streams.Root_Stream_Type'Class;
Texture : in out GL.Objects.Textures.Texture'Class;
Texture_Format : GL.Pixels.Internal_Format;
Try_TGA : Boolean := False);
-- Like Load_Image_To_Texture, but takes the path to a file as input.
procedure Load_File_To_Texture (
Path : String;
Texture : in out GL.Objects.Textures.Texture'Class;
Texture_Format : GL.Pixels.Internal_Format;
Try_TGA : Boolean := False);
end GL.Images; |
stcarrez/ada-servlet | Ada | 1,177 | ads | -----------------------------------------------------------------------
-- servlet-streams-xml -- XML Print streams for servlets
-- Copyright (C) 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 Util.Serialize.IO.XML;
package Servlet.Streams.XML is
subtype Print_Stream is Util.Serialize.IO.XML.Output_Stream;
-- Initialize the stream
procedure Initialize (Stream : in out Print_Stream;
To : in Servlet.Streams.Print_Stream'Class);
end Servlet.Streams.XML;
|
reznikmm/matreshka | Ada | 3,759 | 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_Gradient_Step_Count_Attributes is
pragma Preelaborate;
type ODF_Draw_Gradient_Step_Count_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Gradient_Step_Count_Attribute_Access is
access all ODF_Draw_Gradient_Step_Count_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Gradient_Step_Count_Attributes;
|
zhmu/ananas | Ada | 11,138 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . E X C E P T I O N _ T A B L E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1996-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 System.Soft_Links; use System.Soft_Links;
package body System.Exception_Table is
use System.Standard_Library;
type Hash_Val is mod 2 ** 8;
subtype Hash_Idx is Hash_Val range 1 .. 37;
HTable : array (Hash_Idx) of aliased Exception_Data_Ptr;
-- Actual hash table containing all registered exceptions
--
-- The table is very small and the hash function weak, as looking up
-- registered exceptions is rare and minimizing space and time overhead
-- of registration is more important. In addition, it is expected that the
-- exceptions that need to be looked up are registered dynamically, and
-- therefore will be at the begin of the hash chains.
--
-- The table differs from System.HTable.Static_HTable in that the final
-- element of each chain is not marked by null, but by a pointer to self.
-- This way it is possible to defend against the same entry being inserted
-- twice, without having to do a lookup which is relatively expensive for
-- programs with large number
--
-- All non-local subprograms use the global Task_Lock to protect against
-- concurrent use of the exception table. This is needed as local
-- exceptions may be declared concurrently with those declared at the
-- library level.
-- Local Subprograms
generic
with procedure Process (T : Exception_Data_Ptr; More : out Boolean);
procedure Iterate;
-- Iterate over all
function Lookup (Name : String) return Exception_Data_Ptr;
-- Find and return the Exception_Data of the exception with the given Name
-- (which must be in all uppercase), or null if none was registered.
procedure Register (Item : Exception_Data_Ptr);
-- Register an exception with the given Exception_Data in the table.
function Has_Name (Item : Exception_Data_Ptr; Name : String) return Boolean;
-- Return True iff Item.Full_Name and Name are equal. Both names are
-- assumed to be in all uppercase and end with ASCII.NUL.
function Hash (S : String) return Hash_Idx;
-- Return the index in the hash table for S, which is assumed to be all
-- uppercase and end with ASCII.NUL.
--------------
-- Has_Name --
--------------
function Has_Name (Item : Exception_Data_Ptr; Name : String) return Boolean
is
S : constant Big_String_Ptr := To_Ptr (Item.Full_Name);
J : Integer := S'First;
begin
for K in Name'Range loop
-- Note that as both items are terminated with ASCII.NUL, the
-- comparison below must fail for strings of different lengths.
if S (J) /= Name (K) then
return False;
end if;
J := J + 1;
end loop;
return True;
end Has_Name;
------------
-- Lookup --
------------
function Lookup (Name : String) return Exception_Data_Ptr is
Prev : Exception_Data_Ptr;
Curr : Exception_Data_Ptr;
begin
Curr := HTable (Hash (Name));
Prev := null;
while Curr /= Prev loop
if Has_Name (Curr, Name) then
return Curr;
end if;
Prev := Curr;
Curr := Curr.HTable_Ptr;
end loop;
return null;
end Lookup;
----------
-- Hash --
----------
function Hash (S : String) return Hash_Idx is
Hash : Hash_Val := 0;
begin
for J in S'Range loop
exit when S (J) = ASCII.NUL;
Hash := Hash xor Character'Pos (S (J));
end loop;
return Hash_Idx'First + Hash mod (Hash_Idx'Last - Hash_Idx'First + 1);
end Hash;
-------------
-- Iterate --
-------------
procedure Iterate is
More : Boolean;
Prev, Curr : Exception_Data_Ptr;
begin
Outer : for Idx in HTable'Range loop
Prev := null;
Curr := HTable (Idx);
while Curr /= Prev loop
Process (Curr, More);
exit Outer when not More;
Prev := Curr;
Curr := Curr.HTable_Ptr;
end loop;
end loop Outer;
end Iterate;
--------------
-- Register --
--------------
procedure Register (Item : Exception_Data_Ptr) is
begin
if Item.HTable_Ptr = null then
Prepend_To_Chain : declare
Chain : Exception_Data_Ptr
renames HTable (Hash (To_Ptr (Item.Full_Name).all));
begin
if Chain = null then
Item.HTable_Ptr := Item;
else
Item.HTable_Ptr := Chain;
end if;
Chain := Item;
end Prepend_To_Chain;
end if;
end Register;
-------------------------------
-- Get_Registered_Exceptions --
-------------------------------
procedure Get_Registered_Exceptions
(List : out Exception_Data_Array;
Last : out Integer)
is
procedure Get_One (Item : Exception_Data_Ptr; More : out Boolean);
-- Add Item to List (List'First .. Last) by first incrementing Last
-- and storing Item in List (Last). Last should be in List'First - 1
-- and List'Last.
procedure Get_All is new Iterate (Get_One);
-- Store all registered exceptions in List, updating Last
-------------
-- Get_One --
-------------
procedure Get_One (Item : Exception_Data_Ptr; More : out Boolean) is
begin
if Last < List'Last then
Last := Last + 1;
List (Last) := Item;
More := True;
else
More := False;
end if;
end Get_One;
begin
-- In this routine the invariant is that List (List'First .. Last)
-- contains the registered exceptions retrieved so far.
Last := List'First - 1;
Lock_Task.all;
Get_All;
Unlock_Task.all;
end Get_Registered_Exceptions;
------------------------
-- Internal_Exception --
------------------------
function Internal_Exception
(X : String;
Create_If_Not_Exist : Boolean := True) return Exception_Data_Ptr
is
-- If X was not yet registered and Create_if_Not_Exist is True,
-- dynamically allocate and register a new exception.
type String_Ptr is access all String;
Dyn_Copy : String_Ptr;
Copy : aliased String (X'First .. X'Last + 1);
Result : Exception_Data_Ptr;
begin
Lock_Task.all;
Copy (X'Range) := X;
Copy (Copy'Last) := ASCII.NUL;
Result := Lookup (Copy);
-- If unknown exception, create it on the heap. This is a legitimate
-- situation in the distributed case when an exception is defined
-- only in a partition
if Result = null and then Create_If_Not_Exist then
Dyn_Copy := new String'(Copy);
Result :=
new Exception_Data'
(Not_Handled_By_Others => False,
Lang => 'A',
Name_Length => Copy'Length,
Full_Name => Dyn_Copy.all'Address,
HTable_Ptr => null,
Foreign_Data => Null_Address,
Raise_Hook => null);
Register (Result);
end if;
Unlock_Task.all;
return Result;
end Internal_Exception;
------------------------
-- Register_Exception --
------------------------
procedure Register_Exception (X : Exception_Data_Ptr) is
begin
Lock_Task.all;
Register (X);
Unlock_Task.all;
end Register_Exception;
---------------------------------
-- Registered_Exceptions_Count --
---------------------------------
function Registered_Exceptions_Count return Natural is
Count : Natural := 0;
procedure Count_Item (Item : Exception_Data_Ptr; More : out Boolean);
-- Update Count for given Item
procedure Count_Item (Item : Exception_Data_Ptr; More : out Boolean) is
pragma Unreferenced (Item);
begin
Count := Count + 1;
More := Count < Natural'Last;
end Count_Item;
procedure Count_All is new Iterate (Count_Item);
begin
Lock_Task.all;
Count_All;
Unlock_Task.all;
return Count;
end Registered_Exceptions_Count;
begin
-- Register the standard exceptions at elaboration time
-- We don't need to use the locking version here as the elaboration
-- will not be concurrent and no tasks can call any subprograms of this
-- unit before it has been elaborated.
Register (Abort_Signal_Def'Access);
Register (Tasking_Error_Def'Access);
Register (Storage_Error_Def'Access);
Register (Program_Error_Def'Access);
Register (Numeric_Error_Def'Access);
Register (Constraint_Error_Def'Access);
end System.Exception_Table;
|
kisom/rover-mk1 | Ada | 602 | ads | with AVR; use AVR;
with Interfaces; use Interfaces;
with Hardware.PWM; use Hardware;
package Hardware.DriveTrain is
procedure Init;
procedure Forward;
procedure Backward;
procedure Rotate_Left;
procedure Rotate_Right;
procedure Stop;
private
Motor_Right : Hardware.PWM.Servo_Index;
Motor_Left : Hardware.PWM.Servo_Index;
Pin_Right : AVR.Bit_Number := 3; -- PB5
Pin_Left : AVR.Bit_Number := 4; -- PB6
Rotate_Forward : Unsigned_16 := 1700;
Rotate_Stop : Unsigned_16 := 1500;
Rotate_Backward : Unsigned_16 := 1300;
end Hardware.DriveTrain;
|
reznikmm/matreshka | Ada | 3,709 | 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.Smil_RepeatDur_Attributes is
pragma Preelaborate;
type ODF_Smil_RepeatDur_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Smil_RepeatDur_Attribute_Access is
access all ODF_Smil_RepeatDur_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Smil_RepeatDur_Attributes;
|
charlie5/cBound | Ada | 1,665 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_generic_error_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
error_code : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
bad_value : aliased Interfaces.Unsigned_32;
minor_opcode : aliased Interfaces.Unsigned_16;
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased swig.int8_t_Array (0 .. 20);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_generic_error_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_generic_error_t.Item,
Element_Array => xcb.xcb_glx_generic_error_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_generic_error_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_generic_error_t.Pointer,
Element_Array => xcb.xcb_glx_generic_error_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_generic_error_t;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 3,142 | ads | -- This spec has been automatically generated from STM32F411xx.svd
-- Definition of the device's interrupts
package STM32_SVD.Interrupts is
----------------
-- Interrupts --
----------------
-- PVD through EXTI line detection interrupt
PVD : constant := 1;
-- Tamper and TimeStamp interrupts through the EXTI line
TAMP_STAMP : constant := 2;
-- RTC Wakeup interrupt through the EXTI line
RTC_WKUP : constant := 3;
-- FLASH global interrupt
FLASH : constant := 4;
-- RCC global interrupt
RCC : constant := 5;
-- EXTI Line0 interrupt
EXTI0 : constant := 6;
-- EXTI Line1 interrupt
EXTI1 : constant := 7;
-- EXTI Line2 interrupt
EXTI2 : constant := 8;
-- EXTI Line3 interrupt
EXTI3 : constant := 9;
-- EXTI Line4 interrupt
EXTI4 : constant := 10;
-- ADC1 global interrupt
ADC : constant := 18;
-- EXTI Line[9:5] interrupts
EXTI9_5 : constant := 23;
-- TIM1 Break interrupt and TIM9 global interrupt
TIM1_BRK_TIM9 : constant := 24;
-- TIM1 Update interrupt and TIM10 global interrupt
TIM1_UP_TIM10 : constant := 25;
-- TIM1 Trigger and Commutation interrupts and TIM11 global interrupt
TIM1_TRG_COM_TIM11 : constant := 26;
-- TIM1 Capture Compare interrupt
TIM1_CC : constant := 27;
-- TIM2 global interrupt
TIM2 : constant := 28;
-- TIM3 global interrupt
TIM3 : constant := 29;
-- I2C1 event interrupt
I2C1_EV : constant := 31;
-- I2C1 error interrupt
I2C1_ER : constant := 32;
-- I2C2 event interrupt
I2C2_EV : constant := 33;
-- I2C2 error interrupt
I2C2_ER : constant := 34;
-- SPI1 global interrupt
SPI1 : constant := 35;
-- SPI2 global interrupt
SPI2 : constant := 36;
-- EXTI Line[15:10] interrupts
EXTI15_10 : constant := 40;
-- RTC Alarms (A and B) through EXTI line interrupt
RTC_Alarm : constant := 41;
-- USB On-The-Go FS Wakeup through EXTI line interrupt
OTG_FS_WKUP : constant := 42;
-- SDIO global interrupt
SDIO : constant := 49;
-- SPI3 global interrupt
SPI3 : constant := 51;
-- USB On The Go FS global interrupt
OTG_FS : constant := 67;
-- I2C3 event interrupt
I2C3_EV : constant := 72;
-- I2C3 error interrupt
I2C3_ER : constant := 73;
-- SPI4 global interrupt
SPI4 : constant := 84;
end STM32_SVD.Interrupts;
|
stcarrez/hyperion | Ada | 7,051 | adb | -- Hyperion API
-- Hyperion Monitoring API The monitoring agent is first registered so that the server knows it as well as its security key. Each host are then registered by a monitoring agent.
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
--
-- src/hyperion-rest-servers.adb
--
-- Then, you can drop this edit note comment.
-- ------------ EDIT NOTE ------------
with Hyperion.Agents.Modules;
with Hyperion.Agents.Models;
with Hyperion.Hosts.Modules;
with Hyperion.Hosts.Models;
with ADO.Objects;
with Util.Log.Loggers;
with Util.Beans.Objects.Maps;
with Util.Serialize.IO.JSON;
with Util.Beans.Objects.Readers;
with Servlet.Streams;
with Swagger.Servers;
with Swagger.Servers.Operation;
package body Hyperion.Rest.Servers is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Hyperion.Rest.Servers");
procedure Process_Snapshot
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type);
package Server_Impl is
new Hyperion.Rest.Skeletons.Skeleton (Server_Type, URI_Prefix => "/api/v1");
-- Register a monitoring agent
-- Register a new monitoring agent in the system
overriding
procedure Register_Agent
(Server : in out Server_Type;
Name : in Swagger.UString;
Ip : in Swagger.UString;
Agent_Key : in Swagger.UString;
Result : out Hyperion.Rest.Models.Agent_Type;
Context : in out Swagger.Servers.Context_Type) is
Module : Agents.Modules.Agent_Module_Access := Agents.Modules.Get_Agent_Module;
Agent : Agents.Models.Agent_Ref;
begin
Agent.Set_Hostname (Name);
Agent.Set_Ip (Ip);
Agent.Set_Key (Agent_Key);
Module.Register_Agent (Agent);
Result.Name := Name;
Result.Ip := Ip;
Result.Key := Agent_Key;
Result.Status := Swagger.To_UString ("");
Result.Create_Date := Agent.Get_Create_Date;
Result.Id := Swagger.Long (Agent.Get_Id);
end Register_Agent;
-- Create a host
-- Register a new host in the monitoring system
overriding
procedure Create_Host
(Server : in out Server_Type;
Name : in Swagger.UString;
Ip : in Swagger.UString;
Host_Key : in Swagger.UString;
Agent_Key : in Swagger.UString;
Agent_Id : in Integer;
Result : out Hyperion.Rest.Models.Host_Type;
Context : in out Swagger.Servers.Context_Type) is
Module : Hosts.Modules.Host_Module_Access := Hosts.Modules.Get_Host_Module;
Host : Hosts.Models.Host_Ref;
begin
Host.Set_Name (Name);
Host.Set_Ip (Ip);
Host.Set_Key (Host_Key);
Module.Create_Host (Agent_Key => Swagger.To_String (Agent_Key),
Host => Host);
Result.Name := Host.Get_Name;
Result.Id := Swagger.Long (Host.Get_Id);
Result.Ip := Host.Get_Ip;
Result.Create_Date := Host.Get_Create_Date;
exception
when ADO.Objects.NOT_FOUND =>
Context.Set_Error (Code => 405,
Message => "Invalid agent key");
end Create_Host;
-- Get information about the host
-- Provide information about the host
procedure Get_Host
(Server : in out Server_Type;
Host_Id : in Swagger.Long;
Result : out Hyperion.Rest.Models.Host_Type;
Context : in out Swagger.Servers.Context_Type) is
begin
null;
end Get_Host;
-- Get information about the host datasets
-- The datasets describes and gives access to the monitored data.
overriding
procedure Get_Datasets
(Server : in out Server_Type;
Host_Id : in Swagger.Long;
Result : out Hyperion.Rest.Models.Dataset_Type_Vectors.Vector;
Context : in out Swagger.Servers.Context_Type) is
begin
null;
end Get_Datasets;
package API_Process_Snapshot is
new Swagger.Servers.Operation (Handler => Process_Snapshot,
Method => Swagger.Servers.POST,
URI => "/api/v1/hosts/{host_id}/snapshot");
-- Register a monitoring agent
procedure Process_Snapshot
(Req : in out Swagger.Servers.Request'Class;
Reply : in out Swagger.Servers.Response'Class;
Stream : in out Swagger.Servers.Output_Stream'Class;
Context : in out Swagger.Servers.Context_Type) is
Name : Swagger.UString;
Ip : Swagger.UString;
Agent_Key : Swagger.UString;
Result : Hyperion.Rest.Models.Agent_Type;
Input : constant Servlet.Streams.Input_Stream_Access := Req.Get_Input_Stream;
Parser : Util.Serialize.IO.JSON.Parser;
Mapper : Util.Beans.Objects.Readers.Reader;
Root : Util.Beans.Objects.Object;
Key : Util.Beans.Objects.Object;
Snapshot : Util.Beans.Objects.Object;
package UBO renames Util.Beans.Objects;
procedure Process_Data (Name : in String;
Data : in Util.Beans.Objects.Object) is
Start_Time : Natural := UBO.To_Integer (UBO.Get_Value (Data, "start_time"));
End_Time : Natural := UBO.To_Integer (UBO.Get_Value (Data, "end_time"));
Snapshot : UBO.Object := UBO.Get_Value (Data, "snapshot");
procedure Process_Snapshot (Name : in String;
Data : in Util.Beans.Objects.Object) is
begin
Log.Info (" probe {0} - ", Name);
end Process_Snapshot;
begin
if Start_Time = 0 and End_Time = 0 then
Util.Beans.Objects.Maps.Iterate (Data, Process_Data'Access);
else
Log.Info ("Data {0} - {1} to {2}", Name, Natural'Image (Start_Time),
Natural'Image (End_Time));
Util.Beans.Objects.Maps.Iterate (Snapshot, Process_Snapshot'Access);
end if;
end Process_Data;
begin
if not Context.Is_Authenticated then
Context.Set_Error (401, "Not authenticated");
return;
end if;
if not Context.Has_Permission (Skeletons.ACL_Write_Host.Permission) then
Context.Set_Error (403, "Permission denied");
return;
end if;
Parser.Parse (Input.all, Mapper);
Root := Mapper.Get_Root;
Key := Util.Beans.Objects.Get_Value (Root, "host_key");
Snapshot := Util.Beans.Objects.Get_Value (Root, "snapshot");
Util.Beans.Objects.Maps.Iterate (Snapshot, Process_Data'Access);
Context.Set_Status (200);
end Process_Snapshot;
procedure Register (Server : in out Swagger.Servers.Application_Type'Class) is
begin
Server_Impl.Register (Server);
Swagger.Servers.Register (Server, API_Process_Snapshot.Definition);
end Register;
end Hyperion.Rest.Servers;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 3,031 | ads | ------------------------------------------------------------------------------
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
package nRF51.PPI is
subtype Channel_ID is Natural range 0 .. 15;
subtype Group_ID is Natural range 0 .. 3;
procedure Configure (Chan : Channel_ID;
Evt_EP : Event_Type;
Task_EP : Task_Type);
procedure Enable_Channel (Chan : Channel_ID);
procedure Disable_Channel (Chan : Channel_ID);
procedure Add_To_Group (Chan : Channel_ID;
Group : Group_ID);
procedure Remove_From_Group (Chan : Channel_ID;
Group : Group_ID);
procedure Enable_Group (Group : Group_ID);
procedure Disable_Group (Group : Group_ID);
end nRF51.PPI;
|
tum-ei-rcs/StratoX | Ada | 38 | adb | ../../../../software/modules/nvram.adb |
stcarrez/ada-el | Ada | 2,085 | ads | -----------------------------------------------------------------------
-- Test_Bean - A simple bean ffor unit tests
-- Copyright (C) 2009, 2010, 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 EL.Objects;
with Util.Beans.Basic;
with Ada.Strings.Unbounded;
with Ada.Calendar;
with Ada.Unchecked_Deallocation;
package Test_Bean is
use Ada.Strings.Unbounded;
type Person is new Util.Beans.Basic.Bean with record
Last_Name : Unbounded_String;
First_Name : Unbounded_String;
Age : Natural;
Date : Ada.Calendar.Time;
Weight : Long_Long_Float;
end record;
type Person_Access is access all Person'Class;
function Create_Person (First_Name, Last_Name : String;
Age : Natural) return Person_Access;
-- Get the value identified by the name.
overriding
function Get_Value (From : Person; Name : String) return EL.Objects.Object;
-- Set the value identified by the name.
overriding
procedure Set_Value (From : in out Person;
Name : in String;
Value : in EL.Objects.Object);
-- Function to format a string
function Format (Arg : EL.Objects.Object) return EL.Objects.Object;
procedure Free is new Ada.Unchecked_Deallocation (Object => Person'Class,
Name => Person_Access);
end Test_Bean;
|
reznikmm/matreshka | Ada | 19,723 | 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$
------------------------------------------------------------------------------
with AMF.Internals.UML_Multiplicity_Elements;
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Behaviors;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Input_Pins;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Multiplicity_Elements;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.States.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Types;
with AMF.UML.Value_Specifications;
with AMF.Visitors;
package AMF.Internals.UML_Input_Pins is
package UML_Multiplicity_Elements is
new AMF.Internals.UML_Multiplicity_Elements
(AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy);
type UML_Input_Pin_Proxy is
limited new UML_Multiplicity_Elements.UML_Multiplicity_Element_Proxy
and AMF.UML.Input_Pins.UML_Input_Pin with null record;
overriding function Get_Is_Control
(Self : not null access constant UML_Input_Pin_Proxy)
return Boolean;
-- Getter of Pin::isControl.
--
-- Tells whether the pins provide data to the actions, or just controls
-- when it executes it.
overriding procedure Set_Is_Control
(Self : not null access UML_Input_Pin_Proxy;
To : Boolean);
-- Setter of Pin::isControl.
--
-- Tells whether the pins provide data to the actions, or just controls
-- when it executes it.
overriding function Get_In_State
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.States.Collections.Set_Of_UML_State;
-- Getter of ObjectNode::inState.
--
-- The required states of the object available at this point in the
-- activity.
overriding function Get_Is_Control_Type
(Self : not null access constant UML_Input_Pin_Proxy)
return Boolean;
-- Getter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding procedure Set_Is_Control_Type
(Self : not null access UML_Input_Pin_Proxy;
To : Boolean);
-- Setter of ObjectNode::isControlType.
--
-- Tells whether the type of the object node is to be treated as control.
overriding function Get_Ordering
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.UML_Object_Node_Ordering_Kind;
-- Getter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding procedure Set_Ordering
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.UML_Object_Node_Ordering_Kind);
-- Setter of ObjectNode::ordering.
--
-- Tells whether and how the tokens in the object node are ordered for
-- selection to traverse edges outgoing from the object node.
overriding function Get_Selection
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding procedure Set_Selection
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of ObjectNode::selection.
--
-- Selects tokens for outgoing edges.
overriding function Get_Upper_Bound
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access;
-- Getter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding procedure Set_Upper_Bound
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access);
-- Setter of ObjectNode::upperBound.
--
-- The maximum number of tokens allowed in the node. Objects cannot flow
-- into the node if the upper bound is reached.
overriding function Get_Activity
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Input_Pin_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Input_Pin_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Type
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Types.UML_Type_Access;
-- Getter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding procedure Set_Type
(Self : not null access UML_Input_Pin_Proxy;
To : AMF.UML.Types.UML_Type_Access);
-- Setter of TypedElement::type.
--
-- The type of the TypedElement.
-- This information is derived from the return result for this Operation.
overriding function Is_Consistent_With
(Self : not null access constant UML_Input_Pin_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Input_Pin_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Input_Pin_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Input_Pin_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Compatible_With
(Self : not null access constant UML_Input_Pin_Proxy;
Other : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean;
-- Operation MultiplicityElement::compatibleWith.
--
-- The operation compatibleWith takes another multiplicity as input. It
-- checks if one multiplicity is compatible with another.
overriding function Includes_Cardinality
(Self : not null access constant UML_Input_Pin_Proxy;
C : Integer)
return Boolean;
-- Operation MultiplicityElement::includesCardinality.
--
-- The query includesCardinality() checks whether the specified
-- cardinality is valid for this multiplicity.
overriding function Includes_Multiplicity
(Self : not null access constant UML_Input_Pin_Proxy;
M : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access)
return Boolean;
-- Operation MultiplicityElement::includesMultiplicity.
--
-- The query includesMultiplicity() checks whether this multiplicity
-- includes all the cardinalities allowed by the specified multiplicity.
overriding function Iss
(Self : not null access constant UML_Input_Pin_Proxy;
Lowerbound : Integer;
Upperbound : Integer)
return Boolean;
-- Operation MultiplicityElement::is.
--
-- The operation is determines if the upper and lower bound of the ranges
-- are the ones given.
overriding procedure Enter_Element
(Self : not null access constant UML_Input_Pin_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Input_Pin_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Input_Pin_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Input_Pins;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 1,146 | ads | package STM32GD.Clock is
pragma Preelaborate;
type Clock_Type is (SYSCLK, PCLK1, PCLK2, MSI, HSI, LSI, LSE, HCLK, PLLCLK, RTCCLK);
type PLL_Source_Type is (HSI, HSE);
type RTC_Source_Type is (LSE, HSE, LSI);
type SYSCLK_Source_Type is (PLL, HSI, HSE, MSI);
subtype MSI_Range is Integer range 1024 * 64 .. 4 * 1024 * 1024;
subtype HSE_Range is Integer range 4_000_000 .. 32_000_000;
subtype PLL_Prediv_Range is Integer range 1 .. 16;
subtype PLL_Mul_Range is Integer range 1 .. 16;
subtype PLL_Range is Integer range 16_000_000 .. 48_000_000;
subtype PLL_Input_Range is Integer range 4_000_000 .. 32_000_000;
subtype SYSCLK_Speed is Integer range 4_000_000 .. 48_000_000;
type AHB_Prescaler_Type is (DIV1, DIV2, DIV4, DIV8, DIV16,
DIV64, DIV128, DIV256, DIV512);
type APB1_Prescaler_Type is (DIV1, DIV2, DIV4, DIV8, DIV16);
type APB2_Prescaler_Type is (DIV1, DIV2, DIV4, DIV8, DIV16);
HSI_Value : constant Integer := 16_000_000;
MSI_Value : constant Integer := 2 * 1024 * 1024;
LSI_Value : constant Integer := 40_000;
LSE_Value : constant Integer := 32_768;
end STM32GD.Clock;
|
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.Chart_Axis_Label_Position_Attributes is
pragma Preelaborate;
type ODF_Chart_Axis_Label_Position_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Axis_Label_Position_Attribute_Access is
access all ODF_Chart_Axis_Label_Position_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Axis_Label_Position_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 40,564 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This packages provide a low level driver for the FAT file system
-- architecture. It is recommended to _not_ use this interface directly but to
-- access the file system using the File_IO package. For more info, see the
-- file system chapter of the documentation.
with Ada.Unchecked_Conversion;
package body Filesystem.FAT.Directories is
subtype Entry_Data is Block (1 .. 32);
function To_Data is new Ada.Unchecked_Conversion
(FAT_Directory_Entry, Entry_Data);
function To_Data is new Ada.Unchecked_Conversion
(VFAT_Directory_Entry, Entry_Data);
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index;
-- Finds a sequence of deleted entries that can fit Num_Entries.
-- Returns the first entry of this sequence
--------------
-- Set_Size --
--------------
procedure Set_Size
(E : in out FAT_Node;
Size : FAT_File_Size)
is
begin
if E.Size /= Size then
E.Size := Size;
E.Is_Dirty := True;
end if;
end Set_Size;
----------
-- Find --
----------
function Find
(Parent : FAT_Node;
Filename : FAT_Name;
DEntry : out FAT_Node) return Status_Code
is
-- We use a copy of the handle, so as not to touch the state of initial
-- handle
Status : Status_Code;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Parent.FS.Cluster_To_Block (Cluster);
Index : Entry_Index := 0;
begin
loop
Status := Next_Entry
(FS => Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Index,
DEntry => DEntry);
if Status /= OK then
return No_Such_File;
end if;
if Long_Name (DEntry) = Filename or else
(DEntry.L_Name.Len = 0 and then Short_Name (DEntry) = Filename)
then
return OK;
end if;
end loop;
end Find;
----------
-- Find --
----------
function Find
(FS : in out FAT_Filesystem;
Path : String;
DEntry : out FAT_Node) return Status_Code
is
Status : Status_Code;
Idx : Natural; -- Idx is used to walk through the Path
Token : FAT_Name;
begin
DEntry := Root_Entry (FS);
-- Looping through the Path. We start at 2 as we ignore the initial '/'
Idx := Path'First + 1;
while Idx <= Path'Last loop
Token.Len := 0;
for J in Idx .. Path'Last loop
if Path (J) = '/' then
exit;
end if;
Token.Len := Token.Len + 1;
Token.Name (Token.Len) := Path (J);
end loop;
Idx := Idx + Token.Len + 1;
Status := Find (DEntry, Token, DEntry);
if Status /= OK then
return No_Such_File;
end if;
if Idx < Path'Last then
-- Intermediate entry: needs to be a directory
if not Is_Subdirectory (DEntry) then
return No_Such_Path;
end if;
end if;
end loop;
return OK;
end Find;
------------------
-- Update_Entry --
------------------
function Update_Entry
(Parent : FAT_Node;
Value : in out FAT_Node) return Status_Code
is
subtype Entry_Block is Block (1 .. 32);
function To_Block is new
Ada.Unchecked_Conversion (FAT_Directory_Entry, Entry_Block);
function To_Entry is new
Ada.Unchecked_Conversion (Entry_Block, FAT_Directory_Entry);
Ent : FAT_Directory_Entry;
Cluster : Cluster_Type := Parent.Start_Cluster;
Offset : FAT_File_Size := FAT_File_Size (Value.Index) * 32;
Block_Off : Natural;
Block : Block_Offset;
Ret : Status_Code;
begin
if not Value.Is_Dirty then
return OK;
end if;
while Offset > Parent.FS.Cluster_Size loop
Cluster := Parent.FS.Get_FAT (Cluster);
Offset := Offset - Parent.FS.Cluster_Size;
end loop;
Block := Block_Offset (Offset / Parent.FS.Block_Size);
Block_Off := Natural (Offset mod Parent.FS.Block_Size);
Ret := Parent.FS.Ensure_Block
(Parent.FS.Cluster_To_Block (Cluster) + Block);
if Ret /= OK then
return Ret;
end if;
Ent := To_Entry (Parent.FS.Window (Block_Off .. Block_Off + 31));
-- For now only the size can be modified, so just apply this
-- modification
Ent.Size := Value.Size;
Value.Is_Dirty := False;
Parent.FS.Window (Block_Off .. Block_Off + 31) := To_Block (Ent);
Ret := Parent.FS.Write_Window;
return Ret;
end Update_Entry;
----------------
-- Root_Entry --
----------------
function Root_Entry (FS : in out FAT_Filesystem) return FAT_Node
is
Ret : FAT_Node;
begin
Ret.FS := FS'Unchecked_Access;
Ret.Attributes := (Subdirectory => True,
others => False);
Ret.Is_Root := True;
Ret.L_Name := (Name => (others => ' '),
Len => 0);
if FS.Version = FAT16 then
Ret.Start_Cluster := 0;
else
Ret.Start_Cluster := FS.Root_Dir_Cluster;
end if;
Ret.Index := 0;
return Ret;
end Root_Entry;
----------------
-- Next_Entry --
----------------
function Next_Entry
(FS : access FAT_Filesystem;
Current_Cluster : in out Cluster_Type;
Current_Block : in out Block_Offset;
Current_Index : in out Entry_Index;
DEntry : out FAT_Directory_Entry) return Status_Code
is
subtype Entry_Data is Block (1 .. 32);
function To_Entry is new Ada.Unchecked_Conversion
(Entry_Data, FAT_Directory_Entry);
Ret : Status_Code;
Block_Off : Natural;
begin
if Current_Index = 16#FFFF# then
return No_More_Entries;
end if;
if Current_Cluster = 0 and then FS.Version = FAT16 then
if Current_Index >
Entry_Index (FS.FAT16_Root_Dir_Num_Entries)
then
return No_More_Entries;
else
Block_Off :=
Natural (FAT_File_Size (Current_Index * 32) mod
FS.Block_Size);
Current_Block :=
FS.Root_Dir_Area +
Block_Offset
(FAT_File_Size (Current_Index * 32) / FS.Block_Size);
end if;
else
Block_Off := Natural
(FAT_File_Size (Current_Index * 32) mod FS.Block_Size);
-- Check if we're on a block boundare
if Unsigned_32 (Block_Off) = 0 and then Current_Index /= 0 then
Current_Block := Current_Block + 1;
end if;
-- Check if we're on the boundary of a new cluster
if Current_Block - FS.Cluster_To_Block (Current_Cluster)
= FS.Blocks_Per_Cluster
then
-- The block we need to read is outside of the current cluster.
-- Let's move on to the next
-- Read the FAT table to determine the next cluster
Current_Cluster := FS.Get_FAT (Current_Cluster);
if Current_Cluster = 1
or else FS.Is_Last_Cluster (Current_Cluster)
then
return Internal_Error;
end if;
Current_Block := FS.Cluster_To_Block (Current_Cluster);
end if;
end if;
Ret := FS.Ensure_Block (Current_Block);
if Ret /= OK then
return Ret;
end if;
if FS.Window (Block_Off) = 0 then
-- End of entries: we stick the index here to make sure that further
-- calls to Next_Entry always end-up here
return No_More_Entries;
end if;
DEntry := To_Entry (FS.Window (Block_Off .. Block_Off + 31));
Current_Index := Current_Index + 1;
return OK;
end Next_Entry;
----------------
-- Next_Entry --
----------------
function Next_Entry
(FS : access FAT_Filesystem;
Current_Cluster : in out Cluster_Type;
Current_Block : in out Block_Offset;
Current_Index : in out Entry_Index;
DEntry : out FAT_Node) return Status_Code
is
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural);
-- Prepends Name to Full
-------------
-- Prepend --
-------------
procedure Prepend
(Name : Wide_String;
Full : in out String;
Idx : in out Natural)
is
Val : Unsigned_16;
begin
for J in reverse Name'Range loop
Val := Wide_Character'Pos (Name (J));
if Val /= 16#FFFF#
and then Val /= 0
then
Idx := Idx - 1;
exit when Idx not in Full'Range;
if Val < 255 then
Full (Idx) := Character'Val (Val);
elsif Val = 16#F029# then
-- Path ends with a '.'
Full (Idx) := '.';
elsif Val = 16#F028# then
-- Path ends with a ' '
Full (Idx) := ' ';
else
Full (Idx) := '?';
end if;
end if;
end loop;
end Prepend;
Ret : Status_Code;
D_Entry : FAT_Directory_Entry;
V_Entry : VFAT_Directory_Entry;
function To_VFAT_Entry is new Ada.Unchecked_Conversion
(FAT_Directory_Entry, VFAT_Directory_Entry);
C : Unsigned_8;
Last_Seq : VFAT_Sequence_Number := 0;
CRC : Unsigned_8 := 0;
Matches : Boolean;
Current_CRC : Unsigned_8;
L_Name : String (1 .. MAX_FILENAME_LENGTH);
L_Name_First : Natural;
begin
L_Name_First := L_Name'Last + 1;
loop
Ret := Next_Entry
(FS,
Current_Cluster => Current_Cluster,
Current_Block => Current_Block,
Current_Index => Current_Index,
DEntry => D_Entry);
if Ret /= OK then
return Ret;
end if;
-- Check if we have a VFAT entry here by checking that the
-- attributes are 16#0F# (e.g. all attributes set except
-- subdirectory and archive)
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then
V_Entry := To_VFAT_Entry (D_Entry);
if V_Entry.VFAT_Attr.Stop_Bit then
L_Name_First := L_Name'Last + 1;
else
if Last_Seq = 0
or else Last_Seq - 1 /= V_Entry.VFAT_Attr.Sequence
then
L_Name_First := L_Name'Last + 1;
end if;
end if;
Last_Seq := V_Entry.VFAT_Attr.Sequence;
Prepend (V_Entry.Name_3, L_Name, L_Name_First);
Prepend (V_Entry.Name_2, L_Name, L_Name_First);
Prepend (V_Entry.Name_1, L_Name, L_Name_First);
if V_Entry.VFAT_Attr.Sequence = 1 then
CRC := V_Entry.Checksum;
end if;
-- Ignore Volumes and deleted files
elsif not D_Entry.Attributes.Volume_Label
and then Character'Pos (D_Entry.Filename (1)) /= 16#E5#
then
if L_Name_First not in L_Name'Range then
Matches := False;
else
Current_CRC := 0;
Last_Seq := 0;
for Ch of String'(D_Entry.Filename & D_Entry.Extension) loop
C := Character'Enum_Rep (Ch);
Current_CRC := Shift_Right (Current_CRC and 16#FE#, 1)
or Shift_Left (Current_CRC and 16#01#, 7);
-- Modulo addition
Current_CRC := Current_CRC + C;
end loop;
Matches := Current_CRC = CRC;
end if;
DEntry :=
(FS => FAT_Filesystem_Access (FS),
L_Name => <>,
S_Name => D_Entry.Filename,
S_Name_Ext => D_Entry.Extension,
Attributes => D_Entry.Attributes,
Start_Cluster => (if FS.Version = FAT16
then Cluster_Type (D_Entry.Cluster_L)
else Cluster_Type (D_Entry.Cluster_L) or
Shift_Left
(Cluster_Type (D_Entry.Cluster_H), 16)),
Size => D_Entry.Size,
Index => Current_Index - 1,
Is_Root => False,
Is_Dirty => False);
if Matches then
DEntry.L_Name := -L_Name (L_Name_First .. L_Name'Last);
else
DEntry.L_Name.Len := 0;
end if;
return OK;
end if;
end loop;
end Next_Entry;
----------
-- Read --
----------
function Read
(Dir : in out FAT_Directory_Handle;
DEntry : out FAT_Node) return Status_Code
is
begin
return Next_Entry
(Dir.FS,
Current_Cluster => Dir.Current_Cluster,
Current_Block => Dir.Current_Block,
Current_Index => Dir.Current_Index,
DEntry => DEntry);
end Read;
-------------------
-- Create_Subdir --
-------------------
function Create_Subdir
(Dir : FAT_Node;
Name : FAT_Name;
New_Dir : out FAT_Node) return Status_Code
is
Handle : FAT_Directory_Handle_Access;
Ret : Status_Code;
Block : Block_Offset;
Dot : FAT_Directory_Entry;
Dot_Dot : FAT_Directory_Entry;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
Ret := Allocate_Entry
(Parent => Handle,
Name => Name,
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
E => New_Dir);
if Ret /= OK then
return Ret;
end if;
Block := Dir.FS.Cluster_To_Block (New_Dir.Start_Cluster);
Ret := Handle.FS.Ensure_Block (Block);
if Ret /= OK then
return Ret;
end if;
-- Allocate '.', '..' and the directory entry terminator
Dot :=
(Filename => (1 => '.', others => ' '),
Extension => (others => ' '),
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32
(New_Dir.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (New_Dir.Start_Cluster and 16#FFFF#),
Size => 0);
Dot_Dot :=
(Filename => (1 .. 2 => '.', others => ' '),
Extension => (others => ' '),
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => True,
Archive => False),
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32 (Handle.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (Handle.Start_Cluster and 16#FFFF#),
Size => 0);
Handle.FS.Window (0 .. 31) := To_Data (Dot);
Handle.FS.Window (32 .. 63) := To_Data (Dot_Dot);
Handle.FS.Window (64 .. 95) := (others => 0);
Ret := Handle.FS.Write_Window;
Close (Handle.all);
return Ret;
end Create_Subdir;
----------------------
-- Create_File_Node --
----------------------
function Create_File_Node
(Dir : FAT_Node;
Name : FAT_Name;
New_File : out FAT_Node) return Status_Code
is
Handle : FAT_Directory_Handle_Access;
Ret : Status_Code;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
Ret := Allocate_Entry
(Parent => Handle,
Name => Name,
Attributes => (Read_Only => False,
Hidden => False,
System_File => False,
Volume_Label => False,
Subdirectory => False,
Archive => True),
E => New_File);
Close (Handle.all);
if Ret /= OK then
return Ret;
end if;
return Ret;
end Create_File_Node;
-------------------
-- Delete_Subdir --
-------------------
function Delete_Subdir
(Dir : FAT_Node;
Recursive : Boolean) return Status_Code
is
Parent : FAT_Node;
Handle : FAT_Directory_Handle_Access;
Ent : FAT_Node;
Ret : Status_Code;
begin
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
while Read (Handle.all, Ent) = OK loop
if -Long_Name (Ent) = "." then
null;
elsif -Long_Name (Ent) = ".." then
Parent := Ent;
elsif not Recursive then
return Non_Empty_Directory;
else
if Ent.Attributes.Subdirectory then
Ret := Delete_Subdir (Ent, True);
else
Ret := Delete_Entry (Dir, Ent);
end if;
if Ret /= OK then
Close (Handle.all);
return Ret;
end if;
end if;
end loop;
Close (Handle.all);
-- Free the clusters associated to the subdirectory
Ret := Delete_Entry (Parent, Dir);
if Ret /= OK then
return Ret;
end if;
return Ret;
end Delete_Subdir;
------------------
-- Delete_Entry --
------------------
function Delete_Entry
(Dir : FAT_Node;
Ent : FAT_Node) return Status_Code
is
Current : Cluster_Type := Ent.Start_Cluster;
Handle : FAT_Directory_Handle_Access;
Next : Cluster_Type;
Child_Ent : FAT_Node;
Ret : Status_Code;
Block_Off : Natural;
begin
-- Mark the entry's cluster chain as available
loop
Next := Ent.FS.Get_FAT (Current);
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE);
exit when Ret /= OK;
exit when Ent.FS.Is_Last_Cluster (Next);
Current := Next;
end loop;
-- Mark the parent's entry as deleted
Ret := Dir.FAT_Open (Handle);
if Ret /= OK then
return Ret;
end if;
while Read (Handle.all, Child_Ent) = OK loop
if Long_Name (Child_Ent) = Long_Name (Ent) then
Block_Off := Natural
((FAT_File_Size (Handle.Current_Index - 1) * 32)
mod Dir.FS.Block_Size);
-- Mark the entry as deleted: first basename character set to
-- 16#E5#
Handle.FS.Window (Block_Off) := 16#E5#;
Ret := Handle.FS.Write_Window;
exit;
end if;
end loop;
Close (Handle.all);
return Ret;
end Delete_Entry;
---------------------
-- Adjust_Clusters --
---------------------
function Adjust_Clusters (Ent : FAT_Node) return Status_Code
is
B_Per_Cluster : constant FAT_File_Size :=
FAT_File_Size (Ent.FS.Blocks_Per_Cluster) *
Ent.FS.Block_Size;
Size : FAT_File_Size := Ent.Size;
Current : Cluster_Type := Ent.Start_Cluster;
Next : Cluster_Type;
Ret : Status_Code := OK;
begin
if Ent.Attributes.Subdirectory then
-- ??? Do nothing for now
return OK;
end if;
loop
Next := Ent.FS.Get_FAT (Current);
if Size > B_Per_Cluster then
-- Current cluster is fully used
Size := Size - B_Per_Cluster;
elsif Size > 0 or else Current = Ent.Start_Cluster then
-- Partially used cluster, but the last one
Size := 0;
if Next /= LAST_CLUSTER_VALUE then
Ret := Ent.FS.Set_FAT (Current, LAST_CLUSTER_VALUE);
end if;
else
-- We don't need more clusters
Ret := Ent.FS.Set_FAT (Current, FREE_CLUSTER_VALUE);
end if;
exit when Ret /= OK;
exit when Ent.FS.Is_Last_Cluster (Next);
Current := Next;
Size := Size - B_Per_Cluster;
end loop;
return Ret;
end Adjust_Clusters;
-------------------------------
-- Find_Empty_Entry_Sequence --
-------------------------------
function Find_Empty_Entry_Sequence
(Parent : access FAT_Directory_Handle;
Num_Entries : Natural) return Entry_Index
is
Status : Status_Code;
D_Entry : FAT_Directory_Entry;
Sequence : Natural := 0;
Ret : Entry_Index;
Cluster : Cluster_Type := Parent.Start_Cluster;
Block : Block_Offset := Cluster_To_Block (Parent.FS.all, Cluster);
begin
Parent.Current_Index := 0;
loop
Status := Next_Entry
(Parent.FS,
Current_Cluster => Cluster,
Current_Block => Block,
Current_Index => Parent.Current_Index,
DEntry => D_Entry);
if Status /= OK then
return Null_Index;
end if;
if D_Entry.Attributes = VFAT_Directory_Entry_Attribute then
if Sequence = 0 then
-- Parent.Current_Index points to the next unread value.
-- So the just read entry is at Parent.Current_Index - 1
Ret := Parent.Current_Index - 1;
end if;
Sequence := Sequence + 1;
elsif Character'Pos (D_Entry.Filename (1)) = 16#E5# then
-- A deleted entry has been found
if Sequence >= Num_Entries then
return Ret;
else
Sequence := 0;
end if;
else
Sequence := 0;
end if;
end loop;
end Find_Empty_Entry_Sequence;
--------------------
-- Allocate_Entry --
--------------------
function Allocate_Entry
(Parent : access FAT_Directory_Handle;
Name : FAT_Name;
Attributes : FAT_Directory_Entry_Attribute;
E : out FAT_Node) return Status_Code
is
subtype Short_Name is String (1 .. 8);
subtype Extension is String (1 .. 3);
function Is_Legal_Character (C : Character) return Boolean
is (C in 'A' .. 'Z'
or else C in '0' .. '9'
or else C = '!'
or else C = '#'
or else C = '$'
or else C = '%'
or else C = '&'
or else C = '''
or else C = '('
or else C = ')'
or else C = '-'
or else C = '@'
or else C = '^'
or else C = '_'
or else C = '`'
or else C = '{'
or else C = '}'
or else C = '~');
Block_Off : Natural;
Status : Status_Code;
DEntry : FAT_Node;
SName : Short_Name := (others => ' ');
SExt : Extension := (others => ' ');
Index : Entry_Index;
-- Retrieve the number of VFAT entries that are needed, plus one for
-- the regular FAT entry.
N_Entries : Natural := Get_Num_VFAT_Entries (Name) + 1;
Bytes : Entry_Data;
procedure To_Short_Name
(Name : FAT_Name;
SName : out Short_Name;
Ext : out Extension);
-- Translates a long name into short 8.3 name
-- If the long name is mixed or lower case. then 8.3 will be uppercased
-- If the long name contains characters not allowed in an 8.3 name, then
-- the name is stripped of invalid characters such as space and extra
-- periods. Other unknown characters are changed to underscores.
-- The stripped name is then truncated, followed by a ~1. Inc_SName
-- below will increase the digit number in case there's overloaded 8.3
-- names.
-- If the long name is longer than 8.3, then ~1 suffix will also be
-- used.
function To_Upper (C : Character) return Character is
(if C in 'a' .. 'z'
then Character'Val
(Character'Pos (C) + Character'Pos ('A') - Character'Pos ('a'))
else C);
function Value (S : String) return Natural;
-- For a positive int represented in S, returns its value
procedure Inc_SName (SName : in out String);
-- Increment the suffix of the short FAT name
-- e.g.:
-- ABCDEFGH => ABCDEF~1
-- ABC => ABC~1
-- ABC~9 => ABC~10
-- ABCDEF~9 => ABCDE~10
procedure To_WString
(S : FAT_Name;
Idx : in out Natural;
WS : in out Wide_String);
-- Dumps S (Idx .. Idx + WS'Length - 1) into WS and increments Idx
-----------
-- Value --
-----------
function Value (S : String) return Natural
is
Val : constant String := Trim (S);
Digit : Natural;
Ret : Natural := 0;
begin
for J in Val'Range loop
Digit := Character'Pos (Val (J)) - Character'Pos ('0');
Ret := Ret * 10 + Digit;
end loop;
return Ret;
end Value;
-------------------
-- To_Short_Name --
-------------------
procedure To_Short_Name
(Name : FAT_Name;
SName : out Short_Name;
Ext : out Extension)
is
S_Idx : Natural := 0;
Add_Tilde : Boolean := False;
Last : Natural := Name.Len;
begin
-- Copy the file extension
Ext := (others => ' ');
for J in reverse 1 .. Name.Len loop
if Name.Name (J) = '.' then
if J = Name.Len then
-- Take care of names ending with a '.' (e.g. no extension,
-- the final '.' is part of the basename)
Last := J;
Ext := (others => ' ');
else
Last := J - 1;
S_Idx := Ext'First;
for K in J + 1 .. Name.Len loop
Ext (S_Idx) := To_Upper (Name.Name (K));
S_Idx := S_Idx + 1;
-- In case the extension is more than 3 characters, we
-- keep the first 3 ones.
exit when S_Idx > Ext'Last;
end loop;
end if;
exit;
end if;
end loop;
S_Idx := 0;
SName := (others => ' ');
for J in 1 .. Last loop
exit when Add_Tilde and then S_Idx >= 6;
exit when not Add_Tilde and then S_Idx = 8;
if Name.Name (J) in 'a' .. 'z' then
S_Idx := S_Idx + 1;
SName (S_Idx) := To_Upper (Name.Name (J));
elsif Is_Legal_Character (Name.Name (J)) then
S_Idx := S_Idx + 1;
SName (S_Idx) := Name.Name (J);
elsif Name.Name (J) = '.'
or else Name.Name (J) = ' '
then
-- dots that are not used as extension delimiters are invalid
-- in FAT short names and ignored in long names to short names
-- translation
Add_Tilde := True;
else
-- Any other character is translated as '_'
Add_Tilde := True;
S_Idx := S_Idx + 1;
SName (S_Idx) := '_';
end if;
end loop;
if Add_Tilde then
if S_Idx >= 6 then
SName (7 .. 8) := "~1";
else
SName (S_Idx + 1 .. S_Idx + 2) := "~1";
end if;
end if;
end To_Short_Name;
---------------
-- Inc_SName --
---------------
procedure Inc_SName (SName : in out String)
is
Idx : Natural := 0;
Num : Natural := 0;
begin
for J in reverse SName'Range loop
if Idx = 0 then
if SName (J) = ' ' then
null;
elsif SName (J) in '0' .. '9' then
Idx := J;
else
SName (SName'Last - 1 .. SName'Last) := "~1";
return;
end if;
elsif SName (J) in '0' .. '9' then
Idx := J;
elsif SName (J) = '~' then
Num := Value (SName (Idx .. SName'Last)) + 1;
-- make Idx point to '~'
Idx := J;
declare
N_Suffix : String := Natural'Image (Num);
begin
N_Suffix (N_Suffix'First) := '~';
if Idx + N_Suffix'Length - 1 > SName'Last then
SName (SName'Last - N_Suffix'Length + 1 .. SName'Last) :=
N_Suffix;
else
SName (Idx .. Idx + N_Suffix'Length - 1) := N_Suffix;
end if;
return;
end;
else
SName (SName'Last - 2 .. SName'Last) := "~1";
return;
end if;
end loop;
SName (SName'Last - 2 .. SName'Last) := "~1";
end Inc_SName;
----------------
-- To_WString --
----------------
procedure To_WString
(S : FAT_Name;
Idx : in out Natural;
WS : in out Wide_String)
is
begin
for J in WS'Range loop
if Idx = S.Len and then S.Name (Idx) = '.' then
WS (J) := Wide_Character'Val (16#F029#);
elsif Idx = S.Len and then S.Name (Idx) = ' ' then
WS (J) := Wide_Character'Val (16#F028#);
elsif Idx = S.Len + 1 then
WS (J) := Wide_Character'Val (0);
elsif Idx > S.Len + 1 then
WS (J) := Wide_Character'Val (16#FFFF#);
else
WS (J) := Wide_Character'Val (Character'Pos (S.Name (Idx)));
end if;
Idx := Idx + 1;
end loop;
end To_WString;
begin
if Parent.FS.Version /= FAT32 then
-- we only support FAT32 for now.
return Internal_Error;
end if;
-- Compute an initial version of the short name
To_Short_Name (Name, SName, SExt);
-- Look for an already existing entry, and compute the short name
Reset (Parent.all);
loop
Status := Read (Parent.all, DEntry);
if Status /= OK then
-- no such existing entry, we're good
Status := OK;
exit;
end if;
-- Can't create a new entry as an old entry with the same long name
-- already exists
if Long_Name (DEntry) = Name then
return Already_Exists;
end if;
if DEntry.S_Name = SName
and then DEntry.S_Name_Ext = SExt
then
Inc_SName (SName);
end if;
end loop;
Reset (Parent.all);
-- Look for an already existing entry that has been deleted and so that
-- we could reuse
Index := Find_Empty_Entry_Sequence (Parent, N_Entries);
if Index = Null_Index then
-- No such free sequence of directory entries are available, so we'll
-- need to allocate new ones
-- At this point, Parent.Current_Index points to the first invalid
-- entry.
Index := Parent.Current_Index;
-- Indicate that a new Entry terminator needs to be added.
N_Entries := N_Entries + 1;
end if;
if Status = OK then
-- we now write down the new entry
declare
VFAT_Entry : array (1 .. Get_Num_VFAT_Entries (Name)) of
VFAT_Directory_Entry;
FAT_Entry : FAT_Directory_Entry;
Idx : Natural := Name.Name'First;
CRC : Unsigned_8 := 0;
C : Unsigned_8;
N_Blocks : Block_Offset;
begin
CRC := 0;
for Ch of String'(SName & SExt) loop
C := Character'Enum_Rep (Ch);
CRC := Shift_Right (CRC and 16#FE#, 1)
or Shift_Left (CRC and 16#01#, 7);
-- Modulo addition
CRC := CRC + C;
end loop;
for J in reverse VFAT_Entry'Range loop
VFAT_Entry (J).VFAT_Attr.Sequence :=
VFAT_Sequence_Number (VFAT_Entry'Last - J + 1);
VFAT_Entry (J).VFAT_Attr.Stop_Bit := False;
VFAT_Entry (J).Attribute := VFAT_Directory_Entry_Attribute;
VFAT_Entry (J).Reserved := 0;
VFAT_Entry (J).Checksum := CRC;
VFAT_Entry (J).Cluster := 0;
To_WString (Name, Idx, VFAT_Entry (J).Name_1);
To_WString (Name, Idx, VFAT_Entry (J).Name_2);
To_WString (Name, Idx, VFAT_Entry (J).Name_3);
end loop;
VFAT_Entry (VFAT_Entry'First).VFAT_Attr.Stop_Bit := True;
E :=
(FS => Parent.FS,
L_Name => Name,
S_Name => SName,
S_Name_Ext => SExt,
Attributes => Attributes,
Start_Cluster => Parent.FS.New_Cluster,
Size => 0,
Index => Index + VFAT_Entry'Length,
Is_Root => False,
Is_Dirty => False);
if E.Start_Cluster = INVALID_CLUSTER then
return Disk_Full;
end if;
FAT_Entry :=
(Filename => SName,
Extension => SExt,
Attributes => Attributes,
Reserved => (others => ASCII.NUL),
Cluster_H =>
Unsigned_16
(Shift_Right
(Unsigned_32 (E.Start_Cluster) and 16#FFFF_0000#, 16)),
Time => 0,
Date => 0,
Cluster_L => Unsigned_16 (E.Start_Cluster and 16#FFFF#),
Size => 0);
-- Now write down the new entries:
-- First reset the directory handle
Reset (Parent.all);
-- Retrieve the block number relative to the first block of the
-- directory content
N_Blocks := Block_Offset
(FAT_File_Size (Index) * 32 / Parent.FS.Block_Size);
-- Check if we need to change cluster
while N_Blocks >= Parent.FS.Blocks_Per_Cluster loop
Parent.Current_Cluster :=
Parent.FS.Get_FAT (Parent.Current_Cluster);
N_Blocks := N_Blocks - Parent.FS.Blocks_Per_Cluster;
end loop;
Parent.Current_Block :=
Parent.FS.Cluster_To_Block (Parent.Current_Cluster) + N_Blocks;
Status := Parent.FS.Ensure_Block (Parent.Current_Block);
if Status /= OK then
return Status;
end if;
for J in 1 .. N_Entries loop
if J <= VFAT_Entry'Last then
Bytes := To_Data (VFAT_Entry (J));
elsif J = VFAT_Entry'Last + 1 then
Bytes := To_Data (FAT_Entry);
else
Bytes := (others => 0);
end if;
Block_Off := Natural
((FAT_File_Size (Index) * 32) mod Parent.FS.Block_Size);
if J > 1 and then Block_Off = 0 then
Status := Parent.FS.Write_Window;
exit when Status /= OK;
N_Blocks := N_Blocks + 1;
if N_Blocks = Parent.FS.Blocks_Per_Cluster then
N_Blocks := 0;
if Parent.FS.Is_Last_Cluster
(Parent.FS.Get_FAT (Parent.Current_Cluster))
then
Parent.Current_Cluster :=
Parent.FS.New_Cluster (Parent.Current_Cluster);
else
Parent.Current_Cluster :=
Parent.FS.Get_FAT (Parent.Current_Cluster);
end if;
Parent.Current_Block :=
Parent.FS.Cluster_To_Block (Parent.Current_Cluster);
else
Parent.Current_Block := Parent.Current_Block + 1;
end if;
Status := Parent.FS.Ensure_Block (Parent.Current_Block);
exit when Status /= OK;
end if;
Parent.FS.Window (Block_Off .. Block_Off + 31) := Bytes;
Index := Index + 1;
end loop;
Status := Parent.FS.Write_Window;
Reset (Parent.all);
end;
end if;
return Status;
end Allocate_Entry;
end Filesystem.FAT.Directories;
|
stcarrez/ada-util | Ada | 5,946 | adb | -----------------------------------------------------------------------
-- util-http-headers -- HTTP Headers
-- Copyright (C) 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.Strings.Fixed;
with Util.Strings.Tokenizers;
package body Util.Http.Headers is
-- ------------------------------
-- Split an accept like header into multiple tokens and a quality value.
-- Invoke the `Process` procedure for each token. Example:
--
-- Accept-Language: de, en;q=0.7, jp, fr;q=0.8, ru
--
-- The `Process` will be called for "de", "en" with quality 0.7,
-- and "jp", "fr" with quality 0.8 and then "ru" with quality 1.0.
-- ------------------------------
procedure Split_Header (Header : in String;
Process : access procedure (Item : in String;
Quality : in Quality_Type)) is
use Util.Strings;
procedure Process_Token (Token : in String;
Done : out Boolean);
Quality : Quality_Type := 1.0;
procedure Process_Token (Token : in String;
Done : out Boolean) is
Name : constant String := Ada.Strings.Fixed.Trim (Token, Ada.Strings.Both);
begin
Process (Name, Quality);
Done := False;
end Process_Token;
Q, N, Pos : Natural;
Last : Natural := Header'First;
begin
while Last < Header'Last loop
Quality := 1.0;
Pos := Index (Header, ';', Last);
if Pos > 0 then
N := Index (Header, ',', Pos);
if N = 0 then
N := Header'Last + 1;
end if;
Q := Pos + 1;
while Q < N loop
if Header (Q .. Q + 1) = "q=" then
begin
Quality := Quality_Type'Value (Header (Q + 2 .. N - 1));
exception
when others =>
null;
end;
exit;
elsif Header (Q) /= ' ' then
exit;
end if;
Q := Q + 1;
end loop;
Util.Strings.Tokenizers.Iterate_Tokens (Content => Header (Last .. Pos - 1),
Pattern => ",",
Process => Process_Token'Access);
Last := N + 1;
else
Util.Strings.Tokenizers.Iterate_Tokens (Content => Header (Last .. Header'Last),
Pattern => ",",
Process => Process_Token'Access);
return;
end if;
end loop;
end Split_Header;
-- ------------------------------
-- Get the accepted media according to the `Accept` header value and a list
-- of media/mime types. The quality matching and wildcard are handled
-- so that we return the best match. With the following HTTP header:
--
-- Accept: image/*; q=0.2, image/jpeg
--
-- and if the mimes list contains `image/png` but not `image/jpeg`, the
-- first one is returned. If the list contains both, then `image/jpeg` is
-- returned.
-- ------------------------------
function Get_Accepted (Header : in String;
Mimes : in Util.Http.Mimes.Mime_List)
return Util.Http.Mimes.Mime_Access is
procedure Process_Accept (Name : in String;
Quality : in Quality_Type);
Selected : Util.Http.Mimes.Mime_Access;
Selected_Quality : Quality_Type := 0.0;
procedure Process_Accept (Name : in String;
Quality : in Quality_Type) is
Pos : Natural;
begin
if Quality > Selected_Quality then
Pos := Util.Strings.Index (Name, '*');
if Pos = 0 then
for Mime of Mimes loop
if Name = Mime.all then
Selected := Mime;
Selected_Quality := Quality;
return;
end if;
end loop;
elsif Name = "*/*" then
Selected := Mimes (Mimes'First);
Selected_Quality := Quality;
return;
else
Pos := Pos - 1;
if Pos <= Name'First then
return;
end if;
if Name (Pos .. Name'Last) /= "/*" then
return;
end if;
for Mime of Mimes loop
if Util.Strings.Starts_With (Mime.all, Name (Name'First .. Pos)) then
Selected := Mime;
Selected_Quality := Quality;
return;
end if;
end loop;
end if;
end if;
end Process_Accept;
begin
if Mimes'Length > 0 then
if Header'Length > 0 then
Split_Header (Header, Process_Accept'Access);
else
Selected := Mimes (Mimes'First);
end if;
end if;
return Selected;
end Get_Accepted;
end Util.Http.Headers;
|
peterfrankjohnson/assembler | Ada | 4,633 | adb | with Token; use Token;
package body Lexer is
Filename : String := "test.asm";
InputFile : Ada.Text_IO.File_Type;
Mode : File_Mode := Ada.Text_IO.In_File;
Char : Character;
DiscardedChar : Character;
EOL : Boolean;
Token : Unbounded_String;
procedure Initialise is
begin
Open (InputFile, Mode, FileName);
end Initialise;
procedure ReadCharIntoToken is
begin
Get (InputFile, Char);
Token := Token & Char;
end ReadCharIntoToken;
procedure LookAhead is
begin
Look_Ahead (InputFile, Char, EOL);
end LookAhead;
procedure Discard is
begin
Get (InputFile, Char);
end Discard;
function FetchToken return TokenRecord is
Token1 : TokenRecord;
begin
-- Initialise;
while not End_Of_File (InputFile) loop
Token := To_Unbounded_String ("");
EOL := False;
LookAhead;
if EOL then
-- Put_Line ("<EOL>");
Ada.text_IO.Skip_Line (InputFile);
else
case Char is
-- TAB / SPACE
when Character'Val (9) |
' ' =>
Discard;
when '[' =>
-- Put_Line ("<LEFTBRACKET>");
Discard;
when ']' =>
-- Put_Line ("<RIGHTBRACKET>");
Discard;
when ',' =>
-- Put_Line ("<COMMA>");
Discard;
when ';' =>
Discard;
loop
LookAhead;
if EOL then
Ada.text_IO.Skip_Line (InputFile);
exit;
else
Discard;
end if;
end loop;
when 'a' .. 'z' |
'A' .. 'Z' =>
ReadCharIntoToken;
loop
LookAhead;
case Char is
when 'a' .. 'z' |
'A' .. 'Z' |
'0' .. '9' |
'_' =>
ReadCharIntoToken;
when ':' =>
-- LABEL
ReadCharIntoToken;
-- Put_Line("<LABEL> - " & To_String (Token));
Token1.TokenString := Token;
Token1.TypeOfToken := StringLabel;
return Token1;
-- exit;
when others =>
-- Put_Line("<TOKEN> - " & To_String (Token));
Token1.TokenString := Token;
Token1.TypeOfToken := StringToken;
return Token1;
-- exit;
end case;
end loop;
-- LOCAL LABEL??
when '.' =>
ReadCharIntoToken;
loop
LookAhead;
case Char is
when 'a' .. 'z' |
'A' .. 'Z' |
'0' .. '9' |
'_' =>
ReadCharIntoToken;
when ':' =>
-- LABEL
exit;
when others =>
exit;
end case;
end loop;
-- Put_Line("<LOCALLABEL> - " & To_String (Token));
when '0' .. '9' =>
ReadCharIntoToken;
loop
LookAhead;
case Char is
when 'a' .. 'z' |
'A' .. 'Z' |
'0' .. '9' |
'_' =>
ReadCharIntoToken;
when others =>
Token1.TokenString := Token;
Token1.TypeOfToken := StringToken;
return Token1;
end case;
end loop;
-- Put_Line("<NUMBER> - " & To_String (Token));
when others =>
-- Put_Line ("other: '" & Char & "'");
Discard;
end case;
end if;
end loop;
return Token1;
end FetchToken;
end Lexer; |
reznikmm/slimp | Ada | 25,930 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Streams;
with Ada.Streams.Stream_IO;
with Ada.Unchecked_Deallocation;
with Ada.Wide_Wide_Text_IO;
with Interfaces;
with System;
with League.IRIs;
with League.Settings;
with League.String_Vectors;
with League.Holders;
with Slim.Menu_Models.JSON;
with Slim.Message_Decoders;
with Slim.Message_Visiters;
with Slim.Messages.audg;
with Slim.Messages.strm;
with Slim.Players.Connected_State_Visiters;
with Slim.Players.Displays;
with Slim.Players.Idle_State_Visiters;
with Slim.Players.Play_Radio_Visiters;
with Slim.Players.Play_Files_Visiters;
package body Slim.Players is
Hearbeat_Period : constant := 5.0;
procedure Read_Message
(Socket : GNAT.Sockets.Socket_Type;
Message : out Slim.Messages.Message_Access);
procedure Send_Hearbeat (Self : in out Player'Class);
procedure Read_Splash
(Splash : out League.Stream_Element_Vectors.Stream_Element_Vector;
File : League.Strings.Universal_String);
procedure Free is new Ada.Unchecked_Deallocation
(Slim.Messages.Message'Class, Slim.Messages.Message_Access);
function Seconds_To_Bytes
(File : League.Strings.Universal_String;
Skip : Positive) return League.Strings.Universal_String;
----------------
-- First_Menu --
----------------
function First_Menu
(Self : Player'Class) return Slim.Menu_Views.Menu_View
is
Ignore : Boolean;
begin
return Result : Slim.Menu_Views.Menu_View do
Result.Initialize
(Menu => Slim.Menu_Models.Menu_Model_Access (Self.Menu),
Font => Self.Font'Unchecked_Access);
end return;
end First_Menu;
-----------------
-- Get_Display --
-----------------
function Get_Display
(Self : Player;
Height : Positive := 32;
Width : Positive := 160) return Slim.Players.Displays.Display
is
Size : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset (Height * Width / 8);
begin
return Result : Slim.Players.Displays.Display (Size) do
Slim.Players.Displays.Initialize (Result, Self);
end return;
end Get_Display;
------------------
-- Get_Position --
------------------
procedure Get_Position
(Self : in out Player'Class;
M3U : League.Strings.Universal_String;
Index : out Positive;
Skip : out Natural)
is
pragma Unreferenced (Self);
Setting : League.Settings.Settings;
Key : League.Strings.Universal_String;
Value : League.Holders.Holder;
begin
Key.Append ("Pause/Index.");
Key.Append (M3U);
Value := Setting.Value (Key);
if League.Holders.Is_Universal_String (Value) then
Key := League.Holders.Element (Value);
Index := Positive'Wide_Wide_Value (Key.To_Wide_Wide_String);
else
Index := 1;
end if;
Key.Clear;
Key.Append ("Pause/Skip.");
Key.Append (M3U);
Value := Setting.Value (Key);
if League.Holders.Is_Universal_String (Value) then
Key := League.Holders.Element (Value);
Skip := Natural'Wide_Wide_Value (Key.To_Wide_Wide_String);
else
Skip := 0;
end if;
end Get_Position;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Player'Class;
Socket : GNAT.Sockets.Socket_Type;
Font : League.Strings.Universal_String;
Splash : League.Strings.Universal_String;
Menu : League.Strings.Universal_String) is
begin
Self.Socket := Socket;
GNAT.Sockets.Set_Socket_Option
(Self.Socket,
GNAT.Sockets.Socket_Level,
(GNAT.Sockets.Receive_Timeout, Hearbeat_Period));
Slim.Fonts.Read (Self.Font, Font);
Read_Splash (Self.Splash, Splash);
Self.Menu :=
new Slim.Menu_Models.JSON.JSON_Menu_Model (Self'Unchecked_Access);
Slim.Menu_Models.JSON.JSON_Menu_Model (Self.Menu.all).Initialize
(File => Menu);
end Initialize;
----------------
-- Play_Files --
----------------
procedure Play_Files
(Self : in out Player'Class;
Root : League.Strings.Universal_String;
M3U : League.Strings.Universal_String;
List : Song_Array;
From : Positive;
Skip : Natural)
is
use type Ada.Calendar.Time;
Playlist : Song_Vectors.Vector;
begin
for X of List loop
Playlist.Append (X);
end loop;
Self.State :=
(Play_Files,
(Volume => 30,
Volume_Set_Time => Ada.Calendar.Clock - 60.0,
Current_Song => List (From).Title,
Paused => False,
Seconds => 0),
Root, M3U, Playlist, From, Skip);
Self.Request_Next_File;
end Play_Files;
--------------------
-- Play_Next_File --
--------------------
procedure Play_Next_File
(Self : in out Player'Class;
Immediate : Boolean := True) is
begin
if Self.State.Kind /= Play_Files then
return;
elsif Immediate then
declare
strm : Slim.Messages.strm.Strm_Message;
begin
strm.Simple_Command (Command => Slim.Messages.strm.Flush);
Write_Message (Self.Socket, strm);
end;
end if;
if Self.State.Index < Self.State.Playlist.Last_Index then
Self.State.Index := Self.State.Index + 1;
Self.State.Offset := 0;
Self.Request_Next_File;
else
Self.Stop;
end if;
end Play_Next_File;
------------------------
-- Play_Previous_File --
------------------------
procedure Play_Previous_File (Self : in out Player'Class;
Immediate : Boolean := True) is
begin
if Self.State.Kind /= Play_Files then
return;
elsif Immediate then
declare
strm : Slim.Messages.strm.Strm_Message;
begin
strm.Simple_Command (Command => Slim.Messages.strm.Flush);
Write_Message (Self.Socket, strm);
end;
end if;
if Self.State.Index > 1 then
Self.State.Index := Self.State.Index - 1;
Self.Request_Next_File;
else
Self.Stop;
end if;
end Play_Previous_File;
----------------
-- Play_Radio --
----------------
procedure Play_Radio
(Self : in out Player'Class;
URL : League.Strings.Universal_String)
is
use type Ada.Calendar.Time;
IRI : constant League.IRIs.IRI :=
League.IRIs.From_Universal_String (URL);
Host : League.Strings.Universal_String := IRI.Get_Host;
Port : constant Natural := IRI.Get_Port;
Port_Image : Wide_Wide_String := Integer'Wide_Wide_Image (Port);
Addr : GNAT.Sockets.Inet_Addr_Type;
Strm : Slim.Messages.strm.Strm_Message;
Request : League.String_Vectors.Universal_String_Vector;
Line : League.Strings.Universal_String;
begin
Self.Stop;
declare
Host_Entry : constant GNAT.Sockets.Host_Entry_Type :=
GNAT.Sockets.Get_Host_By_Name (Host.To_UTF_8_String);
begin
for J in 1 .. Host_Entry.Addresses_Length loop
Addr := GNAT.Sockets.Addresses (Host_Entry, J);
exit when Addr.Family in GNAT.Sockets.Family_Inet;
end loop;
end;
if Addr.Family not in GNAT.Sockets.Family_Inet then
return;
end if;
if Port /= 0 then
Port_Image (1) := ':';
Host.Append (Port_Image);
end if;
Line := +"GET /";
Line.Append (IRI.Get_Path.Join ('/'));
Line.Append (" HTTP/1.0");
Ada.Wide_Wide_Text_IO.Put_Line (Line.To_Wide_Wide_String);
Request.Append (Line);
Line := +"Host: ";
Line.Append (Host);
Request.Append (Line);
Request.Append (+"Icy-Metadata: 1");
Request.Append (+"");
Request.Append (+"");
Strm.Start
(Server => (GNAT.Sockets.Family_Inet,
Addr,
Port => GNAT.Sockets.Port_Type (Port)),
Request => Request);
Write_Message (Self.Socket, Strm);
Self.State :=
(Play_Radio,
(Volume => 30,
Volume_Set_Time => Ada.Calendar.Clock - 60.0,
Current_Song => League.Strings.Empty_Universal_String,
Paused => False,
Seconds => 0));
exception
when GNAT.Sockets.Host_Error =>
return;
end Play_Radio;
---------------------
-- Process_Message --
---------------------
not overriding procedure Process_Message (Self : in out Player) is
use type Ada.Calendar.Time;
function Get_Visiter return Slim.Message_Visiters.Visiter'Class;
function Get_Visiter return Slim.Message_Visiters.Visiter'Class is
begin
case Self.State.Kind is
when Connected =>
return V : Connected_State_Visiters.Visiter
(Self'Unchecked_Access);
when Idle =>
return V : Idle_State_Visiters.Visiter
(Self'Unchecked_Access);
when Play_Radio =>
return V : Play_Radio_Visiters.Visiter
(Self'Unchecked_Access);
when Play_Files =>
return V : Play_Files_Visiters.Visiter
(Self'Unchecked_Access);
end case;
end Get_Visiter;
V : Slim.Message_Visiters.Visiter'Class := Get_Visiter;
begin
if Self.State.Kind /= Connected
and then Ada.Calendar.Clock - Self.Ping > 5.0
then
Send_Hearbeat (Self);
end if;
declare
Message : Slim.Messages.Message_Access;
begin
Read_Message (Self.Socket, Message);
Message.Visit (V);
Free (Message);
exception
when E : GNAT.Sockets.Socket_Error =>
case GNAT.Sockets.Resolve_Exception (E) is
when GNAT.Sockets.Resource_Temporarily_Unavailable =>
Send_Hearbeat (Self);
when others =>
raise;
end case;
end;
end Process_Message;
------------------
-- Read_Message --
------------------
procedure Read_Message
(Socket : GNAT.Sockets.Socket_Type;
Message : out Slim.Messages.Message_Access)
is
use type Ada.Streams.Stream_Element_Offset;
Tag : Slim.Messages.Message_Tag;
Raw_Tag : Ada.Streams.Stream_Element_Array (1 .. 4)
with Address => Tag'Address;
Word : Ada.Streams.Stream_Element_Array (1 .. 4);
Length : Ada.Streams.Stream_Element_Offset := 0;
Last : Ada.Streams.Stream_Element_Offset;
Data : aliased League.Stream_Element_Vectors.Stream_Element_Vector;
Decoder : Slim.Message_Decoders.Decoder;
begin
GNAT.Sockets.Receive_Socket (Socket, Raw_Tag, Last);
if Last = 0 then
-- Timeout
return;
end if;
pragma Assert (Last = Raw_Tag'Length);
GNAT.Sockets.Receive_Socket (Socket, Word, Last);
pragma Assert (Last = Word'Length);
for Byte of Word loop
Length := Length * 256 + Ada.Streams.Stream_Element_Offset (Byte);
end loop;
while Length > 0 loop
declare
Piece : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset'Min (Length, 256);
Input : Ada.Streams.Stream_Element_Array (1 .. Piece);
begin
GNAT.Sockets.Receive_Socket (Socket, Input, Last);
pragma Assert (Last = Input'Length);
Data.Append (Input);
Length := Length - Last;
end;
end loop;
Decoder.Decode (Tag, Data'Unchecked_Access, Message);
end Read_Message;
-----------------
-- Read_Splash --
-----------------
procedure Read_Splash
(Splash : out League.Stream_Element_Vectors.Stream_Element_Vector;
File : League.Strings.Universal_String)
is
Size : constant := 32 * 160 / 8;
Data : Ada.Streams.Stream_Element_Array (1 .. Size);
Last : Ada.Streams.Stream_Element_Offset;
Input : Ada.Streams.Stream_IO.File_Type;
begin
Ada.Streams.Stream_IO.Open
(Input,
Mode => Ada.Streams.Stream_IO.In_File,
Name => File.To_UTF_8_String);
Ada.Streams.Stream_IO.Read (Input, Data, Last);
pragma Assert (Last in Data'Last);
Ada.Streams.Stream_IO.Close (Input);
Splash.Clear;
Splash.Append (Data);
end Read_Splash;
-----------------------
-- Request_Next_File --
-----------------------
procedure Request_Next_File (Self : in out Player'Class) is
use type League.Strings.Universal_String;
Item : constant Song := Self.State.Playlist (Self.State.Index);
File : constant League.Strings.Universal_String := Item.File;
Strm : Slim.Messages.strm.Strm_Message;
Request : League.String_Vectors.Universal_String_Vector;
Line : League.Strings.Universal_String;
begin
Line.Append ("GET /Music/");
Line.Append (File);
Line.Append (" HTTP/1.0");
Ada.Wide_Wide_Text_IO.Put_Line (Line.To_Wide_Wide_String);
Request.Append (Line);
if Self.State.Offset > 0 then
Line.Clear;
Line.Append ("Range: ");
Line.Append
(Seconds_To_Bytes
(Self.State.Root & File, Self.State.Offset));
Request.Append (Line);
Ada.Wide_Wide_Text_IO.Put_Line (Line.To_Wide_Wide_String);
end if;
Request.Append (+"");
Request.Append (+"");
Strm.Start
(Server => (GNAT.Sockets.Family_Inet,
GNAT.Sockets.Inet_Addr ("0.0.0.0"),
Port => 8080),
Request => Request);
Write_Message (Self.Socket, Strm);
Self.State.Play_State.Current_Song := Item.Title;
end Request_Next_File;
-------------------
-- Save_Position --
-------------------
procedure Save_Position (Self : in out Player'Class) is
use type League.Strings.Universal_String;
Setting : League.Settings.Settings;
Value : League.Strings.Universal_String;
Skip : constant Natural :=
Self.State.Offset + Self.State.Play_State.Seconds;
begin
if Self.State.Kind /= Play_Files
or else Self.State.M3U_Name.Is_Empty
then
return;
end if;
Value.Append (Integer'Wide_Wide_Image (Self.State.Index));
Value := Value.Tail_From (2);
Setting.Set_Value
("Pause/Index." & Self.State.M3U_Name,
League.Holders.To_Holder (Value));
Value.Clear;
Value.Append (Integer'Wide_Wide_Image (Skip));
Value := Value.Tail_From (2);
Setting.Set_Value
("Pause/Skip." & Self.State.M3U_Name,
League.Holders.To_Holder (Value));
end Save_Position;
----------------------
-- Seconds_To_Bytes --
----------------------
function Seconds_To_Bytes
(File : League.Strings.Universal_String;
Skip : Positive) return League.Strings.Universal_String
is
procedure Read_ID3 (Input : in out Ada.Streams.Stream_IO.File_Type);
-- Skip ID3 header if any
procedure Read_MP3_Header
(Input : in out Ada.Streams.Stream_IO.File_Type;
Bit_Rate : out Ada.Streams.Stream_Element_Count);
function Image (Value : Ada.Streams.Stream_Element_Count)
return Wide_Wide_String;
-----------
-- Image --
-----------
function Image (Value : Ada.Streams.Stream_Element_Count)
return Wide_Wide_String
is
Img : constant Wide_Wide_String :=
Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Value);
begin
return Img (2 .. Img'Last);
end Image;
--------------
-- Read_ID3 --
--------------
procedure Read_ID3 (Input : in out Ada.Streams.Stream_IO.File_Type) is
use type Ada.Streams.Stream_Element;
use type Ada.Streams.Stream_Element_Count;
use type Ada.Streams.Stream_IO.Count;
Index : constant Ada.Streams.Stream_IO.Positive_Count :=
Ada.Streams.Stream_IO.Index (Input);
Data : Ada.Streams.Stream_Element_Array (1 .. 10);
Last : Ada.Streams.Stream_Element_Count;
Skip : Ada.Streams.Stream_IO.Count := 0;
begin
Ada.Streams.Stream_IO.Read (Input, Data, Last);
if Last = Data'Last
and then Data (1) = Character'Pos ('I')
and then Data (2) = Character'Pos ('D')
and then Data (3) = Character'Pos ('3')
then
for J of Data (7 .. 10) loop
Skip := Skip * 128 + Ada.Streams.Stream_IO.Count (J);
end loop;
Ada.Streams.Stream_IO.Set_Index
(Input, Index + Data'Length + Skip);
else
Ada.Streams.Stream_IO.Set_Index (Input, Index);
end if;
end Read_ID3;
---------------------
-- Read_MP3_Header --
---------------------
procedure Read_MP3_Header
(Input : in out Ada.Streams.Stream_IO.File_Type;
Bit_Rate : out Ada.Streams.Stream_Element_Count)
is
use type Interfaces.Unsigned_16;
use type Ada.Streams.Stream_IO.Count;
type MPEG_Version is (MPEG_2_5, Wrong, MPEG_2, MPEG_1);
pragma Unreferenced (Wrong);
for MPEG_Version use (0, 1, 2, 3);
type MPEG_Layer is (Wrong, Layer_III, Layer_II, Layer_I);
pragma Unreferenced (Wrong);
for MPEG_Layer use (0, 1, 2, 3);
type MPEG_Mode is (Stereo, Joint_Stereo, Dual_Channel, Mono);
pragma Unreferenced (Stereo, Joint_Stereo, Dual_Channel, Mono);
for MPEG_Mode use (0, 1, 2, 3);
type MP3_Header is record
Sync_Word : Interfaces.Unsigned_16 range 0 .. 2 ** 11 - 1;
Version : MPEG_Version;
Layer : MPEG_Layer;
Protection : Boolean;
Bit_Rate : Interfaces.Unsigned_8 range 0 .. 15;
Frequency : Interfaces.Unsigned_8 range 0 .. 3;
Padding : Boolean;
Is_Private : Boolean;
Mode : MPEG_Mode;
Extension : Interfaces.Unsigned_8 range 0 .. 3;
Copy : Boolean;
Original : Boolean;
Emphasis : Interfaces.Unsigned_8 range 0 .. 3;
end record;
for MP3_Header'Object_Size use 32;
for MP3_Header'Bit_Order use System.High_Order_First;
for MP3_Header use record
Sync_Word at 0 range 0 .. 10;
Version at 0 range 11 .. 12;
Layer at 0 range 13 .. 14;
Protection at 0 range 15 .. 15;
Bit_Rate at 0 range 16 .. 19;
Frequency at 0 range 20 .. 21;
Padding at 0 range 22 .. 22;
Is_Private at 0 range 23 .. 23;
Mode at 0 range 24 .. 25;
Extension at 0 range 26 .. 27;
Copy at 0 range 28 .. 28;
Original at 0 range 29 .. 29;
Emphasis at 0 range 30 .. 31;
end record;
procedure Read_Header (Header : out MP3_Header);
MPEG_1_Bit_Rate : constant array
(MPEG_Layer range Layer_III .. Layer_I,
Interfaces.Unsigned_8 range 1 .. 14) of
Ada.Streams.Stream_Element_Count :=
(Layer_I => (32_000, 64_000, 96_000, 128_000, 160_000, 192_000,
224_000, 256_000, 288_000, 320_000, 352_000, 384_000,
416_000, 448_000),
Layer_II => (32_000, 48_000, 56_000, 64_000, 80_000, 96_000,
112_000, 128_000, 160_000, 192_000, 224_000,
256_000, 320_000, 384_000),
Layer_III => (32_000, 40_000, 48_000, 56_000, 64_000, 80_000,
96_000, 112_000, 128_000, 160_000, 192_000,
224_000, 256_000, 320_000));
MPEG_2_Bit_Rate : constant array
(MPEG_Layer range Layer_II .. Layer_I,
Interfaces.Unsigned_8 range 1 .. 14) of
Ada.Streams.Stream_Element_Count :=
(Layer_I => (32_000, 48_000, 56_000, 64_000, 80_000, 96_000,
112_000, 128_000, 144_000, 160_000, 176_000, 192_000,
224_000, 256_000),
Layer_II => (8_000, 16_000, 24_000, 32_000, 40_000, 48_000,
56_000, 64_000, 80_000, 96_000, 112_000,
128_000, 144_000, 160_000));
-----------------
-- Read_Header --
-----------------
procedure Read_Header (Header : out MP3_Header) is
use type System.Bit_Order;
Stream : constant Ada.Streams.Stream_IO.Stream_Access :=
Ada.Streams.Stream_IO.Stream (Input);
Data : Ada.Streams.Stream_Element_Array (1 .. 4)
with Import, Address => Header'Address;
begin
if MP3_Header'Bit_Order = System.Default_Bit_Order then
Ada.Streams.Stream_Element_Array'Read (Stream, Data);
else
for X of reverse Data loop
Ada.Streams.Stream_Element'Read (Stream, X);
end loop;
end if;
end Read_Header;
Header : MP3_Header := (Sync_Word => 0, others => <>);
begin
while not Ada.Streams.Stream_IO.End_Of_File (Input) loop
Read_Header (Header);
exit when Header.Sync_Word = 16#7FF#;
Ada.Streams.Stream_IO.Set_Index
(Input,
Ada.Streams.Stream_IO.Index (Input) - 3);
end loop;
if Header.Sync_Word /= 16#7FF# then
Bit_Rate := 0;
elsif Header.Version = MPEG_1 and
Header.Layer in MPEG_1_Bit_Rate'Range (1) and
Header.Bit_Rate in MPEG_1_Bit_Rate'Range (2)
then
Bit_Rate := MPEG_1_Bit_Rate (Header.Layer, Header.Bit_Rate);
elsif Header.Version in MPEG_2 .. MPEG_2_5 and
Header.Layer in Layer_III .. Layer_I and
Header.Bit_Rate in MPEG_2_Bit_Rate'Range (2)
then
Bit_Rate := MPEG_2_Bit_Rate
(MPEG_Layer'Max (Header.Layer, Layer_II),
Header.Bit_Rate);
else
Bit_Rate := 0;
end if;
end Read_MP3_Header;
use type Ada.Streams.Stream_Element_Count;
Input : Ada.Streams.Stream_IO.File_Type;
Bit_Rate : Ada.Streams.Stream_Element_Count;
Offset : Ada.Streams.Stream_Element_Count;
Result : League.Strings.Universal_String;
begin
Ada.Streams.Stream_IO.Open
(Input, Ada.Streams.Stream_IO.In_File, File.To_UTF_8_String);
Read_ID3 (Input);
Read_MP3_Header (Input, Bit_Rate);
Offset := Bit_Rate * Ada.Streams.Stream_Element_Count (Skip) / 8;
Result.Append ("bytes=");
Result.Append (Image (Offset));
Result.Append ("-");
Ada.Streams.Stream_IO.Close (Input);
return Result;
end Seconds_To_Bytes;
-------------------
-- Send_Hearbeat --
-------------------
procedure Send_Hearbeat (Self : in out Player'Class) is
strm : Slim.Messages.strm.Strm_Message;
begin
strm.Simple_Command
(Command => Slim.Messages.strm.Status);
Write_Message (Self.Socket, strm);
Self.Ping := Ada.Calendar.Clock;
end Send_Hearbeat;
----------
-- Stop --
----------
procedure Stop (Self : in out Player'Class) is
use type Ada.Calendar.Time;
Strm : Slim.Messages.strm.Strm_Message;
begin
if Self.State.Kind in Play_Radio | Play_Files then
Strm.Simple_Command (Slim.Messages.strm.Stop);
Write_Message (Self.Socket, Strm);
Self.State :=
(Idle,
Ada.Calendar.Clock - 60.0,
Self.First_Menu);
Self.Send_Hearbeat; -- A reply to this will update display
end if;
end Stop;
------------
-- Volume --
------------
procedure Volume
(Self : in out Player'Class;
Value : Natural)
is
Audg : Slim.Messages.audg.Audg_Message;
begin
if Self.State.Kind in Play_Radio | Play_Files then
Self.State.Play_State.Volume := Value;
Self.State.Play_State.Volume_Set_Time := Ada.Calendar.Clock;
end if;
Audg.Set_Volume (Value);
Write_Message (Self.Socket, Audg);
end Volume;
-------------------
-- Write_Message --
-------------------
procedure Write_Message
(Socket : GNAT.Sockets.Socket_Type;
Message : Slim.Messages.Message'Class)
is
use type Ada.Streams.Stream_Element_Offset;
use type Ada.Streams.Stream_Element_Array;
Data : League.Stream_Element_Vectors.Stream_Element_Vector;
Tag : Slim.Messages.Message_Tag;
Raw_Tag : Ada.Streams.Stream_Element_Array (1 .. 4)
with Address => Tag'Address;
Word : Ada.Streams.Stream_Element_Array (1 .. 2);
Length : Ada.Streams.Stream_Element_Offset;
Last : Ada.Streams.Stream_Element_Offset;
begin
Message.Write (Tag, Data);
Length := Raw_Tag'Length + Data.Length;
Word (1) := Ada.Streams.Stream_Element
(Length / Ada.Streams.Stream_Element'Modulus);
Word (2) := Ada.Streams.Stream_Element
(Length mod Ada.Streams.Stream_Element'Modulus);
GNAT.Sockets.Send_Socket
(Socket, Word & Raw_Tag & Data.To_Stream_Element_Array, Last);
pragma Assert (Last = Length + Word'Length);
end Write_Message;
end Slim.Players;
|
charlie5/cBound | Ada | 609 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with gmp_c.Pointers;
with Interfaces.C;
package gmp_c.mp_ptr is
-- Item
--
subtype Item is gmp_c.Pointers.mp_limb_t_Pointer;
-- Items
--
type Items is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mp_ptr.Item;
-- Pointer
--
type Pointer is access all gmp_c.mp_ptr.Item;
-- Pointers
--
type Pointers is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mp_ptr.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all gmp_c.mp_ptr.Pointer;
end gmp_c.mp_ptr;
|
zhmu/ananas | Ada | 84 | adb | -- { dg-do compile }
package body Ghost5 is
procedure Foo is null;
end Ghost5;
|
LaplaceKorea/curve25519-spark2014 | Ada | 2,702 | adb | package body Construct_Conversion_Array with
SPARK_Mode
is
----------------------
-- Conversion_Array --
----------------------
function Conversion_Array return Conversion_Array_Type is
Conversion_Array : Conversion_Array_Type := (others => Zero);
begin
for J in Product_Index_Type loop
Conversion_Array (J) := Two_Power (Exposant (J));
pragma Loop_Invariant (for all K in 0 .. J => Conversion_Array (K) = Two_Power (Exposant (K)));
end loop;
Prove_Property (Conversion_Array);
return Conversion_Array;
end Conversion_Array;
--------------------
-- Prove_Property --
--------------------
procedure Prove_Property (Conversion_Array : Conversion_Array_Type) is
begin
for J in Index_Type loop
for K in Index_Type loop
Exposant_Lemma (J, K); -- The two lemmas will help solvers
Two_Power_Lemma (Exposant (J), Exposant (K)); -- to prove the following code.
pragma Assert (Two_Power (Exposant (J)) = Conversion_Array (J)
and then Two_Power (Exposant (K)) = Conversion_Array (K)
and then Two_Power (Exposant (J + K)) = Conversion_Array (J + K));
-- A reminder of the precondition
-- The following code will split the two different cases of
-- Property. In the statements, assertions are used to guide
-- provers to the goal.
if J mod 2 = 1 and then K mod 2 = 1 then
pragma Assert (Exposant (J + K) + 1 = Exposant (J) + Exposant (K));
pragma Assert (Two_Power (Exposant (J + K) + 1)
= Two_Power (Exposant (J)) * Two_Power (Exposant (K)));
pragma Assert (Two_Power (Exposant (J + K)) * (+2)
= Two_Power (Exposant (J)) * Two_Power (Exposant (K)));
pragma Assert (Property (Conversion_Array, J, K));
else
pragma Assert (Exposant (J + K) = Exposant (J) + Exposant (K));
pragma Assert (Two_Power (Exposant (J + K)) = Two_Power (Exposant (J)) * Two_Power (Exposant (K)));
pragma Assert (Property (Conversion_Array, J, K));
end if;
pragma Loop_Invariant (for all M in 0 .. K =>
Property (Conversion_Array, J, M));
end loop;
pragma Loop_Invariant (for all L in 0 .. J =>
(for all M in Index_Type =>
Property (Conversion_Array, L, M)));
end loop;
end Prove_Property;
end Construct_Conversion_Array;
|
reznikmm/matreshka | Ada | 3,739 | 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.Grddl_Transformation_Attributes is
pragma Preelaborate;
type ODF_Grddl_Transformation_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Grddl_Transformation_Attribute_Access is
access all ODF_Grddl_Transformation_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Grddl_Transformation_Attributes;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 1,487 | adb | with STM32GD;
with Interfaces; use Interfaces;
with Utils;
package body Config is
type Config_Tag is (Invalid_Tag, Mode_Config_Tag) with Size => 1;
for Config_Tag use (Invalid_Tag => -1, Mode_Config_Tag => 0);
type Mote_Config_Type is record
Tag : Config_Tag;
Length : Unsigned_8;
Git_Short_Hash : String (1 ..12);
TX_Power : Integer_8;
Transmit_Interval : Unsigned_16;
end record with Volatile;
Mote_Config : Mote_Config_Type := (
Tag => Mode_Config_Tag,
Length => Mote_Config_Type'Size / 8,
Git_Short_Hash => "$Id$ ",
TX_Power => -1,
Transmit_Interval => 900)
with Export => True, External_Name => "config_data";
pragma Linker_Section (Mote_Config, ".config");
function TX_Power return Integer is
begin
return Integer (Mote_Config.TX_Power);
end TX_Power;
function Transmit_Interval return Natural is
begin
return Natural (Mote_Config.Transmit_Interval);
end Transmit_Interval;
procedure Get_Git_Short_Hash (Hash : out String) is
begin
Hash := Mote_Config.Git_Short_Hash (6 .. 12);
end Get_Git_Short_Hash;
procedure Get_Node_Name (Name: out String) is
HW_ID : Unsigned_32;
UID : STM32GD.UID_Type := STM32GD.UID;
begin
HW_ID := UID (1) xor UID (2) xor UID (3);
Name := Utils.To_Hex_String (HW_ID);
end Get_Node_Name;
end Config;
|
AdaCore/libadalang | Ada | 154 | adb | procedure Lol is
type Int is range 1 .. 110;
type Int_2 is new Int;
procedure A (I : Int_2);
begin
A (12);
pragma Test_Statement;
end Lol;
|
AdaCore/gpr | Ada | 2,852 | adb | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with GPR2.Unit;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Source.Set;
with GPR2.Project.View;
with GPR2.Project.Tree;
with GPR2.Source_Info.Parser.Ada_Language;
procedure Main is
use Ada;
use GPR2;
use GPR2.Project;
procedure Check (Project_Name : Filename_Type);
-- Do check the given project's sources
procedure Output_Filename (Filename : Path_Name.Full_Name);
-- Remove the leading tmp directory
-----------
-- Check --
-----------
procedure Check (Project_Name : Filename_Type) is
procedure List_Sources (View : Project.View.Object);
procedure Copy_Source (Name : String);
-- Copy source file from srcp directory to src
------------------
-- List_Sources --
------------------
procedure List_Sources (View : Project.View.Object) is
begin
Text_IO.Put_Line ("----------");
for Source of View.Sources loop
declare
U : constant Optional_Name_Type := Source.Unit_Name;
begin
Output_Filename (Source.Path_Name.Value);
Text_IO.Set_Col (20);
Text_IO.Put (" language: " & Image (Source.Language));
Text_IO.Set_Col (36);
Text_IO.Put
(" Kind: "
& GPR2.Unit.Library_Unit_Type'Image (Source.Kind));
if U /= "" then
Text_IO.Set_Col (60);
Text_IO.Put ("unit: " & String (U));
end if;
Text_IO.New_Line;
end;
end loop;
end List_Sources;
-----------------
-- Copy_Source --
-----------------
procedure Copy_Source (Name : String) is
begin
Ada.Directories.Copy_File ("srcp/" & Name, "src/" & Name);
end Copy_Source;
Prj : Project.Tree.Object;
Ctx : Context.Object;
View : Project.View.Object;
begin
-- Create api-call.adb as a separate
Project.Tree.Load (Prj, Create (Project_Name), Ctx);
View := Prj.Root_Project;
Text_IO.Put_Line ("Project: " & String (View.Name));
List_Sources (View);
Prj.Invalidate_Sources;
Copy_Source ("api.ads");
Copy_Source ("api.adb");
Copy_Source ("api-call.adb");
List_Sources (View);
end Check;
---------------------
-- Output_Filename --
---------------------
procedure Output_Filename (Filename : Path_Name.Full_Name) is
I : constant Positive := Strings.Fixed.Index (Filename, "source4");
begin
Text_IO.Put (" > " & Filename (I + 8 .. Filename'Last));
end Output_Filename;
begin
Check ("demo.gpr");
end Main;
|
reznikmm/matreshka | Ada | 3,917 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- 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.JSON_Documents;
package League.JSON.Documents.Internals is
pragma Preelaborate;
function Internal
(Self : League.JSON.Documents.JSON_Document)
return not null Matreshka.JSON_Documents.Shared_JSON_Document_Access;
function Create
(Data : not null Matreshka.JSON_Documents.Shared_JSON_Document_Access)
return League.JSON.Documents.JSON_Document;
function Wrap
(Data : not null Matreshka.JSON_Documents.Shared_JSON_Document_Access)
return League.JSON.Documents.JSON_Document;
end League.JSON.Documents.Internals;
|
zhmu/ananas | Ada | 7,178 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (SUN Solaris Version) --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package 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 := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_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 := Standard'Max_Integer_Size - 1;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 0.01;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := Standard'Word_Size;
Memory_Size : constant := 2 ** Word_Size;
-- 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 := High_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
Max_Priority : constant Positive := 30;
Max_Interrupt_Priority : constant Positive := 31;
subtype Any_Priority is Integer range 0 .. 31;
subtype Priority is Any_Priority range 0 .. 30;
subtype Interrupt_Priority is Any_Priority range 31 .. 31;
Default_Priority : constant Priority := 15;
private
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- 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.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := True;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
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 := True;
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 := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := False;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := True;
end System;
|
jwarwick/aoc_2020 | Ada | 146 | ads | -- AOC 2020, Day 25
package Day is
function encryption_key(card_pk : in Long_Integer; door_pk : in Long_Integer) return Long_Integer;
end Day;
|
Rodeo-McCabe/orka | Ada | 28,393 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[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 System;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Directories;
with Ada.Real_Time;
with Ada.Strings.Hash;
with Ada.Unchecked_Deallocation;
with JSON.Parsers;
with JSON.Streams;
with GL.Types.Indirect;
with Orka.glTF.Buffers;
with Orka.glTF.Accessors;
with Orka.glTF.Meshes;
with Orka.glTF.Scenes;
with Orka.Jobs;
with Orka.Logging;
with Orka.Resources.Locations;
with Orka.Types;
package body Orka.Resources.Models.glTF is
use all type Orka.Logging.Source;
use all type Orka.Logging.Severity;
package Messages is new Orka.Logging.Messages (Resource_Loader);
Default_Root_Name : constant String := "root";
package String_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => Natural,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=");
-----------------------------------------------------------------------------
use Ada.Real_Time;
type Times_Data is record
Reading : Time_Span;
Parsing : Time_Span;
Processing : Time_Span;
Scene : Time_Span;
Buffers : Time_Span;
end record;
type GLTF_Data (Maximum_Nodes, Maximum_Accessors : Natural) is limited record
Directory : SU.Unbounded_String;
Location : Locations.Location_Ptr;
Buffers : Orka.glTF.Buffers.Buffer_Vectors.Vector (Capacity => 8);
Views : Orka.glTF.Buffers.Buffer_View_Vectors.Vector (Capacity => Maximum_Accessors);
Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector (Capacity => Maximum_Accessors);
Meshes : Orka.glTF.Meshes.Mesh_Vectors.Vector (Capacity => Maximum_Nodes);
Nodes : Orka.glTF.Scenes.Node_Vectors.Vector (Capacity => Maximum_Nodes);
Scenes : Orka.glTF.Scenes.Scene_Vectors.Vector (Capacity => 8);
Default_Scene : Long_Integer;
Times : Times_Data := (others => Time_Span_Zero);
Start_Time : Time;
Manager : Managers.Manager_Ptr;
end record;
type GLTF_Data_Access is access GLTF_Data;
procedure Free_Data is new Ada.Unchecked_Deallocation
(Object => GLTF_Data, Name => GLTF_Data_Access);
package GLTF_Data_Pointers is new Orka.Smart_Pointers
(GLTF_Data, GLTF_Data_Access, Free_Data);
-----------------------------------------------------------------------------
type GLTF_Parse_Job is new Jobs.Abstract_Job with record
Data : Loaders.Resource_Data;
Manager : Managers.Manager_Ptr;
Location : Locations.Location_Ptr;
end record;
type GLTF_Finish_Processing_Job is new Jobs.Abstract_Job with record
Data : GLTF_Data_Pointers.Mutable_Pointer;
Path : SU.Unbounded_String;
end record;
type GLTF_Create_Model_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record
Data : GLTF_Data_Pointers.Mutable_Pointer;
Path : SU.Unbounded_String;
Scene : Model_Scene_Ptr;
Vertices, Indices : Natural;
end record;
type GLTF_Write_Buffers_Job is new Jobs.Abstract_Job with record
Data : GLTF_Data_Pointers.Mutable_Pointer;
Model : Model_Ptr;
end record;
type GLTF_Finish_Loading_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record
Data : GLTF_Data_Pointers.Mutable_Pointer;
Path : SU.Unbounded_String;
Model : Model_Ptr;
Parts, Vertices, Indices : Natural;
Start_Time : Ada.Real_Time.Time;
end record;
-----------------------------------------------------------------------------
-- EXECUTE PROCEDURES --
-----------------------------------------------------------------------------
overriding
procedure Execute
(Object : GLTF_Parse_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : GLTF_Finish_Processing_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : GLTF_Create_Model_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : GLTF_Write_Buffers_Job;
Context : Jobs.Execution_Context'Class);
overriding
procedure Execute
(Object : GLTF_Finish_Loading_Job;
Context : Jobs.Execution_Context'Class);
-----------------------------------------------------------------------------
procedure Add_Nodes
(Scene : in out Trees.Tree;
Parts : in out String_Maps.Map;
Nodes : in out Orka.glTF.Scenes.Node_Vectors.Vector;
Parents : Orka.glTF.Scenes.Natural_Vectors.Vector)
is
Current_Parents, Next_Parents : Orka.glTF.Scenes.Natural_Vectors.Vector;
begin
-- Initialize Current_Parents with the elements in Parents
for Parent_Index of Parents loop
Current_Parents.Append (Parent_Index);
end loop;
-- Add the children of Current_Parents, and then the
-- children of those children, etc. etc.
loop
for Parent_Index of Current_Parents loop
declare
Parent_Node : Orka.glTF.Scenes.Node renames Nodes (Parent_Index);
Parent_Name : String renames SU.To_String (Parent_Node.Name);
use type Orka.glTF.Scenes.Transform_Kind;
begin
-- Use "matrix" or TRS for the local transform
if Parent_Node.Transform = Orka.glTF.Scenes.Matrix then
Scene.Set_Local_Transform (Scene.To_Cursor (Parent_Name), Parent_Node.Matrix);
else
declare
Local_Transform : Trees.Matrix4 := Transforms.Identity_Value;
begin
Transforms.Scale (Local_Transform, Parent_Node.Scale);
Transforms.Rotate_At_Origin (Local_Transform, Parent_Node.Rotation);
Transforms.Translate (Local_Transform, Parent_Node.Translation);
Scene.Set_Local_Transform (Scene.To_Cursor (Parent_Name), Local_Transform);
end;
end if;
-- Add the children to the scene as nodes
for Child_Index of Parent_Node.Children loop
Scene.Add_Node (Nodes (Child_Index).Name, Parent_Name);
Next_Parents.Append (Child_Index);
end loop;
-- Add mesh as MDI part by mapping the parent (a node) to the mesh index
if Parent_Node.Mesh /= Orka.glTF.Undefined then
Parts.Insert (Parent_Name, Parent_Node.Mesh);
end if;
end;
end loop;
exit when Next_Parents.Is_Empty;
Current_Parents := Next_Parents;
Next_Parents.Clear;
end loop;
end Add_Nodes;
function Mesh_Node_Cursors
(Parts : String_Maps.Map;
Scene : Trees.Tree) return Cursor_Array_Holder.Holder
is
Shapes : Cursor_Array (1 .. Positive (Parts.Length));
procedure Set_Name (Position : String_Maps.Cursor) is
Mesh_Index : Natural renames String_Maps.Element (Position);
Node_Name : String renames String_Maps.Key (Position);
begin
Shapes (Mesh_Index + 1) := Scene.To_Cursor (Node_Name);
end Set_Name;
begin
Parts.Iterate (Set_Name'Access);
return Cursor_Array_Holder.To_Holder (Shapes);
end Mesh_Node_Cursors;
function Bounds_List
(Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector;
Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector) return Orka.Types.Singles.Vector4_Array
is
use type GL.Types.Size;
use Orka.glTF.Accessors;
Mesh_Index : GL.Types.Size := 1;
begin
return Result : Orka.Types.Singles.Vector4_Array (1 .. GL.Types.Size (Meshes.Length) * 2) do
for Mesh of Meshes loop
declare
Primitives : Orka.glTF.Meshes.Primitive_Vectors.Vector renames Mesh.Primitives;
First_Primitive : Orka.glTF.Meshes.Primitive renames Primitives (0);
Attribute_Position : constant Natural := First_Primitive.Attributes ("POSITION");
Accessor_Position : Accessor renames Accessors (Attribute_Position);
pragma Assert (Accessor_Position.Bounds);
begin
Result (Mesh_Index + 0) := Accessor_Position.Min_Bounds;
Result (Mesh_Index + 1) := Accessor_Position.Max_Bounds;
Mesh_Index := Mesh_Index + 2;
end;
end loop;
end return;
end Bounds_List;
generic
type Target_Type is private;
type Target_Array is array (GL.Types.Size range <>) of aliased Target_Type;
type Target_Array_Access is access Target_Array;
package Buffer_View_Conversions is
generic
type Source_Type is private;
type Source_Array is array (GL.Types.Size range <>) of aliased Source_Type;
with function Cast (Value : Source_Type) return Target_Type;
function Convert_Array (Elements : Source_Array) return Target_Array;
generic
type Source_Type is private;
type Source_Array is array (GL.Types.Size range <>) of aliased Source_Type;
with function Convert_Array (Elements : Source_Array) return Target_Array;
procedure Get_Array
(Accessor : Orka.glTF.Accessors.Accessor;
View : Orka.glTF.Buffers.Buffer_View;
Target : not null Target_Array_Access);
end Buffer_View_Conversions;
package body Buffer_View_Conversions is
function Convert_Array (Elements : Source_Array) return Target_Array is
begin
return Result : Target_Array (Elements'Range) do
for Index in Elements'Range loop
Result (Index) := Cast (Elements (Index));
end loop;
end return;
end Convert_Array;
procedure Get_Array
(Accessor : Orka.glTF.Accessors.Accessor;
View : Orka.glTF.Buffers.Buffer_View;
Target : not null Target_Array_Access)
is
use Orka.glTF.Accessors;
Count : constant Positive := Attribute_Length (Accessor.Kind) * Accessor.Count;
Bytes_Per_Element : constant Positive := Bytes_Element (Accessor.Component);
pragma Assert (View.Length / Bytes_Per_Element = Count);
pragma Assert (Source_Type'Size / System.Storage_Unit = Bytes_Per_Element);
procedure Extract is new Orka.glTF.Buffers.Extract_From_Buffer
(Source_Type, Source_Array);
type Source_Array_Access is access Source_Array;
procedure Free_Array is new Ada.Unchecked_Deallocation
(Object => Source_Array, Name => Source_Array_Access);
Source : Source_Array_Access := new Source_Array (Target.all'Range);
begin
Extract (View, Source.all);
Target.all := Convert_Array (Source.all);
Free_Array (Source);
end Get_Array;
end Buffer_View_Conversions;
procedure Count_Parts
(Index_Kind : GL.Types.Index_Type;
Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector;
Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector;
Vertices, Indices : out Natural)
is
use type Ada.Containers.Count_Type;
use type Orka.glTF.Accessors.Component_Kind;
use type GL.Types.Index_Type;
use Orka.glTF.Accessors;
Count_Vertices : Natural := 0;
Count_Indices : Natural := 0;
begin
for Mesh of Meshes loop
declare
Mesh_Name : String renames SU.To_String (Mesh.Name);
Primitives : Orka.glTF.Meshes.Primitive_Vectors.Vector renames Mesh.Primitives;
pragma Assert (Primitives.Length = 1, "Mesh '" & Mesh_Name & "' has more than one primitive");
First_Primitive : Orka.glTF.Meshes.Primitive renames Primitives (0);
pragma Assert (First_Primitive.Attributes.Length = 3,
"Primitive of mesh " & Mesh_Name & " does not have 3 attributes");
Attribute_Position : constant Natural := First_Primitive.Attributes ("POSITION");
Attribute_Normal : constant Natural := First_Primitive.Attributes ("NORMAL");
Attribute_UV : constant Natural := First_Primitive.Attributes ("TEXCOORD_0");
pragma Assert (First_Primitive.Indices /= Orka.glTF.Undefined);
Attribute_Index : constant Natural := First_Primitive.Indices;
Accessor_Position : Accessor renames Accessors (Attribute_Position);
Accessor_Normal : Accessor renames Accessors (Attribute_Normal);
Accessor_UV : Accessor renames Accessors (Attribute_UV);
pragma Assert (Accessor_Position.Component = Orka.glTF.Accessors.Float);
pragma Assert (Accessor_Normal.Component = Orka.glTF.Accessors.Float);
pragma Assert (Accessor_UV.Component = Orka.glTF.Accessors.Float);
pragma Assert (Accessor_Position.Kind = Orka.glTF.Accessors.Vector3);
pragma Assert (Accessor_Normal.Kind = Orka.glTF.Accessors.Vector3);
pragma Assert (Accessor_UV.Kind = Orka.glTF.Accessors.Vector2);
pragma Assert (Accessor_Position.Count = Accessor_Normal.Count);
pragma Assert (Accessor_Position.Count = Accessor_UV.Count);
Accessor_Index : Accessor renames Accessors (Attribute_Index);
pragma Assert (Accessor_Index.Kind = Orka.glTF.Accessors.Scalar);
pragma Assert (Unsigned_Type (Accessor_Index.Component) <= Index_Kind,
"Index of mesh " & Mesh_Name & " has type " &
GL.Types.Index_Type'Image (Unsigned_Type (Accessor_Index.Component)) &
" but expected " & Index_Kind'Image & " or lower");
begin
Count_Vertices := Count_Vertices + Accessor_Position.Count;
Count_Indices := Count_Indices + Accessor_Index.Count;
end;
end loop;
Vertices := Count_Vertices;
Indices := Count_Indices;
end Count_Parts;
procedure Add_Parts
(Batch : in out Rendering.Buffers.MDI.Batch;
Views : Orka.glTF.Buffers.Buffer_View_Vectors.Vector;
Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector;
Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector)
is
use GL.Types;
use Orka.glTF.Accessors;
use Orka.glTF.Buffers;
use all type Orka.Types.Element_Type;
package Index_Conversions is new Buffer_View_Conversions (UInt, UInt_Array, Indirect.UInt_Array_Access);
package Vertex_Conversions is new Buffer_View_Conversions (Half, Half_Array, Indirect.Half_Array_Access);
procedure Get_Singles is new Vertex_Conversions.Get_Array (Single, Single_Array, Orka.Types.Convert);
function Cast (Value : UShort) return UInt is (UInt (Value));
function Cast (Value : UInt) return UInt is (Value);
function Convert is new Index_Conversions.Convert_Array (UShort, UShort_Array, Cast);
function Convert is new Index_Conversions.Convert_Array (UInt, UInt_Array, Cast);
procedure Get_UShorts is new Index_Conversions.Get_Array (UShort, UShort_Array, Convert);
procedure Get_UInts is new Index_Conversions.Get_Array (UInt, UInt_Array, Convert);
begin
for Mesh of Meshes loop
declare
First_Primitive : Orka.glTF.Meshes.Primitive renames Mesh.Primitives (0);
Attribute_Position : constant Natural := First_Primitive.Attributes ("POSITION");
Attribute_Normal : constant Natural := First_Primitive.Attributes ("NORMAL");
Attribute_UV : constant Natural := First_Primitive.Attributes ("TEXCOORD_0");
Attribute_Index : constant Natural := First_Primitive.Indices;
Accessor_Position : Accessor renames Accessors (Attribute_Position);
Accessor_Normal : Accessor renames Accessors (Attribute_Normal);
Accessor_UV : Accessor renames Accessors (Attribute_UV);
Accessor_Index : Accessor renames Accessors (Attribute_Index);
View_Position : Buffer_View renames Views (Accessor_Position.View);
View_Normal : Buffer_View renames Views (Accessor_Normal.View);
View_UV : Buffer_View renames Views (Accessor_UV.View);
View_Index : Buffer_View renames Views (Accessor_Index.View);
Positions : Indirect.Half_Array_Access := new Half_Array (1 .. Int
(Accessor_Position.Count * Attribute_Length (Accessor_Position.Kind)));
Normals : Indirect.Half_Array_Access := new Half_Array (1 .. Int
(Accessor_Normal.Count * Attribute_Length (Accessor_Normal.Kind)));
UVs : Indirect.Half_Array_Access := new Half_Array (1 .. Int
(Accessor_UV.Count * Attribute_Length (Accessor_UV.Kind)));
Indices : Indirect.UInt_Array_Access := new UInt_Array (1 .. Int
(Accessor_Index.Count));
-- TODO Use Conversions.Target_Array?
begin
-- Convert attributes
Get_Singles (Accessor_Position, View_Position, Positions);
Get_Singles (Accessor_Normal, View_Normal, Normals);
Get_Singles (Accessor_UV, View_UV, UVs);
-- Convert indices
case Unsigned_Type (Accessor_Index.Component) is
when GL.Types.UShort_Type =>
Get_UShorts (Accessor_Index, View_Index, Indices);
when GL.Types.UInt_Type =>
Get_UInts (Accessor_Index, View_Index, Indices);
end case;
Batch.Append (Positions, Normals, UVs, Indices);
-- Deallocate buffers after use
Indirect.Free_Array (Positions);
Indirect.Free_Array (Normals);
Indirect.Free_Array (UVs);
Indirect.Free_Array (Indices);
end;
end loop;
end Add_Parts;
-----------------------------------------------------------------------------
-- Loader --
-----------------------------------------------------------------------------
type GLTF_Loader is limited new Loaders.Loader with record
Manager : Managers.Manager_Ptr;
end record;
overriding
function Extension (Object : GLTF_Loader) return Loaders.Extension_String is ("gltf");
overriding
procedure Load
(Object : GLTF_Loader;
Data : Loaders.Resource_Data;
Enqueue : not null access procedure (Element : Jobs.Job_Ptr);
Location : Locations.Location_Ptr)
is
Job : constant Jobs.Job_Ptr := new GLTF_Parse_Job'
(Jobs.Abstract_Job with
Data => Data,
Manager => Object.Manager,
Location => Location);
begin
Enqueue (Job);
end Load;
function Create_Loader
(Manager : Managers.Manager_Ptr) return Loaders.Loader_Ptr
is (new GLTF_Loader'(Manager => Manager));
-----------------------------------------------------------------------------
overriding
procedure Execute
(Object : GLTF_Parse_Job;
Context : Jobs.Execution_Context'Class)
is
use Orka.glTF.Types;
package Parsers is new JSON.Parsers (Orka.glTF.Types);
Path : String renames SU.To_String (Object.Data.Path);
Stream : constant JSON.Streams.Stream'class
:= JSON.Streams.Create_Stream (Object.Data.Bytes.Get.Value);
Parser : Parsers.Parser := Parsers.Create (Stream);
begin
declare
T1 : constant Time := Clock;
JSON : constant Orka.glTF.Types.JSON_Value := Parser.Parse;
T2 : constant Time := Clock;
Buffers : constant JSON_Value := JSON ("buffers");
Views : constant JSON_Value := JSON ("bufferViews");
Accessors : constant JSON_Value := JSON ("accessors");
Meshes : constant JSON_Value := JSON ("meshes");
Nodes : constant JSON_Value := JSON ("nodes");
Scenes : constant JSON_Value := JSON ("scenes");
Maximum_Nodes : constant Natural := Nodes.Length;
-- Tokenize and parse JSON data
Data : constant GLTF_Data_Access := new GLTF_Data'
(Maximum_Nodes => Maximum_Nodes,
Maximum_Accessors => Maximum_Nodes * 4,
Directory => SU.To_Unbounded_String (Ada.Directories.Containing_Directory (Path)),
Location => Object.Location,
Manager => Object.Manager,
Start_Time => Object.Data.Start_Time,
others => <>);
Asset : constant JSON_Value := JSON ("asset");
Scene : constant JSON_Value := JSON ("scene");
function Load_Data (Path : String) return Byte_Array_Pointers.Pointer is
Directory : String renames SU.To_String (Data.Directory);
Relative_Path : constant String := Directory & Locations.Path_Separator & Path;
begin
return Data.Location.Read_Data (Relative_Path);
end Load_Data;
Pointer : GLTF_Data_Pointers.Mutable_Pointer;
begin
-- Require glTF 2.x
if Asset.Get ("version").Value /= "2.0" then
raise Model_Load_Error with "glTF file '" & Path & "' does not use glTF 2.0";
end if;
-- TODO Check minVersion
-- Process buffers, nodes, meshes, and scenes
Data.Buffers.Append (Orka.glTF.Buffers.Get_Buffers (Buffers, Load_Data'Access));
Data.Views.Append (Orka.glTF.Buffers.Get_Buffer_Views (Data.Buffers, Views));
Data.Accessors.Append (Orka.glTF.Accessors.Get_Accessors (Accessors));
Data.Meshes.Append (Orka.glTF.Meshes.Get_Meshes (Meshes));
Data.Nodes.Append (Orka.glTF.Scenes.Get_Nodes (Nodes));
Data.Scenes.Append (Orka.glTF.Scenes.Get_Scenes (Scenes));
Data.Default_Scene := Scene.Value;
Data.Times.Reading := Object.Data.Reading_Time;
Data.Times.Parsing := T2 - T1;
Data.Times.Processing := Clock - T2;
Pointer.Set (Data);
declare
Finish_Job : constant Jobs.Job_Ptr := new GLTF_Finish_Processing_Job'
(Jobs.Abstract_Job with Data => Pointer, Path => Object.Data.Path);
begin
Context.Enqueue (Finish_Job);
end;
end;
end Execute;
overriding
procedure Execute
(Object : GLTF_Finish_Processing_Job;
Context : Jobs.Execution_Context'Class)
is
Data : GLTF_Data renames Object.Data.Get;
-- TODO Textures, Images, Samplers, Materials, Cameras
Default_Scene_Index : constant Long_Integer := Data.Default_Scene;
Default_Scene : constant Orka.glTF.Scenes.Scene
:= Data.Scenes (Natural (Default_Scene_Index));
-- Cannot be "renames" because freeing Object.Data results in cursor tampering
Path : String renames SU.To_String (Object.Path);
begin
if Default_Scene.Nodes.Is_Empty then
raise Model_Load_Error with "glTF file '" & Path & "' has an empty scene";
end if;
declare
Scene_Data : constant Model_Scene_Ptr := new Model_Scene'
(Scene => Trees.Create_Tree (Default_Root_Name), others => <>);
Scene : Trees.Tree renames Scene_Data.Scene;
Parts : String_Maps.Map;
Start_Time : constant Time := Clock;
Vertices, Indices : Natural;
begin
-- Link the nodes in the default scene to the root node and
-- then add all the other nodes that are reachable
for Node_Index of Default_Scene.Nodes loop
Scene.Add_Node (Data.Nodes (Node_Index).Name, Scene.Root_Name);
end loop;
Add_Nodes (Scene, Parts, Data.Nodes, Default_Scene.Nodes);
-- Collect an array of cursors to nodes in the scene for nodes
-- that have a corresponding mesh part. This is needed so that,
-- after updating the whole scene tree, the world transforms of
-- these nodes can be copied to a GPU buffer before rendering.
Scene_Data.Shapes := Mesh_Node_Cursors (Parts, Scene);
if Scene_Data.Shapes.Element'Length = 0 then
-- TODO Free Scene_Data
raise Model_Load_Error with "glTF file '" & Path & "' has no mesh parts";
end if;
Data.Times.Scene := Clock - Start_Time;
-- Count total number of vertices and indices
Count_Parts (GL.Types.UInt_Type, Data.Accessors,
Data.Meshes, Vertices, Indices);
declare
Create_Job : constant Jobs.Job_Ptr := new GLTF_Create_Model_Job'
(Jobs.Abstract_Job with Data => Object.Data, Path => Object.Path,
Scene => Scene_Data, Vertices => Vertices, Indices => Indices);
begin
Context.Enqueue (Create_Job);
end;
end;
end Execute;
overriding
procedure Execute
(Object : GLTF_Create_Model_Job;
Context : Jobs.Execution_Context'Class)
is
Data : GLTF_Data renames Object.Data.Get;
Parts : constant Positive := Object.Scene.Shapes.Element'Length;
Start_Time : constant Time := Clock;
Model_Data : constant Model_Ptr := new Model'
(Scene => Object.Scene,
Batch => Rendering.Buffers.MDI.Create_Batch
(Parts, Object.Vertices, Object.Indices),
-- Bounding boxes for culling
Bounds => Rendering.Buffers.Create_Buffer
(Flags => (others => False),
Data => Bounds_List (Data.Accessors, Data.Meshes)));
Buffers_Job : constant Jobs.Job_Ptr := new GLTF_Write_Buffers_Job'
(Jobs.Abstract_Job with Data => Object.Data, Model => Model_Data);
Finish_Job : constant Jobs.Job_Ptr := new GLTF_Finish_Loading_Job'
(Jobs.Abstract_Job with Data => Object.Data, Path => Object.Path,
Model => Model_Data, Start_Time => Start_Time,
Parts => Parts, Vertices => Object.Vertices, Indices => Object.Indices);
begin
Orka.Jobs.Chain ((Buffers_Job, Finish_Job));
Context.Enqueue (Buffers_Job);
end Execute;
overriding
procedure Execute
(Object : GLTF_Write_Buffers_Job;
Context : Jobs.Execution_Context'Class)
is
Data : GLTF_Data renames Object.Data.Get;
begin
Add_Parts (Object.Model.Batch, Data.Views, Data.Accessors, Data.Meshes);
end Execute;
overriding
procedure Execute
(Object : GLTF_Finish_Loading_Job;
Context : Jobs.Execution_Context'Class)
is
Data : GLTF_Data renames Object.Data.Get;
Path : String renames SU.To_String (Object.Path);
begin
Object.Model.Batch.Finish_Batch;
Data.Times.Buffers := Clock - Object.Start_Time;
-- Register the model at the resource manager
Data.Manager.Add_Resource (Path, Resource_Ptr (Object.Model));
declare
Times : Times_Data renames Data.Times;
begin
Messages.Log (Info, "Loaded model " & Path & " in " &
Logging.Trim (Logging.Image (Clock - Data.Start_Time)));
Messages.Log (Info, " " &
Object.Parts'Image & " parts," &
Object.Vertices'Image & " vertices," &
Object.Indices'Image & " indices");
Messages.Log (Info, " statistics:");
Messages.Log (Info, " reading file: " & Logging.Image (Times.Reading));
Messages.Log (Info, " parsing JSON: " & Logging.Image (Times.Parsing));
Messages.Log (Info, " processing glTF: " & Logging.Image (Times.Processing));
Messages.Log (Info, " scene tree: " & Logging.Image (Times.Scene));
Messages.Log (Info, " buffers: " & Logging.Image (Times.Buffers));
end;
end Execute;
end Orka.Resources.Models.glTF;
|
Sawchord/Ada_Drivers_Library | Ada | 8,782 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body BMP280 is
-- TODO: Introduce Status Value
subtype Dispatch is BMP280_Device'Class;
procedure Configure (This : in out BMP280_Device;
Configuration : BMP280_Configuration) is
function Config_To_Uint8 is new
Ada.Unchecked_Conversion (BMP280_Config, UInt8);
function Control_To_Uint8 is new
Ada.Unchecked_Conversion (BMP280_Control, UInt8);
function To_Calibration is new
Ada.Unchecked_Conversion (Byte_Array, BMP280_Calibration);
Device_Not_Found : Exception;
D_Id : Byte_Array (1 .. 1);
Config : BMP280_Config;
Control : BMP280_Control;
C_Data : Byte_Array (1 .. BMP280_Calibration'Size / 8);
begin
-- Check the Device Id
Dispatch (This).Read_Port (BMP280_Device_Id_Address, D_Id);
if D_Id (1) /= BMP280_Device_Id then
raise Device_Not_Found;
end if;
-- Read the Calibration Data
Dispatch (This).Read_Port (BMP280_Calibration_Address, C_Data);
This.Cal := To_Calibration (C_Data);
-- Configure the device
Control := (osrs_t => Configuration.Temperature_Oversampling,
osrs_p => Configuration.Pressure_Oversampling,
mode => Normal);
Dispatch (This).Write_Port (BMP280_Control_Address,
Control_To_Uint8 (Control));
Config := (t_sb => Configuration.Standby_Time,
filter => Configuration.Filter_Coefficient,
reserved_1 => False,
spi3w => False);
Dispatch (This).Write_Port (BMP280_Config_Address,
Config_To_Uint8 (Config));
end Configure;
procedure Read_Values_Int (This : BMP280_Device;
Values : out BMP280_Values_Int) is
function To_Readout is new Ada.Unchecked_Conversion (Byte_Array,
BMP280_Raw_Readout);
Readout : BMP280_Raw_Readout;
C_Data : Byte_Array (1 .. BMP280_Raw_Readout'Size / 8);
TFine : Integer_32;
begin
Dispatch (This).Read_Port (BMP280_Readout_Address, C_Data);
Readout := To_Readout (C_Data);
Values.Temperature := This.Compensate_Temperature (Readout, TFine);
Values.Pressure := This.Compensate_Pressure (Readout, TFine);
end Read_Values_Int;
procedure Read_Values_Float (This : BMP280_Device;
Values : out BMP280_Values_Float) is
Int_Values : BMP280_Values_Int;
begin
This.Read_Values_Int (Int_Values);
Values.Temperature := Float (Int_Values.Temperature) / 100.0;
Values.Pressure := Float (Int_Values.Pressure) / 256.0;
end Read_Values_Float;
function Compensate_Temperature (This : BMP280_Device;
Readout : BMP280_Raw_Readout;
TFine : out Integer_32)
return Integer_32 is
function U2I is new Ada.Unchecked_Conversion (Unsigned_32, Integer_32);
function I2U is new Ada.Unchecked_Conversion (Integer_32, Unsigned_32);
function Shr (i : Integer_32; v : Integer) return Integer_32;
function Shr (i : Integer_32; v : Integer) return Integer_32 is
begin
return U2I (Shift_Right_Arithmetic (I2U (i), v));
end Shr;
function Shl (i : Integer_32; v : Integer) return Integer_32;
function Shl (i : Integer_32; v : Integer) return Integer_32 is
begin
return U2I (Shift_Left (I2U (i), v));
end Shl;
T : Integer_32;
var1, var2 : Integer_32;
begin
T := Integer_32 (Readout.Temperature);
var1 := Shr (T, 3) - Shl (Integer_32 (This.Cal.dig_T1), 1);
var1 := Shr (var1 * Integer_32 (This.Cal.dig_T2), 11);
var2 := (Shr (T, 4) - Integer_32 (This.Cal.dig_T1))**2;
var2 := Shr (Shr (var2, 12) * Integer_32 (This.Cal.dig_T3), 14);
TFine := var1 + var2;
return Shr ((TFine) * 5 + 128, 8);
end Compensate_Temperature;
function Compensate_Pressure (This : BMP280_Device;
Readout : BMP280_Raw_Readout;
TFine : Integer_32)
return Integer_64 is
function U2I is new Ada.Unchecked_Conversion (Unsigned_64, Integer_64);
function I2U is new Ada.Unchecked_Conversion (Integer_64, Unsigned_64);
function Shr (i : Integer_64; v : Integer) return Integer_64;
function Shr (i : Integer_64; v : Integer) return Integer_64 is
begin
return U2I (Shift_Right_Arithmetic (I2U (i), v));
end Shr;
function Shl (i : Integer_64; v : Integer) return Integer_64;
function Shl (i : Integer_64; v : Integer) return Integer_64 is
begin
return U2I (Shift_Left (I2U (i), v));
end Shl;
p : Integer_64;
var1, var2 : Integer_64;
t_fine : Integer_64;
begin
p := Integer_64 (Readout.Pressure);
t_fine := Integer_64(TFine);
var1 := t_fine - 128000;
var2 := (var1**2) * Integer_64 (This.Cal.dig_P6);
var2 := var2 + Shl (var1 * Integer_64 (This.Cal.dig_P5), 17);
var2 := var2 + Shl (Integer_64 (This.Cal.dig_P4), 35);
var1 := Shr ((var1**2) * Integer_64 (This.Cal.dig_P3), 8)
+ Shl (var1 * Integer_64 (This.Cal.dig_P2), 12);
var1 := Shr ((Shl (Integer_64 (1), 47) + var1)
* Integer_64 (This.Cal.dig_P1), 33);
if var1 = 0 then
return 0;
end if;
p := 1048576 - p;
p := ((Shl (p, 31) - var2) * 3125) / var1;
var1 := Shr (Integer_64 (This.Cal.dig_P9) * (Shr (p, 13)**2), 25);
var2 := Shr (Integer_64 (This.Cal.dig_P8) * p, 19);
p := Shr (p + var1 + var2, 8) + Shl (Integer_64 (This.Cal.dig_P7), 4);
return p;
end Compensate_Pressure;
procedure Read_Port (This : BMP280_Device;
Address : UInt8;
Data : out Byte_Array) is
Not_Implemented_Error : exception;
begin
raise Not_Implemented_Error;
end Read_Port;
procedure Write_Port (This : BMP280_Device;
Address : UInt8;
Data : UInt8) is
Not_Implemented_Error : exception;
begin
raise Not_Implemented_Error;
end Write_Port;
end BMP280;
|
apple-oss-distributions/old_ncurses | Ada | 3,199 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.PutWin --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 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: Eugene V. Melaragno <[email protected]> 2000
-- Version Control:
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
with Ada.Streams.Stream_IO;
package Terminal_Interface.Curses.PutWin is
procedure Put_Window (Win : Window;
File : Ada.Streams.Stream_IO.File_Type);
function Get_Window (File : Ada.Streams.Stream_IO.File_Type) return Window;
end Terminal_Interface.Curses.PutWin;
|
joakim-strandberg/wayland_ada_binding | Ada | 1,979 | adb | package body C_Binding.Linux.Posix_Select is
procedure Clear (This : in out File_Descriptor_Set) is
begin
This.Descriptors := (Fds_Bits => (others => False));
end Clear;
procedure Set_File_Descriptor
(This : in out File_Descriptor_Set;
Descriptor : Integer) is
begin
This.Descriptors.Fds_Bits (Fds_Bits_Index (Descriptor)) := True;
end Set_File_Descriptor;
function Call_Select
(File_Descriptor : Integer;
Read_File_Descriptors : access File_Descriptor_Set;
Write_File_Descriptors : access File_Descriptor_Set;
Except_File_Descriptors : access File_Descriptor_Set;
Time : Time_Value) return Call_Select_Result
is
Tv : aliased timeval
:= (
tv_sec => Interfaces.C.long (Time.Seconds),
tv_usec => Interfaces.C.long (Time.Micro_Seconds)
);
Result : Interfaces.C.int;
begin
Result
:= C_Select
(File_Descriptor,
(if (Read_File_Descriptors /= null) then
(Read_File_Descriptors.Descriptors'Access)
else
(null)),
(if (Write_File_Descriptors /= null) then
(Write_File_Descriptors.Descriptors'Access)
else
(null)),
(if (Except_File_Descriptors /= null) then
(Except_File_Descriptors.Descriptors'Access)
else
(null)),
Tv'Access);
case Result is
when Interfaces.C.int'First .. -1 =>
return (Id => Select_Failure);
when 0 =>
return (Id => Select_Timeout);
when 1 .. 1024 =>
return
(Id => Select_Success,
Descriptor_Count => File_Descriptor_Count (Result));
when 1025 .. Interfaces.C.int'Last =>
return (Id => Select_Failure);
end case;
end Call_Select;
end C_Binding.Linux.Posix_Select;
|
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.Index_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Db_Index_Element_Node is
begin
return Self : Db_Index_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_Index_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_Index
(ODF.DOM.Db_Index_Elements.ODF_Db_Index_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_Index_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Index_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Db_Index_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_Index
(ODF.DOM.Db_Index_Elements.ODF_Db_Index_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_Index_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_Index
(Visitor,
ODF.DOM.Db_Index_Elements.ODF_Db_Index_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.Index_Element,
Db_Index_Element_Node'Tag);
end Matreshka.ODF_Db.Index_Elements;
|
onox/sdlada | Ada | 2,484 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Images
--
-- Root package implementing the binding to SDL2_mage.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
package SDL.Images is
package C renames Interfaces.C;
Image_Error : exception;
type Init_Image_Flags is new SDL.Init_Flags;
Enable_JPG : constant Init_Image_Flags := 16#0000_0001#;
Enable_PNG : constant Init_Image_Flags := 16#0000_0002#;
Enable_TIFF : constant Init_Image_Flags := 16#0000_0004#;
Enable_WEBP : constant Init_Image_Flags := 16#0000_0008#;
Enable_Everything : constant Init_Image_Flags := Enable_JPG or Enable_PNG or Enable_TIFF or Enable_WEBP;
type Formats is (Targa, Cursor, Icon, BMP, GIF, JPG, LBM, PCX, PNG, PNM, TIFF, XCF, XPM, XV, WEBP);
overriding
function Initialise (Flags : in Init_Image_Flags := Enable_Everything) return Boolean;
procedure Finalise with
Import => True,
Convention => C,
External_Name => "IMG_Quit";
private
subtype Format_String_Names is C.char_array (1 .. 5);
type Format_String_Arrays is array (Formats) of Format_String_Names;
function Format_String (Format : in Formats) return Format_String_Names with
Inline_Always => True;
end SDL.Images;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 XML.DOM.Nodes.Attrs;
with XML.DOM.Nodes.Character_Datas.Texts;
with XML.DOM.Nodes.Elements;
with XML.DOM.Visitors;
package body XML.DOM.Nodes.Documents is
-------------------------
-- Create_Attribute_NS --
-------------------------
not overriding function Create_Attribute_NS
(Self : not null access DOM_Document;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return XML.DOM.Nodes.Attrs.DOM_Attr_Access is
begin
return null;
end Create_Attribute_NS;
-----------------------
-- Create_Element_NS --
-----------------------
not overriding function Create_Element_NS
(Self : not null access DOM_Document;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return XML.DOM.Nodes.Elements.DOM_Element_Access is
begin
return null;
end Create_Element_NS;
----------------------
-- Create_Text_Node --
----------------------
not overriding function Create_Text_Node
(Self : not null access DOM_Document;
Data : League.Strings.Universal_String)
return XML.DOM.Nodes.Character_Datas.Texts.DOM_Text_Access is
begin
return Node : constant
XML.DOM.Nodes.Character_Datas.Texts.DOM_Text_Access
:= new XML.DOM.Nodes.Character_Datas.Texts.DOM_Text
do
XML.DOM.Nodes.Character_Datas.Texts.Constructors.Initialize
(Node, Data);
end return;
end Create_Text_Node;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access DOM_Document;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
Visitor.Enter_Document (DOM_Document_Access (Self), Control);
end Enter_Element;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant DOM_Document)
return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Get_Local_Name;
-----------------------
-- Get_Namespace_URI --
-----------------------
overriding function Get_Namespace_URI
(Self : not null access constant DOM_Document)
return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Get_Namespace_URI;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access DOM_Document;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
Visitor.Leave_Document (DOM_Document_Access (Self), Control);
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access DOM_Document;
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
Iterator.Visit_Document (Visitor, DOM_Document_Access (Self), Control);
end Visit_Element;
end XML.DOM.Nodes.Documents;
|
AdaCore/training_material | Ada | 59,476 | ads | ------------------------------------------------------------------------------
-- --
-- Hardware Abstraction Layer for STM32 Targets --
-- --
-- Copyright (C) 2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This file provides definitions for the timers on the STM32F4 (ARM Cortex
-- M4F) microcontrollers from ST Microelectronics.
pragma Restrictions (No_Elaboration_Code);
with System; use System;
package STM32F4.Timers is
type Timer is limited private;
-- TIM_Cmd
procedure Enable (This : in out Timer)
with Post => Enabled (This);
-- TIM_Cmd
procedure Disable (This : in out Timer)
with Post => (if No_Outputs_Enabled (This) then not Enabled (This));
function Enabled (This : Timer) return Boolean;
-- The Configure routines are overloaded for the sake of
-- additional timer-class specific parameters.
-- TIM_TimeBaseInit (overloaded)
procedure Configure
(This : in out Timer;
Prescaler : Half_Word;
Period : Half_Word)
with
Post => Current_Prescaler (This) = Prescaler and
Current_Autoreload (This) = Period;
-- TIM_SetCounter
procedure Set_Counter (This : in out Timer; Value : Half_Word)
with Post => Current_Counter (This) = Word (Value);
-- TIM_SetCounter
procedure Set_Counter (This : in out Timer; Value : Word)
with
Pre => Has_32bit_Counter (This),
Post => Current_Counter (This) = Value;
-- TIM_GetCounter
function Current_Counter (This : Timer) return Word;
-- For those timers that actually have a 32-bit counter this function will
-- return the full word value. For the other timers, the upper half-word of
-- the result will be all zeros so in effect the result will be a half-word
-- value.
-- TIM_SetAutoreload
procedure Set_Autoreload (This : in out Timer; Value : Half_Word)
with Post => Current_Autoreload (This) = Value;
function Current_Autoreload (This : Timer) return Half_Word;
-- Returns the value of the timer's Auto Reload Register (ARR)
type Timer_Clock_Divisor is (Div1, Div2, Div4);
-- TIM_SetClockDivision
procedure Set_Clock_Division
(This : in out Timer;
Value : Timer_Clock_Divisor)
with
Pre => not Basic_Timer (This),
Post => Current_Clock_Division (This) = Value;
function Current_Clock_Division (This : Timer) return Timer_Clock_Divisor;
type Timer_Counter_Alignment_Mode is
(Up, Down, Center_Aligned1, Center_Aligned2, Center_Aligned3);
-- We combine the up-down direction and the center-aligned mode selection
-- into a single type because the two are interdependent and we don't want
-- the user to have to remember to set the direction when not using one
-- of the center-aligned choices. The discontiguous binary values used to
-- represent the enumerals reflect the combination of the adjacent fields
-- within the timer representation.
for Timer_Counter_Alignment_Mode use
(Up => 2#000#,
Down => 2#001#,
Center_Aligned1 => 2#010#,
Center_Aligned2 => 2#100#,
Center_Aligned3 => 2#110#);
-- TIM_CounterModeConfig
procedure Set_Counter_Mode
(This : in out Timer;
Value : Timer_Counter_Alignment_Mode)
with Post => Current_Counter_Mode (This) = Value;
function Current_Counter_Mode
(This : Timer)
return Timer_Counter_Alignment_Mode;
-- Note that the basic timers only count up.
-- TIM_TimeBaseInit (overloaded)
procedure Configure
(This : in out Timer;
Prescaler : Half_Word;
Period : Half_Word;
Clock_Divisor : Timer_Clock_Divisor;
Counter_Mode : Timer_Counter_Alignment_Mode)
with
Pre => not Basic_Timer (This),
Post => Current_Prescaler (This) = Prescaler and
Current_Clock_Division (This) = Clock_Divisor and
Current_Counter_Mode (This) = Counter_Mode and
Current_Autoreload (This) = Period;
type Timer_Prescaler_Reload_Mode is (Update, Immediate);
-- TIM_PrescalerConfig
procedure Configure_Prescaler
(This : in out Timer;
Prescaler : Half_Word;
Reload_Mode : Timer_Prescaler_Reload_Mode)
with Post => Current_Prescaler (This) = Prescaler;
-- TIM_GetPrescaler
function Current_Prescaler (This : Timer) return Half_Word;
-- TIM_UpdateDisableConfig
procedure Set_UpdateDisable
(This : in out Timer;
To : Boolean);
type Timer_Update_Source is (Global, Regular);
-- TIM_UpdateRequestConfig
procedure Set_UpdateRequest
(This : in out Timer;
Source : Timer_Update_Source);
-- TIM_ARRPreloadConfig
procedure Set_Autoreload_Preload
(This : in out Timer;
To : Boolean);
type Timer_One_Pulse_Mode is (Repetitive, Single);
-- TIM_SelectOnePulseMode
procedure Select_One_Pulse_Mode
(This : in out Timer;
Mode : Timer_One_Pulse_Mode)
with Post => (if Mode = Single then not Enabled (This));
----------------------------------------------------------------------------
-- Interrupts, DMA, Flags Management --------------------------------------
----------------------------------------------------------------------------
type Timer_Interrupt is
(Timer_Update_Interrupt,
Timer_CC1_Interrupt,
Timer_CC2_Interrupt,
Timer_CC3_Interrupt,
Timer_CC4_Interrupt,
Timer_COM_Interrupt,
Timer_Trigger_Interrupt,
Timer_Break_Interrupt);
for Timer_Interrupt use
(Timer_Update_Interrupt => 2#00000001#,
Timer_CC1_Interrupt => 2#00000010#,
Timer_CC2_Interrupt => 2#00000100#,
Timer_CC3_Interrupt => 2#00001000#,
Timer_CC4_Interrupt => 2#00010000#,
Timer_COM_Interrupt => 2#00100000#,
Timer_Trigger_Interrupt => 2#01000000#,
Timer_Break_Interrupt => 2#10000000#);
-- TIM_ITConfig
procedure Enable_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
with
Pre =>
(if Basic_Timer (This) then Source = Timer_Update_Interrupt) and
(if Source in Timer_COM_Interrupt | Timer_Break_Interrupt
then Advanced_Timer (This)),
Post => Interrupt_Enabled (This, Source);
type Timer_Interrupt_List is array (Positive range <>) of Timer_Interrupt;
-- TIM_ITConfig
procedure Enable_Interrupt
(This : in out Timer;
Sources : Timer_Interrupt_List)
with
Pre =>
(for all Source of Sources =>
(if Basic_Timer (This) then Source = Timer_Update_Interrupt) and
(if Source in Timer_COM_Interrupt | Timer_Break_Interrupt
then Advanced_Timer (This))),
Post => (for all Source of Sources => Interrupt_Enabled (This, Source));
-- TIM_ITConfig
procedure Disable_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
with
Pre =>
(if Basic_Timer (This) then Source = Timer_Update_Interrupt) and
(if Source in Timer_COM_Interrupt | Timer_Break_Interrupt
then Advanced_Timer (This)),
Post => not Interrupt_Enabled (This, Source);
-- TIM_ClearITPendingBit
procedure Clear_Pending_Interrupt
(This : in out Timer;
Source : Timer_Interrupt)
with Pre =>
(if Basic_Timer (This) then Source = Timer_Update_Interrupt) and
(if Source in Timer_COM_Interrupt | Timer_Break_Interrupt
then Advanced_Timer (This));
-- TIM_GetITStatus
function Interrupt_Enabled
(This : Timer;
Source : Timer_Interrupt)
return Boolean
with Pre =>
(if Basic_Timer (This) then Source = Timer_Update_Interrupt) and
(if Source in Timer_COM_Interrupt | Timer_Break_Interrupt
then Advanced_Timer (This));
type Timer_Event_Source is
(Event_Source_Update,
Event_Source_CC1,
Event_Source_CC2,
Event_Source_CC3,
Event_Source_CC4,
Event_Source_COM,
Event_Source_Trigger,
Event_Source_Break);
for Timer_Event_Source use
(Event_Source_Update => 16#0001#,
Event_Source_CC1 => 16#0002#,
Event_Source_CC2 => 16#0004#,
Event_Source_CC3 => 16#0008#,
Event_Source_CC4 => 16#0010#,
Event_Source_COM => 16#0020#,
Event_Source_Trigger => 16#0040#,
Event_Source_Break => 16#0080#);
-- TODO: consider alternative to bit-masks
-- TIM_GenerateEvent
procedure Generate_Event
(This : in out Timer;
Source : Timer_Event_Source)
with
Pre =>
(if Basic_Timer (This) then Source = Event_Source_Update) and
(if Source in Event_Source_COM | Event_Source_Break
then Advanced_Timer (This));
type Timer_Status_Flag is
(Timer_Update_Indicated,
Timer_CC1_Indicated,
Timer_CC2_Indicated,
Timer_CC3_Indicated,
Timer_CC4_Indicated,
Timer_COM_Indicated,
Timer_Trigger_Indicated,
Timer_Break_Indicated,
Timer_CC1OF_Indicated,
Timer_CC2OF_Indicated,
Timer_CC3OF_Indicated,
Timer_CC4OF_Indicated);
for Timer_Status_Flag use
(Timer_Update_Indicated => 2#000000000001#,
Timer_CC1_Indicated => 2#000000000010#,
Timer_CC2_Indicated => 2#000000000100#,
Timer_CC3_Indicated => 2#000000001000#,
Timer_CC4_Indicated => 2#000000010000#,
Timer_COM_Indicated => 2#000000100000#,
Timer_Trigger_Indicated => 2#000001000000#,
Timer_Break_Indicated => 2#000010000000#,
Timer_CC1OF_Indicated => 2#000100000000#,
Timer_CC2OF_Indicated => 2#001000000000#,
Timer_CC3OF_Indicated => 2#010000000000#,
Timer_CC4OF_Indicated => 2#100000000000#);
-- TIM_GetFlagStatus
function Status
(This : Timer;
Flag : Timer_Status_Flag)
return Boolean
with Pre =>
(if Basic_Timer (This) then Flag = Timer_Update_Indicated) and
(if Flag in Timer_COM_Indicated | Timer_Break_Indicated
then Advanced_Timer (This));
-- TIM_ClearFlag
procedure Clear_Status
(This : in out Timer;
Flag : Timer_Status_Flag)
with
Pre =>
(if Basic_Timer (This) then Flag = Timer_Update_Indicated) and
(if Flag in Timer_COM_Indicated | Timer_Break_Indicated
then Advanced_Timer (This)),
Post =>
not Status (This, Flag);
type Timer_DMA_Source is
(Timer_DMA_Update,
Timer_DMA_CC1,
Timer_DMA_CC2,
Timer_DMA_CC3,
Timer_DMA_CC4,
Timer_DMA_COM,
Timer_DMA_Trigger);
for Timer_DMA_Source use
(Timer_DMA_Update => 2#00000001_00000000#,
Timer_DMA_CC1 => 2#00000010_00000000#,
Timer_DMA_CC2 => 2#00000100_00000000#,
Timer_DMA_CC3 => 2#00001000_00000000#,
Timer_DMA_CC4 => 2#00010000_00000000#,
Timer_DMA_COM => 2#00100000_00000000#,
Timer_DMA_Trigger => 2#01000000_00000000#);
-- TODO: consider using a packed array of booleans in the SR representation
-- instead of bit-patterns, thereby obviating this rep clause
-- TIM_DMACmd
procedure Enable_DMA_Source
(This : in out Timer;
Source : Timer_DMA_Source)
with
Pre =>
((if Basic_Timer (This) then Source = Timer_DMA_Update) and
(if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This)))
or else DMA_Supported (This),
Post =>
DMA_Source_Enabled (This, Source);
-- TIM_DMACmd
procedure Disable_DMA_Source
(This : in out Timer;
Source : Timer_DMA_Source)
with
Pre =>
((if Basic_Timer (This) then Source = Timer_DMA_Update) and
(if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This)))
or else DMA_Supported (This),
Post =>
not DMA_Source_Enabled (This, Source);
function DMA_Source_Enabled
(This : Timer;
Source : Timer_DMA_Source)
return Boolean
with
Pre =>
((if Basic_Timer (This) then Source = Timer_DMA_Update) and
(if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This)))
or else DMA_Supported (This);
type Timer_DMA_Burst_Length is
(DMA_Burst_Length_1,
DMA_Burst_Length_2,
DMA_Burst_Length_3,
DMA_Burst_Length_4,
DMA_Burst_Length_5,
DMA_Burst_Length_6,
DMA_Burst_Length_7,
DMA_Burst_Length_8,
DMA_Burst_Length_9,
DMA_Burst_Length_10,
DMA_Burst_Length_11,
DMA_Burst_Length_12,
DMA_Burst_Length_13,
DMA_Burst_Length_14,
DMA_Burst_Length_15,
DMA_Burst_Length_16,
DMA_Burst_Length_17,
DMA_Burst_Length_18);
type Timer_DMA_Base_Address is
(DMA_Base_CR1,
DMA_Base_CR2,
DMA_Base_SMCR,
DMA_Base_DIER,
DMA_Base_SR,
DMA_Base_EGR,
DMA_Base_CCMR1,
DMA_Base_CCMR2,
DMA_Base_CCER,
DMA_Base_CNT,
DMA_Base_PSC,
DMA_Base_ARR,
DMA_Base_RCR,
DMA_Base_CCR1,
DMA_Base_CCR2,
DMA_Base_CCR3,
DMA_Base_CCR4,
DMA_Base_BDTR,
DMA_Base_DCR,
DMA_Base_OR);
-- TIM_DMAConfig
procedure Configure_DMA
(This : in out Timer;
Base_Address : Timer_DMA_Base_Address;
Burst_Length : Timer_DMA_Burst_Length);
-- TIM_DMACmd
procedure Enable_Capture_Compare_DMA
(This : in out Timer);
-- TIM_DMACmd
procedure Disable_Capture_Compare_DMA
(This : in out Timer);
----------------------------------------------------------------------------
-- Output Compare Management ----------------------------------------------
----------------------------------------------------------------------------
type Timer_Channel is (Channel_1, Channel_2, Channel_3, Channel_4);
-- TIM_CCxCmd
procedure Enable_Channel
(This : in out Timer;
Channel : Timer_Channel)
with
Pre => not Basic_Timer (This),
Post => Channel_Enabled (This, Channel);
-- TIM_CCxCmd
procedure Disable_Channel
(This : in out Timer;
Channel : Timer_Channel)
with
Pre => not Basic_Timer (This),
Post => not Channel_Enabled (This, Channel);
function Channel_Enabled
(This : Timer; Channel : Timer_Channel)
return Boolean;
-- TIM_CCxNCmd
procedure Enable_Complementary_Channel
(This : in out Timer;
Channel : Timer_Channel)
with
Pre => Complementary_Outputs_Supported (This, Channel),
Post => Complementary_Channel_Enabled (This, Channel);
-- TIM_CCxNCmd
procedure Disable_Complementary_Channel
(This : in out Timer;
Channel : Timer_Channel)
with
Pre => Complementary_Outputs_Supported (This, Channel),
Post => not Complementary_Channel_Enabled (This, Channel);
function Complementary_Channel_Enabled
(This : Timer; Channel : Timer_Channel)
return Boolean
with Pre => Complementary_Outputs_Supported (This, Channel);
Timer_Channel_Access_Error : exception;
-- Raised when accessing a given channel configuration with the wrong view:
-- as an input when it is set to be an output, and vice versa
type Timer_Output_Compare_And_PWM_Mode is
(Timing,
Active,
Inactive,
Toggle,
Force_Inactive,
Force_Active,
PWM1,
PWM2);
type Timer_Capture_Compare_State is (Disable, Enable);
type Timer_Output_Compare_Polarity is (High, Low);
-- TIM_OCxInit (overloaded)
procedure Configure_Channel_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
State : Timer_Capture_Compare_State;
Pulse : Word;
Polarity : Timer_Output_Compare_Polarity)
with
Pre => (CC_Channel_Exists (This, Channel) and
Specific_Channel_Output_Supported (This, Channel)) and
(if not Has_32bit_CC_Values (This) then Pulse <= 16#FFFF#),
Post => (if State = Enable
then Channel_Enabled (This, Channel)
else not Channel_Enabled (This, Channel));
-- TIM_SetCompare
procedure Set_Compare_Value
(This : in out Timer;
Channel : Timer_Channel;
Word_Value : Word)
with
Pre => Has_32bit_CC_Values (This),
Post => Current_Capture_Value (This, Channel) = Word_Value;
-- TIM_SetCompare
procedure Set_Compare_Value
(This : in out Timer;
Channel : Timer_Channel;
Value : Half_Word)
with
Pre => CC_Channel_Exists (This, Channel),
Post => Current_Capture_Value (This, Channel) = Value;
type Timer_Capture_Compare_Modes is
(Output, Direct_TI, Indirect_TI, TRC);
function Current_Capture_Compare_Mode
(This : Timer;
Channel : Timer_Channel)
return Timer_Capture_Compare_Modes;
-- A convenience routine that sets the capture/compare selection to be that
-- of a single channel output and assigns all the controls of that output,
-- as an alternative to calling the individual routines. Does not raise the
-- access error exception because it explicitly sets the mode to Output.
procedure Set_Single_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
OC_Clear_Enabled : Boolean;
Preload_Enabled : Boolean;
Fast_Enabled : Boolean)
with
Pre => CC_Channel_Exists (This, Channel),
Post => Current_Capture_Compare_Mode (This, Channel) = Output;
-- TIM_SelectOCxM
procedure Set_Output_Compare_Mode
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode)
with
Pre => (not Basic_Timer (This)) and
(if Current_Capture_Compare_Mode (This, Channel) /= Output
then raise Timer_Channel_Access_Error);
-- TIM_OCxPreloadConfig: eg TIM_OC1PreloadConfig
procedure Set_Output_Preload_Enable
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
with
Pre => CC_Channel_Exists (This, Channel) and
(if Current_Capture_Compare_Mode (This, Channel) /= Output
then raise Timer_Channel_Access_Error);
-- TIM_OCxFastConfig
procedure Set_Output_Fast_Enable
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
with
Pre => CC_Channel_Exists (This, Channel) and
(if Current_Capture_Compare_Mode (This, Channel) /= Output
then raise Timer_Channel_Access_Error);
-- TIM_ClearOCxRef
procedure Set_Clear_Control
(This : in out Timer;
Channel : Timer_Channel;
Enabled : Boolean)
with
Pre => CC_Channel_Exists (This, Channel) and
(if Current_Capture_Compare_Mode (This, Channel) /= Output
then raise Timer_Channel_Access_Error);
-- TIM_ForcedOCxConfig
procedure Set_Output_Forced_Action
(This : in out Timer;
Channel : Timer_Channel;
Active : Boolean)
with
Pre => CC_Channel_Exists (This, Channel) and
(if Current_Capture_Compare_Mode (This, Channel) /= Output
then raise Timer_Channel_Access_Error);
-- TIM_OCxPolarityConfig
procedure Set_Output_Polarity
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Output_Compare_Polarity)
with
Pre => not Basic_Timer (This);
-- TIM_OCxNPolarityConfig
procedure Set_Output_Complementary_Polarity
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Output_Compare_Polarity)
with
Pre => Advanced_Timer (This);
-- Indicates whether all outputs are disabled for all channels of the given
-- timer. Used in pre/postconditions.
function No_Outputs_Enabled (This : Timer) return Boolean;
----------------------------------------------------------------------------
-- Input Capture Management -----------------------------------------------
----------------------------------------------------------------------------
type Timer_Input_Capture_Filter is mod 16;
type Timer_Input_Capture_Polarity is (Rising, Falling, Both_Edges);
subtype Timer_Input_Capture_Selection is Timer_Capture_Compare_Modes
range Direct_TI .. TRC;
type Timer_Input_Capture_Prescaler is
(Div1, -- Capture performed each time an edge is detected on input
Div2, -- Capture performed once every 2 events
Div4, -- Capture performed once every 4 events
Div8); -- Capture performed once every 8 events
-- TIM_ICInit
procedure Configure_Channel_Input
(This : in out Timer;
Channel : Timer_Channel;
Polarity : Timer_Input_Capture_Polarity;
Selection : Timer_Input_Capture_Selection;
Prescaler : Timer_Input_Capture_Prescaler;
Filter : Timer_Input_Capture_Filter)
with
Pre => CC_Channel_Exists (This, Channel),
Post => Channel_Enabled (This, Channel) and
Current_Capture_Compare_Mode (This, Channel) = Selection;
-- TIM_PWMIConfig
procedure Configure_Channel_Input_PWM
(This : in out Timer;
Channel : Timer_Channel;
Selection : Timer_Input_Capture_Selection;
Polarity : Timer_Input_Capture_Polarity;
Prescaler : Timer_Input_Capture_Prescaler;
Filter : Timer_Input_Capture_Filter)
with
Pre => Has_At_Least_2_CC_Channels (This) and
Channel in Channel_1 | Channel_2,
Post => Channel_Enabled (This, Channel) and
Current_Capture_Compare_Mode (This, Channel) = Selection and
Current_Input_Prescaler (This, Channel) = Prescaler;
-- TIM_SetICxPrescaler
procedure Set_Input_Prescaler
(This : in out Timer;
Channel : Timer_Channel;
Value : Timer_Input_Capture_Prescaler)
with
Pre => not Basic_Timer (This) and
Current_Capture_Compare_Mode (This, Channel) /= Output,
Post => Current_Input_Prescaler (This, Channel) = Value;
function Current_Input_Prescaler
(This : Timer;
Channel : Timer_Channel)
return Timer_Input_Capture_Prescaler;
-- TIM_GetCapturex
function Current_Capture_Value
(This : Timer;
Channel : Timer_Channel)
return Word;
-- Reading the upper reserved area of the CCR register does no harm when
-- the timer does not support 32-bit CC registers so we do not protect
-- this function with a precondition.
-- TIM_GetCapturex
function Current_Capture_Value
(This : Timer;
Channel : Timer_Channel)
return Half_Word;
----------------------------------------------------------------------------
-- Advanced control timers ------------------------------------------------
----------------------------------------------------------------------------
-- TIM_CtrlPWMOutputs
procedure Enable_Main_Output (This : in out Timer)
with
Pre => Advanced_Timer (This),
Post => Main_Output_Enabled (This);
-- TIM_CtrlPWMOutputs
procedure Disable_Main_Output (This : in out Timer)
with
Pre => Advanced_Timer (This),
Post => (if No_Outputs_Enabled (This) then not Main_Output_Enabled (This));
function Main_Output_Enabled (This : Timer) return Boolean;
-- TIM_TimeBaseInit (overloaded)
procedure Configure
(This : in out Timer;
Prescaler : Half_Word;
Period : Half_Word;
Clock_Divisor : Timer_Clock_Divisor;
Counter_Mode : Timer_Counter_Alignment_Mode;
Repetitions : Byte)
with
Pre => Advanced_Timer (This),
Post => Current_Prescaler (This) = Prescaler and
Current_Autoreload (This) = Period;
-- TIM_OCxInit (overloaded)
procedure Configure_Channel_Output
(This : in out Timer;
Channel : Timer_Channel;
Mode : Timer_Output_Compare_And_PWM_Mode;
State : Timer_Capture_Compare_State;
Pulse : Word;
Polarity : Timer_Output_Compare_Polarity;
Idle_State : Timer_Capture_Compare_State;
Complementary_Polarity : Timer_Output_Compare_Polarity;
Complementary_Idle_State : Timer_Capture_Compare_State)
with
Pre => Advanced_Timer (This) and
(if not Has_32bit_CC_Values (This) then Pulse <= 16#FFFF#),
Post => (if State = Enable
then Channel_Enabled (This, Channel)
else not Channel_Enabled (This, Channel));
-- TIM_CCPreloadControl
procedure Enable_CC_Preload_Control (This : in out Timer)
with Pre => Advanced_Timer (This);
-- TIM_CCPreloadControl
procedure Disable_CC_Preload_Control (This : in out Timer)
with Pre => Advanced_Timer (This);
-- TIM_SelectCOM
procedure Select_Commutation (This : in out Timer)
with Pre => Advanced_Timer (This);
-- TIM_SelectCOM
procedure Deselect_Commutation (This : in out Timer)
with Pre => Advanced_Timer (This);
type Timer_Break_Polarity is (Low, High);
type Timer_Lock_Level is (Off, Level_1, Level_2, Level_3);
-- TIM_BDTRConfig
procedure Configure_BDTR
(This : in out Timer;
Automatic_Output_Enabled : Boolean;
Break_Polarity : Timer_Break_Polarity;
Break_Enabled : Boolean;
Off_State_Selection_Run_Mode : Bits_1;
Off_State_Selection_Idle_Mode : Bits_1;
Lock_Configuration : Timer_Lock_Level;
Deadtime_Generator : Byte)
with Pre => Advanced_Timer (This);
----------------------------------------------------------------------------
-- Synchronization Management ---------------------------------------------
----------------------------------------------------------------------------
type Timer_Trigger_Input_Source is
(Internal_Trigger_0, -- ITR0
Internal_Trigger_1, -- ITR1
Internal_Trigger_2, -- ITR2
Internal_Trigger_3, -- ITR3
TI1_Edge_Detector, -- TI1F_ED
Filtered_Timer_Input_1, -- TI1FP1
Filtered_Timer_Input_2, -- TI2FP2
External_Trigger_Input); -- ETRF
-- TIM_SelectInputTrigger
procedure Select_Input_Trigger
(This : in out Timer;
Source : Timer_Trigger_Input_Source)
with Pre => not Basic_Timer (This);
type Timer_Trigger_Output_Source is
(Reset,
Enable,
Update,
OC1,
OC1Ref,
OC2Ref,
OC3Ref,
OC4Ref);
-- TIM_SelectOutputTrigger
procedure Select_Output_Trigger
(This : in out Timer;
Source : Timer_Trigger_Output_Source)
with Pre => Trigger_Output_Selectable (This); -- any of Timer 1 .. 8
type Timer_Slave_Mode is
(Disabled,
Encoder_Mode_1, -- counter counts up/down on TI2FP2 edge
Encoder_Mode_2, -- counter counts up/down on TI1FP1 edge
Encoder_Mode_3, -- counter counts up/down on both TI1FP1 & TI2FP2 edges
Reset,
Gated,
Trigger,
External_1);
-- TIM_SelectSlaveMode
procedure Select_Slave_Mode
(This : in out Timer;
Mode : Timer_Slave_Mode)
with Pre => Slave_Mode_Supported (This);
-- TIM_SelectMasterSlaveMode
procedure Enable_Master_Slave_Mode (This : in out Timer)
with Pre => Slave_Mode_Supported (This);
-- TIM_SelectMasterSlaveMode
procedure Disable_Master_Slave_Mode (This : in out Timer)
with Pre => Slave_Mode_Supported (This);
type Timer_External_Trigger_Polarity is (Inverted, Noninverted);
type Timer_External_Trigger_Prescaler is
(Off,
Div2,
Div4,
Div8);
type Timer_External_Trigger_Filter is mod 16;
-- TIM_ETRConfig
procedure Configure_External_Trigger
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
with Pre => External_Trigger_Supported (This);
----------------------------------------------------------------------------
-- Clocks Management ------------------------------------------------------
----------------------------------------------------------------------------
-- TIM_InternalClockConfig
procedure Select_Internal_Clock
(This : in out Timer)
renames Disable_Master_Slave_Mode;
subtype Timer_Internal_Trigger_Source is Timer_Trigger_Input_Source
range Internal_Trigger_0 .. Internal_Trigger_3;
-- TIM_ITRxExternalClockConfig
procedure Configure_As_External_Clock
(This : in out Timer;
Source : Timer_Internal_Trigger_Source)
with Pre => Clock_Management_Supported (This);
subtype Timer_External_Clock_Source is Timer_Trigger_Input_Source
range TI1_Edge_Detector .. Filtered_Timer_Input_2;
-- TIM_TIxExternalClockConfig
procedure Configure_As_External_Clock
(This : in out Timer;
Source : Timer_External_Clock_Source;
Polarity : Timer_Input_Capture_Polarity;
Filter : Timer_Input_Capture_Filter)
with Pre => not Basic_Timer (This);
-- TIM_ETRClockMode1Config
procedure Configure_External_Clock_Mode1
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
with Pre => External_Trigger_Supported (This);
-- TIM_ETRClockMode2Config
procedure Configure_External_Clock_Mode2
(This : in out Timer;
Polarity : Timer_External_Trigger_Polarity;
Prescaler : Timer_External_Trigger_Prescaler;
Filter : Timer_External_Trigger_Filter)
with Pre => External_Trigger_Supported (This);
----------------------------------------------------------------------------
-- Misc functions ---------------------------------------------------------
----------------------------------------------------------------------------
subtype Timer_Encoder_Mode is
Timer_Slave_Mode range Encoder_Mode_1 .. Encoder_Mode_3;
-- TIM_EncoderInterfaceConfig
procedure Configure_Encoder_Interface
(This : in out Timer;
Mode : Timer_Encoder_Mode;
IC1_Polarity : Timer_Input_Capture_Polarity;
IC2_Polarity : Timer_Input_Capture_Polarity)
with Pre => Has_At_Least_2_CC_Channels (This);
-- TIM_SelectHallSensor
procedure Enable_Hall_Sensor
(This : in out Timer)
with Pre => Hall_Sensor_Supported (This);
-- TIM_SelectHallSensor
procedure Disable_Hall_Sensor
(This : in out Timer)
with Pre => Hall_Sensor_Supported (This);
type Timer_2_Remapping_Options is -- see RM pg 632
(TIM2_TIM8_TRGO,
TIM2_ETH_PTP,
TIM2_USBFS_SOF,
TIM2_USBHS_SOF);
-- TIM_RemapConfig
procedure Configure_Timer_2_Remapping
(This : in out Timer;
Option : Timer_2_Remapping_Options)
with Pre => This'Address = System'To_Address (TIM2_Base);
type Timer_5_Remapping_Options is -- see RM pg 633
(TIM5_GPIO,
TIM5_LSI,
TIM5_LSE,
TIM5_RTC);
-- TIM_RemapConfig
procedure Configure_Timer_5_Remapping
(This : in out Timer;
Option : Timer_5_Remapping_Options)
with Pre => This'Address = System'To_Address (TIM5_Base);
type Timer_11_Remapping_Options is
(TIM11_GPIO,
TIM11_HSE);
for Timer_11_Remapping_Options use -- per RM page 676
(TIM11_GPIO => 0,
TIM11_HSE => 2);
-- TIM_RemapConfig
procedure Configure_Timer_11_Remapping
(This : in out Timer;
Option : Timer_11_Remapping_Options)
with Pre => This'Address = System'To_Address (TIM11_Base);
----------------------------------------------------------------------------
-- Classifier functions ---------------------------------------------------
----------------------------------------------------------------------------
-- Timers 6 and 7
function Basic_Timer (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM6_Base) or
This'Address = System'To_Address (TIM7_Base));
-- Timers 1 and 8
function Advanced_Timer (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM8_Base));
-- Timers 2 and 5
function Has_32bit_Counter (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM2_Base) or
-- The RM register map for timers 2 through 5, pg 634, indicates that
-- only timer 2 and timer 5 actually have the upper half of the counter
-- available, and that the others must keep it reserved. This would
-- appear to contradict the text in the introduction to those timers,
-- but section 18.2 indicates the restriction explicitly.
This'Address = System'To_Address (TIM5_Base));
-- Timers 2 and 5
function Has_32bit_CC_Values (This : Timer) return Boolean
renames Has_32bit_Counter;
-- Timers 1 .. 8
function Trigger_Output_Selectable (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM6_Base) or
This'Address = System'To_Address (TIM7_Base) or
This'Address = System'To_Address (TIM8_Base));
-- IS_TIM_CC2_INSTANCE
-- Timers 1 .. 5, 8, 9, 12
function Has_At_Least_2_CC_Channels (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base) or
This'Address = System'To_Address (TIM9_Base) or
This'Address = System'To_Address (TIM12_Base));
-- Timers 1 .. 5, 8
function Hall_Sensor_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base));
-- Timers 1 .. 5, 8, 9, 12
function Clock_Management_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base) or
This'Address = System'To_Address (TIM9_Base) or
This'Address = System'To_Address (TIM12_Base));
-- IS_TIM_CC3_INSTANCE
-- Timers 1 .. 5, 8
function Has_At_Least_3_CC_Channels (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base));
-- IS_TIM_CC4_INSTANCE
-- Timers 1 .. 5, 8
function Has_At_Least_4_CC_Channels (This : Timer) return Boolean
renames Has_At_Least_3_CC_Channels;
-- Not all timers have four channels available for capture/compare
function CC_Channel_Exists (This : Timer; Channel : Timer_Channel) return Boolean is
((if Channel = Channel_1 then not Basic_Timer (This)) or
(if Channel = Channel_2 then Has_At_Least_2_CC_Channels (This)) or
(if Channel = Channel_3 then Has_At_Least_3_CC_Channels (This)) or
(if Channel = Channel_4 then Has_At_Least_4_CC_Channels (This)));
-- IS_TIM_XOR_INSTANCE
-- Timers 1 .. 5, 8
function Input_XOR_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base));
-- Timers 1 .. 8
function DMA_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM6_Base) or
This'Address = System'To_Address (TIM7_Base) or
This'Address = System'To_Address (TIM8_Base));
-- Timers 1 .. 5, 8, 9, 12
function Slave_Mode_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base) or
This'Address = System'To_Address (TIM9_Base) or
This'Address = System'To_Address (TIM12_Base));
-- IS_TIM_ETR_INSTANCE
-- Timers 1 .. 5, 8
function External_Trigger_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base));
-- IS_TIM_REMAP_INSTANCE
-- Timers 2, 5, 11
function Remapping_Capability_Supported (This : Timer) return Boolean is
(This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM11_Base));
-- Not all timers support output on all channels
-- IS_TIM_CCX_INSTANCE
function Specific_Channel_Output_Supported
(This : Timer; Channel : Timer_Channel)
return Boolean
is
(This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM2_Base) or
This'Address = System'To_Address (TIM3_Base) or
This'Address = System'To_Address (TIM4_Base) or
This'Address = System'To_Address (TIM5_Base) or
This'Address = System'To_Address (TIM8_Base)
-- all the above can be with any of the four channels
or
(This'Address = System'To_Address (TIM9_Base) and
Channel in Channel_1 | Channel_2)
or
(This'Address = System'To_Address (TIM10_Base) and
Channel = Channel_1)
or
(This'Address = System'To_Address (TIM11_Base) and
Channel = Channel_1)
or
(This'Address = System'To_Address (TIM12_Base) and
Channel in Channel_1 | Channel_2)
or
(This'Address = System'To_Address (TIM13_Base) and
Channel = Channel_1)
or
(This'Address = System'To_Address (TIM14_Base) and
Channel = Channel_1));
-- IS_TIM_CCXN_INSTANCE
-- Timers 1 and 8, channels 1 .. 3
function Complementary_Outputs_Supported
(This : Timer; Channel : Timer_Channel)
return Boolean
is
((This'Address = System'To_Address (TIM1_Base) or
This'Address = System'To_Address (TIM8_Base)) and
Channel in Channel_1 | Channel_2 | Channel_3);
private
type TIMx_CR1 is record
Reserved : Bits_6;
Clock_Division : Timer_Clock_Divisor;
ARPE : Boolean; -- Auto-reload preload enable
Mode_And_Dir : Timer_Counter_Alignment_Mode;
One_Pulse_Mode : Timer_One_Pulse_Mode;
Update_Request_Source : Boolean;
Update_Disable : Boolean;
Timer_Enabled : Boolean;
end record with Volatile, Size => 32;
for TIMx_CR1 use record
Reserved at 0 range 10 .. 15;
Clock_Division at 0 range 8 .. 9;
ARPE at 0 range 7 .. 7;
Mode_And_Dir at 0 range 4 .. 6;
One_Pulse_Mode at 0 range 3 .. 3;
Update_Request_Source at 0 range 2 .. 2;
Update_Disable at 0 range 1 .. 1;
Timer_Enabled at 0 range 0 .. 0;
end record;
------------------------ representation for CR2 --------------------------
type TIMx_CR2 is record
Reserved0 : Half_Word;
Reserved1 : Bits_1;
Channel_4_Output_Idle_State : Timer_Capture_Compare_State;
Channel_3_Complementary_Output_Idle_State : Timer_Capture_Compare_State;
Channel_3_Output_Idle_State : Timer_Capture_Compare_State;
Channel_2_Complementary_Output_Idle_State : Timer_Capture_Compare_State;
Channel_2_Output_Idle_State : Timer_Capture_Compare_State;
Channel_1_Complementary_Output_Idle_State : Timer_Capture_Compare_State;
Channel_1_Output_Idle_State : Timer_Capture_Compare_State;
TI1_Selection : Boolean;
Master_Mode_Selection : Timer_Trigger_Output_Source;
Capture_Compare_DMA_Selection : Boolean;
Capture_Compare_Control_Update_Selection : Boolean;
Reserved2 : Bits_1;
Capture_Compare_Preloaded_Control : Boolean;
end record with Volatile, Size => 32;
for TIMx_CR2 use record
Reserved0 at 0 range 16 .. 31;
Reserved1 at 0 range 15 .. 15;
Channel_4_Output_Idle_State at 0 range 14 .. 14;
Channel_3_Complementary_Output_Idle_State at 0 range 13 .. 13;
Channel_3_Output_Idle_State at 0 range 12 .. 12;
Channel_2_Complementary_Output_Idle_State at 0 range 11 .. 11;
Channel_2_Output_Idle_State at 0 range 10 .. 10;
Channel_1_Complementary_Output_Idle_State at 0 range 9 .. 9;
Channel_1_Output_Idle_State at 0 range 8 .. 8;
TI1_Selection at 0 range 7 .. 7;
Master_Mode_Selection at 0 range 4 .. 6;
Capture_Compare_DMA_Selection at 0 range 3 .. 3;
Capture_Compare_Control_Update_Selection at 0 range 2 .. 2;
Reserved2 at 0 range 1 .. 1;
Capture_Compare_Preloaded_Control at 0 range 0 .. 0;
end record;
------------ representation for slave mode control register --------------
type TIMx_SMCR is record
Reserved0 : Half_Word;
External_Trigger_Polarity : Timer_External_Trigger_Polarity;
External_Clock_Enable : Boolean;
External_Trigger_Prescaler : Timer_External_Trigger_Prescaler;
External_Trigger_Filter : Timer_External_Trigger_Filter;
Master_Slave_Mode : Boolean;
Trigger_Selection : Timer_Trigger_Input_Source;
Reserved1 : Bits_1;
Slave_Mode_Selection : Timer_Slave_Mode;
end record with Volatile, Size => 32;
for TIMx_SMCR use record
Reserved0 at 0 range 16 .. 31;
External_Trigger_Polarity at 0 range 15 .. 15;
External_Clock_Enable at 0 range 14 .. 14;
External_Trigger_Prescaler at 0 range 12 .. 13;
External_Trigger_Filter at 0 range 8 .. 11;
Master_Slave_Mode at 0 range 7 .. 7;
Trigger_Selection at 0 range 4 .. 6;
Reserved1 at 0 range 3 .. 3;
Slave_Mode_Selection at 0 range 0 .. 2;
end record;
------------ representation for CCMR1 and CCMR2 --------------------------
-- Per the ST Reference Manual, there are two words (registers)
-- allocated within a timer to describe the capture-compare input/output
-- configurations for the four channels. These are CCMR1 and CCMR2. Both
-- currently only use the lower half of the word, with the upper half
-- reserved.
-- Each description is either that of a single input or a single output
-- for the given channel. Both kinds of description require eight
-- bits, therefore there are two channel descriptions in each word.
-- Although both the input and output descriptions are the same size in
-- terms of bits (six bits each), they do not have the same logical fields.
-- We use two distinct types to represent individual input and output
-- descriptions.
type Channel_Output_Descriptor is record
OCxFast_Enable : Boolean;
OCxPreload_Enable : Boolean;
OCxMode : Timer_Output_Compare_And_PWM_Mode;
OCxClear_Enable : Boolean;
end record with Size => 6;
for Channel_Output_Descriptor use record
OCxFast_Enable at 0 range 0 .. 0;
OCxPreload_Enable at 0 range 1 .. 1;
OCxMode at 0 range 2 .. 4;
OCxClear_Enable at 0 range 5 .. 5;
end record;
type Channel_Input_Descriptor is record
ICxFilter : Timer_Input_Capture_Filter;
ICxPrescaler : Timer_Input_Capture_Prescaler;
end record with Size => 6;
for Channel_Input_Descriptor use record
ICxFilter at 0 range 2 .. 5;
ICxPrescaler at 0 range 0 .. 1;
end record;
-- So any given eight-bit description uses six bits for the specific fields
-- describing the input or output configuration. The other two bits are
-- taken by a field selecting the kind of description, i.e., either an
-- input or an output description. In the RM register definitions this
-- is "CCxS" (where 'x' is a place-holder for a channel number). Although
-- there is one kind of output, there are in fact three kinds of inputs.
-- Thus any given channel description is an eight-bit quantity that
-- both indicates the kind and contains another set of dependent fields
-- representing that kind. The dependent fields are logically mutually
-- exclusive, i.e., if the CCxS selection field indicates an input then
-- the output fields are not present, and vice versa. This logical layout
-- is naturally represented in Ada as a discriminated type, where the
-- discriminant is the CCxS "Selection" indicator.
type IO_Descriptor (CCxSelection : Timer_Capture_Compare_Modes := Output) is
record
case CCxSelection is
when Direct_TI .. TRC =>
Capture : Channel_Input_Descriptor;
when Output =>
Compare : Channel_Output_Descriptor;
end case;
end record with Size => 8;
-- Per the RM, the input fields and the output fields are in the same
-- locations in memory, that is, they overlay, coming after the common
-- CCxS field.
for IO_Descriptor use record
CCxSelection at 0 range 0 .. 1;
Capture at 0 range 2 .. 7;
Compare at 0 range 2 .. 7;
end record;
-- Thus we have a means of describing any single channel's configuration
-- as either an input or an output. But how to get to them? As mentioned
-- above, there are four channels so there are four I/O descriptions,
-- spread across the two words of CCMR1 and CMR2 in the timer
-- representation. Specifically, the descriptions for channels 1 and 2 are
-- in CCMR1, and the descriptions for channels 3 and 4 are in CCMR2. Rather
-- than determine which register to use by having a dedicated routine
-- for each channel, we use an array of descriptions allocated across the
-- memory for the two registers and compute the description to use within
-- the array for that channel.
--
-- The remaining difficulty is the reserved upper halves of each of the
-- two registers in memory. We cannot simply allocate four components in
-- our array because we must skip the reserved areas, but we don't have
-- non-contiguous arrays in Ada (nor should we). As a result we must
-- either declare two arrays, each with two descriptions, thus requiring
-- additional types to specify the reserved areas, or we declare one
-- array of eight descriptions and only access the four "real" ones. If we
-- take the latter approach the other four descriptions would occupy the
-- reserved areas and would never be accessed. As long as the reserved
-- areas remain at their reset values (all zeroes) all should be well...
-- except that we also have the requirement to access the memory for the
-- two registers as either half-words or words, so any simplicity gained
-- from declaring an array larger than required would be lost when
-- processing it. Hence the following takes the first approach, not
-- mapping anything to the reserved upper halves of the two words.
subtype Lower_Half_Index is Integer range 1 .. 2;
type TIMx_CCMRx_Lower_Half is
array (Lower_Half_Index) of IO_Descriptor
with Volatile_Components, Component_Size => 8, Size => 16;
type TIMx_CCMRx is record
Descriptors : TIMx_CCMRx_Lower_Half;
Reserved : Bits_16;
end record with Volatile, Size => 32;
for TIMx_CCMRx use record
Descriptors at 0 range 0 .. 15;
Reserved at 0 range 16 .. 31;
end record;
-- Then we can define the array of this final record type TIMx_CCMRx,
-- taking the space of the two CCMR1 and CCMR2 register words in memory.
subtype CCMRx_Index is Integer range 1 .. 2;
type TIMx_CCMR_Pair is array (CCMRx_Index) of TIMx_CCMRx
with Component_Size => 32, Size => 64;
-- Is this better than using bit masks? There's certainly a good bit more
-- required for the declarations of the data structure! But the access code
-- is pretty small and we would argue that the compile-time checking, and
-- the readability, imply greater robustness and maintainability. (That
-- said, the existing C libraries are very stable and mature.) This part
-- of the hardware is definitely complicated in itself, and overlaying the
-- input and output descriptions in memory didn't help. Performance should
-- be reasonable, although not as good as bit-masking would be. Nowadays
-- that's not necessarily where the money is, so we go with this approach
-- for now...
procedure Write_Channel_Input_Description
(This : in out Timer;
Channel : Timer_Channel;
Kind : Timer_Input_Capture_Selection;
Description : Channel_Input_Descriptor)
with Pre => not Channel_Enabled (This, Channel);
------------ representation for the CCER ---------------------------------
-- The CCER register is composed of a logical grouping of four sets of
-- bits, one per channel. The type Single_CCE describe these four bits.
-- Channels 1 through 3 have all four bits, but channel 4 does not have
-- the complementary state and polarity bits. We pretend that it does for
-- the type declaration and then treat it accordingly in the accessing
-- subprograms.
type Single_CCE is record
CCxE : Timer_Capture_Compare_State;
CCxP : Bits_1;
CCxNE : Timer_Capture_Compare_State;
CCxNP : Bits_1;
end record with Size => 4;
for Single_CCE use record
CCxE at 0 range 0 .. 0;
CCxP at 0 range 1 .. 1;
CCxNE at 0 range 2 .. 2;
CCxNP at 0 range 3 .. 3;
end record;
type TIMx_CCER is array (Timer_Channel) of Single_CCE
with Volatile_Components, Component_Size => 4, Size => 16;
-------- representation for CCR1 through CCR4 ----------------------------
-- Instead of declaring four individual record components, one per channel,
-- each one a word in size, we just declare an array component representing
-- all four values, indexed by the channel. Timers 2 and 5 actually use all
-- 32 bits of each, the other timers only use the lower half.
type Capture_Compare_Registers is array (Timer_Channel) of Word
with Volatile_Components, Component_Size => 32, Size => 128;
---------- representation for the Break and Dead Time Register - ----------
type TIMx_BDTR is record
Reserved : Half_Word;
Main_Output_Enabled : Boolean;
Automatic_Output_Enabled : Boolean;
Break_Polarity : Timer_Break_Polarity;
Break_Enable : Boolean;
Off_State_Selection_Run_Mode : Bits_1;
Off_State_Selection_Idle_Mode : Bits_1;
Lock : Timer_Lock_Level;
Deadtime_Generator : Byte;
end record with Volatile, Size => 32;
for TIMx_BDTR use record
Reserved at 0 range 16 .. 31;
Main_Output_Enabled at 0 range 15 .. 15;
Automatic_Output_Enabled at 0 range 14 .. 14;
Break_Polarity at 0 range 13 .. 13;
Break_Enable at 0 range 12 .. 12;
Off_State_Selection_Run_Mode at 0 range 11 .. 11;
Off_State_Selection_Idle_Mode at 0 range 10 .. 10;
Lock at 0 range 8 .. 9;
Deadtime_Generator at 0 range 0 .. 7;
end record;
----------- representation for the DMA Control Register type -------------
type TIMx_DCR is record
Reserved0 : Half_Word;
Reserved1 : Bits_3;
Burst_Length : Timer_DMA_Burst_Length;
Reserved2 : Bits_3;
Base_Address : Timer_DMA_Base_Address;
end record with Volatile, Size => 32;
for TIMx_DCR use record
Reserved0 at 0 range 16 .. 31;
Reserved1 at 0 range 13 .. 15;
Burst_Length at 0 range 8 .. 12;
Reserved2 at 0 range 5 .. 7;
Base_Address at 0 range 0 .. 4;
end record;
------- representation for Timer 2, 5, and 11 remapping options ----------
type TIMx_OR is record
Reserved0 : Half_Word;
Reserved1 : Bits_4;
ITR1_RMP : Timer_2_Remapping_Options;
Reserved2 : Bits_2;
TI4_RMP : Timer_5_Remapping_Options; -- timer 5, pg 633
Reserved3 : Bits_4;
TI1_RMP : Timer_11_Remapping_Options; -- timer 11, pg 676
end record with Volatile, Size => 32;
-- TODO: ensure the gaps are kept at reserved value in the routines'
-- generated code
for TIMx_OR use record
Reserved0 at 0 range 16 .. 31;
Reserved1 at 0 range 12 .. 15;
ITR1_RMP at 0 range 10 .. 11;
Reserved2 at 0 range 8 .. 9;
TI4_RMP at 0 range 6 .. 7;
Reserved3 at 0 range 2 .. 5;
TI1_RMP at 0 range 0 .. 1;
end record;
---------------- representation for the whole Timer type -----------------
type Timer is limited record
CR1 : TIMx_CR1;
CR2 : TIMx_CR2;
SMCR : TIMx_SMCR;
DIER : Word;
SR : Word;
EGR : Word;
CCMR1_2 : TIMx_CCMR_Pair;
CCER : TIMx_CCER;
Reserved_CCER : Half_Word;
Counter : Word; -- a full word for timers 2 and 5 only
Prescaler : Half_Word;
Reserved_Prescaler : Half_Word;
ARR : Half_Word;
Reserved_ARR : Half_Word;
RCR : Word;
CCR1_4 : Capture_Compare_Registers;
BDTR : TIMx_BDTR;
DCR : TIMx_DCR;
DMAR : Word;
Options : TIMx_OR;
end record with Volatile, Size => 21 * 32;
for Timer use record
CR1 at 16#00# range 0 .. 31;
CR2 at 16#04# range 0 .. 31;
SMCR at 16#08# range 0 .. 31;
DIER at 16#0C# range 0 .. 31;
SR at 16#10# range 0 .. 31;
EGR at 16#14# range 0 .. 31;
CCMR1_2 at 16#18# range 0 .. 63;
CCER at 16#20# range 0 .. 15;
Reserved_CCER at 16#20# range 16 .. 31;
Counter at 16#24# range 0 .. 31;
Prescaler at 16#28# range 0 .. 15;
Reserved_Prescaler at 16#28# range 16 .. 31;
ARR at 16#2C# range 0 .. 15;
Reserved_ARR at 16#2C# range 16 .. 31;
RCR at 16#30# range 0 .. 31;
CCR1_4 at 16#34# range 0 .. 127; -- ie, 4 words
BDTR at 16#44# range 0 .. 31;
DCR at 16#48# range 0 .. 31;
DMAR at 16#4C# range 0 .. 31;
Options at 16#50# range 0 .. 31;
end record ;
end STM32F4.Timers;
|
thierr26/ada-keystore | Ada | 8,715 | ads | -----------------------------------------------------------------------
-- keystore-io-files -- Ada keystore IO for files
-- Copyright (C) 2019 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.Ordered_Sets;
with Ada.Containers.Hashed_Maps;
with Ada.Strings.Unbounded;
with Util.Streams.Raw;
private with Keystore.IO.Headers;
private with Util.Systems.Types;
private with Ada.Finalization;
private with Keystore.Random;
package Keystore.IO.Files is
type Wallet_Stream is limited new Keystore.IO.Wallet_Stream with private;
type Wallet_Stream_Access is access all Wallet_Stream'Class;
-- Open the wallet stream.
procedure Open (Stream : in out Wallet_Stream;
Path : in String;
Data_Path : in String);
procedure Create (Stream : in out Wallet_Stream;
Path : in String;
Data_Path : in String;
Config : in Wallet_Config);
-- Get information about the keystore file.
function Get_Info (Stream : in out Wallet_Stream) return Wallet_Info;
-- Read from the wallet stream the block identified by the number and
-- call the `Process` procedure with the data block content.
overriding
procedure Read (Stream : in out Wallet_Stream;
Block : in Storage_Block;
Process : not null access
procedure (Data : in IO_Block_Type));
-- Write in the wallet stream the block identified by the block number.
overriding
procedure Write (Stream : in out Wallet_Stream;
Block : in Storage_Block;
Process : not null access
procedure (Data : out IO_Block_Type));
-- Allocate a new block and return the block number in `Block`.
overriding
procedure Allocate (Stream : in out Wallet_Stream;
Kind : in Block_Kind;
Block : out Storage_Block);
-- Release the block number.
overriding
procedure Release (Stream : in out Wallet_Stream;
Block : in Storage_Block);
overriding
function Is_Used (Stream : in out Wallet_Stream;
Block : in Storage_Block) return Boolean;
overriding
procedure Set_Header_Data (Stream : in out Wallet_Stream;
Index : in Header_Slot_Index_Type;
Kind : in Header_Slot_Type;
Data : in Ada.Streams.Stream_Element_Array);
overriding
procedure Get_Header_Data (Stream : in out Wallet_Stream;
Index : in Header_Slot_Index_Type;
Kind : out Header_Slot_Type;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Add up to Count data storage files associated with the wallet.
procedure Add_Storage (Stream : in out Wallet_Stream;
Count : in Positive);
-- Close the wallet stream and release any resource.
procedure Close (Stream : in out Wallet_Stream);
private
use type Block_Number;
use type Storage_Identifier;
subtype Wallet_Storage is Keystore.IO.Headers.Wallet_Storage;
subtype Wallet_Header is Keystore.IO.Headers.Wallet_Header;
package Block_Number_Sets is
new Ada.Containers.Ordered_Sets (Element_Type => Block_Number,
"<" => "<",
"=" => "=");
protected type File_Stream is
procedure Open (File_Descriptor : in Util.Systems.Types.File_Type;
Storage : in Storage_Identifier;
Sign : in Secret_Key;
File_Size : in Block_Count;
UUID : out UUID_Type);
procedure Create (File_Descriptor : in Util.Systems.Types.File_Type;
Storage : in Storage_Identifier;
UUID : in UUID_Type;
Sign : in Secret_Key);
function Get_Info return Wallet_Info;
-- Read from the wallet stream the block identified by the number and
-- call the `Process` procedure with the data block content.
procedure Read (Block : in Block_Number;
Process : not null access
procedure (Data : in IO_Block_Type));
-- Write in the wallet stream the block identified by the block number.
procedure Write (Block : in Block_Number;
Process : not null access
procedure (Data : out IO_Block_Type));
-- Allocate a new block and return the block number in `Block`.
procedure Allocate (Block : out Block_Number);
-- Release the block number.
procedure Release (Block : in Block_Number);
function Is_Used (Block : in Block_Number) return Boolean;
procedure Set_Header_Data (Index : in Header_Slot_Index_Type;
Kind : in Header_Slot_Type;
Data : in Ada.Streams.Stream_Element_Array;
Sign : in Secret_Key);
procedure Get_Header_Data (Index : in Header_Slot_Index_Type;
Kind : out Header_Slot_Type;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Add_Storage (Identifier : in Storage_Identifier;
Sign : in Secret_Key);
procedure Scan_Storage (Process : not null access procedure (Storage : in Wallet_Storage));
procedure Close;
private
File : Util.Streams.Raw.Raw_Stream;
Current_Pos : Util.Systems.Types.off_t;
Size : Block_Count;
Data : IO_Block_Type;
Free_Blocks : Block_Number_Sets.Set;
Header : Wallet_Header;
end File_Stream;
type File_Stream_Access is access all File_Stream;
function Hash (Value : Storage_Identifier) return Ada.Containers.Hash_Type;
package File_Stream_Maps is
new Ada.Containers.Hashed_Maps (Key_Type => Storage_Identifier,
Element_Type => File_Stream_Access,
Hash => Hash,
Equivalent_Keys => "=",
"=" => "=");
protected type Stream_Descriptor is
procedure Open (Path : in String;
Data_Path : in String;
Sign : in Secret_Key);
procedure Create (Path : in String;
Data_Path : in String;
Config : in Wallet_Config;
Sign : in Secret_Key);
procedure Add_Storage (Count : in Positive;
Sign : in Secret_Key);
procedure Get (Storage : in Storage_Identifier;
File : out File_Stream_Access);
procedure Allocate (Kind : in Block_Kind;
Storage : out Storage_Identifier;
File : out File_Stream_Access);
procedure Close;
private
Random : Keystore.Random.Generator;
Directory : Ada.Strings.Unbounded.Unbounded_String;
UUID : UUID_Type;
Files : File_Stream_Maps.Map;
Alloc_Id : Storage_Identifier := DEFAULT_STORAGE_ID;
Last_Id : Storage_Identifier := DEFAULT_STORAGE_ID;
end Stream_Descriptor;
type Wallet_Stream is limited new Ada.Finalization.Limited_Controlled
and Keystore.IO.Wallet_Stream with record
Descriptor : Stream_Descriptor;
Sign : Secret_Key (Length => 32);
end record;
end Keystore.IO.Files;
|
rveenker/sdlada | Ada | 31,592 | ads |
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Thin binding to Simple Direct Media Layer --
-- Copyright (C) 2000-2012 A.M.F.Vargas --
-- Antonio M. M. Ferreira Vargas --
-- Manhente - Barcelos - Portugal --
-- http://adasdl.sourceforge.net --
-- E-mail: [email protected] --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- Modified for SDL2 by R.H.I. Veenker
-- (c) RNLA/JIVC/SATS
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL ( Simple DirectMedia Layer from --
-- Sam Lantinga - www.libsld.org ) --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL header files. --
-- **************************************************************** --
with System;
with Interfaces.C.Strings;
with SDL.Types; use SDL.Types;
with SDL.RWops;
package SDL.Audio is
pragma Elaborate_Body;
package C renames Interfaces.C;
use type Interfaces.C.int;
SDL_AUDIO_ALLOW_FREQUENCY_CHANGE : constant C.int := 16#00000001#;
SDL_AUDIO_ALLOW_FORMAT_CHANGE : constant C.int := 16#00000002#;
SDL_AUDIO_ALLOW_CHANNELS_CHANGE : constant C.int := 16#00000004#;
SDL_AUDIO_ALLOW_ANY_CHANGE : constant C.int := (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE
+ SDL_AUDIO_ALLOW_FORMAT_CHANGE
+ SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
-- This function is called when the audio device needs more data.
--
-- \param userdata An application-specific parameter saved in
-- the SDL_AudioSpec structure
-- \param stream A pointer to the audio data buffer.
-- \param len The length of that buffer in bytes.
--
-- Once the callback returns, the buffer will no longer be valid.
-- Stereo samples are stored in a LRLRLR ordering.
--
-- You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
-- you like. Just open your audio device with a NULL callback.
type Callback_ptr_Type is access procedure (
userdata : void_ptr;
stream : Uint8_ptr;
len : C.int);
pragma Convention (C, Callback_ptr_Type);
-- The calculated values in this structure are calculated by SDL_OpenAudio().
--
-- For multi-channel audio, the default SDL channel mapping is:
-- 2: FL FR (stereo)
-- 3: FL FR LFE (2.1 surround)
-- 4: FL FR BL BR (quad)
-- 5: FL FR FC BL BR (quad + center)
-- 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
-- 7: FL FR FC LFE BC SL SR (6.1 surround)
-- 8: FL FR FC LFE BL BR SL SR (7.1 surround)
type AudioSpec is
record
freq : C.int; -- DSP frequency -- samples per second
format : Uint16; -- Audio data format
channels : Uint8; -- Number of channels: 1 mono, 2 stereo
silence : Uint8; -- Audio buffer silence value (calculated)
samples : Uint16; -- Audio buffer size in samples
padding : Uint16; -- Necessary for some compile environments
size : Uint32; -- Audio buffer size in bytes (calculated)
-- This function is called when the audio device needs more data.
-- 'stream' is a pointer to the audio data buffer
-- 'len' is the length of that buffer in bytes.
-- Once the callback returns, the buffer will no longer be valid.
-- Stereo samples are stored in a LRLRLR ordering.
callback : Callback_ptr_Type;
userdata : void_ptr;
end record;
pragma Convention (C, AudioSpec);
type AudioSpec_ptr is access all AudioSpec;
pragma Convention (C, AudioSpec_ptr);
type Format_Flag is mod 2 ** 16;
pragma Convention (C, Format_Flag);
type Format_Flag_ptr is access Format_Flag;
pragma Convention (C, Format_Flag_ptr);
-- Audio format flags (defaults to LSB byte order)
-- Unsigned 8-bit samples
AUDIO_U8 : constant Format_Flag := 16#0008#;
-- Signed 8-bit samples
AUDIO_S8 : constant Format_Flag := 16#8008#;
-- Unsigned 16-bit samples
AUDIO_U16LSB : constant Format_Flag := 16#0010#;
-- Signed 16-bit samples
AUDIO_S16LSB : constant Format_Flag := 16#8010#;
-- As above, but big-endian byte order
AUDIO_U16MSB : constant Format_Flag := 16#1010#;
-- As above, but big-endian byte order
AUDIO_S16MSB : constant Format_Flag := 16#9010#;
AUDIO_U16 : constant Format_Flag := AUDIO_U16LSB;
AUDIO_S16 : constant Format_Flag := AUDIO_S16LSB;
function Get_Audio_U16_Sys return Format_Flag;
function Get_Audio_S16_Sys return Format_Flag;
SDL_AUDIOCVT_MAX_FILTERS : constant := 9;
-- \brief A structure to hold a set of audio conversion filters and buffers.
--
-- Note that various parts of the conversion pipeline can take advantage
-- of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require
-- you to pass it aligned data, but can possibly run much faster if you
-- set both its (buf) field to a pointer that is aligned to 16 bytes, and its
-- (len) field to something that's a multiple of 16, if possible.
-- This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't
-- pad it out to 88 bytes to guarantee ABI compatibility between compilers.
-- vvv
-- The next time we rev the ABI, make sure to size the ints and add padding.
type AudioCVT;
type AudioCVT_ptr is access all AudioCVT;
pragma Convention (C, AudioCVT_ptr);
type filter_ptr is access procedure (
cvt : AudioCVT_ptr;
format : Uint16);
pragma Convention (C, filter_ptr);
type filters_array is array (0 .. 9) of filter_ptr;
pragma Convention (C, filters_array);
type AudioCVT is
record
needed : C.int; -- Set to 1 if conversion possible
src_format : Uint16; -- Source audio format
dst_format : Uint16; -- Target audio format
rate_incr : C.double; -- Rate conversion increment
buf : Uint8_ptr; -- Buffer to hold entire audio data
len : C.int; -- Length of original audio buffer
len_cvt : C.int; -- Length of converted audio buffer
len_mult : C.int; -- buffer must be len*len_mult big
len_ratio : C.double; -- Given len, final size is len*len_ratio
filters : filters_array;
filter_index : C.int; -- Current audio conversion function
end record;
pragma Convention (C, AudioCVT);
-- -------------------
-- Function prototypes
-- -------------------
-- These functions return the list of built in audio drivers, in the
-- order that they are normally initialized by default.
function SDL_GetNumAudioDrivers return C.int;
pragma Import (C, SDL_GetNumAudioDrivers, "SDL_GetNumAudioDrivers");
function SDL_GetAudioDriver (
index : C.int)
return C.Strings.chars_ptr;
pragma Import (C, SDL_GetAudioDriver, "SDL_GetAudioDriver");
-- These function and procedure are used internally, and should not
-- be used unless you have a specific need to specify the audio driver
-- you want to use.You should normally use Init or InitSubSystem.
function SDL_AudioInit (driver_name : C.Strings.chars_ptr) return C.int;
pragma Import (C, SDL_AudioInit, "SDL_AudioInit");
procedure SDL_AudioQuit;
pragma Import (C, SDL_AudioQuit, "SDL_AudioQuit");
-- This function returns the name of the current audio driver, or NULL
-- if no driver has been initialized.
function SDL_GetCurrentAudioDriver (
namebuf : C.Strings.chars_ptr;
maslen : C.int)
return C.Strings.chars_ptr;
pragma Import (C, SDL_GetCurrentAudioDriver, "SDL_GetCurrentAudioDriver");
-- This function opens the audio device with the desired parameters, and
-- returns 0 if successful, placing the actual hardware parameters in the
-- structure pointed to by \c obtained. If \c obtained is NULL, the audio
-- data passed to the callback function will be guaranteed to be in the
-- requested format, and will be automatically converted to the hardware
-- audio format if necessary. This function returns -1 if it failed
-- to open the audio device, or couldn't set up the audio thread.
--
-- When filling in the desired audio spec structure,
-- - \c desired->freq should be the desired audio frequency in samples-per-
-- second.
-- - \c desired->format should be the desired audio format.
-- - \c desired->samples is the desired size of the audio buffer, in
-- samples. This number should be a power of two, and may be adjusted by
-- the audio driver to a value more suitable for the hardware. Good values
-- seem to range between 512 and 8096 inclusive, depending on the
-- application and CPU speed. Smaller values yield faster response time,
-- but can lead to underflow if the application is doing heavy processing
-- and cannot fill the audio buffer in time. A stereo sample consists of
-- both right and left channels in LR ordering.
-- Note that the number of samples is directly related to time by the
-- following formula: \code ms = (samples*1000)/freq \endcode
-- - \c desired->size is the size in bytes of the audio buffer, and is
-- calculated by SDL_OpenAudio().
-- - \c desired->silence is the value used to set the buffer to silence,
-- and is calculated by SDL_OpenAudio().
-- - \c desired->callback should be set to a function that will be called
-- when the audio device is ready for more data. It is passed a pointer
-- to the audio buffer, and the length in bytes of the audio buffer.
-- This function usually runs in a separate thread, and so you should
-- protect data structures that it accesses by calling SDL_LockAudio()
-- and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL
-- pointer here, and call SDL_QueueAudio() with some frequency, to queue
-- more audio samples to be played (or for capture devices, call
-- SDL_DequeueAudio() with some frequency, to obtain audio samples).
-- - \c desired->userdata is passed as the first parameter to your callback
-- function. If you passed a NULL callback, this value is ignored.
--
-- The audio device starts out playing silence when it's opened, and should
-- be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready
-- for your audio callback function to be called. Since the audio driver
-- may modify the requested size of the audio buffer, you should allocate
-- any local mixing buffers after you open the audio device.
function SDL_OpenAudio (
desired : AudioSpec_ptr;
obtained : AudioSpec_ptr)
return C.int;
pragma Import (C, SDL_OpenAudio, "SDL_OpenAudio");
-- ==========================================================================
-- SDL Audio Device IDs:
-- A successful call to SDL_OpenAudio() is always device id 1, and legacy
-- SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
-- always returns devices >= 2 on success. The legacy calls are good both
-- for backwards compatibility and when you don't care about multiple,
-- specific, or capture devices.
-- ==========================================================================
-- Get the number of available devices exposed by the current driver.
-- Only valid after a successfully initializing the audio subsystem.
-- Returns -1 if an explicit list of devices can't be determined; this is
-- not an error. For example, if SDL is set up to talk to a remote audio
-- server, it can't list every one available on the Internet, but it will
-- still allow a specific host to be specified to SDL_OpenAudioDevice().
--
-- In many common cases, when this function returns a value <= 0, it can still
-- successfully open the default device (NULL for first argument of
-- SDL_OpenAudioDevice()).
function SDL_GetNumAudioDevices (
iscapture : C.int)
return C.int;
pragma Import (C, SDL_GetNumAudioDevices, "SDL_GetNumAudioDevices");
-- Get the human-readable name of a specific audio device.
-- Must be a value between 0 and (number of audio devices-1).
-- Only valid after a successfully initializing the audio subsystem.
-- The values returned by this function reflect the latest call to
-- SDL_GetNumAudioDevices(); recall that function to redetect available
-- hardware.
--
-- The string returned by this function is UTF-8 encoded, read-only, and
-- managed internally. You are not to free it. If you need to keep the
-- string for any length of time, you should make your own copy of it, as it
-- will be invalid next time any of several other SDL functions is called.
function SDL_GetAudioDeviceName (
index : C.int;
iscapture : C.int)
return C.Strings.chars_ptr;
pragma Import (C, SDL_GetAudioDeviceName, "SDL_GetAudioDeviceName");
-- Open a specific audio device. Passing in a device name of NULL requests
-- the most reasonable default (and is equivalent to calling SDL_OpenAudio()).
--
-- The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but
-- some drivers allow arbitrary and driver-specific strings, such as a
-- hostname/IP address for a remote audio server, or a filename in the
-- diskaudio driver.
--
-- \return 0 on error, a valid device ID that is >= 2 on success.
--
-- SDL_OpenAudio(), unlike this function, always acts on device ID 1.
function SDL_OpenAudioDevice (
device : C.Strings.chars_ptr;
iscapture : C.int;
desired : AudioSpec_ptr;
obtained : AudioSpec_ptr;
allowed_changes : C.int)
return C.int;
pragma Import (C, SDL_OpenAudioDevice, "SDL_OpenAudioDevice");
-- Get the current audio state:
type audiostatus is new C.int;
AUDIO_STOPED : constant := 0;
AUDIO_PLAYING : constant := 1;
AUDIO_PAUSED : constant := 2;
function SDL_GetAudioStatus return audiostatus;
pragma Import (C, SDL_GetAudioStatus, "SDL_GetAudioStatus");
function SDL_GetAudioDeviceStatus (dev : C.int) return audiostatus;
pragma Import (C, SDL_GetAudioDeviceStatus, "SDL_GetAudioDeviceStatus");
-- These functions pause and unpause the audio callback processing.
-- They should be called with a parameter of 0 after opening the audio
-- device to start playing sound. This is so you can safely initialize
-- data for your callback function after opening the audio device.
-- Silence will be written to the audio device during the pause.
procedure SDL_PauseAudio (pause_on : C.int);
pragma Import (C, SDL_PauseAudio, "SDL_PauseAudio");
procedure SDL_PauseAudioDevice (device : C.int;
pause_on : C.int);
pragma Import (C, SDL_PauseAudioDevice, "SDL_PauseAudioDevice");
-- This function loads a WAVE from the data source, automatically freeing
-- that source if \c freesrc is non-zero. For example, to load a WAVE file,
-- you could do:
-- \code
-- SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
-- \endcode
--
-- If this function succeeds, it returns the given SDL_AudioSpec,
-- filled with the audio data format of the wave data, and sets
-- \c --audio_buf to a malloc()'d buffer containing the audio data,
-- and sets \c --audio_len to the length of that audio buffer, in bytes.
-- You need to free the audio buffer with SDL_FreeWAV() when you are
-- done with it.
--
-- This function returns NULL and sets the SDL error message if the
-- wave file cannot be opened, uses an unknown data format, or is
-- corrupt. Currently raw and MS-ADPCM WAVE files are supported.
function SDL_LoadWAV_RW (
src : SDL.RWops.RWops;
freesrc : C.int;
spec : AudioSpec_ptr;
audio_buf : Uint8_ptr_ptr;
audio_len : Uint32_ptr)
return AudioSpec_ptr;
pragma Import (C, SDL_LoadWAV_RW, "SDL_LoadWAV_RW");
-- Loads a WAV from a file.
-- Compatibility convenience function.
function SDL_LoadWAV (
file : C.Strings.chars_ptr;
spec : AudioSpec_ptr;
audio_buf : Uint8_ptr_ptr;
audio_len : Uint32_ptr)
return AudioSpec_ptr;
pragma Inline (SDL_LoadWAV);
-- This function frees data previously allocated with SDL_LoadWAV_RW()
procedure SDL_FreeWAV (audio_buf : Uint8_ptr);
pragma Import (C, SDL_FreeWAV, "SDL_FreeWAV");
-- This function takes a source format and rate and a destination format
-- and rate, and initializes the \c cvt structure with information needed
-- by SDL_ConvertAudio() to convert a buffer of audio data from one format
-- to the other. An unsupported format causes an error and -1 will be returned.
--
-- \return 0 if no conversion is needed, 1 if the audio filter is set up,
-- or -1 on error.
function SDL_BuildAudioCVT (
cvt : AudioCVT_ptr;
src_format : Uint16;
src_channels : Uint8;
src_rate : C.int;
dst_format : Uint16;
dst_channels : Uint8;
dst_rate : C.int)
return C.int;
pragma Import (C, SDL_BuildAudioCVT, "SDL_BuildAudioCVT");
-- Once you have initialized the 'cvt' structure using BuildAudioCVT,
-- created an audio buffer cvt.buf, and filled it with cvt.len bytes of
-- audio data in the source format, this function will convert it in-place
-- to the desired format.
-- The data conversion may expand the size of the audio data, so the buffer
-- cvt.buf should be allocated after the cvt structure is initialized by
-- BuildAudioCVT, and should be cvt.len * cvt.len_mult bytes long.
function SDL_ConvertAudio (cvt : AudioCVT_ptr) return C.int;
pragma Import (C, SDL_ConvertAudio, "SDL_ConvertAudio");
-- =========================================================================
-- Incomplete:
-- Needs mixer support
-- Test:
-- This takes two audio buffers of the playing audio format and mixes
-- them, performing addition, volume adjustment, and overflow clipping.
-- The volume ranges from 0 - 128, and should be set to _MIX_MAXVOLUME
-- for full audio volume. Note this does not change hardware volume.
-- This is provided for convenience -- you can mix your own audio data.
MIX_MAXVOLUME : constant := 128;
procedure MixAudio (
dst : Uint8_ptr;
src : Uint8_ptr;
len : Uint32;
volume : C.int);
pragma Import (c, MixAudio, "SDL_MixAudio");
-- =========================================================================
-- Queue more audio on non-callback devices.
--
-- (If you are looking to retrieve queued audio from a non-callback capture
-- device, you want SDL_DequeueAudio() instead. This will return -1 to
-- signify an error if you use it with capture devices.)
--
-- SDL offers two ways to feed audio to the device: you can either supply a
-- callback that SDL triggers with some frequency to obtain more audio
-- (pull method), or you can supply no callback, and then SDL will expect
-- you to supply data at regular intervals (push method) with this function.
--
-- There are no limits on the amount of data you can queue, short of
-- exhaustion of address space. Queued data will drain to the device as
-- necessary without further intervention from you. If the device needs
-- audio but there is not enough queued, it will play silence to make up
-- the difference. This means you will have skips in your audio playback
-- if you aren't routinely queueing sufficient data.
--
-- This function copies the supplied data, so you are safe to free it when
-- the function returns. This function is thread-safe, but queueing to the
-- same device from two threads at once does not promise which buffer will
-- be queued first.
--
-- You may not queue audio on a device that is using an application-supplied
-- callback; doing so returns an error. You have to use the audio callback
-- or queue audio with this function, but not both.
--
-- You should not call SDL_LockAudio() on the device before queueing; SDL
-- handles locking internally for this function.
--
-- \param dev The device ID to which we will queue audio.
-- \param data The data to queue to the device for later playback.
-- \param len The number of bytes (not samples!) to which (data) points.
-- \return 0 on success, or -1 on error.
--
-- \sa SDL_GetQueuedAudioSize
-- \sa SDL_ClearQueuedAudio
function SDL_QueueAudio (device : C.int;
data : Uint8_ptr;
len : Uint32)
return C.int;
pragma Import (C, SDL_QueueAudio, "SDL_QueueAudio");
-- Dequeue more audio on non-callback devices.
--
-- (If you are looking to queue audio for output on a non-callback playback
-- device, you want SDL_QueueAudio() instead. This will always return 0
-- if you use it with playback devices.)
--
-- SDL offers two ways to retrieve audio from a capture device: you can
-- either supply a callback that SDL triggers with some frequency as the
-- device records more audio data, (push method), or you can supply no
-- callback, and then SDL will expect you to retrieve data at regular
-- intervals (pull method) with this function.
--
-- There are no limits on the amount of data you can queue, short of
-- exhaustion of address space. Data from the device will keep queuing as
-- necessary without further intervention from you. This means you will
-- eventually run out of memory if you aren't routinely dequeueing data.
--
-- Capture devices will not queue data when paused; if you are expecting
-- to not need captured audio for some length of time, use
-- SDL_PauseAudioDevice() to stop the capture device from queueing more
-- data. This can be useful during, say, level loading times. When
-- unpaused, capture devices will start queueing data from that point,
-- having flushed any capturable data available while paused.
--
-- This function is thread-safe, but dequeueing from the same device from
-- two threads at once does not promise which thread will dequeued data
-- first.
--
-- You may not dequeue audio from a device that is using an
-- application-supplied callback; doing so returns an error. You have to use
-- the audio callback, or dequeue audio with this function, but not both.
--
-- You should not call SDL_LockAudio() on the device before queueing; SDL
-- handles locking internally for this function.
--
-- \param dev The device ID from which we will dequeue audio.
-- \param data A pointer into where audio data should be copied.
-- \param len The number of bytes (not samples!) to which (data) points.
-- \return number of bytes dequeued, which could be less than requested.
--
-- \sa SDL_GetQueuedAudioSize
-- \sa SDL_ClearQueuedAudio
function SDL_DequeueAudio (device : C.int;
data : Uint8_ptr;
len : Uint32)
return Uint32;
pragma Import (C, SDL_DequeueAudio, "SDL_DequeueAudio");
-- Get the number of bytes of still-queued audio.
--
-- For playback device:
--
-- This is the number of bytes that have been queued for playback with
-- SDL_QueueAudio(), but have not yet been sent to the hardware. This
-- number may shrink at any time, so this only informs of pending data.
--
-- Once we've sent it to the hardware, this function can not decide the
-- exact byte boundary of what has been played. It's possible that we just
-- gave the hardware several kilobytes right before you called this
-- function, but it hasn't played any of it yet, or maybe half of it, etc.
--
-- For capture devices:
--
-- This is the number of bytes that have been captured by the device and
-- are waiting for you to dequeue. This number may grow at any time, so
-- this only informs of the lower-bound of available data.
--
-- You may not queue audio on a device that is using an application-supplied
-- callback; calling this function on such a device always returns 0.
-- You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use
-- the audio callback, but not both.
--
-- You should not call SDL_LockAudio() on the device before querying; SDL
-- handles locking internally for this function.
--
-- \param dev The device ID of which we will query queued audio size.
-- \return Number of bytes (not samples!) of queued audio.
--
-- \sa SDL_QueueAudio
-- \sa SDL_ClearQueuedAudio
function SDL_GetQueuedAudioSize (device : C.int)
return Uint32;
pragma Import (C, SDL_GetQueuedAudioSize, "SDL_GetQueuedAudioSize");
-- Drop any queued audio data. For playback devices, this is any queued data
-- still waiting to be submitted to the hardware. For capture devices, this
-- is any data that was queued by the device that hasn't yet been dequeued by
-- the application.
--
-- Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For
-- playback devices, the hardware will start playing silence if more audio
-- isn't queued. Unpaused capture devices will start filling the queue again
-- as soon as they have more data available (which, depending on the state
-- of the hardware and the thread, could be before this function call
-- returns!).
--
-- This will not prevent playback of queued audio that's already been sent
-- to the hardware, as we can not undo that, so expect there to be some
-- fraction of a second of audio that might still be heard. This can be
-- useful if you want to, say, drop any pending music during a level change
-- in your game.
--
-- You may not queue audio on a device that is using an application-supplied
-- callback; calling this function on such a device is always a no-op.
-- You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use
-- the audio callback, but not both.
--
-- You should not call SDL_LockAudio() on the device before clearing the
-- queue; SDL handles locking internally for this function.
--
-- This function always succeeds and thus returns void.
--
-- \param dev The device ID of which to clear the audio queue.
--
-- \sa SDL_QueueAudio
-- \sa SDL_GetQueuedAudioSize
procedure SDL_ClearQueuedAudio (device : C.int);
pragma Import (C, SDL_ClearQueuedAudio, "SDL_ClearQueuedAudio");
-- The lock manipulated by these functions protects the callback function.
-- During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that
-- the callback function is not running. Do not call these from the callback
-- function or you will cause deadlock.
procedure LockAudio;
pragma Import (C, LockAudio, "SDL_LockAudio");
procedure SDL_LockAudioDevice (dev : C.int);
pragma Import (C, SDL_LockAudioDevice, "SDL_LockAudioDevice");
procedure UnlockAudio;
pragma Import (C, UnlockAudio, "SDL_UnlockAudio");
procedure SDL_UnlockAudioDevice (dev : C.int);
pragma Import (C, SDL_UnlockAudioDevice, "SDL_UnlockAudioDevice");
-- This procedure shuts down audio processing and closes the audio device.
procedure CloseAudio;
pragma Import (C, CloseAudio, "SDL_CloseAudio");
procedure SDL_CloseAudioDevice (dev : C.int);
pragma Import (C, SDL_CloseAudioDevice, "SDL_CloseAudioDevice");
end SDL.Audio;
|
tum-ei-rcs/StratoX | Ada | 4,534 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M E M O R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2011, 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. --
-- --
-- --
-- --
-- --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Simple implementation for use with ZFP
with System.Storage_Elements;
with Unchecked_Conversion;
package body System.Memory is
package SSE renames System.Storage_Elements;
Default_Size : constant := 20 * 1_024;
type Mark_Id is new SSE.Integer_Address;
type Memory is array (Mark_Id range <>) of SSE.Storage_Element;
for Memory'Alignment use Standard'Maximum_Alignment;
Mem : Memory (1 .. Default_Size);
Top : Mark_Id := Mem'First;
function To_Mark_Id is new Unchecked_Conversion
(size_t, Mark_Id);
----------------
-- For C code --
----------------
function Malloc (Size : size_t) return System.Address;
pragma Export (C, Malloc, "malloc");
function Calloc (N_Elem : size_t; Elem_Size : size_t) return System.Address;
pragma Export (C, Calloc, "calloc");
procedure Free (Ptr : System.Address);
pragma Export (C, Free, "free");
-----------
-- Alloc --
-----------
function Alloc (Size : size_t) return System.Address is
Max_Align : constant Mark_Id := Mark_Id (Standard'Maximum_Alignment);
Max_Size : Mark_Id :=
((To_Mark_Id (Size) + Max_Align - 1) / Max_Align) *
Max_Align;
Location : constant Mark_Id := Top;
begin
if Max_Size = 0 then
Max_Size := Max_Align;
end if;
if Size = size_t'Last then
raise Storage_Error;
end if;
Top := Top + Max_Size;
if Top > Default_Size then
raise Storage_Error;
end if;
return Mem (Location)'Address;
end Alloc;
------------
-- Malloc --
------------
function Malloc (Size : size_t) return System.Address is
begin
return Alloc (Size);
end Malloc;
------------
-- Calloc --
------------
function Calloc
(N_Elem : size_t; Elem_Size : size_t) return System.Address
is
begin
return Malloc (N_Elem * Elem_Size);
end Calloc;
----------
-- Free --
----------
procedure Free (Ptr : System.Address) is
pragma Unreferenced (Ptr);
begin
null;
end Free;
end System.Memory;
|
persan/A-gst | Ada | 22,241 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h;
-- with GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h;
with glib;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstcollectpads2_h is
-- unsupported macro: GST_TYPE_COLLECT_PADS2 (gst_collect_pads2_get_type())
-- arg-macro: function GST_COLLECT_PADS2 (obj)
-- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COLLECT_PADS2,GstCollectPads2);
-- arg-macro: function GST_COLLECT_PADS2_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COLLECT_PADS2,GstCollectPads2Class);
-- arg-macro: function GST_COLLECT_PADS2_GET_CLASS (obj)
-- return G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_COLLECT_PADS2,GstCollectPads2Class);
-- arg-macro: function GST_IS_COLLECT_PADS2 (obj)
-- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLLECT_PADS2);
-- arg-macro: function GST_IS_COLLECT_PADS2_CLASS (klass)
-- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLLECT_PADS2);
-- arg-macro: function GST_COLLECT_PADS2_STATE (data)
-- return ((GstCollectData2 *) data).state;
-- arg-macro: procedure GST_COLLECT_PADS2_STATE_IS_SET (data, flag)
-- notnot(GST_COLLECT_PADS2_STATE (data) and flag)
-- arg-macro: function GST_COLLECT_PADS2_STATE_SET (data, flag)
-- return GST_COLLECT_PADS2_STATE (data) |= flag;
-- arg-macro: function GST_COLLECT_PADS2_STATE_UNSET (data, flag)
-- return GST_COLLECT_PADS2_STATE (data) &= ~(flag);
-- arg-macro: function GST_COLLECT_PADS2_GET_STREAM_LOCK (pads)
-- return and((GstCollectPads2 *)pads).stream_lock;
-- arg-macro: function GST_COLLECT_PADS2_STREAM_LOCK (pads)
-- return g_static_rec_mutex_lock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads));
-- arg-macro: function GST_COLLECT_PADS2_STREAM_UNLOCK (pads)
-- return g_static_rec_mutex_unlock(GST_COLLECT_PADS2_GET_STREAM_LOCK (pads));
-- GStreamer
-- * Copyright (C) 2005 Wim Taymans <[email protected]>
-- * Copyright (C) 2008 Mark Nauwelaerts <[email protected]>
-- *
-- * gstcollectpads2.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 GstCollectData2;
type u_GstCollectData2_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstCollectData2 is u_GstCollectData2; -- gst/base/gstcollectpads2.h:37
-- skipped empty struct u_GstCollectData2Private
-- skipped empty struct GstCollectData2Private
type GstCollectPads2;
type u_GstCollectPads2_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstCollectPads2 is u_GstCollectPads2; -- gst/base/gstcollectpads2.h:39
-- skipped empty struct u_GstCollectPads2Private
-- skipped empty struct GstCollectPads2Private
type GstCollectPads2Class;
type u_GstCollectPads2Class_u_gst_reserved_array is array (0 .. 3) of System.Address;
--subtype GstCollectPads2Class is u_GstCollectPads2Class; -- gst/base/gstcollectpads2.h:41
--*
-- * GstCollectData2DestroyNotify:
-- * @data: the #GstCollectData2 that will be freed
-- *
-- * A function that will be called when the #GstCollectData2 will be freed.
-- * It is passed the pointer to the structure and should free any custom
-- * memory and resources allocated for it.
-- *
-- * Since: 0.10.36
--
type GstCollectData2DestroyNotify is access procedure (arg1 : access GstCollectData2);
pragma Convention (C, GstCollectData2DestroyNotify); -- gst/base/gstcollectpads2.h:53
--*
-- * GstCollectPads2StateFlags:
-- * @GST_COLLECT_PADS2_STATE_EOS: Set if collectdata's pad is EOS.
-- * @GST_COLLECT_PADS2_STATE_FLUSHING: Set if collectdata's pad is flushing.
-- * @GST_COLLECT_PADS2_STATE_NEW_SEGMENT: Set if collectdata's pad received a
-- * new_segment event.
-- * @GST_COLLECT_PADS2_STATE_WAITING: Set if collectdata's pad must be waited
-- * for when collecting.
-- * @GST_COLLECT_PADS2_STATE_LOCKED: Set collectdata's pad WAITING state must
-- * not be changed.
-- * #GstCollectPads2StateFlags indicate private state of a collectdata('s pad).
-- *
-- * Since: 0.10.36
--
subtype GstCollectPads2StateFlags is unsigned;
GST_COLLECT_PADS2_STATE_EOS : constant GstCollectPads2StateFlags := 1;
GST_COLLECT_PADS2_STATE_FLUSHING : constant GstCollectPads2StateFlags := 2;
GST_COLLECT_PADS2_STATE_NEW_SEGMENT : constant GstCollectPads2StateFlags := 4;
GST_COLLECT_PADS2_STATE_WAITING : constant GstCollectPads2StateFlags := 8;
GST_COLLECT_PADS2_STATE_LOCKED : constant GstCollectPads2StateFlags := 16; -- gst/base/gstcollectpads2.h:75
--*
-- * GST_COLLECT_PADS2_STATE:
-- * @data: a #GstCollectData2.
-- *
-- * A flags word containing #GstCollectPads2StateFlags flags set
-- * on this collected pad.
-- *
-- * Since: 0.10.36
--
--*
-- * GST_COLLECT_PADS2_STATE_IS_SET:
-- * @data: a #GstCollectData2.
-- * @flag: the #GstCollectPads2StateFlags to check.
-- *
-- * Gives the status of a specific flag on a collected pad.
-- *
-- * Since: 0.10.36
--
--*
-- * GST_COLLECT_PADS2_STATE_SET:
-- * @data: a #GstCollectData2.
-- * @flag: the #GstCollectPads2StateFlags to set.
-- *
-- * Sets a state flag on a collected pad.
-- *
-- * Since: 0.10.36
--
--*
-- * GST_COLLECT_PADS2_STATE_UNSET:
-- * @data: a #GstCollectData2.
-- * @flag: the #GstCollectPads2StateFlags to clear.
-- *
-- * Clears a state flag on a collected pad.
-- *
-- * Since: 0.10.36
--
--*
-- * GstCollectData2:
-- * @collect: owner #GstCollectPads2
-- * @pad: #GstPad managed by this data
-- * @buffer: currently queued buffer.
-- * @pos: position in the buffer
-- * @segment: last segment received.
-- *
-- * Structure used by the collect_pads2.
-- *
-- * Since: 0.10.36
--
-- with STREAM_LOCK of @collect
type GstCollectData2 is record
collect : access GstCollectPads2; -- gst/base/gstcollectpads2.h:133
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad; -- gst/base/gstcollectpads2.h:134
buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstcollectpads2.h:135
pos : aliased GLIB.guint; -- gst/base/gstcollectpads2.h:136
segment : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstsegment_h.GstSegment; -- gst/base/gstcollectpads2.h:137
state : aliased GstCollectPads2StateFlags; -- gst/base/gstcollectpads2.h:142
priv : System.Address; -- gst/base/gstcollectpads2.h:144
u_gst_reserved : u_GstCollectData2_u_gst_reserved_array; -- gst/base/gstcollectpads2.h:146
end record;
pragma Convention (C_Pass_By_Copy, GstCollectData2); -- gst/base/gstcollectpads2.h:130
--< private >
-- state: bitfield for easier extension;
-- * eos, flushing, new_segment, waiting
--*
-- * GstCollectPads2Function:
-- * @pads: the #GstCollectPads2 that trigered the callback
-- * @user_data: user data passed to gst_collect_pads2_set_function()
-- *
-- * A function that will be called when all pads have received data.
-- *
-- * Returns: #GST_FLOW_OK for success
-- *
-- * Since: 0.10.36
--
type GstCollectPads2Function is access function (arg1 : access GstCollectPads2; arg2 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn;
pragma Convention (C, GstCollectPads2Function); -- gst/base/gstcollectpads2.h:160
--*
-- * GstCollectPads2BufferFunction:
-- * @pads: the #GstCollectPads2 that trigered the callback
-- * @data: the #GstCollectData2 of pad that has received the buffer
-- * @buffer: the #GstBuffer
-- * @user_data: user data passed to gst_collect_pads2_set_buffer_function()
-- *
-- * A function that will be called when a (considered oldest) buffer can be muxed.
-- * If all pads have reached EOS, this function is called with NULL @buffer
-- * and NULL @data.
-- *
-- * Returns: #GST_FLOW_OK for success
-- *
-- * Since: 0.10.36
--
type GstCollectPads2BufferFunction is access function
(arg1 : access GstCollectPads2;
arg2 : access GstCollectData2;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
arg4 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn;
pragma Convention (C, GstCollectPads2BufferFunction); -- gst/base/gstcollectpads2.h:177
--*
-- * GstCollectPads2CompareFunction:
-- * @pads: the #GstCollectPads that is comparing the timestamps
-- * @data1: the first #GstCollectData2
-- * @timestamp1: the first timestamp
-- * @data2: the second #GstCollectData2
-- * @timestamp2: the second timestamp
-- * @user_data: user data passed to gst_collect_pads2_set_compare_function()
-- *
-- * A function for comparing two timestamps of buffers or newsegments collected on one pad.
-- *
-- * Returns: Integer less than zero when first timestamp is deemed older than the second one.
-- * Zero if the timestamps are deemed equally old.
-- * Integer greate than zero when second timestamp is deemed older than the first one.
-- *
-- * Since: 0.10.36
--
type GstCollectPads2CompareFunction is access function
(arg1 : access GstCollectPads2;
arg2 : access GstCollectData2;
arg3 : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
arg4 : access GstCollectData2;
arg5 : GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstclock_h.GstClockTime;
arg6 : System.Address) return GLIB.gint;
pragma Convention (C, GstCollectPads2CompareFunction); -- gst/base/gstcollectpads2.h:197
--*
-- * GstCollectPads2EventFunction:
-- * @pads: the #GstCollectPads2 that trigered the callback
-- * @pad: the #GstPad that received an event
-- * @event: the #GstEvent received
-- * @user_data: user data passed to gst_collect_pads2_set_event_function()
-- *
-- * A function that will be called after collectpads has processed the event.
-- *
-- * Returns: %TRUE if the pad could handle the event
-- *
-- * Since: 0.10.36
--
type GstCollectPads2EventFunction is access function
(arg1 : access GstCollectPads2;
arg2 : access GstCollectData2;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstevent_h.GstEvent;
arg4 : System.Address) return GLIB.gboolean;
pragma Convention (C, GstCollectPads2EventFunction); -- gst/base/gstcollectpads2.h:215
--*
-- * GstCollectPads2ClipFunction:
-- * @pads: a #GstCollectPads2
-- * @data: a #GstCollectData2
-- * @inbuffer: the input #GstBuffer
-- * @outbuffer: the output #GstBuffer
-- * @user_data: user data
-- *
-- * A function that will be called when @inbuffer is received on the pad managed
-- * by @data in the collecpad object @pads.
-- *
-- * The function should use the segment of @data and the negotiated media type on
-- * the pad to perform clipping of @inbuffer.
-- *
-- * This function takes ownership of @inbuffer and should output a buffer in
-- * @outbuffer or return %NULL in @outbuffer if the buffer should be dropped.
-- *
-- * Returns: a #GstFlowReturn that corresponds to the result of clipping.
-- *
-- * Since: 0.10.36
--
type GstCollectPads2ClipFunction is access function
(arg1 : access GstCollectPads2;
arg2 : access GstCollectData2;
arg3 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
arg4 : System.Address;
arg5 : System.Address) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn;
pragma Convention (C, GstCollectPads2ClipFunction); -- gst/base/gstcollectpads2.h:240
--*
-- * GST_COLLECT_PADS2_GET_STREAM_LOCK:
-- * @pads: a #GstCollectPads2
-- *
-- * Get the stream lock of @pads. The stream lock is used to coordinate and
-- * serialize execution among the various streams being collected, and in
-- * protecting the resources used to accomplish this.
-- *
-- * Since: 0.10.36
--
--*
-- * GST_COLLECT_PADS2_STREAM_LOCK:
-- * @pads: a #GstCollectPads2
-- *
-- * Lock the stream lock of @pads.
-- *
-- * Since: 0.10.36
--
--*
-- * GST_COLLECT_PADS2_STREAM_UNLOCK:
-- * @pads: a #GstCollectPads2
-- *
-- * Unlock the stream lock of @pads.
-- *
-- * Since: 0.10.36
--
--*
-- * GstCollectPads2:
-- * @data: #GList of #GstCollectData2 managed by this #GstCollectPads2.
-- *
-- * Collectpads object.
-- *
-- * Since: 0.10.36
--
type GstCollectPads2 is record
object : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObject; -- gst/base/gstcollectpads2.h:283
data : access GStreamer.GST_Low_Level.glib_2_0_glib_gslist_h.GSList; -- gst/base/gstcollectpads2.h:286
stream_lock : aliased GStreamer.GST_Low_Level.glib_2_0_glib_deprecated_gthread_h.GStaticRecMutex; -- gst/base/gstcollectpads2.h:289
priv : System.Address; -- gst/base/gstcollectpads2.h:291
u_gst_reserved : u_GstCollectPads2_u_gst_reserved_array; -- gst/base/gstcollectpads2.h:293
end record;
pragma Convention (C_Pass_By_Copy, GstCollectPads2); -- gst/base/gstcollectpads2.h:282
--< public >
-- with LOCK and/or STREAM_LOCK
-- list of CollectData items
--< private >
-- used to serialize collection among several streams
type GstCollectPads2Class is record
parent_class : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstobject_h.GstObjectClass; -- gst/base/gstcollectpads2.h:298
u_gst_reserved : u_GstCollectPads2Class_u_gst_reserved_array; -- gst/base/gstcollectpads2.h:301
end record;
pragma Convention (C_Pass_By_Copy, GstCollectPads2Class); -- gst/base/gstcollectpads2.h:297
--< private >
function gst_collect_pads2_get_type return GLIB.GType; -- gst/base/gstcollectpads2.h:304
pragma Import (C, gst_collect_pads2_get_type, "gst_collect_pads2_get_type");
-- creating the object
function gst_collect_pads2_new return access GstCollectPads2; -- gst/base/gstcollectpads2.h:307
pragma Import (C, gst_collect_pads2_new, "gst_collect_pads2_new");
-- set the callbacks
procedure gst_collect_pads2_set_function
(pads : access GstCollectPads2;
func : GstCollectPads2Function;
user_data : System.Address); -- gst/base/gstcollectpads2.h:310
pragma Import (C, gst_collect_pads2_set_function, "gst_collect_pads2_set_function");
procedure gst_collect_pads2_set_buffer_function
(pads : access GstCollectPads2;
func : GstCollectPads2BufferFunction;
user_data : System.Address); -- gst/base/gstcollectpads2.h:312
pragma Import (C, gst_collect_pads2_set_buffer_function, "gst_collect_pads2_set_buffer_function");
procedure gst_collect_pads2_set_event_function
(pads : access GstCollectPads2;
func : GstCollectPads2EventFunction;
user_data : System.Address); -- gst/base/gstcollectpads2.h:314
pragma Import (C, gst_collect_pads2_set_event_function, "gst_collect_pads2_set_event_function");
procedure gst_collect_pads2_set_compare_function
(pads : access GstCollectPads2;
func : GstCollectPads2CompareFunction;
user_data : System.Address); -- gst/base/gstcollectpads2.h:316
pragma Import (C, gst_collect_pads2_set_compare_function, "gst_collect_pads2_set_compare_function");
procedure gst_collect_pads2_set_clip_function
(pads : access GstCollectPads2;
clipfunc : GstCollectPads2ClipFunction;
user_data : System.Address); -- gst/base/gstcollectpads2.h:318
pragma Import (C, gst_collect_pads2_set_clip_function, "gst_collect_pads2_set_clip_function");
-- pad management
function gst_collect_pads2_add_pad
(pads : access GstCollectPads2;
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
size : GLIB.guint) return access GstCollectData2; -- gst/base/gstcollectpads2.h:322
pragma Import (C, gst_collect_pads2_add_pad, "gst_collect_pads2_add_pad");
function gst_collect_pads2_add_pad_full
(pads : access GstCollectPads2;
pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad;
size : GLIB.guint;
destroy_notify : GstCollectData2DestroyNotify;
lock : GLIB.gboolean) return access GstCollectData2; -- gst/base/gstcollectpads2.h:323
pragma Import (C, gst_collect_pads2_add_pad_full, "gst_collect_pads2_add_pad_full");
function gst_collect_pads2_remove_pad (pads : access GstCollectPads2; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/base/gstcollectpads2.h:325
pragma Import (C, gst_collect_pads2_remove_pad, "gst_collect_pads2_remove_pad");
function gst_collect_pads2_is_active (pads : access GstCollectPads2; pad : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstPad) return GLIB.gboolean; -- gst/base/gstcollectpads2.h:326
pragma Import (C, gst_collect_pads2_is_active, "gst_collect_pads2_is_active");
-- start/stop collection
function gst_collect_pads2_collect (pads : access GstCollectPads2) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/base/gstcollectpads2.h:329
pragma Import (C, gst_collect_pads2_collect, "gst_collect_pads2_collect");
function gst_collect_pads2_collect_range
(pads : access GstCollectPads2;
offset : GLIB.guint64;
length : GLIB.guint) return GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstpad_h.GstFlowReturn; -- gst/base/gstcollectpads2.h:330
pragma Import (C, gst_collect_pads2_collect_range, "gst_collect_pads2_collect_range");
procedure gst_collect_pads2_start (pads : access GstCollectPads2); -- gst/base/gstcollectpads2.h:332
pragma Import (C, gst_collect_pads2_start, "gst_collect_pads2_start");
procedure gst_collect_pads2_stop (pads : access GstCollectPads2); -- gst/base/gstcollectpads2.h:333
pragma Import (C, gst_collect_pads2_stop, "gst_collect_pads2_stop");
procedure gst_collect_pads2_set_flushing (pads : access GstCollectPads2; flushing : GLIB.gboolean); -- gst/base/gstcollectpads2.h:334
pragma Import (C, gst_collect_pads2_set_flushing, "gst_collect_pads2_set_flushing");
-- get collected buffers
function gst_collect_pads2_peek (pads : access GstCollectPads2; data : access GstCollectData2) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstcollectpads2.h:337
pragma Import (C, gst_collect_pads2_peek, "gst_collect_pads2_peek");
function gst_collect_pads2_pop (pads : access GstCollectPads2; data : access GstCollectData2) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstcollectpads2.h:338
pragma Import (C, gst_collect_pads2_pop, "gst_collect_pads2_pop");
-- get collected bytes
function gst_collect_pads2_available (pads : access GstCollectPads2) return GLIB.guint; -- gst/base/gstcollectpads2.h:341
pragma Import (C, gst_collect_pads2_available, "gst_collect_pads2_available");
function gst_collect_pads2_read
(pads : access GstCollectPads2;
data : access GstCollectData2;
bytes : System.Address;
size : GLIB.guint) return GLIB.guint; -- gst/base/gstcollectpads2.h:342
pragma Import (C, gst_collect_pads2_read, "gst_collect_pads2_read");
function gst_collect_pads2_flush
(pads : access GstCollectPads2;
data : access GstCollectData2;
size : GLIB.guint) return GLIB.guint; -- gst/base/gstcollectpads2.h:344
pragma Import (C, gst_collect_pads2_flush, "gst_collect_pads2_flush");
function gst_collect_pads2_read_buffer
(pads : access GstCollectPads2;
data : access GstCollectData2;
size : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstcollectpads2.h:346
pragma Import (C, gst_collect_pads2_read_buffer, "gst_collect_pads2_read_buffer");
function gst_collect_pads2_take_buffer
(pads : access GstCollectPads2;
data : access GstCollectData2;
size : GLIB.guint) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/base/gstcollectpads2.h:348
pragma Import (C, gst_collect_pads2_take_buffer, "gst_collect_pads2_take_buffer");
-- setting and unsetting waiting mode
procedure gst_collect_pads2_set_waiting
(pads : access GstCollectPads2;
data : access GstCollectData2;
waiting : GLIB.gboolean); -- gst/base/gstcollectpads2.h:352
pragma Import (C, gst_collect_pads2_set_waiting, "gst_collect_pads2_set_waiting");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_base_gstcollectpads2_h;
|
AdaCore/Ada_Drivers_Library | Ada | 7,690 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.FLASH is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ACR_LATENCY_Field is HAL.UInt3;
-- Flash access control register
type ACR_Register is record
-- Latency
LATENCY : ACR_LATENCY_Field := 16#0#;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Prefetch enable
PRFTEN : Boolean := False;
-- Instruction cache enable
ICEN : Boolean := False;
-- Data cache enable
DCEN : Boolean := False;
-- Write-only. Instruction cache reset
ICRST : Boolean := False;
-- Data cache reset
DCRST : Boolean := False;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ACR_Register use record
LATENCY at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
PRFTEN at 0 range 8 .. 8;
ICEN at 0 range 9 .. 9;
DCEN at 0 range 10 .. 10;
ICRST at 0 range 11 .. 11;
DCRST at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-- Status register
type SR_Register is record
-- End of operation
EOP : Boolean := False;
-- Operation error
OPERR : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Write protection error
WRPERR : Boolean := False;
-- Programming alignment error
PGAERR : Boolean := False;
-- Programming parallelism error
PGPERR : Boolean := False;
-- Programming sequence error
PGSERR : Boolean := False;
-- unspecified
Reserved_8_15 : HAL.UInt8 := 16#0#;
-- Read-only. Busy
BSY : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
EOP at 0 range 0 .. 0;
OPERR at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WRPERR at 0 range 4 .. 4;
PGAERR at 0 range 5 .. 5;
PGPERR at 0 range 6 .. 6;
PGSERR at 0 range 7 .. 7;
Reserved_8_15 at 0 range 8 .. 15;
BSY at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype CR_SNB_Field is HAL.UInt5;
subtype CR_PSIZE_Field is HAL.UInt2;
-- Control register
type CR_Register is record
-- Programming
PG : Boolean := False;
-- Sector Erase
SER : Boolean := False;
-- Mass Erase of sectors 0 to 11
MER : Boolean := False;
-- Sector number
SNB : CR_SNB_Field := 16#0#;
-- Program size
PSIZE : CR_PSIZE_Field := 16#0#;
-- unspecified
Reserved_10_14 : HAL.UInt5 := 16#0#;
-- Mass Erase of sectors 12 to 23
MER1 : Boolean := False;
-- Start
STRT : Boolean := False;
-- unspecified
Reserved_17_23 : HAL.UInt7 := 16#0#;
-- End of operation interrupt enable
EOPIE : Boolean := False;
-- Error interrupt enable
ERRIE : Boolean := False;
-- unspecified
Reserved_26_30 : HAL.UInt5 := 16#0#;
-- Lock
LOCK : Boolean := True;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
PG at 0 range 0 .. 0;
SER at 0 range 1 .. 1;
MER at 0 range 2 .. 2;
SNB at 0 range 3 .. 7;
PSIZE at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
MER1 at 0 range 15 .. 15;
STRT at 0 range 16 .. 16;
Reserved_17_23 at 0 range 17 .. 23;
EOPIE at 0 range 24 .. 24;
ERRIE at 0 range 25 .. 25;
Reserved_26_30 at 0 range 26 .. 30;
LOCK at 0 range 31 .. 31;
end record;
subtype OPTCR_BOR_LEV_Field is HAL.UInt2;
subtype OPTCR_RDP_Field is HAL.UInt8;
subtype OPTCR_nWRP_Field is HAL.UInt12;
-- Flash option control register
type OPTCR_Register is record
-- Option lock
OPTLOCK : Boolean := True;
-- Option start
OPTSTRT : Boolean := False;
-- BOR reset Level
BOR_LEV : OPTCR_BOR_LEV_Field := 16#3#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- WDG_SW User option bytes
WDG_SW : Boolean := True;
-- nRST_STOP User option bytes
nRST_STOP : Boolean := True;
-- nRST_STDBY User option bytes
nRST_STDBY : Boolean := True;
-- Read protect
RDP : OPTCR_RDP_Field := 16#AA#;
-- Not write protect
nWRP : OPTCR_nWRP_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OPTCR_Register use record
OPTLOCK at 0 range 0 .. 0;
OPTSTRT at 0 range 1 .. 1;
BOR_LEV at 0 range 2 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
WDG_SW at 0 range 5 .. 5;
nRST_STOP at 0 range 6 .. 6;
nRST_STDBY at 0 range 7 .. 7;
RDP at 0 range 8 .. 15;
nWRP at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype OPTCR1_nWRP_Field is HAL.UInt12;
-- Flash option control register 1
type OPTCR1_Register is record
-- unspecified
Reserved_0_15 : HAL.UInt16 := 16#0#;
-- Not write protect
nWRP : OPTCR1_nWRP_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OPTCR1_Register use record
Reserved_0_15 at 0 range 0 .. 15;
nWRP at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- FLASH
type FLASH_Peripheral is record
-- Flash access control register
ACR : aliased ACR_Register;
-- Flash key register
KEYR : aliased HAL.UInt32;
-- Flash option key register
OPTKEYR : aliased HAL.UInt32;
-- Status register
SR : aliased SR_Register;
-- Control register
CR : aliased CR_Register;
-- Flash option control register
OPTCR : aliased OPTCR_Register;
-- Flash option control register 1
OPTCR1 : aliased OPTCR1_Register;
end record
with Volatile;
for FLASH_Peripheral use record
ACR at 16#0# range 0 .. 31;
KEYR at 16#4# range 0 .. 31;
OPTKEYR at 16#8# range 0 .. 31;
SR at 16#C# range 0 .. 31;
CR at 16#10# range 0 .. 31;
OPTCR at 16#14# range 0 .. 31;
OPTCR1 at 16#18# range 0 .. 31;
end record;
-- FLASH
FLASH_Periph : aliased FLASH_Peripheral
with Import, Address => System'To_Address (16#40023C00#);
end STM32_SVD.FLASH;
|
wookey-project/ewok-legacy | Ada | 11,498 | 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
convention => c,
export => true,
external_name => "soc_dwt_stop_timer",
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,
convention => c,
export => true,
external_name => "soc_dwt_ovf_manage";
-- initialize the DWT module
-- This procedure is called by the kernel main() function, and as
-- a consequence exported to C
procedure init
with
pre => not init_is_done,
global => (in_out => (Ini_F,
Ctrl,
Dem),
output => (Last,
Loo,
Cnt,
Lar_register)),
convention => c,
export => true,
external_name => "soc_dwt_init";
-- get the DWT timer (without overflow support, keep a 32bit value)
procedure get_cycles_32(cycles : out unsigned_32)
with
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
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
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;
|
DrenfongWong/tkm-rpc | Ada | 1,032 | ads | with Tkmrpc.Types;
with Tkmrpc.Operations.Ike;
package Tkmrpc.Response.Ike.Esa_Reset is
Data_Size : constant := 0;
Padding_Size : constant := Response.Body_Size - Data_Size;
subtype Padding_Range is Natural range 1 .. Padding_Size;
subtype Padding_Type is Types.Byte_Sequence (Padding_Range);
type Response_Type is record
Header : Response.Header_Type;
Padding : Padding_Type;
end record;
for Response_Type use record
Header at 0 range 0 .. (Response.Header_Size * 8) - 1;
Padding at Response.Header_Size + Data_Size range
0 .. (Padding_Size * 8) - 1;
end record;
for Response_Type'Size use Response.Response_Size * 8;
Null_Response : constant Response_Type :=
Response_Type'
(Header =>
Response.Header_Type'(Operation => Operations.Ike.Esa_Reset,
Result => Results.Invalid_Operation,
Request_Id => 0),
Padding => Padding_Type'(others => 0));
end Tkmrpc.Response.Ike.Esa_Reset;
|
stcarrez/ada-el | Ada | 2,818 | adb | -----------------------------------------------------------------------
-- 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 Util.Beans.Objects;
package body EL.Beans is
-- ------------------------------
-- 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) is
Param : Param_Value (Length => Name'Length);
begin
Param.Name := Name;
Param.Value := EL.Expressions.Create_Expression (Value, Context).Reduce_Expression (Context);
Container.Append (Param);
end Add_Parameter;
-- ------------------------------
-- 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) is
procedure Set_Parameter (Param : in Param_Value);
procedure Set_Parameter (Param : in Param_Value) is
Value : constant Util.Beans.Objects.Object := Param.Value.Get_Value (Context);
begin
Bean.Set_Value (Param.Name, Value);
end Set_Parameter;
Iter : Param_Vectors.Cursor := Params.First;
begin
while Param_Vectors.Has_Element (Iter) loop
Param_Vectors.Query_Element (Iter, Set_Parameter'Access);
Param_Vectors.Next (Iter);
end loop;
end Initialize;
end EL.Beans;
|
AdaCore/Ada_Drivers_Library | Ada | 2,663 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016-2020, 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 NRF52_DK.Time;
with NRF52_DK.LEDs; use NRF52_DK.LEDs;
with Beacon;
procedure Main is
begin
Initialize_LEDs;
Beacon.Initialize_Radio;
loop
Turn_On (LED1);
Beacon.Send_Beacon_Packet;
Turn_Off (LED1);
NRF52_DK.Time.Delay_Ms (500);
end loop;
end Main;
|
landgraf/nanomsg-ada | Ada | 2,715 | adb | -- The MIT License (MIT)
-- Copyright (c) 2015 Pavel Zhukov <[email protected]>
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Nanomsg.Domains;
with Nanomsg.Pipeline;
with Aunit.Assertions;
with Nanomsg.Messages;
package body Nanomsg.Test_Send_Binary_File is
procedure Run_Test (T : in out TC) is
use Aunit.Assertions;
Address : constant String := "tcp://127.0.0.1:5555";
Msg1 : Nanomsg.Messages.Message_T;-- := Nanomsg.Messages.From_File ("tests/data/test_send_binary_file.jpg");
Msg2 : Nanomsg.Messages.Message_T := Nanomsg.Messages.Empty_Message;
begin
Assert (False, "Not Implemented yer");
Nanomsg.Socket.Init (T.Socket1, Nanomsg.Domains.Af_Sp, Nanomsg.Pipeline.Nn_Push);
Nanomsg.Socket.Init (T.Socket2, Nanomsg.Domains.Af_Sp, Nanomsg.Pipeline.Nn_Pull);
Assert (Condition => not T.Socket1.Is_Null, Message => "Failed to initialize socket1");
Assert (Condition => not T.Socket2.Is_Null, Message => "Failed to initialize socket2");
Assert (Condition => T.Socket1.Get_Fd /= T.Socket2.Get_Fd,
Message => "Descriptors collision!");
Nanomsg.Socket.Connect (T.Socket1, Address);
Nanomsg.Socket.Bind (T.Socket2, "tcp://*:5555");
end Run_Test;
function Name (T : TC) return Message_String is
begin
return Aunit.Format ("Test case name : Message send/receive test");
end Name;
procedure Tear_Down (T : in out Tc) is
begin
if T.Socket1.Get_Fd >= 0 then
T.Socket1.Close;
end if;
if T.Socket2.Get_Fd >= 0 then
T.Socket2.Close;
end if;
end Tear_Down;
end Nanomsg.Test_Send_Binary_File;
|
AdaCore/training_material | Ada | 259 | ads | package Protected_Objects is
--$ begin cut
protected Object
with Lock_Free is
--$ end cut
procedure Set (V : Integer);
function Get return Integer;
private
Local : Integer := 0;
end Object;
end Protected_Objects;
|
zhmu/ananas | Ada | 3,635 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . T T Y --
-- --
-- S p e c --
-- --
-- Copyright (C) 2002-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides control over pseudo terminals (ttys)
-- This package is only supported on unix systems. See function TTY_Supported
-- to test dynamically whether other functions of this package can be called.
with System;
with GNAT.OS_Lib;
package GNAT.TTY is
type TTY_Handle is private;
-- Handle for a tty descriptor
function TTY_Supported return Boolean;
-- If True, the other functions of this package can be called. Otherwise,
-- all functions in this package will raise Program_Error if called.
procedure Allocate_TTY (Handle : out TTY_Handle);
-- Allocate a new tty
procedure Reset_TTY (Handle : TTY_Handle);
-- Reset settings of a given tty
procedure Close_TTY (Handle : in out TTY_Handle);
-- Close a given tty
function TTY_Name (Handle : TTY_Handle) return String;
-- Return the external name of a tty. The name depends on the tty handling
-- on the given target. It will typically look like: "/dev/ptya1"
function TTY_Descriptor
(Handle : TTY_Handle) return GNAT.OS_Lib.File_Descriptor;
-- Return the low level descriptor associated with Handle
private
type TTY_Handle is record
Handle : System.Address := System.Null_Address;
end record;
end GNAT.TTY;
|
reznikmm/matreshka | Ada | 3,987 | 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.Xhtml_Content_Attributes;
package Matreshka.ODF_Xhtml.Content_Attributes is
type Xhtml_Content_Attribute_Node is
new Matreshka.ODF_Xhtml.Abstract_Xhtml_Attribute_Node
and ODF.DOM.Xhtml_Content_Attributes.ODF_Xhtml_Content_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Xhtml_Content_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Xhtml_Content_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Xhtml.Content_Attributes;
|
reznikmm/matreshka | Ada | 40,735 | 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$
------------------------------------------------------------------------------
with AMF.Internals.UML_Nodes;
with AMF.String_Collections;
with AMF.UML.Behaviors.Collections;
with AMF.UML.Classes.Collections;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Collaboration_Uses.Collections;
with AMF.UML.Connectable_Elements.Collections;
with AMF.UML.Connectors.Collections;
with AMF.UML.Constraints.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Deployments.Collections;
with AMF.UML.Devices;
with AMF.UML.Element_Imports.Collections;
with AMF.UML.Extensions.Collections;
with AMF.UML.Features.Collections;
with AMF.UML.Generalization_Sets.Collections;
with AMF.UML.Generalizations.Collections;
with AMF.UML.Interface_Realizations.Collections;
with AMF.UML.Named_Elements.Collections;
with AMF.UML.Namespaces;
with AMF.UML.Nodes.Collections;
with AMF.UML.Operations.Collections;
with AMF.UML.Package_Imports.Collections;
with AMF.UML.Packageable_Elements.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.Parameterable_Elements.Collections;
with AMF.UML.Ports.Collections;
with AMF.UML.Properties.Collections;
with AMF.UML.Receptions.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.String_Expressions;
with AMF.UML.Substitutions.Collections;
with AMF.UML.Template_Bindings.Collections;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Types;
with AMF.UML.Use_Cases.Collections;
with AMF.Visitors;
package AMF.Internals.UML_Devices is
type UML_Device_Proxy is
limited new AMF.Internals.UML_Nodes.UML_Node_Proxy
and AMF.UML.Devices.UML_Device with null record;
overriding function Get_Nested_Node
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Nodes.Collections.Set_Of_UML_Node;
-- Getter of Node::nestedNode.
--
-- The Nodes that are defined (nested) within the Node.
overriding function Get_Extension
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Getter of Class::extension.
--
-- References the Extensions that specify additional properties of the
-- metaclass. The property is derived from the extensions whose memberEnds
-- are typed by the Class.
overriding function Get_Is_Abstract
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Getter of Class::isAbstract.
--
-- True when a class is abstract.
-- If true, the Classifier does not provide a complete declaration and can
-- typically not be instantiated. An abstract classifier is intended to be
-- used by other classifiers e.g. as the target of general
-- metarelationships or generalization relationships.
overriding function Get_Is_Active
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Getter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding procedure Set_Is_Active
(Self : not null access UML_Device_Proxy;
To : Boolean);
-- Setter of Class::isActive.
--
-- Determines whether an object specified by this class is active or not.
-- If true, then the owning class is referred to as an active class. If
-- false, then such a class is referred to as a passive class.
overriding function Get_Nested_Classifier
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifiers.Collections.Ordered_Set_Of_UML_Classifier;
-- Getter of Class::nestedClassifier.
--
-- References all the Classifiers that are defined (nested) within the
-- Class.
overriding function Get_Owned_Attribute
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Properties.Collections.Ordered_Set_Of_UML_Property;
-- Getter of Class::ownedAttribute.
--
-- The attributes (i.e. the properties) owned by the class.
overriding function Get_Owned_Operation
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Operations.Collections.Ordered_Set_Of_UML_Operation;
-- Getter of Class::ownedOperation.
--
-- The operations owned by the class.
overriding function Get_Owned_Reception
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Receptions.Collections.Set_Of_UML_Reception;
-- Getter of Class::ownedReception.
--
-- Receptions that objects of this class are willing to accept.
overriding function Get_Super_Class
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Getter of Class::superClass.
--
-- This gives the superclasses of a class.
overriding function Get_Classifier_Behavior
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding procedure Set_Classifier_Behavior
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of BehavioredClassifier::classifierBehavior.
--
-- A behavior specification that specifies the behavior of the classifier
-- itself.
overriding function Get_Interface_Realization
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Interface_Realizations.Collections.Set_Of_UML_Interface_Realization;
-- Getter of BehavioredClassifier::interfaceRealization.
--
-- The set of InterfaceRealizations owned by the BehavioredClassifier.
-- Interface realizations reference the Interfaces of which the
-- BehavioredClassifier is an implementation.
overriding function Get_Owned_Behavior
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior;
-- Getter of BehavioredClassifier::ownedBehavior.
--
-- References behavior specifications owned by a classifier.
overriding function Get_Attribute
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of Classifier::attribute.
--
-- Refers to all of the Properties that are direct (i.e. not inherited or
-- imported) attributes of the classifier.
overriding function Get_Collaboration_Use
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Collaboration_Uses.Collections.Set_Of_UML_Collaboration_Use;
-- Getter of Classifier::collaborationUse.
--
-- References the collaboration uses owned by the classifier.
overriding function Get_Feature
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Getter of Classifier::feature.
--
-- Specifies each feature defined in the classifier.
-- Note that there may be members of the Classifier that are of the type
-- Feature but are not included in this association, e.g. inherited
-- features.
overriding function Get_General
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::general.
--
-- Specifies the general Classifiers for this Classifier.
-- References the general classifier in the Generalization relationship.
overriding function Get_Generalization
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization;
-- Getter of Classifier::generalization.
--
-- Specifies the Generalization relationships for this Classifier. These
-- Generalizations navigaten to more general classifiers in the
-- generalization hierarchy.
overriding function Get_Inherited_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Classifier::inheritedMember.
--
-- Specifies all elements inherited by this classifier from the general
-- classifiers.
overriding function Get_Is_Final_Specialization
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Getter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding procedure Set_Is_Final_Specialization
(Self : not null access UML_Device_Proxy;
To : Boolean);
-- Setter of Classifier::isFinalSpecialization.
--
-- If true, the Classifier cannot be specialized by generalization. Note
-- that this property is preserved through package merge operations; that
-- is, the capability to specialize a Classifier (i.e.,
-- isFinalSpecialization =false) must be preserved in the resulting
-- Classifier of a package merge operation where a Classifier with
-- isFinalSpecialization =false is merged with a matching Classifier with
-- isFinalSpecialization =true: the resulting Classifier will have
-- isFinalSpecialization =false.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
-- Getter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access);
-- Setter of Classifier::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Owned_Use_Case
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::ownedUseCase.
--
-- References the use cases owned by this classifier.
overriding function Get_Powertype_Extent
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Generalization_Sets.Collections.Set_Of_UML_Generalization_Set;
-- Getter of Classifier::powertypeExtent.
--
-- Designates the GeneralizationSet of which the associated Classifier is
-- a power type.
overriding function Get_Redefined_Classifier
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of Classifier::redefinedClassifier.
--
-- References the Classifiers that are redefined by this Classifier.
overriding function Get_Representation
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
-- Getter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding procedure Set_Representation
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access);
-- Setter of Classifier::representation.
--
-- References a collaboration use which indicates the collaboration that
-- represents this classifier.
overriding function Get_Substitution
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Substitutions.Collections.Set_Of_UML_Substitution;
-- Getter of Classifier::substitution.
--
-- References the substitutions that are owned by this Classifier.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
-- Getter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access);
-- Setter of Classifier::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Use_Case
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Use_Cases.Collections.Set_Of_UML_Use_Case;
-- Getter of Classifier::useCase.
--
-- The set of use cases for which this Classifier is the subject.
overriding function Get_Element_Import
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import;
-- Getter of Namespace::elementImport.
--
-- References the ElementImports owned by the Namespace.
overriding function Get_Imported_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of Namespace::importedMember.
--
-- References the PackageableElements that are members of this Namespace
-- as a result of either PackageImports or ElementImports.
overriding function Get_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::member.
--
-- A collection of NamedElements identifiable within the Namespace, either
-- by being owned or by being introduced by importing or inheritance.
overriding function Get_Owned_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Getter of Namespace::ownedMember.
--
-- A collection of NamedElements owned by the Namespace.
overriding function Get_Owned_Rule
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint;
-- Getter of Namespace::ownedRule.
--
-- Specifies a set of Constraints owned by this Namespace.
overriding function Get_Package_Import
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import;
-- Getter of Namespace::packageImport.
--
-- References the PackageImports owned by the Namespace.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Device_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Device_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Get_Package
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packages.UML_Package_Access;
-- Getter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding procedure Set_Package
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Packages.UML_Package_Access);
-- Setter of Type::package.
--
-- Specifies the owning package of this classifier, if any.
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::owningTemplateParameter.
--
-- The formal template parameter that owns this element.
overriding function Get_Template_Parameter
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
-- Getter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding procedure Set_Template_Parameter
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access);
-- Setter of ParameterableElement::templateParameter.
--
-- The template parameter that exposes this element as a formal parameter.
overriding function Get_Owned_Template_Signature
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
-- Getter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding procedure Set_Owned_Template_Signature
(Self : not null access UML_Device_Proxy;
To : AMF.UML.Template_Signatures.UML_Template_Signature_Access);
-- Setter of TemplateableElement::ownedTemplateSignature.
--
-- The optional template signature specifying the formal template
-- parameters.
overriding function Get_Template_Binding
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding;
-- Getter of TemplateableElement::templateBinding.
--
-- The optional bindings from this element to templates.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Device_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Owned_Port
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Getter of EncapsulatedClassifier::ownedPort.
--
-- References a set of ports that an encapsulated classifier owns.
overriding function Get_Owned_Connector
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Connectors.Collections.Set_Of_UML_Connector;
-- Getter of StructuredClassifier::ownedConnector.
--
-- References the connectors owned by the classifier.
overriding function Get_Part
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Getter of StructuredClassifier::part.
--
-- References the properties specifying instances that the classifier owns
-- by composition. This association is derived, selecting those owned
-- properties where isComposite is true.
overriding function Get_Role
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Connectable_Elements.Collections.Set_Of_UML_Connectable_Element;
-- Getter of StructuredClassifier::role.
--
-- References the roles that instances may play in this classifier.
overriding function Get_Deployed_Element
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Getter of DeploymentTarget::deployedElement.
--
-- The set of elements that are manifested in an Artifact that is involved
-- in Deployment to a DeploymentTarget.
overriding function Get_Deployment
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Deployments.Collections.Set_Of_UML_Deployment;
-- Getter of DeploymentTarget::deployment.
--
-- The set of Deployments for a DeploymentTarget.
overriding function Extension
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Extensions.Collections.Set_Of_UML_Extension;
-- Operation Class::extension.
--
-- Missing derivation for Class::/extension : Extension
overriding function Inherit
(Self : not null access constant UML_Device_Proxy;
Inhs : AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Class::inherit.
--
-- The inherit operation is overridden to exclude redefined properties.
overriding function Super_Class
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classes.Collections.Set_Of_UML_Class;
-- Operation Class::superClass.
--
-- Missing derivation for Class::/superClass : Class
overriding function All_Features
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Features.Collections.Set_Of_UML_Feature;
-- Operation Classifier::allFeatures.
--
-- The query allFeatures() gives all of the features in the namespace of
-- the classifier. In general, through mechanisms such as inheritance,
-- this will be a larger set than feature.
overriding function Conforms_To
(Self : not null access constant UML_Device_Proxy;
Other : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::conformsTo.
--
-- The query conformsTo() gives true for a classifier that defines a type
-- that conforms to another. This is used, for example, in the
-- specification of signature conformance for operations.
overriding function General
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Operation Classifier::general.
--
-- The general classifiers are the classifiers referenced by the
-- generalization relationships.
overriding function Has_Visibility_Of
(Self : not null access constant UML_Device_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access)
return Boolean;
-- Operation Classifier::hasVisibilityOf.
--
-- The query hasVisibilityOf() determines whether a named element is
-- visible in the classifier. By default all are visible. It is only
-- called when the argument is something owned by a parent.
overriding function Inheritable_Members
(Self : not null access constant UML_Device_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritableMembers.
--
-- The query inheritableMembers() gives all of the members of a classifier
-- that may be inherited in one of its descendants, subject to whatever
-- visibility restrictions apply.
overriding function Inherited_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Classifier::inheritedMember.
--
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
-- The inheritedMember association is derived by inheriting the
-- inheritable members of the parents.
overriding function Is_Template
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Operation Classifier::isTemplate.
--
-- The query isTemplate() returns whether this templateable element is
-- actually a template.
overriding function May_Specialize_Type
(Self : not null access constant UML_Device_Proxy;
C : AMF.UML.Classifiers.UML_Classifier_Access)
return Boolean;
-- Operation Classifier::maySpecializeType.
--
-- The query maySpecializeType() determines whether this classifier may
-- have a generalization relationship to classifiers of the specified
-- type. By default a classifier may specialize classifiers of the same or
-- a more general type. It is intended to be redefined by classifiers that
-- have different specialization constraints.
overriding function Exclude_Collisions
(Self : not null access constant UML_Device_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::excludeCollisions.
--
-- The query excludeCollisions() excludes from a set of
-- PackageableElements any that would not be distinguishable from each
-- other in this namespace.
overriding function Get_Names_Of_Member
(Self : not null access constant UML_Device_Proxy;
Element : AMF.UML.Named_Elements.UML_Named_Element_Access)
return AMF.String_Collections.Set_Of_String;
-- Operation Namespace::getNamesOfMember.
--
-- The query getNamesOfMember() takes importing into account. It gives
-- back the set of names that an element would have in an importing
-- namespace, either because it is owned, or if not owned then imported
-- individually, or if not individually then from a package.
-- The query getNamesOfMember() gives a set of all of the names that a
-- member would have in a Namespace. In general a member can have multiple
-- names in a Namespace if it is imported more than once with different
-- aliases. The query takes account of importing. It gives back the set of
-- names that an element would have in an importing namespace, either
-- because it is owned, or if not owned then imported individually, or if
-- not individually then from a package.
overriding function Import_Members
(Self : not null access constant UML_Device_Proxy;
Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importMembers.
--
-- The query importMembers() defines which of a set of PackageableElements
-- are actually imported into the namespace. This excludes hidden ones,
-- i.e., those which have names that conflict with names of owned members,
-- and also excludes elements which would have the same name when imported.
overriding function Imported_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation Namespace::importedMember.
--
-- The importedMember property is derived from the ElementImports and the
-- PackageImports. References the PackageableElements that are members of
-- this Namespace as a result of either PackageImports or ElementImports.
overriding function Members_Are_Distinguishable
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Operation Namespace::membersAreDistinguishable.
--
-- The Boolean query membersAreDistinguishable() determines whether all of
-- the namespace's members are distinguishable within it.
overriding function Owned_Member
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element;
-- Operation Namespace::ownedMember.
--
-- Missing derivation for Namespace::/ownedMember : NamedElement
overriding function All_Owning_Packages
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Device_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding function Conforms_To
(Self : not null access constant UML_Device_Proxy;
Other : AMF.UML.Types.UML_Type_Access)
return Boolean;
-- Operation Type::conformsTo.
--
-- The query conformsTo() gives true for a type that conforms to another.
-- By default, two types do not conform to each other. This query is
-- intended to be redefined for specific conformance situations.
overriding function Is_Compatible_With
(Self : not null access constant UML_Device_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean;
-- Operation ParameterableElement::isCompatibleWith.
--
-- The query isCompatibleWith() determines if this parameterable element
-- is compatible with the specified parameterable element. By default
-- parameterable element P is compatible with parameterable element Q if
-- the kind of P is the same or a subtype as the kind of Q. Subclasses
-- should override this operation to specify different compatibility
-- constraints.
overriding function Is_Template_Parameter
(Self : not null access constant UML_Device_Proxy)
return Boolean;
-- Operation ParameterableElement::isTemplateParameter.
--
-- The query isTemplateParameter() determines if this parameterable
-- element is exposed as a formal template parameter.
overriding function Parameterable_Elements
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element;
-- Operation TemplateableElement::parameterableElements.
--
-- The query parameterableElements() returns the set of elements that may
-- be used as the parametered elements for a template parameter of this
-- templateable element. By default, this set includes all the owned
-- elements. Subclasses may override this operation if they choose to
-- restrict the set of parameterable elements.
overriding function Is_Consistent_With
(Self : not null access constant UML_Device_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Device_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function Owned_Port
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Ports.Collections.Set_Of_UML_Port;
-- Operation EncapsulatedClassifier::ownedPort.
--
-- Missing derivation for EncapsulatedClassifier::/ownedPort : Port
overriding function Part
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Properties.Collections.Set_Of_UML_Property;
-- Operation StructuredClassifier::part.
--
-- Missing derivation for StructuredClassifier::/part : Property
overriding function Deployed_Element
(Self : not null access constant UML_Device_Proxy)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element;
-- Operation DeploymentTarget::deployedElement.
--
-- Missing derivation for DeploymentTarget::/deployedElement :
-- PackageableElement
overriding procedure Enter_Element
(Self : not null access constant UML_Device_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Device_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Device_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Devices;
|
reznikmm/matreshka | Ada | 33,742 | 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 XML.DOM.Documents;
with ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal;
with ODF.DOM.Attributes.Draw.End_Line_Spacing_Vertical;
with ODF.DOM.Attributes.Draw.Fill_Color;
with ODF.DOM.Attributes.Draw.Shadow_Offset_X;
with ODF.DOM.Attributes.Draw.Shadow_Offset_Y;
with ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal;
with ODF.DOM.Attributes.Draw.Start_Line_Spacing_Vertical;
with ODF.DOM.Attributes.FO.Background_Color;
with ODF.DOM.Attributes.FO.Border;
with ODF.DOM.Attributes.FO.Border_Bottom;
with ODF.DOM.Attributes.FO.Border_Left;
with ODF.DOM.Attributes.FO.Border_Right;
with ODF.DOM.Attributes.FO.Border_Top;
with ODF.DOM.Attributes.FO.Country;
with ODF.DOM.Attributes.FO.Font_Size;
with ODF.DOM.Attributes.FO.Font_Style;
with ODF.DOM.Attributes.FO.Font_Weight;
with ODF.DOM.Attributes.FO.Hyphenate;
with ODF.DOM.Attributes.FO.Hyphenation_Ladder_Count;
with ODF.DOM.Attributes.FO.Hyphenation_Push_Char_Count;
with ODF.DOM.Attributes.FO.Hyphenation_Remain_Char_Count;
with ODF.DOM.Attributes.FO.Keep_Together;
with ODF.DOM.Attributes.FO.Keep_With_Next;
with ODF.DOM.Attributes.FO.Language;
with ODF.DOM.Attributes.FO.Margin;
with ODF.DOM.Attributes.FO.Margin_Bottom;
with ODF.DOM.Attributes.FO.Margin_Left;
with ODF.DOM.Attributes.FO.Margin_Right;
with ODF.DOM.Attributes.FO.Margin_Top;
with ODF.DOM.Attributes.FO.Padding;
with ODF.DOM.Attributes.FO.Page_Height;
with ODF.DOM.Attributes.FO.Page_Width;
with ODF.DOM.Attributes.FO.Text_Align;
with ODF.DOM.Attributes.FO.Text_Indent;
with ODF.DOM.Attributes.FO.Wrap_Option;
with ODF.DOM.Attributes.Office.Value_Type;
with ODF.DOM.Attributes.Office.Version;
with ODF.DOM.Attributes.Style.Adjustment;
with ODF.DOM.Attributes.Style.Class;
with ODF.DOM.Attributes.Style.Color;
with ODF.DOM.Attributes.Style.Column_Width;
with ODF.DOM.Attributes.Style.Contextual_Spacing;
with ODF.DOM.Attributes.Style.Country_Asian;
with ODF.DOM.Attributes.Style.Country_Complex;
with ODF.DOM.Attributes.Style.Default_Outline_Level;
with ODF.DOM.Attributes.Style.Display_Name;
with ODF.DOM.Attributes.Style.Distance_After_Sep;
with ODF.DOM.Attributes.Style.Distance_Before_Sep;
with ODF.DOM.Attributes.Style.Family;
with ODF.DOM.Attributes.Style.Flow_With_Text;
with ODF.DOM.Attributes.Style.Font_Family_Generic;
with ODF.DOM.Attributes.Style.Font_Independent_Line_Spacing;
with ODF.DOM.Attributes.Style.Font_Name;
with ODF.DOM.Attributes.Style.Font_Name_Asian;
with ODF.DOM.Attributes.Style.Font_Name_Complex;
with ODF.DOM.Attributes.Style.Font_Pitch;
with ODF.DOM.Attributes.Style.Font_Size_Asian;
with ODF.DOM.Attributes.Style.Font_Size_Complex;
with ODF.DOM.Attributes.Style.Font_Style_Asian;
with ODF.DOM.Attributes.Style.Font_Style_Complex;
with ODF.DOM.Attributes.Style.Font_Weight_Asian;
with ODF.DOM.Attributes.Style.Font_Weight_Complex;
with ODF.DOM.Attributes.Style.Footnote_Max_Height;
with ODF.DOM.Attributes.Style.Justify_Single_Word;
with ODF.DOM.Attributes.Style.Language_Asian;
with ODF.DOM.Attributes.Style.Language_Complex;
with ODF.DOM.Attributes.Style.Letter_Kerning;
with ODF.DOM.Attributes.Style.Line_Break;
with ODF.DOM.Attributes.Style.Line_Style;
with ODF.DOM.Attributes.Style.Name;
with ODF.DOM.Attributes.Style.Next_Style_Name;
with ODF.DOM.Attributes.Style.Num_Format;
with ODF.DOM.Attributes.Style.Page_Layout_Name;
with ODF.DOM.Attributes.Style.Parent_Style_Name;
with ODF.DOM.Attributes.Style.Print_Orientation;
with ODF.DOM.Attributes.Style.Punctuation_Wrap;
with ODF.DOM.Attributes.Style.Rel_Column_Width;
with ODF.DOM.Attributes.Style.Rel_Width;
with ODF.DOM.Attributes.Style.Tab_Stop_Distance;
with ODF.DOM.Attributes.Style.Text_Autospace;
with ODF.DOM.Attributes.Style.Text_Underline_Color;
with ODF.DOM.Attributes.Style.Text_Underline_Style;
with ODF.DOM.Attributes.Style.Text_Underline_Width;
with ODF.DOM.Attributes.Style.Use_Window_Font_Color;
with ODF.DOM.Attributes.Style.Vertical_Align;
with ODF.DOM.Attributes.Style.Width;
with ODF.DOM.Attributes.Style.Writing_Mode;
with ODF.DOM.Attributes.SVG.Font_Family;
with ODF.DOM.Attributes.SVG.Stroke_Color;
with ODF.DOM.Attributes.Table.Align;
with ODF.DOM.Attributes.Table.Border_Model;
with ODF.DOM.Attributes.Table.Name;
with ODF.DOM.Attributes.Table.Number_Columns_Spanned;
with ODF.DOM.Attributes.Table.Style_Name;
with ODF.DOM.Attributes.Text.Display_Outline_Level;
with ODF.DOM.Attributes.Text.Footnotes_Position;
with ODF.DOM.Attributes.Text.Increment;
with ODF.DOM.Attributes.Text.Label_Followed_By;
with ODF.DOM.Attributes.Text.Level;
with ODF.DOM.Attributes.Text.Line_Number;
with ODF.DOM.Attributes.Text.List_Level_Position_And_Space_Mode;
with ODF.DOM.Attributes.Text.List_Tab_Stop_Position;
with ODF.DOM.Attributes.Text.Min_Label_Distance;
with ODF.DOM.Attributes.Text.Name;
with ODF.DOM.Attributes.Text.Note_Class;
with ODF.DOM.Attributes.Text.Number_Lines;
with ODF.DOM.Attributes.Text.Number_Position;
with ODF.DOM.Attributes.Text.Offset;
with ODF.DOM.Attributes.Text.Outline_Level;
with ODF.DOM.Attributes.Text.Start_Numbering_At;
with ODF.DOM.Attributes.Text.Start_Value;
with ODF.DOM.Attributes.Text.Style_Name;
with ODF.DOM.Elements.Office.Automatic_Styles;
with ODF.DOM.Elements.Office.Bodies;
with ODF.DOM.Elements.Office.Document_Content;
with ODF.DOM.Elements.Office.Document_Styles;
with ODF.DOM.Elements.Office.Font_Face_Decls;
with ODF.DOM.Elements.Office.Master_Styles;
with ODF.DOM.Elements.Office.Scripts;
with ODF.DOM.Elements.Office.Styles;
with ODF.DOM.Elements.Office.Text;
with ODF.DOM.Elements.Style.Background_Image;
with ODF.DOM.Elements.Style.Default_Style;
with ODF.DOM.Elements.Style.Font_Face;
with ODF.DOM.Elements.Style.Footer_Style;
with ODF.DOM.Elements.Style.Footnote_Sep;
with ODF.DOM.Elements.Style.Graphic_Properties;
with ODF.DOM.Elements.Style.Header_Style;
with ODF.DOM.Elements.Style.List_Level_Label_Alignment;
with ODF.DOM.Elements.Style.List_Level_Properties;
with ODF.DOM.Elements.Style.Master_Page;
with ODF.DOM.Elements.Style.Page_Layout;
with ODF.DOM.Elements.Style.Page_Layout_Properties;
with ODF.DOM.Elements.Style.Paragraph_Properties;
with ODF.DOM.Elements.Style.Style;
with ODF.DOM.Elements.Style.Tab_Stops;
with ODF.DOM.Elements.Style.Table_Cell_Properties;
with ODF.DOM.Elements.Style.Table_Column_Properties;
with ODF.DOM.Elements.Style.Table_Properties;
with ODF.DOM.Elements.Style.Table_Row_Properties;
with ODF.DOM.Elements.Style.Text_Properties;
with ODF.DOM.Elements.Table.Covered_Table_Cell;
with ODF.DOM.Elements.Table.Table;
with ODF.DOM.Elements.Table.Table_Cell;
with ODF.DOM.Elements.Table.Table_Column;
with ODF.DOM.Elements.Table.Table_Row;
with ODF.DOM.Elements.Text.H;
with ODF.DOM.Elements.Text.Linenumbering_Configuration;
with ODF.DOM.Elements.Text.Notes_Configuration;
with ODF.DOM.Elements.Text.Outline_Level_Style;
with ODF.DOM.Elements.Text.Outline_Style;
with ODF.DOM.Elements.Text.P;
with ODF.DOM.Elements.Text.Sequence_Decl;
with ODF.DOM.Elements.Text.Sequence_Decls;
with ODF.DOM.Elements.Text.Span;
package ODF.DOM.Documents is
type ODF_Document is new XML.DOM.Documents.DOM_Document with private;
function Create_Draw_End_Line_Spacing_Horizontal
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.End_Line_Spacing_Horizontal.ODF_Draw_End_Line_Spacing_Horizontal;
function Create_Draw_End_Line_Spacing_Vertical
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.End_Line_Spacing_Vertical.ODF_Draw_End_Line_Spacing_Vertical;
function Create_Draw_Fill_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.Fill_Color.ODF_Draw_Fill_Color;
function Create_Draw_Shadow_Offset_X
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.Shadow_Offset_X.ODF_Draw_Shadow_Offset_X;
function Create_Draw_Shadow_Offset_Y
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.Shadow_Offset_Y.ODF_Draw_Shadow_Offset_Y;
function Create_Draw_Start_Line_Spacing_Horizontal
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.Start_Line_Spacing_Horizontal.ODF_Draw_Start_Line_Spacing_Horizontal;
function Create_Draw_Start_Line_Spacing_Vertical
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Draw.Start_Line_Spacing_Vertical.ODF_Draw_Start_Line_Spacing_Vertical;
function Create_FO_Background_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Background_Color.ODF_FO_Background_Color;
function Create_FO_Border
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Border.ODF_FO_Border;
function Create_FO_Border_Bottom
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Border_Bottom.ODF_FO_Border_Bottom;
function Create_FO_Border_Left
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Border_Left.ODF_FO_Border_Left;
function Create_FO_Border_Right
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Border_Right.ODF_FO_Border_Right;
function Create_FO_Border_Top
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Border_Top.ODF_FO_Border_Top;
function Create_FO_Country
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Country.ODF_FO_Country;
function Create_FO_Font_Size
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Font_Size.ODF_FO_Font_Size;
function Create_FO_Font_Style
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Font_Style.ODF_FO_Font_Style;
function Create_FO_Font_Weight
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Font_Weight.ODF_FO_Font_Weight;
function Create_FO_Hyphenate
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Hyphenate.ODF_FO_Hyphenate;
function Create_FO_Hyphenation_Ladder_Count
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Hyphenation_Ladder_Count.ODF_FO_Hyphenation_Ladder_Count;
function Create_FO_Hyphenation_Push_Char_Count
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Hyphenation_Push_Char_Count.ODF_FO_Hyphenation_Push_Char_Count;
function Create_FO_Hyphenation_Remain_Char_Count
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Hyphenation_Remain_Char_Count.ODF_FO_Hyphenation_Remain_Char_Count;
function Create_FO_Keep_Together
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Keep_Together.ODF_FO_Keep_Together;
function Create_FO_Keep_With_Next
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Keep_With_Next.ODF_FO_Keep_With_Next;
function Create_FO_Language
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Language.ODF_FO_Language;
function Create_FO_Margin
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Margin.ODF_FO_Margin;
function Create_FO_Margin_Bottom
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Margin_Bottom.ODF_FO_Margin_Bottom;
function Create_FO_Margin_Left
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Margin_Left.ODF_FO_Margin_Left;
function Create_FO_Margin_Right
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Margin_Right.ODF_FO_Margin_Right;
function Create_FO_Margin_Top
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Margin_Top.ODF_FO_Margin_Top;
function Create_FO_Padding
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Padding.ODF_FO_Padding;
function Create_FO_Page_Height
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Page_Height.ODF_FO_Page_Height;
function Create_FO_Page_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Page_Width.ODF_FO_Page_Width;
function Create_FO_Text_Align
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Text_Align.ODF_FO_Text_Align;
function Create_FO_Text_Indent
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Text_Indent.ODF_FO_Text_Indent;
function Create_FO_Wrap_Option
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.FO.Wrap_Option.ODF_FO_Wrap_Option;
function Create_Office_Automatic_Styles
(Self : ODF_Document'Class)
return
ODF.DOM.Elements.Office.Automatic_Styles.ODF_Office_Automatic_Styles;
function Create_Office_Body
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Office.Bodies.ODF_Office_Body;
function Create_Office_Document_Content
(Self : ODF_Document'Class)
return
ODF.DOM.Elements.Office.Document_Content.ODF_Office_Document_Content;
function Create_Office_Document_Styles
(Self : ODF_Document'Class)
return
ODF.DOM.Elements.Office.Document_Styles.ODF_Office_Document_Styles;
function Create_Office_Font_Face_Decls
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Office.Font_Face_Decls.ODF_Office_Font_Face_Decls;
function Create_Office_Master_Styles
(Self : ODF_Document'Class)
return
ODF.DOM.Elements.Office.Master_Styles.ODF_Office_Master_Styles;
function Create_Office_Scripts
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Office.Scripts.ODF_Office_Scripts;
function Create_Office_Styles
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Office.Styles.ODF_Office_Styles;
function Create_Office_Text
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Office.Text.ODF_Office_Text;
function Create_Office_Value_Type
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Office.Value_Type.ODF_Office_Value_Type;
function Create_Office_Version
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Office.Version.ODF_Office_Version;
function Create_Style_Background_Image
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Background_Image.ODF_Style_Background_Image;
function Create_Style_Adjustment
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Adjustment.ODF_Style_Adjustment;
function Create_Style_Class
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Class.ODF_Style_Class;
function Create_Style_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Color.ODF_Style_Color;
function Create_Style_Column_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Column_Width.ODF_Style_Column_Width;
function Create_Style_Contextual_Spacing
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Contextual_Spacing.ODF_Style_Contextual_Spacing;
function Create_Style_Country_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Country_Asian.ODF_Style_Country_Asian;
function Create_Style_Country_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Country_Complex.ODF_Style_Country_Complex;
function Create_Style_Default_Outline_Level
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Default_Outline_Level.ODF_Style_Default_Outline_Level;
function Create_Style_Default_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Default_Style.ODF_Style_Default_Style;
function Create_Style_Display_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Display_Name.ODF_Style_Display_Name;
function Create_Style_Distance_After_Sep
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Distance_After_Sep.ODF_Style_Distance_After_Sep;
function Create_Style_Distance_Before_Sep
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Distance_Before_Sep.ODF_Style_Distance_Before_Sep;
function Create_Style_Family
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Family.ODF_Style_Family;
function Create_Style_Flow_With_Text
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Flow_With_Text.ODF_Style_Flow_With_Text;
function Create_Style_Font_Face
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Font_Face.ODF_Style_Font_Face;
function Create_Style_Font_Family_Generic
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Family_Generic.ODF_Style_Font_Family_Generic;
function Create_Style_Font_Independent_Line_Spacing
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Independent_Line_Spacing.ODF_Style_Font_Independent_Line_Spacing;
function Create_Style_Font_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Name.ODF_Style_Font_Name;
function Create_Style_Font_Name_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Name_Asian.ODF_Style_Font_Name_Asian;
function Create_Style_Font_Name_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Name_Complex.ODF_Style_Font_Name_Complex;
function Create_Style_Font_Pitch
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Pitch.ODF_Style_Font_Pitch;
function Create_Style_Font_Size_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Size_Asian.ODF_Style_Font_Size_Asian;
function Create_Style_Font_Size_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Size_Complex.ODF_Style_Font_Size_Complex;
function Create_Style_Font_Style_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Style_Asian.ODF_Style_Font_Style_Asian;
function Create_Style_Font_Style_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Style_Complex.ODF_Style_Font_Style_Complex;
function Create_Style_Font_Weight_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Weight_Asian.ODF_Style_Font_Weight_Asian;
function Create_Style_Font_Weight_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Font_Weight_Complex.ODF_Style_Font_Weight_Complex;
function Create_Style_Footer_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Footer_Style.ODF_Style_Footer_Style;
function Create_Style_Footnote_Max_Height
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Footnote_Max_Height.ODF_Style_Footnote_Max_Height;
function Create_Style_Footnote_Sep
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Footnote_Sep.ODF_Style_Footnote_Sep;
function Create_Style_Graphic_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Graphic_Properties.ODF_Style_Graphic_Properties;
function Create_Style_Header_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Header_Style.ODF_Style_Header_Style;
function Create_Style_Justify_Single_Word
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Justify_Single_Word.ODF_Style_Justify_Single_Word;
function Create_Style_Language_Asian
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Language_Asian.ODF_Style_Language_Asian;
function Create_Style_Language_Complex
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Language_Complex.ODF_Style_Language_Complex;
function Create_Style_Letter_Kerning
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Letter_Kerning.ODF_Style_Letter_Kerning;
function Create_Style_Line_Break
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Line_Break.ODF_Style_Line_Break;
function Create_Style_Line_Style
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Line_Style.ODF_Style_Line_Style;
function Create_Style_List_Level_Label_Alignment
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.List_Level_Label_Alignment.ODF_Style_List_Level_Label_Alignment;
function Create_Style_List_Level_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.List_Level_Properties.ODF_Style_List_Level_Properties;
function Create_Style_Master_Page
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Master_Page.ODF_Style_Master_Page;
function Create_Style_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Name.ODF_Style_Name;
function Create_Style_Next_Style_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Next_Style_Name.ODF_Style_Next_Style_Name;
function Create_Style_Num_Format
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Num_Format.ODF_Style_Num_Format;
function Create_Style_Page_Layout
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Page_Layout.ODF_Style_Page_Layout;
function Create_Style_Page_Layout_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Page_Layout_Properties.ODF_Style_Page_Layout_Properties;
function Create_Style_Paragraph_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Paragraph_Properties.ODF_Style_Paragraph_Properties;
function Create_Style_Page_Layout_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Page_Layout_Name.ODF_Style_Page_Layout_Name;
function Create_Style_Parent_Style_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Parent_Style_Name.ODF_Style_Parent_Style_Name;
function Create_Style_Print_Orientation
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Print_Orientation.ODF_Style_Print_Orientation;
function Create_Style_Punctuation_Wrap
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Punctuation_Wrap.ODF_Style_Punctuation_Wrap;
function Create_Style_Rel_Column_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Rel_Column_Width.ODF_Style_Rel_Column_Width;
function Create_Style_Rel_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Rel_Width.ODF_Style_Rel_Width;
function Create_Style_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Style.ODF_Style_Style;
function Create_Style_Tab_Stop_Distance
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Tab_Stop_Distance.ODF_Style_Tab_Stop_Distance;
function Create_Style_Tab_Stops
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Tab_Stops.ODF_Style_Tab_Stops;
function Create_Style_Table_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Table_Properties.ODF_Style_Table_Properties;
function Create_Style_Table_Cell_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Table_Cell_Properties.ODF_Style_Table_Cell_Properties;
function Create_Style_Table_Column_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Table_Column_Properties.ODF_Style_Table_Column_Properties;
function Create_Style_Table_Row_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Table_Row_Properties.ODF_Style_Table_Row_Properties;
function Create_Style_Text_Autospace
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Text_Autospace.ODF_Style_Text_Autospace;
function Create_Style_Text_Underline_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Text_Underline_Color.ODF_Style_Text_Underline_Color;
function Create_Style_Text_Underline_Style
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Text_Underline_Style.ODF_Style_Text_Underline_Style;
function Create_Style_Text_Underline_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Text_Underline_Width.ODF_Style_Text_Underline_Width;
function Create_Style_Text_Properties
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Style.Text_Properties.ODF_Style_Text_Properties;
function Create_Style_Use_Window_Font_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Use_Window_Font_Color.ODF_Style_Use_Window_Font_Color;
function Create_Style_Vertical_Align
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Vertical_Align.ODF_Style_Vertical_Align;
function Create_Style_Width
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Width.ODF_Style_Width;
function Create_Style_Writing_Mode
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Style.Writing_Mode.ODF_Style_Writing_Mode;
function Create_SVG_Font_Family
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.SVG.Font_Family.ODF_SVG_Font_Family;
function Create_SVG_Stroke_Color
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.SVG.Stroke_Color.ODF_SVG_Stroke_Color;
function Create_Table_Align
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Table.Align.ODF_Table_Align;
function Create_Table_Border_Model
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Table.Border_Model.ODF_Table_Border_Model;
function Create_Table_Covered_Table_Cell
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Table.Covered_Table_Cell.ODF_Table_Covered_Table_Cell;
function Create_Table_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Table.Name.ODF_Table_Name;
function Create_Table_Number_Columns_Spanned
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Table.Number_Columns_Spanned.ODF_Table_Number_Columns_Spanned;
function Create_Table_Style_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Table.Style_Name.ODF_Table_Style_Name;
function Create_Table_Table
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Table.Table.ODF_Table_Table;
function Create_Table_Table_Cell
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Table.Table_Cell.ODF_Table_Table_Cell;
function Create_Table_Table_Column
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Table.Table_Column.ODF_Table_Table_Column;
function Create_Table_Table_Row
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Table.Table_Row.ODF_Table_Table_Row;
function Create_Text_Display_Outline_Level
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Display_Outline_Level.ODF_Text_Display_Outline_Level;
function Create_Text_Footnotes_Position
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Footnotes_Position.ODF_Text_Footnotes_Position;
function Create_Text_H
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.H.ODF_Text_H;
function Create_Text_Increment
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Increment.ODF_Text_Increment;
function Create_Text_Label_Followed_By
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Label_Followed_By.ODF_Text_Label_Followed_By;
function Create_Text_Level
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Level.ODF_Text_Level;
function Create_Text_Line_Number
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Line_Number.ODF_Text_Line_Number;
function Create_Text_Linenumbering_Configuration
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Linenumbering_Configuration.ODF_Text_Linenumbering_Configuration;
function Create_Text_List_Level_Position_And_Space_Mode
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.List_Level_Position_And_Space_Mode.ODF_Text_List_Level_Position_And_Space_Mode;
function Create_Text_List_Tab_Stop_Position
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.List_Tab_Stop_Position.ODF_Text_List_Tab_Stop_Position;
function Create_Text_Min_Label_Distance
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Min_Label_Distance.ODF_Text_Min_Label_Distance;
function Create_Text_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Name.ODF_Text_Name;
function Create_Text_Notes_Configuration
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Notes_Configuration.ODF_Text_Notes_Configuration;
function Create_Text_Note_Class
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Note_Class.ODF_Text_Note_Class;
function Create_Text_Number_Lines
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Number_Lines.ODF_Text_Number_Lines;
function Create_Text_Number_Position
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Number_Position.ODF_Text_Number_Position;
function Create_Text_Offset
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Offset.ODF_Text_Offset;
function Create_Text_Outline_Level
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Outline_Level.ODF_Text_Outline_Level;
function Create_Text_Outline_Level_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Outline_Level_Style.ODF_Text_Outline_Level_Style;
function Create_Text_Outline_Style
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Outline_Style.ODF_Text_Outline_Style;
function Create_Text_P
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.P.ODF_Text_P;
function Create_Text_Sequence_Decl
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Sequence_Decl.ODF_Text_Sequence_Decl;
function Create_Text_Sequence_Decls
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Sequence_Decls.ODF_Text_Sequence_Decls;
function Create_Text_Span
(Self : ODF_Document'Class)
return ODF.DOM.Elements.Text.Span.ODF_Text_Span;
function Create_Text_Start_Numbering_At
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Start_Numbering_At.ODF_Text_Start_Numbering_At;
function Create_Text_Start_Value
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Start_Value.ODF_Text_Start_Value;
function Create_Text_Style_Name
(Self : ODF_Document'Class)
return ODF.DOM.Attributes.Text.Style_Name.ODF_Text_Style_Name;
private
type ODF_Document is new XML.DOM.Documents.DOM_Document with null record;
end ODF.DOM.Documents;
|
onox/orka | Ada | 1,683 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 onox <[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 Orka.SIMD.SSE2.Longs.Shift is
type All_Bits_Count is new Integer range 0 .. 128;
function Shift_All_Bits_Left_Zeros
(Elements : m128l; Bits : All_Bits_Count) return m128l
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_pslldqi128";
-- Shift each bit to the left by the given amount of bits, shifting in zeros
function Shift_All_Bits_Right_Zeros
(Elements : m128l; Bits : All_Bits_Count) return m128l
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_psrldqi128";
-- Shift each bit to the right by the given amount of bits, shifting in zeros
----------------------------------------------------------------------------
function Shift_Elements_Left_Zeros (Elements : m128l) return m128l is
(Shift_All_Bits_Left_Zeros (Elements, Integer_64'Size));
function Shift_Elements_Right_Zeros (Elements : m128l) return m128l is
(Shift_All_Bits_Right_Zeros (Elements, Integer_64'Size));
end Orka.SIMD.SSE2.Longs.Shift;
|
zhmu/ananas | Ada | 10,593 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I N T E R F A C E S . P A C K E D _ D E C I M A L --
-- --
-- B o d y --
-- (Version for IBM Mainframe Packed Decimal Format) --
-- --
-- Copyright (C) 1992-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 System; use System;
with Ada.Unchecked_Conversion;
package body Interfaces.Packed_Decimal is
type Packed is array (Byte_Length) of Unsigned_8;
-- The type used internally to represent packed decimal
type Packed_Ptr is access Packed;
function To_Packed_Ptr is
new Ada.Unchecked_Conversion (Address, Packed_Ptr);
-- The following array is used to convert a value in the range 0-99 to
-- a packed decimal format with two hexadecimal nibbles. It is worth
-- using table look up in this direction because divides are expensive.
Packed_Byte : constant array (00 .. 99) of Unsigned_8 :=
[16#00#, 16#01#, 16#02#, 16#03#, 16#04#,
16#05#, 16#06#, 16#07#, 16#08#, 16#09#,
16#10#, 16#11#, 16#12#, 16#13#, 16#14#,
16#15#, 16#16#, 16#17#, 16#18#, 16#19#,
16#20#, 16#21#, 16#22#, 16#23#, 16#24#,
16#25#, 16#26#, 16#27#, 16#28#, 16#29#,
16#30#, 16#31#, 16#32#, 16#33#, 16#34#,
16#35#, 16#36#, 16#37#, 16#38#, 16#39#,
16#40#, 16#41#, 16#42#, 16#43#, 16#44#,
16#45#, 16#46#, 16#47#, 16#48#, 16#49#,
16#50#, 16#51#, 16#52#, 16#53#, 16#54#,
16#55#, 16#56#, 16#57#, 16#58#, 16#59#,
16#60#, 16#61#, 16#62#, 16#63#, 16#64#,
16#65#, 16#66#, 16#67#, 16#68#, 16#69#,
16#70#, 16#71#, 16#72#, 16#73#, 16#74#,
16#75#, 16#76#, 16#77#, 16#78#, 16#79#,
16#80#, 16#81#, 16#82#, 16#83#, 16#84#,
16#85#, 16#86#, 16#87#, 16#88#, 16#89#,
16#90#, 16#91#, 16#92#, 16#93#, 16#94#,
16#95#, 16#96#, 16#97#, 16#98#, 16#99#];
---------------------
-- Int32_To_Packed --
---------------------
procedure Int32_To_Packed (V : Integer_32; P : System.Address; D : D32) is
PP : constant Packed_Ptr := To_Packed_Ptr (P);
Empty_Nibble : constant Boolean := ((D rem 2) = 0);
B : constant Byte_Length := (D / 2) + 1;
VV : Integer_32 := V;
begin
-- Deal with sign byte first
if VV >= 0 then
PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#C#;
VV := VV / 10;
else
VV := -VV;
PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#D#;
end if;
for J in reverse B - 1 .. 2 loop
if VV = 0 then
for K in 1 .. J loop
PP (K) := 16#00#;
end loop;
return;
else
PP (J) := Packed_Byte (Integer (VV rem 100));
VV := VV / 100;
end if;
end loop;
-- Deal with leading byte
if Empty_Nibble then
if VV > 9 then
raise Constraint_Error;
else
PP (1) := Unsigned_8 (VV);
end if;
else
if VV > 99 then
raise Constraint_Error;
else
PP (1) := Packed_Byte (Integer (VV));
end if;
end if;
end Int32_To_Packed;
---------------------
-- Int64_To_Packed --
---------------------
procedure Int64_To_Packed (V : Integer_64; P : System.Address; D : D64) is
PP : constant Packed_Ptr := To_Packed_Ptr (P);
Empty_Nibble : constant Boolean := ((D rem 2) = 0);
B : constant Byte_Length := (D / 2) + 1;
VV : Integer_64 := V;
begin
-- Deal with sign byte first
if VV >= 0 then
PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#C#;
VV := VV / 10;
else
VV := -VV;
PP (B) := Unsigned_8 (VV rem 10) * 16 + 16#D#;
end if;
for J in reverse B - 1 .. 2 loop
if VV = 0 then
for K in 1 .. J loop
PP (K) := 16#00#;
end loop;
return;
else
PP (J) := Packed_Byte (Integer (VV rem 100));
VV := VV / 100;
end if;
end loop;
-- Deal with leading byte
if Empty_Nibble then
if VV > 9 then
raise Constraint_Error;
else
PP (1) := Unsigned_8 (VV);
end if;
else
if VV > 99 then
raise Constraint_Error;
else
PP (1) := Packed_Byte (Integer (VV));
end if;
end if;
end Int64_To_Packed;
---------------------
-- Packed_To_Int32 --
---------------------
function Packed_To_Int32 (P : System.Address; D : D32) return Integer_32 is
PP : constant Packed_Ptr := To_Packed_Ptr (P);
Empty_Nibble : constant Boolean := ((D mod 2) = 0);
B : constant Byte_Length := (D / 2) + 1;
V : Integer_32;
Dig : Unsigned_8;
Sign : Unsigned_8;
J : Positive;
begin
-- Cases where there is an unused (zero) nibble in the first byte.
-- Deal with the single digit nibble at the right of this byte
if Empty_Nibble then
V := Integer_32 (PP (1));
J := 2;
if V > 9 then
raise Constraint_Error;
end if;
-- Cases where all nibbles are used
else
V := 0;
J := 1;
end if;
-- Loop to process bytes containing two digit nibbles
while J < B loop
Dig := Shift_Right (PP (J), 4);
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_32 (Dig);
end if;
Dig := PP (J) and 16#0F#;
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_32 (Dig);
end if;
J := J + 1;
end loop;
-- Deal with digit nibble in sign byte
Dig := Shift_Right (PP (J), 4);
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_32 (Dig);
end if;
Sign := PP (J) and 16#0F#;
-- Process sign nibble (deal with most common cases first)
if Sign = 16#C# then
return V;
elsif Sign = 16#D# then
return -V;
elsif Sign = 16#B# then
return -V;
elsif Sign >= 16#A# then
return V;
else
raise Constraint_Error;
end if;
end Packed_To_Int32;
---------------------
-- Packed_To_Int64 --
---------------------
function Packed_To_Int64 (P : System.Address; D : D64) return Integer_64 is
PP : constant Packed_Ptr := To_Packed_Ptr (P);
Empty_Nibble : constant Boolean := ((D mod 2) = 0);
B : constant Byte_Length := (D / 2) + 1;
V : Integer_64;
Dig : Unsigned_8;
Sign : Unsigned_8;
J : Positive;
begin
-- Cases where there is an unused (zero) nibble in the first byte.
-- Deal with the single digit nibble at the right of this byte
if Empty_Nibble then
V := Integer_64 (PP (1));
J := 2;
if V > 9 then
raise Constraint_Error;
end if;
-- Cases where all nibbles are used
else
J := 1;
V := 0;
end if;
-- Loop to process bytes containing two digit nibbles
while J < B loop
Dig := Shift_Right (PP (J), 4);
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_64 (Dig);
end if;
Dig := PP (J) and 16#0F#;
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_64 (Dig);
end if;
J := J + 1;
end loop;
-- Deal with digit nibble in sign byte
Dig := Shift_Right (PP (J), 4);
if Dig > 9 then
raise Constraint_Error;
else
V := V * 10 + Integer_64 (Dig);
end if;
Sign := PP (J) and 16#0F#;
-- Process sign nibble (deal with most common cases first)
if Sign = 16#C# then
return V;
elsif Sign = 16#D# then
return -V;
elsif Sign = 16#B# then
return -V;
elsif Sign >= 16#A# then
return V;
else
raise Constraint_Error;
end if;
end Packed_To_Int64;
end Interfaces.Packed_Decimal;
|
zhmu/ananas | Ada | 77 | ads | generic
package Generic2 is
private
type Int is new Integer;
end Generic2;
|
fengjixuchui/ewok-kernel | Ada | 10,108 | 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 ada.unchecked_conversion;
with m4.layout;
with m4.scb;
package m4.mpu
with spark_mode => on
is
------------
-- Config --
------------
subtype t_region_number is unsigned_8 range 0 .. 7;
subtype t_region_size is bits_5 range 4 .. 31;
type t_region_config is record
region_number : t_region_number;
addr : system_address;
size : t_region_size;
access_perm : bits_3;
xn : bool;
b : bool;
s : bool;
subregion_mask : unsigned_8; -- 0: sub-region enabled, 1: disabled
end record;
REGION_SIZE_32B : constant t_region_size := 4;
REGION_SIZE_64B : constant t_region_size := 5;
REGION_SIZE_128B : constant t_region_size := 6;
REGION_SIZE_256B : constant t_region_size := 7;
REGION_SIZE_512B : constant t_region_size := 8;
REGION_SIZE_1KB : constant t_region_size := 9;
REGION_SIZE_2KB : constant t_region_size := 10;
REGION_SIZE_4KB : constant t_region_size := 11;
REGION_SIZE_8KB : constant t_region_size := 12;
REGION_SIZE_16KB : constant t_region_size := 13;
REGION_SIZE_32KB : constant t_region_size := 14;
REGION_SIZE_64KB : constant t_region_size := 15;
REGION_SIZE_128KB : constant t_region_size := 16;
REGION_SIZE_256KB : constant t_region_size := 17;
REGION_SIZE_512KB : constant t_region_size := 18;
REGION_SIZE_1MB : constant t_region_size := 19;
REGION_SIZE_2MB : constant t_region_size := 20;
REGION_SIZE_4MB : constant t_region_size := 21;
REGION_SIZE_8MB : constant t_region_size := 22;
REGION_SIZE_16MB : constant t_region_size := 23;
REGION_SIZE_32MB : constant t_region_size := 24;
REGION_SIZE_64MB : constant t_region_size := 25;
REGION_SIZE_128MB : constant t_region_size := 26;
REGION_SIZE_256MB : constant t_region_size := 27;
REGION_SIZE_512MB : constant t_region_size := 28;
REGION_SIZE_1GB : constant t_region_size := 29;
REGION_SIZE_2GB : constant t_region_size := 30;
REGION_SIZE_4GB : constant t_region_size := 31;
-- Access Permissions
-- Note: Describes privileged and user access.
-- For example, REGION_PERM_PRIV_RW_USER_NO means
-- - privileged : read/write access
-- - user : no access
REGION_PERM_PRIV_NO_USER_NO : constant bits_3 := 2#000#;
REGION_PERM_PRIV_RW_USER_NO : constant bits_3 := 2#001#;
REGION_PERM_PRIV_RW_USER_RO : constant bits_3 := 2#010#;
REGION_PERM_PRIV_RW_USER_RW : constant bits_3 := 2#011#;
REGION_PERM_UNUSED : constant bits_3 := 2#100#;
REGION_PERM_PRIV_RO_USER_NO : constant bits_3 := 2#101#;
REGION_PERM_PRIV_RO_USER_RO : constant bits_3 := 2#110#;
REGION_PERM_PRIV_RO_USER_RO2 : constant bits_3 := 2#111#;
---------------
-- Functions --
---------------
procedure is_mpu_available
(success : out boolean)
with
Global => (In_Out => MPU);
procedure enable
with
global => (in_out => (MPU));
procedure disable
with
global => (in_out => (MPU));
procedure disable_region
(region_number : in t_region_number)
with
global => (in_out => (MPU));
-- Only used by SPARK prover
function region_not_rwx(region : t_region_config) return boolean
is (region.xn = true or
region.access_perm = REGION_PERM_PRIV_RO_USER_RO or
region.access_perm = REGION_PERM_PRIV_NO_USER_NO)
with ghost;
procedure init
with
global => (in_out => (MPU, m4.scb.SCB));
-- That function is only used by SPARK prover
function get_region_size_mask (size : t_region_size) return unsigned_32
is (2**(natural (size) + 1) - 1)
with ghost;
pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE);
pragma warnings (off, "explicit membership test may be optimized");
pragma warnings (off, "condition can only be False if invalid values present");
procedure configure_region
(region : in t_region_config)
with
global => (in_out => (MPU)),
pre =>
(region.region_number in 0 .. 7
and
(region.addr and 2#11111#) = 0
and
region.size >= 4
and
(region.addr and get_region_size_mask(region.size)) = 0)
and region_not_rwx (region);
procedure update_subregion_mask
(region : in t_region_config)
with
global => (in_out => (MPU)),
pre =>
(region.region_number < 8
and
(region.addr and 2#11111#) = 0
and
region.size >= 4
and
(region.addr and get_region_size_mask(region.size)) = 0)
and region_not_rwx (region);
pragma warnings (on);
-----------------------
-- MPU Type Register --
-----------------------
type t_MPU_TYPE is record
SEPARAT : bool := true; -- Support for separate instruction and date memory maps
DREGION : unsigned_8 := 8; -- Number of supported MPU data regions
IREGION : unsigned_8 := 0; -- Number of supported MPU instruction regions
end record
with size => 32;
for t_MPU_TYPE use
record
SEPARAT at 0 range 0 .. 0;
DREGION at 0 range 8 .. 15;
IREGION at 0 range 16 .. 23;
end record;
function to_unsigned_32 is new ada.unchecked_conversion
(t_MPU_TYPE, unsigned_32);
--------------------------
-- MPU Control Register --
--------------------------
type t_MPU_CTRL is record
ENABLE : bool; -- Enables the MPU
HFNMIENA : bool; -- Enables the operation of MPU during hard fault,
-- NMI, and FAULTMASK handlers
PRIVDEFENA : bool; -- Enables privileged software access to the default
-- memory map
end record
with size => 32;
for t_MPU_CTRL use record
ENABLE at 0 range 0 .. 0;
HFNMIENA at 0 range 1 .. 1;
PRIVDEFENA at 0 range 2 .. 2;
end record;
--------------------------------
-- MPU Region Number Register --
--------------------------------
type t_MPU_RNR is record
REGION : unsigned_8 range 0 .. 7; -- Indicates the region referenced by
-- MPU_RBAR and MPU_RASR
end record
with size => 32;
for t_MPU_RNR use record
REGION at 0 range 0 .. 7;
end record;
--------------------------------------
-- MPU Region Base Address Register --
--------------------------------------
--
-- Defines the base address of the MPU region selected by the MPU_RNR
--
type t_MPU_RBAR is record
REGION : bits_4 range 0 .. 7;
VALID : bool;
ADDR : bits_27;
end record
with size => 32;
for t_MPU_RBAR use record
REGION at 0 range 0 .. 3;
VALID at 0 range 4 .. 4;
ADDR at 0 range 5 .. 31;
end record;
function address_to_bits_27 (addr : system_address)
return bits_27
with pre => (addr and 2#11111#) = 0;
--------------------------------------------
-- MPU Region Attribute and Size Register --
--------------------------------------------
type t_MPU_RASR is record
ENABLE : bool; -- Enable region
SIZE : t_region_size;
SRD : unsigned_8; -- Subregion disable bits (0 = enabled, 1 = disabled)
B : bool;
C : bool;
S : bool; -- Shareable
TEX : bits_3; -- Memory attributes
AP : bits_3; -- Permissions
XN : bool; -- Instruction fetches disabled
end record
with size => 32;
for t_MPU_RASR use record
ENABLE at 0 range 0 .. 0;
SIZE at 0 range 1 .. 5;
SRD at 0 range 8 .. 15;
B at 0 range 16 .. 16;
C at 0 range 17 .. 17;
S at 0 range 18 .. 18;
TEX at 0 range 19 .. 21;
AP at 0 range 24 .. 26;
XN at 0 range 28 .. 28;
end record;
function to_MPU_RASR is new ada.unchecked_conversion
(unsigned_32, t_MPU_RASR);
--------------------
-- MPU peripheral --
--------------------
type t_MPU_peripheral is record
TYPER : t_MPU_TYPE;
CTRL : t_MPU_CTRL;
RNR : t_MPU_RNR;
RBAR : t_MPU_RBAR;
RASR : t_MPU_RASR;
RBAR_A1 : t_MPU_RBAR;
RASR_A1 : t_MPU_RASR;
RBAR_A2 : t_MPU_RBAR;
RASR_A2 : t_MPU_RASR;
RBAR_A3 : t_MPU_RBAR;
RASR_A3 : t_MPU_RASR;
end record;
for t_MPU_peripheral use record
TYPER at 16#00# range 0 .. 31;
CTRL at 16#04# range 0 .. 31;
RNR at 16#08# range 0 .. 31;
RBAR at 16#0C# range 0 .. 31;
RASR at 16#10# range 0 .. 31;
RBAR_A1 at 16#14# range 0 .. 31;
RASR_A1 at 16#18# range 0 .. 31;
RBAR_A2 at 16#1C# range 0 .. 31;
RASR_A2 at 16#20# range 0 .. 31;
RBAR_A3 at 16#24# range 0 .. 31;
RASR_A3 at 16#28# range 0 .. 31;
end record;
----------------
-- Peripheral --
----------------
MPU : t_MPU_peripheral
with
import,
volatile,
address => m4.layout.MPU_base;
end m4.mpu;
|
sungyeon/drake | Ada | 1,154 | adb | with Ada.Containers.Murmur_Hash_3;
with Ada.Strings.Naked_Maps.Case_Folding;
function Ada.Strings.Generic_Hash_Case_Insensitive (Key : String_Type)
return Containers.Hash_Type
is
Mapping : constant not null Naked_Maps.Character_Mapping_Access :=
Strings.Naked_Maps.Case_Folding.Case_Folding_Map;
State : Containers.Murmur_Hash_3.State :=
Containers.Murmur_Hash_3.Initialize (0);
Result : Containers.Hash_Type;
Last : Natural := Key'First - 1;
begin
while Last < Key'Last loop
declare
Code : Wide_Wide_Character;
Is_Illegal_Sequence : Boolean; -- ignore
begin
-- get single unicode character
Get (
Key (Last + 1 .. Key'Last),
Last,
Code,
Is_Illegal_Sequence);
-- update
Containers.Murmur_Hash_3.Update (
State,
Containers.Hash_Type'(
Wide_Wide_Character'Pos (
Strings.Naked_Maps.Value (Mapping.all, Code))));
end;
end loop;
Containers.Murmur_Hash_3.Finalize (State, Result);
return Result;
end Ada.Strings.Generic_Hash_Case_Insensitive;
|
egustafson/sandbox | Ada | 955 | ads | with Ada.Text_IO;
use Ada.Text_IO;
generic
type Element_Type is private;
with function Less_Than( Left, Right : in Element_Type ) return Boolean;
with function Greater_Than( Left, Right : in Element_Type ) return Boolean;
with procedure Put( Item: in Element_Type );
package Generic_Binary_Tree is
type T is limited private;
function Is_In_Tree( Tree: in T; Element: in Element_Type ) return Boolean;
procedure Insert( Tree: in out T; Element: in Element_Type );
procedure Remove( Tree: in out T; Element: in Element_Type );
procedure Print( Tree: in T );
procedure Debug_Print( Tree: in T );
private
type Tree_Node;
type Tree_Node_Ptr is access Tree_Node;
type Tree_Node is
record
Data : Element_Type;
Left : Tree_Node_Ptr;
Right : Tree_Node_Ptr;
end record;
type T is
record
Root : Tree_Node_Ptr;
end record;
end Generic_Binary_Tree;
|
AdaCore/spat | Ada | 3,161 | adb | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
with Ada.Strings.Fixed;
with SI_Units.Metric;
with SI_Units.Names;
with SPAT.Command_Line;
package body SPAT is
---------------------------------------------------------------------------
-- Nice_Image
---------------------------------------------------------------------------
function Nice_Image is new
SI_Units.Metric.Fixed_Image (Item => Duration,
Default_Aft => 0,
Unit => SI_Units.Names.Second);
---------------------------------------------------------------------------
-- Image
---------------------------------------------------------------------------
function Image (Value : in Duration) return String is
(if SPAT.Command_Line.Raw_Mode.Get
then Value'Image
else Nice_Image (Value => Value));
---------------------------------------------------------------------------
-- Image
---------------------------------------------------------------------------
function Image (Value : in Duration;
Steps : in Prover_Steps) return String is
(Image (Value => Value) & " (" &
Ada.Strings.Fixed.Trim (Source => Steps'Image,
Side => Ada.Strings.Both) & " step" &
(if Steps /= 1 then "s)" else ")"));
---------------------------------------------------------------------------
-- Scaled
--
-- See https://github.com/AdaCore/why3/blob/master/src/gnat/gnat_config.ml#L538
---------------------------------------------------------------------------
function Scaled (Prover : in Prover_Name;
Raw_Steps : in Prover_Steps) return Prover_Steps is
begin
-- Especially with Z3, negative steps indicate a proof failure (i.e. out
-- of memory situation etc.), so if the input number is negative leave it
-- as is. At least I find it counterintuitive, that -1 would be
-- converted to +1 instead.
if Raw_Steps < 0 then
return Raw_Steps;
end if;
if
Ada.Strings.Unbounded.Index (Source => Subject_Name (Prover),
Pattern => "CVC4") = 1
then
-- add = 15_000, mult = 35
return Prover_Steps'Max (Raw_Steps - 15_000, 0) / 35 + 1;
end if;
if
Ada.Strings.Unbounded.Index (Source => Subject_Name (Prover),
Pattern => "Z3") = 1
then
-- add = 450_000, mult = 800
return Prover_Steps'Max (Raw_Steps - 450_000, 0) / 800 + 1;
end if;
-- alt-ergo, and others => no scaling
return Raw_Steps + 1;
end Scaled;
end SPAT;
|
AdaCore/training_material | Ada | 1,083 | adb | package body Basics is
procedure Swap (X, Y : in out Integer) is
Tmp : Integer := X;
begin
X := Y;
Y := Tmp;
end Swap;
procedure Bump_Rec (R : in out Rec) is
begin
case R.Disc is
when True =>
R.A := R.A + 1;
when False =>
R.B := R.B + 1;
end case;
end Bump_Rec;
procedure Swap_Table (T : in out Table; I, J : Index) is
begin
if I /= J then
Swap (T (I), T (J));
pragma Annotate (GNATprove, False_Positive,
"formal parameters * might be aliased",
"I /= J so T(I) and T(J) cannot alias");
end if;
end Swap_Table;
procedure Init_Rec (R : out Rec) is
begin
case R.Disc is
when True =>
R := (Disc => True, A => 1);
when False =>
R := (Disc => False, B => 1);
end case;
end Init_Rec;
procedure Init_Table (T : out Table) is
begin
T := (others => 0);
T (T'First) := 1;
T (T'Last) := 2;
end Init_Table;
end Basics;
|
zhmu/ananas | Ada | 948 | ads | with System;
package Unc_Memops is
pragma Elaborate_Body;
type size_t is mod 2 ** Standard'Address_Size;
subtype addr_t is System.Address;
function Alloc (Size : size_t) return addr_t;
procedure Free (Ptr : addr_t);
function Realloc (Ptr : addr_t; Size : size_t) return addr_t;
procedure Expect_Symetry (Status : Boolean);
-- Whether we expect "free"s to match "alloc" return values in
-- reverse order, like alloc->X, alloc->Y should be followed by
-- free Y, free X.
private
-- Uncomment the exports below to really exercise the alternate versions.
-- This only works when using an installed version of the tools which
-- grabs the runtime library objects from an archive, hence doesn't force
-- the inclusion of s-memory.o.
-- pragma Export (C, Alloc, "__gnat_malloc");
-- pragma Export (C, Free, "__gnat_free");
-- pragma Export (C, Realloc, "__gnat_realloc");
end;
|
reznikmm/gela | Ada | 73 | ads | package Asis.Extensions is
pragma Preelaborate;
end Asis.Extensions;
|
kjseefried/coreland-cgbc | Ada | 1,114 | adb | with CGBC.Bounded_Wide_Wide_Strings;
with Test;
procedure T_WWBstr_Init_01 is
package BS renames CGBC.Bounded_Wide_Wide_Strings;
TC : Test.Context_t;
S1 : BS.Bounded_String (8);
begin
Test.Initialize
(Test_Context => TC,
Program => "t_wwbstr_init_01",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
-- "Referenced before value"
pragma Warnings (Off);
Test.Check (TC, 2227, BS.To_String (S1) = "", "BS.To_String (S1) = """"");
pragma Warnings (On);
Test.Check (TC, 2228, BS.Length (S1) = 0, "BS.Length (S1) = 0");
Test.Check (TC, 2229, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
BS.Append (S1, "ABCD");
Test.Check (TC, 2230, BS.Length (S1) = 4, "BS.Length (S1) = 4");
Test.Check (TC, 2231, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
declare
S2 : constant BS.Bounded_String := BS.To_Bounded_String ("ABCD");
begin
Test.Check (TC, 2232, BS.Equivalent (S1, S2), "BS.Equivalent (S1, S2)");
Test.Check (TC, 2233, BS.To_String (S2) = "ABCD", "BS.To_String (S2) = ""ABCD""");
end;
end T_WWBstr_Init_01;
|
faelys/natools | Ada | 3,185 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2013-2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expressions.Printers mainly provides an interface for objects --
-- that are "printer-like", which means the client somehow transmits --
-- sequentially whatever information is needed to output a S-expression. --
-- This contrasts with Descriptor interface, in that the latter provides an --
-- interface for S-expression from the object to its client, while Printer --
-- interface is for S-epression transmitted from the client to its the --
-- object. --
-- --
-- The package also provide concrete type Canonical, which outputs the --
-- S-expression provided through the interface into the given output --
-- stream, using canonical encoding. --
------------------------------------------------------------------------------
with Ada.Streams;
package Natools.S_Expressions.Printers is
pragma Pure (Natools.S_Expressions.Printers);
type Printer is limited interface;
procedure Open_List (Output : in out Printer) is abstract;
procedure Append_Atom (Output : in out Printer; Data : in Atom) is abstract;
procedure Close_List (Output : in out Printer) is abstract;
procedure Append_String (Output : in out Printer'Class; Data : in String);
procedure Transfer
(Source : in out Descriptor'Class;
Target : in out Printer'Class;
Check_Level : in Boolean := False);
type Canonical (Stream : access Ada.Streams.Root_Stream_Type'Class) is
new Printer with null record;
overriding procedure Open_List (Output : in out Canonical);
overriding procedure Append_Atom (Output : in out Canonical;
Data : in Atom);
overriding procedure Close_List (Output : in out Canonical);
end Natools.S_Expressions.Printers;
|
reznikmm/matreshka | Ada | 4,631 | 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_Smil.TargetElement_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Smil_TargetElement_Attribute_Node is
begin
return Self : Smil_TargetElement_Attribute_Node do
Matreshka.ODF_Smil.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Smil_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Smil_TargetElement_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.TargetElement_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Smil_URI,
Matreshka.ODF_String_Constants.TargetElement_Attribute,
Smil_TargetElement_Attribute_Node'Tag);
end Matreshka.ODF_Smil.TargetElement_Attributes;
|
zhmu/ananas | Ada | 184 | adb | -- { dg-do run }
-- { dg-options "-flto" { target lto } }
with Lto19_Pkg1;
procedure Lto19 is
R : Lto19_Pkg1.Rec := (I => 1, A => (others => 0));
begin
Lto19_Pkg1.Proc (R);
end;
|
Fabien-Chouteau/GESTE | Ada | 6,541 | ads | with GESTE;
with GESTE.Grid;
pragma Style_Checks (Off);
package Game_Assets.cave is
-- cave
Width : constant := 20;
Height : constant := 15;
Tile_Width : constant := 16;
Tile_Height : constant := 16;
-- Ground
package Ground is
Width : constant := 20;
Height : constant := 20;
Data : aliased GESTE.Grid.Grid_Data :=
(( 339, 340, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 342),
( 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 348, 349, 350, 354),
( 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 360, 361, 362, 366),
( 343, 344, 345, 346, 347, 367, 368, 369, 370, 371, 372, 367, 368, 369, 354),
( 355, 356, 357, 358, 359, 373, 374, 375, 376, 377, 378, 373, 374, 375, 366),
( 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 348, 349, 350, 354),
( 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 360, 361, 362, 366),
( 343, 344, 345, 346, 347, 367, 368, 369, 370, 371, 372, 367, 368, 369, 354),
( 355, 356, 357, 358, 359, 373, 374, 375, 376, 377, 378, 373, 374, 375, 366),
( 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 348, 349, 350, 354),
( 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 360, 361, 362, 366),
( 343, 344, 345, 346, 347, 367, 368, 369, 370, 371, 372, 367, 368, 369, 354),
( 355, 356, 357, 358, 359, 373, 374, 375, 376, 377, 378, 373, 374, 375, 366),
( 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 348, 349, 350, 354),
( 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 360, 361, 362, 366),
( 343, 344, 345, 346, 347, 367, 368, 369, 370, 371, 372, 367, 368, 369, 354),
( 355, 356, 357, 358, 359, 373, 374, 375, 376, 377, 378, 373, 374, 375, 366),
( 343, 344, 345, 346, 347, 367, 368, 369, 370, 371, 372, 367, 0, 0, 354),
( 355, 356, 357, 358, 359, 373, 374, 375, 376, 377, 378, 0, 0, 0, 366),
( 379, 380, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, 382)) ;
end Ground;
-- Over
package Over is
Width : constant := 20;
Height : constant := 20;
Data : aliased GESTE.Grid.Grid_Data :=
(( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 383, 384, 385, 386, 387, 388, 389, 390, 0, 0, 0),
( 0, 0, 0, 0, 391, 392, 393, 394, 395, 396, 397, 398, 0, 0, 0),
( 0, 167, 168, 0, 399, 400, 401, 402, 0, 0, 0, 0, 0, 0, 0),
( 0, 173, 174, 0, 403, 404, 405, 406, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 407, 408, 409, 410, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 411, 412, 413, 414, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 415, 416, 417, 418, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 419, 420, 421, 422, 0, 0, 0, 0, 0, 0, 0),
( 0, 167, 168, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
( 0, 173, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 0, 0, 0, 0, 423, 424, 0, 0, 0, 0, 0),
( 0, 0, 0, 0, 0, 0, 0, 0, 425, 426, 0, 0, 0, 0, 0),
( 0, 427, 428, 429, 430, 431, 0, 0, 432, 433, 0, 0, 0, 0, 0),
( 0, 434, 435, 436, 437, 438, 0, 0, 439, 440, 0, 0, 0, 0, 0),
( 0, 441, 442, 443, 444, 445, 0, 0, 0, 0, 446, 447, 448, 449, 0),
( 0, 450, 451, 452, 453, 454, 0, 0, 0, 0, 455, 456, 457, 458, 0),
( 0, 459, 460, 461, 462, 463, 0, 0, 0, 0, 464, 465, 466, 467, 0),
( 0, 468, 469, 470, 471, 472, 0, 0, 0, 0, 473, 474, 475, 476, 0),
( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) ;
end Over;
-- collisions
package collisions is
Width : constant := 20;
Height : constant := 20;
Data : aliased GESTE.Grid.Grid_Data :=
(( 0, 0, 0, 0, 0, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234),
( 0, 0, 0, 0, 0, 234, 234, 234, 234, 234, 234, 234, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 234, 241, 477, 241, 477, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 478, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 477, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 0, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 478, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 0, 234, 234, 234, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 234, 240, 0, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 0, 0, 0, 234, 234, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 0, 0, 0, 234, 234, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 238, 234, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 234, 234, 0, 0, 0, 0, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 0, 0, 0, 242, 234, 234, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 0, 0, 0, 234, 234, 234, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 0, 0, 242, 234, 234, 234, 234),
( 0, 0, 0, 0, 234, 235, 0, 0, 0, 0, 234, 234, 234, 234, 234),
( 0, 0, 0, 0, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234, 234)) ;
end collisions;
package gates is
Objects : Object_Array :=
(
0 => (
Kind => POINT_OBJ,
Id => 1,
Name => new String'("From_House"),
X => 2.00000E+02,
Y => 2.08000E+02,
Width => 0.00000E+00,
Height => 0.00000E+00,
Tile_Id => 0,
Str => null
),
1 => (
Kind => RECTANGLE_OBJ,
Id => 2,
Name => new String'("To_House"),
X => 2.24000E+02,
Y => 1.88000E+02,
Width => 1.60000E+01,
Height => 3.60000E+01,
Tile_Id => 0,
Str => null
)
);
From_House : aliased constant Object := (
Kind => POINT_OBJ,
Id => 1,
Name => new String'("From_House"),
X => 2.00000E+02,
Y => 2.08000E+02,
Width => 0.00000E+00,
Height => 0.00000E+00,
Tile_Id => 0,
Str => null
);
To_House : aliased constant Object := (
Kind => RECTANGLE_OBJ,
Id => 2,
Name => new String'("To_House"),
X => 2.24000E+02,
Y => 1.88000E+02,
Width => 1.60000E+01,
Height => 3.60000E+01,
Tile_Id => 0,
Str => null
);
end gates;
end Game_Assets.cave;
|
reznikmm/matreshka | Ada | 3,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 ODF.DOM.Svg_Widths_Attributes;
package Matreshka.ODF_Svg.Widths_Attributes is
type Svg_Widths_Attribute_Node is
new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node
and ODF.DOM.Svg_Widths_Attributes.ODF_Svg_Widths_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Svg_Widths_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Svg_Widths_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Svg.Widths_Attributes;
|
reznikmm/matreshka | Ada | 9,551 | adb | ------------------------------------------------------------------------------
-- --
-- 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$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UMLDI_Iterators;
with AMF.Visitors.UMLDI_Visitors;
package body AMF.Internals.UMLDI_UML_Shapes is
-----------------
-- Get_Is_Icon --
-----------------
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Icon
(Self.Element);
end Get_Is_Icon;
-----------------
-- Set_Is_Icon --
-----------------
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Shape_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Icon
(Self.Element, To);
end Set_Is_Icon;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is
begin
return
AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Shape_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
raise Program_Error;
return X : AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- return
-- AMF.UML.Elements.Collections.Wrap
-- (AMF.Internals.Element_Collections.Wrap
-- (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
-- (Self.Element)));
end Get_Model_Element;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access is
begin
return
AMF.CMOF.Elements.CMOF_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
(Self.Element)));
end Get_Model_Element;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return AMF.DI.Styles.DI_Style_Access is
begin
return
AMF.DI.Styles.DI_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Shape_Proxy;
To : AMF.DI.Styles.DI_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
----------------
-- Get_Bounds --
----------------
overriding function Get_Bounds
(Self : not null access constant UMLDI_UML_Shape_Proxy)
return AMF.DC.Optional_DC_Bounds is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Bounds
(Self.Element);
end Get_Bounds;
----------------
-- Set_Bounds --
----------------
overriding procedure Set_Bounds
(Self : not null access UMLDI_UML_Shape_Proxy;
To : AMF.DC.Optional_DC_Bounds) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Bounds
(Self.Element, To);
end Set_Bounds;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Shape_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Enter_UML_Shape
(AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Shape_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Leave_UML_Shape
(AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Shape_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.UMLDI_Iterators.UMLDI_Iterator'Class then
AMF.Visitors.UMLDI_Iterators.UMLDI_Iterator'Class
(Iterator).Visit_UML_Shape
(Visitor,
AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.UMLDI_UML_Shapes;
|
simonjwright/sdlada | Ada | 8,979 | adb | with Interfaces.C.Pointers;
with SDL.Events.Events;
with SDL.Events.Keyboards;
with SDL.Events.Mice;
with SDL.Log;
with SDL.Video.Palettes;
with SDL.Video.Pixel_Formats;
with SDL.Video.Surfaces.Makers;
with SDL.Video.Rectangles;
with SDL.Video.Windows.Makers;
with Ada.Numerics.Long_Complex_Types;
use Ada.Numerics.Long_Complex_Types;
procedure Surface_Direct_Access is
W : SDL.Video.Windows.Window;
package Sprite is
subtype Pixel is Interfaces.Unsigned_16;
type Image_Type is array (Integer range <>, Integer range <>) of aliased Pixel;
T : constant := 16#0000#;
R : constant := 16#F00F#;
W : constant := 16#FFFF#;
Image : aliased Image_Type := (
(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T),
(T, T, T, R, R, R, T, T, T, R, R, R, T, T, T, T),
(T, T, R, W, W, R, R, T, R, W, W, R, R, T, T, T),
(T, R, W, R, R, R, R, R, W, R, R, R, R, R, T, T),
(R, W, R, R, R, R, R, R, R, R, R, R, R, R, R, T),
(R, W, R, R, R, R, R, R, R, R, R, R, R, R, R, T),
(R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, T),
(T, R, R, R, R, R, R, R, R, R, R, R, R, R, T, T),
(T, R, R, R, R, R, R, R, R, R, R, R, R, R, T, T),
(T, T, R, R, R, R, R, R, R, R, R, R, R, T, T, T),
(T, T, T, R, R, R, R, R, R, R, R, R, T, T, T, T),
(T, T, T, T, R, R, R, R, R, R, R, T, T, T, T, T),
(T, T, T, T, T, R, R, R, R, R, T, T, T, T, T, T),
(T, T, T, T, T, T, R, R, R, T, T, T, T, T, T, T),
(T, T, T, T, T, T, T, R, T, T, T, T, T, T, T, T),
(T, T, T, T, T, T, T, R, T, T, T, T, T, T, T, T)
);
S : SDL.Video.Surfaces.Surface;
procedure Create_From is new SDL.Video.Surfaces.Makers.Create_From_Array (
Element => Pixel,
Index => Integer,
Element_Array => Image_Type);
end Sprite;
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
if SDL.Initialise (Flags => SDL.Enable_Screen) = True then
SDL.Video.Windows.Makers.Create (Win => W,
Title => "Surface direct access: Julia set interactive view (Esc to exit)",
Position => SDL.Natural_Coordinates'(X => 100, Y => 100),
Size => SDL.Positive_Sizes'(640, 640),
Flags => SDL.Video.Windows.Resizable);
Sprite.Create_From (Self => Sprite.S,
Pixels => Sprite.Image'Access,
Red_Mask => 16#000F#,
Green_Mask => 16#00F0#,
Blue_Mask => 16#0F00#,
Alpha_Mask => 16#F000#);
-- Main loop.
declare
Pixel_Depth : constant := 16;
-- Not all Pixel_Depth values are displayed correctly.
-- Actual data layout may differ than implied here.
type Pixel is mod 2**Pixel_Depth;
type Pixel_Array is array (Integer range <>) of aliased Pixel;
package Pixel_Pointers is new Interfaces.C.Pointers (Index => Integer,
Element => Pixel,
Element_Array => Pixel_Array,
Default_Terminator => 0);
use type Pixel_Pointers.Pointer;
S : SDL.Video.Surfaces.Surface;
package Pixel_Data is new SDL.Video.Surfaces.Pixel_Data (Element => Pixel,
Element_Pointer => Pixel_Pointers.Pointer);
-- This procedure writes individual pixel in the surface (no blending or masking)
procedure Write_Pixel (X, Y : Integer; Colour : Pixel) is
Row_Ptr : constant Pixel_Pointers.Pointer := Pixel_Data.Get_Row (S, SDL.Coordinate (Y));
Ptr : constant Pixel_Pointers.Pointer := Row_Ptr + Interfaces.C.ptrdiff_t (X);
begin
Ptr.all := Colour;
end Write_Pixel;
Cursor : SDL.Natural_Coordinates;
N_Max : constant := 63; -- Maximum number of iterations for Julia set
-- Precalculated map of colours
False_Colour : Pixel_Array (0 .. N_Max);
procedure Make_False_Colour is
Z : Complex;
A : constant Complex := Compose_From_Polar (1.0, 1.0, 3.0);
R, G, B : Integer;
begin
for I in 0 .. N_Max loop
case I is
when 0 .. N_Max - 1 =>
Z := Compose_From_Polar
(127.0, Long_Float (I), Long_Float (N_Max));
B := 127 + Integer (Re (Z));
R := 127 + Integer (Re (Z * A));
G := 127 + Integer (Re (Z * A * A));
when others => -- last iteration means we did'nt reach condition
R := 0;
G := 0;
B := 0;
end case;
False_Colour (I) := Pixel (SDL.Video.Pixel_Formats.To_Pixel
(Format => S.Pixel_Format,
Red => SDL.Video.Palettes.Colour_Component (R),
Green => SDL.Video.Palettes.Colour_Component (G),
Blue => SDL.Video.Palettes.Colour_Component (B)));
end loop;
end Make_False_Colour;
procedure Render is
-- A constant for Julia set iteration
C : constant Complex := (
(Long_Float (Cursor.X) / 640.0) * 4.0 - 2.0,
(Long_Float (Cursor.Y) / 640.0) * 4.0 - 2.0);
-- Julia set iteration variable
Z : Complex;
-- Julia set iteration counter
N : Integer;
begin
S.Lock;
for X in 0 .. 639 loop
for Y in 0 .. 639 loop
-- Julia set iteration
Z := ((Long_Float (X) / 640.0) * 4.0 - 2.0,
(Long_Float (Y) / 640.0) * 4.0 - 2.0);
N := 0;
-- Julia set iteration
while Re (Z)**2 + Im (Z)**2 < 4.0 and N < N_Max loop
N := N + 1;
Z := Z**2 + C;
end loop;
Write_Pixel (X, Y, False_Colour (N));
end loop;
end loop;
S.Unlock;
declare
TR, SR : SDL.Video.Rectangles.Rectangle := (X => 0,
Y => 0,
Width => Sprite.Image'Length (2),
Height => Sprite.Image'Length (1));
begin
TR.X := 20;
TR.Y := 20;
S.Blit (TR,
Sprite.S,
SR);
end;
end Render;
Window_Surface : SDL.Video.Surfaces.Surface;
Event : SDL.Events.Events.Events;
Finished : Boolean := False;
use type SDL.Events.Keyboards.Key_Codes;
begin
SDL.Video.Surfaces.Makers.Create (Self => S,
Size => (640, 640),
BPP => Pixel_Depth,
Red_Mask => 0,
Blue_Mask => 0,
Green_Mask => 0,
Alpha_Mask => 0); -- a surface with known pixel depth
Make_False_Colour;
Render;
Window_Surface := W.Get_Surface;
Window_Surface.Blit (S);
W.Update_Surface;
loop
while SDL.Events.Events.Poll (Event) loop
case Event.Common.Event_Type is
when SDL.Events.Quit =>
Finished := True;
when SDL.Events.Keyboards.Key_Down =>
if Event.Keyboard.Key_Sym.Key_Code = SDL.Events.Keyboards.Code_Escape then
Finished := True;
end if;
when SDL.Events.Mice.Motion =>
Cursor := (X => Event.Mouse_Motion.X, Y => Event.Mouse_Motion.Y);
Render;
Window_Surface := W.Get_Surface;
Window_Surface.Blit (S);
W.Update_Surface;
when others =>
null;
end case;
end loop;
exit when Finished;
end loop;
end;
W.Finalize;
SDL.Finalise;
end if;
end Surface_Direct_Access;
|
stcarrez/dynamo | Ada | 473 | adb | -- part of ParserTools, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Strings.Hash;
package body Text is
function "&" (Left, Right : Reference) return String is
(Ada.Strings.Unbounded.To_String (Left) & Ada.Strings.Unbounded.To_String (Right));
function Hash (Object : Reference) return Ada.Containers.Hash_Type is
(Ada.Strings.Hash (Ada.Strings.Unbounded.To_String (Object)));
end Text;
|
octonion/examples | Ada | 7,227 | ads | pragma Ada_95;
pragma Warnings (Off);
with System;
package ada_main is
procedure adainit;
pragma Export (C, adainit, "adainit");
procedure adafinal;
pragma Export (C, adafinal, "adafinal");
type Version_32 is mod 2 ** 32;
u00001 : constant Version_32 := 16#3faa9122#;
pragma Export (C, u00001, "unitB");
u00002 : constant Version_32 := 16#0c02f564#;
pragma Export (C, u00002, "unitS");
u00003 : constant Version_32 := 16#b6df930e#;
pragma Export (C, u00003, "system__standard_libraryB");
u00004 : constant Version_32 := 16#7ec093d3#;
pragma Export (C, u00004, "system__standard_libraryS");
u00005 : constant Version_32 := 16#5ab55268#;
pragma Export (C, u00005, "interfacesS");
u00006 : constant Version_32 := 16#769e25e6#;
pragma Export (C, u00006, "interfaces__cB");
u00007 : constant Version_32 := 16#70be4e8c#;
pragma Export (C, u00007, "interfaces__cS");
u00008 : constant Version_32 := 16#c2326fda#;
pragma Export (C, u00008, "ada__exceptionsB");
u00009 : constant Version_32 := 16#6e98a13f#;
pragma Export (C, u00009, "ada__exceptionsS");
u00010 : constant Version_32 := 16#76789da1#;
pragma Export (C, u00010, "adaS");
u00011 : constant Version_32 := 16#e947e6a9#;
pragma Export (C, u00011, "ada__exceptions__last_chance_handlerB");
u00012 : constant Version_32 := 16#41e5552e#;
pragma Export (C, u00012, "ada__exceptions__last_chance_handlerS");
u00013 : constant Version_32 := 16#4635ec04#;
pragma Export (C, u00013, "systemS");
u00014 : constant Version_32 := 16#4e7785b8#;
pragma Export (C, u00014, "system__soft_linksB");
u00015 : constant Version_32 := 16#d8b13451#;
pragma Export (C, u00015, "system__soft_linksS");
u00016 : constant Version_32 := 16#b01dad17#;
pragma Export (C, u00016, "system__parametersB");
u00017 : constant Version_32 := 16#381fe17b#;
pragma Export (C, u00017, "system__parametersS");
u00018 : constant Version_32 := 16#30ad09e5#;
pragma Export (C, u00018, "system__secondary_stackB");
u00019 : constant Version_32 := 16#fca7137e#;
pragma Export (C, u00019, "system__secondary_stackS");
u00020 : constant Version_32 := 16#f103f468#;
pragma Export (C, u00020, "system__storage_elementsB");
u00021 : constant Version_32 := 16#6bf6a600#;
pragma Export (C, u00021, "system__storage_elementsS");
u00022 : constant Version_32 := 16#41837d1e#;
pragma Export (C, u00022, "system__stack_checkingB");
u00023 : constant Version_32 := 16#c88a87ec#;
pragma Export (C, u00023, "system__stack_checkingS");
u00024 : constant Version_32 := 16#87a448ff#;
pragma Export (C, u00024, "system__exception_tableB");
u00025 : constant Version_32 := 16#1b9b8546#;
pragma Export (C, u00025, "system__exception_tableS");
u00026 : constant Version_32 := 16#ce4af020#;
pragma Export (C, u00026, "system__exceptionsB");
u00027 : constant Version_32 := 16#2e5681f2#;
pragma Export (C, u00027, "system__exceptionsS");
u00028 : constant Version_32 := 16#843d48dc#;
pragma Export (C, u00028, "system__exceptions__machineS");
u00029 : constant Version_32 := 16#aa0563fc#;
pragma Export (C, u00029, "system__exceptions_debugB");
u00030 : constant Version_32 := 16#38bf15c0#;
pragma Export (C, u00030, "system__exceptions_debugS");
u00031 : constant Version_32 := 16#6c2f8802#;
pragma Export (C, u00031, "system__img_intB");
u00032 : constant Version_32 := 16#44ee0cc6#;
pragma Export (C, u00032, "system__img_intS");
u00033 : constant Version_32 := 16#39df8c17#;
pragma Export (C, u00033, "system__tracebackB");
u00034 : constant Version_32 := 16#181732c0#;
pragma Export (C, u00034, "system__tracebackS");
u00035 : constant Version_32 := 16#9ed49525#;
pragma Export (C, u00035, "system__traceback_entriesB");
u00036 : constant Version_32 := 16#466e1a74#;
pragma Export (C, u00036, "system__traceback_entriesS");
u00037 : constant Version_32 := 16#6fd210f2#;
pragma Export (C, u00037, "system__traceback__symbolicB");
u00038 : constant Version_32 := 16#dd19f67a#;
pragma Export (C, u00038, "system__traceback__symbolicS");
u00039 : constant Version_32 := 16#701f9d88#;
pragma Export (C, u00039, "ada__exceptions__tracebackB");
u00040 : constant Version_32 := 16#20245e75#;
pragma Export (C, u00040, "ada__exceptions__tracebackS");
u00041 : constant Version_32 := 16#9f00b3d3#;
pragma Export (C, u00041, "system__address_imageB");
u00042 : constant Version_32 := 16#e7d9713e#;
pragma Export (C, u00042, "system__address_imageS");
u00043 : constant Version_32 := 16#8c33a517#;
pragma Export (C, u00043, "system__wch_conB");
u00044 : constant Version_32 := 16#5d48ced6#;
pragma Export (C, u00044, "system__wch_conS");
u00045 : constant Version_32 := 16#9721e840#;
pragma Export (C, u00045, "system__wch_stwB");
u00046 : constant Version_32 := 16#7059e2d7#;
pragma Export (C, u00046, "system__wch_stwS");
u00047 : constant Version_32 := 16#a831679c#;
pragma Export (C, u00047, "system__wch_cnvB");
u00048 : constant Version_32 := 16#52ff7425#;
pragma Export (C, u00048, "system__wch_cnvS");
u00049 : constant Version_32 := 16#ece6fdb6#;
pragma Export (C, u00049, "system__wch_jisB");
u00050 : constant Version_32 := 16#d28f6d04#;
pragma Export (C, u00050, "system__wch_jisS");
u00051 : constant Version_32 := 16#a6359005#;
pragma Export (C, u00051, "system__memoryB");
u00052 : constant Version_32 := 16#1f488a30#;
pragma Export (C, u00052, "system__memoryS");
u00053 : constant Version_32 := 16#36a43a0a#;
pragma Export (C, u00053, "system__crtlS");
-- BEGIN ELABORATION ORDER
-- ada%s
-- interfaces%s
-- system%s
-- system.img_int%s
-- system.img_int%b
-- system.parameters%s
-- system.parameters%b
-- system.crtl%s
-- system.storage_elements%s
-- system.storage_elements%b
-- system.stack_checking%s
-- system.stack_checking%b
-- system.traceback_entries%s
-- system.traceback_entries%b
-- system.wch_con%s
-- system.wch_con%b
-- system.wch_jis%s
-- system.wch_jis%b
-- system.wch_cnv%s
-- system.wch_cnv%b
-- system.traceback%s
-- system.traceback%b
-- system.wch_stw%s
-- system.standard_library%s
-- system.exceptions_debug%s
-- system.exceptions_debug%b
-- ada.exceptions%s
-- system.wch_stw%b
-- ada.exceptions.traceback%s
-- system.soft_links%s
-- system.exception_table%s
-- system.exception_table%b
-- system.exceptions%s
-- system.exceptions%b
-- system.secondary_stack%s
-- system.address_image%s
-- system.soft_links%b
-- ada.exceptions.last_chance_handler%s
-- system.memory%s
-- system.memory%b
-- ada.exceptions.traceback%b
-- system.traceback.symbolic%s
-- system.traceback.symbolic%b
-- system.exceptions.machine%s
-- system.secondary_stack%b
-- system.address_image%b
-- ada.exceptions.last_chance_handler%b
-- system.standard_library%b
-- ada.exceptions%b
-- interfaces.c%s
-- interfaces.c%b
-- unit%s
-- unit%b
-- END ELABORATION ORDER
end ada_main;
|
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_Meta.Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Meta_Name_Attribute_Node is
begin
return Self : Meta_Name_Attribute_Node do
Matreshka.ODF_Meta.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Meta_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Meta_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Meta_URI,
Matreshka.ODF_String_Constants.Name_Attribute,
Meta_Name_Attribute_Node'Tag);
end Matreshka.ODF_Meta.Name_Attributes;
|
reznikmm/matreshka | Ada | 10,271 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Orthogonal Persistence Manager --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009, 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 Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
--with Ada.Text_IO;
with SQLite;
package body Matreshka.Internals.Persistence_Manager is
package Descriptor_Lists is
new Ada.Containers.Doubly_Linked_Lists (Descriptor_Access);
Modified : Descriptor_Lists.List;
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out Abstract_Proxy) is
begin
Self.Descriptor.Reference;
end Adjust;
------------
-- Commit --
------------
procedure Commit is
procedure Process (Position : Descriptor_Lists.Cursor);
-------------
-- Process --
-------------
procedure Process (Position : Descriptor_Lists.Cursor) is
Descriptor : Descriptor_Access := Descriptor_Lists.Element (Position);
begin
-- Ada.Text_IO.Put_Line ("Save");
Descriptor.Save;
Descriptor.Is_Modified := False;
if Matreshka.Internals.Atomics.Counters.Is_Zero
(Descriptor.Counter'Access)
then
-- XXX Object can be destroyed.
null;
-- Ada.Text_IO.Put_Line ("Destroy object");
end if;
end Process;
Statement : SQLite.SQLite_Statement_Access;
begin
Modified.Iterate (Process'Access);
Modified.Clear;
SQLite.Prepare (Database, "COMMIT", Statement);
SQLite.Step (Statement);
SQLite.Finalize (Statement);
end Commit;
------------------
-- Constructors --
------------------
package body Constructors is
package Object_Constructor_Maps is
new Ada.Containers.Indefinite_Hashed_Maps
(String, Object_Constructor, Ada.Strings.Hash, "=");
Object_Constructors : Object_Constructor_Maps.Map;
------------
-- Create --
------------
function Create (Class_Name : String)
return not null Descriptor_Access
is
begin
return Object_Constructors.Element (Class_Name).all;
end Create;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Abstract_Proxy'Class;
Descriptor : not null access Abstract_Descriptor'Class)
is
begin
Descriptor.Reference;
Self.Descriptor := Descriptor_Access (Descriptor);
end Initialize;
--------------
-- Register --
--------------
procedure Register
(Class_Name : String;
Constructor : Object_Constructor)
is
begin
Object_Constructors.Insert (Class_Name, Constructor);
end Register;
end Constructors;
-----------------
-- Dereference --
-----------------
procedure Dereference (Self : not null access Abstract_Descriptor'Class) is
begin
if Matreshka.Internals.Atomics.Counters.Decrement
(Self.Counter'Access)
then
if not Self.Is_Modified then
-- XXX Object can be destroyed.
null;
-- Ada.Text_IO.Put_Line ("Destroy object");
else
null;
-- Ada.Text_IO.Put_Line
-- ("Object's destruction postponed until end of transaction");
end if;
end if;
end Dereference;
----------------
-- Descriptor --
----------------
function Descriptor (Self : Abstract_Proxy'Class)
return not null access Abstract_Descriptor'Class
is
begin
return Self.Descriptor;
end Descriptor;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Abstract_Proxy) is
begin
Self.Descriptor.Dereference;
end Finalize;
----------------
-- Identifier --
----------------
function Identifier (Self : not null access Abstract_Descriptor'Class)
return Positive
is
Statement : SQLite.SQLite_Statement_Access;
begin
if Self.Identifier = 0 then
-- Ada.Text_IO.Put_Line ("Assign object identifier");
-- XXX SQLite3: INSERT operation must be executed in critical
-- section.
SQLite.Prepare
(Database,
"INSERT INTO matreshka_object (class_identifier)"
& " VALUES ((SELECT class_identifier FROM matreshka_class"
& " WHERE class_name = ?1))",
Statement);
SQLite.Bind (Statement, 1, "Person");
SQLite.Step (Statement);
Self.Identifier := Positive (SQLite.Last_Insert_Row_Id (Database));
Self.Is_New := True;
Self.Is_Modified := True;
SQLite.Finalize (Statement);
end if;
return Self.Identifier;
end Identifier;
------------
-- Is_New --
------------
function Is_New (Self : not null access Abstract_Descriptor'Class)
return Boolean
is
begin
return Self.Is_New;
end Is_New;
----------
-- Load --
----------
function Load (Identifier : Positive) return not null Descriptor_Access is
Descriptor : Descriptor_Access;
Statement : SQLite.SQLite_Statement_Access;
begin
-- Resolve class name
SQLite.Prepare
(Database,
"SELECT class_name FROM matreshka_object NATURAL JOIN matreshka_class"
& " WHERE object_identifier = ?1",
Statement);
SQLite.Bind (Statement, 1, Identifier);
if not SQLite.Step (Statement) then
raise Program_Error;
end if;
Descriptor := Constructors.Create (SQLite.Column (Statement, 0));
Descriptor.Identifier := Identifier;
Descriptor.Load;
SQLite.Finalize (Statement);
return Descriptor;
end Load;
---------------
-- Reference --
---------------
procedure Reference (Self : not null access Abstract_Descriptor'Class) is
begin
Matreshka.Internals.Atomics.Counters.Increment (Self.Counter'Access);
end Reference;
--------------
-- Rollback --
--------------
procedure Rollback is
Statement : SQLite.SQLite_Statement_Access;
begin
SQLite.Prepare (Database, "ROLLBACK", Statement);
SQLite.Step (Statement);
SQLite.Finalize (Statement);
end Rollback;
------------------
-- Set_Modified --
------------------
procedure Set_Modified (Self : not null access Abstract_Descriptor'Class) is
begin
if not Self.Is_Modified then
Self.Is_Modified := True;
Modified.Append (Descriptor_Access (Self));
-- Ada.Text_IO.Put_Line ("Modified");
end if;
end Set_Modified;
-----------
-- Start --
-----------
procedure Start is
Statement : SQLite.SQLite_Statement_Access;
begin
SQLite.Prepare (Database, "BEGIN", Statement);
SQLite.Step (Statement);
SQLite.Finalize (Statement);
end Start;
begin
SQLite.Initialize;
SQLite.Open ("person.db", Database);
end Matreshka.Internals.Persistence_Manager;
|
skordal/databases | Ada | 519 | ads | -- Databases - A simple database library for Ada applications
-- (c) Kristian Klomsten Skordal 2019 <[email protected]>
-- Report bugs and issues on <https://github.com/skordal/databases/issues>
-- vim:ts=3:sw=3:et:si:sta
with Databases;
package Databases.Utilities is
-- Directly executes a statement and returns only the status:
function Execute (Database : in Databases.Database_Access; Statement : in String)
return Databases.Statement_Execution_Status;
end Databases.Utilities;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,466 | ads | -- This spec has been automatically generated from STM32F072x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces; use Interfaces;
with System;
-- STM32F072x
package STM32_SVD is
pragma Preelaborate;
---------------
-- Base type --
---------------
type UInt32 is new Interfaces.Unsigned_32;
type UInt16 is new Interfaces.Unsigned_16;
type Byte is new Interfaces.Unsigned_8;
type Bit is mod 2**1
with Size => 1;
type UInt2 is mod 2**2
with Size => 2;
type UInt3 is mod 2**3
with Size => 3;
type UInt4 is mod 2**4
with Size => 4;
type UInt5 is mod 2**5
with Size => 5;
type UInt6 is mod 2**6
with Size => 6;
type UInt7 is mod 2**7
with Size => 7;
type UInt9 is mod 2**9
with Size => 9;
type UInt10 is mod 2**10
with Size => 10;
type UInt11 is mod 2**11
with Size => 11;
type UInt12 is mod 2**12
with Size => 12;
type UInt13 is mod 2**13
with Size => 13;
type UInt14 is mod 2**14
with Size => 14;
type UInt15 is mod 2**15
with Size => 15;
type UInt17 is mod 2**17
with Size => 17;
type UInt18 is mod 2**18
with Size => 18;
type UInt19 is mod 2**19
with Size => 19;
type UInt20 is mod 2**20
with Size => 20;
type UInt21 is mod 2**21
with Size => 21;
type UInt22 is mod 2**22
with Size => 22;
type UInt23 is mod 2**23
with Size => 23;
type UInt24 is mod 2**24
with Size => 24;
type UInt25 is mod 2**25
with Size => 25;
type UInt26 is mod 2**26
with Size => 26;
type UInt27 is mod 2**27
with Size => 27;
type UInt28 is mod 2**28
with Size => 28;
type UInt29 is mod 2**29
with Size => 29;
type UInt30 is mod 2**30
with Size => 30;
type UInt31 is mod 2**31
with Size => 31;
--------------------
-- Base addresses --
--------------------
CRC_Base : constant System.Address :=
System'To_Address (16#40023000#);
GPIOF_Base : constant System.Address :=
System'To_Address (16#48001400#);
GPIOD_Base : constant System.Address :=
System'To_Address (16#48000C00#);
GPIOC_Base : constant System.Address :=
System'To_Address (16#48000800#);
GPIOB_Base : constant System.Address :=
System'To_Address (16#48000400#);
GPIOE_Base : constant System.Address :=
System'To_Address (16#48001000#);
GPIOA_Base : constant System.Address :=
System'To_Address (16#48000000#);
SPI1_Base : constant System.Address :=
System'To_Address (16#40013000#);
SPI2_Base : constant System.Address :=
System'To_Address (16#40003800#);
DAC_Base : constant System.Address :=
System'To_Address (16#40007400#);
PWR_Base : constant System.Address :=
System'To_Address (16#40007000#);
I2C1_Base : constant System.Address :=
System'To_Address (16#40005400#);
I2C2_Base : constant System.Address :=
System'To_Address (16#40005800#);
IWDG_Base : constant System.Address :=
System'To_Address (16#40003000#);
WWDG_Base : constant System.Address :=
System'To_Address (16#40002C00#);
TIM1_Base : constant System.Address :=
System'To_Address (16#40012C00#);
TIM2_Base : constant System.Address :=
System'To_Address (16#40000000#);
TIM3_Base : constant System.Address :=
System'To_Address (16#40000400#);
TIM14_Base : constant System.Address :=
System'To_Address (16#40002000#);
TIM6_Base : constant System.Address :=
System'To_Address (16#40001000#);
TIM7_Base : constant System.Address :=
System'To_Address (16#40001400#);
EXTI_Base : constant System.Address :=
System'To_Address (16#40010400#);
NVIC_Base : constant System.Address :=
System'To_Address (16#E000E100#);
DMA_Base : constant System.Address :=
System'To_Address (16#40020000#);
RCC_Base : constant System.Address :=
System'To_Address (16#40021000#);
SYSCFG_Base : constant System.Address :=
System'To_Address (16#40010000#);
ADC_Base : constant System.Address :=
System'To_Address (16#40012400#);
USART1_Base : constant System.Address :=
System'To_Address (16#40013800#);
USART2_Base : constant System.Address :=
System'To_Address (16#40004400#);
USART3_Base : constant System.Address :=
System'To_Address (16#40004800#);
USART4_Base : constant System.Address :=
System'To_Address (16#40004C00#);
COMP_Base : constant System.Address :=
System'To_Address (16#4001001C#);
RTC_Base : constant System.Address :=
System'To_Address (16#40002800#);
TIM15_Base : constant System.Address :=
System'To_Address (16#40014000#);
TIM16_Base : constant System.Address :=
System'To_Address (16#40014400#);
TIM17_Base : constant System.Address :=
System'To_Address (16#40014800#);
TSC_Base : constant System.Address :=
System'To_Address (16#40024000#);
CEC_Base : constant System.Address :=
System'To_Address (16#40007800#);
Flash_Base : constant System.Address :=
System'To_Address (16#40022000#);
DBGMCU_Base : constant System.Address :=
System'To_Address (16#40015800#);
USB_Base : constant System.Address :=
System'To_Address (16#40005C00#);
CRS_Base : constant System.Address :=
System'To_Address (16#40006C00#);
CAN_Base : constant System.Address :=
System'To_Address (16#40006400#);
end STM32_SVD;
|
optikos/oasis | Ada | 3,080 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Nodes.Null_Literals is
function Create
(Null_Literal_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Null_Literal is
begin
return Result : Null_Literal :=
(Null_Literal_Token => Null_Literal_Token, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
function Create
(Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Null_Literal is
begin
return Result : Implicit_Null_Literal :=
(Is_Part_Of_Implicit => Is_Part_Of_Implicit,
Is_Part_Of_Inherited => Is_Part_Of_Inherited,
Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null)
do
Initialize (Result);
end return;
end Create;
overriding function Null_Literal_Token
(Self : Null_Literal)
return not null Program.Lexical_Elements.Lexical_Element_Access is
begin
return Self.Null_Literal_Token;
end Null_Literal_Token;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Null_Literal)
return Boolean is
begin
return Self.Is_Part_Of_Implicit;
end Is_Part_Of_Implicit;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Null_Literal)
return Boolean is
begin
return Self.Is_Part_Of_Inherited;
end Is_Part_Of_Inherited;
overriding function Is_Part_Of_Instance
(Self : Implicit_Null_Literal)
return Boolean is
begin
return Self.Is_Part_Of_Instance;
end Is_Part_Of_Instance;
procedure Initialize (Self : aliased in out Base_Null_Literal'Class) is
begin
null;
end Initialize;
overriding function Is_Null_Literal_Element
(Self : Base_Null_Literal)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Null_Literal_Element;
overriding function Is_Expression_Element
(Self : Base_Null_Literal)
return Boolean is
pragma Unreferenced (Self);
begin
return True;
end Is_Expression_Element;
overriding procedure Visit
(Self : not null access Base_Null_Literal;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is
begin
Visitor.Null_Literal (Self);
end Visit;
overriding function To_Null_Literal_Text
(Self : aliased in out Null_Literal)
return Program.Elements.Null_Literals.Null_Literal_Text_Access is
begin
return Self'Unchecked_Access;
end To_Null_Literal_Text;
overriding function To_Null_Literal_Text
(Self : aliased in out Implicit_Null_Literal)
return Program.Elements.Null_Literals.Null_Literal_Text_Access is
pragma Unreferenced (Self);
begin
return null;
end To_Null_Literal_Text;
end Program.Nodes.Null_Literals;
|
aeszter/lox-spark | Ada | 16,455 | adb | with Ada.Containers; use Ada.Containers;
-- with Ada.Containers.Formal_Hashed_Maps;
with Tokens; use Tokens;
with L_Strings; use L_Strings;
package body Scanners with SPARK_Mode is
-- Note: Instantiation Formal_Hashed_Maps triggers a bug in
-- gnatprove, so we use a simpler and slower method
-- instead. Focus of this implementation is provability,
-- not performance (or even elegance).
--
-- package Hashed_Maps is new
-- Ada.Containers.Formal_Hashed_Maps (Key_Type => L_String,
-- Element_Type => Token_Kind,
-- Hash => Hash,
-- Equivalent_Keys => L_Strings."="
-- );
--
-- Keywords : Hashed_Maps.Map (Capacity => 20, Modulus => 97);
--
-- procedure Add_Keyword (Word : String; T : Token_Kind) with
-- Global => Keywords,
-- Pre => Hashed_Maps.Length (Keywords) < 20,
-- Post => Hashed_Maps.Length (Keywords) = Hashed_Maps.Length (Keywords)'Old + 1;
--
-- procedure Add_Keyword (Word : String; T : Token_Kind) is
-- begin
-- Hashed_Maps.Insert (Container => Keywords,
-- Key => L_Strings.To_Bounded_String (Word),
-- New_Item => T);
-- end Add_Keyword;
function Is_Alphanumeric (C : Character) return Boolean is
begin
if C in 'a' .. 'z' or else C in 'A' .. 'Z' or else C in '0' .. '9' then
return True;
else
return False;
end if;
end Is_Alphanumeric;
function Is_Decimal_Digit (C : Character) return Boolean is
begin
if C in '0' .. '9' then
return True;
else
return False;
end if;
end Is_Decimal_Digit;
function Is_Letter (C : Character) return Boolean is
begin
if C in 'a' .. 'z' or else C in 'A' .. 'Z' then
return True;
else
return False;
end if;
end Is_Letter;
procedure Scan_Tokens (Source : String; Token_List : in out Tokens.List) is
Start, Current : Natural;
Line : Positive := 1;
function Is_At_End return Boolean with
Global => (Input => (Current, Source)),
Post => (if Is_At_End'Result = False then Current <= Source'Last);
procedure Scan_Token with
Global => (Input => (Source, Start),
in_out => (Current, Line, Token_List, SPARK.Text_IO.Standard_Error, Error_Reporter.State)),
Pre => Source'First <= Start and then Start <= Current and then Current <= Source'Last and then Source'Last < Integer'Last,
Post => Current >= Current'Old;
function Is_At_End return Boolean is
begin
return Current > Source'Last;
end Is_At_End;
procedure Scan_Token is
procedure Add_Token (Kind : Token_Kind) with
Global => (input => (Start, Current, Source, Line),
in_out => (Error_Reporter.State, SPARK.Text_IO.Standard_Error, Token_List)),
Pre => Source'First <= Start and then Start < Current and then Current - 1 <= Source'Last;
procedure Add_Token (Kind : Token_Kind; Lexeme : String) with
Global => (input => (Line),
in_out => (Error_Reporter.State, SPARK.Text_IO.Standard_Error, Token_List));
procedure Advance (C : out Character) with
Global => (Input => Source, In_Out => Current),
Pre => Current >= Source'First and then
Current <= Source'Last and then
Current < Integer'Last,
Post => Current = Current'Old + 1;
procedure Ignore with
Global => (Input => Source, In_Out => Current),
Pre => Current >= Source'First and then
Current <= Source'Last and then
Current < Integer'Last,
Post => Current = Current'Old + 1;
procedure Advance_If_Match (Expected : Character; Match : out Boolean) with
Global => (in_out => Current, Input => Source),
Pre => Source'First <= Current and then Source'Last < Integer'Last,
Post => (if Match then
(Current - 1 <= Source'Last and then Current = Current'Old + 1)
else
Current = Current'Old);
function Peek return Character with
Global => (Input => (Current, Source)),
Pre => Current >= Source'First,
Post => (if Peek'Result /= NUL then Current <= Source'Last);
function Peek_Next return Character with
Pre => Current >= Source'First and then Current < Integer'Last;
procedure Scan_Identifier with
Pre => Source'First <= Start and then Start < Current and then
Current - 1 <= Source'Last and then Source'Last < Integer'Last,
Post => Current >= Current'Old;
procedure Scan_Number with
Pre => Source'First <= Start and then Start < Current and then
Current - 1 <= Source'Last and then Source'Last < Integer'Last,
Post => Current >= Current'Old;
procedure Scan_String with
Global => (Input => (Source, Start),
in_out => (Current, Line, Token_List, SPARK.Text_IO.Standard_Error, Error_Reporter.State)),
Pre => Source'First <= Start and then Start < Current and then Source'Last < Integer'Last,
Post => Current >= Current'Old;
procedure Add_Token (Kind : Token_Kind) is
begin
Add_Token (Kind, Source (Start .. Current - 1));
end Add_Token;
procedure Add_Token (Kind : Token_Kind; Lexeme : String) is
use Tokens.Lists;
begin
if Length (Token_List) >= Token_List.Capacity then
Error_Reporter.Error (Line_No => Line,
Message => "Out of token capacity");
return;
end if;
Append (Container => Token_List,
New_Item => Tokens.New_Token (Kind => Kind,
Lexeme => Lexeme,
Line => Line));
end Add_Token;
procedure Advance (C : out Character) is
begin
Current := Current + 1;
C := Source (Current - 1);
end Advance;
procedure Advance_If_Match (Expected : Character; Match : out Boolean) is
begin
if Is_At_End then
Match := False;
elsif Source (Current) /= Expected then
Match := False;
else
Current := Current + 1;
Match := True;
end if;
end Advance_If_Match;
procedure Ignore is
begin
Current := Current + 1;
end Ignore;
function Peek return Character is
begin
if Is_At_End then
return NUL;
else
return Source (Current);
end if;
end Peek;
function Peek_Next return Character is
begin
if Current + 1 > Source'Last then
return NUL;
else
return Source (Current + 1);
end if;
end Peek_Next;
procedure Scan_Identifier is
-- use Hashed_Maps;
begin
while Is_Alphanumeric (Peek)
or else Peek = '_' loop
pragma Loop_Invariant (Start <= Current);
pragma Loop_Invariant (Source'First <= Current and then Current <= Source'Last);
pragma Loop_Invariant (Start = Start'Loop_Entry);
pragma Loop_Invariant (Current >= Current'Loop_Entry);
Ignore;
end loop;
declare
Text : constant L_String := L_Strings.To_Bounded_String (Source (Start .. Current - 1));
begin
-- if Contains (Keywords, Text) then
-- Add_Token (Element (Keywords, Text));
if Text = "and" then
Add_Token (T_AND);
elsif Text = "class" then
Add_Token (T_CLASS);
elsif Text = "else" then
Add_Token (T_ELSE);
elsif Text = "false" then
Add_Token (T_FALSE);
elsif Text = "for" then
Add_Token (T_FOR);
elsif Text = "fun" then
Add_Token (T_FUN);
elsif Text = "if" then
Add_Token (T_IF);
elsif Text = "nil" then
Add_Token (T_NIL);
elsif Text = "or" then
Add_Token (T_OR);
elsif Text = "print" then
Add_Token (T_PRINT);
elsif Text = "return" then
Add_Token (T_RETURN);
elsif Text = "super" then
Add_Token (T_SUPER);
elsif Text = "this" then
Add_Token (T_THIS);
elsif Text = "true" then
Add_Token (T_TRUE);
elsif Text = "var" then
Add_Token (T_VAR);
elsif Text = "while" then
Add_Token (T_WHILE);
else
Add_Token (T_IDENTIFIER);
end if;
end;
end Scan_Identifier;
procedure Scan_Number is
begin
while Is_Decimal_Digit (Peek) loop
pragma Loop_Invariant (Start <= Current);
pragma Loop_Invariant (Source'First <= Current and then Current <= Source'Last);
pragma Loop_Invariant (Start = Start'Loop_Entry);
pragma Loop_Invariant (Current >= Current'Loop_Entry);
Ignore;
end loop;
-- look for a fractional part
if Peek = '.' and then Is_Decimal_Digit (Peek_Next) then
-- consume the '.'
Ignore;
while Is_Decimal_Digit (Peek) loop
pragma Loop_Invariant (Start <= Current);
pragma Loop_Invariant (Source'First <= Current and then Current <= Source'Last);
pragma Loop_Invariant (Start = Start'Loop_Entry);
pragma Loop_Invariant (Current >= Current'Loop_Entry);
Ignore;
end loop;
end if;
-- Our Add_Token only takes strings, so, like Ivan, leave out
-- the value for now.
-- Add_Token (T_NUMBER, Float'Value (Source (Start .. Current)));
Add_Token (T_NUMBER);
end Scan_Number;
procedure Scan_String is
begin
while not Is_At_End and then Peek /= '"'loop
pragma Loop_Invariant (Source'First <= Current and then Current <= Source'Last);
pragma Loop_Invariant (Current >= Current'Loop_Entry);
if Peek = LF then
if Line < Integer'Last then
Line := Line + 1;
else
Error_Reporter.Error (Line_No => Line,
Message => "Too many lines of source code");
end if;
end if;
Ignore;
end loop;
-- unterminated string
if Is_At_End then
Error_Reporter.Error (Line, "Unterminated string.");
return;
end if;
-- the closing "
Ignore;
-- trim the surrounding quotes
Add_Token (T_STRING, Source (Start + 1 .. Current - 1));
end Scan_String;
C : Character;
Match : Boolean;
begin
Advance (C);
case C is
when '(' => Add_Token (T_LEFT_PAREN);
when ')' => Add_Token (T_RIGHT_PAREN);
when '{' => Add_Token (T_LEFT_BRACE);
when '}' => Add_Token (T_RIGHT_BRACE);
when ',' => Add_Token (T_COMMA);
when '.' => Add_Token (T_DOT);
when '-' => Add_Token (T_MINUS);
when '+' => Add_Token (T_PLUS);
when ';' => Add_Token (T_SEMICOLON);
when '*' => Add_Token (T_STAR);
when '!' =>
Advance_If_Match (Expected => '=',
Match => Match);
if Match then
Add_Token (T_BANG_EQUAL);
else
Add_Token (T_BANG);
end if;
when '=' =>
Advance_If_Match (Expected => '=',
Match => Match);
if Match then
Add_Token (T_EQUAL_EQUAL);
else
Add_Token (T_EQUAL);
end if;
when '<' =>
Advance_If_Match (Expected => '=',
Match => Match);
if Match then
Add_Token (T_LESS_EQUAL);
else
Add_Token (T_LESS);
end if;
when '>' =>
Advance_If_Match (Expected => '=',
Match => Match);
if Match then
Add_Token (T_GREATER_EQUAL);
else
Add_Token (T_GREATER);
end if;
when '/' =>
Advance_If_Match (Expected => '/',
Match => Match);
if Match then
while Peek /= LF and then not Is_At_End loop
pragma Loop_Invariant (Source'First <= Current and then Current <= Source'Last);
pragma Loop_Invariant (Current >= Current'Loop_Entry);
Current := Current + 1;
end loop;
else
Add_Token (T_SLASH);
end if;
when ' ' | CR | HT =>
null;
when LF =>
if Line < Integer'Last then
Line := Line + 1;
else
Error_Reporter.Error (Line_No => Line,
Message => "Too many lines of source code");
end if;
when '"' =>
Scan_String;
when others =>
if Is_Decimal_Digit (C) then
Scan_Number;
elsif Is_Letter (C) then
Scan_Identifier;
else
Error_Reporter.Error (Line, "Unexpected character.");
end if;
end case;
end Scan_Token;
begin
Tokens.Lists.Clear (Token_List);
Current := Source'First;
while not Is_At_End loop
Start := Current;
pragma Loop_Invariant (Source'First <= Start);
pragma Loop_Invariant (Start <= Current);
pragma Loop_Invariant (Current <= Source'Last);
pragma Assert (Source'First <= Start);
pragma Assert (Current <= Source'Last);
pragma Assert (Source'Last < Integer'Last);
Scan_Token;
end loop;
if Tokens.Lists.Length (Token_List) >= Token_List.Capacity then
Error_Reporter.Error (Line_No => Line,
Message => "Out of token capacity");
else
Tokens.Lists.Append (Container => Token_List,
New_Item => Tokens.New_Token (Kind => Tokens.T_EOF,
Lexeme => "",
Line => Line));
end if;
end Scan_Tokens;
begin
-- Add_Keyword ("and", T_AND);
-- Add_Keyword ("class", T_CLASS);
-- Add_Keyword ("else", T_ELSE);
-- Add_Keyword ("false", T_FALSE);
-- Add_Keyword ("for", T_FOR);
-- Add_Keyword ("fun", T_FUN);
-- Add_Keyword ("if", T_IF);
-- Add_Keyword ("nil", T_NIL);
-- Add_Keyword ("or", T_OR);
-- Add_Keyword ("print", T_PRINT);
-- Add_Keyword ("return", T_RETURN);
-- Add_Keyword ("super", T_SUPER);
-- Add_Keyword ("this", T_THIS);
-- Add_Keyword ("true", T_TRUE);
-- Add_Keyword ("var", T_VAR);
-- Add_Keyword ("while", T_WHILE);
null;
end Scanners;
|
zhmu/ananas | Ada | 6,246 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 1 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-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 System.Storage_Elements;
with System.Unsigned_Types;
package body System.Pack_11 is
subtype Bit_Order is System.Bit_Order;
Reverse_Bit_Order : constant Bit_Order :=
Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order));
subtype Ofs is System.Storage_Elements.Storage_Offset;
subtype Uns is System.Unsigned_Types.Unsigned;
subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
use type System.Storage_Elements.Storage_Offset;
use type System.Unsigned_Types.Unsigned;
type Cluster is record
E0, E1, E2, E3, E4, E5, E6, E7 : Bits_11;
end record;
for Cluster use record
E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
end record;
for Cluster'Size use Bits * 8;
for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
1 +
1 * Boolean'Pos (Bits mod 2 = 0) +
2 * Boolean'Pos (Bits mod 4 = 0));
-- Use maximum possible alignment, given the bit field size, since this
-- will result in the most efficient code possible for the field.
type Cluster_Ref is access Cluster;
type Rev_Cluster is new Cluster
with Bit_Order => Reverse_Bit_Order,
Scalar_Storage_Order => Reverse_Bit_Order;
type Rev_Cluster_Ref is access Rev_Cluster;
------------
-- Get_11 --
------------
function Get_11
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_11
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => return RC.E0;
when 1 => return RC.E1;
when 2 => return RC.E2;
when 3 => return RC.E3;
when 4 => return RC.E4;
when 5 => return RC.E5;
when 6 => return RC.E6;
when 7 => return RC.E7;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => return C.E0;
when 1 => return C.E1;
when 2 => return C.E2;
when 3 => return C.E3;
when 4 => return C.E4;
when 5 => return C.E5;
when 6 => return C.E6;
when 7 => return C.E7;
end case;
end if;
end Get_11;
------------
-- Set_11 --
------------
procedure Set_11
(Arr : System.Address;
N : Natural;
E : Bits_11;
Rev_SSO : Boolean)
is
A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8);
C : Cluster_Ref with Address => A'Address, Import;
RC : Rev_Cluster_Ref with Address => A'Address, Import;
begin
if Rev_SSO then
case N07 (Uns (N) mod 8) is
when 0 => RC.E0 := E;
when 1 => RC.E1 := E;
when 2 => RC.E2 := E;
when 3 => RC.E3 := E;
when 4 => RC.E4 := E;
when 5 => RC.E5 := E;
when 6 => RC.E6 := E;
when 7 => RC.E7 := E;
end case;
else
case N07 (Uns (N) mod 8) is
when 0 => C.E0 := E;
when 1 => C.E1 := E;
when 2 => C.E2 := E;
when 3 => C.E3 := E;
when 4 => C.E4 := E;
when 5 => C.E5 := E;
when 6 => C.E6 := E;
when 7 => C.E7 := E;
end case;
end if;
end Set_11;
end System.Pack_11;
|
reznikmm/matreshka | Ada | 4,621 | 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.Keep_With_Next_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Fo_Keep_With_Next_Attribute_Node is
begin
return Self : Fo_Keep_With_Next_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_Keep_With_Next_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Keep_With_Next_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Fo_URI,
Matreshka.ODF_String_Constants.Keep_With_Next_Attribute,
Fo_Keep_With_Next_Attribute_Node'Tag);
end Matreshka.ODF_Fo.Keep_With_Next_Attributes;
|
reznikmm/matreshka | Ada | 20,379 | adb |
-- Module : string_scanner.ada
-- Component of : common_library
-- Version : 1.2
-- Date : 11/21/86 16:36:26
-- SCCS File : disk21~/rschm/hasee/sccs/common_library/sccs/sxstring_scanner.ada
with String_Pkg; use String_Pkg;
with Unchecked_Deallocation;
package body String_Scanner is
SCCS_ID : constant String := "@(#) string_scanner.ada, Version 1.2";
White_Space : constant string := " " & ASCII.HT;
Number_1 : constant string := "0123456789";
Number : constant string := Number_1 & "_";
Quote : constant string := """";
Ada_Id_1 : constant string := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
Ada_Id : constant string := Ada_Id_1 & Number;
procedure Free_Scanner is
new Unchecked_Deallocation(Scan_Record, Scanner);
pragma Page;
function Is_Valid(
T : in Scanner
) return boolean is
begin
return T /= null;
end Is_Valid;
function Make_Scanner(
S : in String_Type
) return Scanner is
T : Scanner := new Scan_Record;
begin
T.text := String_Pkg.Make_Persistent(S);
return T;
end Make_Scanner;
----------------------------------------------------------------
procedure Destroy_Scanner(
T : in out Scanner
) is
begin
if Is_Valid(T) then
String_Pkg.Flush(T.text);
Free_Scanner(T);
end if;
end Destroy_Scanner;
----------------------------------------------------------------
function More(
T : in Scanner
) return boolean is
begin
if Is_Valid(T) then
if T.index > String_Pkg.Length(T.text) then
return false;
else
return true;
end if;
else
return false;
end if;
end More;
----------------------------------------------------------------
function Get(
T : in Scanner
) return character is
begin
if not More(T) then
raise Out_Of_Bounds;
end if;
return String_Pkg.Fetch(T.text, T.index);
end Get;
----------------------------------------------------------------
procedure Forward(
T : in Scanner
) is
begin
if Is_Valid(T) then
if String_Pkg.Length(T.text) >= T.index then
T.index := T.index + 1;
end if;
end if;
end Forward;
----------------------------------------------------------------
procedure Backward(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.index > 1 then
T.index := T.index - 1;
end if;
end if;
end Backward;
----------------------------------------------------------------
procedure Next(
T : in Scanner;
C : out character
) is
begin
C := Get(T);
Forward(T);
end Next;
----------------------------------------------------------------
function Position(
T : in Scanner
) return positive is
begin
if not More(T) then
raise Out_Of_Bounds;
end if;
return T.index;
end Position;
----------------------------------------------------------------
function Get_String(
T : in Scanner
) return String_Type is
begin
if Is_Valid(T) then
return String_Pkg.Make_Persistent(T.text);
else
return String_Pkg.Make_Persistent("");
end if;
end Get_String;
----------------------------------------------------------------
function Get_Remainder(
T : in Scanner
) return String_Type is
S_Str : String_Type;
begin
if More(T) then
String_Pkg.Mark;
S_Str := String_Pkg.Make_Persistent(
String_Pkg.Substr(T.text,
T.index,
String_Pkg.Length(T.text) - T.index + 1));
String_Pkg.Release;
else
S_Str := String_Pkg.Make_Persistent("");
end if;
return S_Str;
end Get_Remainder;
----------------------------------------------------------------
procedure Mark(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.mark /= 0 then
raise Scanner_Already_Marked;
else
T.mark := T.index;
end if;
end if;
end Mark;
----------------------------------------------------------------
procedure Restore(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.mark /= 0 then
T.index := T.mark;
T.mark := 0;
end if;
end if;
end Restore;
pragma Page;
function Is_Any(
T : in Scanner;
Q : in string
) return boolean is
N : natural;
begin
if not More(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Q, T.index);
if N /= T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Any;
pragma Page;
procedure Scan_Any(
T : in Scanner;
Q : in string;
Found : out boolean;
Result : in out String_Type
) is
S_Str : String_Type;
N : natural;
begin
if Is_Any(T, Q) then
N := String_Pkg.Match_None(T.text, Q, T.index);
if N = 0 then
N := String_Pkg.Length(T.text) + 1;
end if;
Result := Result & String_Pkg.Substr(T.text, T.index, N - T.index);
T.index := N;
Found := true;
else
Found := false;
end if;
end Scan_Any;
pragma Page;
function Quoted_String(
T : in Scanner
) return integer is
Count : integer := 0;
I : positive;
N : natural;
begin
if not Is_Valid(T) then
return Count;
end if;
I := T.index;
while Is_Any(T, """") loop
T.index := T.index + 1;
if not More(T) then
T.index := I;
return 0;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, """", T.index);
String_Pkg.Release;
if N = 0 then
T.index := I;
return 0;
end if;
T.index := N + 1;
end loop;
Count := T.index - I;
T.index := I;
return Count;
end Quoted_String;
pragma Page;
function Enclosed_String(
B : in character;
E : in character;
T : in Scanner
) return natural is
Count : natural := 1;
I : positive;
Inx_B : natural;
Inx_E : natural;
Depth : natural := 1;
begin
if not Is_Any(T, B & "") then
return 0;
end if;
I := T.index;
Forward(T);
while Depth /= 0 loop
if not More(T) then
T.index := I;
return 0;
end if;
String_Pkg.Mark;
Inx_B := String_Pkg.Match_Any(T.text, B & "", T.index);
Inx_E := String_Pkg.Match_Any(T.text, E & "", T.index);
String_Pkg.Release;
if Inx_E = 0 then
T.index := I;
return 0;
end if;
if Inx_B /= 0 and then Inx_B < Inx_E then
Depth := Depth + 1;
else
Inx_B := Inx_E;
Depth := Depth - 1;
end if;
T.index := Inx_B + 1;
end loop;
Count := T.index - I;
T.index := I;
return Count;
end Enclosed_String;
pragma Page;
function Is_Word(
T : in Scanner
) return boolean is
begin
if not More(T) then
return false;
else
return not Is_Any(T, White_Space);
end if;
end Is_Word;
----------------------------------------------------------------
procedure Scan_Word(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
S_Str : String_Type;
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Word(T) then
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, White_Space, T.index);
if N = 0 then
N := String_Pkg.Length(T.text) + 1;
end if;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
return;
end Scan_Word;
pragma Page;
function Is_Number(
T : in Scanner
) return boolean is
begin
return Is_Any(T, Number_1);
end Is_Number;
----------------------------------------------------------------
procedure Scan_Number(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if not Is_Number(T) then
Found := false;
return;
end if;
String_Pkg.Mark;
while Is_Number(T) loop
Scan_Any(T, Number_1, Found, S_Str);
if More(T) then
C := Get(T);
if C = '_' then
Forward(T);
if Is_Number(T) then
S_Str := S_Str & "_";
else
Backward(T);
end if;
end if;
end if;
end loop;
Result := String_Pkg.Make_Persistent(S_Str);
String_Pkg.Release;
end Scan_Number;
----------------------------------------------------------------
procedure Scan_Number(
T : in Scanner;
Found : out boolean;
Result : out integer;
Skip : in boolean := false
) is
F : boolean;
S_Str : String_Type;
begin
Scan_Number(T, F, S_Str, Skip);
if F then
Result := integer'value(String_Pkg.Value(S_Str));
end if;
Found := F;
end Scan_Number;
pragma Page;
function Is_Signed_Number(
T : in Scanner
) return boolean is
I : positive;
C : character;
F : boolean;
begin
if More(T) then
I := T.index;
C := Get(T);
if C = '+' or C = '-' then
T.index := T.index + 1;
end if;
F := Is_Any(T, Number_1);
T.index := I;
return F;
else
return false;
end if;
end Is_Signed_Number;
----------------------------------------------------------------
procedure Scan_Signed_Number(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Signed_Number(T) then
C := Get(T);
if C = '+' or C = '-' then
Forward(T);
end if;
Scan_Number(T, Found, S_Str);
String_Pkg.Mark;
if C = '+' or C = '-' then
Result := String_Pkg.Make_Persistent(("" & C) & S_Str);
else
Result := String_Pkg.Make_Persistent(S_Str);
end if;
String_Pkg.Release;
String_Pkg.Flush(S_Str);
else
Found := false;
end if;
end Scan_Signed_Number;
----------------------------------------------------------------
procedure Scan_Signed_Number(
T : in Scanner;
Found : out boolean;
Result : out integer;
Skip : in boolean := false
) is
F : boolean;
S_Str : String_Type;
begin
Scan_Signed_Number(T, F, S_Str, Skip);
if F then
Result := integer'value(String_Pkg.Value(S_Str));
end if;
Found := F;
end Scan_Signed_Number;
pragma Page;
function Is_Space(
T : in Scanner
) return boolean is
begin
return Is_Any(T, White_Space);
end Is_Space;
----------------------------------------------------------------
procedure Scan_Space(
T : in Scanner;
Found : out boolean;
Result : out String_Type
) is
S_Str : String_Type;
begin
String_Pkg.Mark;
Scan_Any(T, White_Space, Found, S_Str);
Result := String_Pkg.Make_Persistent(S_Str);
String_Pkg.Release;
end Scan_Space;
----------------------------------------------------------------
procedure Skip_Space(
T : in Scanner
) is
S_Str : String_Type;
Found : boolean;
begin
String_Pkg.Mark;
Scan_Any(T, White_Space, Found, S_Str);
String_Pkg.Release;
end Skip_Space;
pragma Page;
function Is_Ada_Id(
T : in Scanner
) return boolean is
begin
return Is_Any(T, Ada_Id_1);
end Is_Ada_Id;
----------------------------------------------------------------
procedure Scan_Ada_Id(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
F : boolean;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Ada_Id(T) then
String_Pkg.Mark;
Next(T, C);
Scan_Any(T, Ada_Id, F, S_Str);
Result := String_Pkg.Make_Persistent(("" & C) & S_Str);
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Ada_Id;
pragma Page;
function Is_Quoted(
T : in Scanner
) return boolean is
begin
if Quoted_String(T) = 0 then
return false;
else
return true;
end if;
end Is_Quoted;
----------------------------------------------------------------
procedure Scan_Quoted(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
Count : integer;
begin
if Skip then
Skip_Space(T);
end if;
Count := Quoted_String(T);
if Count /= 0 then
Count := Count - 2;
T.index := T.index + 1;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, positive(Count)));
String_Pkg.Release;
else
Result := String_Pkg.Make_Persistent("");
end if;
T.index := T.index + Count + 1;
Found := true;
else
Found := false;
end if;
end Scan_Quoted;
pragma Page;
function Is_Enclosed(
B : in character;
E : in character;
T : in Scanner
) return boolean is
begin
if Enclosed_String(B, E, T) = 0 then
return false;
else
return true;
end if;
end Is_Enclosed;
----------------------------------------------------------------
procedure Scan_Enclosed(
B : in character;
E : in character;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
Count : natural;
begin
if Skip then
Skip_Space(T);
end if;
Count := Enclosed_String(B, E, T);
if Count /= 0 then
Count := Count - 2;
T.index := T.index + 1;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent(String_Pkg.Substr(T.text, T.index, positive(Count)));
String_Pkg.Release;
else
Result := String_Pkg.Make_Persistent("");
end if;
T.index := T.index + Count + 1;
Found := true;
else
Found := false;
end if;
end Scan_Enclosed;
pragma Page;
function Is_Sequence(
Chars : in String_Type;
T : in Scanner
) return boolean is
begin
return Is_Any(T, String_Pkg.Value(Chars));
end Is_Sequence;
----------------------------------------------------------------
function Is_Sequence(
Chars : in string;
T : in Scanner
) return boolean is
begin
return Is_Any(T, Chars);
end Is_Sequence;
----------------------------------------------------------------
procedure Scan_Sequence(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
I : positive;
Count : integer := 0;
begin
if Skip then
Skip_Space(T);
end if;
if not Is_Valid(T) then
Found := false;
return;
end if;
I := T.index;
while Is_Any(T, Value(Chars)) loop
Forward(T);
Count := Count + 1;
end loop;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, I, positive(Count)));
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Sequence;
----------------------------------------------------------------
procedure Scan_Sequence(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
String_Pkg.Mark;
Scan_Sequence(String_Pkg.Create(Chars), T, Found, Result, Skip);
String_Pkg.Release;
end Scan_Sequence;
pragma Page;
function Is_Not_Sequence(
Chars : in String_Type;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Chars, T.index);
if N = T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Not_Sequence;
----------------------------------------------------------------
function Is_Not_Sequence(
Chars : in string;
T : in Scanner
) return boolean is
begin
return Is_Not_Sequence(String_Pkg.Create(Chars), T);
end Is_Not_Sequence;
----------------------------------------------------------------
procedure Scan_Not_Sequence(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Not_Sequence(Chars, T) then
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Chars, T.index);
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Not_Sequence;
----------------------------------------------------------------
procedure Scan_Not_Sequence(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
Scan_Not_Sequence(String_Pkg.Value(Chars), T, Found, Result, Skip);
end Scan_Not_Sequence;
pragma Page;
function Is_Literal(
Chars : in String_Type;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
if N /= T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Literal;
----------------------------------------------------------------
function Is_Literal(
Chars : in string;
T : in Scanner
) return boolean is
Found : boolean;
begin
String_Pkg.Mark;
Found := Is_Literal(String_Pkg.Create(Chars), T);
String_Pkg.Release;
return Found;
end Is_Literal;
----------------------------------------------------------------
procedure Scan_Literal(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Skip : in boolean := false
) is
begin
if Skip then
Skip_Space(T);
end if;
if Is_Literal(Chars, T) then
T.index := T.index + String_Pkg.Length(Chars);
Found := true;
else
Found := false;
end if;
end Scan_Literal;
----------------------------------------------------------------
procedure Scan_Literal(
Chars : in string;
T : in Scanner;
Found : out boolean;
Skip : in boolean := false
) is
begin
String_Pkg.Mark;
Scan_Literal(String_Pkg.Create(Chars), T, Found, Skip);
String_Pkg.Release;
end Scan_Literal;
pragma Page;
function Is_Not_Literal(
Chars : in string;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
if N = T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Not_Literal;
----------------------------------------------------------------
function Is_Not_Literal(
Chars : in String_Type;
T : in Scanner
) return boolean is
begin
if not More(T) then
return false;
end if;
return Is_Not_Literal(String_Pkg.Value(Chars), T);
end Is_Not_Literal;
----------------------------------------------------------------
procedure Scan_Not_Literal(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Not_Literal(Chars, T) then
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
Result := String_Pkg.Make_Persistent(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
return;
end if;
end Scan_Not_Literal;
----------------------------------------------------------------
procedure Scan_Not_Literal(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
Scan_Not_Literal(String_Pkg.Value(Chars), T, Found, Result, Skip);
end Scan_Not_Literal;
end String_Scanner;
pragma Page;
|
jwarwick/aoc_2020 | Ada | 731 | ads | -- AOC 2020, Day 13
with Ada.Containers.Vectors;
package Day is
type Schedule is private;
function load_file(filename : in String) return Schedule;
function bus_mult(s : in Schedule) return Long_Long_Integer;
function earliest_matching(s : in Schedule) return Long_Long_Integer;
function earliest_matching_iterative(s : in Schedule) return Long_Long_Integer;
private
package Depart_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Long_Long_Integer);
use Depart_Vectors;
type Schedule is record
earliest : Long_Long_Integer := 0;
departures : Depart_Vectors.Vector := Empty_Vector;
offsets : Depart_Vectors.Vector := Empty_Vector;
end record;
end Day;
|
reznikmm/matreshka | Ada | 3,642 | 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.Instance_Specifications.Hash is
new AMF.Elements.Generic_Hash (UML_Instance_Specification, UML_Instance_Specification_Access);
|
zhmu/ananas | Ada | 444 | adb | -- { dg-do run }
-- { dg-options "-gnatws" }
procedure Alignment9 is
type Kind is (Small, Large);
for Kind'Size use 8;
type Header is
record
K : Kind;
I : Integer;
end record;
for Header use
record
K at 4 range 0..7;
I at 0 range 0..31;
end record;
for Header'Size use 5*8;
for Header'Alignment use 1;
H : Header;
begin
if H'Size /= 40 then
raise Program_Error;
end if;
end;
|
optikos/oasis | Ada | 1,477 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
with Program.Elements.Array_Component_Associations;
package Program.Elements.Array_Aggregates is
pragma Pure (Program.Elements.Array_Aggregates);
type Array_Aggregate is
limited interface and Program.Elements.Expressions.Expression;
type Array_Aggregate_Access is access all Array_Aggregate'Class
with Storage_Size => 0;
not overriding function Components
(Self : Array_Aggregate)
return Program.Elements.Array_Component_Associations
.Array_Component_Association_Vector_Access is abstract;
type Array_Aggregate_Text is limited interface;
type Array_Aggregate_Text_Access is access all Array_Aggregate_Text'Class
with Storage_Size => 0;
not overriding function To_Array_Aggregate_Text
(Self : aliased in out Array_Aggregate)
return Array_Aggregate_Text_Access is abstract;
not overriding function Left_Bracket_Token
(Self : Array_Aggregate_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Array_Aggregate_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Array_Aggregates;
|
reznikmm/matreshka | Ada | 4,304 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools 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$
------------------------------------------------------------------------------
-- This test detects whether valgrind is installed on system.
--
-- It sets following substitution variables:
-- - HAS_VALGRIND
------------------------------------------------------------------------------
with Configure.Abstract_Tests;
package Configure.Tests.Valgrind is
type Valgrind_Test is
new Configure.Abstract_Tests.Abstract_Test with private;
overriding function Name (Self : Valgrind_Test) return String;
-- Returns name of the test to be used in reports.
overriding function Help
(Self : Valgrind_Test) return Unbounded_String_Vector;
-- Returns help information for test.
overriding procedure Execute
(Self : in out Valgrind_Test;
Arguments : in out Unbounded_String_Vector);
-- Executes test's actions. All used arguments must be removed from
-- Arguments.
private
type Valgrind_Test is
new Configure.Abstract_Tests.Abstract_Test with null record;
end Configure.Tests.Valgrind;
|
wiremoons/cputemp | Ada | 3,492 | adb | -------------------------------------------------------------------------------
-- Package : Get_Linux --
-- Description : Find the Linus distro name and version being executing on. --
-- Author : Simon Rowe <[email protected]> --
-- License : MIT Open Source. --
-------------------------------------------------------------------------------
with Ada.Directories;
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps; use Ada.Strings.Maps;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
package body Get_Linux is
-- Linux disros using 'systemd' are required to have the file:
OS_Release_File : constant String := "/etc/os-release";
F : File_Type;
---------------------------------------
-- Check if the OS is a Linux distro
---------------------------------------
function Is_Linux return Boolean is
begin
if Ada.Directories.Exists (OS_Release_File) then
return True;
else
return False;
end if;
end Is_Linux;
-----------------------------------------------
-- Clean up the 'PRETTY_NAME' and extract text
-----------------------------------------------
procedure Clean_Pretty_Name (OS_Name : in out Unbounded_String) is
Quote_Char : constant Character_Set := To_Set ('"'); --\""
begin
if Length (OS_Name) > 0 then
-- delete up to character '=' in string
Delete (OS_Name, 1, Index (OS_Name, "="));
-- trim off quotes
Trim (OS_Name, Quote_Char, Quote_Char);
end if;
end Clean_Pretty_Name;
----------------------------------------
-- Get the OS Linux distro 'PRETTY_NAME'
----------------------------------------
function Get_Linux_OS return String is
OS_Name : Unbounded_String := Null_Unbounded_String;
begin
if Ada.Directories.Exists (OS_Release_File) then
Open (F, In_File, OS_Release_File);
while not End_Of_File (F) loop
declare
Line : constant String := Get_Line (F);
begin
if Ada.Strings.Fixed.Count (Line, "PRETTY_NAME") > 0 then
-- get the identified line from the file
OS_Name := To_Unbounded_String (Line);
pragma Debug (Put_Line (Standard_Error, "DEBUG: Unmodified: " & OS_Name));
-- extract the part required
Clean_Pretty_Name (OS_Name);
pragma Debug (Put_Line (Standard_Error, "DEBUG: Cleaned up: " & OS_Name));
end if;
end;
end loop;
-- return the extracted distro text
return To_String (OS_Name);
else
New_Line (2);
Put_Line (Standard_Error, "ERROR: unable to locate file:");
Put_Line (Standard_Error, " - " & OS_Release_File);
New_Line (1);
return "UNKNOWN LINUX OS";
end if;
exception
when Name_Error =>
New_Line (2);
Put_Line (Standard_Error, "ERROR: file not found exception!");
return "UNKNOWN LINUX OS";
when others =>
New_Line (2);
Put_Line (Standard_Error, "ERROR: unknown exception!");
return "UNKNOWN LINUX OS";
end Get_Linux_OS;
end Get_Linux;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.