repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
zhmu/ananas | Ada | 230 | ads | with Root.Level_1;
package Root.Level_2 is
type Level_2_Type (First : Natural;
Second : Natural) is new
Level_1.Level_1_Type (First => First, Second => Second) with null record;
end Root.Level_2;
|
riccardo-bernardini/eugen | Ada | 381 | ads | with Ada.Containers.Indefinite_Vectors;
package Tokenize.Token_Vectors is
package String_Vectors is
new Ada.Containers.Indefinite_Vectors (Index_Type => Positive,
Element_Type => String);
subtype Vector is String_Vectors.Vector;
function To_Vector (X : Token_Array) return Vector;
end Tokenize.Token_Vectors;
|
stcarrez/ada-asf | Ada | 6,617 | ads | -----------------------------------------------------------------------
-- asf-factory -- Component and tag factory
-- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2018, 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 ASF.Views.Nodes;
with ASF.Converters;
with ASF.Validators;
with EL.Objects;
private with Util.Beans.Objects.Hash;
private with Ada.Containers;
private with Ada.Containers.Hashed_Maps;
-- The <b>ASF.Factory</b> is the main factory for building the facelet
-- node tree and defining associated component factory. A binding library
-- must be registered before the application starts. The binding library
-- must not be changed (this is a read-only static definition of names
-- associated with create functions).
package ASF.Factory is
-- ------------------------------
-- List of bindings
-- ------------------------------
-- The binding array defines a set of XML entity names that represent
-- a library accessible through a XML name-space. The binding array
-- must be sorted on the binding name. The <b>Check</b> procedure will
-- verify this assumption when the bindings are registered in the factory.
type Binding_Array is array (Natural range <>) of aliased ASF.Views.Nodes.Binding_Type;
type Binding_Array_Access is access constant Binding_Array;
type Factory_Bindings is limited record
URI : ASF.Views.Nodes.Name_Access;
Bindings : Binding_Array_Access;
end record;
type Factory_Bindings_Access is access constant Factory_Bindings;
-- ------------------------------
-- Component Factory
-- ------------------------------
-- The <b>Component_Factory</b> is the main entry point to register bindings
-- and resolve them when an XML file is read.
type Component_Factory is limited private;
-- Register a binding library in the factory.
procedure Register (Factory : in out Component_Factory;
Bindings : in Factory_Bindings_Access);
procedure Register (Factory : in out Component_Factory;
URI : in ASF.Views.Nodes.Name_Access;
Name : in ASF.Views.Nodes.Name_Access;
Tag : in ASF.Views.Nodes.Tag_Node_Create_Access;
Create : in ASF.Views.Nodes.Create_Access);
-- Find the create function in bound to the name in the given URI name-space.
-- Returns null if no such binding exist.
function Find (Factory : in Component_Factory;
URI : in String;
Name : in String) return ASF.Views.Nodes.Binding_Type;
-- ------------------------------
-- Converter Factory
-- ------------------------------
-- The <b>Converter_Factory</b> registers the converters which can be used
-- to convert a value into a string or the opposite.
-- Register the converter instance under the given name.
procedure Register (Factory : in out Component_Factory;
Name : in String;
Converter : in ASF.Converters.Converter_Access);
-- Find the converter instance that was registered under the given name.
-- Returns null if no such converter exist.
function Find (Factory : in Component_Factory;
Name : in EL.Objects.Object) return ASF.Converters.Converter_Access;
-- ------------------------------
-- Validator Factory
-- ------------------------------
-- Register the validator instance under the given name.
procedure Register (Factory : in out Component_Factory;
Name : in String;
Validator : in ASF.Validators.Validator_Access);
-- Find the validator instance that was registered under the given name.
-- Returns null if no such validator exist.
function Find (Factory : in Component_Factory;
Name : in EL.Objects.Object) return ASF.Validators.Validator_Access;
private
use ASF.Converters;
use ASF.Validators;
use ASF.Views.Nodes;
-- The tag name defines a URI with the name.
type Tag_Name is record
URI : ASF.Views.Nodes.Name_Access;
Name : ASF.Views.Nodes.Name_Access;
end record;
-- Compute a hash for the tag name.
function Hash (Key : in Tag_Name) return Ada.Containers.Hash_Type;
-- Returns true if both tag names are identical.
overriding
function "=" (Left, Right : in Tag_Name) return Boolean;
-- Tag library map indexed on the library namespace.
package Factory_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => Tag_Name,
Element_Type => Binding_Type,
Hash => Hash,
Equivalent_Keys => "=");
-- Converter map indexed on the converter name.
-- The key is an EL.Objects.Object to minimize the conversions when searching
-- for a converter.
package Converter_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => EL.Objects.Object,
Element_Type => Converter_Access,
Hash => EL.Objects.Hash,
Equivalent_Keys => EL.Objects."=");
-- Validator map indexed on the validator name.
-- The key is an EL.Objects.Object to minimize the conversions when searching
-- for a validator.
package Validator_Maps is new
Ada.Containers.Hashed_Maps (Key_Type => EL.Objects.Object,
Element_Type => Validator_Access,
Hash => EL.Objects.Hash,
Equivalent_Keys => EL.Objects."=");
type Component_Factory is limited record
Map : Factory_Maps.Map;
Converters : Converter_Maps.Map;
Validators : Validator_Maps.Map;
end record;
end ASF.Factory;
|
Fabien-Chouteau/samd51-hal | Ada | 2,821 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2019, 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 SAM.Clock_Generator;
package SAM.Clock_Setup_120Mhz is
procedure Initialize_Clocks;
Clk_CPU : constant SAM.Clock_Generator.Generator_Id := 0;
Clk_120Mhz : constant SAM.Clock_Generator.Generator_Id := Clk_CPU;
Clk_48Mhz : constant SAM.Clock_Generator.Generator_Id := 1;
Clk_32Khz : constant SAM.Clock_Generator.Generator_Id := 3;
Clk_2Mhz : constant SAM.Clock_Generator.Generator_Id := 5;
end SAM.Clock_Setup_120Mhz;
|
ptrebuc/ewok-kernel | Ada | 1,922 | adb | --
-- 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; use system;
with soc.rcc;
package body soc.exti
with spark_mode => off
is
procedure init
is
begin
deinit;
soc.rcc.RCC.APB2ENR.SYSCFGEN := true;
end init;
procedure deinit
is
begin
for line in t_exti_line_index'range loop
clear_pending(line);
disable(line);
end loop;
end deinit;
function is_line_pending
(line : t_exti_line_index)
return boolean
is
begin
return (EXTI.PR.line(line) = PENDING_REQUEST);
end is_line_pending;
procedure clear_pending
(line : in t_exti_line_index)
is
begin
EXTI.PR.line(line) := CLEAR_REQUEST;
end clear_pending;
procedure enable
(line : in t_exti_line_index)
is
begin
EXTI.IMR.line(line) := NOT_MASKED; -- interrupt is unmasked
end enable;
procedure disable
(line : in t_exti_line_index)
is
begin
EXTI.IMR.line(line) := MASKED; -- interrupt is masked
end disable;
function is_enabled (line : in t_exti_line_index)
return boolean
is
begin
return EXTI.IMR.line(line) = NOT_MASKED;
end;
end soc.exti;
|
reznikmm/matreshka | Ada | 3,699 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Style_Length_Attributes is
pragma Preelaborate;
type ODF_Style_Length_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Length_Attribute_Access is
access all ODF_Style_Length_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Length_Attributes;
|
zhmu/ananas | Ada | 167 | ads | package Vect18 is
type Sarray is array (1 .. 4) of Long_Float;
for Sarray'Alignment use 16;
procedure Comp (X, Y : Sarray; R : in out Sarray);
end Vect18;
|
AdaCore/gpr | Ada | 3,234 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Ada.Unchecked_Deallocation;
-- The root package of the Gpr_Parser_AdaSAT library. Defines the base data structures
-- that are used everywhere else.
-- You should instantiate the `Gpr_Parser_AdaSAT.DPLL` package with your own theory or
-- use the `Gpr_Parser_AdaSAT.Helpers.DPLL_Solve` function to start solving!
package Gpr_Parser_AdaSAT is
type Variable is new Positive;
-- A boolean variable, which can appear positively or negatively in a
-- literal. For example, ``-2`` represents ``¬2``. From literals, we can
-- build clauses, and then formulas. Ultimately, the solver's job is to
-- assign the value ``True`` or ``False`` to each variable so that the
-- given formula is satisfied. The set of assignments is called a model.
--
-- Note that we represent variables as positive integers so that we can
-- directly use them as keys in arrays (for example in the ``Model`` type),
-- rather than, say strings (which would require replacing arrays by
-- hash maps) or records (which would require extra indirections).
subtype Variable_Or_Null is Variable'Base range 0 .. Variable'Last;
type Literal is private;
-- A positive or negative occurrence of a variable
function "+" (V : Variable) return Literal
with Inline;
-- Create a literal with a positive polarity occurrence of a variable
function "-" (V : Variable) return Literal
with Inline;
-- Create a literal with a negative polarity occurrence of a variable
function Get_Var (L : Literal) return Variable
with Inline;
-- Get the variable that occurs in this literal
type Literal_Array is array (Positive range <>) of Literal;
type Literal_Array_Access is access Literal_Array;
-- Note that we don't use a generalized access type to avoid users from
-- giving stack-allocated clauses to the solver.
subtype Clause is Literal_Array_Access;
-- A clause represents a disjunction of literals
function Image (C : Clause) return String;
-- Returns a string representation of the clause
type Variable_Value is (True, False, Unset);
-- A variable can either be set to True or False, or Unset
type Model is array (Variable range <>) of Variable_Value;
-- A mapping from variable to its value
function Image (M : Model) return String;
-- Returns a string representation of the model
private
type Literal is new Integer;
-- Packed representation of literals: instead of having a literal be a
-- record with a variable and a field that indicates whether it is a
-- positive or negative occurrence of it, we use the positive value to
-- represent a positive occurrence of a variable, and a negative value
-- for a negative occurrence.
--
-- Note that while both literals and variables are "just" integers, we
-- cannot mix them up in our code thanks to Ada's strong type system.
procedure Free is new Ada.Unchecked_Deallocation
(Literal_Array, Clause);
-- We declare this here to make it available to each child package
-- of Gpr_Parser_AdaSAT.
end Gpr_Parser_AdaSAT;
|
AdaCore/libadalang | Ada | 169 | adb | package body B is
Body_Int : Integer := 12;
I : Integer := B.Public_Int + B.Private_Int + B.Body_Int;
pragma Test_Statement;
procedure Foo is null;
end B;
|
reznikmm/matreshka | Ada | 3,769 | 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_Extrusion_Specularity_Attributes is
pragma Preelaborate;
type ODF_Draw_Extrusion_Specularity_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Extrusion_Specularity_Attribute_Access is
access all ODF_Draw_Extrusion_Specularity_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Extrusion_Specularity_Attributes;
|
SayCV/rtems-addon-packages | Ada | 6,971 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Termcap --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2006,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
package body Terminal_Interface.Curses.Termcap is
function Get_Entry (Name : String) return Boolean
is
function tgetent (name : char_array; val : char_array)
return C_Int;
pragma Import (C, tgetent, "tgetent");
NameTxt : char_array (0 .. Name'Length);
Length : size_t;
ignored : constant char_array (0 .. 0) := (0 => nul);
result : C_Int;
begin
To_C (Name, NameTxt, Length);
result := tgetent (char_array (ignored), NameTxt);
if result = -1 then
raise Curses_Exception;
else
return Boolean'Val (result);
end if;
end Get_Entry;
------------------------------------------------------------------------------
function Get_Flag (Name : String) return Boolean
is
function tgetflag (id : char_array) return C_Int;
pragma Import (C, tgetflag, "tgetflag");
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
if tgetflag (Txt) = 0 then
return False;
else
return True;
end if;
end Get_Flag;
------------------------------------------------------------------------------
procedure Get_Number (Name : String;
Value : out Integer;
Result : out Boolean)
is
function tgetnum (id : char_array) return C_Int;
pragma Import (C, tgetnum, "tgetnum");
Txt : char_array (0 .. Name'Length);
Length : size_t;
begin
To_C (Name, Txt, Length);
Value := Integer (tgetnum (Txt));
if Value = -1 then
Result := False;
else
Result := True;
end if;
end Get_Number;
------------------------------------------------------------------------------
procedure Get_String (Name : String;
Value : out String;
Result : out Boolean)
is
function tgetstr (id : char_array;
buf : char_array) return chars_ptr;
pragma Import (C, tgetstr, "tgetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
type t is new char_array (0 .. 1024); -- does it need to be 1024?
Return_Buffer : constant t := (others => nul);
begin
To_C (Name, Txt, Length);
Txt2 := tgetstr (Txt, char_array (Return_Buffer));
if Txt2 = Null_Ptr then
Result := False;
else
Value := Fill_String (Txt2);
Result := True;
end if;
end Get_String;
function Get_String (Name : String) return Boolean
is
function tgetstr (Id : char_array;
buf : char_array) return chars_ptr;
pragma Import (C, tgetstr, "tgetstr");
Txt : char_array (0 .. Name'Length);
Length : size_t;
Txt2 : chars_ptr;
type t is new char_array (0 .. 1024); -- does it need to be 1024?
Phony_Txt : constant t := (others => nul);
begin
To_C (Name, Txt, Length);
Txt2 := tgetstr (Txt, char_array (Phony_Txt));
if Txt2 = Null_Ptr then
return False;
else
return True;
end if;
end Get_String;
------------------------------------------------------------------------------
function TGoto (Cap : String;
Col : Column_Position;
Row : Line_Position) return Termcap_String is
function tgoto (cap : char_array;
col : C_Int;
row : C_Int) return chars_ptr;
pragma Import (C, tgoto);
Txt : char_array (0 .. Cap'Length);
Length : size_t;
begin
To_C (Cap, Txt, Length);
return Termcap_String (Fill_String
(tgoto (Txt, C_Int (Col), C_Int (Row))));
end TGoto;
end Terminal_Interface.Curses.Termcap;
|
rogermc2/OpenGLAda | Ada | 8,327 | ads | -- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
package Glfw.Input.Keys is
type Action is (Release, Press, Repeat);
type Key is (Unknown,
Space,
Apostrophe,
Comma,
Minus,
Period,
Slash,
Key_0,
Key_1,
Key_2,
Key_3,
Key_4,
Key_5,
Key_6,
Key_7,
Key_8,
Key_9,
Semicolon,
Equal,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Left_Bracket,
Backslash,
Right_Bracket,
Grave_Accent,
World_1,
World_2,
Escape,
Enter,
Tab,
Backspace,
Insert,
Delete,
Right,
Left,
Down,
Up,
Page_Up,
Page_Down,
Home,
Key_End,
Caps_Lock,
Scroll_Lock,
Print_Screen,
Pause,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
F21,
F22,
F23,
F24,
F25,
Numpad_0,
Numpad_1,
Numpad_2,
Numpad_3,
Numpad_4,
Numpad_5,
Numpad_6,
Numpad_7,
Numpad_8,
Numpad_9,
Numpad_Decimal,
Numpad_Divide,
Numpad_Multiply,
Numpad_Substract,
Numpad_Add,
Numpad_Enter,
Numpad_Equal,
Left_Shift,
Left_Control,
Left_Alt,
Left_Super,
Right_Shift,
Right_Control,
Right_Alt,
Right_Super,
Menu);
type Modifiers is record
Shift : Boolean;
Control : Boolean;
Alt : Boolean;
Super : Boolean;
end record;
type Scancode is new Interfaces.C.int;
private
for Action use (Release => 0,
Press => 1,
Repeat => 2);
for Action'Size use Interfaces.C.int'Size;
for Key use (Unknown => -1,
Space => 32,
Apostrophe => 39,
Comma => 44,
Minus => 45,
Period => 46,
Slash => 47,
Key_0 => 48,
Key_1 => 49,
Key_2 => 50,
Key_3 => 51,
Key_4 => 52,
Key_5 => 53,
Key_6 => 54,
Key_7 => 55,
Key_8 => 56,
Key_9 => 57,
Semicolon => 59,
Equal => 61,
A => 65,
B => 66,
C => 67,
D => 68,
E => 69,
F => 70,
G => 71,
H => 72,
I => 73,
J => 74,
K => 75,
L => 76,
M => 77,
N => 78,
O => 79,
P => 80,
Q => 81,
R => 82,
S => 83,
T => 84,
U => 85,
V => 86,
W => 87,
X => 88,
Y => 89,
Z => 90,
Left_Bracket => 91,
Backslash => 92,
Right_Bracket => 93,
Grave_Accent => 96,
World_1 => 161,
World_2 => 162,
Escape => 256,
Enter => 257,
Tab => 258,
Backspace => 259,
Insert => 260,
Delete => 261,
Right => 262,
Left => 263,
Down => 264,
Up => 265,
Page_Up => 266,
Page_Down => 267,
Home => 268,
Key_End => 269,
Caps_Lock => 280,
Scroll_Lock => 281,
Print_Screen => 283,
Pause => 284,
F1 => 290,
F2 => 291,
F3 => 292,
F4 => 293,
F5 => 294,
F6 => 295,
F7 => 296,
F8 => 297,
F9 => 298,
F10 => 299,
F11 => 300,
F12 => 301,
F13 => 302,
F14 => 303,
F15 => 304,
F16 => 305,
F17 => 306,
F18 => 307,
F19 => 308,
F20 => 309,
F21 => 310,
F22 => 311,
F23 => 312,
F24 => 313,
F25 => 314,
Numpad_0 => 320,
Numpad_1 => 321,
Numpad_2 => 322,
Numpad_3 => 323,
Numpad_4 => 324,
Numpad_5 => 325,
Numpad_6 => 326,
Numpad_7 => 327,
Numpad_8 => 328,
Numpad_9 => 329,
Numpad_Decimal => 330,
Numpad_Divide => 331,
Numpad_Multiply => 332,
Numpad_Substract => 333,
Numpad_Add => 334,
Numpad_Enter => 335,
Numpad_Equal => 336,
Left_Shift => 340,
Left_Control => 341,
Left_Alt => 342,
Left_Super => 343,
Right_Shift => 344,
Right_Control => 345,
Right_Alt => 346,
Right_Super => 347,
Menu => 348);
for Key'Size use Interfaces.C.int'Size;
for Modifiers use record
Shift at 0 range 0 .. 0;
Control at 0 range 1 .. 1;
Alt at 0 range 2 .. 2;
Super at 0 range 3 .. 3;
end record;
pragma Warnings (Off);
for Modifiers'Size use Interfaces.C.int'Size;
pragma Warnings (On);
pragma Convention (C_Pass_By_Copy, Modifiers);
for Scancode'Size use Interfaces.C.int'Size;
end Glfw.Input.Keys;
|
zhmu/ananas | Ada | 26,505 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- U I N T P --
-- --
-- S p e c --
-- --
-- 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. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Support for universal integer arithmetic
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file uintp.h
with Alloc;
with Table;
pragma Elaborate_All (Table);
with Types; use Types;
package Uintp is
-------------------------------------------------
-- Basic Types and Constants for Uintp Package --
-------------------------------------------------
type Uint is private;
-- The basic universal integer type
No_Uint : constant Uint;
-- A constant value indicating a missing or unset Uint value
Uint_0 : constant Uint;
Uint_1 : constant Uint;
Uint_2 : constant Uint;
Uint_3 : constant Uint;
Uint_4 : constant Uint;
Uint_5 : constant Uint;
Uint_6 : constant Uint;
Uint_7 : constant Uint;
Uint_8 : constant Uint;
Uint_9 : constant Uint;
Uint_10 : constant Uint;
Uint_11 : constant Uint;
Uint_12 : constant Uint;
Uint_13 : constant Uint;
Uint_14 : constant Uint;
Uint_15 : constant Uint;
Uint_16 : constant Uint;
Uint_24 : constant Uint;
Uint_31 : constant Uint;
Uint_32 : constant Uint;
Uint_63 : constant Uint;
Uint_64 : constant Uint;
Uint_80 : constant Uint;
Uint_127 : constant Uint;
Uint_128 : constant Uint;
Uint_Minus_1 : constant Uint;
Uint_Minus_2 : constant Uint;
Uint_Minus_3 : constant Uint;
Uint_Minus_4 : constant Uint;
Uint_Minus_5 : constant Uint;
Uint_Minus_6 : constant Uint;
Uint_Minus_7 : constant Uint;
Uint_Minus_8 : constant Uint;
Uint_Minus_9 : constant Uint;
Uint_Minus_12 : constant Uint;
Uint_Minus_18 : constant Uint;
Uint_Minus_31 : constant Uint;
Uint_Minus_36 : constant Uint;
Uint_Minus_63 : constant Uint;
Uint_Minus_76 : constant Uint;
Uint_Minus_80 : constant Uint;
Uint_Minus_127 : constant Uint;
Uint_Minus_128 : constant Uint;
-- Functions for detecting No_Uint. Note that clients of this package
-- cannot use "=" and "/=" to compare with No_Uint; they must use No
-- and Present instead.
function No (X : Uint) return Boolean is (X = No_Uint);
-- Note that this is using the predefined "=", not the "=" declared below,
-- which would blow up on No_Uint.
function Present (X : Uint) return Boolean is (not No (X));
subtype Valid_Uint is Uint with Predicate => Present (Valid_Uint);
subtype Unat is Valid_Uint with Predicate => Unat >= Uint_0; -- natural
subtype Upos is Valid_Uint with Predicate => Upos >= Uint_1; -- positive
subtype Nonzero_Uint is Valid_Uint with Predicate => Nonzero_Uint /= Uint_0;
subtype Unegative is Valid_Uint with Predicate => Unegative < Uint_0;
subtype Ubool is Valid_Uint with Predicate => Ubool in Uint_0 | Uint_1;
subtype Opt_Ubool is Uint with
Predicate => No (Opt_Ubool) or else Opt_Ubool in Ubool;
-----------------
-- Subprograms --
-----------------
procedure Initialize;
-- Initialize Uint tables. Note also that there is no lock routine in this
-- unit, these are among the few tables that can be expanded during
-- gigi processing.
function UI_Abs (Right : Valid_Uint) return Unat;
pragma Inline (UI_Abs);
-- Returns abs function of universal integer
function UI_Add (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
function UI_Add (Left : Int; Right : Valid_Uint) return Valid_Uint;
function UI_Add (Left : Valid_Uint; Right : Int) return Valid_Uint;
-- Returns sum of two integer values
function UI_Decimal_Digits_Hi (U : Valid_Uint) return Nat;
-- Returns an estimate of the number of decimal digits required to
-- represent the absolute value of U. This estimate is correct or high,
-- i.e. it never returns a value that is too low. The accuracy of the
-- estimate affects only the effectiveness of comparison optimizations
-- in Urealp.
function UI_Decimal_Digits_Lo (U : Valid_Uint) return Nat;
-- Returns an estimate of the number of decimal digits required to
-- represent the absolute value of U. This estimate is correct or low,
-- i.e. it never returns a value that is too high. The accuracy of the
-- estimate affects only the effectiveness of comparison optimizations
-- in Urealp.
function UI_Div (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
function UI_Div (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
function UI_Div (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
-- Returns quotient of two integer values. Fatal error if Right = 0
function UI_Eq (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Eq (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Eq (Left : Valid_Uint; Right : Int) return Boolean;
pragma Inline (UI_Eq);
-- Compares integer values for equality
function UI_Expon (Left : Valid_Uint; Right : Unat) return Valid_Uint;
function UI_Expon (Left : Int; Right : Unat) return Valid_Uint;
function UI_Expon (Left : Valid_Uint; Right : Nat) return Valid_Uint;
function UI_Expon (Left : Int; Right : Nat) return Valid_Uint;
-- Returns result of exponentiating two integer values.
-- Fatal error if Right is negative.
function UI_GCD (Uin, Vin : Valid_Uint) return Valid_Uint;
-- Computes GCD of input values. Assumes Uin >= Vin >= 0
function UI_Ge (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Ge (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Ge (Left : Valid_Uint; Right : Int) return Boolean;
pragma Inline (UI_Ge);
-- Compares integer values for greater than or equal
function UI_Gt (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Gt (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Gt (Left : Valid_Uint; Right : Int) return Boolean;
pragma Inline (UI_Gt);
-- Compares integer values for greater than
function UI_Is_In_Int_Range (Input : Valid_Uint) return Boolean;
pragma Inline (UI_Is_In_Int_Range);
-- Determines if universal integer is in Int range.
function UI_Le (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Le (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Le (Left : Valid_Uint; Right : Int) return Boolean;
pragma Inline (UI_Le);
-- Compares integer values for less than or equal
function UI_Lt (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Lt (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Lt (Left : Valid_Uint; Right : Int) return Boolean;
-- Compares integer values for less than
function UI_Max (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
function UI_Max (Left : Int; Right : Valid_Uint) return Valid_Uint;
function UI_Max (Left : Valid_Uint; Right : Int) return Valid_Uint;
-- Returns maximum of two integer values
function UI_Min (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
function UI_Min (Left : Int; Right : Valid_Uint) return Valid_Uint;
function UI_Min (Left : Valid_Uint; Right : Int) return Valid_Uint;
-- Returns minimum of two integer values
function UI_Mod (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
function UI_Mod (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
function UI_Mod (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
pragma Inline (UI_Mod);
-- Returns mod function of two integer values
function UI_Mul (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
function UI_Mul (Left : Int; Right : Valid_Uint) return Valid_Uint;
function UI_Mul (Left : Valid_Uint; Right : Int) return Valid_Uint;
-- Returns product of two integer values
function UI_Ne (Left : Valid_Uint; Right : Valid_Uint) return Boolean;
function UI_Ne (Left : Int; Right : Valid_Uint) return Boolean;
function UI_Ne (Left : Valid_Uint; Right : Int) return Boolean;
pragma Inline (UI_Ne);
-- Compares integer values for inequality
function UI_Negate (Right : Valid_Uint) return Valid_Uint;
pragma Inline (UI_Negate);
-- Returns negative of universal integer
function UI_Rem (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint;
function UI_Rem (Left : Int; Right : Nonzero_Uint) return Valid_Uint;
function UI_Rem (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint;
-- Returns rem of two integer values
function UI_Sub (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint;
function UI_Sub (Left : Int; Right : Valid_Uint) return Valid_Uint;
function UI_Sub (Left : Valid_Uint; Right : Int) return Valid_Uint;
pragma Inline (UI_Sub);
-- Returns difference of two integer values
function UI_From_Int (Input : Int) return Valid_Uint;
-- Converts Int value to universal integer form
generic
type In_T is range <>;
function UI_From_Integral (Input : In_T) return Valid_Uint;
-- Likewise, but converts from any integer type. Must not be applied to
-- biased types (instantiation will provide a warning if actual is a biased
-- type).
function UI_From_CC (Input : Char_Code) return Valid_Uint;
-- Converts Char_Code value to universal integer form
function UI_To_Int (Input : Valid_Uint) return Int;
-- Converts universal integer value to Int. Constraint_Error if value is
-- not in appropriate range.
type Unsigned_64 is mod 2**64;
function UI_To_Unsigned_64 (Input : Valid_Uint) return Unsigned_64;
-- Converts universal integer value to Unsigned_64. Constraint_Error if
-- value is not in appropriate range.
function UI_To_CC (Input : Valid_Uint) return Char_Code;
-- Converts universal integer value to Char_Code. Constraint_Error if value
-- is not in Char_Code range.
function Num_Bits (Input : Valid_Uint) return Nat;
-- Approximate number of binary bits in given universal integer. This
-- function is used for capacity checks, and it can be one bit off
-- without affecting its usage.
---------------------
-- Output Routines --
---------------------
type UI_Format is (Hex, Decimal, Auto);
-- Used to determine whether UI_Image/UI_Write output is in hexadecimal
-- or decimal format. Auto, the default setting, lets the routine make a
-- decision based on the value.
UI_Image_Max : constant := 1024;
UI_Image_Buffer : String (1 .. UI_Image_Max);
UI_Image_Length : Natural;
-- Buffer used for UI_Image as described below
procedure UI_Image (Input : Uint; Format : UI_Format := Auto);
-- Places a representation of Uint, consisting of a possible minus sign,
-- followed by the value in UI_Image_Buffer. The form of the value is an
-- integer literal in either decimal (no base) or hexadecimal (base 16)
-- format. If Hex is True on entry, then hex mode is forced, otherwise
-- UI_Image makes a guess at which output format is more convenient. The
-- value must fit in UI_Image_Buffer. The actual length of the result is
-- returned in UI_Image_Length. If necessary to meet this requirement, the
-- result is an approximation of the proper value, using an exponential
-- format. The image of No_Uint is output as a single question mark.
function UI_Image (Input : Uint; Format : UI_Format := Auto) return String;
-- Functional form, in which the result is returned as a string. This call
-- also leaves the result in UI_Image_Buffer/Length as described above.
procedure UI_Write (Input : Uint; Format : UI_Format := Auto);
-- Writes a representation of Uint, consisting of a possible minus sign,
-- followed by the value to the output file. The form of the value is an
-- integer literal in either decimal (no base) or hexadecimal (base 16)
-- format as appropriate. UI_Format shows which format to use. Auto, the
-- default, asks UI_Write to make a guess at which output format will be
-- more convenient to read.
procedure pid (Input : Uint);
pragma Export (Ada, pid);
-- Writes representation of Uint in decimal with a terminating line
-- return. This is intended for use from the debugger.
procedure pih (Input : Uint);
pragma Export (Ada, pih);
-- Writes representation of Uint in hex with a terminating line return.
-- This is intended for use from the debugger.
------------------------
-- Operator Renamings --
------------------------
function "+" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
renames UI_Add;
function "+" (Left : Int; Right : Valid_Uint) return Valid_Uint
renames UI_Add;
function "+" (Left : Valid_Uint; Right : Int) return Valid_Uint
renames UI_Add;
function "/" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
renames UI_Div;
function "/" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
renames UI_Div;
function "/" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
renames UI_Div;
function "*" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
renames UI_Mul;
function "*" (Left : Int; Right : Valid_Uint) return Valid_Uint
renames UI_Mul;
function "*" (Left : Valid_Uint; Right : Int) return Valid_Uint
renames UI_Mul;
function "-" (Left : Valid_Uint; Right : Valid_Uint) return Valid_Uint
renames UI_Sub;
function "-" (Left : Int; Right : Valid_Uint) return Valid_Uint
renames UI_Sub;
function "-" (Left : Valid_Uint; Right : Int) return Valid_Uint
renames UI_Sub;
function "**" (Left : Valid_Uint; Right : Unat) return Valid_Uint
renames UI_Expon;
function "**" (Left : Valid_Uint; Right : Nat) return Valid_Uint
renames UI_Expon;
function "**" (Left : Int; Right : Unat) return Valid_Uint
renames UI_Expon;
function "**" (Left : Int; Right : Nat) return Valid_Uint
renames UI_Expon;
function "abs" (Real : Valid_Uint) return Unat
renames UI_Abs;
function "mod" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
renames UI_Mod;
function "mod" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
renames UI_Mod;
function "mod" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
renames UI_Mod;
function "rem" (Left : Valid_Uint; Right : Nonzero_Uint) return Valid_Uint
renames UI_Rem;
function "rem" (Left : Int; Right : Nonzero_Uint) return Valid_Uint
renames UI_Rem;
function "rem" (Left : Valid_Uint; Right : Nonzero_Int) return Valid_Uint
renames UI_Rem;
function "-" (Real : Valid_Uint) return Valid_Uint
renames UI_Negate;
function "=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
renames UI_Eq;
function "=" (Left : Int; Right : Valid_Uint) return Boolean
renames UI_Eq;
function "=" (Left : Valid_Uint; Right : Int) return Boolean
renames UI_Eq;
function ">=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
renames UI_Ge;
function ">=" (Left : Int; Right : Valid_Uint) return Boolean
renames UI_Ge;
function ">=" (Left : Valid_Uint; Right : Int) return Boolean
renames UI_Ge;
function ">" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
renames UI_Gt;
function ">" (Left : Int; Right : Valid_Uint) return Boolean
renames UI_Gt;
function ">" (Left : Valid_Uint; Right : Int) return Boolean
renames UI_Gt;
function "<=" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
renames UI_Le;
function "<=" (Left : Int; Right : Valid_Uint) return Boolean
renames UI_Le;
function "<=" (Left : Valid_Uint; Right : Int) return Boolean
renames UI_Le;
function "<" (Left : Valid_Uint; Right : Valid_Uint) return Boolean
renames UI_Lt;
function "<" (Left : Int; Right : Valid_Uint) return Boolean
renames UI_Lt;
function "<" (Left : Valid_Uint; Right : Int) return Boolean
renames UI_Lt;
-----------------------------
-- Mark/Release Processing --
-----------------------------
-- The space used by Uint data is not automatically reclaimed. However, a
-- mark-release regime is implemented which allows storage to be released
-- back to a previously noted mark. This is used for example when doing
-- comparisons, where only intermediate results get stored that do not
-- need to be saved for future use.
type Save_Mark is private;
function Mark return Save_Mark;
-- Note mark point for future release
procedure Release (M : Save_Mark);
-- Release storage allocated since mark was noted
procedure Release_And_Save (M : Save_Mark; UI : in out Valid_Uint);
-- Like Release, except that the given Uint value (which is typically among
-- the data being released) is recopied after the release, so that it is
-- the most recent item, and UI is updated to point to its copied location.
procedure Release_And_Save (M : Save_Mark; UI1, UI2 : in out Valid_Uint);
-- Like Release, except that the given Uint values (which are typically
-- among the data being released) are recopied after the release, so that
-- they are the most recent items, and UI1 and UI2 are updated if necessary
-- to point to the copied locations. This routine is careful to do things
-- in the right order, so that the values do not clobber one another.
-----------------------------------
-- Representation of Uint Values --
-----------------------------------
private
type Uint is new Int range Uint_Low_Bound .. Uint_High_Bound;
for Uint'Size use 32;
No_Uint : constant Uint := Uint (Uint_Low_Bound);
-- Uint values are represented as multiple precision integers stored in
-- a multi-digit format using Base as the base. This value is chosen so
-- that the product Base*Base is within the range of allowed Int values.
-- Base is defined to allow efficient execution of the primitive operations
-- (a0, b0, c0) defined in the section "The Classical Algorithms"
-- (sec. 4.3.1) of Donald Knuth's "The Art of Computer Programming",
-- Vol. 2. These algorithms are used in this package. In particular,
-- the product of two single digits in this base fits in a 32-bit integer.
Base_Bits : constant := 15;
-- Number of bits in base value
Base : constant Int := 2**Base_Bits;
-- Values in the range -(Base-1) .. Max_Direct are encoded directly as
-- Uint values by adding a bias value. The value of Max_Direct is chosen
-- so that a directly represented number always fits in two digits when
-- represented in base format.
Min_Direct : constant Int := -(Base - 1);
Max_Direct : constant Int := (Base - 1) * (Base - 1);
-- The following values define the bias used to store Uint values which
-- are in this range, as well as the biased values for the first and last
-- values in this range. We use a new derived type for these constants to
-- avoid accidental use of Uint arithmetic on these values, which is never
-- correct.
type Ctrl is new Int;
Uint_Direct_Bias : constant Ctrl := Ctrl (Uint_Low_Bound) + Ctrl (Base);
Uint_Direct_First : constant Ctrl := Uint_Direct_Bias + Ctrl (Min_Direct);
Uint_Direct_Last : constant Ctrl := Uint_Direct_Bias + Ctrl (Max_Direct);
Uint_0 : constant Uint := Uint (Uint_Direct_Bias + 0);
Uint_1 : constant Uint := Uint (Uint_Direct_Bias + 1);
Uint_2 : constant Uint := Uint (Uint_Direct_Bias + 2);
Uint_3 : constant Uint := Uint (Uint_Direct_Bias + 3);
Uint_4 : constant Uint := Uint (Uint_Direct_Bias + 4);
Uint_5 : constant Uint := Uint (Uint_Direct_Bias + 5);
Uint_6 : constant Uint := Uint (Uint_Direct_Bias + 6);
Uint_7 : constant Uint := Uint (Uint_Direct_Bias + 7);
Uint_8 : constant Uint := Uint (Uint_Direct_Bias + 8);
Uint_9 : constant Uint := Uint (Uint_Direct_Bias + 9);
Uint_10 : constant Uint := Uint (Uint_Direct_Bias + 10);
Uint_11 : constant Uint := Uint (Uint_Direct_Bias + 11);
Uint_12 : constant Uint := Uint (Uint_Direct_Bias + 12);
Uint_13 : constant Uint := Uint (Uint_Direct_Bias + 13);
Uint_14 : constant Uint := Uint (Uint_Direct_Bias + 14);
Uint_15 : constant Uint := Uint (Uint_Direct_Bias + 15);
Uint_16 : constant Uint := Uint (Uint_Direct_Bias + 16);
Uint_24 : constant Uint := Uint (Uint_Direct_Bias + 24);
Uint_31 : constant Uint := Uint (Uint_Direct_Bias + 31);
Uint_32 : constant Uint := Uint (Uint_Direct_Bias + 32);
Uint_63 : constant Uint := Uint (Uint_Direct_Bias + 63);
Uint_64 : constant Uint := Uint (Uint_Direct_Bias + 64);
Uint_80 : constant Uint := Uint (Uint_Direct_Bias + 80);
Uint_127 : constant Uint := Uint (Uint_Direct_Bias + 127);
Uint_128 : constant Uint := Uint (Uint_Direct_Bias + 128);
Uint_Minus_1 : constant Uint := Uint (Uint_Direct_Bias - 1);
Uint_Minus_2 : constant Uint := Uint (Uint_Direct_Bias - 2);
Uint_Minus_3 : constant Uint := Uint (Uint_Direct_Bias - 3);
Uint_Minus_4 : constant Uint := Uint (Uint_Direct_Bias - 4);
Uint_Minus_5 : constant Uint := Uint (Uint_Direct_Bias - 5);
Uint_Minus_6 : constant Uint := Uint (Uint_Direct_Bias - 6);
Uint_Minus_7 : constant Uint := Uint (Uint_Direct_Bias - 7);
Uint_Minus_8 : constant Uint := Uint (Uint_Direct_Bias - 8);
Uint_Minus_9 : constant Uint := Uint (Uint_Direct_Bias - 9);
Uint_Minus_12 : constant Uint := Uint (Uint_Direct_Bias - 12);
Uint_Minus_18 : constant Uint := Uint (Uint_Direct_Bias - 18);
Uint_Minus_31 : constant Uint := Uint (Uint_Direct_Bias - 31);
Uint_Minus_36 : constant Uint := Uint (Uint_Direct_Bias - 36);
Uint_Minus_63 : constant Uint := Uint (Uint_Direct_Bias - 63);
Uint_Minus_76 : constant Uint := Uint (Uint_Direct_Bias - 76);
Uint_Minus_80 : constant Uint := Uint (Uint_Direct_Bias - 80);
Uint_Minus_127 : constant Uint := Uint (Uint_Direct_Bias - 127);
Uint_Minus_128 : constant Uint := Uint (Uint_Direct_Bias - 128);
Uint_Max_Simple_Mul : constant := Uint_Direct_Bias + 2**15;
-- If two values are directly represented and less than or equal to this
-- value, then we know the product fits in a 32-bit integer. This allows
-- UI_Mul to efficiently compute the product in this case.
type Save_Mark is record
Save_Uint : Valid_Uint;
Save_Udigit : Int;
end record;
-- Values outside the range that is represented directly are stored using
-- two tables. The secondary table Udigits contains sequences of Int values
-- consisting of the digits of the number in a radix Base system. The
-- digits are stored from most significant to least significant with the
-- first digit only carrying the sign.
-- There is one entry in the primary Uints table for each distinct Uint
-- value. This table entry contains the length (number of digits) and
-- a starting offset of the value in the Udigits table.
Uint_First_Entry : constant Uint := Uint (Uint_Table_Start);
-- Some subprograms defined in this package manipulate the Udigits table
-- directly, while for others it is more convenient to work with locally
-- defined arrays of the digits of the Universal Integers. The type
-- UI_Vector is declared in the package body for this purpose and some
-- internal subprograms used for converting from one to the other are
-- defined.
type Uint_Entry is record
Length : aliased Pos;
-- Length of entry in Udigits table in digits (i.e. in words)
Loc : aliased Int;
-- Starting location in Udigits table of this Uint value
end record;
package Uints is new Table.Table (
Table_Component_Type => Uint_Entry,
Table_Index_Type => Uint'Base,
Table_Low_Bound => Uint_First_Entry,
Table_Initial => Alloc.Uints_Initial,
Table_Increment => Alloc.Uints_Increment,
Table_Name => "Uints");
package Udigits is new Table.Table (
Table_Component_Type => Int,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => Alloc.Udigits_Initial,
Table_Increment => Alloc.Udigits_Increment,
Table_Name => "Udigits");
-- Note: the reason these tables are defined here in the private part of
-- the spec, rather than in the body, is that they are referenced directly
-- by gigi.
end Uintp;
|
reznikmm/increment | Ada | 2,370 | ads | -- Copyright (c) 2015-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package Incr.Nodes.Joints is
type Joint (Document : Documents.Document_Access;
Arity : Natural) is new Node with private;
type Joint_Access is access all Joint'Class;
package Constructors is
procedure Initialize
(Self : aliased out Joint'Class;
Kind : Node_Kind;
Children : Node_Array);
procedure Initialize_Ancient
(Self : out Joint'Class;
Parent : Node_Access);
end Constructors;
private
type Versioned_Node_Array is array (Positive range <>) of
Versioned_Nodes.Container;
type Cached_Integer is record
Value : Integer := -1; -- -1 means invalid cache
Time : Version_Trees.Version;
end record;
type Cached_Spans is array (Span_Kinds) of Cached_Integer;
type Joint (Document : Documents.Document_Access;
Arity : Natural) is
new Node_With_Parent (Document) with
record
Kind : Node_Kind;
Kids : Versioned_Node_Array (1 .. Arity);
NC : Versioned_Booleans.Container;
NE : Versioned_Booleans.Container;
Span_Cache : Cached_Spans;
end record;
overriding function Arity (Self : Joint) return Natural;
overriding function Is_Token (Self : Joint) return Boolean;
overriding function Kind (Self : Joint) return Node_Kind;
overriding function Child
(Self : Joint;
Index : Positive;
Time : Version_Trees.Version) return Node_Access;
overriding procedure Set_Child
(Self : aliased in out Joint;
Index : Positive;
Value : Node_Access);
overriding function Nested_Changes
(Self : Joint;
From : Version_Trees.Version;
To : Version_Trees.Version) return Boolean;
overriding function Nested_Errors
(Self : Joint;
Time : Version_Trees.Version) return Boolean;
overriding function Span
(Self : aliased in out Joint;
Kind : Span_Kinds;
Time : Version_Trees.Version) return Natural;
overriding procedure Discard (Self : in out Joint);
overriding procedure On_Commit
(Self : in out Joint;
Parent : Node_Access);
end Incr.Nodes.Joints;
|
reznikmm/gela | Ada | 565 | ads | with League.Strings;
package Asis.Extensions.Static_Expressions is
type Value is tagged private;
function Static_Value (Expression : Asis.Expression) return Value;
function Is_Static (Self : Value) return Boolean;
function Is_String (Self : Value) return Boolean;
function Value_Image (Self : Value) return Asis.Program_Text;
private
type Value is tagged record
Is_Static : Boolean := False;
Is_String : Boolean := False;
Image : League.Strings.Universal_String;
end record;
end Asis.Extensions.Static_Expressions;
|
reznikmm/matreshka | Ada | 4,417 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-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 League.Characters;
with League.Strings;
package XML.SAX.Output_Destinations is
pragma Preelaborate;
type SAX_Output_Destination is limited interface;
not overriding function Get_Encoding
(Self : SAX_Output_Destination)
return League.Strings.Universal_String is abstract;
-- Returns character encoding used to convert Unicode character code point
-- into the external items. This operation is used by XML writers to
-- generate 'encoding' attribute for XML declaration or text declaration.
not overriding procedure Put
(Self : in out SAX_Output_Destination;
Text : League.Strings.Universal_String) is abstract;
not overriding procedure Put
(Self : in out SAX_Output_Destination;
Text : Wide_Wide_String) is abstract;
not overriding procedure Put
(Self : in out SAX_Output_Destination;
Char : League.Characters.Universal_Character) is abstract;
not overriding procedure Put
(Self : in out SAX_Output_Destination;
Char : Wide_Wide_Character) is abstract;
end XML.SAX.Output_Destinations;
|
reznikmm/matreshka | Ada | 3,891 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Style.Background_Image;
package ODF.DOM.Elements.Style.Background_Image.Internals is
function Create
(Node : Matreshka.ODF_Elements.Style.Background_Image.Style_Background_Image_Access)
return ODF.DOM.Elements.Style.Background_Image.ODF_Style_Background_Image;
function Wrap
(Node : Matreshka.ODF_Elements.Style.Background_Image.Style_Background_Image_Access)
return ODF.DOM.Elements.Style.Background_Image.ODF_Style_Background_Image;
end ODF.DOM.Elements.Style.Background_Image.Internals;
|
reznikmm/matreshka | Ada | 3,649 | 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.Elements;
package ODF.DOM.Dc_Subject_Elements is
pragma Preelaborate;
type ODF_Dc_Subject is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Dc_Subject_Access is
access all ODF_Dc_Subject'Class
with Storage_Size => 0;
end ODF.DOM.Dc_Subject_Elements;
|
strenkml/EE368 | Ada | 1,780 | ads |
package Memory.Dup is
type Dup_Type is new Memory_Type with private;
type Dup_Pointer is access all Dup_Type'Class;
function Create_Dup return Dup_Pointer;
overriding
function Clone(mem : Dup_Type) return Memory_Pointer;
procedure Add_Memory(mem : in out Dup_Type;
other : access Memory_Type'Class);
overriding
procedure Reset(mem : in out Dup_Type;
context : in Natural);
overriding
procedure Read(mem : in out Dup_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Write(mem : in out Dup_Type;
address : in Address_Type;
size : in Positive);
overriding
procedure Idle(mem : in out Dup_Type;
cycles : in Time_Type);
overriding
procedure Show_Stats(mem : in out Dup_Type);
overriding
function To_String(mem : Dup_Type) return Unbounded_String;
overriding
function Get_Cost(mem : Dup_Type) return Cost_Type;
overriding
function Get_Writes(mem : Dup_Type) return Long_Integer;
overriding
function Get_Word_Size(mem : Dup_Type) return Positive;
overriding
procedure Generate(mem : in Dup_Type;
sigs : in out Unbounded_String;
code : in out Unbounded_String);
overriding
function Get_Ports(mem : Dup_Type) return Port_Vector_Type;
overriding
procedure Adjust(mem : in out Dup_Type);
overriding
procedure Finalize(mem : in out Dup_Type);
private
package Memory_Vectors is new Vectors(Natural, Memory_Pointer);
type Dup_Type is new Memory_Type with record
memories : Memory_Vectors.Vector;
end record;
end Memory.Dup;
|
DavJo-dotdotdot/Ada_Drivers_Library | Ada | 139 | ads | package Brain is
task Sense with Priority => 3;
task Think with Priority => 1;
task Act with Priority => 2;
private
end Brain;
|
optikos/ada-lsp | Ada | 7,655 | adb | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with League.Strings.Hash;
package body Ada_LSP.Ada_Lexers is
package body Tables is separate;
package Maps is new Ada.Containers.Hashed_Maps
(Key_Type => League.Strings.Universal_String,
Element_Type => Token,
Hash => League.Strings.Hash,
Equivalent_Keys => League.Strings."=",
"=" => Incr.Lexers.Batch_Lexers."=");
Default : constant Incr.Lexers.Batch_Lexers.State := 0;
Apostrophe : constant Incr.Lexers.Batch_Lexers.State := 87;
Map : Maps.Map;
-- Our batch lexer return token codes in this order:
Convert : constant array (Token range 1 .. 107) of Token :=
(Arrow_Token,
Double_Dot_Token,
Double_Star_Token,
Assignment_Token,
Inequality_Token,
Greater_Or_Equal_Token,
Less_Or_Equal_Token,
Left_Label_Token,
Right_Label_Token,
Box_Token,
Ampersand_Token,
Apostrophe_Token,
Left_Parenthesis_Token,
Right_Parenthesis_Token,
Star_Token,
Plus_Token,
Comma_Token,
Hyphen_Token,
Dot_Token,
Slash_Token,
Colon_Token,
Semicolon_Token,
Less_Token,
Equal_Token,
Greater_Token,
Vertical_Line_Token,
Identifier_Token,
Numeric_Literal_Token,
Character_Literal_Token,
String_Literal_Token,
Comment_Token,
Space_Token,
New_Line_Token,
Error_Token,
Abort_Token,
Abs_Token,
Abstract_Token,
Accept_Token,
Access_Token,
Aliased_Token,
All_Token,
And_Token,
Array_Token,
At_Token,
Begin_Token,
Body_Token,
Case_Token,
Constant_Token,
Declare_Token,
Delay_Token,
Delta_Token,
Digits_Token,
Do_Token,
Else_Token,
Elsif_Token,
End_Token,
Entry_Token,
Exception_Token,
Exit_Token,
For_Token,
Function_Token,
Generic_Token,
Goto_Token,
If_Token,
In_Token,
Interface_Token,
Is_Token,
Limited_Token,
Loop_Token,
Mod_Token,
New_Token,
Not_Token,
Null_Token,
Of_Token,
Or_Token,
Others_Token,
Out_Token,
Overriding_Token,
Package_Token,
Pragma_Token,
Private_Token,
Procedure_Token,
Protected_Token,
Raise_Token,
Range_Token,
Record_Token,
Rem_Token,
Renames_Token,
Requeue_Token,
Return_Token,
Reverse_Token,
Select_Token,
Separate_Token,
Some_Token,
Subtype_Token,
Synchronized_Token,
Tagged_Token,
Task_Token,
Terminate_Token,
Then_Token,
Type_Token,
Until_Token,
Use_Token,
When_Token,
While_Token,
With_Token,
Xor_Token);
overriding procedure Get_Token
(Self : access Batch_Lexer;
Result : out Incr.Lexers.Batch_Lexers.Rule_Index)
is
use type Incr.Lexers.Batch_Lexers.Rule_Index;
use type Incr.Lexers.Batch_Lexers.State;
Start : constant Incr.Lexers.Batch_Lexers.State :=
Self.Get_Start_Condition;
begin
if Start = Apostrophe then
Self.Set_Start_Condition (Default);
end if;
Base_Lexers.Batch_Lexer (Self.all).Get_Token (Result);
if Result = 34 then
Result := Vertical_Line_Token;
elsif Result = 35 then
Result := Numeric_Literal_Token;
elsif Result = 36 then
Result := String_Literal_Token;
elsif Result > 36 then
Result := Error_Token;
elsif Result = 27 then
declare
Text : constant League.Strings.Universal_String :=
Self.Get_Text.To_Casefold;
Cursor : constant Maps.Cursor := Map.Find (Text);
begin
if Maps.Has_Element (Cursor) then
Result := Maps.Element (Cursor);
if Start = Apostrophe and Result /= Range_Token then
Result := Identifier_Token;
end if;
else
Result := Identifier_Token;
end if;
end;
elsif Result > 0 then
Result := Convert (Result);
end if;
if Result = Apostrophe_Token then
Self.Set_Start_Condition (Apostrophe);
else
Self.Set_Start_Condition (Default);
end if;
end Get_Token;
function "+" (V : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
begin
Map.Insert (+"abort", Abort_Token);
Map.Insert (+"abs", Abs_Token);
Map.Insert (+"abstract", Abstract_Token);
Map.Insert (+"accept", Accept_Token);
Map.Insert (+"access", Access_Token);
Map.Insert (+"aliased", Aliased_Token);
Map.Insert (+"all", All_Token);
Map.Insert (+"and", And_Token);
Map.Insert (+"array", Array_Token);
Map.Insert (+"at", At_Token);
Map.Insert (+"begin", Begin_Token);
Map.Insert (+"body", Body_Token);
Map.Insert (+"case", Case_Token);
Map.Insert (+"constant", Constant_Token);
Map.Insert (+"declare", Declare_Token);
Map.Insert (+"delay", Delay_Token);
Map.Insert (+"delta", Delta_Token);
Map.Insert (+"digits", Digits_Token);
Map.Insert (+"do", Do_Token);
Map.Insert (+"else", Else_Token);
Map.Insert (+"elsif", Elsif_Token);
Map.Insert (+"end", End_Token);
Map.Insert (+"entry", Entry_Token);
Map.Insert (+"exception", Exception_Token);
Map.Insert (+"exit", Exit_Token);
Map.Insert (+"for", For_Token);
Map.Insert (+"function", Function_Token);
Map.Insert (+"generic", Generic_Token);
Map.Insert (+"goto", Goto_Token);
Map.Insert (+"if", If_Token);
Map.Insert (+"in", In_Token);
Map.Insert (+"interface", Interface_Token);
Map.Insert (+"is", Is_Token);
Map.Insert (+"limited", Limited_Token);
Map.Insert (+"loop", Loop_Token);
Map.Insert (+"mod", Mod_Token);
Map.Insert (+"new", New_Token);
Map.Insert (+"not", Not_Token);
Map.Insert (+"null", Null_Token);
Map.Insert (+"of", Of_Token);
Map.Insert (+"or", Or_Token);
Map.Insert (+"others", Others_Token);
Map.Insert (+"out", Out_Token);
Map.Insert (+"overriding", Overriding_Token);
Map.Insert (+"package", Package_Token);
Map.Insert (+"pragma", Pragma_Token);
Map.Insert (+"private", Private_Token);
Map.Insert (+"procedure", Procedure_Token);
Map.Insert (+"protected", Protected_Token);
Map.Insert (+"raise", Raise_Token);
Map.Insert (+"range", Range_Token);
Map.Insert (+"record", Record_Token);
Map.Insert (+"rem", Rem_Token);
Map.Insert (+"renames", Renames_Token);
Map.Insert (+"requeue", Requeue_Token);
Map.Insert (+"return", Return_Token);
Map.Insert (+"reverse", Reverse_Token);
Map.Insert (+"select", Select_Token);
Map.Insert (+"separate", Separate_Token);
Map.Insert (+"some", Some_Token);
Map.Insert (+"subtype", Subtype_Token);
Map.Insert (+"synchronized", Synchronized_Token);
Map.Insert (+"tagged", Tagged_Token);
Map.Insert (+"task", Task_Token);
Map.Insert (+"terminate", Terminate_Token);
Map.Insert (+"then", Then_Token);
Map.Insert (+"type", Type_Token);
Map.Insert (+"until", Until_Token);
Map.Insert (+"use", Use_Token);
Map.Insert (+"when", When_Token);
Map.Insert (+"while", While_Token);
Map.Insert (+"with", With_Token);
Map.Insert (+"xor", Xor_Token);
end Ada_LSP.Ada_Lexers;
|
io7m/coreland-plexlog-ada | Ada | 1,494 | adb | with Ada.Command_Line;
with Ada.IO_Exceptions;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with getline;
with Plexlog.API;
procedure log is
package IO renames Ada.Text_IO;
package UStrings renames Ada.Strings.Unbounded;
max_files : Natural;
max_size : Plexlog.API.File_Size_t;
line : UStrings.Unbounded_String;
context : Plexlog.API.Plexlog_t;
begin
if Ada.Command_Line.Argument_Count /= 3 then
IO.Put_Line (IO.Current_Error, "usage: dir max_file max_size");
raise Program_Error;
end if;
max_files := Natural'Value (Ada.Command_Line.Argument (2));
max_size := Plexlog.API.File_Size_t'Value (Ada.Command_Line.Argument (3));
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Current_Error,
Item => "log: info: opening path");
Plexlog.API.Open (context, Ada.Command_Line.Argument (1));
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Current_Error,
Item => "log: info: opened directory");
Plexlog.API.Set_Maximum_Saved_Files (context, max_files);
Plexlog.API.Set_Maximum_File_Size (context, max_size);
begin
loop
getline.get (IO.Current_Input, line);
Plexlog.API.Write (context,
Level => Plexlog.API.Log_Info,
Data => UStrings.To_String (line));
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Current_Error,
Item => "log: info: wrote message");
UStrings.Set_Unbounded_String (line, "");
end loop;
exception
when Ada.IO_Exceptions.End_Error => null;
end;
end log;
|
reznikmm/matreshka | Ada | 464 | adb |
package body ORM.Fields is
-----------------
-- Is_Modified --
-----------------
function Is_Modified (Self : Abstract_Field'Class) return Boolean is
begin
return Self.Is_Modified;
end Is_Modified;
-----------------------
-- Reset_Is_Modified --
-----------------------
procedure Reset_Is_Modified (Self : in out Abstract_Field'Class) is
begin
Self.Is_Modified := False;
end Reset_Is_Modified;
end ORM.Fields;
|
jhumphry/auto_counters | Ada | 3,414 | adb | -- smart_ptr_example.adb
-- An example of using the Smart_Ptr types
-- Copyright (c) 2016-2023, James Humphry
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-- PERFORMANCE OF THIS SOFTWARE.
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
with Basic_Smart_Ptrs;
procedure Smart_Ptr_Example is
procedure Custom_Deleter(X : in out String) is
begin
Put_Line("Freeing resources relating to a string: " & X);
end Custom_Deleter;
package String_Ptrs is new Basic_Smart_Ptrs(T => String,
Delete => Custom_Deleter);
use String_Ptrs.Ptr_Types;
SP1 : Smart_Ptr := Make_Smart_Ptr(new String'("Hello, World!"));
begin
Put_Line("An example of using the Smart_Ptrs package."); New_Line;
Put_Line("SP1 => " & SP1.P);
Put("SP1.Use_Count => "); Put(SP1.Use_Count); New_Line;
New_Line; Flush;
declare
SP2 : Smart_Ptr;
begin
Put_Line("- In a new block");
Put_Line("- SP2 := SP1");
SP2 := SP1;
Put_Line("- SP2 => " & SP2.P);
Put("- SP1.Use_Count => "); Put(SP1.Use_Count); New_Line;
Put("- SP2.Use_Count => "); Put(SP2.Use_Count); New_Line;
Put_Line("- SP2.Get(6) := ';'");
SP2.Get(6) := ';';
Put_Line("- SP2 => " & SP2.P);
Put_Line("- End of block");
Flush;
end;
New_Line;
Put_Line("Now SP2 should have been destroyed.");
Put_Line("SP1 should still show the changes made via SP2.");
Put_Line("SP1 => " & SP1.P);
Put("SP1.Use_Count => "); Put(SP1.Use_Count); New_Line;
New_Line;
Put_Line("Reassigning SP1..."); Flush;
SP1 := Make_Smart_Ptr(new String'("Goodbye, World!"));
Put_Line("SP1 => " & SP1.P);
Put("SP1.Use_Count => "); Put(SP1.Use_Count); New_Line; Flush;
declare
WP1 : constant Weak_Ptr := Make_Weak_Ptr(SP1);
SP3 : Smart_Ptr;
begin
Put_Line("Made a Weak_Ptr WP1 from SP1.");
Put("SP1.Use_Count => "); Put(SP1.Use_Count); New_Line;
Put("SP1.Weak_Ptr_Count => "); Put(SP1.Weak_Ptr_Count); New_Line;
Put_Line("Recovering a Smart_Ptr SP3 from WP1"); Flush;
SP3 := WP1.Lock;
Put_Line("SP3 => " & SP3.P);
Put("SP3.Use_Count => "); Put(SP3.Use_Count); New_Line;
Put("SP3.Weak_Ptr_Count => "); Put(SP3.Weak_Ptr_Count); New_Line;
Put_Line("Now deleting SP1 and SP3. Resources should be freed here.");
Flush;
SP1 := Null_Smart_Ptr;
SP3 := Null_Smart_Ptr;
Put_Line("Check: SP1.Is_Null => " &
(if SP1.Is_Null then "True" else "False"));
Put("WP1.Use_Count => "); Put(WP1.Use_Count); New_Line;
Put_Line("WP1.Expired => " & (if WP1.Expired then "True" else "False"));
Flush;
end;
New_Line;
end Smart_Ptr_Example;
|
Intelligente-sanntidssystemer/Ada-prosjekt | Ada | 4,123 | adb | with NRF52_DK.Time;
with NRF52_DK.IOs;
with NRF52_DK.Buttons; use NRF52_DK.Buttons;
package body SteeringControl is
procedure Servocontrol(ServoPin : NRF52_DK.IOs.Pin_Id; Value : NRF52_DK.IOs.Analog_Value) is --Servo --
begin
--Writing values to the servo motor.
NRF52_DK.IOs.Write(ServoPin,Value);
NRF52_DK.IOs.Set_Analog_Period_Us(20000);
NRF52_DK.Time.Delay_Ms (2);
end Servocontrol;
procedure Direction_Controller is --Turning left/right with buttons by changing servo degrees --
begin
Servocontrol(3,300);
loop
while NRF52_DK.Buttons.State(Button_1) = Pressed loop
Servocontrol(3,200); --0value at 0 degrees, 200value medium state, 400value max degrees 180
if NRF52_DK.Buttons.State(Button_1) = Released then
Servocontrol(3,300);
end if;
end loop;
while (NRF52_DK.Buttons.State(Button_2) = Pressed) loop
Servocontrol(3,400); --0value at 0 degrees, 200value medium state, 400value max degrees 180
if NRF52_DK.Buttons.State(Button_2) = Released then
Servocontrol(3,300);
end if;
end loop;
end loop;
end Direction_Controller;
procedure Motor_Controller is --Forward/Backward using buttons --
begin
loop
--CLOCKWISE
while (NRF52_DK.Buttons.State(Button_3) = Pressed) loop -- DRIVE FORWARD --
NRF52_DK.IOs.Set (27, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, false);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, False);
NRF52_DK.Time.Delay_Ms (5);
end loop;
while (NRF52_DK.Buttons.State(Button_4) = Pressed) loop -- DRIVE Backward --
--Anti CLOCKWISE
NRF52_DK.IOs.Set (23, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, False);
NRF52_DK.Time.Delay_Ms (5);
end loop;
end loop;
end Motor_Controller;
procedure Crash_Stop_Forward is
begin
--This function will run when the sensor in front is triggering an emergency.
--The idea was so every time we tried to drive forward while the sensor in front
--is active, then this would run and run a loop of backwards on motor in order
--to even it out, since we thought it sounded better than stopping the motor completely.
--BACKWARD LOOP
NRF52_DK.IOs.Set (23, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, False);
NRF52_DK.Time.Delay_Ms (5);
end Crash_Stop_Forward;
procedure Crash_Stop_Backward is
begin
--Same thing here as with the function above, but here we run a forward loop.
--FORWARD LOOP
NRF52_DK.IOs.Set (27, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (27, false);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (21, False);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, True);
NRF52_DK.Time.Delay_Ms (5);
NRF52_DK.IOs.Set (23, False);
NRF52_DK.Time.Delay_Ms (5);
end Crash_Stop_Backward;
end SteeringControl;
|
Fabien-Chouteau/lvgl-ada | Ada | 67 | adb | procedure Check_Pix16_Swap is
begin
null;
end Check_Pix16_Swap;
|
reznikmm/matreshka | Ada | 4,810 | 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.Presentation_Date_Time_Elements;
package Matreshka.ODF_Presentation.Date_Time_Elements is
type Presentation_Date_Time_Element_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Element_Node
and ODF.DOM.Presentation_Date_Time_Elements.ODF_Presentation_Date_Time
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Presentation_Date_Time_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Date_Time_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Presentation_Date_Time_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 Presentation_Date_Time_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 Presentation_Date_Time_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_Presentation.Date_Time_Elements;
|
reznikmm/ada-pretty | Ada | 13,885 | ads | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.String_Vectors;
with League.Strings;
private with League.Pretty_Printers;
package Ada_Pretty is
type Node is abstract tagged private;
type Node_Access is access constant Node'Class;
type Node_Access_Array is array (Positive range <>) of not null Node_Access;
type Factory is tagged private;
not overriding function To_Text
(Self : access Factory;
Unit : not null Node_Access)
return League.String_Vectors.Universal_String_Vector;
-- Compilation units
not overriding function New_Compilation_Unit
(Self : access Factory;
Root : not null Node_Access;
Clauses : Node_Access := null;
License : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Subunit
(Self : access Factory;
Parent_Name : not null Node_Access;
Proper_Body : not null Node_Access) return not null Node_Access;
-- Node lists
not overriding function New_List
(Self : access Factory;
List : Node_Access_Array) return not null Node_Access;
not overriding function New_List
(Self : access Factory;
Head : Node_Access;
Tail : not null Node_Access) return not null Node_Access;
-- Add a Tail item to a Head list. Head could be
-- * a null value, that means an empty list. Result is Tail then.
-- * a non-list node, that means a list with single node inside.
-- * a list of items.
-- Clauses, Pragmas and Aspects
not overriding function New_Aspect
(Self : access Factory;
Name : not null Node_Access;
Value : Node_Access := null) return not null Node_Access;
not overriding function New_Pragma
(Self : access Factory;
Name : not null Node_Access;
Arguments : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Use
(Self : access Factory;
Name : not null Node_Access;
Use_Type : Boolean := False) return not null Node_Access;
not overriding function New_With
(Self : access Factory;
Name : not null Node_Access;
Is_Limited : Boolean := False;
Is_Private : Boolean := False) return not null Node_Access;
-- Declarations
not overriding function New_Package
(Self : access Factory;
Name : not null Node_Access;
Public_Part : Node_Access := null;
Private_Part : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Package_Body
(Self : access Factory;
Name : not null Node_Access;
List : Node_Access := null) return not null Node_Access;
not overriding function New_Package_Instantiation
(Self : access Factory;
Name : not null Node_Access;
Template : not null Node_Access;
Actual_Part : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Parameter
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access := null;
Is_In : Boolean := False;
Is_Out : Boolean := False;
Is_Aliased : Boolean := False;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Subprogram_Body
(Self : access Factory;
Specification : not null Node_Access;
Declarations : Node_Access := null;
Statements : Node_Access := null;
Exceptions : Node_Access := null) return not null Node_Access;
not overriding function New_Subprogram_Declaration
(Self : access Factory;
Specification : not null Node_Access;
Aspects : Node_Access := null;
Is_Abstract : Boolean := False;
Is_Null : Boolean := False;
Expression : Node_Access := null;
Renamed : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Subtype
(Self : access Factory;
Name : not null Node_Access;
Definition : not null Node_Access;
Constrain : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Type
(Self : access Factory;
Name : not null Node_Access;
Discriminants : Node_Access := null;
Definition : Node_Access := null;
Aspects : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
not overriding function New_Variable
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : Node_Access := null;
Initialization : Node_Access := null;
Rename : Node_Access := null;
Is_Constant : Boolean := False;
Is_Aliased : Boolean := False;
Aspects : Node_Access := null;
Comment : League.Strings.Universal_String :=
League.Strings.Empty_Universal_String) return not null Node_Access;
-- Definitions
type Access_Modifier is (Access_All, Access_Constant, Unspecified);
not overriding function New_Access
(Self : access Factory;
Modifier : Access_Modifier := Unspecified;
Target : not null Node_Access) return not null Node_Access;
not overriding function New_Derived
(Self : access Factory;
Parent : not null Node_Access) return not null Node_Access;
not overriding function New_Null_Exclusion
(Self : access Factory;
Definition : not null Node_Access;
Exclude : Boolean := True) return not null Node_Access;
not overriding function New_Interface
(Self : access Factory;
Is_Limited : Boolean := False;
Parents : Node_Access := null) return not null Node_Access;
not overriding function New_Private_Record
(Self : access Factory;
Is_Tagged : Boolean := False;
Is_Limited : Boolean := False;
Parents : Node_Access := null) return not null Node_Access;
not overriding function New_Record
(Self : access Factory;
Parent : Node_Access := null;
Components : Node_Access := null;
Is_Abstract : Boolean := False;
Is_Tagged : Boolean := False;
Is_Limited : Boolean := False) return not null Node_Access;
not overriding function New_Array
(Self : access Factory;
Indexes : not null Node_Access;
Component : not null Node_Access) return not null Node_Access;
type Trilean is (False, True, Unspecified);
not overriding function New_Subprogram_Specification
(Self : access Factory;
Is_Overriding : Trilean := Unspecified;
Name : Node_Access := null;
Parameters : Node_Access := null;
Result : Node_Access := null) return not null Node_Access;
-- Expressions and Names
not overriding function New_Apply
(Self : access Factory;
Prefix : not null Node_Access;
Arguments : not null Node_Access) return not null Node_Access;
-- This node represent construction in form 'prefix (arguments)'
-- This includes function_call, indexed_component, slice,
-- subtype_indication, etc
not overriding function New_Qualified_Expession
(Self : access Factory;
Prefix : not null Node_Access;
Argument : not null Node_Access) return not null Node_Access;
not overriding function New_Infix
(Self : access Factory;
Operator : League.Strings.Universal_String;
Left : not null Node_Access) return not null Node_Access;
not overriding function New_Literal
(Self : access Factory;
Value : Natural;
Base : Positive := 10) return not null Node_Access;
not overriding function New_Name
(Self : access Factory;
Name : League.Strings.Universal_String) return not null Node_Access;
-- Identifier, character literal ('X'), operator ("<")
not overriding function New_Selected_Name
(Self : access Factory;
Name : League.Strings.Universal_String) return not null Node_Access;
not overriding function New_Selected_Name
(Self : access Factory;
Prefix : not null Node_Access;
Selector : not null Node_Access) return not null Node_Access;
not overriding function New_String_Literal
(Self : access Factory;
Text : League.Strings.Universal_String) return not null Node_Access;
not overriding function New_Parentheses
(Self : access Factory;
Child : not null Node_Access) return not null Node_Access;
not overriding function New_Argument_Association
(Self : access Factory;
Value : not null Node_Access;
Choice : Node_Access := null) return not null Node_Access;
not overriding function New_Component_Association
(Self : access Factory;
Value : not null Node_Access;
Choices : Node_Access := null) return not null Node_Access;
not overriding function New_If_Expression
(Self : access Factory;
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access := null;
Else_Path : Node_Access := null) return not null Node_Access;
-- Statements and Paths
not overriding function New_Assignment
(Self : access Factory;
Left : not null Node_Access;
Right : not null Node_Access) return not null Node_Access;
not overriding function New_Case
(Self : access Factory;
Expression : not null Node_Access;
List : not null Node_Access) return not null Node_Access;
not overriding function New_Case_Path
(Self : access Factory;
Choice : not null Node_Access;
List : not null Node_Access) return not null Node_Access;
not overriding function New_Elsif
(Self : access Factory;
Condition : not null Node_Access;
List : not null Node_Access) return not null Node_Access;
not overriding function New_If
(Self : access Factory;
Condition : not null Node_Access;
Then_Path : not null Node_Access;
Elsif_List : Node_Access := null;
Else_Path : Node_Access := null) return not null Node_Access;
not overriding function New_For
(Self : access Factory;
Name : not null Node_Access;
Iterator : not null Node_Access;
Statements : not null Node_Access) return not null Node_Access;
not overriding function New_Loop
(Self : access Factory;
Condition : Node_Access;
Statements : not null Node_Access) return not null Node_Access;
not overriding function New_Return
(Self : access Factory;
Expression : Node_Access := null) return not null Node_Access;
not overriding function New_Extended_Return
(Self : access Factory;
Name : not null Node_Access;
Type_Definition : not null Node_Access;
Initialization : Node_Access := null;
Statements : not null Node_Access) return not null Node_Access;
not overriding function New_Statement
(Self : access Factory;
Expression : Node_Access := null) return not null Node_Access;
not overriding function New_Block
(Self : access Factory;
Declarations : Node_Access := null;
Statements : Node_Access := null;
Exceptions : Node_Access := null) return not null Node_Access;
private
type Node is abstract tagged null record;
not overriding function Document
(Self : Node;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
not overriding function Max_Pad (Self : Node) return Natural is (0);
-- Return maximum lengh of name in Node
not overriding function Join
(Self : Node;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document;
-- Join documents of several nodes in a list
type Expression is abstract new Node with null record;
overriding function Join
(Self : Expression;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document;
type Declaration is abstract new Node with null record;
overriding function Join
(Self : Declaration;
List : Node_Access_Array;
Pad : Natural;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document;
-- Declarations are separated by an extra new line
type Factory is tagged null record;
function Print_Aspect
(Aspect : Node_Access;
Printer : not null access League.Pretty_Printers.Printer'Class)
return League.Pretty_Printers.Document;
end Ada_Pretty;
|
meowthsli/EVB1000 | Ada | 31,252 | ads | -- This spec has been automatically generated from STM32F105xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with System;
package STM32.BKP is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- DR1_Register --
------------------
subtype DR1_D1_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR1_Register is record
-- Backup data
D1 : DR1_D1_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR1_Register use record
D1 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR2_Register --
------------------
subtype DR2_D2_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR2_Register is record
-- Backup data
D2 : DR2_D2_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR2_Register use record
D2 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR3_Register --
------------------
subtype DR3_D3_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR3_Register is record
-- Backup data
D3 : DR3_D3_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR3_Register use record
D3 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR4_Register --
------------------
subtype DR4_D4_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR4_Register is record
-- Backup data
D4 : DR4_D4_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR4_Register use record
D4 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR5_Register --
------------------
subtype DR5_D5_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR5_Register is record
-- Backup data
D5 : DR5_D5_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR5_Register use record
D5 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR6_Register --
------------------
subtype DR6_D6_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR6_Register is record
-- Backup data
D6 : DR6_D6_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR6_Register use record
D6 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR7_Register --
------------------
subtype DR7_D7_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR7_Register is record
-- Backup data
D7 : DR7_D7_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR7_Register use record
D7 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR8_Register --
------------------
subtype DR8_D8_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR8_Register is record
-- Backup data
D8 : DR8_D8_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR8_Register use record
D8 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- DR9_Register --
------------------
subtype DR9_D9_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR9_Register is record
-- Backup data
D9 : DR9_D9_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR9_Register use record
D9 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR10_Register --
-------------------
subtype DR10_D10_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR10_Register is record
-- Backup data
D10 : DR10_D10_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR10_Register use record
D10 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------
-- RTCCR_Register --
--------------------
subtype RTCCR_CAL_Field is STM32.UInt7;
subtype RTCCR_CCO_Field is STM32.Bit;
-- RTC clock calibration register (BKP_RTCCR)
type RTCCR_Register is record
-- Calibration value
CAL : RTCCR_CAL_Field := 16#0#;
-- Calibration Clock Output
CCO : RTCCR_CCO_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTCCR_Register use record
CAL at 0 range 0 .. 6;
CCO at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- CR_Register --
-----------------
subtype CR_TPE_Field is STM32.Bit;
subtype CR_TPAL_Field is STM32.Bit;
-- Backup control register (BKP_CR)
type CR_Register is record
-- Tamper pin enable
TPE : CR_TPE_Field := 16#0#;
-- Tamper pin active level
TPAL : CR_TPAL_Field := 16#0#;
-- unspecified
Reserved_2_31 : STM32.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
TPE at 0 range 0 .. 0;
TPAL at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
------------------
-- CSR_Register --
------------------
subtype CSR_CTE_Field is STM32.Bit;
subtype CSR_CTI_Field is STM32.Bit;
subtype CSR_TPIE_Field is STM32.Bit;
subtype CSR_TEF_Field is STM32.Bit;
subtype CSR_TIF_Field is STM32.Bit;
-- BKP_CSR control/status register
type CSR_Register is record
-- Write-only. Clear Tamper event
CTE : CSR_CTE_Field := 16#0#;
-- Write-only. Clear Tamper Interrupt
CTI : CSR_CTI_Field := 16#0#;
-- Tamper Pin interrupt enable
TPIE : CSR_TPIE_Field := 16#0#;
-- unspecified
Reserved_3_7 : STM32.UInt5 := 16#0#;
-- Read-only. Tamper Event Flag
TEF : CSR_TEF_Field := 16#0#;
-- Read-only. Tamper Interrupt Flag
TIF : CSR_TIF_Field := 16#0#;
-- unspecified
Reserved_10_31 : STM32.UInt22 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
CTE at 0 range 0 .. 0;
CTI at 0 range 1 .. 1;
TPIE at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
TEF at 0 range 8 .. 8;
TIF at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-------------------
-- DR11_Register --
-------------------
subtype DR11_DR11_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR11_Register is record
-- Backup data
DR11 : DR11_DR11_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR11_Register use record
DR11 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR12_Register --
-------------------
subtype DR12_DR12_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR12_Register is record
-- Backup data
DR12 : DR12_DR12_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR12_Register use record
DR12 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR13_Register --
-------------------
subtype DR13_DR13_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR13_Register is record
-- Backup data
DR13 : DR13_DR13_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR13_Register use record
DR13 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR14_Register --
-------------------
subtype DR14_D14_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR14_Register is record
-- Backup data
D14 : DR14_D14_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR14_Register use record
D14 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR15_Register --
-------------------
subtype DR15_D15_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR15_Register is record
-- Backup data
D15 : DR15_D15_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR15_Register use record
D15 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR16_Register --
-------------------
subtype DR16_D16_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR16_Register is record
-- Backup data
D16 : DR16_D16_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR16_Register use record
D16 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR17_Register --
-------------------
subtype DR17_D17_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR17_Register is record
-- Backup data
D17 : DR17_D17_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR17_Register use record
D17 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR18_Register --
-------------------
subtype DR18_D18_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR18_Register is record
-- Backup data
D18 : DR18_D18_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR18_Register use record
D18 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR19_Register --
-------------------
subtype DR19_D19_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR19_Register is record
-- Backup data
D19 : DR19_D19_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR19_Register use record
D19 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR20_Register --
-------------------
subtype DR20_D20_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR20_Register is record
-- Backup data
D20 : DR20_D20_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR20_Register use record
D20 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR21_Register --
-------------------
subtype DR21_D21_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR21_Register is record
-- Backup data
D21 : DR21_D21_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR21_Register use record
D21 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR22_Register --
-------------------
subtype DR22_D22_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR22_Register is record
-- Backup data
D22 : DR22_D22_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR22_Register use record
D22 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR23_Register --
-------------------
subtype DR23_D23_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR23_Register is record
-- Backup data
D23 : DR23_D23_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR23_Register use record
D23 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR24_Register --
-------------------
subtype DR24_D24_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR24_Register is record
-- Backup data
D24 : DR24_D24_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR24_Register use record
D24 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR25_Register --
-------------------
subtype DR25_D25_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR25_Register is record
-- Backup data
D25 : DR25_D25_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR25_Register use record
D25 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR26_Register --
-------------------
subtype DR26_D26_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR26_Register is record
-- Backup data
D26 : DR26_D26_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR26_Register use record
D26 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR27_Register --
-------------------
subtype DR27_D27_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR27_Register is record
-- Backup data
D27 : DR27_D27_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR27_Register use record
D27 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR28_Register --
-------------------
subtype DR28_D28_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR28_Register is record
-- Backup data
D28 : DR28_D28_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR28_Register use record
D28 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR29_Register --
-------------------
subtype DR29_D29_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR29_Register is record
-- Backup data
D29 : DR29_D29_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR29_Register use record
D29 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR30_Register --
-------------------
subtype DR30_D30_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR30_Register is record
-- Backup data
D30 : DR30_D30_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR30_Register use record
D30 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR31_Register --
-------------------
subtype DR31_D31_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR31_Register is record
-- Backup data
D31 : DR31_D31_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR31_Register use record
D31 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR32_Register --
-------------------
subtype DR32_D32_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR32_Register is record
-- Backup data
D32 : DR32_D32_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR32_Register use record
D32 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR33_Register --
-------------------
subtype DR33_D33_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR33_Register is record
-- Backup data
D33 : DR33_D33_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR33_Register use record
D33 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR34_Register --
-------------------
subtype DR34_D34_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR34_Register is record
-- Backup data
D34 : DR34_D34_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR34_Register use record
D34 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR35_Register --
-------------------
subtype DR35_D35_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR35_Register is record
-- Backup data
D35 : DR35_D35_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR35_Register use record
D35 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR36_Register --
-------------------
subtype DR36_D36_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR36_Register is record
-- Backup data
D36 : DR36_D36_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR36_Register use record
D36 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR37_Register --
-------------------
subtype DR37_D37_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR37_Register is record
-- Backup data
D37 : DR37_D37_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR37_Register use record
D37 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR38_Register --
-------------------
subtype DR38_D38_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR38_Register is record
-- Backup data
D38 : DR38_D38_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR38_Register use record
D38 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR39_Register --
-------------------
subtype DR39_D39_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR39_Register is record
-- Backup data
D39 : DR39_D39_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR39_Register use record
D39 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR40_Register --
-------------------
subtype DR40_D40_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR40_Register is record
-- Backup data
D40 : DR40_D40_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR40_Register use record
D40 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR41_Register --
-------------------
subtype DR41_D41_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR41_Register is record
-- Backup data
D41 : DR41_D41_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR41_Register use record
D41 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- DR42_Register --
-------------------
subtype DR42_D42_Field is STM32.Short;
-- Backup data register (BKP_DR)
type DR42_Register is record
-- Backup data
D42 : DR42_D42_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR42_Register use record
D42 at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Backup registers
type BKP_Peripheral is record
-- Backup data register (BKP_DR)
DR1 : DR1_Register;
-- Backup data register (BKP_DR)
DR2 : DR2_Register;
-- Backup data register (BKP_DR)
DR3 : DR3_Register;
-- Backup data register (BKP_DR)
DR4 : DR4_Register;
-- Backup data register (BKP_DR)
DR5 : DR5_Register;
-- Backup data register (BKP_DR)
DR6 : DR6_Register;
-- Backup data register (BKP_DR)
DR7 : DR7_Register;
-- Backup data register (BKP_DR)
DR8 : DR8_Register;
-- Backup data register (BKP_DR)
DR9 : DR9_Register;
-- Backup data register (BKP_DR)
DR10 : DR10_Register;
-- RTC clock calibration register (BKP_RTCCR)
RTCCR : RTCCR_Register;
-- Backup control register (BKP_CR)
CR : CR_Register;
-- BKP_CSR control/status register
CSR : CSR_Register;
-- Backup data register (BKP_DR)
DR11 : DR11_Register;
-- Backup data register (BKP_DR)
DR12 : DR12_Register;
-- Backup data register (BKP_DR)
DR13 : DR13_Register;
-- Backup data register (BKP_DR)
DR14 : DR14_Register;
-- Backup data register (BKP_DR)
DR15 : DR15_Register;
-- Backup data register (BKP_DR)
DR16 : DR16_Register;
-- Backup data register (BKP_DR)
DR17 : DR17_Register;
-- Backup data register (BKP_DR)
DR18 : DR18_Register;
-- Backup data register (BKP_DR)
DR19 : DR19_Register;
-- Backup data register (BKP_DR)
DR20 : DR20_Register;
-- Backup data register (BKP_DR)
DR21 : DR21_Register;
-- Backup data register (BKP_DR)
DR22 : DR22_Register;
-- Backup data register (BKP_DR)
DR23 : DR23_Register;
-- Backup data register (BKP_DR)
DR24 : DR24_Register;
-- Backup data register (BKP_DR)
DR25 : DR25_Register;
-- Backup data register (BKP_DR)
DR26 : DR26_Register;
-- Backup data register (BKP_DR)
DR27 : DR27_Register;
-- Backup data register (BKP_DR)
DR28 : DR28_Register;
-- Backup data register (BKP_DR)
DR29 : DR29_Register;
-- Backup data register (BKP_DR)
DR30 : DR30_Register;
-- Backup data register (BKP_DR)
DR31 : DR31_Register;
-- Backup data register (BKP_DR)
DR32 : DR32_Register;
-- Backup data register (BKP_DR)
DR33 : DR33_Register;
-- Backup data register (BKP_DR)
DR34 : DR34_Register;
-- Backup data register (BKP_DR)
DR35 : DR35_Register;
-- Backup data register (BKP_DR)
DR36 : DR36_Register;
-- Backup data register (BKP_DR)
DR37 : DR37_Register;
-- Backup data register (BKP_DR)
DR38 : DR38_Register;
-- Backup data register (BKP_DR)
DR39 : DR39_Register;
-- Backup data register (BKP_DR)
DR40 : DR40_Register;
-- Backup data register (BKP_DR)
DR41 : DR41_Register;
-- Backup data register (BKP_DR)
DR42 : DR42_Register;
end record
with Volatile;
for BKP_Peripheral use record
DR1 at 0 range 0 .. 31;
DR2 at 4 range 0 .. 31;
DR3 at 8 range 0 .. 31;
DR4 at 12 range 0 .. 31;
DR5 at 16 range 0 .. 31;
DR6 at 20 range 0 .. 31;
DR7 at 24 range 0 .. 31;
DR8 at 28 range 0 .. 31;
DR9 at 32 range 0 .. 31;
DR10 at 36 range 0 .. 31;
RTCCR at 40 range 0 .. 31;
CR at 44 range 0 .. 31;
CSR at 48 range 0 .. 31;
DR11 at 60 range 0 .. 31;
DR12 at 64 range 0 .. 31;
DR13 at 68 range 0 .. 31;
DR14 at 72 range 0 .. 31;
DR15 at 76 range 0 .. 31;
DR16 at 80 range 0 .. 31;
DR17 at 84 range 0 .. 31;
DR18 at 88 range 0 .. 31;
DR19 at 92 range 0 .. 31;
DR20 at 96 range 0 .. 31;
DR21 at 100 range 0 .. 31;
DR22 at 104 range 0 .. 31;
DR23 at 108 range 0 .. 31;
DR24 at 112 range 0 .. 31;
DR25 at 116 range 0 .. 31;
DR26 at 120 range 0 .. 31;
DR27 at 124 range 0 .. 31;
DR28 at 128 range 0 .. 31;
DR29 at 132 range 0 .. 31;
DR30 at 136 range 0 .. 31;
DR31 at 140 range 0 .. 31;
DR32 at 144 range 0 .. 31;
DR33 at 148 range 0 .. 31;
DR34 at 152 range 0 .. 31;
DR35 at 156 range 0 .. 31;
DR36 at 160 range 0 .. 31;
DR37 at 164 range 0 .. 31;
DR38 at 168 range 0 .. 31;
DR39 at 172 range 0 .. 31;
DR40 at 176 range 0 .. 31;
DR41 at 180 range 0 .. 31;
DR42 at 184 range 0 .. 31;
end record;
-- Backup registers
BKP_Periph : aliased BKP_Peripheral
with Import, Address => BKP_Base;
end STM32.BKP;
|
reznikmm/matreshka | Ada | 7,654 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2016, 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 package represents a parameter of form that was received. It works
-- with files transferred within a multipart/form-data POST request.
------------------------------------------------------------------------------
with Ada.Streams;
with League.Strings;
with League.String_Vectors;
package Servlet.HTTP_Parameters is
pragma Preelaborate;
type HTTP_Parameter is tagged private;
function Get_Content_Type
(Self : HTTP_Parameter'Class) return League.Strings.Universal_String;
-- Gets the content type of this parameter.
function Get_Header
(Self : HTTP_Parameter'Class;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Returns the value of the specified mime header as a string. If the
-- Parameter did not include a header of the specified name, this method
-- returns empty string. If there are multiple headers with the same name,
-- this method returns the first header in the part. The header name is
-- case insensitive. You can use this method with any request header.
function Get_Headers
(Self : HTTP_Parameter'Class;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector;
-- Gets the values of the Patameter header with the given name. Parameter
-- header names are case insensitive.
function Get_Header_Names
(Self : HTTP_Parameter'Class)
return League.String_Vectors.Universal_String_Vector;
-- Gets the header names of this Parameter. Some servlet containers do not
-- allow servlets to access headers using this method, in which case this
-- method returns empty vector.
function Get_Input_Stream
(Self : HTTP_Parameter'Class)
return access Ada.Streams.Root_Stream_Type'Class;
-- Gets the content of this parameter as an stream.
function Get_Name
(Self : HTTP_Parameter'Class) return League.Strings.Universal_String;
-- Gets the name of this parameter.
function Get_Size
(Self : HTTP_Parameter'Class) return Ada.Streams.Stream_Element_Count;
-- Returns the size of this file.
function Get_Submitted_File_Name
(Self : HTTP_Parameter'Class) return League.Strings.Universal_String;
-- Gets the file name specified by the client.
procedure Write
(Self : HTTP_Parameter'Class;
File_Name : League.Strings.Universal_String);
-- A convenience method to write this uploaded item to disk.
--
-- This method is not guaranteed to succeed if called more than once for
-- the same parameter. This allows a particular implementation to use, for
-- example, file renaming, where possible, rather than copying all of the
-- underlying data, thus gaining a significant performance benefit.
private
type Abstract_Parameter is abstract tagged limited null record;
-- Internal representation of HTTP parameter.
type Parameter_Access is access all Abstract_Parameter'Class;
not overriding function Get_Content_Type
(Self : Abstract_Parameter) return League.Strings.Universal_String
is abstract;
not overriding function Get_Headers
(Self : Abstract_Parameter;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector is abstract;
not overriding function Get_Header_Names
(Self : Abstract_Parameter)
return League.String_Vectors.Universal_String_Vector is abstract;
not overriding function Get_Input_Stream
(Self : Abstract_Parameter)
return access Ada.Streams.Root_Stream_Type'Class is abstract;
not overriding function Get_Name
(Self : Abstract_Parameter) return League.Strings.Universal_String
is abstract;
not overriding function Get_Size
(Self : Abstract_Parameter) return Ada.Streams.Stream_Element_Count
is abstract;
not overriding function Get_Submitted_File_Name
(Self : Abstract_Parameter) return League.Strings.Universal_String
is abstract;
not overriding procedure Write
(Self : Abstract_Parameter;
File_Name : League.Strings.Universal_String);
--------------------
-- HTTP_Parameter --
--------------------
type HTTP_Parameter is tagged record
Parameter : Parameter_Access;
end record;
end Servlet.HTTP_Parameters;
|
AdaCore/Ada_Drivers_Library | Ada | 3,450 | 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. --
-- --
------------------------------------------------------------------------------
-- This package provides a simple software synthesizer that can be used to try
-- audio streams and DACs.
with HAL.Audio; use HAL.Audio;
package Simple_Synthesizer is
type Synthesizer (Stereo : Boolean := True;
Amplitude : Natural := 500) is
limited new Audio_Stream with private;
procedure Set_Note_Frequency (This : in out Synthesizer;
Note : Float);
overriding
procedure Set_Frequency (This : in out Synthesizer;
Frequency : Audio_Frequency);
overriding
procedure Transmit (This : in out Synthesizer;
Data : Audio_Buffer);
overriding
procedure Receive (This : in out Synthesizer;
Data : out Audio_Buffer);
private
type Synthesizer (Stereo : Boolean := True;
Amplitude : Natural := 500) is
limited new Audio_Stream with record
Frequency : Audio_Frequency;
Note : Float := 0.0;
Last_Sample : Float := 0.0;
end record;
end Simple_Synthesizer;
|
AdaCore/libadalang | Ada | 81 | ads | generic
X : Integer;
package Pkg.Impl_G is
procedure Test;
end Pkg.Impl_G;
|
reznikmm/matreshka | Ada | 12,141 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.Element_Collections;
with AMF.Internals.Tables.DI_Metamodel;
with AMF.Internals.Tables.Standard_Profile_L2_Metamodel;
with AMF.Internals.Tables.Standard_Profile_L3_Metamodel;
with AMF.Internals.Tables.UML_Attribute_Mappings;
with AMF.Internals.Tables.UML_Element_Table;
with AMF.Internals.Tables.UML_Metamodel;
with AMF.Internals.Tables.UMLDI_Metamodel;
package body AMF.Internals.Factories.UML_Module_Factory is
procedure Construct_Union
(Element : AMF.Internals.AMF_Element;
Property : AMF.Internals.CMOF_Element;
Link : AMF.Internals.AMF_Link);
--------------------
-- Connect_Extent --
--------------------
overriding procedure Connect_Extent
(Self : not null access constant UML_Module_Factory;
Element : AMF.Internals.AMF_Element;
Extent : AMF.Internals.AMF_Extent)
is
pragma Unreferenced (Self);
begin
AMF.Internals.Tables.UML_Element_Table.Table (Element).Extent := Extent;
end Connect_Extent;
----------------------
-- Connect_Link_End --
----------------------
overriding procedure Connect_Link_End
(Self : not null access constant UML_Module_Factory;
Element : AMF.Internals.AMF_Element;
Property : AMF.Internals.CMOF_Element;
Link : AMF.Internals.AMF_Link;
Other : AMF.Internals.AMF_Element)
is
pragma Unreferenced (Self);
use AMF.Internals.Tables;
use AMF.Internals.Tables.DI_Metamodel;
use AMF.Internals.Tables.Standard_Profile_L2_Metamodel;
use AMF.Internals.Tables.Standard_Profile_L3_Metamodel;
use AMF.Internals.Tables.UML_Attribute_Mappings;
use AMF.Internals.Tables.UML_Metamodel;
use AMF.Internals.Tables.UMLDI_Metamodel;
begin
-- Properties which comes from UML metamodel.
if Property in MB_UML .. ML_UML then
declare
PO : constant AMF.Internals.CMOF_Element := Property - MB_UML;
begin
if PO in UML_Collection_Offset'Range (2) then
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection
+ UML_Collection_Offset
(UML_Element_Table.Table (Element).Kind, PO),
Other,
Link);
elsif PO in UML_Member_Offset'Range (2)
and then UML_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO) /= 0
then
UML_Element_Table.Table (Element).Member
(UML_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO)).Link := Link;
else
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection,
Other,
Link);
end if;
end;
elsif Property in MB_Standard_Profile_L2 .. ML_Standard_Profile_L2 then
declare
PO : constant AMF.Internals.CMOF_Element
:= Property - MB_Standard_Profile_L2;
begin
if PO in Standard_Profile_L2_Collection_Offset'Range (2) then
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection
+ Standard_Profile_L2_Collection_Offset
(UML_Element_Table.Table (Element).Kind, PO),
Other,
Link);
elsif PO in Standard_Profile_L2_Member_Offset'Range (2)
and then Standard_Profile_L2_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO) /= 0
then
UML_Element_Table.Table (Element).Member
(Standard_Profile_L2_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO)).Link := Link;
else
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection,
Other,
Link);
end if;
end;
elsif Property in MB_Standard_Profile_L3 .. ML_Standard_Profile_L3 then
declare
PO : constant AMF.Internals.CMOF_Element
:= Property - MB_Standard_Profile_L3;
begin
if PO in Standard_Profile_L3_Collection_Offset'Range (2) then
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection
+ Standard_Profile_L3_Collection_Offset
(UML_Element_Table.Table (Element).Kind, PO),
Other,
Link);
elsif PO in Standard_Profile_L3_Member_Offset'Range (2)
and then Standard_Profile_L3_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO) /= 0
then
UML_Element_Table.Table (Element).Member
(Standard_Profile_L3_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO)).Link := Link;
else
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection,
Other,
Link);
end if;
end;
elsif Property in MB_DI .. ML_DI then
declare
PO : constant AMF.Internals.CMOF_Element
:= Property - MB_DI;
begin
if PO in DI_Collection_Offset'Range (2) then
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection
+ DI_Collection_Offset
(UML_Element_Table.Table (Element).Kind, PO),
Other,
Link);
elsif PO in DI_Member_Offset'Range (2)
and then DI_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO) /= 0
then
UML_Element_Table.Table (Element).Member
(DI_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO)).Link := Link;
else
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection,
Other,
Link);
end if;
end;
elsif Property in MB_UMLDI .. ML_UMLDI then
declare
PO : constant AMF.Internals.CMOF_Element
:= Property - MB_UMLDI;
begin
if PO in UMLDI_Collection_Offset'Range (2) then
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection
+ UMLDI_Collection_Offset
(UML_Element_Table.Table (Element).Kind, PO),
Other,
Link);
elsif PO in UMLDI_Member_Offset'Range (2)
and then UMLDI_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO) /= 0
then
UML_Element_Table.Table (Element).Member
(UMLDI_Member_Offset
(UML_Element_Table.Table (Element).Kind, PO)).Link := Link;
else
AMF.Internals.Element_Collections.Internal_Append
(UML_Element_Table.Table (Element).Member (0).Collection,
Other,
Link);
end if;
end;
end if;
end Connect_Link_End;
---------------------
-- Construct_Union --
---------------------
procedure Construct_Union
(Element : AMF.Internals.AMF_Element;
Property : AMF.Internals.CMOF_Element;
Link : AMF.Internals.AMF_Link) is separate;
--------------------------
-- Synchronize_Link_Set --
--------------------------
overriding procedure Synchronize_Link_Set
(Self : not null access constant UML_Module_Factory;
Element : AMF.Internals.AMF_Element;
Property : AMF.Internals.CMOF_Element;
Link : AMF.Internals.AMF_Link) is
begin
-- Construct derived unions.
Construct_Union (Element, Property, Link);
end Synchronize_Link_Set;
----------------
-- To_Element --
----------------
overriding function To_Element
(Self : not null access constant UML_Module_Factory;
Element : AMF.Internals.AMF_Element) return AMF.Elements.Element_Access
is
pragma Unreferenced (Self);
begin
return AMF.Internals.Tables.UML_Element_Table.Table (Element).Proxy;
end To_Element;
end AMF.Internals.Factories.UML_Module_Factory;
|
reznikmm/matreshka | Ada | 4,655 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Reference_Format_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Reference_Format_Attribute_Node is
begin
return Self : Text_Reference_Format_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Reference_Format_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Reference_Format_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Reference_Format_Attribute,
Text_Reference_Format_Attribute_Node'Tag);
end Matreshka.ODF_Text.Reference_Format_Attributes;
|
ALPHA-60/ada-keystore | Ada | 15,678 | ads | -----------------------------------------------------------------------
-- keystore -- Ada keystore
-- 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 Util.Encoders;
with Util.Streams;
with Ada.Streams;
with Ada.Calendar;
with Ada.Containers.Indefinite_Ordered_Maps;
with Interfaces;
with GNAT.Regpat;
private with Ada.Exceptions;
private with Ada.Finalization;
private with Util.Executors;
-- == Keystore ==
-- The `Keystore` package provides operations to store information in secure wallets and
-- protect the stored information by encrypting the content. It is necessary to know one
-- of the wallet password to access its content. Wallets are protected by a master key
-- using AES-256 and the wallet master key is protected by a user password. The wallet
-- defines up to 7 slots that identify a password key that is able to unlock the master key.
-- To open a wallet, it is necessary to unlock one of the 7 slots by providing the correct
-- password. Wallet key slots are protected by the user's password and the PBKDF2-HMAC-256
-- algorithm, a random salt, a random counter and they are encrypted using AES-256.
--
-- === Creation ===
-- To create a keystore you will first declare a `Wallet_File` instance. You will also need
-- a password that will be used to protect the wallet master key.
--
-- with Keystore.Files;
-- ...
-- WS : Keystore.Files.Wallet_File;
-- Pass : Keystore.Secret := Keystore.Create ("There was no choice but to be pioneers");
--
-- You can then create the keystore file by using the `Create` operation:
--
-- WS.Create ("secure.akt", Pass);
--
-- === Storing ===
-- Values stored in the wallet are protected by their own encryption keys using AES-256.
-- The encryption key is generated when the value is added to the wallet by using the `Add`
-- operation.
--
-- WS.Add ("Grace Hopper", "If it's a good idea, go ahead and do it.");
--
-- The `Get` function allows to retrieve the value. The value is decrypted only when the `Get`
-- operation is called.
--
-- Citation : constant String := WS.Get ("Grace Hopper");
--
-- The `Delete` procedure can be used to remove the value. When the value is removed,
-- the encryption key and the data are erased.
--
-- WS.Delete ("Grace Hopper");
--
package Keystore is
subtype Secret_Key is Util.Encoders.Secret_Key;
subtype Key_Length is Util.Encoders.Key_Length;
function Create (Password : in String) return Secret_Key
renames Util.Encoders.Create;
-- Exception raised when a keystore entry was not found.
Not_Found : exception;
-- Exception raised when a keystore entry already exist.
Name_Exist : exception;
-- Exception raised when the wallet cannot be opened with the given password.
Bad_Password : exception;
-- Exception raised by Set_Key when there is no available free slot to add a new key.
No_Key_Slot : exception;
-- Exception raised by Set_Header_Data when the slot index is out of range.
No_Header_Slot : exception;
-- Exception raised when trying to get/set an item which is a wallet.
No_Content : exception;
-- The key slot is used (it cannot be erased unless the operation is forced).
Used_Key_Slot : exception;
-- Exception raised when the wallet is corrupted.
Corrupted : exception;
-- Exception raised when opening the keystore and the header is invalid.
Invalid_Keystore : exception;
-- Exception raised when there is a configuration issue.
Invalid_Config : exception;
-- Invalid data block when reading the wallet.
Invalid_Block : exception;
-- Invalid HMAC signature when reading a block.
Invalid_Signature : exception;
-- Invalid storage identifier when loading a wallet data block.
Invalid_Storage : exception;
-- The wallet state.
type State_Type is (S_INVALID, S_PROTECTED, S_OPEN, S_CLOSED);
-- Identifies the type of data stored for a named entry in the wallet.
type Entry_Type is (T_INVALID, T_STRING, T_FILE, T_DIRECTORY, T_BINARY, T_WALLET);
type Filter_Type is array (Entry_Type) of Boolean;
-- Defines the key operation mode.
type Mode_Type is (KEY_ADD, KEY_REPLACE, KEY_REMOVE, KEY_REMOVE_LAST);
-- Defines the key slot number.
type Key_Slot is new Positive range 1 .. 7;
-- Defines which key slot is used.
type Key_Slot_Allocation is array (Key_Slot) of Boolean;
type Header_Slot_Count_Type is new Natural range 0 .. 32;
subtype Header_Slot_Index_Type is Header_Slot_Count_Type range 1 .. Header_Slot_Count_Type'Last;
-- Header slot type is a 16-bit values that identifies the data type slot.
type Header_Slot_Type is new Interfaces.Unsigned_16;
SLOT_EMPTY : constant Header_Slot_Type := 0;
SLOT_KEY_GPG1 : constant Header_Slot_Type := 1; -- Contains key encrypted using GPG1
SLOT_KEY_GPG2 : constant Header_Slot_Type := 2; -- Contains key encrypted using GPG2
type UUID_Type is private;
function To_String (UUID : in UUID_Type) return String;
type Wallet_Info is record
UUID : UUID_Type;
Header_Count : Header_Slot_Count_Type := 0;
Storage_Count : Natural := 0;
end record;
-- Information about a keystore entry.
type Entry_Info is record
Size : Interfaces.Unsigned_64 := 0;
Kind : Entry_Type := T_INVALID;
Create_Date : Ada.Calendar.Time;
Update_Date : Ada.Calendar.Time;
Block_Count : Natural := 0;
end record;
package Entry_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => Entry_Info);
subtype Entry_Map is Entry_Maps.Map;
subtype Entry_Cursor is Entry_Maps.Cursor;
-- Task manager to run encryption and decryption work.
-- It can be assigned to the wallet through the `Set_Task_Manager` procedure.
type Task_Manager (Count : Positive) is limited private;
type Task_Manager_Access is access all Task_Manager;
-- Start the tasks of the task manager.
procedure Start (Manager : in Task_Manager_Access);
-- Stop the tasks.
procedure Stop (Manager : in Task_Manager_Access);
-- Configuration to create or open a keystore.
type Wallet_Config is record
Randomize : Boolean := True;
Overwrite : Boolean := False;
Max_Counter : Positive := 300_000;
Min_Counter : Positive := 100_000;
Max_File_Size : Positive := Positive'Last;
Storage_Count : Positive := 1;
end record;
-- Fast configuration but less secure.
Unsecure_Config : constant Wallet_Config
:= (Randomize => False, Overwrite => False,
Min_Counter => 10_000, Max_Counter => 100_000,
Max_File_Size => Positive'Last,
Storage_Count => 1);
-- Slow configuration but more secure.
Secure_Config : constant Wallet_Config
:= (Randomize => True, Overwrite => False,
Min_Counter => 500_000, Max_Counter => 1_000_000,
Max_File_Size => Positive'Last,
Storage_Count => 1);
type Wallet_Stats is record
UUID : UUID_Type;
Keys : Key_Slot_Allocation := (others => False);
Entry_Count : Natural := 0;
Total_Size : Natural := 0;
Block_Count : Natural := 0;
Free_Block_Count : Natural := 0;
Storage_Count : Natural := 0;
end record;
-- The wallet base type.
type Wallet is abstract tagged limited private;
-- Return True if the container was configured.
function Is_Configured (Container : in Wallet) return Boolean is abstract;
-- Return True if the container can be accessed.
function Is_Open (Container : in Wallet) return Boolean is abstract;
-- Get the wallet state.
function State (Container : in Wallet) return State_Type is abstract;
-- Set the key to encrypt and decrypt the container meta data.
procedure Set_Key (Container : in out Wallet;
Secret : in Secret_Key;
New_Secret : in Secret_Key;
Config : in Wallet_Config := Secure_Config;
Mode : in Mode_Type := KEY_REPLACE) is abstract with
Pre'Class => Container.Is_Open;
-- Return True if the container contains the given named entry.
function Contains (Container : in Wallet;
Name : in String) return Boolean is abstract with
Pre'Class => Container.Is_Open;
-- Add in the wallet the named entry and associate it the content.
-- The content is encrypted in AES-CBC with a secret key and an IV vector
-- that is created randomly for the new named entry.
procedure Add (Container : in out Wallet;
Name : in String;
Content : in String) with
Pre => Wallet'Class (Container).Is_Open,
Post => Wallet'Class (Container).Contains (Name);
-- Add in the wallet the named entry and associate it the content.
-- The content is encrypted in AES-CBC with a secret key and an IV vector
-- that is created randomly for the new named entry.
procedure Add (Container : in out Wallet;
Name : in String;
Kind : in Entry_Type := T_BINARY;
Content : in Ada.Streams.Stream_Element_Array) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => Container.Contains (Name);
procedure Add (Container : in out Wallet;
Name : in String;
Kind : in Entry_Type := T_BINARY;
Input : in out Util.Streams.Input_Stream'Class) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => Container.Contains (Name);
-- Add or update in the wallet the named entry and associate it the content.
-- The content is encrypted in AES-CBC with a secret key and an IV vector
-- that is created randomly for the new or updated named entry.
procedure Set (Container : in out Wallet;
Name : in String;
Kind : in Entry_Type := T_BINARY;
Content : in Ada.Streams.Stream_Element_Array) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => Container.Contains (Name);
-- Add or update in the wallet the named entry and associate it the content.
-- The content is encrypted in AES-CBC with a secret key and an IV vector
-- that is created randomly for the new or updated named entry.
procedure Set (Container : in out Wallet;
Name : in String;
Content : in String) with
Pre => Wallet'Class (Container).Is_Open,
Post => Wallet'Class (Container).Contains (Name);
procedure Set (Container : in out Wallet;
Name : in String;
Kind : in Entry_Type := T_BINARY;
Input : in out Util.Streams.Input_Stream'Class) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => Container.Contains (Name);
-- Update in the wallet the named entry and associate it the new content.
-- The secret key and IV vectors are not changed.
procedure Update (Container : in out Wallet;
Name : in String;
Content : in String) with
Pre => Wallet'Class (Container).Is_Open,
Post => Wallet'Class (Container).Contains (Name);
-- Update in the wallet the named entry and associate it the new content.
-- The secret key and IV vectors are not changed.
procedure Update (Container : in out Wallet;
Name : in String;
Kind : in Entry_Type := T_BINARY;
Content : in Ada.Streams.Stream_Element_Array) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => Container.Contains (Name);
-- Delete from the wallet the named entry.
procedure Delete (Container : in out Wallet;
Name : in String) is abstract with
Pre'Class => Container.Is_Open,
Post'Class => not Container.Contains (Name);
-- Get from the wallet the named entry.
function Get (Container : in out Wallet;
Name : in String) return String with
Pre => Wallet'Class (Container).Is_Open;
procedure Get (Container : in out Wallet;
Name : in String;
Info : out Entry_Info;
Content : out Ada.Streams.Stream_Element_Array) is abstract with
Pre'Class => Wallet'Class (Container).Is_Open;
-- Write in the output stream the named entry value from the wallet.
procedure Get (Container : in out Wallet;
Name : in String;
Output : in out Util.Streams.Output_Stream'Class) is abstract with
Pre'Class => Container.Is_Open;
-- Get the list of entries contained in the wallet that correspond to the optional filter.
procedure List (Container : in out Wallet;
Filter : in Filter_Type := (others => True);
Content : out Entry_Map) is abstract with
Pre'Class => Container.Is_Open;
-- Get the list of entries contained in the wallet that correspond to the optiona filter
-- and whose name matches the pattern.
procedure List (Container : in out Wallet;
Pattern : in GNAT.Regpat.Pattern_Matcher;
Filter : in Filter_Type := (others => True);
Content : out Entry_Map) is abstract with
Pre'Class => Container.Is_Open;
function Find (Container : in out Wallet;
Name : in String) return Entry_Info is abstract with
Pre'Class => Container.Is_Open;
DEFAULT_WALLET_KEY : constant String
:= "If you can't give me poetry, can't you give me poetical science?";
private
type UUID_Type is array (1 .. 4) of Interfaces.Unsigned_32;
type Wallet_Identifier is new Positive;
type Wallet_Entry_Index is new Interfaces.Unsigned_32 range 1 .. Interfaces.Unsigned_32'Last;
type Wallet is abstract limited new Ada.Finalization.Limited_Controlled with null record;
type Work_Type is limited interface;
type Work_Type_Access is access all Work_Type'Class;
procedure Execute (Work : in out Work_Type) is abstract;
procedure Execute (Work : in out Work_Type_Access);
procedure Error (Work : in out Work_Type_Access;
Ex : in Ada.Exceptions.Exception_Occurrence);
package Executors is
new Util.Executors (Work_Type => Work_Type_Access,
Execute => Execute,
Error => Error);
type Task_Manager (Count : Positive) is limited
new Executors.Executor_Manager (Count) with null record;
procedure Execute (Manager : in out Task_Manager;
Work : in Work_Type_Access);
end Keystore;
|
AdaCore/training_material | Ada | 1,346 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with SDL_SDL_stdinc_h;
package SDL_SDL_cpuinfo_h is
function SDL_HasRDTSC return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:40
pragma Import (C, SDL_HasRDTSC, "SDL_HasRDTSC");
function SDL_HasMMX return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:43
pragma Import (C, SDL_HasMMX, "SDL_HasMMX");
function SDL_HasMMXExt return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:46
pragma Import (C, SDL_HasMMXExt, "SDL_HasMMXExt");
function SDL_Has3DNow return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:49
pragma Import (C, SDL_Has3DNow, "SDL_Has3DNow");
function SDL_Has3DNowExt return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:52
pragma Import (C, SDL_Has3DNowExt, "SDL_Has3DNowExt");
function SDL_HasSSE return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:55
pragma Import (C, SDL_HasSSE, "SDL_HasSSE");
function SDL_HasSSE2 return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:58
pragma Import (C, SDL_HasSSE2, "SDL_HasSSE2");
function SDL_HasAltiVec return SDL_SDL_stdinc_h.SDL_bool; -- ../include/SDL/SDL_cpuinfo.h:61
pragma Import (C, SDL_HasAltiVec, "SDL_HasAltiVec");
end SDL_SDL_cpuinfo_h;
|
LionelDraghi/List_Image | Ada | 6,493 | ads | -- -----------------------------------------------------------------------------
-- Copyright 2018 Lionel Draghi
--
-- 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.
-- -----------------------------------------------------------------------------
-- This file is part of the List_Image project
-- available at https://github.com/LionelDraghi/List_Image
-- -----------------------------------------------------------------------------
package List_Image is
-- --------------------------------------------------------------------------
-- Style
-- --------------------------------------------------------------------------
-- This signature package defines the style of the String returned by the
-- Image function.
--
-- Prefix, Postfix and Separator parameters are self explaining.
-- If Prefix = '(', Postfix = ')', and Separator = ',', Image will be of
-- this kind : (A,B,C,D)
-- If all parameters are set to "", the image will be : ABCD
--
-- Special Prefix and Postfix are possible for null list, and for list with
-- a single element.
-- This is usefull when you want to want "[A,B,C]" as an image, but you don't
-- want "[]" when the list is empty.
--
-- A usefull application of this feature is to have well written comments
-- regarding singular and plural.
-- If you want your image to be "A item found" but "A, B, C items found",
-- just set Postfix to " items found", and Postfix_If_Single to
-- " item found".
-- And by the way, if you want the Image to be "No item found" when the
-- list is emtpy, Prefix_If_Empty and Postfix_If_Empty are here for you.
--
-- Last_Separator allows to have this kind of output :
-- "A, B, C and D"
--
-- Note that Separator may be whatever String. You may want to insert an End
-- of Line sequence to split the list on several line, the EOL String and
-- parameters are provided for that purpose.
-- --------------------------------------------------------------------------
generic
Prefix : String := "";
Postfix : String := "";
Separator : String := "";
Last_Separator : String := Separator;
Prefix_If_Empty : String := Prefix;
Postfix_If_Empty : String := Postfix;
Prefix_If_Single : String := Prefix;
Postfix_If_Single : String := Postfix;
EOL : String := "";
package Image_Style is end Image_Style;
-- --------------------------------------------------------------------------
-- Predefined single line styles
-- --------------------------------------------------------------------------
--
-- Predefined **single line** styles (that are not relying on EOL
-- definition), and are not plateform specific, are proposed here after.
--
-- - Default_Style :
-- > A, B, C
--
-- - English_Style :
-- > A, B and C
--
-- - Bracketed_List_Style :
-- > [A, B, C]
--
-- - Markdown_Table_Style :
-- > | A | B | C |
-- Note : Markdown don't define tables, but it's a common extension,
-- like in Github Flavored Markdown for example.
--
-- --------------------------------------------------------------------------
package Default_Style is new Image_Style (Separator => ", ");
package English_Style is new Image_Style (Separator => ", ",
Last_Separator => " and ");
package Bracketed_List_Style is new Image_Style (Prefix => "[",
Postfix => "]",
Separator => ", ");
package Markdown_Table_Style is new List_Image.Image_Style
(Prefix => "|",
Separator => "|",
Postfix => "|",
Prefix_If_Empty => "",
Postfix_If_Empty => "");
-- --------------------------------------------------------------------------
-- Predefined Multi-Lines styles
-- --------------------------------------------------------------------------
--
-- Predefined (platform dependent) **multi lines** styles
-- are proposed in the following child packages :
-- - List_Image.Unix_Predefined_Styles
-- - List_Image.Windows_Predefined_Styles
--
-- Common line terminator definitions are provided here for convenience,
-- as there is no easy and standard way in Ada to get the right EOL
-- terminator on the current platform (supposing there is one on the
-- targeted platform).
--
-- --------------------------------------------------------------------------
-- Predefined EOL are (terminator explicit) :
LF_EOL : constant String := (1 => ASCII.LF);
CRLF_EOL : constant String := ASCII.CR & ASCII.LF;
-- or (platform explicit) :
Unix_EOL : constant String := LF_EOL;
Windows_EOL : constant String := CRLF_EOL;
-- --------------------------------------------------------------------------
-- Cursors
-- --------------------------------------------------------------------------
generic
type Container (<>) is limited private;
type Cursor is private;
with function First (Self : Container) return Cursor is <>;
with function Has_Element (Pos : Cursor) return Boolean is <>;
with function Next (Pos : Cursor) return Cursor is <>;
package Cursors_Signature is end Cursors_Signature;
-- --------------------------------------------------------------------------
-- The Image function
-- --------------------------------------------------------------------------
generic
with package Cursors is new Cursors_Signature (<>);
with function Image (C : Cursors.Cursor) return String is <>;
with package Style is new Image_Style (<>);
function Image (Cont : in Cursors.Container) return String;
end List_Image;
|
muharihar/Amass | Ada | 1,089 | ads | -- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "CommonCrawl"
type = "crawl"
local urls = {}
function start()
set_rate_limit(10)
end
function vertical(ctx, domain)
if (urls == nil or #urls == 0) then
get_urls(ctx)
end
for _, url in pairs(urls) do
scrape(ctx, {['url']=build_url(url, domain)})
end
end
function build_url(url, domain)
return url .. "?url=*." .. domain .. "&output=json&fl=url"
end
function get_urls(ctx)
local resp, err = request(ctx, {['url']="https://index.commoncrawl.org/collinfo.json"})
if (err ~= nil and err ~= "") then
log(ctx, "get_urls request to service failed: " .. err)
return
end
local data = json.decode(resp)
if (data == nil or #data == 0) then
return
end
for _, u in pairs(data) do
local url = u['cdx-api']
if (url ~= nil and url ~= "") then
table.insert(urls, url)
end
end
end
|
reznikmm/matreshka | Ada | 4,287 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Nodes;
with XML.DOM.Elements.Internals;
package body ODF.DOM.Elements.Style.Text_Properties.Internals is
------------
-- Create --
------------
function Create
(Node : Matreshka.ODF_Elements.Style.Text_Properties.Style_Text_Properties_Access)
return ODF.DOM.Elements.Style.Text_Properties.ODF_Style_Text_Properties is
begin
return
(XML.DOM.Elements.Internals.Create
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Create;
----------
-- Wrap --
----------
function Wrap
(Node : Matreshka.ODF_Elements.Style.Text_Properties.Style_Text_Properties_Access)
return ODF.DOM.Elements.Style.Text_Properties.ODF_Style_Text_Properties is
begin
return
(XML.DOM.Elements.Internals.Wrap
(Matreshka.DOM_Nodes.Element_Access (Node)) with null record);
end Wrap;
end ODF.DOM.Elements.Style.Text_Properties.Internals;
|
AdaCore/training_material | Ada | 12,818 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package emmintrin_h is
-- Copyright (C) 2003-2017 Free Software Foundation, Inc.
-- This file is part of GCC.
-- GCC is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3, or (at your option)
-- any later version.
-- GCC 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.
-- 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/>.
-- Implemented from the specification included in the Intel C++ Compiler
-- User Guide and Reference, version 9.0.
-- We need definitions from the SSE header files
-- SSE2
subtype uu_v2df is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:40
subtype uu_v2di is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:41
subtype uu_v2du is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:42
subtype uu_v4si is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:43
subtype uu_v4su is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:44
subtype uu_v8hi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:45
subtype uu_v8hu is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:46
subtype uu_v16qi is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:47
subtype uu_v16qu is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:48
-- The Intel API is flexible enough that we must allow aliasing with other
-- vector types, and their scalar components.
subtype uu_m128i is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:52
subtype uu_m128d is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:53
-- Unaligned version of the same types.
subtype uu_m128i_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:56
subtype uu_m128d_u is <vector>; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\emmintrin.h:57
-- Create a selector for use with the SHUFPD instruction.
-- Create a vector with element 0 as F and the rest zero.
-- skipped func _mm_set_sd
-- Create a vector with both elements equal to F.
-- skipped func _mm_set1_pd
-- skipped func _mm_set_pd1
-- Create a vector with the lower value X and upper value W.
-- skipped func _mm_set_pd
-- Create a vector with the lower value W and upper value X.
-- skipped func _mm_setr_pd
-- Create an undefined vector.
-- skipped func _mm_undefined_pd
-- Create a vector of zeros.
-- skipped func _mm_setzero_pd
-- Sets the low DPFP value of A from the low value of B.
-- skipped func _mm_move_sd
-- Load two DPFP values from P. The address must be 16-byte aligned.
-- skipped func _mm_load_pd
-- Load two DPFP values from P. The address need not be 16-byte aligned.
-- skipped func _mm_loadu_pd
-- Create a vector with all two elements equal to *P.
-- skipped func _mm_load1_pd
-- Create a vector with element 0 as *P and the rest zero.
-- skipped func _mm_load_sd
-- skipped func _mm_load_pd1
-- Load two DPFP values in reverse order. The address must be aligned.
-- skipped func _mm_loadr_pd
-- Store two DPFP values. The address must be 16-byte aligned.
-- skipped func _mm_store_pd
-- Store two DPFP values. The address need not be 16-byte aligned.
-- skipped func _mm_storeu_pd
-- Stores the lower DPFP value.
-- skipped func _mm_store_sd
-- skipped func _mm_cvtsd_f64
-- skipped func _mm_storel_pd
-- Stores the upper DPFP value.
-- skipped func _mm_storeh_pd
-- Store the lower DPFP value across two words.
-- The address must be 16-byte aligned.
-- skipped func _mm_store1_pd
-- skipped func _mm_store_pd1
-- Store two DPFP values in reverse order. The address must be aligned.
-- skipped func _mm_storer_pd
-- skipped func _mm_cvtsi128_si32
-- Intel intrinsic.
-- skipped func _mm_cvtsi128_si64
-- Microsoft intrinsic.
-- skipped func _mm_cvtsi128_si64x
-- skipped func _mm_add_pd
-- skipped func _mm_add_sd
-- skipped func _mm_sub_pd
-- skipped func _mm_sub_sd
-- skipped func _mm_mul_pd
-- skipped func _mm_mul_sd
-- skipped func _mm_div_pd
-- skipped func _mm_div_sd
-- skipped func _mm_sqrt_pd
-- Return pair {sqrt (B[0]), A[1]}.
-- skipped func _mm_sqrt_sd
-- skipped func _mm_min_pd
-- skipped func _mm_min_sd
-- skipped func _mm_max_pd
-- skipped func _mm_max_sd
-- skipped func _mm_and_pd
-- skipped func _mm_andnot_pd
-- skipped func _mm_or_pd
-- skipped func _mm_xor_pd
-- skipped func _mm_cmpeq_pd
-- skipped func _mm_cmplt_pd
-- skipped func _mm_cmple_pd
-- skipped func _mm_cmpgt_pd
-- skipped func _mm_cmpge_pd
-- skipped func _mm_cmpneq_pd
-- skipped func _mm_cmpnlt_pd
-- skipped func _mm_cmpnle_pd
-- skipped func _mm_cmpngt_pd
-- skipped func _mm_cmpnge_pd
-- skipped func _mm_cmpord_pd
-- skipped func _mm_cmpunord_pd
-- skipped func _mm_cmpeq_sd
-- skipped func _mm_cmplt_sd
-- skipped func _mm_cmple_sd
-- skipped func _mm_cmpgt_sd
-- skipped func _mm_cmpge_sd
-- skipped func _mm_cmpneq_sd
-- skipped func _mm_cmpnlt_sd
-- skipped func _mm_cmpnle_sd
-- skipped func _mm_cmpngt_sd
-- skipped func _mm_cmpnge_sd
-- skipped func _mm_cmpord_sd
-- skipped func _mm_cmpunord_sd
-- skipped func _mm_comieq_sd
-- skipped func _mm_comilt_sd
-- skipped func _mm_comile_sd
-- skipped func _mm_comigt_sd
-- skipped func _mm_comige_sd
-- skipped func _mm_comineq_sd
-- skipped func _mm_ucomieq_sd
-- skipped func _mm_ucomilt_sd
-- skipped func _mm_ucomile_sd
-- skipped func _mm_ucomigt_sd
-- skipped func _mm_ucomige_sd
-- skipped func _mm_ucomineq_sd
-- Create a vector of Qi, where i is the element number.
-- skipped func _mm_set_epi64x
-- skipped func _mm_set_epi64
-- skipped func _mm_set_epi32
-- skipped func _mm_set_epi16
-- skipped func _mm_set_epi8
-- Set all of the elements of the vector to A.
-- skipped func _mm_set1_epi64x
-- skipped func _mm_set1_epi64
-- skipped func _mm_set1_epi32
-- skipped func _mm_set1_epi16
-- skipped func _mm_set1_epi8
-- Create a vector of Qi, where i is the element number.
-- The parameter order is reversed from the _mm_set_epi* functions.
-- skipped func _mm_setr_epi64
-- skipped func _mm_setr_epi32
-- skipped func _mm_setr_epi16
-- skipped func _mm_setr_epi8
-- Create a vector with element 0 as *P and the rest zero.
-- skipped func _mm_load_si128
-- skipped func _mm_loadu_si128
-- skipped func _mm_loadl_epi64
-- skipped func _mm_store_si128
-- skipped func _mm_storeu_si128
-- skipped func _mm_storel_epi64
-- skipped func _mm_movepi64_pi64
-- skipped func _mm_movpi64_epi64
-- skipped func _mm_move_epi64
-- Create an undefined vector.
-- skipped func _mm_undefined_si128
-- Create a vector of zeros.
-- skipped func _mm_setzero_si128
-- skipped func _mm_cvtepi32_pd
-- skipped func _mm_cvtepi32_ps
-- skipped func _mm_cvtpd_epi32
-- skipped func _mm_cvtpd_pi32
-- skipped func _mm_cvtpd_ps
-- skipped func _mm_cvttpd_epi32
-- skipped func _mm_cvttpd_pi32
-- skipped func _mm_cvtpi32_pd
-- skipped func _mm_cvtps_epi32
-- skipped func _mm_cvttps_epi32
-- skipped func _mm_cvtps_pd
-- skipped func _mm_cvtsd_si32
-- Intel intrinsic.
-- skipped func _mm_cvtsd_si64
-- Microsoft intrinsic.
-- skipped func _mm_cvtsd_si64x
-- skipped func _mm_cvttsd_si32
-- Intel intrinsic.
-- skipped func _mm_cvttsd_si64
-- Microsoft intrinsic.
-- skipped func _mm_cvttsd_si64x
-- skipped func _mm_cvtsd_ss
-- skipped func _mm_cvtsi32_sd
-- Intel intrinsic.
-- skipped func _mm_cvtsi64_sd
-- Microsoft intrinsic.
-- skipped func _mm_cvtsi64x_sd
-- skipped func _mm_cvtss_sd
-- skipped func _mm_unpackhi_pd
-- skipped func _mm_unpacklo_pd
-- skipped func _mm_loadh_pd
-- skipped func _mm_loadl_pd
-- skipped func _mm_movemask_pd
-- skipped func _mm_packs_epi16
-- skipped func _mm_packs_epi32
-- skipped func _mm_packus_epi16
-- skipped func _mm_unpackhi_epi8
-- skipped func _mm_unpackhi_epi16
-- skipped func _mm_unpackhi_epi32
-- skipped func _mm_unpackhi_epi64
-- skipped func _mm_unpacklo_epi8
-- skipped func _mm_unpacklo_epi16
-- skipped func _mm_unpacklo_epi32
-- skipped func _mm_unpacklo_epi64
-- skipped func _mm_add_epi8
-- skipped func _mm_add_epi16
-- skipped func _mm_add_epi32
-- skipped func _mm_add_epi64
-- skipped func _mm_adds_epi8
-- skipped func _mm_adds_epi16
-- skipped func _mm_adds_epu8
-- skipped func _mm_adds_epu16
-- skipped func _mm_sub_epi8
-- skipped func _mm_sub_epi16
-- skipped func _mm_sub_epi32
-- skipped func _mm_sub_epi64
-- skipped func _mm_subs_epi8
-- skipped func _mm_subs_epi16
-- skipped func _mm_subs_epu8
-- skipped func _mm_subs_epu16
-- skipped func _mm_madd_epi16
-- skipped func _mm_mulhi_epi16
-- skipped func _mm_mullo_epi16
-- skipped func _mm_mul_su32
-- skipped func _mm_mul_epu32
-- skipped func _mm_slli_epi16
-- skipped func _mm_slli_epi32
-- skipped func _mm_slli_epi64
-- skipped func _mm_srai_epi16
-- skipped func _mm_srai_epi32
-- skipped func _mm_srli_epi16
-- skipped func _mm_srli_epi32
-- skipped func _mm_srli_epi64
-- skipped func _mm_sll_epi16
-- skipped func _mm_sll_epi32
-- skipped func _mm_sll_epi64
-- skipped func _mm_sra_epi16
-- skipped func _mm_sra_epi32
-- skipped func _mm_srl_epi16
-- skipped func _mm_srl_epi32
-- skipped func _mm_srl_epi64
-- skipped func _mm_and_si128
-- skipped func _mm_andnot_si128
-- skipped func _mm_or_si128
-- skipped func _mm_xor_si128
-- skipped func _mm_cmpeq_epi8
-- skipped func _mm_cmpeq_epi16
-- skipped func _mm_cmpeq_epi32
-- skipped func _mm_cmplt_epi8
-- skipped func _mm_cmplt_epi16
-- skipped func _mm_cmplt_epi32
-- skipped func _mm_cmpgt_epi8
-- skipped func _mm_cmpgt_epi16
-- skipped func _mm_cmpgt_epi32
-- skipped func _mm_max_epi16
-- skipped func _mm_max_epu8
-- skipped func _mm_min_epi16
-- skipped func _mm_min_epu8
-- skipped func _mm_movemask_epi8
-- skipped func _mm_mulhi_epu16
-- skipped func _mm_maskmoveu_si128
-- skipped func _mm_avg_epu8
-- skipped func _mm_avg_epu16
-- skipped func _mm_sad_epu8
-- skipped func _mm_stream_si32
-- skipped func _mm_stream_si64
-- skipped func _mm_stream_si128
-- skipped func _mm_stream_pd
-- skipped func _mm_clflush
-- skipped func _mm_lfence
-- skipped func _mm_mfence
-- skipped func _mm_cvtsi32_si128
-- Intel intrinsic.
-- skipped func _mm_cvtsi64_si128
-- Microsoft intrinsic.
-- skipped func _mm_cvtsi64x_si128
-- Casts between various SP, DP, INT vector types. Note that these do no
-- conversion of values, they just change the type.
-- skipped func _mm_castpd_ps
-- skipped func _mm_castpd_si128
-- skipped func _mm_castps_pd
-- skipped func _mm_castps_si128
-- skipped func _mm_castsi128_ps
-- skipped func _mm_castsi128_pd
end emmintrin_h;
|
davidkristola/vole | Ada | 12,280 | adb | with Ada.Unchecked_Deallocation;
with kv.avm.Log; use kv.avm.Log;
with kv.avm.Actor_Pool;
package body kv.avm.Test.Runners is
use Interfaces;
-----------------------------------------------------------------------------
procedure Execute
(Self : in out Base_Behavior_Type;
Runner : in out Runner_Type'CLASS) is
begin
Put_Line("Base_Behavior_Type for " & Runner.Image & ", Self.Remaining = " & Natural'IMAGE(Self.Remaining));
if Self.Remaining = 0 then
Do_It_Now(Base_Behavior_Type'CLASS(Self), Runner);
Self.Remaining := Self.Cycle_Time;
else
Self.Remaining := Self.Remaining - 1;
end if;
end Execute;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Consume_After_X is new Base_Behavior_Type with null record;
type Consume_After_X_Access is access all Consume_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Consume_After_X, Consume_After_X_Access);
-----------------------------------------------------------------------------
procedure Do_It_Now
(Self : in out Consume_After_X;
Runner : in out Runner_Type'CLASS) is
begin
Runner.Running := False;
end Do_It_Now;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Send_After_X is new Base_Behavior_Type with
record
Destination : kv.avm.Actor_References.Actor_Reference_Type;
end record;
type Send_After_X_Access is access all Send_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Send_After_X, Send_After_X_Access);
-----------------------------------------------------------------------------
procedure Execute
(Self : in out Send_After_X;
Runner : in out Runner_Type'CLASS) is
Machine : kv.avm.Control.Control_Access;
Empty_Tuple : aliased kv.avm.Tuples.Tuple_Type;
Message : kv.avm.Messages.Message_Type;
begin
Put_Line("Send_After_X for " & Runner.Image & ", Self.Remaining = " & Natural'IMAGE(Self.Remaining));
if Self.Remaining = 0 then
Machine := Runner.CPU.Get_Machine;
Empty_Tuple.Initialize;
Empty_Tuple.Fold_Empty;
Message.Initialize
(Source => kv.avm.Actor_References.Null_Reference,
Reply_To => kv.avm.Actor_References.Null_Reference,
Destination => Self.Destination,
Message_Name => "Ping",
Data => Empty_Tuple,
Future => kv.avm.Control.NO_FUTURE);
Machine.Post_Message
(Message => Message,
Status => Runner.Status); -- Important to pass this through
Self.Remaining := Self.Cycle_Time;
else
Runner.Status := kv.avm.Control.Active;
Self.Remaining := Self.Remaining - 1;
end if;
end Execute;
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
type Spawn_After_X is new Base_Behavior_Type with null record;
type Spawn_After_X_Access is access all Spawn_After_X;
procedure Free is new Ada.Unchecked_Deallocation(Spawn_After_X, Spawn_After_X_Access);
-----------------------------------------------------------------------------
procedure Do_It_Now
(Self : in out Spawn_After_X;
Runner : in out Runner_Type'CLASS) is
Machine : kv.avm.Control.Control_Access;
Actor : kv.avm.Actor_References.Actor_Reference_Type;
Empty_Tuple : aliased kv.avm.Tuples.Tuple_Type;
Status : kv.avm.Control.Status_Type;
Message : kv.avm.Messages.Message_Type;
begin
Machine := Runner.CPU.Get_Machine;
Machine.New_Actor("Test_A1", Actor);
Empty_Tuple.Initialize;
Empty_Tuple.Fold_Empty;
Message.Initialize
(Source => kv.avm.Actor_References.Null_Reference,
Reply_To => kv.avm.Actor_References.Null_Reference,
Destination => Actor,
Message_Name => "CONSTRUCTOR",
Data => Empty_Tuple,
Future => kv.avm.Control.NO_FUTURE);
Machine.Post_Message
(Message => Message,
Status => Status);
end Do_It_Now;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Runner_Type;
ID : in Interfaces.Unsigned_32;
Next : in Runner_Access) is
Behavior : Consume_After_X_Access;
begin
Self.ID := ID;
Put_Line(Self.Image & ".Initialize");
Self.Next := kv.avm.Executables.Executable_Access(Next);
Behavior := new Consume_After_X;
Behavior.Cycle_Time := 3;
Behavior.Remaining := 3;
Self.Behavior := Behavior_Access(Behavior);
end Initialize;
-----------------------------------------------------------------------------
procedure Free_Behavior
(Self : in out Runner_Type) is
Free_Me : Consume_After_X_Access;
begin
if Self.Behavior /= null then
if Self.Behavior.all in Consume_After_X'CLASS then
Free_Me := Consume_After_X_Access(Self.Behavior);
Free(Free_Me);
Self.Behavior := null;
end if;
end if;
end Free_Behavior;
-----------------------------------------------------------------------------
procedure Set_Behavior_Send
(Self : in out Runner_Type;
Destination : in kv.avm.Actor_References.Actor_Reference_Type;
Cycle_Time : in Natural) is
Behavior : Send_After_X_Access;
begin
Self.Free_Behavior;
Behavior := new Send_After_X;
Behavior.Cycle_Time := Cycle_Time;
Behavior.Remaining := Cycle_Time;
Behavior.Destination := Destination;
Self.Behavior := Behavior_Access(Behavior);
end Set_Behavior_Send;
-----------------------------------------------------------------------------
procedure Set_Behavior_Spawn
(Self : in out Runner_Type;
Cycle_Time : in Natural) is
Behavior : Spawn_After_X_Access;
begin
Self.Free_Behavior;
Behavior := new Spawn_After_X;
Behavior.Cycle_Time := Cycle_Time;
Behavior.Remaining := Cycle_Time;
Self.Behavior := Behavior_Access(Behavior);
end Set_Behavior_Spawn;
-----------------------------------------------------------------------------
procedure Process_Message
(Self : in out Runner_Type;
Message : in kv.avm.Messages.Message_Type) is
begin
Put_Line(Self.Image & ".Process_Message " & Message.Image);
Self.Running := True;
Self.Last_Msg := Message;
end Process_Message;
-----------------------------------------------------------------------------
procedure Process_Gosub
(Self : access Runner_Type;
Tailcall : in Boolean;
Supercall : in Boolean;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Method : in kv.avm.Registers.String_Type;
Data : access constant kv.avm.Memories.Register_Set_Type;
Future : in Interfaces.Unsigned_32) is
begin
Put_Line(Self.Image & ".Process_Gosub");
end Process_Gosub;
-----------------------------------------------------------------------------
function Can_Accept_Message_Now(Self : Runner_Type; Message : kv.avm.Messages.Message_Type) return Boolean is
begin
Put_Line(Self.Image & ".Can_Accept_Message_Now returning " & Boolean'IMAGE(not Self.Running));
return not Self.Running;
end Can_Accept_Message_Now;
-----------------------------------------------------------------------------
function Program_Counter
(Self : in Runner_Type) return Interfaces.Unsigned_32 is
begin
Put_Line(Self.Image & ".Program_Counter = " & Interfaces.Unsigned_32'IMAGE(Self.PC));
return Self.PC;
end Program_Counter;
-----------------------------------------------------------------------------
function Is_Running
(Self : in Runner_Type) return Boolean is
begin
Put_Line(Self.Image & ".Is_Running = " & Boolean'IMAGE(Self.Running));
return Self.Running;
end Is_Running;
-----------------------------------------------------------------------------
procedure Step
(Self : access Runner_Type;
Processor : access kv.avm.Processors.Processor_Type;
Status : out kv.avm.Control.Status_Type) is
begin
Put_Line(Self.Image & ".Step");
Self.CPU := Processor.all'ACCESS;
Self.PC := Self.PC + 1;
if Self.Behavior /= null then
Self.Behavior.Execute(Self.all);
end if;
Status := Self.Status;
end Step;
-----------------------------------------------------------------------------
procedure Process_Internal_Response
(Self : in out Runner_Type;
Answer : in kv.avm.Tuples.Tuple_Type) is
begin
Put_Line(Self.Image & ".Process_Internal_Response");
end Process_Internal_Response;
-----------------------------------------------------------------------------
procedure Resolve_Future
(Self : in out Runner_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
begin
Put_Line(Self.Image & ".Resolve_Future");
end Resolve_Future;
-----------------------------------------------------------------------------
procedure Halt_Actor
(Self : in out Runner_Type) is
begin
Put_Line(Self.Image & ".Halt_Actor");
Self.Running := False;
end Halt_Actor;
-----------------------------------------------------------------------------
function Reachable(Self : Runner_Type) return kv.avm.Actor_References.Sets.Set is
begin
return kv.avm.Actor_References.Sets.Empty_Set;
end Reachable;
-----------------------------------------------------------------------------
function Image(Self : Runner_Type) return String is
Id_Img : constant String := Interfaces.Unsigned_32'IMAGE(Self.ID);
begin
return "Runner_"&Id_Img(2 .. Id_Img'LAST);
end Image;
-----------------------------------------------------------------------------
function Debug_Info(Self : Runner_Type) return String is
begin
return Self.Image & ".Debug_Info";
end Debug_Info;
-----------------------------------------------------------------------------
procedure New_Executable
(Self : in out Runner_Factory;
Actor : in kv.avm.Actors.Actor_Access;
Machine : in kv.avm.Control.Control_Access;
Executable : out kv.avm.Executables.Executable_Access;
Reference : out kv.avm.Actor_References.Actor_Reference_Type) is
Instance : Runner_Access;
begin
Put_Line("Runner_Factory.New_Executable");
Instance := new Runner_Type;
Self.Count := Self.Count + 1;
Instance.Initialize(Self.Count, Self.Head);
Self.Head := Instance;
kv.avm.Actor_Pool.Add(kv.avm.Executables.Executable_Access(Instance), Reference);
Executable := kv.avm.Executables.Executable_Access(Instance);
end New_Executable;
-----------------------------------------------------------------------------
function Get_Allocated_Count(Self : Runner_Factory) return Natural is
begin
return Natural(Self.Count);
end Get_Allocated_Count;
-----------------------------------------------------------------------------
function Runner_By_ID(Runner : Runner_Access; ID : Interfaces.Unsigned_32) return Runner_Access is
begin
if Runner.ID = ID then
return Runner;
else
return Runner_By_ID(Runner_Access(Runner.Next), ID);
end if;
end Runner_By_ID;
-----------------------------------------------------------------------------
function Get_Runner_By_ID(Self : Runner_Factory; ID : Interfaces.Unsigned_32) return Runner_Access is
begin
return Runner_By_ID(Self.Head, ID);
end Get_Runner_By_ID;
end kv.avm.Test.Runners;
|
AdaCore/libadalang | Ada | 108 | adb | procedure Teststd is
A : Standard.Boolean := True;
pragma Test_Statement;
begin
null;
end Teststd;
|
zhmu/ananas | Ada | 63 | adb | package body Packed_Array is
procedure Dummy is null;
end;
|
reznikmm/matreshka | Ada | 4,139 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Tools 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 League.Application;
with Matreshka.XML_Schema.URI_Rewriter;
with XML.Schema.Models;
with XML.Schema.Utilities;
with XSD_To_Ada.Generator;
with League.Strings;
procedure XSD_To_Ada_Generator is
Model : XML.Schema.Models.XS_Model;
Mapping_Path : constant League.Strings.Universal_String
:= League.Application.Arguments.Element (2);
Payloads_Types_Path : constant League.Strings.Universal_String
:= League.Application.Arguments.Element (3);
begin
Matreshka.XML_Schema.URI_Rewriter.Initialize;
Model :=
XML.Schema.Utilities.Load (League.Application.Arguments.Element (1));
if Model.Is_Null then
raise Program_Error;
end if;
XSD_To_Ada.Generator.Generate (Model, Mapping_Path, Payloads_Types_Path);
end XSD_To_Ada_Generator;
|
wookey-project/ewok-legacy | Ada | 40 | adb | ../../stm32f439/Ada/default_handlers.adb |
reznikmm/ada-pretty | Ada | 4,613 | ads | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
private package Ada_Pretty.Definitions is
type Access_Definition is new Node with private;
function New_Access
(Modifier : Access_Modifier;
Target : not null Node_Access) return Node'Class;
type Derived is new Node with private;
function New_Derived (Parent : not null Node_Access) return Node'Class;
type Null_Exclusion is new Node with private;
function New_Null_Exclusion
(Definition : not null Node_Access;
Exclude : Boolean) return Node'Class;
type Interface_Type is new Node with private;
function New_Interface
(Is_Limited : Boolean;
Parents : Node_Access) return Node'Class;
type Private_Record is new Node with private;
function New_Private_Record
(Is_Tagged : Boolean;
Is_Limited : Boolean;
Parents : Node_Access) return Node'Class;
type Record_Definition is new Node with private;
function New_Record
(Parent : Node_Access := null;
Components : Node_Access;
Is_Abstract : Boolean;
Is_Tagged : Boolean;
Is_Limited : Boolean) return Node'Class;
type Array_Definition is new Node with private;
function New_Array
(Indexes : not null Node_Access;
Component : not null Node_Access) return Node'Class;
type Subprogram is new Node with private;
function Name (Self : Subprogram) return Node_Access;
function New_Subprogram
(Is_Overriding : Trilean;
Name : Node_Access;
Parameters : Node_Access;
Result : Node_Access) return Node'Class;
private
type Access_Definition is new Node with record
Modifier : Access_Modifier;
Target : not null Node_Access;
end record;
overriding function Document
(Self : Access_Definition;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Derived is new Node with record
Parent : not null Node_Access;
end record;
overriding function Document
(Self : Derived;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Null_Exclusion is new Node with record
Definition : not null Node_Access;
Exclude : Boolean;
end record;
overriding function Document
(Self : Null_Exclusion;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Interface_Type is new Node with record
Is_Limited : Boolean;
Parents : Node_Access;
end record;
overriding function Document
(Self : Interface_Type;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Private_Record is new Node with record
Is_Tagged : Boolean;
Is_Limited : Boolean;
Parents : Node_Access := null;
end record;
overriding function Document
(Self : Private_Record;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Record_Definition is new Node with record
Parent : Node_Access;
Components : Node_Access;
Is_Abstract : Boolean;
Is_Tagged : Boolean;
Is_Limited : Boolean;
end record;
overriding function Document
(Self : Record_Definition;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Array_Definition is new Node with record
Indexes : not null Node_Access;
Component : not null Node_Access;
end record;
overriding function Document
(Self : Array_Definition;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
type Subprogram is new Node with record
Is_Overriding : Trilean;
Name : Node_Access;
Parameters : Node_Access;
Result : Node_Access;
end record;
overriding function Document
(Self : Subprogram;
Printer : not null access League.Pretty_Printers.Printer'Class;
Pad : Natural)
return League.Pretty_Printers.Document;
end Ada_Pretty.Definitions;
|
reznikmm/matreshka | Ada | 3,829 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- OpenGL Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with OpenGL.Functions;
package OpenGL.Contexts is
pragma Preelaborate;
type OpenGL_Context is limited interface;
type OpenGL_Context_Access is access all OpenGL_Context'Class;
not overriding function Functions
(Self : OpenGL_Context)
return access OpenGL.Functions.OpenGL_Functions'Class is abstract;
function Current_Context return OpenGL_Context_Access;
private
procedure Set_Current_Context (Context : OpenGL_Context_Access);
end OpenGL.Contexts;
|
reznikmm/matreshka | Ada | 3,714 | 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.Elements;
package ODF.DOM.Table_Data_Pilot_Tables_Elements is
pragma Preelaborate;
type ODF_Table_Data_Pilot_Tables is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Data_Pilot_Tables_Access is
access all ODF_Table_Data_Pilot_Tables'Class
with Storage_Size => 0;
end ODF.DOM.Table_Data_Pilot_Tables_Elements;
|
Componolit/libsparkcrypto | Ada | 5,170 | adb | -------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- Copyright (C) 2010, Alexander Senier
-- Copyright (C) 2010, secunet Security Networks AG
-- 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 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 LSC.Internal.Ops32;
package body LSC.Internal.AES.CBC is
procedure Encrypt (Context : in AES.AES_Enc_Context;
IV : in AES.Block_Type;
Plaintext : in AES.Message_Type;
Length : in AES.Message_Index;
Ciphertext : out AES.Message_Type)
is
Temp : AES.Block_Type;
Next : AES.Block_Type;
begin
Next := IV;
for I in AES.Message_Index range Ciphertext'First .. Ciphertext'Last
loop
pragma Loop_Invariant
(Plaintext'First = Ciphertext'First and
Plaintext'Last = Ciphertext'Last and
Ciphertext'First + Length - 1 <= Plaintext'Last and
Ciphertext'First + Length - 1 in AES.Message_Index);
if I <= (Ciphertext'First - 1) + Length then
Ops32.Block_XOR (Next, Plaintext (I), Temp);
Next := AES.Encrypt (Context, Temp);
Ciphertext (I) := Next;
pragma Annotate
(GNATprove, False_Positive,
"""Ciphertext"" might not be initialized",
"Initialized in complete loop");
else
Ciphertext (I) := AES.Null_Block;
pragma Annotate
(GNATprove, False_Positive,
"""Ciphertext"" might not be initialized",
"Initialized in complete loop");
end if;
end loop;
end Encrypt;
pragma Annotate
(GNATprove, False_Positive,
"""Ciphertext"" might not be initialized in ""Encrypt""",
"Initialized in complete loop");
----------------------------------------------------------------------------
procedure Decrypt (Context : in AES.AES_Dec_Context;
IV : in AES.Block_Type;
Ciphertext : in AES.Message_Type;
Length : in AES.Message_Index;
Plaintext : out AES.Message_Type)
is
Temp : AES.Block_Type;
Next : AES.Block_Type;
begin
Next := IV;
for I in AES.Message_Index range Plaintext'First .. Plaintext'Last
loop
pragma Loop_Invariant
(Plaintext'First = Ciphertext'First and
Plaintext'Last = Ciphertext'Last and
Plaintext'First + Length - 1 <= Ciphertext'Last and
Plaintext'First + Length - 1 in AES.Message_Index);
if I <= (Plaintext'First - 1) + Length then
Temp := AES.Decrypt (Context, Ciphertext (I));
Ops32.Block_XOR (Temp, Next, Plaintext (I));
pragma Annotate
(GNATprove, False_Positive,
"""Plaintext"" might not be initialized",
"Initialized in complete loop");
Next := Ciphertext (I);
else
Plaintext (I) := AES.Null_Block;
pragma Annotate
(GNATprove, False_Positive,
"""Plaintext"" might not be initialized",
"Initialized in complete loop");
end if;
end loop;
end Decrypt;
pragma Annotate
(GNATprove, False_Positive,
"""Plaintext"" might not be initialized in ""Decrypt""",
"Initialized in complete loop");
end LSC.Internal.AES.CBC;
|
zhmu/ananas | Ada | 3,225 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 0 9 --
-- --
-- S p e c --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 9
package System.Pack_09 is
pragma Preelaborate;
Bits : constant := 9;
type Bits_09 is mod 2 ** Bits;
for Bits_09'Size use Bits;
-- In all subprograms below, Rev_SSO is set True if the array has the
-- non-default scalar storage order.
function Get_09
(Arr : System.Address;
N : Natural;
Rev_SSO : Boolean) return Bits_09 with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_09
(Arr : System.Address;
N : Natural;
E : Bits_09;
Rev_SSO : Boolean) with Inline;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_09;
|
gusthoff/fixed_types | Ada | 3,965 | adb | -------------------------------------------------------------------------------
--
-- FIXED TYPES
--
-- Fixed_Short & Fixed_Sat_Short definitions
--
-- The MIT License (MIT)
--
-- Copyright (c) 2015 Gustavo A. Hoffmann
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and /
-- or sell copies of the Software, and to permit persons to whom the Software
-- is furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-- IN THE SOFTWARE.
-------------------------------------------------------------------------------
-- with Ada.Text_IO; use Ada.Text_IO;
package body Fixed_Types.Short is
overriding
function "abs" (A : Fixed_Sat_Short) return Fixed_Sat_Short is
begin
if A = Fixed_Sat_Short'First then
return Fixed_Sat_Short'Last;
else
return Fixed_Sat_Short (abs Fixed_Short (A));
end if;
end "abs";
overriding
function "+" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short is
pragma Suppress (Overflow_Check);
C : Fixed_Integer_Short;
Zero : constant Fixed_Integer_Short := 0;
begin
C := To_Fixed_Integer_Short (A) + To_Fixed_Integer_Short (B);
if A > 0.0 and then B > 0.0 and then C < Zero then
return Fixed_Sat_Short'Last;
elsif A < 0.0 and then B < 0.0 and then C > Zero then
return Fixed_Sat_Short'First;
else
return To_Fixed_Sat_Short (C);
end if;
end "+";
overriding
function "-" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short is
pragma Suppress (Overflow_Check);
C : Fixed_Integer_Short;
Zero : constant Fixed_Integer_Short := 0;
begin
C := To_Fixed_Integer_Short (A) - To_Fixed_Integer_Short (B);
if A > 0.0 and then B < 0.0 and then C < Zero then
return Fixed_Sat_Short'Last;
elsif A < 0.0 and then B > 0.0 and then C > Zero then
return Fixed_Sat_Short'First;
else
return To_Fixed_Sat_Short (C);
end if;
end "-";
overriding
function "-" (A : Fixed_Sat_Short) return Fixed_Sat_Short is
pragma Suppress (Overflow_Check);
begin
if A = Fixed_Sat_Short'First then
return Fixed_Sat_Short'Last;
else
return Fixed_Sat_Short (-Fixed_Short (A));
end if;
end "-";
not overriding
function "*" (A, B : Fixed_Sat_Short) return Fixed_Sat_Short is
pragma Suppress (Overflow_Check);
begin
if A = Fixed_Sat_Short'First and then B = Fixed_Sat_Short'First then
return Fixed_Sat_Short'Last;
else
return Fixed_Sat_Short (Fixed_Short (A) * Fixed_Short (B));
end if;
end "*";
overriding
function "*" (A : Fixed_Sat_Short; B : Integer) return Fixed_Sat_Short is
pragma Unsuppress (Overflow_Check);
begin
return Fixed_Sat_Short (Fixed_Short (A) * B);
exception
when Constraint_Error =>
if (A > 0.0 and B > 0) or (A < 0.0 and B < 0) then
return Fixed_Sat_Short'Last;
else
return Fixed_Sat_Short'First;
end if;
end "*";
end Fixed_Types.Short;
|
Fabien-Chouteau/samd51-hal | Ada | 8,541 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.PM is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Control A
type PM_CTRLA_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- I/O Retention
IORET : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_CTRLA_Register use record
Reserved_0_1 at 0 range 0 .. 1;
IORET at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Sleep Mode
type SLEEPCFG_SLEEPMODESelect is
(-- CPU, AHBx, and APBx clocks are OFF
IDLE,
-- All Clocks are OFF
STANDBY,
-- Backup domain is ON as well as some PDRAMs
HIBERNATE,
-- Only Backup domain is powered ON
BACKUP,
-- All power domains are powered OFF
OFF)
with Size => 3;
for SLEEPCFG_SLEEPMODESelect use
(IDLE => 2,
STANDBY => 4,
HIBERNATE => 5,
BACKUP => 6,
OFF => 7);
-- Sleep Configuration
type PM_SLEEPCFG_Register is record
-- Sleep Mode
SLEEPMODE : SLEEPCFG_SLEEPMODESelect := SAM_SVD.PM.IDLE;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_SLEEPCFG_Register use record
SLEEPMODE at 0 range 0 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
-- Interrupt Enable Clear
type PM_INTENCLR_Register is record
-- Sleep Mode Entry Ready Enable
SLEEPRDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_INTENCLR_Register use record
SLEEPRDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Interrupt Enable Set
type PM_INTENSET_Register is record
-- Sleep Mode Entry Ready Enable
SLEEPRDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_INTENSET_Register use record
SLEEPRDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Interrupt Flag Status and Clear
type PM_INTFLAG_Register is record
-- Sleep Mode Entry Ready
SLEEPRDY : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_INTFLAG_Register use record
SLEEPRDY at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Ram Configuration
type STDBYCFG_RAMCFGSelect is
(-- All the system RAM is retained
RET,
-- Only the first 32Kbytes of the system RAM is retained
PARTIAL,
-- All the system RAM is turned OFF
OFF)
with Size => 2;
for STDBYCFG_RAMCFGSelect use
(RET => 0,
PARTIAL => 1,
OFF => 2);
-- Fast Wakeup
type STDBYCFG_FASTWKUPSelect is
(-- Fast Wakeup is disabled
NO,
-- Fast Wakeup is enabled on NVM
NVM,
-- Fast Wakeup is enabled on the main voltage regulator (MAINVREG)
MAINVREG,
-- Fast Wakeup is enabled on both NVM and MAINVREG
BOTH)
with Size => 2;
for STDBYCFG_FASTWKUPSelect use
(NO => 0,
NVM => 1,
MAINVREG => 2,
BOTH => 3);
-- Standby Configuration
type PM_STDBYCFG_Register is record
-- Ram Configuration
RAMCFG : STDBYCFG_RAMCFGSelect := SAM_SVD.PM.RET;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Fast Wakeup
FASTWKUP : STDBYCFG_FASTWKUPSelect := SAM_SVD.PM.NO;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_STDBYCFG_Register use record
RAMCFG at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
FASTWKUP at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- Ram Configuration
type HIBCFG_RAMCFGSelect is
(-- All the system RAM is retained
RET,
-- Only the first 32Kbytes of the system RAM is retained
PARTIAL,
-- All the system RAM is turned OFF
OFF)
with Size => 2;
for HIBCFG_RAMCFGSelect use
(RET => 0,
PARTIAL => 1,
OFF => 2);
-- Backup Ram Configuration
type HIBCFG_BRAMCFGSelect is
(-- All the backup RAM is retained
RET,
-- Only the first 4Kbytes of the backup RAM is retained
PARTIAL,
-- All the backup RAM is turned OFF
OFF)
with Size => 2;
for HIBCFG_BRAMCFGSelect use
(RET => 0,
PARTIAL => 1,
OFF => 2);
-- Hibernate Configuration
type PM_HIBCFG_Register is record
-- Ram Configuration
RAMCFG : HIBCFG_RAMCFGSelect := SAM_SVD.PM.RET;
-- Backup Ram Configuration
BRAMCFG : HIBCFG_BRAMCFGSelect := SAM_SVD.PM.RET;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_HIBCFG_Register use record
RAMCFG at 0 range 0 .. 1;
BRAMCFG at 0 range 2 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- Ram Configuration
type BKUPCFG_BRAMCFGSelect is
(-- All the backup RAM is retained
RET,
-- Only the first 4Kbytes of the backup RAM is retained
PARTIAL,
-- All the backup RAM is turned OFF
OFF)
with Size => 2;
for BKUPCFG_BRAMCFGSelect use
(RET => 0,
PARTIAL => 1,
OFF => 2);
-- Backup Configuration
type PM_BKUPCFG_Register is record
-- Ram Configuration
BRAMCFG : BKUPCFG_BRAMCFGSelect := SAM_SVD.PM.RET;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_BKUPCFG_Register use record
BRAMCFG at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
subtype PM_PWSAKDLY_DLYVAL_Field is HAL.UInt7;
-- Power Switch Acknowledge Delay
type PM_PWSAKDLY_Register is record
-- Delay Value
DLYVAL : PM_PWSAKDLY_DLYVAL_Field := 16#0#;
-- Ignore Acknowledge
IGNACK : Boolean := False;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for PM_PWSAKDLY_Register use record
DLYVAL at 0 range 0 .. 6;
IGNACK at 0 range 7 .. 7;
end record;
-----------------
-- Peripherals --
-----------------
-- Power Manager
type PM_Peripheral is record
-- Control A
CTRLA : aliased PM_CTRLA_Register;
-- Sleep Configuration
SLEEPCFG : aliased PM_SLEEPCFG_Register;
-- Interrupt Enable Clear
INTENCLR : aliased PM_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased PM_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased PM_INTFLAG_Register;
-- Standby Configuration
STDBYCFG : aliased PM_STDBYCFG_Register;
-- Hibernate Configuration
HIBCFG : aliased PM_HIBCFG_Register;
-- Backup Configuration
BKUPCFG : aliased PM_BKUPCFG_Register;
-- Power Switch Acknowledge Delay
PWSAKDLY : aliased PM_PWSAKDLY_Register;
end record
with Volatile;
for PM_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
SLEEPCFG at 16#1# range 0 .. 7;
INTENCLR at 16#4# range 0 .. 7;
INTENSET at 16#5# range 0 .. 7;
INTFLAG at 16#6# range 0 .. 7;
STDBYCFG at 16#8# range 0 .. 7;
HIBCFG at 16#9# range 0 .. 7;
BKUPCFG at 16#A# range 0 .. 7;
PWSAKDLY at 16#12# range 0 .. 7;
end record;
-- Power Manager
PM_Periph : aliased PM_Peripheral
with Import, Address => PM_Base;
end SAM_SVD.PM;
|
ekoeppen/MSP430_Generic_Ada_Drivers | Ada | 13,534 | ads | -- This spec has been automatically generated from out.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- Port 1/2
package MSP430_SVD.PORT_1_2 is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- P1IN_P array
type P1IN_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Input
type P1IN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1IN_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1IN_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1OUT_P array
type P1OUT_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Output
type P1OUT_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1OUT_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1OUT_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1DIR_P array
type P1DIR_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Direction
type P1DIR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1DIR_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1DIR_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1IFG_P array
type P1IFG_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Interrupt Flag
type P1IFG_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1IFG_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1IFG_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1IES_P array
type P1IES_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Interrupt Edge Select
type P1IES_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1IES_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1IES_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1IE_P array
type P1IE_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Interrupt Enable
type P1IE_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1IE_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1IE_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1SEL_P array
type P1SEL_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Selection
type P1SEL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1SEL_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1SEL_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P1REN_P array
type P1REN_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 1 Resistor Enable
type P1REN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P1REN_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P1REN_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2IN_P array
type P2IN_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Input
type P2IN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2IN_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2IN_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2OUT_P array
type P2OUT_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Output
type P2OUT_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2OUT_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2OUT_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2DIR_P array
type P2DIR_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Direction
type P2DIR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2DIR_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2DIR_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2IFG_P array
type P2IFG_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Interrupt Flag
type P2IFG_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2IFG_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2IFG_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2IES_P array
type P2IES_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Interrupt Edge Select
type P2IES_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2IES_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2IES_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2IE_P array
type P2IE_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Interrupt Enable
type P2IE_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2IE_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2IE_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2SEL_P array
type P2SEL_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Selection
type P2SEL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2SEL_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2SEL_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- P2REN_P array
type P2REN_P_Field_Array is array (0 .. 7) of MSP430_SVD.Bit
with Component_Size => 1, Size => 8;
-- Port 2 Resistor Enable
type P2REN_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- P as a value
Val : MSP430_SVD.Byte;
when True =>
-- P as an array
Arr : P2REN_P_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8, Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for P2REN_Register use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-----------------
-- Peripherals --
-----------------
-- Port 1/2
type PORT_1_2_Peripheral is record
-- Port 1 Input
P1IN : aliased P1IN_Register;
-- Port 1 Output
P1OUT : aliased P1OUT_Register;
-- Port 1 Direction
P1DIR : aliased P1DIR_Register;
-- Port 1 Interrupt Flag
P1IFG : aliased P1IFG_Register;
-- Port 1 Interrupt Edge Select
P1IES : aliased P1IES_Register;
-- Port 1 Interrupt Enable
P1IE : aliased P1IE_Register;
-- Port 1 Selection
P1SEL : aliased P1SEL_Register;
-- Port 1 Resistor Enable
P1REN : aliased P1REN_Register;
-- Port 2 Input
P2IN : aliased P2IN_Register;
-- Port 2 Output
P2OUT : aliased P2OUT_Register;
-- Port 2 Direction
P2DIR : aliased P2DIR_Register;
-- Port 2 Interrupt Flag
P2IFG : aliased P2IFG_Register;
-- Port 2 Interrupt Edge Select
P2IES : aliased P2IES_Register;
-- Port 2 Interrupt Enable
P2IE : aliased P2IE_Register;
-- Port 2 Selection
P2SEL : aliased P2SEL_Register;
-- Port 2 Resistor Enable
P2REN : aliased P2REN_Register;
-- Port 1 Selection 2
P1SEL2 : aliased P1SEL_Register;
-- Port 2 Selection 2
P2SEL2 : aliased P2SEL_Register;
end record
with Volatile;
for PORT_1_2_Peripheral use record
P1IN at 16#0# range 0 .. 7;
P1OUT at 16#1# range 0 .. 7;
P1DIR at 16#2# range 0 .. 7;
P1IFG at 16#3# range 0 .. 7;
P1IES at 16#4# range 0 .. 7;
P1IE at 16#5# range 0 .. 7;
P1SEL at 16#6# range 0 .. 7;
P1REN at 16#7# range 0 .. 7;
P2IN at 16#8# range 0 .. 7;
P2OUT at 16#9# range 0 .. 7;
P2DIR at 16#A# range 0 .. 7;
P2IFG at 16#B# range 0 .. 7;
P2IES at 16#C# range 0 .. 7;
P2IE at 16#D# range 0 .. 7;
P2SEL at 16#E# range 0 .. 7;
P2REN at 16#F# range 0 .. 7;
P1SEL2 at 16#21# range 0 .. 7;
P2SEL2 at 16#22# range 0 .. 7;
end record;
-- Port 1/2
PORT_1_2_Periph : aliased PORT_1_2_Peripheral
with Import, Address => PORT_1_2_Base;
end MSP430_SVD.PORT_1_2;
|
optikos/oasis | Ada | 5,647 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Discrete_Ranges;
with Program.Elements.Component_Definitions;
with Program.Elements.Constrained_Array_Types;
with Program.Element_Visitors;
package Program.Nodes.Constrained_Array_Types is
pragma Preelaborate;
type Constrained_Array_Type is
new Program.Nodes.Node
and Program.Elements.Constrained_Array_Types.Constrained_Array_Type
and Program.Elements.Constrained_Array_Types
.Constrained_Array_Type_Text
with private;
function Create
(Array_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Index_Subtypes : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access)
return Constrained_Array_Type;
type Implicit_Constrained_Array_Type is
new Program.Nodes.Node
and Program.Elements.Constrained_Array_Types.Constrained_Array_Type
with private;
function Create
(Index_Subtypes : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Constrained_Array_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Constrained_Array_Type is
abstract new Program.Nodes.Node
and Program.Elements.Constrained_Array_Types.Constrained_Array_Type
with record
Index_Subtypes : not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access;
Component_Definition : not null Program.Elements.Component_Definitions
.Component_Definition_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Constrained_Array_Type'Class);
overriding procedure Visit
(Self : not null access Base_Constrained_Array_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Index_Subtypes
(Self : Base_Constrained_Array_Type)
return not null Program.Elements.Discrete_Ranges
.Discrete_Range_Vector_Access;
overriding function Component_Definition
(Self : Base_Constrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access;
overriding function Is_Constrained_Array_Type_Element
(Self : Base_Constrained_Array_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Constrained_Array_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Constrained_Array_Type)
return Boolean;
type Constrained_Array_Type is
new Base_Constrained_Array_Type
and Program.Elements.Constrained_Array_Types.Constrained_Array_Type_Text
with record
Array_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Right_Bracket_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Constrained_Array_Type_Text
(Self : aliased in out Constrained_Array_Type)
return Program.Elements.Constrained_Array_Types
.Constrained_Array_Type_Text_Access;
overriding function Array_Token
(Self : Constrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Left_Bracket_Token
(Self : Constrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Constrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Of_Token
(Self : Constrained_Array_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Constrained_Array_Type is
new Base_Constrained_Array_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Constrained_Array_Type_Text
(Self : aliased in out Implicit_Constrained_Array_Type)
return Program.Elements.Constrained_Array_Types
.Constrained_Array_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Constrained_Array_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Constrained_Array_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Constrained_Array_Type)
return Boolean;
end Program.Nodes.Constrained_Array_Types;
|
PThierry/ewok-kernel | Ada | 1,982 | 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.
--
--
--
-- Ring buffer generic implementation
--
generic
type object is private;
size : in integer := 512;
package rings is
pragma Preelaborate;
type ring is private;
type ring_state is (EMPTY, USED, FULL);
procedure init
(r : out ring);
-- write some new data and increment top counter
procedure write
(r : out ring;
item : in object;
success : out boolean);
-- read some data and increment bottom counter
procedure read
(r : in out ring;
item : out object;
success : out boolean);
-- decrement top counter
procedure unwrite
(r : out ring;
success : out boolean);
-- return ring state (empty, used or full)
function state
(r : in ring)
return ring_state;
pragma inline (state);
private
type ring_range is new integer range 1 .. size;
type buffer is array (ring_range) of object;
type ring is
record
buf : buffer;
top : ring_range := ring_range'first; -- place to write
bottom : ring_range := ring_range'first; -- place to read
state : ring_state := EMPTY;
end record;
end rings;
|
reznikmm/matreshka | Ada | 21,717 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This package provides implementation of simple SAX reader. It can be used
-- for both stream and incremental processing of data. It supports XML
-- Namespaces and includes partial support for validation against DTD.
--
-- Supported features:
-- - http://xml.org/sax/features/namespaces
-- - http://xml.org/sax/features/namespace-prefixes
-- - http://xml.org/sax/features/validation
-- - http://apache.org/xml/features/nonvalidating/load-external-dtd
------------------------------------------------------------------------------
private with Ada.Containers.Vectors;
private with Ada.Exceptions;
private with Ada.Finalization;
private with Interfaces;
with League.IRIs;
with League.Strings;
private with Matreshka.Internals.SAX_Locators;
private with Matreshka.Internals.Strings;
private with Matreshka.Internals.Unicode;
private with Matreshka.Internals.Utf16;
private with Matreshka.Internals.XML.Attribute_Tables;
private with Matreshka.Internals.XML.Attributes;
private with Matreshka.Internals.XML.Base_Scopes;
private with Matreshka.Internals.XML.Element_Tables;
private with Matreshka.Internals.XML.Entity_Tables;
private with Matreshka.Internals.XML.Namespace_Scopes;
private with Matreshka.Internals.XML.Notation_Tables;
private with Matreshka.Internals.XML.Symbol_Tables;
private with XML.SAX.Attributes;
private with XML.SAX.Default_Handlers;
with XML.SAX.Input_Sources;
with XML.SAX.Readers;
package XML.SAX.Simple_Readers is
type Simple_Reader is
limited new XML.SAX.Readers.SAX_Reader with private;
not overriding procedure Parse
(Self : in out Simple_Reader;
Source : not null access XML.SAX.Input_Sources.SAX_Input_Source'Class);
-- Reads data from the specified input source till end of data is reached
-- and parse it. Reader can be used to read data several times, each time
-- it process separate XML document.
not overriding procedure Set_Input_Source
(Self : in out Simple_Reader;
Source : not null access XML.SAX.Input_Sources.SAX_Input_Source'Class);
-- Sets input source to read data from it in incremental mode. It must be
-- called once to set input source, and procedure Parse without input
-- source parameter must be used to process chunks of data.
not overriding procedure Parse (Self : in out Simple_Reader);
-- Reads next chunk of data from the input source and parse it. Input
-- source must be setted by call to procedure Set_Input_Source.
private
type Token is
(End_Of_Input,
Error,
End_Of_Chunk,
Token_Xml_Decl_Open,
Token_Pi_Open,
Token_Pi_Close,
Token_Pe_Reference,
Token_Doctype_Decl_Open,
Token_Entity_Decl_Open,
Token_Element_Decl_Open,
Token_Notation_Decl_Open,
Token_Close,
Token_Name,
Token_System,
Token_Public,
Token_System_Literal,
Token_Public_Literal,
Token_Internal_Subset_Open,
Token_Internal_Subset_Close,
Token_Percent,
Token_Value_Open,
Token_Value_Close,
Token_String_Segment,
Token_Ndata,
Token_Comment,
Token_Element_Open,
Token_Equal,
Token_End_Open,
Token_Empty_Close,
Token_Version,
Token_Encoding,
Token_Standalone,
Token_Empty,
Token_Any,
Token_Open_Parenthesis,
Token_Close_Parenthesis,
Token_Vertical_Bar,
Token_Comma,
Token_Question,
Token_Asterisk,
Token_Plus,
Token_Pcdata,
Token_Attlist_Decl_Open,
Token_Cdata,
Token_Id,
Token_Idref,
Token_Idrefs,
Token_Entity,
Token_Entities,
Token_Nmtoken,
Token_Nmtokens,
Token_Notation,
Token_Required,
Token_Implied,
Token_Fixed,
Token_Entity_Start,
Token_Entity_End,
Token_Conditional_Open,
Token_Conditional_Close,
Token_Cdata_Open,
Token_Cdata_Close);
type YYSType is limited record
String : Matreshka.Internals.Strings.Shared_String_Access;
Symbol : Matreshka.Internals.XML.Symbol_Identifier;
Is_Whitespace : Boolean;
end record;
procedure Set_String
(Item : in out YYSType;
String : League.Strings.Universal_String;
Is_Whitespace : Boolean);
pragma Inline (Set_String);
procedure Set_String_Internal
(Item : in out YYSType;
String : Matreshka.Internals.Strings.Shared_String_Access;
Is_Whitespace : Boolean);
pragma Inline (Set_String_Internal);
procedure Set_Symbol
(Item : in out YYSType;
Symbol : Matreshka.Internals.XML.Symbol_Identifier);
pragma Inline (Set_Symbol);
procedure Move
(To : in out YYSType;
From : in out YYSType);
pragma Inline (Move);
procedure Clear (Item : in out YYSType);
pragma Inline (Clear);
-------------------
-- Scanner state --
-------------------
type XML_Version is (XML_1_0, XML_1_1, XML_1_X);
subtype Supported_XML_Version is XML_Version range XML_1_0 .. XML_1_1;
package Unsigned_32_Vectors is
new Ada.Containers.Vectors
(Positive, Interfaces.Unsigned_32, Interfaces."=");
type Scanner_State_Information is record
Source : XML.SAX.Input_Sources.SAX_Input_Source_Access;
Data : Matreshka.Internals.Strings.Shared_String_Access
:= Matreshka.Internals.Strings.Shared_Empty'Access;
YY_Base_Position : Matreshka.Internals.Utf16.Utf16_String_Index := 0;
YY_Base_Index : Positive := 1;
YY_Base_Line : Natural := 1;
YY_Base_Column : Natural := 1;
YY_Base_Skip_LF : Boolean := False;
YY_Current_Position : Matreshka.Internals.Utf16.Utf16_String_Index := 0;
YY_Current_Index : Positive := 1;
YY_Current_Line : Natural := 1;
YY_Current_Column : Natural := 1;
YY_Current_Skip_LF : Boolean := False;
YY_Start_State : Interfaces.Unsigned_32 := 1;
Incremental : Boolean := False;
Is_External_Subset : Boolean := False;
Entity : Matreshka.Internals.XML.Entity_Identifier
:= Matreshka.Internals.XML.No_Entity;
Start_Condition_Stack : Unsigned_32_Vectors.Vector;
Delimiter : Matreshka.Internals.Unicode.Code_Point;
-- Delimiter of the entity value.
In_Literal : Boolean := False;
-- Include in literal mode, apostrophe and quotation characters are
-- ignored.
-- XXX The same behavior can be achived by resetting Delimiter to
-- any symbol.
Start_Issued : Boolean := False;
-- Sets to True when Token_Entity_Start was issued before the start of
-- entity's replacement text scanning, thus Token_Entity_End must be
-- issued after completing of scanning of replacement text.
end record;
package Scanner_State_Vectors is
new Ada.Containers.Vectors (Positive, Scanner_State_Information);
package Symbol_Identifier_Vectors is
new Ada.Containers.Vectors
(Positive,
Matreshka.Internals.XML.Symbol_Identifier,
Matreshka.Internals.XML."=");
------------------
-- Parser state --
------------------
YY_Stack_Size : constant := 300;
-- The size of the value and state stacks.
type Value_Stack_Array is array (0 .. YY_Stack_Size) of YYSType;
type State_Stack_Array is array (0 .. YY_Stack_Size) of Natural;
type Parser_State_Information is record
-- Stack data used by the parser.
TOS : Natural := 0;
Value_Stack : Value_Stack_Array;
State_Stack : State_Stack_Array;
Input_Symbol : Token;
-- Current input symbol.
Look_Ahead : Boolean := True;
-- Obtain next token from the scanner.
Error : Boolean := False;
-- Error recovery flag.
-- error_flag : natural := 0;
-- -- indicates 3 - (number of valid shifts after an error occurs)
end record;
Default_Handler : aliased XML.SAX.Default_Handlers.SAX_Default_Handler;
-- Default handler for use when user defined handler is not specified.
type Attribute_Record is record
Namespace_URI : League.Strings.Universal_String;
Local_Name : Matreshka.Internals.XML.Symbol_Identifier;
Qualified_Name : Matreshka.Internals.XML.Symbol_Identifier;
Value : League.Strings.Universal_String;
end record;
type Namespaces_Options is record
Enabled : Boolean := True;
Prefixes : Boolean := False;
end record;
type Validation_Options is record
Enabled : Boolean := False;
Has_DTD : Boolean := False;
Load_DTD : Boolean := True;
end record;
type Configuration_Information is record
Reset : Boolean := True;
Source : XML.SAX.Input_Sources.SAX_Input_Source_Access;
Incremental : Boolean := False;
Enable_Namespaces : Boolean := True;
Enable_Prefixes : Boolean := False;
Enable_Validation : Boolean := False;
Load_External_DTD : Boolean := True;
end record;
type Simple_Shared_Locator is tagged;
type Simple_Shared_Locator_Access is access all Simple_Shared_Locator'Class;
type Simple_Reader is limited new Ada.Finalization.Limited_Controlled
and XML.SAX.Readers.SAX_Reader with
record
-- Handlers
Content_Handler : XML.SAX.Readers.SAX_Content_Handler_Access
:= Default_Handler'Access;
Declaration_Handler : XML.SAX.Readers.SAX_Declaration_Handler_Access
:= Default_Handler'Access;
DTD_Handler : XML.SAX.Readers.SAX_DTD_Handler_Access
:= Default_Handler'Access;
Error_Handler : XML.SAX.Readers.SAX_Error_Handler_Access
:= Default_Handler'Access;
Lexical_Handler : XML.SAX.Readers.SAX_Lexical_Handler_Access
:= Default_Handler'Access;
Entity_Resolver : XML.SAX.Readers.SAX_Entity_Resolver_Access;
-- Configuration, it is used to initialize state of the reader.
Configuration : Configuration_Information;
-- Scanner state
Scanner_State : Scanner_State_Information;
Scanner_Stack : Scanner_State_Vectors.Vector;
Symbols :
Matreshka.Internals.XML.Symbol_Tables.Symbol_Table;
Locator : Simple_Shared_Locator_Access;
YYLVal : YYSType;
Character_Buffer :
Matreshka.Internals.Strings.Shared_String_Access;
-- Preallocated buffer for character reference and attribute value
-- delimiter handling.
Character_Data : Matreshka.Internals.Strings.Shared_String_Access
:= Matreshka.Internals.Strings.Shared_Empty'Access;
-- Preallocated buffer for character data to avoid unnecessary
-- allocations, and to accumulate attribute's value.
Normalize_Value : Boolean;
-- When True attribute value normalization is applied to the
-- attribute's character data.
Space_Before : Boolean;
-- When normalize attribute value of non-CDATA type, it indicates that
-- previous processed character was space.
Version : Supported_XML_Version := XML_1_0;
-- XML version of document entity.
Conditional_Directive : Boolean;
-- True when conditional directive is parsed or not needed to be checked
-- (for nested conditional sections).
Conditional_Depth : Natural := 0;
-- Depth of conditional sections.
Ignore_Depth : Natural := 0;
-- Depth of ignore conditional sections.
Notation_Attribute : Boolean;
-- Sets when processing attribute declaration of type of NOTATION.
-- Parser state
Parser_State : Parser_State_Information;
Public_Id : League.Strings.Universal_String;
System_Id : League.Strings.Universal_String;
Error_Reported : Boolean := False;
-- Analyzer state
Whitespace_Matched : Boolean;
-- Used to check whether whitespace is used to separate tokens. For
-- example, '%' must be separated by whitespace from '<!ENTITY' and
-- following name.
In_Document_Content : Boolean := False;
Is_Standalone : Boolean := False;
Entities :
Matreshka.Internals.XML.Entity_Tables.Entity_Table;
Elements :
Matreshka.Internals.XML.Element_Tables.Element_Table;
Attributes :
Matreshka.Internals.XML.Attribute_Tables.Attribute_Table;
Notations :
Matreshka.Internals.XML.Notation_Tables.Notation_Table;
External_Subset_Entity : Matreshka.Internals.XML.Entity_Identifier
:= Matreshka.Internals.XML.No_Entity;
-- Entity of the external subset if any.
External_Subset_Done : Boolean := False;
Element_Names : Symbol_Identifier_Vectors.Vector;
-- Stack of names of elements.
Continue : Boolean := True;
-- Continue processing.
Error_Message : League.Strings.Universal_String;
-- Error message.
User_Exception : Ada.Exceptions.Exception_Occurrence;
-- Catched exception from the user defined handler.
Current_Element_Name : Matreshka.Internals.XML.Symbol_Identifier;
-- Name of the currently processed element.
Current_Element : Matreshka.Internals.XML.Element_Identifier;
-- Currently analyzed element, used to handle attribute list
-- declaration and element declaration.
Current_Attribute : Matreshka.Internals.XML.Attribute_Identifier;
-- Currently analyzed attribute, used to handle default declaration
-- of the attribute definition.
Attribute_Redefined : Boolean;
-- Mark redefinition of the currently processing attribute. Once
-- attribute is defined it can't be redefined.
-- When components can't be nested thier information is not hold in
-- YYSType and placed directly here to avoid copy overhead.
Attribute_Set :
Matreshka.Internals.XML.Attributes.Attribute_Set;
SAX_Attributes : XML.SAX.Attributes.SAX_Attributes;
-- Set of attributes of the element.
-- Namespaces handling state
Namespaces : Namespaces_Options;
Namespace_Scope :
Matreshka.Internals.XML.Namespace_Scopes.Namespace_Scope;
-- XML Base handling state
Bases : Matreshka.Internals.XML.Base_Scopes.Base_Scope;
-- Tracks current base URI.
-- Validator state
Validation : Validation_Options;
-- Validation options
Root_Symbol : Matreshka.Internals.XML.Symbol_Identifier
:= Matreshka.Internals.XML.No_Symbol;
-- Expected name of the root element.
end record;
overriding procedure Initialize (Self : in out Simple_Reader);
-- Initialize internal state of the reader.
overriding procedure Finalize (Self : in out Simple_Reader);
-- Finalize internal state of the reader.
overriding function Content_Handler
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_Content_Handler_Access;
overriding function Declaration_Handler
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_Declaration_Handler_Access;
overriding function DTD_Handler
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_DTD_Handler_Access;
overriding function Entity_Resolver
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_Entity_Resolver_Access;
overriding function Error_Handler
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_Error_Handler_Access;
overriding function Feature
(Self : Simple_Reader;
Name : League.Strings.Universal_String) return Boolean;
overriding function Has_Feature
(Self : Simple_Reader;
Name : League.Strings.Universal_String) return Boolean;
overriding function Lexical_Handler
(Self : Simple_Reader)
return XML.SAX.Readers.SAX_Lexical_Handler_Access;
overriding procedure Set_Content_Handler
(Self : in out Simple_Reader;
Handler : XML.SAX.Readers.SAX_Content_Handler_Access);
overriding procedure Set_Declaration_Handler
(Self : in out Simple_Reader;
Handler : XML.SAX.Readers.SAX_Declaration_Handler_Access);
overriding procedure Set_DTD_Handler
(Self : in out Simple_Reader;
Handler : XML.SAX.Readers.SAX_DTD_Handler_Access);
overriding procedure Set_Entity_Resolver
(Self : in out Simple_Reader;
Resolver : XML.SAX.Readers.SAX_Entity_Resolver_Access);
overriding procedure Set_Error_Handler
(Self : in out Simple_Reader;
Handler : XML.SAX.Readers.SAX_Error_Handler_Access);
overriding procedure Set_Feature
(Self : in out Simple_Reader;
Name : League.Strings.Universal_String;
Value : Boolean);
overriding procedure Set_Lexical_Handler
(Self : in out Simple_Reader;
Handler : XML.SAX.Readers.SAX_Lexical_Handler_Access);
-------------
-- Locator --
-------------
type Simple_Shared_Locator is
new Matreshka.Internals.SAX_Locators.Shared_Abstract_Locator with record
Reader : access Simple_Reader'Class;
end record;
overriding function Line
(Self : not null access constant Simple_Shared_Locator) return Natural;
overriding function Column
(Self : not null access constant Simple_Shared_Locator) return Natural;
overriding function Encoding
(Self : not null access constant Simple_Shared_Locator)
return League.Strings.Universal_String;
overriding function Version
(Self : not null access constant Simple_Shared_Locator)
return League.Strings.Universal_String;
overriding function Public_Id
(Self : not null access constant Simple_Shared_Locator)
return League.Strings.Universal_String;
overriding function System_Id
(Self : not null access constant Simple_Shared_Locator)
return League.Strings.Universal_String;
overriding function Base_URI
(Self : not null access constant Simple_Shared_Locator)
return League.IRIs.IRI;
end XML.SAX.Simple_Readers;
|
tum-ei-rcs/StratoX | Ada | 20,619 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_dac.c and stm32f4xx_hal_dac_ex.c --
-- @author MCD Application Team --
-- @version V1.3.1 --
-- @date 25-March-2015 --
-- @brief Header file of DAC HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with STM32_SVD.DAC; use STM32_SVD.DAC;
package body STM32.DAC is
------------
-- Enable --
------------
procedure Enable
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.EN1 := True;
when Channel_2 =>
This.CR.EN2 := True;
end case;
end Enable;
-------------
-- Disable --
-------------
procedure Disable
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.EN1 := False;
when Channel_2 =>
This.CR.EN2 := False;
end case;
end Disable;
-------------
-- Enabled --
-------------
function Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean is
begin
case Channel is
when Channel_1 =>
return This.CR.EN1;
when Channel_2 =>
return This.CR.EN2;
end case;
end Enabled;
----------------
-- Set_Output --
----------------
procedure Set_Output
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Value : Word;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
is
begin
case Channel is
when Channel_1 =>
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12L1.DACC1DHR :=
UInt12 (Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12R1.DACC1DHR :=
UInt12 (Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8R1.DACC1DHR := Byte (Value and Max_8bit_Resolution);
end case;
when Channel_2 =>
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12L2.DACC2DHR :=
UInt12 (Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12R2.DACC2DHR :=
UInt12 (Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8R2.DACC2DHR := Byte (Value and Max_8bit_Resolution);
end case;
end case;
end Set_Output;
------------------------------------
-- Trigger_Conversion_By_Software --
------------------------------------
procedure Trigger_Conversion_By_Software
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.SWTRIGR.SWTRIG.Arr (1) := True; -- cleared by hardware
when Channel_2 =>
This.SWTRIGR.SWTRIG.Arr (2) := True; -- cleared by hardware
end case;
end Trigger_Conversion_By_Software;
----------------------------
-- Converted_Output_Value --
----------------------------
function Converted_Output_Value
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Word
is
begin
case Channel is
when Channel_1 =>
return Word (This.DOR1.DACC1DOR);
when Channel_2 =>
return Word (This.DOR2.DACC2DOR);
end case;
end Converted_Output_Value;
------------------------------
-- Set_Dual_Output_Voltages --
------------------------------
procedure Set_Dual_Output_Voltages
(This : in out Digital_To_Analog_Converter;
Channel_1_Value : Word;
Channel_2_Value : Word;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
is
begin
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
This.DHR12LD.DACC1DHR :=
UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12LD.DACC2DHR :=
UInt12 (Channel_2_Value and Max_12bit_Resolution);
when Right_Aligned =>
This.DHR12RD.DACC1DHR :=
UInt12 (Channel_1_Value and Max_12bit_Resolution);
This.DHR12RD.DACC2DHR :=
UInt12 (Channel_2_Value and Max_12bit_Resolution);
end case;
when DAC_Resolution_8_Bits =>
This.DHR8RD.DACC1DHR :=
Byte (Channel_1_Value and Max_8bit_Resolution);
This.DHR8RD.DACC2DHR :=
Byte (Channel_2_Value and Max_8bit_Resolution);
end case;
end Set_Dual_Output_Voltages;
---------------------------------
-- Converted_Dual_Output_Value --
---------------------------------
function Converted_Dual_Output_Value (This : Digital_To_Analog_Converter)
return Dual_Channel_Output
is
Result : Dual_Channel_Output;
begin
Result.Channel_1_Data := Short (This.DOR1.DACC1DOR);
Result.Channel_2_Data := Short (This.DOR2.DACC2DOR);
return Result;
end Converted_Dual_Output_Value;
--------------------------
-- Enable_Output_Buffer --
--------------------------
procedure Enable_Output_Buffer
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.BOFF1 := True;
when Channel_2 =>
This.CR.BOFF2 := True;
end case;
end Enable_Output_Buffer;
---------------------------
-- Disable_Output_Buffer --
---------------------------
procedure Disable_Output_Buffer
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.BOFF1 := False;
when Channel_2 =>
This.CR.BOFF2 := False;
end case;
end Disable_Output_Buffer;
---------------------------
-- Output_Buffer_Enabled --
---------------------------
function Output_Buffer_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean
is
begin
case Channel is
when Channel_1 =>
return This.CR.BOFF1;
when Channel_2 =>
return This.CR.BOFF2;
end case;
end Output_Buffer_Enabled;
--------------------
-- Select_Trigger --
--------------------
procedure Select_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Trigger : External_Event_Trigger_Selection)
is
begin
case Channel is
when Channel_1 =>
This.CR.TSEL1 :=
External_Event_Trigger_Selection'Enum_Rep (Trigger);
when Channel_2 =>
This.CR.TSEL2 :=
External_Event_Trigger_Selection'Enum_Rep (Trigger);
end case;
end Select_Trigger;
-----------------------
-- Trigger_Selection --
-----------------------
function Trigger_Selection
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return External_Event_Trigger_Selection
is
begin
case Channel is
when Channel_1 =>
return External_Event_Trigger_Selection'Val (This.CR.TSEL1);
when Channel_2 =>
return External_Event_Trigger_Selection'Val (This.CR.TSEL2);
end case;
end Trigger_Selection;
--------------------
-- Enable_Trigger --
--------------------
procedure Enable_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.TEN1 := True;
when Channel_2 =>
This.CR.TEN2 := True;
end case;
end Enable_Trigger;
---------------------
-- Disable_Trigger --
---------------------
procedure Disable_Trigger
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.TEN1 := False;
when Channel_2 =>
This.CR.TEN2 := False;
end case;
end Disable_Trigger;
---------------------
-- Trigger_Enabled --
---------------------
function Trigger_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean
is
begin
case Channel is
when Channel_1 =>
return This.CR.TEN1;
when Channel_2 =>
return This.CR.TEN2;
end case;
end Trigger_Enabled;
----------------
-- Enable_DMA --
----------------
procedure Enable_DMA
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.DMAEN1 := True;
when Channel_2 =>
This.CR.DMAEN2 := True;
end case;
end Enable_DMA;
-----------------
-- Disable_DMA --
-----------------
procedure Disable_DMA
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.CR.DMAEN1 := False;
when Channel_2 =>
This.CR.DMAEN2 := False;
end case;
end Disable_DMA;
-----------------
-- DMA_Enabled --
-----------------
function DMA_Enabled
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Boolean
is
begin
case Channel is
when Channel_1 =>
return This.CR.DMAEN1;
when Channel_2 =>
return This.CR.DMAEN2;
end case;
end DMA_Enabled;
------------
-- Status --
------------
function Status
(This : Digital_To_Analog_Converter;
Flag : DAC_Status_Flag)
return Boolean
is
begin
case Flag is
when DMA_Underrun_Channel_1 =>
return This.SR.DMAUDR1;
when DMA_Underrun_Channel_2 =>
return This.SR.DMAUDR2;
end case;
end Status;
------------------
-- Clear_Status --
------------------
procedure Clear_Status
(This : in out Digital_To_Analog_Converter;
Flag : DAC_Status_Flag)
is
begin
case Flag is
when DMA_Underrun_Channel_1 =>
This.SR.DMAUDR1 := True; -- set to 1 to clear
when DMA_Underrun_Channel_2 =>
This.SR.DMAUDR2 := True; -- set to 1 to clear
end case;
end Clear_Status;
-----------------------
-- Enable_Interrupts --
-----------------------
procedure Enable_Interrupts
(This : in out Digital_To_Analog_Converter;
Source : DAC_Interrupts)
is
begin
case Source is
when DMA_Underrun_Channel_1 =>
This.CR.DMAUDRIE1 := True;
when DMA_Underrun_Channel_2 =>
This.CR.DMAUDRIE2 := True;
end case;
end Enable_Interrupts;
------------------------
-- Disable_Interrupts --
------------------------
procedure Disable_Interrupts
(This : in out Digital_To_Analog_Converter;
Source : DAC_Interrupts)
is
begin
case Source is
when DMA_Underrun_Channel_1 =>
This.CR.DMAUDRIE1 := False;
when DMA_Underrun_Channel_2 =>
This.CR.DMAUDRIE2 := False;
end case;
end Disable_Interrupts;
-----------------------
-- Interrupt_Enabled --
-----------------------
function Interrupt_Enabled
(This : Digital_To_Analog_Converter;
Source : DAC_Interrupts)
return Boolean
is
begin
case Source is
when DMA_Underrun_Channel_1 =>
return This.CR.DMAUDRIE1;
when DMA_Underrun_Channel_2 =>
return This.CR.DMAUDRIE2;
end case;
end Interrupt_Enabled;
----------------------
-- Interrupt_Source --
----------------------
function Interrupt_Source
(This : Digital_To_Analog_Converter)
return DAC_Interrupts
is
begin
if This.CR.DMAUDRIE1 then
return DMA_Underrun_Channel_1;
else
return DMA_Underrun_Channel_2;
end if;
end Interrupt_Source;
-----------------------------
-- Clear_Interrupt_Pending --
-----------------------------
procedure Clear_Interrupt_Pending
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel)
is
begin
case Channel is
when Channel_1 =>
This.SR.DMAUDR1 := False;
when Channel_2 =>
This.SR.DMAUDR2 := False;
end case;
end Clear_Interrupt_Pending;
----------------------------
-- Select_Wave_Generation --
----------------------------
procedure Select_Wave_Generation
(This : in out Digital_To_Analog_Converter;
Channel : DAC_Channel;
Selection : Wave_Generation)
is
function As_UInt4 is new Ada.Unchecked_Conversion
(Source => Noise_Wave_Mask_Selection, Target => UInt4);
function As_UInt4 is new Ada.Unchecked_Conversion
(Source => Triangle_Wave_Amplitude_Selection, Target => UInt4);
begin
case Channel is
when Channel_1 =>
This.CR.WAVE1 :=
Wave_Generation_Selection'Enum_Rep (Selection.Kind);
when Channel_2 =>
This.CR.WAVE2 :=
Wave_Generation_Selection'Enum_Rep (Selection.Kind);
end case;
case Selection.Kind is
when No_Wave_Generation =>
null;
when Noise_Wave =>
case Channel is
when Channel_1 =>
This.CR.MAMP1 := As_UInt4 (Selection.Mask);
when Channel_2 =>
This.CR.MAMP2 := As_UInt4 (Selection.Mask);
end case;
when Triangle_Wave =>
case Channel is
when Channel_1 =>
This.CR.MAMP1 := As_UInt4 (Selection.Amplitude);
when Channel_2 =>
This.CR.MAMP2 := As_UInt4 (Selection.Amplitude);
end case;
end case;
end Select_Wave_Generation;
------------------------------
-- Selected_Wave_Generation --
------------------------------
function Selected_Wave_Generation
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel)
return Wave_Generation
is
Kind : Wave_Generation_Selection;
function As_Mask is new Ada.Unchecked_Conversion
(Target => Noise_Wave_Mask_Selection, Source => UInt4);
function As_Amplitude is new Ada.Unchecked_Conversion
(Target => Triangle_Wave_Amplitude_Selection, Source => UInt4);
begin
case Channel is
when Channel_1 =>
Kind := Wave_Generation_Selection'Val (This.CR.WAVE1);
when Channel_2 =>
Kind := Wave_Generation_Selection'Val (This.CR.WAVE2);
end case;
declare
Result : Wave_Generation (Kind);
begin
case Kind is
when No_Wave_Generation =>
null;
when Noise_Wave =>
case Channel is
when Channel_1 =>
Result.Mask := As_Mask (This.CR.MAMP1);
when Channel_2 =>
Result.Mask := As_Mask (This.CR.MAMP2);
end case;
when Triangle_Wave =>
case Channel is
when Channel_1 =>
Result.Amplitude := As_Amplitude (This.CR.MAMP1);
when Channel_2 =>
Result.Amplitude := As_Amplitude (This.CR.MAMP2);
end case;
end case;
return Result;
end;
end Selected_Wave_Generation;
------------------
-- Data_Address --
------------------
function Data_Address
(This : Digital_To_Analog_Converter;
Channel : DAC_Channel;
Resolution : DAC_Resolution;
Alignment : Data_Alignment)
return Address
is
Result : Address;
begin
case Channel is
when Channel_1 =>
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
Result := This.DHR12L1'Address;
when Right_Aligned =>
Result := This.DHR12R1'Address;
end case;
when DAC_Resolution_8_Bits =>
Result := This.DHR8R1'Address;
end case;
when Channel_2 =>
case Resolution is
when DAC_Resolution_12_Bits =>
case Alignment is
when Left_Aligned =>
Result := This.DHR12L2'Address;
when Right_Aligned =>
Result := This.DHR12R2'Address;
end case;
when DAC_Resolution_8_Bits =>
Result := This.DHR8R2'Address;
end case;
end case;
return Result;
end Data_Address;
end STM32.DAC;
|
reznikmm/matreshka | Ada | 3,699 | 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.Db_User_Name_Attributes is
pragma Preelaborate;
type ODF_Db_User_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_User_Name_Attribute_Access is
access all ODF_Db_User_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_User_Name_Attributes;
|
zhmu/ananas | Ada | 136 | adb | -- { dg-do run }
with Limited1_Outer; use Limited1_Outer;
procedure Limited1 is
X : Outer_Type := Make_Outer;
begin
null;
end;
|
reznikmm/matreshka | Ada | 5,632 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A dependency is a relationship that signifies that a single or a set of
-- model elements requires other model elements for their specification or
-- implementation. This means that the complete semantics of the depending
-- elements is either semantically or structurally dependent on the
-- definition of the supplier element(s).
------------------------------------------------------------------------------
with AMF.UML.Directed_Relationships;
limited with AMF.UML.Named_Elements.Collections;
with AMF.UML.Packageable_Elements;
package AMF.UML.Dependencies is
pragma Preelaborate;
type UML_Dependency is limited interface
and AMF.UML.Directed_Relationships.UML_Directed_Relationship
and AMF.UML.Packageable_Elements.UML_Packageable_Element;
type UML_Dependency_Access is
access all UML_Dependency'Class;
for UML_Dependency_Access'Storage_Size use 0;
not overriding function Get_Client
(Self : not null access constant UML_Dependency)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Getter of Dependency::client.
--
-- The element(s) dependent on the supplier element(s). In some cases
-- (such as a Trace Abstraction) the assignment of direction (that is, the
-- designation of the client element) is at the discretion of the modeler,
-- and is a stipulation.
not overriding function Get_Supplier
(Self : not null access constant UML_Dependency)
return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is abstract;
-- Getter of Dependency::supplier.
--
-- The element(s) independent of the client element(s), in the same
-- respect and the same dependency relationship. In some directed
-- dependency relationships (such as Refinement Abstractions), a common
-- convention in the domain of class-based OO software is to put the more
-- abstract element in this role. Despite this convention, users of UML
-- may stipulate a sense of dependency suitable for their domain, which
-- makes a more abstract element dependent on that which is more specific.
end AMF.UML.Dependencies;
|
adamnemecek/GA_Ada | Ada | 6,225 | adb |
with Ada.Text_IO; use Ada.Text_IO;
with GL.Objects.Vertex_Arrays;
with GL.Uniforms;
with Blade;
with E2GA;
with E3GA;
with GA_Draw;
with Multivector_Analyze;
package body E2GA_Draw is
-- Method & flags are dependent on what 'X' represents.
-- They are forwarded to drawVector, drawBivector, drawTrivector.
--
-- Currently, 'method' is some integer in range [0, n), where each
-- integer indicates a different way of drawing the multivector.
--
-- The Palet can be used to specify foreground, background and outline color.
--
-- Uses g_drawState for some extra flags!
-- If this gets annoying, allow DrawState to be passed along
-- as argument (and also integrate 'Palet')
procedure Draw (Render_Program : GL.Objects.Programs.Program;
Model_View_Matrix : GL.Types.Singles.Matrix4;
MV : in out Multivector.Multivector;
Method : GA_Draw.Bivector_Method_Type
:= GA_Draw.Draw_Bivector_Circle;
Colour : GL.Types.Colors.Color := (0.0, 0.5, 0.5, 1.0)) is
use GA_Draw;
use GA_Maths;
use Multivector;
use Multivector_Analyze;
A : MV_Analysis;
V1 : Vector;
V2 : Vector;
OP : Multivector.Multivector;
Normal : Vector;
Direction : Vector;
Scale : float := 1.0;
begin
Analyze (A, MV);
Print_Analysis ("E2GA Draw Analysis", A);
if isBlade (A) then
Put_Line ("E2GA_Draw isBlade.");
case Blade_Subclass (A) is
when Vector_Subclass =>
Put_Line (" E2GA_Draw Vector_Subclass.");
-- E3GA.Set_Coords (Direction, 0.0, 0.0, Float (A.M_Scalors (1)));
-- Direction := New_Vector (0.0, 0.0, Float (A.M_Scalors (1)));
Add_Blade (Direction, Blade.E3_e3, Float (A.M_Scalors (1)));
Draw_Vector (Render_Program, Model_View_Matrix,
A.M_Vectors (1), Direction, Colour, Scale);
when Bivector_Subclass =>
Put_Line (" E2GA_Draw Bivector_Subclass.");
if Get_Draw_Mode = OD_Magnitude then
Scale := Float_Functions.Sqrt (Float (Abs (A.M_Scalors (1)))) / Pi;
end if;
-- V1 := E3GA.To_2D (A.M_Vectors (1));
-- V2 := E3GA.To_2D (A.M_Vectors (2));
V1 := A.M_Vectors (1);
V2 := A.M_Vectors (2);
OP := Multivector.Outer_Product (V1, V2);
declare
use Blade_List_Package;
Blades : constant Blade_List := Get_Blade_List (OP);
aBlade : Blade.Basis_Blade;
Curs : Cursor := Blades.Last;
OP_MV : Multivector.Multivector := OP;
Normal_MV : Multivector.Multivector := OP;
begin
Normal_MV := Multivector.Dual (OP_MV);
Add_Blade (Normal, Blade.E3_e3, Blade.Weight (Element (curs)));
-- E3GA.Set_Coords (Normal, 0.0, 0.0, Blade.Weight (Element (curs)));
-- Normal_MV.Coordinates (Length (Blades)));
GA_Draw.Draw_Bivector (Render_Program,
Model_View_Matrix, Normal,
A.M_Vectors (1), A.M_Vectors (2),
Colour, Scale, Method);
end;
when Even_Versor_Subclass => null;
when Unspecified_Subclass => null;
end case;
elsif isVersor (A) and then A.M_Scalors (1) > 0.0001 then
Put_Line ("E2GA_Draw isVersor.");
end if;
Put_Line ("E2GA_Draw No true case.");
exception
when anError : others =>
Put_Line ("An exception occurred in E2GA_Draw.Draw.");
raise;
end Draw;
-- -------------------------------------------------------------------------
procedure Draw_Bivector (Render_Program : GL.Objects.Programs.Program;
Translation_Matrix : GL.Types.Singles.Matrix4;
BV : Multivector.Bivector; Colour : GL.Types.Colors.Color;
Method_Type : GA_Draw.Bivector_Method_Type
:= GA_Draw.Draw_Bivector_Circle) is
use GA_Maths.Float_Functions;
use GL.Types.Colors;
use Multivector;
Radius : constant Float := Sqrt (Abs (E2GA.Get_Coord (BV)));
Scale : constant Float := 20.0;
Ortho_1 : constant Vector := New_Vector (Radius, 0.0, 0.0);
Ortho_2 : constant Vector := New_Vector (0.0, Radius, 0.0);
Normal : Vector := New_Vector (0.0, 0.0);
begin
Multivector.Add_Blade (Normal, Blade.New_Basis_Blade (Blade.E3_e3));
GA_Draw.Draw_Bivector (Render_Program, Translation_Matrix,
Normal, Ortho_1, Ortho_2,
Colour, Scale, Method_Type);
exception
when anError : others =>
Put_Line ("An exception occurred in E2GA_Draw.Draw_Bivector.");
raise;
end Draw_Bivector;
-- -------------------------------------------------------------------------
procedure Draw_Vector (Render_Program : GL.Objects.Programs.Program;
Model_View_Matrix : GL.Types.Singles.Matrix4;
Direction : Multivector.Vector; Colour : GL.Types.Colors.Color;
Scale : float := 1.0) is
use Multivector;
Vec_3D : Vector;
Tail : constant Vector := New_Vector (0.0, 0.0, 0.0);
begin
if E2GA.e1 (Direction) /= 0.0 then
Add_Blade (Vec_3D, Blade.E3_e1, E2GA.e1 (Direction));
end if;
if E2GA.e2 (Direction) /= 0.0 then
Add_Blade (Vec_3D, Blade.E3_e2, E2GA.e2 (Direction));
end if;
GA_Draw.Draw_Vector (Render_Program, Model_View_Matrix,
Tail, Vec_3D, Colour, Scale);
exception
when anError : others =>
Put_Line ("An exception occurred in E2GA_Draw.Draw_Vector.");
raise;
end Draw_Vector;
-- -------------------------------------------------------------------------
end E2GA_Draw;
|
Holt59/Ada-SDL | Ada | 7,465 | adb | --------------------------------------------
-- --
-- PACKAGE GAME - PARTIE ADA --
-- --
-- GAME-DISPLAY-FONT.ADB --
-- --
-- Gestion de l'affichage du texte --
-- --
-- Créateur : CAPELLE Mikaël --
-- Adresse : [email protected] --
-- --
-- Dernière modification : 14 / 06 / 2011 --
-- --
--------------------------------------------
with Interfaces.C, Interfaces.C.Extensions, Game.Display, Game.Gtype, Ada.Exceptions;
use Interfaces.C, Interfaces.C.Extensions, Game.Display, Game.Gtype;
with Ada.Text_IO;
package body Game.Display.Font is
-----------------
-- CLOSE_FONT --
-----------------
procedure C_Close_Font(F : in SDL_Font);
pragma Import(C,C_Close_Font,"close_font");
procedure Close_Font (F : in out Font) is
begin
if F.Fon /= Null_SDL_Font then
C_Close_Font(F.Fon);
F.Fon := Null_SDL_Font;
end if;
end Close_Font;
---------------
-- OPEN_FONT --
---------------
function C_Open_Font(Nom : in Char_Array; Taille : in Int) return SDL_Font;
pragma Import(C,C_Open_Font,"open_font");
procedure Open_Font (F : out Font;
Nom : in String;
Taille : in Integer) is
begin
Close_Font(F);
F.Fon := C_Open_Font(To_C(Nom), Int(Taille));
if F.Fon = Null_SDL_Font then
Ada.Exceptions.Raise_Exception(Font_Error'Identity,"Impossible de charger la police " & Nom & " avec la taille" & Integer'Image(Taille) & " : " & Game.Error);
end if;
end Open_Font;
---------------------------
-- INITIALIZE - FINALIZE --
---------------------------
procedure Initialize (F : in out Font) is
begin
F.Fon := Null_SDL_Font;
end Initialize;
procedure Finalize (F : in out Font) is
begin
Close_Font(F);
end Finalize;
-----------------------------
-- CREATE_SURF (C VERSION) --
-----------------------------
function C_Create_Surf_Pol(Text : in Char_Array;
F : in SDL_Font;
F_Type : in Int;
F_Encode : in Int;
Normal : in Int;
Bold : in Int;
Italic : in Int;
Underline : in Int;
Coul : in C_Color;
Fond : in C_Color) return SDL_Surface;
pragma Import(C,C_Create_Surf_Pol,"create_text_font");
-------------------
-- GET_TEXT_SURF --
-------------------
function Get_Text_Surf (Text : in String;
Police : in Font;
F_Type : in Type_Rendu := BLENDED;
Bold : in Boolean := False;
Underline : in Boolean := False;
Italic : in Boolean := False;
Encode : in Encodage := UTF8;
Coul : in Color := (0,0,0);
Fond : in Color := (255,255,255)) return Surface is
No : Int := 1;
Res : SDL_Surface := Null_SDL_Surface;
begin
if Bold or Underline or Italic then
No := 0;
end if;
Res := C_Create_Surf_Pol(Text => To_C(Text),
F => Police.Fon,
F_Type => Type_Rendu'Pos(F_Type),
F_Encode => Encodage'Pos(Encode),
Normal => No,
Bold => Boolean'Pos(Bold),
Italic => Boolean'Pos(Italic),
Underline => Boolean'Pos(Underline),
Coul => To_C_Col(Coul),
Fond => To_C_Col(Fond));
if Res = Null_SDL_Surface then
Ada.Exceptions.Raise_Exception(Font_Error'Identity,"Impossible de créer la surface avec le texte " & Text & " : " & Game.Error);
end if;
return (AF.Controlled with Res);
end Get_Text_Surf;
function Get_Text_Surf(Text : in String;
Police : in String;
Taille : in Natural;
F_Type : in Type_Rendu := BLENDED;
Bold : in Boolean := False;
Underline : in Boolean := False;
Italic : in Boolean := False;
Encode : in Encodage := UTF8;
Coul : in Color := (0,0,0);
Fond : in Color := (255,255,255)) return Surface is
F : Font;
begin
Open_Font(F,Police,Taille);
return Get_Text_Surf (Text => Text,
Police => F,
F_Type => F_Type,
Bold => Bold,
Underline => Underline,
Italic => Italic,
Encode => Encode,
Coul => Coul,
Fond => Fond);
end Get_Text_Surf;
----------------
-- PRINT_TEXT --
----------------
procedure Print_Text(Surf : in out Surface;
Pos : in out Rect;
Text : in String;
Police : in Font;
F_Type : in Type_Rendu := BLENDED;
Bold : in Boolean := False;
Underline : in Boolean := False;
Italic : in Boolean := False;
Encode : in Encodage := UTF8;
Coul : in Color := (0,0,0);
Fond : in Color := (255,255,255)) is
S : Surface := Null_Surface;
begin
S := Get_Text_Surf(Text,Police,F_Type,Bold,Underline,Italic,Encode,Coul,Fond);
Blit(Surf,S,Pos);
Flip;
Pos.W := Get_Width(S);
Pos.H := Get_Height(S);
end Print_Text;
procedure Print_Text(Surf : in out Surface;
Pos : in out Rect;
Text : in String;
Police : in String;
Taille : in Natural;
F_Type : in Type_Rendu := BLENDED;
Bold : in Boolean := False;
Underline : in Boolean := False;
Italic : in Boolean := False;
Encode : in Encodage := UTF8;
Coul : in Color := (0,0,0);
Fond : in Color := (255,255,255))is
F : Font;
begin
Open_Font(F,Police,Taille);
Print_Text(Surf,Pos,Text,F,F_Type,Bold,Underline,Italic,Encode,Coul,Fond);
end Print_Text;
end Game.Display.Font;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 16,408 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32L0x1.svd
pragma Restrictions (No_Elaboration_Code);
with System;
package STM32_SVD.ADC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype ISR_ADRDY_Field is STM32_SVD.Bit;
subtype ISR_EOSMP_Field is STM32_SVD.Bit;
subtype ISR_EOC_Field is STM32_SVD.Bit;
subtype ISR_EOS_Field is STM32_SVD.Bit;
subtype ISR_OVR_Field is STM32_SVD.Bit;
subtype ISR_AWD_Field is STM32_SVD.Bit;
subtype ISR_EOCAL_Field is STM32_SVD.Bit;
-- interrupt and status register
type ISR_Register is record
-- ADC ready
ADRDY : ISR_ADRDY_Field := 16#0#;
-- End of sampling flag
EOSMP : ISR_EOSMP_Field := 16#0#;
-- End of conversion flag
EOC : ISR_EOC_Field := 16#0#;
-- End of sequence flag
EOS : ISR_EOS_Field := 16#0#;
-- ADC overrun
OVR : ISR_OVR_Field := 16#0#;
-- unspecified
Reserved_5_6 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog flag
AWD : ISR_AWD_Field := 16#0#;
-- unspecified
Reserved_8_10 : STM32_SVD.UInt3 := 16#0#;
-- End Of Calibration flag
EOCAL : ISR_EOCAL_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
ADRDY at 0 range 0 .. 0;
EOSMP at 0 range 1 .. 1;
EOC at 0 range 2 .. 2;
EOS at 0 range 3 .. 3;
OVR at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
AWD at 0 range 7 .. 7;
Reserved_8_10 at 0 range 8 .. 10;
EOCAL at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype IER_ADRDYIE_Field is STM32_SVD.Bit;
subtype IER_EOSMPIE_Field is STM32_SVD.Bit;
subtype IER_EOCIE_Field is STM32_SVD.Bit;
subtype IER_EOSIE_Field is STM32_SVD.Bit;
subtype IER_OVRIE_Field is STM32_SVD.Bit;
subtype IER_AWDIE_Field is STM32_SVD.Bit;
subtype IER_EOCALIE_Field is STM32_SVD.Bit;
-- interrupt enable register
type IER_Register is record
-- ADC ready interrupt enable
ADRDYIE : IER_ADRDYIE_Field := 16#0#;
-- End of sampling flag interrupt enable
EOSMPIE : IER_EOSMPIE_Field := 16#0#;
-- End of conversion interrupt enable
EOCIE : IER_EOCIE_Field := 16#0#;
-- End of conversion sequence interrupt enable
EOSIE : IER_EOSIE_Field := 16#0#;
-- Overrun interrupt enable
OVRIE : IER_OVRIE_Field := 16#0#;
-- unspecified
Reserved_5_6 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog interrupt enable
AWDIE : IER_AWDIE_Field := 16#0#;
-- unspecified
Reserved_8_10 : STM32_SVD.UInt3 := 16#0#;
-- End of calibration interrupt enable
EOCALIE : IER_EOCALIE_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
ADRDYIE at 0 range 0 .. 0;
EOSMPIE at 0 range 1 .. 1;
EOCIE at 0 range 2 .. 2;
EOSIE at 0 range 3 .. 3;
OVRIE at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
AWDIE at 0 range 7 .. 7;
Reserved_8_10 at 0 range 8 .. 10;
EOCALIE at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype CR_ADEN_Field is STM32_SVD.Bit;
subtype CR_ADDIS_Field is STM32_SVD.Bit;
subtype CR_ADSTART_Field is STM32_SVD.Bit;
subtype CR_ADSTP_Field is STM32_SVD.Bit;
subtype CR_ADVREGEN_Field is STM32_SVD.Bit;
subtype CR_ADCAL_Field is STM32_SVD.Bit;
-- control register
type CR_Register is record
-- ADC enable command
ADEN : CR_ADEN_Field := 16#0#;
-- ADC disable command
ADDIS : CR_ADDIS_Field := 16#0#;
-- ADC start conversion command
ADSTART : CR_ADSTART_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- ADC stop conversion command
ADSTP : CR_ADSTP_Field := 16#0#;
-- unspecified
Reserved_5_27 : STM32_SVD.UInt23 := 16#0#;
-- ADC Voltage Regulator Enable
ADVREGEN : CR_ADVREGEN_Field := 16#0#;
-- unspecified
Reserved_29_30 : STM32_SVD.UInt2 := 16#0#;
-- ADC calibration
ADCAL : CR_ADCAL_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
ADEN at 0 range 0 .. 0;
ADDIS at 0 range 1 .. 1;
ADSTART at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
ADSTP at 0 range 4 .. 4;
Reserved_5_27 at 0 range 5 .. 27;
ADVREGEN at 0 range 28 .. 28;
Reserved_29_30 at 0 range 29 .. 30;
ADCAL at 0 range 31 .. 31;
end record;
subtype CFGR1_DMAEN_Field is STM32_SVD.Bit;
subtype CFGR1_DMACFG_Field is STM32_SVD.Bit;
subtype CFGR1_SCANDIR_Field is STM32_SVD.Bit;
subtype CFGR1_RES_Field is STM32_SVD.UInt2;
subtype CFGR1_ALIGN_Field is STM32_SVD.Bit;
subtype CFGR1_EXTSEL_Field is STM32_SVD.UInt3;
subtype CFGR1_EXTEN_Field is STM32_SVD.UInt2;
subtype CFGR1_OVRMOD_Field is STM32_SVD.Bit;
subtype CFGR1_CONT_Field is STM32_SVD.Bit;
subtype CFGR1_AUTDLY_Field is STM32_SVD.Bit;
subtype CFGR1_AUTOFF_Field is STM32_SVD.Bit;
subtype CFGR1_DISCEN_Field is STM32_SVD.Bit;
subtype CFGR1_AWDSGL_Field is STM32_SVD.Bit;
subtype CFGR1_AWDEN_Field is STM32_SVD.Bit;
subtype CFGR1_AWDCH_Field is STM32_SVD.UInt5;
-- configuration register 1
type CFGR1_Register is record
-- Direct memory access enable
DMAEN : CFGR1_DMAEN_Field := 16#0#;
-- Direct memery access configuration
DMACFG : CFGR1_DMACFG_Field := 16#0#;
-- Scan sequence direction
SCANDIR : CFGR1_SCANDIR_Field := 16#0#;
-- Data resolution
RES : CFGR1_RES_Field := 16#0#;
-- Data alignment
ALIGN : CFGR1_ALIGN_Field := 16#0#;
-- External trigger selection
EXTSEL : CFGR1_EXTSEL_Field := 16#0#;
-- unspecified
Reserved_9_9 : STM32_SVD.Bit := 16#0#;
-- External trigger enable and polarity selection
EXTEN : CFGR1_EXTEN_Field := 16#0#;
-- Overrun management mode
OVRMOD : CFGR1_OVRMOD_Field := 16#0#;
-- Single / continuous conversion mode
CONT : CFGR1_CONT_Field := 16#0#;
-- Auto-delayed conversion mode
AUTDLY : CFGR1_AUTDLY_Field := 16#0#;
-- Auto-off mode
AUTOFF : CFGR1_AUTOFF_Field := 16#0#;
-- Discontinuous mode
DISCEN : CFGR1_DISCEN_Field := 16#0#;
-- unspecified
Reserved_17_21 : STM32_SVD.UInt5 := 16#0#;
-- Enable the watchdog on a single channel or on all channels
AWDSGL : CFGR1_AWDSGL_Field := 16#0#;
-- Analog watchdog enable
AWDEN : CFGR1_AWDEN_Field := 16#0#;
-- unspecified
Reserved_24_25 : STM32_SVD.UInt2 := 16#0#;
-- Analog watchdog channel selection
AWDCH : CFGR1_AWDCH_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR1_Register use record
DMAEN at 0 range 0 .. 0;
DMACFG at 0 range 1 .. 1;
SCANDIR at 0 range 2 .. 2;
RES at 0 range 3 .. 4;
ALIGN at 0 range 5 .. 5;
EXTSEL at 0 range 6 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
EXTEN at 0 range 10 .. 11;
OVRMOD at 0 range 12 .. 12;
CONT at 0 range 13 .. 13;
AUTDLY at 0 range 14 .. 14;
AUTOFF at 0 range 15 .. 15;
DISCEN at 0 range 16 .. 16;
Reserved_17_21 at 0 range 17 .. 21;
AWDSGL at 0 range 22 .. 22;
AWDEN at 0 range 23 .. 23;
Reserved_24_25 at 0 range 24 .. 25;
AWDCH at 0 range 26 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype CFGR2_OVSE_Field is STM32_SVD.Bit;
subtype CFGR2_OVSR_Field is STM32_SVD.UInt3;
subtype CFGR2_OVSS_Field is STM32_SVD.UInt4;
subtype CFGR2_TOVS_Field is STM32_SVD.Bit;
subtype CFGR2_CKMODE_Field is STM32_SVD.UInt2;
-- configuration register 2
type CFGR2_Register is record
-- Oversampler Enable
OVSE : CFGR2_OVSE_Field := 16#0#;
-- unspecified
Reserved_1_1 : STM32_SVD.Bit := 16#0#;
-- Oversampling ratio
OVSR : CFGR2_OVSR_Field := 16#0#;
-- Oversampling shift
OVSS : CFGR2_OVSS_Field := 16#0#;
-- Triggered Oversampling
TOVS : CFGR2_TOVS_Field := 16#0#;
-- unspecified
Reserved_10_29 : STM32_SVD.UInt20 := 16#0#;
-- ADC clock mode
CKMODE : CFGR2_CKMODE_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR2_Register use record
OVSE at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
OVSR at 0 range 2 .. 4;
OVSS at 0 range 5 .. 8;
TOVS at 0 range 9 .. 9;
Reserved_10_29 at 0 range 10 .. 29;
CKMODE at 0 range 30 .. 31;
end record;
subtype SMPR_SMPR_Field is STM32_SVD.UInt3;
-- sampling time register
type SMPR_Register is record
-- Sampling time selection
SMPR : SMPR_SMPR_Field := 16#0#;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for SMPR_Register use record
SMPR at 0 range 0 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype TR_LT_Field is STM32_SVD.UInt12;
subtype TR_HT_Field is STM32_SVD.UInt12;
-- watchdog threshold register
type TR_Register is record
-- Analog watchdog lower threshold
LT : TR_LT_Field := 16#0#;
-- unspecified
Reserved_12_15 : STM32_SVD.UInt4 := 16#0#;
-- Analog watchdog higher threshold
HT : TR_HT_Field := 16#FFF#;
-- unspecified
Reserved_28_31 : STM32_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TR_Register use record
LT at 0 range 0 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
HT at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-- CHSELR_CHSEL array element
subtype CHSELR_CHSEL_Element is STM32_SVD.Bit;
-- CHSELR_CHSEL array
type CHSELR_CHSEL_Field_Array is array (0 .. 18) of CHSELR_CHSEL_Element
with Component_Size => 1, Size => 19;
-- Type definition for CHSELR_CHSEL
type CHSELR_CHSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- CHSEL as a value
Val : STM32_SVD.UInt19;
when True =>
-- CHSEL as an array
Arr : CHSELR_CHSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 19;
for CHSELR_CHSEL_Field use record
Val at 0 range 0 .. 18;
Arr at 0 range 0 .. 18;
end record;
-- channel selection register
type CHSELR_Register is record
-- Channel-x selection
CHSEL : CHSELR_CHSEL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_19_31 : STM32_SVD.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CHSELR_Register use record
CHSEL at 0 range 0 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype DR_DATA_Field is STM32_SVD.UInt16;
-- data register
type DR_Register is record
-- Read-only. Converted data
DATA : DR_DATA_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DATA at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CALFACT_CALFACT_Field is STM32_SVD.UInt7;
-- ADC Calibration factor
type CALFACT_Register is record
-- Calibration factor
CALFACT : CALFACT_CALFACT_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32_SVD.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CALFACT_Register use record
CALFACT at 0 range 0 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype CCR_PRESC_Field is STM32_SVD.UInt4;
subtype CCR_VREFEN_Field is STM32_SVD.Bit;
subtype CCR_TSEN_Field is STM32_SVD.Bit;
subtype CCR_VLCDEN_Field is STM32_SVD.Bit;
subtype CCR_LFMEN_Field is STM32_SVD.Bit;
-- ADC common configuration register
type CCR_Register is record
-- unspecified
Reserved_0_17 : STM32_SVD.UInt18 := 16#0#;
-- ADC prescaler
PRESC : CCR_PRESC_Field := 16#0#;
-- VREFINT enable
VREFEN : CCR_VREFEN_Field := 16#0#;
-- Temperature sensor enable
TSEN : CCR_TSEN_Field := 16#0#;
-- VLCD enable
VLCDEN : CCR_VLCDEN_Field := 16#0#;
-- Low Frequency Mode enable
LFMEN : CCR_LFMEN_Field := 16#0#;
-- unspecified
Reserved_26_31 : STM32_SVD.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
Reserved_0_17 at 0 range 0 .. 17;
PRESC at 0 range 18 .. 21;
VREFEN at 0 range 22 .. 22;
TSEN at 0 range 23 .. 23;
VLCDEN at 0 range 24 .. 24;
LFMEN at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog-to-digital converter
type ADC_Peripheral is record
-- interrupt and status register
ISR : aliased ISR_Register;
-- interrupt enable register
IER : aliased IER_Register;
-- control register
CR : aliased CR_Register;
-- configuration register 1
CFGR1 : aliased CFGR1_Register;
-- configuration register 2
CFGR2 : aliased CFGR2_Register;
-- sampling time register
SMPR : aliased SMPR_Register;
-- watchdog threshold register
TR : aliased TR_Register;
-- channel selection register
CHSELR : aliased CHSELR_Register;
-- data register
DR : aliased DR_Register;
-- ADC Calibration factor
CALFACT : aliased CALFACT_Register;
-- ADC common configuration register
CCR : aliased CCR_Register;
end record
with Volatile;
for ADC_Peripheral use record
ISR at 16#0# range 0 .. 31;
IER at 16#4# range 0 .. 31;
CR at 16#8# range 0 .. 31;
CFGR1 at 16#C# range 0 .. 31;
CFGR2 at 16#10# range 0 .. 31;
SMPR at 16#14# range 0 .. 31;
TR at 16#20# range 0 .. 31;
CHSELR at 16#28# range 0 .. 31;
DR at 16#40# range 0 .. 31;
CALFACT at 16#B4# range 0 .. 31;
CCR at 16#308# range 0 .. 31;
end record;
-- Analog-to-digital converter
ADC_Periph : aliased ADC_Peripheral
with Import, Address => ADC_Base;
end STM32_SVD.ADC;
|
AdaDoom3/wayland_ada_binding | Ada | 239 | ads | with Posix.Wayland_Client;
with Ada.Text_IO;
package Client_Examples is
package Px renames Posix;
package Wl renames Posix.Wayland_Client;
procedure Put_Line (Text : String) renames Ada.Text_IO.Put_Line;
end Client_Examples;
|
persan/a-vulkan | Ada | 831 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
package Vulkan.Low_Level.vulkan_h is
VULKAN_H_u : constant := 1; -- vulkan.h:2
--** Copyright (c) 2015-2019 The Khronos Group Inc.
--**
--** 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.
--
end Vulkan.Low_Level.vulkan_h;
|
reznikmm/matreshka | Ada | 7,120 | 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_Text.Alphabetical_Index_Mark_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Alphabetical_Index_Mark_Element_Node is
begin
return Self : Text_Alphabetical_Index_Mark_Element_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Text_Alphabetical_Index_Mark_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_Text_Alphabetical_Index_Mark
(ODF.DOM.Text_Alphabetical_Index_Mark_Elements.ODF_Text_Alphabetical_Index_Mark_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 Text_Alphabetical_Index_Mark_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Alphabetical_Index_Mark_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Text_Alphabetical_Index_Mark_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_Text_Alphabetical_Index_Mark
(ODF.DOM.Text_Alphabetical_Index_Mark_Elements.ODF_Text_Alphabetical_Index_Mark_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 Text_Alphabetical_Index_Mark_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_Text_Alphabetical_Index_Mark
(Visitor,
ODF.DOM.Text_Alphabetical_Index_Mark_Elements.ODF_Text_Alphabetical_Index_Mark_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.Text_URI,
Matreshka.ODF_String_Constants.Alphabetical_Index_Mark_Element,
Text_Alphabetical_Index_Mark_Element_Node'Tag);
end Matreshka.ODF_Text.Alphabetical_Index_Mark_Elements;
|
reznikmm/matreshka | Ada | 3,789 | 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.Fo_Hyphenation_Push_Char_Count_Attributes is
pragma Preelaborate;
type ODF_Fo_Hyphenation_Push_Char_Count_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Fo_Hyphenation_Push_Char_Count_Attribute_Access is
access all ODF_Fo_Hyphenation_Push_Char_Count_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Fo_Hyphenation_Push_Char_Count_Attributes;
|
kraileth/ravensource | Ada | 536 | adb | --- python/core/gps-python_core.adb.orig 2022-05-11 12:25:42 UTC
+++ python/core/gps-python_core.adb
@@ -43,8 +43,7 @@ package body GPS.Python_Core is
if Python_Home.Is_Empty then
declare
Packaged_Python_Location : constant Virtual_File :=
- Create (+Executable_Location)
- / (+"share") / (+"gnatstudio") / (+"python");
+ Create (+Executable_Location);
begin
Register_Python_Scripting
(Kernel.Scripts,
|
albinjal/Ada_Project | Ada | 1,958 | adb | with Ada.Command_Line; use Ada.Command_Line;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with TJa.Sockets; use TJa.Sockets;
with TJa.Window.Text; use TJa.Window.Text;
with TJa.Window.Elementary; use TJa.Window.Elementary;
with TJa.Window.Graphic; use TJa.Window.Graphic;
with TJa.Keyboard; use TJa.Keyboard;
with Yatzy_graphics_package; use Yatzy_graphics_package;
procedure Test is
procedure Test_TJa is
Own_Protocoll, Other_Protocoll: Protocoll_Type;
Selected_Place : Integer;
begin
Reset_Colours; -- Standard colours is supposed to be black on white ...
Clear_Window;
Set_Graphical_Mode(On);
background;
protocoll_background(125, 4);
logo_background(24, 4);
message(38, 18, "Hejsan");
-- Draw a rectangle on screen ...
--Set_Graphical_Mode(On);
for I in 1..15 loop
case I is
when 1 => Own_Protocoll(I) := 1;
when 2 => Own_Protocoll(I) := 2;
when 3 => Own_Protocoll(I) := 3;
when 4 => Own_Protocoll(I) := 4;
when 5 => Own_Protocoll(I) := 5;
when 6 => Own_Protocoll(I) := -1;
when 7 => Own_Protocoll(I) := -1;
when 8 => Own_Protocoll(I) := -1;
when 9 => Own_Protocoll(I) := -1;
when 10 => Own_Protocoll(I) := -1;
when 11 => Own_Protocoll(I) := -1;
when 12 => Own_Protocoll(I) := 15;
when 13 => Own_Protocoll(I) := -1;
when 14 => Own_Protocoll(I) := 15;
when 15 => Own_Protocoll(I) := -1;
when others => null;
-- Own_Protocoll(I) := I;
end case;
end loop;
for I in 1..15 loop
Other_Protocoll(I) := I;
end loop;
update_protocoll(125, 4, Own_Protocoll, Other_Protocoll);
for x in 1..5 loop
dice(x,8 + 15 * x, 38);
--dice_placement;
end loop;
logo(24, 4);
Set_Graphical_Mode(Off);
place(Own_Protocoll, Selected_Place);
Reset_Colours;
Reset_Text_Modes; -- Resets boold mode ...
end Test_TJa;
begin
Test_TJa;
Skip_Line;
end;
|
vpodzime/ada-util | Ada | 4,301 | adb | -----------------------------------------------------------------------
-- Util.beans.factory -- Bean Registration and Factory
-- Copyright (C) 2009, 2010, 2015 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.Log.Loggers;
package body Util.Beans.Factory is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Beans.Factory");
-- ------------------------------
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Definition : in Bean_Definition_Access;
Scope : in Scope_Type := REQUEST_SCOPE) is
B : constant Simple_Binding_Access := new Simple_Binding '(Def => Definition,
Scope => Scope);
begin
Log.Info ("Register bean '{0}' in scope {1}", Name, Scope_Type'Image (Scope));
Register (Factory, Name, B.all'Access);
end Register;
-- ------------------------------
-- Register under the given name a function to create the bean instance when
-- it is accessed for a first time. The scope defines the scope of the bean.
-- bean
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
Name : in String;
Bind : in Binding_Access) is
begin
Log.Info ("Register bean binding '{0}'", Name);
Factory.Map.Include (Key => To_Unbounded_String (Name),
New_Item => Bind);
end Register;
-- ------------------------------
-- Register all the definitions from a factory to a main factory.
-- ------------------------------
procedure Register (Factory : in out Bean_Factory;
From : in Bean_Factory) is
Pos : Bean_Maps.Cursor := Bean_Maps.First (From.Map);
begin
while Bean_Maps.Has_Element (Pos) loop
Factory.Map.Include (Key => Bean_Maps.Key (Pos),
New_Item => Bean_Maps.Element (Pos));
Bean_Maps.Next (Pos);
end loop;
end Register;
-- ------------------------------
-- Create a bean by using the create operation registered for the name
-- ------------------------------
procedure Create (Factory : in Bean_Factory;
Name : in Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type) is
Pos : constant Bean_Maps.Cursor := Factory.Map.Find (Name);
begin
if Bean_Maps.Has_Element (Pos) then
declare
B : constant Binding_Access := Bean_Maps.Element (Pos);
begin
B.Create (Name, Result, Definition, Scope);
end;
end if;
end Create;
procedure Create (Factory : in Simple_Binding;
Name : in Ada.Strings.Unbounded.Unbounded_String;
Result : out Util.Beans.Basic.Readonly_Bean_Access;
Definition : out Bean_Definition_Access;
Scope : out Scope_Type) is
pragma Unreferenced (Name);
begin
Result := Factory.Def.Create;
Definition := Factory.Def;
Scope := Factory.Scope;
end Create;
end Util.Beans.Factory;
|
zhmu/ananas | Ada | 7,175 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ T E X T _ I O . I N T E G E R _ I O --
-- --
-- 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 Ada.Wide_Text_IO.Integer_Aux;
with System.Img_BIU; use System.Img_BIU;
with System.Img_Int; use System.Img_Int;
with System.Img_LLB; use System.Img_LLB;
with System.Img_LLI; use System.Img_LLI;
with System.Img_LLW; use System.Img_LLW;
with System.Img_LLLB; use System.Img_LLLB;
with System.Img_LLLI; use System.Img_LLLI;
with System.Img_LLLW; use System.Img_LLLW;
with System.Img_WIU; use System.Img_WIU;
with System.Val_Int; use System.Val_Int;
with System.Val_LLI; use System.Val_LLI;
with System.Val_LLLI; use System.Val_LLLI;
with System.WCh_Con; use System.WCh_Con;
with System.WCh_WtS; use System.WCh_WtS;
package body Ada.Wide_Text_IO.Integer_IO is
package Aux_Int is new
Ada.Wide_Text_IO.Integer_Aux
(Integer,
Scan_Integer,
Set_Image_Integer,
Set_Image_Width_Integer,
Set_Image_Based_Integer);
package Aux_LLI is new
Ada.Wide_Text_IO.Integer_Aux
(Long_Long_Integer,
Scan_Long_Long_Integer,
Set_Image_Long_Long_Integer,
Set_Image_Width_Long_Long_Integer,
Set_Image_Based_Long_Long_Integer);
package Aux_LLLI is new
Ada.Wide_Text_IO.Integer_Aux
(Long_Long_Long_Integer,
Scan_Long_Long_Long_Integer,
Set_Image_Long_Long_Long_Integer,
Set_Image_Width_Long_Long_Long_Integer,
Set_Image_Based_Long_Long_Long_Integer);
Need_LLI : constant Boolean := Num'Base'Size > Integer'Size;
Need_LLLI : constant Boolean := Num'Base'Size > Long_Long_Integer'Size;
-- Throughout this generic body, we distinguish between cases where type
-- Integer is acceptable, where type Long_Long_Integer is acceptable and
-- where type Long_Long_Long_Integer is needed. These boolean constants
-- are used to test for these cases and since they are constant, only code
-- for the relevant case will be included in the instance.
---------
-- Get --
---------
procedure Get
(File : File_Type;
Item : out Num;
Width : Field := 0)
is
-- We depend on a range check to get Data_Error
pragma Unsuppress (Range_Check);
pragma Unsuppress (Overflow_Check);
begin
if Need_LLLI then
Aux_LLLI.Get (File, Long_Long_Long_Integer (Item), Width);
elsif Need_LLI then
Aux_LLI.Get (File, Long_Long_Integer (Item), Width);
else
Aux_Int.Get (File, Integer (Item), Width);
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
procedure Get
(Item : out Num;
Width : Field := 0)
is
begin
Get (Current_In, Item, Width);
end Get;
procedure Get
(From : Wide_String;
Item : out Num;
Last : out Positive)
is
-- We depend on a range check to get Data_Error
pragma Unsuppress (Range_Check);
pragma Unsuppress (Overflow_Check);
S : constant String := Wide_String_To_String (From, WCEM_Upper);
-- String on which we do the actual conversion. Note that the method
-- used for wide character encoding is irrelevant, since if there is
-- a character outside the Standard.Character range then the call to
-- Aux.Gets will raise Data_Error in any case.
begin
if Need_LLLI then
Aux_LLLI.Gets (S, Long_Long_Long_Integer (Item), Last);
elsif Need_LLI then
Aux_LLI.Gets (S, Long_Long_Integer (Item), Last);
else
Aux_Int.Gets (S, Integer (Item), Last);
end if;
exception
when Constraint_Error => raise Data_Error;
end Get;
---------
-- Put --
---------
procedure Put
(File : File_Type;
Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base)
is
begin
if Need_LLLI then
Aux_LLLI.Put (File, Long_Long_Long_Integer (Item), Width, Base);
elsif Need_LLI then
Aux_LLI.Put (File, Long_Long_Integer (Item), Width, Base);
else
Aux_Int.Put (File, Integer (Item), Width, Base);
end if;
end Put;
procedure Put
(Item : Num;
Width : Field := Default_Width;
Base : Number_Base := Default_Base)
is
begin
Put (Current_Out, Item, Width, Base);
end Put;
procedure Put
(To : out Wide_String;
Item : Num;
Base : Number_Base := Default_Base)
is
S : String (To'First .. To'Last);
begin
if Need_LLLI then
Aux_LLLI.Puts (S, Long_Long_Long_Integer (Item), Base);
elsif Need_LLI then
Aux_LLI.Puts (S, Long_Long_Integer (Item), Base);
else
Aux_Int.Puts (S, Integer (Item), Base);
end if;
for J in S'Range loop
To (J) := Wide_Character'Val (Character'Pos (S (J)));
end loop;
end Put;
end Ada.Wide_Text_IO.Integer_IO;
|
SayCV/rtems-addon-packages | Ada | 10,336 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2006,2009 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$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with ncurses2.genericPuts;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
procedure ncurses2.color_edit is
use Int_IO;
type RGB_Enum is (Redx, Greenx, Bluex);
procedure change_color (current : Color_Number;
field : RGB_Enum;
value : RGB_Value;
usebase : Boolean);
procedure change_color (current : Color_Number;
field : RGB_Enum;
value : RGB_Value;
usebase : Boolean) is
red, green, blue : RGB_Value;
begin
if usebase then
Color_Content (current, red, green, blue);
else
red := 0;
green := 0;
blue := 0;
end if;
case field is
when Redx => red := red + value;
when Greenx => green := green + value;
when Bluex => blue := blue + value;
end case;
declare
begin
Init_Color (current, red, green, blue);
exception
when Curses_Exception => Beep;
end;
end change_color;
package x is new ncurses2.genericPuts (100); use x;
tmpb : x.BS.Bounded_String;
tmp4 : String (1 .. 4);
tmp6 : String (1 .. 6);
tmp8 : String (1 .. 8);
-- This would be easier if Ada had a Bounded_String
-- defined as a class instead of the inferior generic package,
-- then I could define Put, Add, and Get for them. Blech.
value : RGB_Value := 0;
red, green, blue : RGB_Value;
max_colors : constant Natural := Number_Of_Colors;
current : Color_Number := 0;
field : RGB_Enum := Redx;
this_c : Key_Code := 0;
begin
Refresh;
for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop
Init_Pair (Color_Pair (i), White, i);
end loop;
Move_Cursor (Line => Lines - 2, Column => 0);
Add (Str => "Number: ");
myPut (tmpb, Integer (value));
myAdd (Str => tmpb);
loop
Switch_Character_Attribute (On => False,
Attr => (Bold_Character => True,
others => False));
Add (Line => 0, Column => 20, Str => "Color RGB Value Editing");
Switch_Character_Attribute (On => False,
Attr => (Bold_Character => True,
others => False));
for i in Color_Number'(0) .. Color_Number (Number_Of_Colors) loop
Move_Cursor (Line => 2 + Line_Position (i), Column => 0);
if current = i then
Add (Ch => '>');
else
Add (Ch => ' ');
end if;
-- TODO if i <= color_names'Max then
Put (tmp8, Integer (i));
Set_Character_Attributes (Color => Color_Pair (i));
Add (Str => " ");
Set_Character_Attributes;
Refresh;
Color_Content (i, red, green, blue);
Add (Str => " R = ");
if current = i and field = Redx then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (red));
Add (Str => tmp4);
if current = i and field = Redx then
Set_Character_Attributes;
end if;
Add (Str => " G = ");
if current = i and field = Greenx then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (green));
Add (Str => tmp4);
if current = i and field = Greenx then
Set_Character_Attributes;
end if;
Add (Str => " B = ");
if current = i and field = Bluex then
Switch_Character_Attribute (On => True,
Attr => (Stand_Out => True,
others => False));
end if;
Put (tmp4, Integer (blue));
Add (Str => tmp4);
if current = i and field = Bluex then
Set_Character_Attributes;
end if;
Set_Character_Attributes;
Add (Ch => ')');
end loop;
Add (Line => Line_Position (Number_Of_Colors + 3), Column => 0,
Str => "Use up/down to select a color, left/right to change " &
"fields.");
Add (Line => Line_Position (Number_Of_Colors + 4), Column => 0,
Str => "Modify field by typing nnn=, nnn-, or nnn+. ? for help.");
Move_Cursor (Line => 2 + Line_Position (current), Column => 0);
this_c := Getchar;
if Is_Digit (this_c) then
value := 0;
end if;
case this_c is
when KEY_UP =>
current := (current - 1) mod Color_Number (max_colors);
when KEY_DOWN =>
current := (current + 1) mod Color_Number (max_colors);
when KEY_RIGHT =>
field := RGB_Enum'Val ((RGB_Enum'Pos (field) + 1) mod 3);
when KEY_LEFT =>
field := RGB_Enum'Val ((RGB_Enum'Pos (field) - 1) mod 3);
when
Character'Pos ('0') |
Character'Pos ('1') |
Character'Pos ('2') |
Character'Pos ('3') |
Character'Pos ('4') |
Character'Pos ('5') |
Character'Pos ('6') |
Character'Pos ('7') |
Character'Pos ('8') |
Character'Pos ('9') =>
value := value * 10 + RGB_Value (ctoi (Code_To_Char (this_c)));
when Character'Pos ('+') =>
change_color (current, field, value, True);
when Character'Pos ('-') =>
change_color (current, field, -value, True);
when Character'Pos ('=') =>
change_color (current, field, value, False);
when Character'Pos ('?') =>
Erase;
P (" RGB Value Editing Help");
P ("");
P ("You are in the RGB value editor. Use the arrow keys to " &
"select one of");
P ("the fields in one of the RGB triples of the current colors;" &
" the one");
P ("currently selected will be reverse-video highlighted.");
P ("");
P ("To change a field, enter the digits of the new value; they" &
" are echoed");
P ("as entered. Finish by typing `='. The change will take" &
" effect instantly.");
P ("To increment or decrement a value, use the same procedure," &
" but finish");
P ("with a `+' or `-'.");
P ("");
P ("To quit, do `x' or 'q'");
Pause;
Erase;
when Character'Pos ('q') |
Character'Pos ('x') =>
null;
when others =>
Beep;
end case;
Move_Cursor (Line => Lines - 2, Column => 0);
Put (tmp6, Integer (value));
Add (Str => "Number: " & tmp6);
Clear_To_End_Of_Line;
exit when this_c = Character'Pos ('x') or
this_c = Character'Pos ('q');
end loop;
Erase;
End_Windows;
end ncurses2.color_edit;
|
onox/dcf-ada | Ada | 4,433 | adb | -- SPDX-License-Identifier: MIT
--
-- Copyright (c) 2007 - 2018 Gautier de Montmollin (Maintainer of the Ada version)
-- SWITZERLAND
--
-- 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 DCF.Zip.Compress.Deflate;
with DCF.Zip.CRC;
package body DCF.Zip.Compress is
use DCF.Zip.CRC;
procedure Compress_Data
(Input, Output : in out DCF.Streams.Root_Zipstream_Type'Class;
Input_Size : File_Size_Type;
Method : Compression_Method;
Feedback : Feedback_Proc;
CRC : out Unsigned_32;
Output_Size : out File_Size_Type;
Zip_Type : out Unsigned_16)
is
Index_In : constant DCF.Streams.Zs_Index_Type := Input.Index;
Index_Out : constant DCF.Streams.Zs_Index_Type := Output.Index;
Compression_OK : Boolean := False;
procedure Store_Data is
use type Ada.Streams.Stream_Element_Offset;
function Percentage (Left, Right : Ada.Streams.Stream_Element_Count) return Natural is
(Natural ((100.0 * Float (Left)) / Float (Right)));
Buffer : Ada.Streams.Stream_Element_Array (1 .. Default_Buffer_Size);
Last_Read : Ada.Streams.Stream_Element_Offset;
Counted : Ada.Streams.Stream_Element_Count := 0;
Size : constant Ada.Streams.Stream_Element_Count :=
Ada.Streams.Stream_Element_Count (Input_Size);
User_Aborting : Boolean := False;
begin
while not Input.End_Of_Stream loop
if Feedback /= null then
Feedback (Percentage (Counted, Size), User_Aborting);
if User_Aborting then
raise User_Abort;
end if;
end if;
if Counted >= Size then
exit;
end if;
Input.Read (Buffer, Last_Read);
Counted := Counted + Last_Read;
Output.Write (Buffer (1 .. Last_Read));
Update_Stream_Array (CRC, Buffer (1 .. Last_Read));
end loop;
Output_Size := File_Size_Type (Counted);
Zip_Type := Compression_Format_Code.Store;
Compression_OK := True;
end Store_Data;
procedure Compress_Data_Single_Method (Actual_Method : Compression_Method) is
begin
Init (CRC);
case Actual_Method is
when Store =>
Store_Data;
when Deflation_Method =>
Zip.Compress.Deflate
(Input,
Output,
Input_Size,
Feedback,
Actual_Method,
CRC,
Output_Size,
Compression_OK);
Zip_Type := Compression_Format_Code.Deflate;
end case;
CRC := Final (CRC);
end Compress_Data_Single_Method;
begin
Compress_Data_Single_Method (Method);
-- Handle case where compression has been unefficient:
-- data to be compressed is too "random"; then compressed data
-- happen to be larger than uncompressed data
if not Compression_OK then
-- Go back to the beginning and just store the data
Input.Set_Index (Index_In);
Output.Set_Index (Index_Out);
Compress_Data_Single_Method (Store);
end if;
end Compress_Data;
end DCF.Zip.Compress;
|
optikos/oasis | Ada | 4,594 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Element_Vectors;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Array_Component_Associations;
with Program.Element_Visitors;
package Program.Nodes.Array_Component_Associations is
pragma Preelaborate;
type Array_Component_Association is
new Program.Nodes.Node
and Program.Elements.Array_Component_Associations
.Array_Component_Association
and Program.Elements.Array_Component_Associations
.Array_Component_Association_Text
with private;
function Create
(Choices : Program.Element_Vectors.Element_Vector_Access;
Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access;
Expression : Program.Elements.Expressions.Expression_Access;
Box_Token : Program.Lexical_Elements.Lexical_Element_Access)
return Array_Component_Association;
type Implicit_Array_Component_Association is
new Program.Nodes.Node
and Program.Elements.Array_Component_Associations
.Array_Component_Association
with private;
function Create
(Choices : Program.Element_Vectors.Element_Vector_Access;
Expression : Program.Elements.Expressions.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Array_Component_Association
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Array_Component_Association is
abstract new Program.Nodes.Node
and Program.Elements.Array_Component_Associations
.Array_Component_Association
with record
Choices : Program.Element_Vectors.Element_Vector_Access;
Expression : Program.Elements.Expressions.Expression_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Array_Component_Association'Class);
overriding procedure Visit
(Self : not null access Base_Array_Component_Association;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Choices
(Self : Base_Array_Component_Association)
return Program.Element_Vectors.Element_Vector_Access;
overriding function Expression
(Self : Base_Array_Component_Association)
return Program.Elements.Expressions.Expression_Access;
overriding function Is_Array_Component_Association_Element
(Self : Base_Array_Component_Association)
return Boolean;
overriding function Is_Association_Element
(Self : Base_Array_Component_Association)
return Boolean;
type Array_Component_Association is
new Base_Array_Component_Association
and Program.Elements.Array_Component_Associations
.Array_Component_Association_Text
with record
Arrow_Token : Program.Lexical_Elements.Lexical_Element_Access;
Box_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Array_Component_Association_Text
(Self : aliased in out Array_Component_Association)
return Program.Elements.Array_Component_Associations
.Array_Component_Association_Text_Access;
overriding function Arrow_Token
(Self : Array_Component_Association)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Box_Token
(Self : Array_Component_Association)
return Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Array_Component_Association is
new Base_Array_Component_Association
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Array_Component_Association_Text
(Self : aliased in out Implicit_Array_Component_Association)
return Program.Elements.Array_Component_Associations
.Array_Component_Association_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Array_Component_Association)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Array_Component_Association)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Array_Component_Association)
return Boolean;
end Program.Nodes.Array_Component_Associations;
|
reznikmm/slimp | Ada | 4,946 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Slim.Messages.vers;
with Slim.Messages.strm;
with Slim.Messages.grfb;
with Slim.Messages.grfe;
with Slim.Messages.visu;
with Slim.Messages.bled;
with Slim.Messages.rtcs;
with Slim.Messages.bdac;
with Slim.Messages.aude;
with Slim.Messages.audg;
with Slim.Messages.Server_setd;
package body Slim.Players.Connected_State_Visiters is
----------
-- HELO --
----------
overriding procedure HELO
(Self : in out Visiter;
Message : not null access Slim.Messages.HELO.HELO_Message)
is
pragma Unreferenced (Message);
Player : Players.Player renames Self.Player.all;
Vers : Slim.Messages.vers.Vers_Message;
begin
Vers.Set_Version (League.Strings.To_Universal_String ("7.7.3"));
Write_Message (Player.Socket, Vers);
end HELO;
----------
-- STAT --
----------
overriding procedure STAT
(Self : in out Visiter;
Message : not null access Slim.Messages.STAT.STAT_Message)
is
pragma Unreferenced (Message);
use type Ada.Calendar.Time;
Player : Players.Player renames Self.Player.all;
Time : constant Natural := Natural
(Ada.Calendar.Seconds (Ada.Calendar.Clock));
Strm : Slim.Messages.strm.Strm_Message;
Grfb : Slim.Messages.grfb.Grfb_Message;
Grfe : Slim.Messages.grfe.Grfe_Message;
Visu : Slim.Messages.visu.Visu_Message;
Bled : Slim.Messages.bled.Bled_Message;
RTC1 : Slim.Messages.rtcs.Rtcs_Message;
RTC2 : Slim.Messages.rtcs.Rtcs_Message;
Bdac : Slim.Messages.bdac.Bdac_Message;
Aude : Slim.Messages.aude.Aude_Message;
Audg : Slim.Messages.audg.Audg_Message;
Setd : Slim.Messages.Server_setd.Setd_Message;
begin
Strm.Simple_Command
(Command => Slim.Messages.strm.Stop);
Write_Message (Player.Socket, Strm);
-- Set dynamic brightness - minimum in range 1 .. 7
-- 21 - coefficient in range (1 .. 20)
Grfb.Set_Brightness (16#0b04#);
Write_Message (Player.Socket, Grfb);
-- Send splash screen
Grfe.Initialize (Player.Splash.To_Stream_Element_Array);
Write_Message (Player.Socket, Grfe);
-- deactivate visualizer
Visu.Deactivate;
Write_Message (Player.Socket, Visu);
-- Enable backlight leds
Bled.Enable_LED;
Write_Message (Player.Socket, Bled);
-- Set 24hours clock mode
RTC1.Set_Format;
Write_Message (Player.Socket, RTC1);
-- Set clock
RTC2.Set_Time
(Hours => Time / 60 / 60,
Minutes => (Time / 60) mod 60,
Seconds => Time mod 60);
Write_Message (Player.Socket, RTC2);
-- Send a DAC settings to the client.
Bdac.Initialize
(6,
(16#09#, 16#00#, 16#00#, 16#02#, 16#92#, 16#00#,
16#00#, 16#03#, 16#d4#, 16#00#, 16#00#, 16#06#,
16#c1#, 16#00#, 16#00#, 16#0b#, 16#00#, 16#00#,
16#00#, 16#14#, 16#00#, 16#00#, 16#00#, 16#23#,
16#00#, 16#8f#, 16#ff#, 16#ff#, 16#ff#, 16#8f#,
16#ff#, 16#ff#, 16#ff#, 16#8f#, 16#ff#, 16#ff#,
16#ff#));
Write_Message (Player.Socket, Bdac);
-- Send a DAC settings to the client. Part 2
Bdac.Initialize
(7,
(16#09#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#8f#,
16#ff#, 16#ff#, 16#ff#, 16#8f#, 16#ff#, 16#ff#,
16#ff#));
Write_Message (Player.Socket, Bdac);
-- Send a DAC settings to the client. Part 3
Bdac.Initialize
(4, (16#05#, 16#37#, 16#00#, 16#00#, 16#17#, 16#2e#));
Write_Message (Player.Socket, Bdac);
-- Send a DAC settings to the client. Part 4
Bdac.Initialize
(4,
(16#11#, 16#29#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#));
Write_Message (Player.Socket, Bdac);
-- Send a DAC settings to the client. Part 5
Bdac.Initialize
(8, (16#00#, 16#00#, 16#26#, 16#00#));
Write_Message (Player.Socket, Bdac);
-- Enable the audio output.
Aude.Enable_Output;
Write_Message (Player.Socket, Aude);
-- Adjust the volume level
Audg.Set_Volume (50);
Write_Message (Player.Socket, Audg);
-- Ask player name
Setd.Request_Player_Name;
Write_Message (Player.Socket, Setd);
Player.State :=
(Idle,
Ada.Calendar.Clock - 60.0,
Menu_View => Player.First_Menu);
end STAT;
end Slim.Players.Connected_State_Visiters;
|
tum-ei-rcs/StratoX | Ada | 310 | adb | with p1; use p1;
package body p2 with SPARK_Mode is
procedure write_to_uart (msg : Byte_Array) with
Global => (Output => some_register)
is
begin
some_register := msg(1);
end;
procedure foo is
begin
write_to_uart(p1.toBytes (some_constant));
end foo;
end p2;
|
godunko/cga | Ada | 1,270 | ads | --
-- Copyright (C) 2023, Vadim Godunko <[email protected]>
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Line in 2D space.
with CGK.Primitives.Axes_2D;
with CGK.Primitives.Directions_2D;
with CGK.Primitives.Points_2D;
with CGK.Reals;
package CGK.Primitives.Lines_2D is
pragma Pure;
type Line_2D is private;
function Create_Line_2D
(Axis : CGK.Primitives.Axes_2D.Axis_2D) return Line_2D with Inline;
function Create_Line_2D
(Point : CGK.Primitives.Points_2D.Point_2D;
Direction : CGK.Primitives.Directions_2D.Direction_2D)
return Line_2D with Inline;
function Location
(Self : Line_2D) return CGK.Primitives.Points_2D.Point_2D with Inline;
-- Returns location point (origin) of the line.
function Direction
(Self : Line_2D)
return CGK.Primitives.Directions_2D.Direction_2D with Inline;
-- Returns the direction of the line.
procedure Coefficients
(Self : Line_2D;
A : out CGK.Reals.Real;
B : out CGK.Reals.Real;
C : out CGK.Reals.Real) with Inline;
-- Returns the normalized coefficients of the line.
private
type Line_2D is record
Axis : CGK.Primitives.Axes_2D.Axis_2D;
end record;
end CGK.Primitives.Lines_2D;
|
AdaCore/gpr | Ada | 1,441 | adb | --
-- Copyright (C) 2020-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Text_IO;
with GPR2.Context;
with GPR2.Path_Name;
with GPR2.Project.Tree;
procedure Main is
Tree : GPR2.Project.Tree.Object;
Context : GPR2.Context.Object;
Project_Name : constant GPR2.Filename_Type := "test";
use GPR2;
begin
Tree.Load_Autoconf
(Filename => GPR2.Path_Name.Create_File
(GPR2.Project.Ensure_Extension (Project_Name),
GPR2.Path_Name.No_Resolution),
Context => Context);
Tree.Update_Sources (With_Runtime => True);
if not Tree.Log_Messages.Has_Error then
declare
use Ada.Text_IO;
OK : Boolean := True;
procedure Check (S : GPR2.Simple_Name; Should_Be : Boolean := True) is
File : constant GPR2.Path_Name.Object := Tree.Get_File (S);
begin
if (File.Is_Defined and then File.Exists
and then File.Simple_Name = S) /= Should_Be
then
Put_Line ("Wrong for " & String (S));
OK := False;
end if;
end Check;
begin
Check ("gpr2.gpr");
Check ("main.adb");
Check ("main.o");
Check ("gpr2-project-tree.ads");
Check ("a-textio.ads");
Check ("none.ads", Should_Be => False);
if OK then
Put_Line ("OK");
end if;
end;
end if;
end Main;
|
msrLi/portingSources | Ada | 794 | ads | -- Copyright 2010-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pack is
procedure Print (I1 : Positive; I2 : Positive);
end Pack;
|
skill-lang/adaCommon | Ada | 784 | ads | -- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ synchronization in skill --
-- |___/_|\_\_|_|____| by: Dennis Przytarski, Timm Felden --
-- --
pragma Ada_2012;
package Skill.Synchronization is
pragma Pure;
protected type Mutex is
entry Lock;
procedure Unlock;
private
Locked : Boolean := False;
end Mutex;
protected type Barrier is
entry Await;
procedure Start;
procedure Complete;
private
Counter : Natural := 0;
end Barrier;
end Skill.Synchronization;
|
docandrew/troodon | Ada | 22,523 | adb | ---------------------------------
-- GID - Generic Image Decoder --
---------------------------------
--
-- Private child of GID, with helpers for identifying
-- image formats and reading header informations.
--
with GID.Buffering,
GID.Color_tables,
GID.Decoding_JPG,
GID.Decoding_PNG,
GID.Decoding_PNM;
with Ada.Unchecked_Deallocation;
package body GID.Headers is
-------------------------------------------------------
-- The very first: read signature to identify format --
-------------------------------------------------------
procedure Load_signature (
image : in out Image_descriptor;
try_tga : Boolean:= False
)
is
use Bounded_255;
c: Character;
FITS_challenge : String(1..5); -- without the initial
GIF_challenge : String(1..5); -- without the initial
PNG_challenge : String(1..7); -- without the initial
PNG_signature : constant String:= "PNG" & ASCII.CR & ASCII.LF & ASCII.SUB & ASCII.LF;
PNM_challenge : Character;
TIFF_challenge : String(1..3); -- without the initial
TIFF_signature : String(1..2);
procedure Dispose is
new Ada.Unchecked_Deallocation(Color_table, p_Color_table);
begin
-- Some cleanup
Dispose(image.palette);
image.next_frame:= 0.0;
image.display_orientation:= Unchanged;
--
Character'Read(image.stream, c);
image.first_byte:= Character'Pos(c);
case c is
when 'B' =>
Character'Read(image.stream, c);
if c='M' then
image.detailed_format:= To_Bounded_String("BMP");
image.format:= BMP;
return;
end if;
when 'S' =>
String'Read(image.stream, FITS_challenge);
if FITS_challenge = "IMPLE" then
image.detailed_format:= To_Bounded_String("FITS");
image.format:= FITS;
return;
end if;
when 'G' =>
String'Read(image.stream, GIF_challenge);
if GIF_challenge = "IF87a" or GIF_challenge = "IF89a" then
image.detailed_format:= To_Bounded_String('G' & GIF_challenge & ", ");
image.format:= GIF;
return;
end if;
when 'I' | 'M' =>
String'Read(image.stream, TIFF_challenge);
if c = TIFF_challenge(1) then
-- TIFF begins either with II (Intel) or MM (Motorola) - TIFF 6.0 Specification p.13
if c = 'I' then
image.detailed_format:= To_Bounded_String("TIFF, little-endian");
image.endianess:= little;
TIFF_signature:= '*' & ASCII.NUL; -- 42 (The Answer) on 16 bits
else
image.detailed_format:= To_Bounded_String("TIFF, big-endian");
image.endianess:= big;
TIFF_signature:= ASCII.NUL & '*'; -- 42 (The Answer) on 16 bits
end if;
if TIFF_challenge(2..3) = TIFF_signature then
image.format:= TIFF;
return;
end if;
end if;
when Character'Val(16#FF#) =>
Character'Read(image.stream, c);
if c=Character'Val(16#D8#) then
-- SOI (Start of Image) segment marker (FFD8)
image.detailed_format:= To_Bounded_String("JPEG");
image.format:= JPEG;
return;
end if;
when Character'Val(16#89#) =>
String'Read(image.stream, PNG_challenge);
if PNG_challenge = PNG_signature then
image.detailed_format:= To_Bounded_String("PNG");
image.format:= PNG;
return;
end if;
when 'P' =>
Character'Read(image.stream, PNM_challenge);
if PNM_challenge in '1'..'6' then
image.detailed_format:= To_Bounded_String("PNM (PBM, PGM or PPM)");
image.format:= PNM;
image.subformat_id:= Integer'Value((1 => PNM_challenge));
return;
end if;
when others =>
if try_tga then
image.detailed_format:= To_Bounded_String("TGA");
image.format:= TGA;
return;
else
raise unknown_image_format;
end if;
end case;
raise unknown_image_format;
end Load_signature;
-- Define reading of unsigned numbers from a byte stream
-- Little-endian
generic
type Number_LE is mod <>;
procedure Read_Intel_x86_number(
from_le : in Stream_Access;
n : out Number_LE
);
pragma Inline(Read_Intel_x86_number);
generic
type Number_BE is mod <>;
procedure Big_endian_number(
from_be : in Stream_Access;
n : out Number_BE
);
pragma Inline(Big_endian_number);
generic
type Number is mod <>;
procedure Big_endian_number_buffered(
from : in out Input_buffer;
n : out Number
);
pragma Inline(Big_endian_number_buffered);
generic
type Number is mod <>;
procedure Read_any_endian_number(
from : in Stream_Access;
n : out Number;
endi : in Endianess_type
);
pragma Inline(Read_any_endian_number);
-- Implementations
procedure Read_Intel_x86_number(
from_le : in Stream_Access;
n : out Number_LE
)
is
b: U8;
m: Number_LE:= 1;
begin
n:= 0;
for i in 1..Number_LE'Size/8 loop
U8'Read(from_le, b);
n:= n + m * Number_LE(b);
m:= m * 256;
end loop;
end Read_Intel_x86_number;
procedure Big_endian_number(
from_be : in Stream_Access;
n : out Number_BE
)
is
b: U8;
begin
n:= 0;
for i in 1..Number_BE'Size/8 loop
U8'Read(from_be, b);
n:= n * 256 + Number_BE(b);
end loop;
end Big_endian_number;
procedure Big_endian_number_buffered(
from : in out Input_buffer;
n : out Number
)
is
b: U8;
begin
n:= 0;
for i in 1..Number'Size/8 loop
Buffering.Get_Byte(from, b);
n:= n * 256 + Number(b);
end loop;
end Big_endian_number_buffered;
procedure Read_any_endian_number(
from : in Stream_Access;
n : out Number;
endi : in Endianess_type
)
is
procedure Read_Intel is new Read_Intel_x86_number(Number);
procedure Big_endian is new Big_endian_number(Number);
begin
case endi is
when little => Read_Intel(from, n);
when big => Big_endian(from, n);
end case;
end Read_any_endian_number;
-- Instantiations
procedure Read_Intel is new Read_Intel_x86_number( U16 );
procedure Read_Intel is new Read_Intel_x86_number( U32 );
procedure Big_endian_buffered is new Big_endian_number_buffered( U32 );
procedure Read_any_endian is new Read_any_endian_number( U32 );
----------------------------------------------------------
-- Loading of various format's headers (past signature) --
----------------------------------------------------------
----------------
-- BMP header --
----------------
procedure Load_BMP_header (image: in out Image_descriptor) is
n, dummy: U32;
pragma Warnings(off, dummy);
w, dummy16: U16;
pragma Warnings(off, dummy16);
begin
-- Pos= 3, read the file size
Read_Intel(image.stream, dummy);
-- Pos= 7, read four bytes, unknown
Read_Intel(image.stream, dummy);
-- Pos= 11, read four bytes offset, file top to bitmap data.
-- For 256 colors, this is usually 36 04 00 00
Read_Intel(image.stream, dummy);
-- Pos= 15. The beginning of Bitmap information header.
-- Data expected: 28H, denoting 40 byte header
Read_Intel(image.stream, dummy);
-- Pos= 19. Bitmap width, in pixels. Four bytes
Read_Intel(image.stream, n);
image.width:= Positive_32 (n);
-- Pos= 23. Bitmap height, in pixels. Four bytes
Read_Intel(image.stream, n);
image.height:= Positive_32 (n);
-- Pos= 27, skip two bytes. Data is number of Bitmap planes.
Read_Intel(image.stream, dummy16); -- perform the skip
-- Pos= 29, Number of bits per pixel
-- Value 8, denoting 256 color, is expected
Read_Intel(image.stream, w);
case w is
when 1 | 4 | 8 | 24 =>
null;
when others =>
raise unsupported_image_subformat with "BMP bit depth =" & U16'Image(w);
end case;
image.bits_per_pixel:= Integer(w);
-- Pos= 31, read four bytes
Read_Intel(image.stream, n); -- Type of compression used
-- BI_RLE8 = 1
-- BI_RLE4 = 2
if n /= 0 then
raise unsupported_image_subformat with "BMP: RLE compression";
end if;
--
Read_Intel(image.stream, dummy); -- Pos= 35, image size
Read_Intel(image.stream, dummy); -- Pos= 39, horizontal resolution
Read_Intel(image.stream, dummy); -- Pos= 43, vertical resolution
Read_Intel(image.stream, n); -- Pos= 47, number of palette colors
if image.bits_per_pixel <= 8 then
if n = 0 then
image.palette:= new Color_table(0..2**image.bits_per_pixel-1);
else
image.palette:= new Color_table(0..Natural(n)-1);
end if;
end if;
Read_Intel(image.stream, dummy); -- Pos= 51, number of important colors
-- Pos= 55 (36H), - start of palette
Color_tables.Load_palette(image);
end Load_BMP_header;
procedure Load_FITS_header (image: in out Image_descriptor) is
begin
raise known_but_unsupported_image_format;
end Load_FITS_header;
----------------
-- GIF header --
----------------
procedure Load_GIF_header (image: in out Image_descriptor) is
-- GIF - logical screen descriptor
screen_width, screen_height : U16;
packed, background, aspect_ratio_code : U8;
global_palette: Boolean;
begin
Read_Intel(image.stream, screen_width);
Read_Intel(image.stream, screen_height);
if screen_width = 0 then
raise error_in_image_data with "GIF image: zero width";
end if;
if screen_height = 0 then
raise error_in_image_data with "GIF image: zero height";
end if;
image.width:= Positive_32 (screen_width);
image.height:= Positive_32 (screen_height);
image.transparency:= True; -- cannot exclude transparency at this level.
U8'Read(image.stream, packed);
-- Global Color Table Flag 1 Bit
-- Color Resolution 3 Bits
-- Sort Flag 1 Bit
-- Size of Global Color Table 3 Bits
global_palette:= (packed and 16#80#) /= 0;
image.bits_per_pixel:= Natural((packed and 16#7F#)/16#10#) + 1;
-- Indicative:
-- iv) [...] This value should be set to indicate the
-- richness of the original palette
U8'Read(image.stream, background);
U8'Read(image.stream, aspect_ratio_code);
Buffering.Attach_Stream(image.buffer, image.stream);
if global_palette then
image.subformat_id:= 1+(Natural(packed and 16#07#));
-- palette's bits per pixels, usually <= image's
--
-- if image.subformat_id > image.bits_per_pixel then
-- raise
-- error_in_image_data with
-- "GIF: global palette has more colors than the image" &
-- image.subformat_id'img & image.bits_per_pixel'img;
-- end if;
image.palette:= new Color_table(0..2**(image.subformat_id)-1);
Color_tables.Load_palette(image);
end if;
end Load_GIF_header;
-----------------
-- JPEG header --
-----------------
procedure Load_JPEG_header (image: in out Image_descriptor) is
-- http://en.wikipedia.org/wiki/JPEG
use GID.Decoding_JPG, GID.Buffering;
sh: Segment_head;
b: U8;
begin
-- We have already passed the SOI (Start of Image) segment marker (FFD8).
image.JPEG_stuff.restart_interval:= 0;
Attach_Stream(image.buffer, image.stream);
loop
Read(image, sh);
case sh.kind is
when DHT => -- Huffman Table
Read_DHT(image, Natural(sh.length));
when DQT =>
Read_DQT(image, Natural(sh.length));
when DRI => -- Restart Interval
Read_DRI(image);
when SOF_0 .. SOF_15 =>
Read_SOF(image, sh);
exit; -- we've got header-style informations, then it's time to quit
when APP_1 =>
Read_EXIF(image, Natural(sh.length));
when others =>
-- Skip segment data
for i in 1..sh.length loop
Get_Byte(image.buffer, b);
end loop;
end case;
end loop;
end Load_JPEG_header;
----------------
-- PNG header --
----------------
procedure Load_PNG_header (image: in out Image_descriptor) is
use Decoding_PNG, Buffering;
ch: Chunk_head;
n, dummy: U32;
pragma Unreferenced(dummy);
b, color_type: U8;
palette: Boolean:= False;
begin
Buffering.Attach_Stream(image.buffer, image.stream);
Read(image, ch);
if ch.kind /= IHDR then
raise error_in_image_data with "PNG: expected 'IHDR' chunk as first chunk in PNG stream";
end if;
Big_endian_buffered(image.buffer, n);
if n = 0 then
raise error_in_image_data with "PNG image with zero width";
end if;
if n > U32 (Positive_32'Last) then
raise error_in_image_data with "PNG image: width value too large:" & U32'Image (n);
end if;
image.width:= Positive_32 (n);
Big_endian_buffered(image.buffer, n);
if n = 0 then
raise error_in_image_data with "PNG image with zero height";
end if;
if n > U32 (Positive_32'Last) then
raise error_in_image_data with "PNG image: height value too large:" & U32'Image (n);
end if;
image.height:= Positive_32 (n);
Get_Byte(image.buffer, b);
if b = 0 then
raise error_in_image_data with "PNG image: zero bit-per-pixel";
end if;
image.bits_per_pixel:= Integer(b);
Get_Byte(image.buffer, color_type);
image.subformat_id:= Integer(color_type);
case color_type is
when 0 => -- Greyscale
image.greyscale:= True;
case image.bits_per_pixel is
when 1 | 2 | 4 | 8 | 16 =>
null;
when others =>
raise error_in_image_data with
"PNG, type 0 (greyscale): wrong bit-per-channel depth";
end case;
when 2 => -- RGB TrueColor
case image.bits_per_pixel is
when 8 | 16 =>
image.bits_per_pixel:= 3 * image.bits_per_pixel;
when others =>
raise error_in_image_data with
"PNG, type 2 (RGB): wrong bit-per-channel depth";
end case;
when 3 => -- RGB with palette
palette:= True;
case image.bits_per_pixel is
when 1 | 2 | 4 | 8 =>
null;
when others =>
raise error_in_image_data with
"PNG, type 3: wrong bit-per-channel depth";
end case;
when 4 => -- Grey & Alpha
image.greyscale:= True;
image.transparency:= True;
case image.bits_per_pixel is
when 8 | 16 =>
image.bits_per_pixel:= 2 * image.bits_per_pixel;
when others =>
raise error_in_image_data with
"PNG, type 4 (Greyscale & Alpha): wrong bit-per-channel depth";
end case;
when 6 => -- RGBA
image.transparency:= True;
case image.bits_per_pixel is
when 8 | 16 =>
image.bits_per_pixel:= 4 * image.bits_per_pixel;
when others =>
raise error_in_image_data with
"PNG, type 6 (RGBA): wrong bit-per-channel depth";
end case;
when others =>
raise error_in_image_data with "PNG: unknown color type";
end case;
Get_Byte(image.buffer, b);
if b /= 0 then
raise error_in_image_data with
"PNG: unknown compression format; ISO/IEC 15948:2003" &
" knows only 'method 0' (Deflate)";
end if;
Get_Byte(image.buffer, b);
if b /= 0 then
raise error_in_image_data with
"PNG: unknown filtering; ISO/IEC 15948:2003 knows only 'method 0'";
end if;
Get_Byte(image.buffer, b);
image.interlaced:= b = 1; -- Adam7
Big_endian_buffered(image.buffer, dummy); -- Chunk's CRC
if palette then
loop
Read(image, ch);
case ch.kind is
when IEND =>
raise error_in_image_data with
"PNG: a palette (PLTE) is expected here, found IEND";
when PLTE =>
if ch.length rem 3 /= 0 then
raise error_in_image_data with
"PNG: palette chunk byte length must be a multiple of 3";
end if;
image.palette:= new Color_table(0..Integer(ch.length/3)-1);
Color_tables.Load_palette(image);
Big_endian_buffered(image.buffer, dummy); -- Chunk's CRC
exit;
when others =>
-- Skip chunk data and CRC
for i in 1..ch.length + 4 loop
Get_Byte(image.buffer, b);
end loop;
end case;
end loop;
end if;
end Load_PNG_header;
--------------------------------
-- PNM (PBM, PGM, PPM) header --
--------------------------------
procedure Load_PNM_header (image: in out Image_descriptor) is
use Decoding_PNM;
depth_val: Integer;
begin
image.width := Get_Positive_32 (image.stream);
case image.subformat_id is
when 1 | 4 =>
image.height := Get_Positive_32 (image.stream, needs_EOL => True);
image.greyscale:= True;
image.bits_per_pixel:= 3;
when 2..3 | 5..6 =>
image.height := Get_Positive_32 (image.stream);
depth_val := Get_Integer(image.stream, needs_EOL => True);
if depth_val /= 255 then
raise unsupported_image_subformat with
"PNM: maximum depth value" & Integer'Image(depth_val) &
"; only 255 is supported";
end if;
image.greyscale:= image.subformat_id = 2 or image.subformat_id = 5;
image.bits_per_pixel:= 24;
when others =>
raise unsupported_image_subformat with
"PNM: P" & Integer'Image(image.subformat_id) & " not supported";
end case;
exception
when Constraint_Error =>
raise error_in_image_data with "PNM: invalid numeric value in PNM header";
end Load_PNM_header;
------------------------
-- TGA (Targa) header --
------------------------
procedure Load_TGA_header (image: in out Image_descriptor) is
-- TGA FILE HEADER, p.6
--
image_ID_length: U8; -- Field 1
color_map_type : U8; -- Field 2
image_type : U8; -- Field 3
-- Color Map Specification - Field 4
first_entry_index : U16; -- Field 4.1
color_map_length : U16; -- Field 4.2
color_map_entry_size: U8; -- Field 4.3
-- Image Specification - Field 5
x_origin: U16;
y_origin: U16;
image_width: U16;
image_height: U16;
pixel_depth: U8;
tga_image_descriptor: U8;
--
dummy: U8;
base_image_type: Integer;
begin
-- Read the header
image_ID_length:= image.first_byte;
U8'Read(image.stream, color_map_type);
U8'Read(image.stream, image_type);
-- Color Map Specification - Field 4
Read_Intel(image.stream, first_entry_index);
Read_Intel(image.stream, color_map_length);
U8'Read(image.stream, color_map_entry_size);
-- Image Specification - Field 5
Read_Intel(image.stream, x_origin);
Read_Intel(image.stream, y_origin);
Read_Intel(image.stream, image_width);
Read_Intel(image.stream, image_height);
U8'Read(image.stream, pixel_depth);
U8'Read(image.stream, tga_image_descriptor);
-- Done.
--
-- Image type:
-- 1 = 8-bit palette style
-- 2 = Direct [A]RGB image
-- 3 = grayscale
-- 9 = RLE version of Type 1
-- 10 = RLE version of Type 2
-- 11 = RLE version of Type 3
--
base_image_type:= U8'Pos(image_type and 7);
image.RLE_encoded:= (image_type and 8) /= 0;
--
if color_map_type /= 0 then
image.palette:= new Color_table(
Integer(first_entry_index)..
Integer(first_entry_index)+Integer(color_map_length)-1
);
image.subformat_id:= Integer(color_map_entry_size);
case image.subformat_id is -- = palette's bit depth
when 8 => -- Grey
null;
when 15 => -- RGB 3*5 bit
null;
when 16 => -- RGBA 3*5+1 bit
image.transparency:= True;
when 24 => -- RGB 3*8 bit
null;
when 32 => -- RGBA 4*8 bit
image.transparency:= True;
when others =>
raise error_in_image_data with
"TGA color map (palette): wrong bit depth:" &
Integer'Image(image.subformat_id);
end case;
end if;
--
image.greyscale:= False; -- ev. overridden later
case base_image_type is
when 1 =>
image.greyscale:= color_map_entry_size = 8;
when 2 =>
null;
when 3 =>
image.greyscale:= True;
when others =>
raise unsupported_image_subformat with
"TGA type =" & Integer'Image(base_image_type);
end case;
image.width := U16'Pos(image_width);
image.height := U16'Pos(image_height);
image.bits_per_pixel := U8'Pos(pixel_depth);
-- Make sure we are loading a supported TGA_type
case image.bits_per_pixel is
when 24 | 15 | 8 =>
null;
when 32 | 16 =>
image.transparency:= True;
when others =>
raise unsupported_image_subformat with
"TGA bits per pixels =" & Integer'Image(image.bits_per_pixel) &
"; supported bpp are: 8, 15, 16, 24, 32";
end case;
image.top_first:= (tga_image_descriptor and 32) /= 0;
-- *** Image and color map data
-- * Image ID
for i in 1..image_ID_length loop
U8'Read( image.stream, dummy );
end loop;
-- * Color map data (palette)
Color_tables.Load_palette(image);
-- * Image data: Read by Load_image_contents.
end Load_TGA_header;
procedure Load_TIFF_header (image: in out Image_descriptor) is
first_IFD_offset: U32;
--
-- IFD: Image File Directory. Basically, the image header.
-- Issue with TIFF: often the image header is stored after the image data.
-- This would need streams with Set_Index instead of a general stream
-- (e.g. a file, not an HTTP stream), or to store the full image data
-- in a temp buffer. Perhaps we'll do that one day.
begin
Read_any_endian(image.stream, first_IFD_offset, image.endianess);
raise known_but_unsupported_image_format with
"TIFF is not appropriate for streaming. Use PNG, BMP (lossless) or JPEG instead." &
"Info: IFD Offset=" & U32'Image(first_IFD_offset);
end Load_TIFF_header;
end GID.Headers;
|
reznikmm/matreshka | Ada | 3,938 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Attributes.Style.Font_Family_Generic;
package ODF.DOM.Attributes.Style.Font_Family_Generic.Internals is
function Create
(Node : Matreshka.ODF_Attributes.Style.Font_Family_Generic.Style_Font_Family_Generic_Access)
return ODF.DOM.Attributes.Style.Font_Family_Generic.ODF_Style_Font_Family_Generic;
function Wrap
(Node : Matreshka.ODF_Attributes.Style.Font_Family_Generic.Style_Font_Family_Generic_Access)
return ODF.DOM.Attributes.Style.Font_Family_Generic.ODF_Style_Font_Family_Generic;
end ODF.DOM.Attributes.Style.Font_Family_Generic.Internals;
|
stcarrez/dynamo | Ada | 1,836 | ads | with Ada.Finalization;
with Lexer.Source;
package Lexer.Base is
pragma Preelaborate;
Default_Initial_Buffer_Size : constant := 8192;
type Buffer_Type is access all String;
type Private_Values is limited private;
type Instance is limited new Ada.Finalization.Limited_Controlled with record
Cur_Line : Positive := 1;
-- index of the line at the current position
Line_Start : Positive := 1;
-- the buffer index where the current line started
Prev_Lines_Chars : Natural := 0;
-- number of characters in all previous lines,
-- used for calculating index.
Pos : Positive := 1;
-- position of the next character to be read from the buffer
Buffer : Buffer_Type; -- input buffer. filled from the source.
Internal : Private_Values;
end record;
procedure Init (Object : in out Instance; Input : Source.Pointer;
Initial_Buffer_Size : Positive :=
Default_Initial_Buffer_Size);
procedure Init (Object : in out Instance; Input : String);
subtype Rune is Wide_Wide_Character;
function Next (Object : in out Instance) return Character with Inline;
procedure Handle_CR (L : in out Instance);
procedure Handle_LF (L : in out Instance);
End_Of_Input : constant Character := Character'Val (4);
Line_Feed : constant Character := Character'Val (10);
Carriage_Return : constant Character := Character'Val (13);
private
type Private_Values is limited record
Input : Source.Pointer; -- input provider
Sentinel : Positive;
-- the position at which, when reached, the buffer must be refilled
end record;
overriding procedure Finalize (Object : in out Instance);
procedure Refill_Buffer (L : in out Instance);
end Lexer.Base;
|
ohenley/ada-util | Ada | 2,052 | ads | -----------------------------------------------------------------------
-- strings.tests -- Unit tests for Strings
-- Copyright (C) 2009, 2010, 2011, 2012, 2015 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.Tests;
package Util.Strings.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Escape_Javascript (T : in out Test);
procedure Test_Escape_Xml (T : in out Test);
procedure Test_Unescape_Xml (T : in out Test);
procedure Test_Capitalize (T : in out Test);
procedure Test_To_Upper_Case (T : in out Test);
procedure Test_To_Lower_Case (T : in out Test);
procedure Test_To_Hex (T : in out Test);
procedure Test_Measure_Copy (T : in out Test);
procedure Test_Index (T : in out Test);
procedure Test_Rindex (T : in out Test);
-- Do some benchmark on String -> X hash mapped.
procedure Test_Measure_Hash (T : in out Test);
-- Test String_Ref creation
procedure Test_String_Ref (T : in out Test);
-- Benchmark comparison between the use of Iterate vs Query_Element.
procedure Test_Perf_Vector (T : in out Test);
-- Test perfect hash (samples/gperfhash)
procedure Test_Perfect_Hash (T : in out Test);
-- Test the token iteration.
procedure Test_Iterate_Token (T : in out Test);
end Util.Strings.Tests;
|
98devin/ada-wfc | Ada | 3,560 | adb | ------------------------------------------------------------------------------
-- EMAIL: <[email protected]> --
-- License: ISC --
-- --
-- Copyright © 2015 - 2016 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
with Ada.Characters.Latin_1;
with Interfaces.C;
with Interfaces.C.Strings;
package body Imago.ILU is
--------------------------------------------------------------------------
-------------------
-- R E N A M E S --
-------------------
--------------------------------------------------------------------------
package ASCII renames Ada.Characters.Latin_1;
package IC renames Interfaces.C;
package CStrings renames Interfaces.C.Strings;
--------------------------------------------------------------------------
-------------------------------------------
-- S U B P R O G R A M S ' B O D I E S --
-------------------------------------------
--------------------------------------------------------------------------
function Error_String (String_Name: in IL.Enum) return String
is
function iluErrorString (String_Name: in IL.Enum) return CStrings.chars_ptr
with Import => True, Convention => StdCall,
External_Name => "iluErrorString";
begin
return IC.To_Ada (CStrings.Value (iluErrorString (String_Name)));
end Error_String;
--------------------------------------------------------------------------
function Get_String (String_Name: in IL.Enum) return String
is
function iluGetString (String_Name: in IL.Enum) return CStrings.chars_ptr
with Import => True, Convention => StdCall,
External_Name => "iluGetString";
begin
return IC.To_Ada (CStrings.Value (iluGetString (String_Name)));
end Get_String;
------------------------------------------------------------------
function Load_Image (File_Name: in String) return IL.UInt
is
function iluLoadImage (F: in IL.Pointer) return IL.UInt
with Import => True, Convention => StdCall,
External_Name => "iluLoadImage";
CString: constant String := File_Name & ASCII.NUL;
begin
return iluLoadImage (CString'Address);
end Load_Image;
------------------------------------------------------------------
end Imago.ILU;
|
reznikmm/matreshka | Ada | 3,729 | 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.Elements;
package ODF.DOM.Table_Data_Pilot_Sort_Info_Elements is
pragma Preelaborate;
type ODF_Table_Data_Pilot_Sort_Info is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Data_Pilot_Sort_Info_Access is
access all ODF_Table_Data_Pilot_Sort_Info'Class
with Storage_Size => 0;
end ODF.DOM.Table_Data_Pilot_Sort_Info_Elements;
|
reznikmm/matreshka | Ada | 5,163 | 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.Generic_Collections;
package AMF.UMLDI.UML_Name_Labels.Collections is
pragma Preelaborate;
package UMLDI_UML_Name_Label_Collections is
new AMF.Generic_Collections
(UMLDI_UML_Name_Label,
UMLDI_UML_Name_Label_Access);
type Set_Of_UMLDI_UML_Name_Label is
new UMLDI_UML_Name_Label_Collections.Set with null record;
Empty_Set_Of_UMLDI_UML_Name_Label : constant Set_Of_UMLDI_UML_Name_Label;
type Ordered_Set_Of_UMLDI_UML_Name_Label is
new UMLDI_UML_Name_Label_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UMLDI_UML_Name_Label : constant Ordered_Set_Of_UMLDI_UML_Name_Label;
type Bag_Of_UMLDI_UML_Name_Label is
new UMLDI_UML_Name_Label_Collections.Bag with null record;
Empty_Bag_Of_UMLDI_UML_Name_Label : constant Bag_Of_UMLDI_UML_Name_Label;
type Sequence_Of_UMLDI_UML_Name_Label is
new UMLDI_UML_Name_Label_Collections.Sequence with null record;
Empty_Sequence_Of_UMLDI_UML_Name_Label : constant Sequence_Of_UMLDI_UML_Name_Label;
private
Empty_Set_Of_UMLDI_UML_Name_Label : constant Set_Of_UMLDI_UML_Name_Label
:= (UMLDI_UML_Name_Label_Collections.Set with null record);
Empty_Ordered_Set_Of_UMLDI_UML_Name_Label : constant Ordered_Set_Of_UMLDI_UML_Name_Label
:= (UMLDI_UML_Name_Label_Collections.Ordered_Set with null record);
Empty_Bag_Of_UMLDI_UML_Name_Label : constant Bag_Of_UMLDI_UML_Name_Label
:= (UMLDI_UML_Name_Label_Collections.Bag with null record);
Empty_Sequence_Of_UMLDI_UML_Name_Label : constant Sequence_Of_UMLDI_UML_Name_Label
:= (UMLDI_UML_Name_Label_Collections.Sequence with null record);
end AMF.UMLDI.UML_Name_Labels.Collections;
|
tum-ei-rcs/StratoX | Ada | 16,114 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.USART is
pragma Preelaborate;
---------------
-- Registers --
---------------
-----------------
-- SR_Register --
-----------------
-- Status register
type SR_Register is record
-- Read-only. Parity error
PE : Boolean := False;
-- Read-only. Framing error
FE : Boolean := False;
-- Read-only. Noise detected flag
NF : Boolean := False;
-- Read-only. Overrun error
ORE : Boolean := False;
-- Read-only. IDLE line detected
IDLE : Boolean := False;
-- Read data register not empty
RXNE : Boolean := False;
-- Transmission complete
TC : Boolean := False;
-- Read-only. Transmit data register empty
TXE : Boolean := False;
-- LIN break detection flag
LBD : Boolean := False;
-- CTS flag
CTS : Boolean := False;
-- unspecified
Reserved_10_31 : HAL.UInt22 := 16#3000#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBD at 0 range 8 .. 8;
CTS at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
-----------------
-- DR_Register --
-----------------
subtype DR_DR_Field is HAL.UInt9;
-- Data register
type DR_Register is record
-- Data value
DR : DR_DR_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DR at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
------------------
-- BRR_Register --
------------------
subtype BRR_DIV_Fraction_Field is HAL.UInt4;
subtype BRR_DIV_Mantissa_Field is HAL.UInt12;
-- Baud rate register
type BRR_Register is record
-- fraction of USARTDIV
DIV_Fraction : BRR_DIV_Fraction_Field := 16#0#;
-- mantissa of USARTDIV
DIV_Mantissa : BRR_DIV_Mantissa_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BRR_Register use record
DIV_Fraction at 0 range 0 .. 3;
DIV_Mantissa at 0 range 4 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CR1_Register --
------------------
-- Control register 1
type CR1_Register is record
-- Send break
SBK : Boolean := False;
-- Receiver wakeup
RWU : Boolean := False;
-- Receiver enable
RE : Boolean := False;
-- Transmitter enable
TE : Boolean := False;
-- IDLE interrupt enable
IDLEIE : Boolean := False;
-- RXNE interrupt enable
RXNEIE : Boolean := False;
-- Transmission complete interrupt enable
TCIE : Boolean := False;
-- TXE interrupt enable
TXEIE : Boolean := False;
-- PE interrupt enable
PEIE : Boolean := False;
-- Parity selection
PS : Boolean := False;
-- Parity control enable
PCE : Boolean := False;
-- Wakeup method
WAKE : Boolean := False;
-- Word length
M : Boolean := False;
-- USART enable
UE : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Oversampling mode
OVER8 : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
SBK at 0 range 0 .. 0;
RWU at 0 range 1 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
IDLEIE at 0 range 4 .. 4;
RXNEIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
TXEIE at 0 range 7 .. 7;
PEIE at 0 range 8 .. 8;
PS at 0 range 9 .. 9;
PCE at 0 range 10 .. 10;
WAKE at 0 range 11 .. 11;
M at 0 range 12 .. 12;
UE at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
OVER8 at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CR2_Register --
------------------
subtype CR2_ADD_Field is HAL.UInt4;
subtype CR2_STOP_Field is HAL.UInt2;
-- Control register 2
type CR2_Register is record
-- Address of the USART node
ADD : CR2_ADD_Field := 16#0#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- lin break detection length
LBDL : Boolean := False;
-- LIN break detection interrupt enable
LBDIE : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Last bit clock pulse
LBCL : Boolean := False;
-- Clock phase
CPHA : Boolean := False;
-- Clock polarity
CPOL : Boolean := False;
-- Clock enable
CLKEN : Boolean := False;
-- STOP bits
STOP : CR2_STOP_Field := 16#0#;
-- LIN mode enable
LINEN : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
ADD at 0 range 0 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
LBCL at 0 range 8 .. 8;
CPHA at 0 range 9 .. 9;
CPOL at 0 range 10 .. 10;
CLKEN at 0 range 11 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
------------------
-- CR3_Register --
------------------
-- Control register 3
type CR3_Register is record
-- Error interrupt enable
EIE : Boolean := False;
-- IrDA mode enable
IREN : Boolean := False;
-- IrDA low-power
IRLP : Boolean := False;
-- Half-duplex selection
HDSEL : Boolean := False;
-- Smartcard NACK enable
NACK : Boolean := False;
-- Smartcard mode enable
SCEN : Boolean := False;
-- DMA enable receiver
DMAR : Boolean := False;
-- DMA enable transmitter
DMAT : Boolean := False;
-- RTS enable
RTSE : Boolean := False;
-- CTS enable
CTSE : Boolean := False;
-- CTS interrupt enable
CTSIE : Boolean := False;
-- One sample bit method enable
ONEBIT : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
NACK at 0 range 4 .. 4;
SCEN at 0 range 5 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
RTSE at 0 range 8 .. 8;
CTSE at 0 range 9 .. 9;
CTSIE at 0 range 10 .. 10;
ONEBIT at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-------------------
-- GTPR_Register --
-------------------
subtype GTPR_PSC_Field is HAL.Byte;
subtype GTPR_GT_Field is HAL.Byte;
-- Guard time and prescaler register
type GTPR_Register is record
-- Prescaler value
PSC : GTPR_PSC_Field := 16#0#;
-- Guard time value
GT : GTPR_GT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GTPR_Register use record
PSC at 0 range 0 .. 7;
GT at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- SR_Register --
-----------------
-- Status register
type SR_Register_1 is record
-- Read-only. Parity error
PE : Boolean := False;
-- Read-only. Framing error
FE : Boolean := False;
-- Read-only. Noise detected flag
NF : Boolean := False;
-- Read-only. Overrun error
ORE : Boolean := False;
-- Read-only. IDLE line detected
IDLE : Boolean := False;
-- Read data register not empty
RXNE : Boolean := False;
-- Transmission complete
TC : Boolean := False;
-- Read-only. Transmit data register empty
TXE : Boolean := False;
-- LIN break detection flag
LBD : Boolean := False;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#6000#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_1 use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBD at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
------------------
-- CR2_Register --
------------------
-- Control register 2
type CR2_Register_1 is record
-- Address of the USART node
ADD : CR2_ADD_Field := 16#0#;
-- unspecified
Reserved_4_4 : HAL.Bit := 16#0#;
-- lin break detection length
LBDL : Boolean := False;
-- LIN break detection interrupt enable
LBDIE : Boolean := False;
-- unspecified
Reserved_7_11 : HAL.UInt5 := 16#0#;
-- STOP bits
STOP : CR2_STOP_Field := 16#0#;
-- LIN mode enable
LINEN : Boolean := False;
-- unspecified
Reserved_15_31 : HAL.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_1 use record
ADD at 0 range 0 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7_11 at 0 range 7 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
------------------
-- CR3_Register --
------------------
-- Control register 3
type CR3_Register_1 is record
-- Error interrupt enable
EIE : Boolean := False;
-- IrDA mode enable
IREN : Boolean := False;
-- IrDA low-power
IRLP : Boolean := False;
-- Half-duplex selection
HDSEL : Boolean := False;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- DMA enable receiver
DMAR : Boolean := False;
-- DMA enable transmitter
DMAT : Boolean := False;
-- unspecified
Reserved_8_10 : HAL.UInt3 := 16#0#;
-- One sample bit method enable
ONEBIT : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register_1 use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
Reserved_8_10 at 0 range 8 .. 10;
ONEBIT at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Universal synchronous asynchronous receiver transmitter
type USART2_Peripheral is record
-- Status register
SR : SR_Register;
-- Data register
DR : DR_Register;
-- Baud rate register
BRR : BRR_Register;
-- Control register 1
CR1 : CR1_Register;
-- Control register 2
CR2 : CR2_Register;
-- Control register 3
CR3 : CR3_Register;
-- Guard time and prescaler register
GTPR : GTPR_Register;
end record
with Volatile;
for USART2_Peripheral use record
SR at 0 range 0 .. 31;
DR at 4 range 0 .. 31;
BRR at 8 range 0 .. 31;
CR1 at 12 range 0 .. 31;
CR2 at 16 range 0 .. 31;
CR3 at 20 range 0 .. 31;
GTPR at 24 range 0 .. 31;
end record;
-- Universal synchronous asynchronous receiver transmitter
USART2_Periph : aliased USART2_Peripheral
with Import, Address => USART2_Base;
-- Universal synchronous asynchronous receiver transmitter
USART3_Periph : aliased USART2_Peripheral
with Import, Address => USART3_Base;
-- Universal synchronous asynchronous receiver transmitter
UART7_Periph : aliased USART2_Peripheral
with Import, Address => UART7_Base;
-- Universal synchronous asynchronous receiver transmitter
UART8_Periph : aliased USART2_Peripheral
with Import, Address => UART8_Base;
-- Universal synchronous asynchronous receiver transmitter
USART1_Periph : aliased USART2_Peripheral
with Import, Address => USART1_Base;
-- Universal synchronous asynchronous receiver transmitter
USART6_Periph : aliased USART2_Peripheral
with Import, Address => USART6_Base;
-- Universal synchronous asynchronous receiver transmitter
type UART4_Peripheral is record
-- Status register
SR : SR_Register_1;
-- Data register
DR : DR_Register;
-- Baud rate register
BRR : BRR_Register;
-- Control register 1
CR1 : CR1_Register;
-- Control register 2
CR2 : CR2_Register_1;
-- Control register 3
CR3 : CR3_Register_1;
end record
with Volatile;
for UART4_Peripheral use record
SR at 0 range 0 .. 31;
DR at 4 range 0 .. 31;
BRR at 8 range 0 .. 31;
CR1 at 12 range 0 .. 31;
CR2 at 16 range 0 .. 31;
CR3 at 20 range 0 .. 31;
end record;
-- Universal synchronous asynchronous receiver transmitter
UART4_Periph : aliased UART4_Peripheral
with Import, Address => UART4_Base;
-- Universal synchronous asynchronous receiver transmitter
UART5_Periph : aliased UART4_Peripheral
with Import, Address => UART5_Base;
end STM32_SVD.USART;
|
alexcamposruiz/dds-requestreply | Ada | 6,780 | adb | with DDS.Topic;
with DDS.TopicDescription;
with DDS.Request_Reply.Untypedcommon;
with DDS.Request_Reply.Connext_C_Entity_Params;
with System;
with DDS.Request_Reply.Connext_C_Replier;
package body DDS.Request_Reply.Replieruntypedimpl is
use System;
use Untypedcommon;
use Connext_C_Entity_Params;
use Connext_C_Replier;
function RTI_Connext_ReplierUntypedImpl_Create_Writer_Topic
(Self : not null access RTI_Connext_EntityUntypedImpl;
Params : RTI_Connext_EntityParams;
Reply_Type_Name : DDS.String) return DDS.Topic.Ref_Access is
Reply_Topic_Name : DDS.String;
RetTopicDescription : DDS.TopicDescription.Ref_Access;
begin
DDS.Copy (Reply_Topic_Name , (if DDS.Length (Reply_Topic_Name) /= DDS.long'(0)
then
DDS.To_Standard_String (Params.Reply_Topic_Name)
else
DDS.To_Standard_String (RTI_Connext_Create_Reply_Topic_Name_From_Service_Name ((Params.Service_Name)))));
RetTopicDescription := RTI_Connext_Get_Or_Create_Topic (Self.Participant, Reply_Topic_Name, Reply_Type_Name, False);
DDS.Finalize (Reply_Topic_Name);
return DDS.Topic.Narrow (RetTopicDescription);
end;
function RTI_Connext_ReplierUntypedImpl_Create_Reader_Topic
(Self : not null access RTI_Connext_EntityUntypedImpl;
Params : RTI_Connext_EntityParams;
Request_Type_Name : DDS.String) return DDS.Topic.Ref_Access is
Request_Topic_Name : DDS.String;
RetTopicDescription : DDS.TopicDescription.Ref_Access;
begin
DDS.Copy (Request_Topic_Name , (if DDS.Length (Request_Topic_Name) /= DDS.long'(0)
then
DDS.To_Standard_String (Params.Request_Topic_Name)
else
DDS.To_Standard_String (RTI_Connext_Create_Request_Topic_Name_From_Service_Name ((Params.Service_Name)))));
RetTopicDescription := RTI_Connext_Get_Or_Create_Topic (Self.Participant, Request_Topic_Name, Request_Type_Name, False);
DDS.Finalize (Request_Topic_Name);
return DDS.Topic.Narrow (RetTopicDescription);
end;
-- DDS_ReturnCode_t RTI_Connext_ReplierUntypedImpl_initialize(
-- RTI_Connext_ReplierUntypedImpl * self,
-- const struct RTI_Connext_EntityParams* params,
-- RegisterTypeFunc _request_type_fnc,
-- const char * request_type_name,
-- RegisterTypeFunc _reply_type_fnc,
-- const char * reply_type_name,
-- int request_size,
-- struct DDS_DataReaderListener * listener)
-- {
-- DDS_ReturnCode_t retCode = DDS_RETCODE_OK;
-- struct RTI_Connext_TopicBuilder topic_builder;
-- topic_builder.create_reader_topic = &RTI_Connext_ReplierUntypedImpl_create_reader_topic;
-- topic_builder.create_writer_topic = &RTI_Connext_ReplierUntypedImpl_create_writer_topic;
--
--
-- retCode = RTI_Connext_EntityUntypedImpl_initialize(
-- self,
-- params,
-- _reply_type_fnc,
-- reply_type_name,
-- _request_type_fnc,
-- request_type_name,
-- request_size,
-- &topic_builder,
-- listener,
-- "Replier");
--
-- if(retCode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "error initializing the entity untyped");
-- }
-- return retCode;
--
-- DDS_ReturnCode_t RTI_Connext_ReplierUntypedImpl_configure_params_for_reply(
-- RTI_Connext_ReplierUntypedImpl * self, struct DDS_WriteParams_t* params,
-- const struct DDS_SampleIdentity_t* related_request_info)
-- {
-- if(DDS_SampleIdentity_equals(related_request_info, &DDS_AUTO_SAMPLE_IDENTITY))
-- {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "bad related_request_info");
-- return DDS_RETCODE_BAD_PARAMETER;
-- }
--
-- DDS_GUID_copy(¶ms->related_sample_identity.writer_guid,
-- &related_request_info->writer_guid);
--
-- params->related_sample_identity.sequence_number =
-- related_request_info->sequence_number;
-- return DDS_RETCODE_OK;
--
-- }
function RTI_Connext_ReplierUntypedImpl_Configure_Params_For_Reply
(Self : not null access RTI_Connext_ReplierUntypedImpl;
Params : in out WriteParams_T;
Related_Request_Info : DDS.SampleIdentity_T) return DDS.ReturnCode_T is
begin
if Related_Request_Info = AUTO_SAMPLE_IDENTITY then
return DDS.RETCODE_BAD_PARAMETER;
end if;
Params.Related_Sample_Identity := Related_Request_Info;
return DDS.RETCODE_OK;
end;
-- DDS_ReturnCode_t RTI_Connext_ReplierUntypedImpl_send_sample(
-- RTI_Connext_ReplierUntypedImpl * self,
-- const void * data,
-- const struct DDS_SampleIdentity_t * related_request_info,
-- struct DDS_WriteParams_t * writeParams)
-- {
-- DDS_ReturnCode_t retcode = DDS_RETCODE_OK;
--
-- retcode = RTI_Connext_ReplierUntypedImpl_configure_params_for_reply(
-- self, writeParams, related_request_info);
--
-- if(retcode != DDS_RETCODE_OK)
-- {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "failure on Writing reply");
-- return retcode;
-- }
-- retcode = DDS_DataWriter_write_w_params_untypedI(
-- self->_writer, data, writeParams);
--
-- if(retcode != DDS_RETCODE_OK) {
-- DDSLog_exception(&RTI_LOG_ANY_FAILURE_s,
-- "failure on Writing reply");
-- }
-- return retcode;
-- }
function RTI_Connext_ReplierUntypedImpl_Send_Sample
(Self : not null access RTI_Connext_ReplierUntypedImpl;
Data : System.Address;
Related_Request_Info : DDS.SampleIdentity_T;
WriteParams : in out DDS.WriteParams_T) return DDS.ReturnCode_T is
Retcode : DDS.ReturnCode_T;
begin
retcode := RTI_Connext_ReplierUntypedImpl_Configure_Params_For_Reply
(Self,
WriteParams,
Related_Request_Info);
if retcode = DDS.RETCODE_OK then
return Self.Writer.Write_W_Params (Instance_Data => Data, Params => WriteParams);
else
return Retcode;
end if;
end;
end DDS.Request_Reply.Replieruntypedimpl;
|
onox/orka | Ada | 743 | ads | -- 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.
package Orka.SIMD.SSE4_1.Singles is
pragma Pure;
end Orka.SIMD.SSE4_1.Singles;
|
yannickmoy/atomic | Ada | 11,931 | ads | generic
type T is mod <>;
package Atomic.Generic8
with Preelaborate, Spark_Mode => On
is
-- Based on GCC atomic built-ins. See:
-- https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
--
-- The specification is exactly the same for all sizes of data (8, 16, 32,
-- 64).
type Instance is limited private;
-- This type is limited and private, it can only be manipulated using the
-- primitives below.
function Init (Val : T) return Instance
with Post => Value (Init'Result) = Val;
-- Can be used to initialize an atomic instance:
--
-- A : Atomic.Unsigned_8.Instance := Atomic.Unsigned_8.Init (0);
function Value (This : Instance) return T
with Ghost;
-- Ghost function to get the value of an instance without needing it
-- aliased. This function can be used in contracts for instance.
-- This doesn't use the atomic built-ins.
function Load (This : aliased Instance;
Order : Mem_Order := Seq_Cst)
return T
with Pre => Order in Relaxed | Consume | Acquire | Seq_Cst,
Post => Load'Result = Value (This);
procedure Store (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Pre => Order in Relaxed | Release | Seq_Cst,
Post => Value (This) = Val;
procedure Exchange (This : aliased in out Instance;
Val : T;
Old : out T;
Order : Mem_Order := Seq_Cst)
with Pre => Order in Relaxed | Acquire | Release | Acq_Rel | Seq_Cst,
Post => Old = Value (This)'Old and then Value (This) = Val;
procedure Compare_Exchange (This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success : out Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst)
with Pre => Failure_Order in Relaxed | Consume | Acquire | Seq_Cst
and then
not Stronger (Failure_Order, Success_Order),
Post => Success = (Value (This)'Old = Expected)
and then
(if Success then Value (This) = Desired);
procedure Add (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = Value (This)'Old + Val;
procedure Sub (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = Value (This)'Old - Val;
procedure Op_And (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old and Val);
procedure Op_XOR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old xor Val);
procedure Op_OR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = (Value (This)'Old or Val);
procedure NAND (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
with Post => Value (This) = not (Value (This)'Old and Val);
procedure Add_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old + Val)
and then Value (This) = Result;
procedure Sub_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old - Val)
and then Value (This) = Result;
procedure And_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old and Val)
and then Value (This) = Result;
procedure XOR_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old xor Val)
and then Value (This) = Result;
procedure OR_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = (Value (This)'Old or Val)
and then Value (This) = Result;
procedure NAND_Fetch (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = not (Value (This)'Old and Val)
and then Value (This) = Result;
procedure Fetch_Add (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old + Val);
procedure Fetch_Sub (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old - Val);
procedure Fetch_And (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old and Val);
procedure Fetch_XOR (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old xor Val);
procedure Fetch_OR (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = (Value (This)'Old or Val);
procedure Fetch_NAND (This : aliased in out Instance;
Val : T;
Result : out T;
Order : Mem_Order := Seq_Cst)
with Post => Result = Value (This)'Old
and Value (This) = not (Value (This)'Old and Val);
-- NOT SPARK compatible --
function Exchange (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Exchange'Result = Value (This)'Old
and then Value (This) = Val;
function Compare_Exchange (This : aliased in out Instance;
Expected : T;
Desired : T;
Weak : Boolean;
Success_Order : Mem_Order := Seq_Cst;
Failure_Order : Mem_Order := Seq_Cst)
return Boolean
with SPARK_Mode => Off,
Post =>
Compare_Exchange'Result = (Value (This)'Old = Expected)
and then
(if Compare_Exchange'Result then Value (This) = Desired);
function Add_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Add_Fetch'Result = (Value (This)'Old + Val)
and then Value (This) = Add_Fetch'Result;
function Sub_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => Sub_Fetch'Result = (Value (This)'Old - Val)
and then Value (This) = Sub_Fetch'Result;
function And_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => And_Fetch'Result = (Value (This)'Old and Val)
and then Value (This) = And_Fetch'Result;
function XOR_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => XOR_Fetch'Result = (Value (This)'Old xor Val)
and then Value (This) = XOR_Fetch'Result;
function OR_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => OR_Fetch'Result = (Value (This)'Old or Val)
and then Value (This) = OR_Fetch'Result;
function NAND_Fetch (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off,
Post => NAND_Fetch'Result = not (Value (This)'Old and Val)
and then Value (This) = NAND_Fetch'Result;
function Fetch_Add (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_Sub (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_And (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_XOR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_OR (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
function Fetch_NAND (This : aliased in out Instance;
Val : T;
Order : Mem_Order := Seq_Cst)
return T
with SPARK_Mode => Off;
private
type Instance is new T;
----------
-- Init --
----------
function Init (Val : T) return Instance
is (Instance (Val));
-----------
-- Value --
-----------
function Value (This : Instance) return T
is (T (This));
pragma Inline (Init);
pragma Inline (Load);
pragma Inline (Store);
pragma Inline (Exchange);
pragma Inline (Compare_Exchange);
pragma Inline (Add);
pragma Inline (Sub);
pragma Inline (Add_Fetch);
pragma Inline (Sub_Fetch);
pragma Inline (Fetch_Add);
pragma Inline (Fetch_Sub);
pragma Inline (Op_And);
pragma Inline (Op_XOR);
pragma Inline (Op_OR);
pragma Inline (NAND);
pragma Inline (And_Fetch);
pragma Inline (XOR_Fetch);
pragma Inline (OR_Fetch);
pragma Inline (NAND_Fetch);
pragma Inline (Fetch_And);
pragma Inline (Fetch_XOR);
pragma Inline (Fetch_OR);
pragma Inline (Fetch_NAND);
end Atomic.Generic8;
|
reznikmm/matreshka | Ada | 3,704 | 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_Overlap_Attributes is
pragma Preelaborate;
type ODF_Chart_Overlap_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Overlap_Attribute_Access is
access all ODF_Chart_Overlap_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Overlap_Attributes;
|
sungyeon/drake | Ada | 5,912 | adb | with Ada.IO_Exceptions;
with Ada.Environment_Encoding.Encoding_Streams;
with Ada.Environment_Encoding.Names;
with Ada.Environment_Encoding.Strings;
with Ada.Environment_Encoding.Wide_Strings;
with Ada.Environment_Encoding.Wide_Wide_Strings;
with Ada.Streams.Unbounded_Storage_IO;
procedure nls is
package USIO renames Ada.Streams.Unbounded_Storage_IO;
use type Ada.Streams.Stream_Element_Array;
use type Ada.Streams.Stream_Element_Offset;
Japanease_A : constant String := (
Character'Val (16#e3#),
Character'Val (16#81#),
Character'Val (16#82#));
Mongolian_Birga : constant String := (
Character'Val (16#e1#),
Character'Val (16#a0#),
Character'Val (16#80#));
begin
Ada.Debug.Put (Ada.Environment_Encoding.Image (Ada.Environment_Encoding.Current_Encoding));
-- status check
declare
E : Ada.Environment_Encoding.Strings.Encoder;
pragma Warnings (Off, E);
begin
if Ada.Environment_Encoding.Strings.Encode (E, "") = (1 .. 0 => <>) then
null;
end if;
raise Program_Error; -- bad
exception
when Ada.Environment_Encoding.Status_Error =>
null;
end;
-- decoding
declare
D : Ada.Environment_Encoding.Strings.Decoder :=
Ada.Environment_Encoding.Strings.From (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Strings.Decode (D, (1 .. 0 => <>)) = "");
pragma Assert (Ada.Environment_Encoding.Strings.Decode (D, (1 => 16#41#)) = "A");
pragma Assert (Ada.Environment_Encoding.Strings.Decode (D, (16#41#, 16#42#)) = "AB");
pragma Assert (Ada.Environment_Encoding.Strings.Decode (D, (16#82#, 16#a0#)) = Japanease_A);
null;
end;
declare
WD : Ada.Environment_Encoding.Wide_Strings.Decoder :=
Ada.Environment_Encoding.Wide_Strings.From (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Wide_Strings.Decode (WD, (16#41#, 16#42#)) = "AB");
null;
end;
declare
WWD : Ada.Environment_Encoding.Wide_Wide_Strings.Decoder :=
Ada.Environment_Encoding.Wide_Wide_Strings.From (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Wide_Wide_Strings.Decode (WWD, (16#41#, 16#42#)) = "AB");
null;
end;
-- encoding
declare
E : Ada.Environment_Encoding.Strings.Encoder :=
Ada.Environment_Encoding.Strings.To (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Strings.Encode (E, "") = (1 .. 0 => <>));
pragma Assert (Ada.Environment_Encoding.Strings.Encode (E, "A") = (1 => 16#41#));
pragma Assert (Ada.Environment_Encoding.Strings.Encode (E, "AB") = (16#41#, 16#42#));
pragma Assert (Ada.Environment_Encoding.Strings.Encode (E, Japanease_A) = (16#82#, 16#a0#));
-- substitute
declare
Default : constant Ada.Streams.Stream_Element_Array := Ada.Environment_Encoding.Strings.Substitute (E);
Mongolian_Birga_In_Windows_31J : constant Ada.Streams.Stream_Element_Array :=
Ada.Environment_Encoding.Strings.Encode (E, Mongolian_Birga);
begin
pragma Assert (Mongolian_Birga_In_Windows_31J = Default
or else Mongolian_Birga_In_Windows_31J = Default & Default & Default);
null;
end;
Ada.Environment_Encoding.Strings.Set_Substitute (E, (16#81#, 16#51#)); -- fullwidth low line in Windows-31J
declare
Mongolian_Birga_In_Windows_31J : constant Ada.Streams.Stream_Element_Array :=
Ada.Environment_Encoding.Strings.Encode (E, Mongolian_Birga);
begin
pragma Assert (Mongolian_Birga_In_Windows_31J = (16#81#, 16#51#)
or else Mongolian_Birga_In_Windows_31J = (16#81#, 16#51#, 16#81#, 16#51#, 16#81#, 16#51#));
null;
end;
end;
declare
WE : Ada.Environment_Encoding.Wide_Strings.Encoder :=
Ada.Environment_Encoding.Wide_Strings.To (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Wide_Strings.Encode (WE, "AB") = (16#41#, 16#42#));
null;
end;
declare
WWE : Ada.Environment_Encoding.Wide_Wide_Strings.Encoder :=
Ada.Environment_Encoding.Wide_Wide_Strings.To (Ada.Environment_Encoding.Names.Windows_31J);
begin
pragma Assert (Ada.Environment_Encoding.Wide_Wide_Strings.Encode (WWE, "AB") = (16#41#, 16#42#));
null;
end;
-- reading
declare
Buffer : USIO.Buffer_Type;
E : aliased Ada.Environment_Encoding.Encoding_Streams.Inout_Type :=
Ada.Environment_Encoding.Encoding_Streams.Open (
Ada.Environment_Encoding.Names.UTF_8,
Ada.Environment_Encoding.Names.Windows_31J,
USIO.Stream (Buffer));
S : String (1 .. 3);
One_Element : String (1 .. 1);
begin
for I in 1 .. 100 loop
Ada.Streams.Write (
USIO.Stream (Buffer).all,
(16#82#, 16#a0#));
end loop;
Ada.Streams.Set_Index (
Ada.Streams.Seekable_Stream_Type'Class (USIO.Stream (Buffer).all),
1);
for I in 1 .. 100 loop
String'Read (
Ada.Environment_Encoding.Encoding_Streams.Stream (E),
S);
pragma Assert (S = Japanease_A);
end loop;
begin
String'Read (
Ada.Environment_Encoding.Encoding_Streams.Stream (E),
One_Element);
raise Program_Error;
exception
when Ada.IO_Exceptions.End_Error =>
null;
end;
end;
-- writing
declare
Buffer : USIO.Buffer_Type;
E : aliased Ada.Environment_Encoding.Encoding_Streams.Inout_Type :=
Ada.Environment_Encoding.Encoding_Streams.Open (
Ada.Environment_Encoding.Names.Windows_31J,
Ada.Environment_Encoding.Names.UTF_8,
USIO.Stream (Buffer));
S : String (1 .. 3);
begin
for I in 1 .. 100 loop
Ada.Streams.Write (
Ada.Environment_Encoding.Encoding_Streams.Stream (E).all,
(16#82#, 16#a0#));
end loop;
Ada.Environment_Encoding.Encoding_Streams.Finish (E);
Ada.Streams.Set_Index (
Ada.Streams.Seekable_Stream_Type'Class (USIO.Stream (Buffer).all),
1);
pragma Assert (USIO.Size (Buffer) = 300);
for I in 1 .. 100 loop
String'Read (
USIO.Stream (Buffer),
S);
pragma Assert (S = Japanease_A);
end loop;
end;
pragma Debug (Ada.Debug.Put ("OK"));
end nls;
|
reznikmm/matreshka | Ada | 4,796 | 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.Table_Named_Expression_Elements;
package Matreshka.ODF_Table.Named_Expression_Elements is
type Table_Named_Expression_Element_Node is
new Matreshka.ODF_Table.Abstract_Table_Element_Node
and ODF.DOM.Table_Named_Expression_Elements.ODF_Table_Named_Expression
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Named_Expression_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Named_Expression_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Table_Named_Expression_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 Table_Named_Expression_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 Table_Named_Expression_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_Table.Named_Expression_Elements;
|
zyron92/banana_tree_generator | Ada | 771 | adb | with Parseur_Temp, Geometry_Helpers, Ada.Text_Io, Ada.Integer_Text_Io;
use Parseur_Temp, Geometry_Helpers, Ada.Text_Io, Ada.Integer_Text_Io;
procedure Test_Geometry is
P1,P2,P3,P4,P5 : Coord_Point;
begin
P1 := (0.0,0.0);
P4 := (-1.0,-1.0);
P2 := (0.0,2.0);
P3:= (1.0,-1.0);
P5 := (1.0,-1.0);
Put_Line("1-2,1-3 : "&Float'Image(Angle_Intersection_Arrete(Vecteur(P1,P2),Vecteur(P1,P3),P1,P2,P3,true)));
--Put_Line("1-2,1-4 : "&Float'Image(Angle_Intersection_Arrete(Vecteur(P1,P2),Vecteur(P1,P4),P1,P2,P4)));
--Put_Line("1-2,1-5 : "&Float'Image(Angle_Intersection_Arrete(Vecteur(P1,P2),Vecteur(P1,P5),P1,P2,P5)));
--Res:=Projection(P4,P5,P5);
--Put_Line("Voila : "&Float'Image(Res.X)&" "&Float'Image(Res.Y));
end Test_Geometry;
|
reznikmm/matreshka | Ada | 5,154 | 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.
------------------------------------------------------------------------------
-- The most general class for UML diagram elements that are rendered as lines.
------------------------------------------------------------------------------
with AMF.DI.Edges;
with AMF.UMLDI.UML_Diagram_Elements;
package AMF.UMLDI.UML_Edges is
pragma Preelaborate;
type UMLDI_UML_Edge is limited interface
and AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element
and AMF.DI.Edges.DI_Edge;
type UMLDI_UML_Edge_Access is
access all UMLDI_UML_Edge'Class;
for UMLDI_UML_Edge_Access'Storage_Size use 0;
not overriding function Get_Source
(Self : not null access constant UMLDI_UML_Edge)
return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access is abstract;
-- Getter of UMLEdge::source.
--
-- Restricts the sources of UMLEdges to UMLDiagramElements.
not overriding procedure Set_Source
(Self : not null access UMLDI_UML_Edge;
To : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access) is abstract;
-- Setter of UMLEdge::source.
--
-- Restricts the sources of UMLEdges to UMLDiagramElements.
not overriding function Get_Target
(Self : not null access constant UMLDI_UML_Edge)
return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access is abstract;
-- Getter of UMLEdge::target.
--
-- Restricts the targets of UMLEdges to UMLDiagramElements.
not overriding procedure Set_Target
(Self : not null access UMLDI_UML_Edge;
To : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access) is abstract;
-- Setter of UMLEdge::target.
--
-- Restricts the targets of UMLEdges to UMLDiagramElements.
end AMF.UMLDI.UML_Edges;
|
jrcarter/Ada_GUI | Ada | 4,842 | ads | -- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Streams Luebeck --
-- Interface Spring, 2009 --
-- --
-- Last revision : 14:23 11 Feb 2012 --
-- --
-- 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. --
--____________________________________________________________________--
--
-- The package provides stream interface to string. A string can be
-- read and written using stream I/O attributes.
--
with Ada.Streams; use Ada.Streams;
with System.Storage_Elements;
package Strings_Edit.Streams is
--
-- String_Stream -- A string stream, when read, Data (Position..Length)
-- is amount of data available to read/write. Note that
-- before reading from the stream is must be initialized using Set.
-- Otherwise the result of reading will be the unitialized contents of
-- the Data field.
--
type String_Stream (Length : Natural) is
new Root_Stream_Type with
record
Position : Positive := 1;
Data : String (1..Length);
end record;
--
-- Get -- Written contents of the stream
--
-- Stream - The stream object
--
-- Get is an operation inverse to T'Write.
--
-- Returns :
--
-- String written
--
function Get (Stream : String_Stream) return String;
--
-- Get_Size -- Number of stream elements available to write or to read
--
-- Stream - The stream object
--
function Get_Size (Stream : String_Stream)
return Stream_Element_Count;
--
-- Read -- Overrides Ada.Streams...
--
procedure Read
( Stream : in out String_Stream;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset
);
--
-- Rewind -- The stream
--
-- Stream - The stream object
--
-- This procedure moves Stream.Position to the beginning. This undoes
-- all reading/writing actions.
--
procedure Rewind (Stream : in out String_Stream);
--
-- Set -- Contents
--
-- Stream - The stream object
-- Content - String to read
--
-- The stream is changed to contain Content. The next read operation
-- will yield the first character of Content. Set is an operation
-- inverse to T'Read.
--
-- Exceptions :
--
-- Contraint_Error - no room in Stream
--
procedure Set (Stream : in out String_Stream; Content : String);
--
-- Write -- Overrides Ada.Streams...
--
-- Exceptions :
--
-- End_Error - No room in the string
--
procedure Write
( Stream : in out String_Stream;
Item : Stream_Element_Array
);
private
use System.Storage_Elements;
pragma Inline (Get_Size);
--
-- Char_Count -- Number of characters per string elements
--
Char_Count : constant := Stream_Element'Size / Character'Size;
--
-- Stream_Element'Size must be a multiple of Character'Size and the
-- later be a multiple of Storage_Element'Size.
--
subtype Confirmed is Boolean range True..True;
Assert : constant Confirmed :=
( Char_Count * Character'Size = Stream_Element'Size
and then
Character'Size mod Storage_Element'Size = 0
);
end Strings_Edit.Streams;
|
MinimSecure/unum-sdk | Ada | 1,097 | adb | -- Copyright 2006-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
function Create_Small return Data_Small is
begin
return (others => 1);
end Create_Small;
function Create_Large return Data_Large is
begin
return (others => 2);
end Create_Large;
function Create_Small_Float_Vector return Small_Float_Vector is
begin
return (others => 4.25);
end Create_Small_Float_Vector;
end Pck;
|
reznikmm/matreshka | Ada | 4,688 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- SQL Database Access --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Implementation of Abstract_Database type for SQLite3 database.
------------------------------------------------------------------------------
package Matreshka.Internals.SQL_Drivers.SQLite3.Databases is
type SQLite3_Database is new Abstract_Database with private;
function Database_Handle
(Self : not null access constant SQLite3_Database'Class)
return sqlite3_Access;
pragma Inline (Database_Handle);
-- Returns database handle for SQLite3 library API.
private
type SQLite3_Database is new Abstract_Database with record
Handle : aliased sqlite3_Access;
Error : League.Strings.Universal_String;
Success : Boolean := True;
end record;
overriding procedure Close (Self : not null access SQLite3_Database);
overriding procedure Commit (Self : not null access SQLite3_Database);
overriding function Error_Message
(Self : not null access SQLite3_Database)
return League.Strings.Universal_String;
overriding procedure Finalize (Self : not null access SQLite3_Database);
overriding function Open
(Self : not null access SQLite3_Database;
Options : SQL.Options.SQL_Options) return Boolean;
overriding function Query
(Self : not null access SQLite3_Database) return not null Query_Access;
end Matreshka.Internals.SQL_Drivers.SQLite3.Databases;
|
AdaCore/libadalang | Ada | 99 | adb | procedure Pkg.Child_Subp is
Origin_Pkg_Child_Subp : Integer;
begin
null;
end Pkg.Child_Subp;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.